glazier

the original window manipulator
Log | Files | Refs | Submodules | README | LICENSE

commit 4ff647b4cf2634c47bef4581ab8f1a4ab753d736
parent 7871aacdb21b40503f548e77e623c4ed1d19cc8b
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 22 Oct 2019 08:17:34 +0200

Make cb_create more robust

When a new window is created, we won't decorate it if it is a frame
window, or if the overrid_redirect bit is set.
We also need to move it somewhere near the cursor to avoid them popping
at the top left, with the decoration outside the screen (which makes it
impossible to drag).

Diffstat:
glazier.c | 22++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/glazier.c b/glazier.c @@ -136,20 +136,30 @@ cb_default(xcb_generic_event_t *ev) static int cb_create(xcb_generic_event_t *ev) { + int x, y, w, h; + static xcb_window_t frame; xcb_create_notify_event_t *e; e = (xcb_create_notify_event_t *)ev; - if (verbose) - fprintf(stderr, "create: 0x%08x\n", e->window); + if (e->override_redirect) { + return 0; + } /* avoid infinite loops when creating frame window */ - if (wid == e->window) + if (frame == e->window) return 0; - wid = frame_window(e->window); - wm_set_focus(wid); - wm_reg_event(e->window, XCB_EVENT_MASK_STRUCTURE_NOTIFY); + if (verbose) + fprintf(stderr, "create: 0x%08x\n", e->window); + frame = frame_window(e->window); + + wm_get_cursor(0, scrn->root, &x, &y); + w = wm_get_attribute(frame, ATTR_W); + h = wm_get_attribute(frame, ATTR_H); + wm_move(frame, ABSOLUTE, x - w/2, y - h/2); + wm_reg_event(e->window, XCB_EVENT_MASK_STRUCTURE_NOTIFY); + wm_set_focus(e->window); return 0; }