Implement moving floating clients using Mod1+Left mouse button

next
Michael Stapelberg 2009-06-03 13:54:13 +02:00
parent 036728c4d7
commit fb63c2ed58
2 changed files with 18 additions and 0 deletions

View File

@ -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 clients 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 clients titlebar nor on a client itself, maybe on a stack_window? */
if (button_press_stackwin(conn, event))

View File

@ -235,6 +235,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
1 /* left mouse button */,
XCB_BUTTON_MASK_ANY /* dont 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 its a dock) */
xcb_atom_t *atom;
xcb_get_property_reply_t *preply = xcb_get_property_reply(conn, wm_type_cookie, NULL);