From a2d20b6848feee70b3a013eac8ddb0a021b3fc27 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 11 Apr 2009 22:37:48 +0200 Subject: [PATCH] Bugfix: Send clients their absolute position/size in generated configure events, not relative This fixes ticket #26. --- include/xcb.h | 7 +++++++ src/handlers.c | 2 +- src/layout.c | 8 ++++---- src/util.c | 2 +- src/xcb.c | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/xcb.h b/include/xcb.h index 83069e45..bcdd19a1 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -110,6 +110,13 @@ void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext */ void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window); +/** + * Generates a configure_notify_event with absolute coordinates (relative to the X root + * window, not to the client’s frame) for the given client. + * + */ +void fake_absolute_configure_notify(xcb_connection_t *conn, Client *client); + /** * Finds out which modifier mask is the one for numlock, as the user may change this. * diff --git a/src/handlers.c b/src/handlers.c index 7ca05686..a9aaf8c3 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -542,7 +542,7 @@ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure return 1; } - fake_configure_notify(conn, client->child_rect, client->child); + fake_absolute_configure_notify(conn, client); return 1; } diff --git a/src/layout.c b/src/layout.c index 23f47cfd..a3690ad6 100644 --- a/src/layout.c +++ b/src/layout.c @@ -261,10 +261,10 @@ static void resize_client(xcb_connection_t *conn, Client *client) { xcb_configure_window(conn, client->child, mask, &(rect->x)); - /* After configuring a child window we need to fake a configure_notify_event according - to ICCCM 4.2.3. This seems rather broken, especially since X sends exactly the same - configure_notify_event automatically according to xtrace. Anyone knows details? */ - fake_configure_notify(conn, *rect, client->child); + /* After configuring a child window we need to fake a configure_notify_event (see ICCCM 4.2.3). + * This is necessary to inform the client of its position relative to the root window, + * not relative to its frame (as done in the configure_notify_event by the x server). */ + fake_absolute_configure_notify(conn, client); } /* diff --git a/src/util.c b/src/util.c index 1ac3357d..63b929c0 100644 --- a/src/util.c +++ b/src/util.c @@ -396,7 +396,7 @@ void toggle_fullscreen(xcb_connection_t *conn, Client *client) { Rect child_rect = workspace->rect; child_rect.x = child_rect.y = 0; - fake_configure_notify(conn, child_rect, client->child); + fake_absolute_configure_notify(conn, client); } else { LOG("leaving fullscreen mode\n"); /* Because the coordinates of the window haven’t changed, it would not be diff --git a/src/xcb.c b/src/xcb.c index 383500c7..0b4531c9 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -212,6 +212,22 @@ void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window) LOG("Told the client it is at %dx%d with %dx%d\n", r.x, r.y, r.width, r.height); } +/* + * Generates a configure_notify_event with absolute coordinates (relative to the X root + * window, not to the client’s frame) for the given client. + * + */ +void fake_absolute_configure_notify(xcb_connection_t *conn, Client *client) { + Rect absolute; + + absolute.x = client->rect.x; + absolute.y = client->rect.y; + absolute.width = client->rect.width - client->child_rect.x; + absolute.height = client->rect.height - client->child_rect.y; + + fake_configure_notify(conn, absolute, client->child); +} + /* * Finds out which modifier mask is the one for numlock, as the user may change this. * -- 2.39.5