Commit c93c2e77 authored by Olivier Fourdan's avatar Olivier Fourdan 🛠 Committed by Olivier Fourdan
Browse files

xwayland: Add xwl_cursor_clear_frame_cb()



The code to clear a cursor pending frame callback was duplicated in
multiple places in the code.

Introduce a new xwl_cursor_clear_frame_cb() function and remove the
duplicated code.

No functional change.
Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Simon Ser's avatarSimon Ser <contact@emersion.fr>
Reviewed-by: Carlos Garnacho's avatarCarlos Garnacho <carlosg@gnome.org>
parent 672fe9e2
Pipeline #432098 passed with stages
in 6 minutes and 23 seconds
......@@ -111,15 +111,6 @@ xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
return xwl_shm_destroy_pixmap(pixmap);
}
static void
clear_cursor_frame_callback(struct xwl_cursor *xwl_cursor)
{
if (xwl_cursor->frame_cb) {
wl_callback_destroy (xwl_cursor->frame_cb);
xwl_cursor->frame_cb = NULL;
}
}
static void
frame_callback(void *data,
struct wl_callback *callback,
......@@ -127,7 +118,7 @@ frame_callback(void *data,
{
struct xwl_cursor *xwl_cursor = data;
clear_cursor_frame_callback(xwl_cursor);
xwl_cursor_clear_frame_cb(xwl_cursor);
if (xwl_cursor->needs_update) {
xwl_cursor->needs_update = FALSE;
xwl_cursor->update_proc(xwl_cursor);
......@@ -187,6 +178,18 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
wl_surface_commit(xwl_cursor->surface);
}
Bool
xwl_cursor_clear_frame_cb(struct xwl_cursor *xwl_cursor)
{
if (xwl_cursor->frame_cb) {
wl_callback_destroy(xwl_cursor->frame_cb);
xwl_cursor->frame_cb = NULL;
return TRUE;
}
return FALSE;
}
void
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
{
......@@ -200,7 +203,7 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
if (!xwl_seat->x_cursor) {
wl_pointer_set_cursor(xwl_seat->wl_pointer,
xwl_seat->pointer_enter_serial, NULL, 0, 0);
clear_cursor_frame_callback(xwl_cursor);
xwl_cursor_clear_frame_cb(xwl_cursor);
xwl_cursor->needs_update = FALSE;
return;
}
......@@ -238,7 +241,7 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
xwl_tablet_tool->proximity_in_serial,
NULL, 0, 0);
clear_cursor_frame_callback(xwl_cursor);
xwl_cursor_clear_frame_cb(xwl_cursor);
xwl_cursor->needs_update = FALSE;
return;
}
......@@ -268,8 +271,7 @@ void
xwl_cursor_release(struct xwl_cursor *xwl_cursor)
{
wl_surface_destroy(xwl_cursor->surface);
if (xwl_cursor->frame_cb)
wl_callback_destroy(xwl_cursor->frame_cb);
xwl_cursor_clear_frame_cb(xwl_cursor);
}
static void
......
......@@ -31,6 +31,7 @@
#include <xwayland-types.h>
#include <xwayland-input.h>
Bool xwl_cursor_clear_frame_cb(struct xwl_cursor *xwl_cursor);
void xwl_cursor_release(struct xwl_cursor *xwl_cursor);
void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *tool);
void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
......
......@@ -463,11 +463,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
* of our surfaces might not have been shown. In that case we'll
* have a cursor surface frame callback pending which we need to
* clear so that we can continue submitting new cursor frames. */
if (xwl_seat->cursor.frame_cb) {
wl_callback_destroy(xwl_seat->cursor.frame_cb);
xwl_seat->cursor.frame_cb = NULL;
if (xwl_cursor_clear_frame_cb(&xwl_seat->cursor))
xwl_seat_set_cursor(xwl_seat);
}
if (xwl_seat->pointer_warp_emulator) {
xwl_pointer_warp_emulator_maybe_lock(xwl_seat->pointer_warp_emulator,
......@@ -1672,10 +1669,7 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool,
/* If there is a cursor surface frame callback pending, we need to clear it
* so that we can continue submitting new cursor frames.
*/
if (xwl_tablet_tool->cursor.frame_cb) {
wl_callback_destroy(xwl_tablet_tool->cursor.frame_cb);
xwl_tablet_tool->cursor.frame_cb = NULL;
}
xwl_cursor_clear_frame_cb(&xwl_tablet_tool->cursor);
xwl_tablet_tool_set_cursor(xwl_tablet_tool);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment