Display appropriate cursors when resizing or moving floating windows.
This commit is contained in:
parent
e582e19ffd
commit
b235c469c1
|
@ -134,8 +134,8 @@ void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
|
|||
*
|
||||
*/
|
||||
void drag_pointer(Con *con, const xcb_button_press_event_t *event,
|
||||
xcb_window_t confine_to, border_t border, callback_t callback,
|
||||
const void *extra);
|
||||
xcb_window_t confine_to, border_t border, int cursor,
|
||||
callback_t callback, const void *extra);
|
||||
|
||||
/**
|
||||
* Repositions the CT_FLOATING_CON to have the coordinates specified by
|
||||
|
|
|
@ -16,7 +16,12 @@ enum xcursor_cursor_t {
|
|||
XCURSOR_CURSOR_POINTER = 0,
|
||||
XCURSOR_CURSOR_RESIZE_HORIZONTAL,
|
||||
XCURSOR_CURSOR_RESIZE_VERTICAL,
|
||||
XCURSOR_CURSOR_TOP_LEFT_CORNER,
|
||||
XCURSOR_CURSOR_TOP_RIGHT_CORNER,
|
||||
XCURSOR_CURSOR_BOTTOM_LEFT_CORNER,
|
||||
XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER,
|
||||
XCURSOR_CURSOR_WATCH,
|
||||
XCURSOR_CURSOR_MOVE,
|
||||
XCURSOR_CURSOR_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ void floating_drag_window(Con *con, const xcb_button_press_event_t *event) {
|
|||
tree_render();
|
||||
|
||||
/* Drag the window */
|
||||
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, drag_window_callback, event);
|
||||
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, XCURSOR_CURSOR_MOVE, drag_window_callback, event);
|
||||
tree_render();
|
||||
}
|
||||
|
||||
|
@ -479,13 +479,21 @@ void floating_resize_window(Con *con, const bool proportional,
|
|||
corner |= BORDER_LEFT;
|
||||
else corner |= BORDER_RIGHT;
|
||||
|
||||
if (event->event_y <= (con->rect.height / 2))
|
||||
int cursor = 0;
|
||||
if (event->event_y <= (con->rect.height / 2)) {
|
||||
corner |= BORDER_TOP;
|
||||
else corner |= BORDER_BOTTOM;
|
||||
cursor = (corner & BORDER_LEFT) ?
|
||||
XCURSOR_CURSOR_TOP_LEFT_CORNER : XCURSOR_CURSOR_TOP_RIGHT_CORNER;
|
||||
}
|
||||
else {
|
||||
corner |= BORDER_BOTTOM;
|
||||
cursor = (corner & BORDER_LEFT) ?
|
||||
XCURSOR_CURSOR_BOTTOM_LEFT_CORNER : XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER;
|
||||
}
|
||||
|
||||
struct resize_window_callback_params params = { corner, proportional, event };
|
||||
|
||||
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, resize_window_callback, ¶ms);
|
||||
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, cursor, resize_window_callback, ¶ms);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -497,13 +505,16 @@ void floating_resize_window(Con *con, const bool proportional,
|
|||
*
|
||||
*/
|
||||
void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
|
||||
confine_to, border_t border, callback_t callback, const void *extra)
|
||||
confine_to, border_t border, int cursor, callback_t callback, const void *extra)
|
||||
{
|
||||
uint32_t new_x, new_y;
|
||||
Rect old_rect = { 0, 0, 0, 0 };
|
||||
if (con != NULL)
|
||||
memcpy(&old_rect, &(con->rect), sizeof(Rect));
|
||||
|
||||
Cursor xcursor = (cursor && xcursor_supported) ?
|
||||
xcursor_get_cursor(cursor) : XCB_NONE;
|
||||
|
||||
/* Grab the pointer */
|
||||
xcb_grab_pointer_cookie_t cookie;
|
||||
xcb_grab_pointer_reply_t *reply;
|
||||
|
@ -514,7 +525,7 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
|
|||
XCB_GRAB_MODE_ASYNC, /* pointer events should continue as normal */
|
||||
XCB_GRAB_MODE_ASYNC, /* keyboard mode */
|
||||
confine_to, /* confine_to = in which window should the cursor stay */
|
||||
XCB_NONE, /* don’t display a special cursor */
|
||||
xcursor, /* possibly display a special cursor */
|
||||
XCB_CURRENT_TIME);
|
||||
|
||||
if ((reply = xcb_grab_pointer_reply(conn, cookie, NULL)) == NULL) {
|
||||
|
|
|
@ -106,7 +106,7 @@ int resize_graphical_handler(Con *first, Con *second, orientation_t orientation,
|
|||
|
||||
const struct callback_params params = { orientation, output, helpwin, &new_position };
|
||||
|
||||
drag_pointer(NULL, event, grabwin, BORDER_TOP, resize_callback, ¶ms);
|
||||
drag_pointer(NULL, event, grabwin, BORDER_TOP, 0, resize_callback, ¶ms);
|
||||
|
||||
xcb_destroy_window(conn, helpwin);
|
||||
xcb_destroy_window(conn, grabwin);
|
||||
|
|
|
@ -34,10 +34,15 @@ static Cursor load_cursor(const char *name) {
|
|||
}
|
||||
|
||||
void xcursor_load_cursors(void) {
|
||||
cursors[XCURSOR_CURSOR_POINTER] = load_cursor("left_ptr");
|
||||
cursors[XCURSOR_CURSOR_RESIZE_HORIZONTAL] = load_cursor("sb_h_double_arrow");
|
||||
cursors[XCURSOR_CURSOR_RESIZE_VERTICAL] = load_cursor("sb_v_double_arrow");
|
||||
cursors[XCURSOR_CURSOR_WATCH] = load_cursor("watch");
|
||||
cursors[XCURSOR_CURSOR_POINTER] = load_cursor("left_ptr");
|
||||
cursors[XCURSOR_CURSOR_RESIZE_HORIZONTAL] = load_cursor("sb_h_double_arrow");
|
||||
cursors[XCURSOR_CURSOR_RESIZE_VERTICAL] = load_cursor("sb_v_double_arrow");
|
||||
cursors[XCURSOR_CURSOR_WATCH] = load_cursor("watch");
|
||||
cursors[XCURSOR_CURSOR_MOVE] = load_cursor("fleur");
|
||||
cursors[XCURSOR_CURSOR_TOP_LEFT_CORNER] = load_cursor("top_left_corner");
|
||||
cursors[XCURSOR_CURSOR_TOP_RIGHT_CORNER] = load_cursor("top_right_corner");
|
||||
cursors[XCURSOR_CURSOR_BOTTOM_LEFT_CORNER] = load_cursor("bottom_left_corner");
|
||||
cursors[XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER] = load_cursor("bottom_right_corner");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue