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 <ofourdan@redhat.com> Reviewed-by: Simon Ser <contact@emersion.fr> Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
This commit is contained in:
parent
672fe9e244
commit
c93c2e7718
|
@ -111,15 +111,6 @@ xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
|
||||||
return xwl_shm_destroy_pixmap(pixmap);
|
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
|
static void
|
||||||
frame_callback(void *data,
|
frame_callback(void *data,
|
||||||
struct wl_callback *callback,
|
struct wl_callback *callback,
|
||||||
|
@ -127,7 +118,7 @@ frame_callback(void *data,
|
||||||
{
|
{
|
||||||
struct xwl_cursor *xwl_cursor = 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) {
|
if (xwl_cursor->needs_update) {
|
||||||
xwl_cursor->needs_update = FALSE;
|
xwl_cursor->needs_update = FALSE;
|
||||||
xwl_cursor->update_proc(xwl_cursor);
|
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);
|
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
|
void
|
||||||
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
|
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) {
|
if (!xwl_seat->x_cursor) {
|
||||||
wl_pointer_set_cursor(xwl_seat->wl_pointer,
|
wl_pointer_set_cursor(xwl_seat->wl_pointer,
|
||||||
xwl_seat->pointer_enter_serial, NULL, 0, 0);
|
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;
|
xwl_cursor->needs_update = FALSE;
|
||||||
return;
|
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,
|
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
|
||||||
xwl_tablet_tool->proximity_in_serial,
|
xwl_tablet_tool->proximity_in_serial,
|
||||||
NULL, 0, 0);
|
NULL, 0, 0);
|
||||||
clear_cursor_frame_callback(xwl_cursor);
|
xwl_cursor_clear_frame_cb(xwl_cursor);
|
||||||
xwl_cursor->needs_update = FALSE;
|
xwl_cursor->needs_update = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -268,8 +271,7 @@ void
|
||||||
xwl_cursor_release(struct xwl_cursor *xwl_cursor)
|
xwl_cursor_release(struct xwl_cursor *xwl_cursor)
|
||||||
{
|
{
|
||||||
wl_surface_destroy(xwl_cursor->surface);
|
wl_surface_destroy(xwl_cursor->surface);
|
||||||
if (xwl_cursor->frame_cb)
|
xwl_cursor_clear_frame_cb(xwl_cursor);
|
||||||
wl_callback_destroy(xwl_cursor->frame_cb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <xwayland-types.h>
|
#include <xwayland-types.h>
|
||||||
#include <xwayland-input.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_cursor_release(struct xwl_cursor *xwl_cursor);
|
||||||
void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *tool);
|
void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *tool);
|
||||||
void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
|
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
|
* of our surfaces might not have been shown. In that case we'll
|
||||||
* have a cursor surface frame callback pending which we need to
|
* have a cursor surface frame callback pending which we need to
|
||||||
* clear so that we can continue submitting new cursor frames. */
|
* clear so that we can continue submitting new cursor frames. */
|
||||||
if (xwl_seat->cursor.frame_cb) {
|
if (xwl_cursor_clear_frame_cb(&xwl_seat->cursor))
|
||||||
wl_callback_destroy(xwl_seat->cursor.frame_cb);
|
|
||||||
xwl_seat->cursor.frame_cb = NULL;
|
|
||||||
xwl_seat_set_cursor(xwl_seat);
|
xwl_seat_set_cursor(xwl_seat);
|
||||||
}
|
|
||||||
|
|
||||||
if (xwl_seat->pointer_warp_emulator) {
|
if (xwl_seat->pointer_warp_emulator) {
|
||||||
xwl_pointer_warp_emulator_maybe_lock(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
|
/* If there is a cursor surface frame callback pending, we need to clear it
|
||||||
* so that we can continue submitting new cursor frames.
|
* so that we can continue submitting new cursor frames.
|
||||||
*/
|
*/
|
||||||
if (xwl_tablet_tool->cursor.frame_cb) {
|
xwl_cursor_clear_frame_cb(&xwl_tablet_tool->cursor);
|
||||||
wl_callback_destroy(xwl_tablet_tool->cursor.frame_cb);
|
|
||||||
xwl_tablet_tool->cursor.frame_cb = NULL;
|
|
||||||
}
|
|
||||||
xwl_tablet_tool_set_cursor(xwl_tablet_tool);
|
xwl_tablet_tool_set_cursor(xwl_tablet_tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue