commit 828f56fdbab6f62eed068f8ee0d9587e05fad15d
parent b48ed0964d63aa5b11c449f810d48535702320f5
Author: Willy Goiffon <dev@z3bra.org>
Date: Tue, 22 Oct 2019 08:24:39 +0200
Add new callback for CONFIGURE events
The goal here is to resize the frame window whenever it's direct child
is resized/moved.
When such an event occur, the frame will receive a "CONFIGURE_NOTIFY"
event with the new dimension/position of the window.
We need to take extra care with such events, because when we resize
the frame window, we also force resizing the child, and that triggers
a configure event. The quick and dirty way is to not handle these events
when a window is selected (`curwid` is set) and being dragged with
the cursor.
Diffstat:
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/glazier.c b/glazier.c
@@ -46,6 +46,7 @@ static const struct ev_callback_t cb[] = {
{ XCB_BUTTON_RELEASE, cb_mouse_release },
{ XCB_MOTION_NOTIFY, cb_motion },
{ XCB_ENTER_NOTIFY, cb_enter },
+ { XCB_CONFIGURE_NOTIFY, cb_configure },
{ NO_EVENT, cb_default },
};
@@ -337,6 +338,34 @@ cb_enter(xcb_generic_event_t *ev)
}
static int
+cb_configure(xcb_generic_event_t *ev)
+{
+ int x, y;
+ xcb_window_t frame;
+ xcb_configure_notify_event_t *e;
+
+ e = (xcb_configure_notify_event_t *)ev;
+
+ if (e->window == e->event || e->event == scrn->root || e->override_redirect || curwid != scrn->root)
+ return 0;
+
+ frame = get_frame(e->window);
+
+ if (verbose)
+ fprintf(stderr, "configure: 0x%08x (0x%08x: %dx%d+%d+%d)\n",
+ frame, e->window,
+ e->width, e->height,
+ e->x, e->y);
+
+ x = wm_get_attribute(frame, ATTR_X);
+ y = wm_get_attribute(frame, ATTR_Y);
+ wm_teleport(e->window, 0, titlebar, e->width, e->height);
+ wm_teleport(get_frame(e->window), x + e->x, y + e->y + titlebar, e->width, e->height + titlebar);
+
+ return 0;
+}
+
+static int
ev_callback(xcb_generic_event_t *ev)
{
uint8_t i;