avoid setting duplicate cursor image
Reference: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3436 Based on: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3595
This commit is contained in:
parent
c13d948ea9
commit
b5776e5180
1 changed files with 15 additions and 10 deletions
25
dwl.c
25
dwl.c
|
@ -298,6 +298,7 @@ static void zoom(const Arg *arg);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
|
static const char *cursor_image = "left_ptr";
|
||||||
static pid_t child_pid = -1;
|
static pid_t child_pid = -1;
|
||||||
static void *exclusive_focus;
|
static void *exclusive_focus;
|
||||||
static struct wl_display *dpy;
|
static struct wl_display *dpy;
|
||||||
|
@ -674,10 +675,13 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||||
break;
|
break;
|
||||||
case WLR_BUTTON_RELEASED:
|
case WLR_BUTTON_RELEASED:
|
||||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||||
/* TODO should reset to the pointer focus's current setcursor */
|
|
||||||
if (cursor_mode != CurNormal) {
|
if (cursor_mode != CurNormal) {
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor);
|
|
||||||
cursor_mode = CurNormal;
|
cursor_mode = CurNormal;
|
||||||
|
/* Clear the pointer focus, this way if the cursor is over a surface
|
||||||
|
* we will send an enter event after which the client will provide us
|
||||||
|
* a cursor surface */
|
||||||
|
wlr_seat_pointer_clear_focus(seat);
|
||||||
|
motionnotify(0);
|
||||||
/* Drop the window off on its new monitor */
|
/* Drop the window off on its new monitor */
|
||||||
selmon = xytomon(cursor->x, cursor->y);
|
selmon = xytomon(cursor->x, cursor->y);
|
||||||
setmon(grabc, selmon, 0);
|
setmon(grabc, selmon, 0);
|
||||||
|
@ -1531,8 +1535,8 @@ motionnotify(uint32_t time)
|
||||||
/* If there's no client surface under the cursor, set the cursor image to a
|
/* If there's no client surface under the cursor, set the cursor image to a
|
||||||
* default. This is what makes the cursor image appear when you move it
|
* default. This is what makes the cursor image appear when you move it
|
||||||
* off of a client or over its border. */
|
* off of a client or over its border. */
|
||||||
if (!surface)
|
if (!surface && (!cursor_image || strcmp(cursor_image, "left_ptr")))
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor);
|
wlr_xcursor_manager_set_cursor_image(cursor_mgr, (cursor_image = "left_ptr"), cursor);
|
||||||
|
|
||||||
pointerfocus(c, surface, sx, sy, time);
|
pointerfocus(c, surface, sx, sy, time);
|
||||||
}
|
}
|
||||||
|
@ -1567,7 +1571,7 @@ moveresize(const Arg *arg)
|
||||||
case CurMove:
|
case CurMove:
|
||||||
grabcx = cursor->x - grabc->geom.x;
|
grabcx = cursor->x - grabc->geom.x;
|
||||||
grabcy = cursor->y - grabc->geom.y;
|
grabcy = cursor->y - grabc->geom.y;
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "fleur", cursor);
|
wlr_xcursor_manager_set_cursor_image(cursor_mgr, (cursor_image = "fleur"), cursor);
|
||||||
break;
|
break;
|
||||||
case CurResize:
|
case CurResize:
|
||||||
/* Doesn't work for X11 output - the next absolute motion event
|
/* Doesn't work for X11 output - the next absolute motion event
|
||||||
|
@ -1576,7 +1580,7 @@ moveresize(const Arg *arg)
|
||||||
grabc->geom.x + grabc->geom.width,
|
grabc->geom.x + grabc->geom.width,
|
||||||
grabc->geom.y + grabc->geom.height);
|
grabc->geom.y + grabc->geom.height);
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr,
|
wlr_xcursor_manager_set_cursor_image(cursor_mgr,
|
||||||
"bottom_right_corner", cursor);
|
(cursor_image = "bottom_right_corner"), cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1702,7 +1706,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
||||||
* wlroots makes this a no-op if surface is already focused */
|
* wlroots makes this a no-op if surface is already focused */
|
||||||
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
||||||
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1867,7 +1870,7 @@ run(char *startup_cmd)
|
||||||
* initialized, as the image/coordinates are not transformed for the
|
* initialized, as the image/coordinates are not transformed for the
|
||||||
* monitor when displayed here */
|
* monitor when displayed here */
|
||||||
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
|
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor);
|
wlr_xcursor_manager_set_cursor_image(cursor_mgr, cursor_image, cursor);
|
||||||
|
|
||||||
/* Run the Wayland event loop. This does not return until you exit the
|
/* Run the Wayland event loop. This does not return until you exit the
|
||||||
* compositor. Starting the backend rigged up all of the necessary event
|
* compositor. Starting the backend rigged up all of the necessary event
|
||||||
|
@ -1890,10 +1893,12 @@ setcursor(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
/* This event is raised by the seat when a client provides a cursor image */
|
/* This event is raised by the seat when a client provides a cursor image */
|
||||||
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
||||||
/* If we're "grabbing" the cursor, don't use the client's image */
|
/* If we're "grabbing" the cursor, don't use the client's image, we will
|
||||||
/* TODO still need to save the provided surface to restore later */
|
* restore it after "grabbing" sending a leave event, followed by a enter
|
||||||
|
* event, which will result in the client requesting set the cursor surface */
|
||||||
if (cursor_mode != CurNormal)
|
if (cursor_mode != CurNormal)
|
||||||
return;
|
return;
|
||||||
|
cursor_image = NULL;
|
||||||
/* This can be sent by any client, so we check to make sure this one is
|
/* This can be sent by any client, so we check to make sure this one is
|
||||||
* actually has pointer focus first. If so, we can tell the cursor to
|
* actually has pointer focus first. If so, we can tell the cursor to
|
||||||
* use the provided surface as the cursor image. It will set the
|
* use the provided surface as the cursor image. It will set the
|
||||||
|
|
Loading…
Reference in a new issue