From: Michael Stapelberg Date: Wed, 3 Jun 2009 11:54:13 +0000 (+0200) Subject: Implement moving floating clients using Mod1+Left mouse button X-Git-Tag: 3.b~70 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fb63c2ed5888c5a9355c58b3045396d9843fe8ea;p=i3%2Fi3 Implement moving floating clients using Mod1+Left mouse button --- diff --git a/src/handlers.c b/src/handlers.c index 92ad73cb..250465d1 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -294,6 +294,7 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) { LOG("button press!\n"); + LOG("state = %d\n", event->state); /* This was either a focus for a client’s parent (= titlebar)… */ Client *client = table_get(&by_child, event->event); bool border_click = false; @@ -301,6 +302,19 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ client = table_get(&by_parent, event->event); border_click = true; } + /* See if this was a click with Mod1. If so, we need to move around + * the client if it was floating. if not, we just process as usual. */ + if ((event->state & XCB_MOD_MASK_1) != 0) { + if (client == NULL) { + LOG("Not handling, Mod1 was pressed and no client found\n"); + return 1; + } + if (client->floating) { + floating_drag_window(conn, client, event); + return 1; + } + } + if (client == NULL) { /* The client was neither on a client’s titlebar nor on a client itself, maybe on a stack_window? */ if (button_press_stackwin(conn, event)) diff --git a/src/manage.c b/src/manage.c index 9a26f214..de258c01 100644 --- a/src/manage.c +++ b/src/manage.c @@ -235,6 +235,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, 1 /* left mouse button */, XCB_BUTTON_MASK_ANY /* don’t filter for any modifiers */); + xcb_grab_button(conn, false, child, XCB_EVENT_MASK_BUTTON_PRESS, + XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, root, XCB_NONE, + 1 /* left mouse button */, XCB_MOD_MASK_1); + /* Get _NET_WM_WINDOW_TYPE (to see if it’s a dock) */ xcb_atom_t *atom; xcb_get_property_reply_t *preply = xcb_get_property_reply(conn, wm_type_cookie, NULL);