From 99054fb50fc1aef65e7e88d4a944539230404a76 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 2 May 2009 20:51:55 +0200 Subject: [PATCH] Bugfix: Fix drag&drop in GTK applications (firefox, thunderbird) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Daniel Wäber’s contribution to wmii: http://code.suckless.org/hg/wmii/rev/f4f25de0de54 --- include/i3.h | 2 +- include/xcb.h | 8 +++++--- src/mainx.c | 5 +++++ src/xcb.c | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/i3.h b/include/i3.h index a3dfc4c0..02df9996 100644 --- a/include/i3.h +++ b/include/i3.h @@ -20,7 +20,7 @@ #ifndef _I3_H #define _I3_H -#define NUM_ATOMS 12 +#define NUM_ATOMS 13 extern char **start_argv; extern Display *xkbdpy; diff --git a/include/xcb.h b/include/xcb.h index bcdd19a1..4001cad7 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -36,8 +36,9 @@ #define FRAME_EVENT_MASK (XCB_EVENT_MASK_BUTTON_PRESS | /* …mouse is pressed/released */ \ XCB_EVENT_MASK_BUTTON_RELEASE | \ XCB_EVENT_MASK_EXPOSURE | /* …our window needs to be redrawn */ \ - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | /* …user moves cursor inside our window */ \ - XCB_EVENT_MASK_ENTER_WINDOW) /* …the application tries to resize itself */ + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | /* …the application tries to resize itself */ \ + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | /* …subwindows get notifies */ \ + XCB_EVENT_MASK_ENTER_WINDOW) /* …user moves cursor inside our window */ enum { _NET_SUPPORTED = 0, @@ -51,7 +52,8 @@ enum { _NET_SUPPORTED = 0, _NET_WM_STRUT_PARTIAL, WM_PROTOCOLS, WM_DELETE_WINDOW, - UTF8_STRING + UTF8_STRING, + WM_STATE }; extern unsigned int xcb_numlock_mask; diff --git a/src/mainx.c b/src/mainx.c index 03390f90..38ae2511 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -187,6 +187,9 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, /* Yo dawg, I heard you like windows, so I create a window around your window… */ new->frame = create_window(conn, framerect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values); + long data[] = { XCB_WM_STATE_NORMAL, XCB_NONE }; + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, new->child, atoms[WM_STATE], atoms[WM_STATE], 32, 2, data); + /* Put the client inside the save set. Upon termination (whether killed or normal exit does not matter) of the window manager, these clients will be correctly reparented to their most closest living ancestor (= cleanup) */ @@ -381,6 +384,7 @@ int main(int argc, char *argv[], char *env[]) { REQUEST_ATOM(WM_PROTOCOLS); REQUEST_ATOM(WM_DELETE_WINDOW); REQUEST_ATOM(UTF8_STRING); + REQUEST_ATOM(WM_STATE); /* TODO: this has to be more beautiful somewhen */ int major, minor, error; @@ -483,6 +487,7 @@ int main(int argc, char *argv[], char *env[]) { GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(UTF8_STRING); + GET_ATOM(WM_STATE); xcb_property_set_handler(&prophs, atoms[_NET_WM_WINDOW_TYPE], UINT_MAX, handle_window_type, NULL); /* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */ diff --git a/src/xcb.c b/src/xcb.c index 708e1ead..10608ac4 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -220,8 +220,8 @@ void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window) void fake_absolute_configure_notify(xcb_connection_t *conn, Client *client) { Rect absolute; - absolute.x = client->rect.x; - absolute.y = client->rect.y; + absolute.x = client->rect.x + client->child_rect.x; + absolute.y = client->rect.y + client->child_rect.y; absolute.width = client->rect.width - (2 * client->child_rect.x); absolute.height = client->rect.height - client->child_rect.y - 1;