Implement resizing floating clients with Mod1 + right mouse button
This commit is contained in:
parent
32532792cd
commit
c7ba95e79d
|
@ -55,6 +55,15 @@ int floating_border_click(xcb_connection_t *conn, Client *client,
|
|||
void floating_drag_window(xcb_connection_t *conn, Client *client,
|
||||
xcb_button_press_event_t *event);
|
||||
|
||||
/**
|
||||
* Called when the user right-clicked on the titlebar of a floating window to
|
||||
* resize it.
|
||||
* Calls the drag_pointer function with the resize_window callback
|
||||
*
|
||||
*/
|
||||
void floating_resize_window(xcb_connection_t *conn, Client *client,
|
||||
xcb_button_press_event_t *event);
|
||||
|
||||
/**
|
||||
* Changes focus in the given direction for floating clients.
|
||||
*
|
||||
|
|
|
@ -255,10 +255,37 @@ void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_pre
|
|||
/* fake_absolute_configure_notify flushes */
|
||||
}
|
||||
|
||||
|
||||
drag_pointer(conn, client, event, XCB_NONE, BORDER_TOP /* irrelevant */, drag_window_callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the user right-clicked on the titlebar of a floating window to
|
||||
* resize it.
|
||||
* Calls the drag_pointer function with the resize_window callback
|
||||
*
|
||||
*/
|
||||
void floating_resize_window(xcb_connection_t *conn, Client *client, xcb_button_press_event_t *event) {
|
||||
LOG("floating_resize_window\n");
|
||||
|
||||
void resize_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) {
|
||||
int32_t new_width = old_rect->width + (new_x - event->root_x);
|
||||
int32_t new_height = old_rect->height + (new_y - event->root_y);
|
||||
/* Obey minimum window size */
|
||||
if (new_width < 75 || new_height < 50)
|
||||
return;
|
||||
|
||||
/* Reposition the client correctly while moving */
|
||||
client->rect.width = new_width;
|
||||
client->rect.height = new_height;
|
||||
|
||||
/* resize_client flushes */
|
||||
resize_client(conn, client);
|
||||
}
|
||||
|
||||
drag_pointer(conn, client, event, XCB_NONE, BORDER_TOP /* irrelevant */, resize_window_callback);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function grabs your pointer and lets you drag stuff around (borders).
|
||||
* Every time you move your mouse, an XCB_MOTION_NOTIFY event will be received
|
||||
|
|
|
@ -380,7 +380,14 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
|
|||
return 1;
|
||||
}
|
||||
if (client_is_floating(client)) {
|
||||
floating_drag_window(conn, client, event);
|
||||
LOG("button %d pressed\n", event->detail);
|
||||
if (event->detail == 1) {
|
||||
LOG("left mouse button, dragging\n");
|
||||
floating_drag_window(conn, client, event);
|
||||
} else if (event->detail == 3) {
|
||||
LOG("right mouse button\n");
|
||||
floating_resize_window(conn, client, event);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,6 +233,11 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
|
|||
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, root, XCB_NONE,
|
||||
1 /* left mouse button */, XCB_MOD_MASK_1);
|
||||
|
||||
xcb_grab_button(conn, false, child, XCB_EVENT_MASK_BUTTON_PRESS,
|
||||
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, root, XCB_NONE,
|
||||
3 /* right 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);
|
||||
|
|
Loading…
Reference in New Issue