2014-03-11 16:11:39 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
|
* Copyright © 2011 Kristian Høgsberg
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
|
* and its documentation for any purpose is hereby granted without
|
|
|
|
|
* fee, provided that the above copyright notice appear in all copies
|
|
|
|
|
* and that both that copyright notice and this permission notice
|
|
|
|
|
* appear in supporting documentation, and that the name of the
|
|
|
|
|
* copyright holders not be used in advertising or publicity
|
|
|
|
|
* pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no
|
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
|
* warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
|
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-12-16 17:07:02 +01:00
|
|
|
#include <xwayland-config.h>
|
|
|
|
|
|
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
|
#include "servermd.h"
|
|
|
|
|
#include "cursorstr.h"
|
|
|
|
|
#include "inputstr.h"
|
|
|
|
|
#include "mipointer.h"
|
|
|
|
|
|
2019-12-18 10:45:17 +01:00
|
|
|
#include "xwayland-cursor.h"
|
2019-12-17 17:40:21 +01:00
|
|
|
#include "xwayland-input.h"
|
2020-12-07 14:09:58 +01:00
|
|
|
#include "xwayland-pixmap.h"
|
2019-12-18 10:03:43 +01:00
|
|
|
#include "xwayland-screen.h"
|
2019-12-16 17:07:02 +01:00
|
|
|
#include "xwayland-shm.h"
|
|
|
|
|
#include "xwayland-types.h"
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2019-12-16 17:07:02 +01:00
|
|
|
#include "tablet-unstable-v2-client-protocol.h"
|
2014-03-11 16:11:39 -07:00
|
|
|
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
#define DELAYED_X_CURSOR_TIMEOUT 5 /* ms */
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static DevPrivateKeyRec xwl_cursor_private_key;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
expand_source_and_mask(CursorPtr cursor, CARD32 *data)
|
|
|
|
|
{
|
|
|
|
|
CARD32 *p, d, fg, bg;
|
|
|
|
|
CursorBitsPtr bits = cursor->bits;
|
|
|
|
|
int x, y, stride, i, bit;
|
|
|
|
|
|
|
|
|
|
p = data;
|
|
|
|
|
fg = ((cursor->foreRed & 0xff00) << 8) |
|
|
|
|
|
(cursor->foreGreen & 0xff00) | (cursor->foreGreen >> 8);
|
|
|
|
|
bg = ((cursor->backRed & 0xff00) << 8) |
|
|
|
|
|
(cursor->backGreen & 0xff00) | (cursor->backGreen >> 8);
|
2017-09-27 18:01:01 +02:00
|
|
|
stride = BitmapBytePad(bits->width);
|
2014-03-11 16:11:39 -07:00
|
|
|
for (y = 0; y < bits->height; y++)
|
|
|
|
|
for (x = 0; x < bits->width; x++) {
|
|
|
|
|
i = y * stride + x / 8;
|
|
|
|
|
bit = 1 << (x & 7);
|
|
|
|
|
if (bits->source[i] & bit)
|
|
|
|
|
d = fg;
|
|
|
|
|
else
|
|
|
|
|
d = bg;
|
|
|
|
|
if (bits->mask[i] & bit)
|
|
|
|
|
d |= 0xff000000;
|
|
|
|
|
else
|
|
|
|
|
d = 0x00000000;
|
|
|
|
|
|
|
|
|
|
*p++ = d;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_realize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pixmap;
|
|
|
|
|
|
|
|
|
|
pixmap = xwl_shm_create_pixmap(screen, cursor->bits->width,
|
2019-07-09 11:08:27 +02:00
|
|
|
cursor->bits->height, 32,
|
|
|
|
|
CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
|
2014-03-11 16:11:39 -07:00
|
|
|
dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, pixmap);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pixmap;
|
2016-09-22 09:38:50 +02:00
|
|
|
struct xwl_screen *xwl_screen;
|
2016-06-06 09:22:28 +02:00
|
|
|
struct xwl_seat *xwl_seat;
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key);
|
2016-06-06 09:22:28 +02:00
|
|
|
if (!pixmap)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, NULL);
|
|
|
|
|
|
|
|
|
|
/* When called from FreeCursor(), device is always NULL */
|
2016-09-22 09:38:50 +02:00
|
|
|
xwl_screen = xwl_screen_get(screen);
|
|
|
|
|
xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
|
|
|
|
|
if (cursor == xwl_seat->x_cursor)
|
2016-06-06 09:22:28 +02:00
|
|
|
xwl_seat->x_cursor = NULL;
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
return xwl_shm_destroy_pixmap(pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 10:28:35 +01:00
|
|
|
static void
|
2016-11-04 19:36:10 +01:00
|
|
|
clear_cursor_frame_callback(struct xwl_cursor *xwl_cursor)
|
2017-03-07 10:28:35 +01:00
|
|
|
{
|
2016-11-04 19:36:10 +01:00
|
|
|
if (xwl_cursor->frame_cb) {
|
|
|
|
|
wl_callback_destroy (xwl_cursor->frame_cb);
|
|
|
|
|
xwl_cursor->frame_cb = NULL;
|
2017-03-07 10:28:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 12:08:45 +02:00
|
|
|
static void
|
|
|
|
|
frame_callback(void *data,
|
|
|
|
|
struct wl_callback *callback,
|
|
|
|
|
uint32_t time)
|
|
|
|
|
{
|
2016-11-04 19:36:10 +01:00
|
|
|
struct xwl_cursor *xwl_cursor = data;
|
2016-08-02 11:24:41 +02:00
|
|
|
|
2016-11-04 19:36:10 +01:00
|
|
|
clear_cursor_frame_callback(xwl_cursor);
|
|
|
|
|
if (xwl_cursor->needs_update) {
|
|
|
|
|
xwl_cursor->needs_update = FALSE;
|
|
|
|
|
xwl_cursor->update_proc(xwl_cursor);
|
2015-05-27 12:08:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_callback_listener frame_listener = {
|
|
|
|
|
frame_callback
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-07 14:09:58 +01:00
|
|
|
static void
|
|
|
|
|
xwl_cursor_buffer_release_callback(void *data)
|
|
|
|
|
{
|
|
|
|
|
/* drop the reference we took in set_cursor */
|
|
|
|
|
xwl_shm_destroy_pixmap(data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
static void
|
|
|
|
|
xwl_cursor_copy_bits_to_pixmap(CursorPtr cursor, PixmapPtr pixmap)
|
|
|
|
|
{
|
|
|
|
|
int stride;
|
|
|
|
|
|
|
|
|
|
stride = cursor->bits->width * 4;
|
|
|
|
|
if (cursor->bits->argb)
|
|
|
|
|
memcpy(pixmap->devPrivate.ptr,
|
|
|
|
|
cursor->bits->argb, cursor->bits->height * stride);
|
|
|
|
|
else
|
|
|
|
|
expand_source_and_mask(cursor, pixmap->devPrivate.ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
|
|
|
|
|
struct xwl_cursor *xwl_cursor, PixmapPtr pixmap)
|
|
|
|
|
{
|
2021-03-29 15:01:15 +02:00
|
|
|
struct wl_buffer *buffer;
|
|
|
|
|
|
|
|
|
|
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
|
|
|
|
|
if (!buffer) {
|
|
|
|
|
ErrorF("cursor: Error getting buffer\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wl_surface_attach(xwl_cursor->surface, buffer, 0, 0);
|
2020-12-10 10:10:05 +01:00
|
|
|
xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
|
|
|
|
|
xwl_seat->x_cursor->bits->width,
|
|
|
|
|
xwl_seat->x_cursor->bits->height);
|
|
|
|
|
|
|
|
|
|
xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface);
|
|
|
|
|
wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor);
|
|
|
|
|
|
2020-12-07 14:09:58 +01:00
|
|
|
/* Hold a reference on the pixmap until it's released by the compositor */
|
|
|
|
|
pixmap->refcnt++;
|
|
|
|
|
xwl_pixmap_set_buffer_release_cb(pixmap,
|
|
|
|
|
xwl_cursor_buffer_release_callback,
|
|
|
|
|
pixmap);
|
|
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
wl_surface_commit(xwl_cursor->surface);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
void
|
|
|
|
|
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
|
|
|
|
|
{
|
2016-11-04 19:36:10 +01:00
|
|
|
struct xwl_cursor *xwl_cursor = &xwl_seat->cursor;
|
2014-03-11 16:11:39 -07:00
|
|
|
PixmapPtr pixmap;
|
|
|
|
|
CursorPtr cursor;
|
|
|
|
|
|
|
|
|
|
if (!xwl_seat->wl_pointer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!xwl_seat->x_cursor) {
|
|
|
|
|
wl_pointer_set_cursor(xwl_seat->wl_pointer,
|
|
|
|
|
xwl_seat->pointer_enter_serial, NULL, 0, 0);
|
2016-11-04 19:36:10 +01:00
|
|
|
clear_cursor_frame_callback(xwl_cursor);
|
|
|
|
|
xwl_cursor->needs_update = FALSE;
|
2014-03-11 16:11:39 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 19:36:10 +01:00
|
|
|
if (xwl_cursor->frame_cb) {
|
|
|
|
|
xwl_cursor->needs_update = TRUE;
|
2015-05-27 12:08:45 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
cursor = xwl_seat->x_cursor;
|
|
|
|
|
pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key);
|
2016-06-06 09:22:28 +02:00
|
|
|
if (!pixmap)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
xwl_cursor_copy_bits_to_pixmap(cursor, pixmap);
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
wl_pointer_set_cursor(xwl_seat->wl_pointer,
|
|
|
|
|
xwl_seat->pointer_enter_serial,
|
2016-11-04 19:36:10 +01:00
|
|
|
xwl_cursor->surface,
|
2014-03-11 16:11:39 -07:00
|
|
|
xwl_seat->x_cursor->bits->xhot,
|
|
|
|
|
xwl_seat->x_cursor->bits->yhot);
|
2015-05-27 12:08:45 +02:00
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2016-11-04 19:58:04 +01:00
|
|
|
void
|
|
|
|
|
xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
|
|
|
|
|
struct xwl_cursor *xwl_cursor = &xwl_tablet_tool->cursor;
|
|
|
|
|
PixmapPtr pixmap;
|
|
|
|
|
CursorPtr cursor;
|
|
|
|
|
|
|
|
|
|
if (!xwl_seat->x_cursor) {
|
|
|
|
|
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
|
|
|
|
|
xwl_tablet_tool->proximity_in_serial,
|
|
|
|
|
NULL, 0, 0);
|
2019-05-22 17:51:04 +02:00
|
|
|
clear_cursor_frame_callback(xwl_cursor);
|
|
|
|
|
xwl_cursor->needs_update = FALSE;
|
2016-11-04 19:58:04 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xwl_cursor->frame_cb) {
|
|
|
|
|
xwl_cursor->needs_update = TRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursor = xwl_seat->x_cursor;
|
|
|
|
|
pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key);
|
|
|
|
|
if (!pixmap)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
xwl_cursor_copy_bits_to_pixmap(cursor, pixmap);
|
2016-11-04 19:58:04 +01:00
|
|
|
|
|
|
|
|
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
|
|
|
|
|
xwl_tablet_tool->proximity_in_serial,
|
|
|
|
|
xwl_cursor->surface,
|
|
|
|
|
xwl_seat->x_cursor->bits->xhot,
|
|
|
|
|
xwl_seat->x_cursor->bits->yhot);
|
|
|
|
|
|
2020-12-10 10:10:05 +01:00
|
|
|
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
|
2016-11-04 19:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
static void
|
|
|
|
|
xwl_seat_update_cursor(struct xwl_seat *xwl_seat)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_tablet_tool *xwl_tablet_tool;
|
|
|
|
|
|
|
|
|
|
xwl_seat_set_cursor(xwl_seat);
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(xwl_tablet_tool, &xwl_seat->tablet_tools, link) {
|
|
|
|
|
if (xwl_tablet_tool->proximity_in_serial != 0)
|
|
|
|
|
xwl_tablet_tool_set_cursor(xwl_tablet_tool);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clear delayed cursor if any */
|
|
|
|
|
xwl_seat->pending_x_cursor = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_seat_update_cursor_visibility(struct xwl_seat *xwl_seat)
|
|
|
|
|
{
|
|
|
|
|
xwl_seat->x_cursor = xwl_seat->pending_x_cursor;
|
|
|
|
|
xwl_seat_cursor_visibility_changed(xwl_seat);
|
|
|
|
|
xwl_seat_update_cursor(xwl_seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_set_cursor_free_timer(struct xwl_seat *xwl_seat)
|
|
|
|
|
{
|
|
|
|
|
if (xwl_seat->x_cursor_timer) {
|
|
|
|
|
TimerFree(xwl_seat->x_cursor_timer);
|
|
|
|
|
xwl_seat->x_cursor_timer = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CARD32
|
|
|
|
|
xwl_set_cursor_timer_callback(OsTimerPtr timer, CARD32 time, void *arg)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_seat *xwl_seat = arg;
|
|
|
|
|
|
|
|
|
|
xwl_set_cursor_free_timer(xwl_seat);
|
|
|
|
|
xwl_seat_update_cursor_visibility(xwl_seat);
|
|
|
|
|
|
|
|
|
|
/* Don't re-arm the timer */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_set_cursor_delayed(struct xwl_seat *xwl_seat, CursorPtr cursor)
|
|
|
|
|
{
|
|
|
|
|
xwl_seat->pending_x_cursor = cursor;
|
|
|
|
|
|
|
|
|
|
if (xwl_seat->x_cursor_timer == NULL) {
|
|
|
|
|
xwl_seat->x_cursor_timer = TimerSet(xwl_seat->x_cursor_timer,
|
|
|
|
|
0, DELAYED_X_CURSOR_TIMEOUT,
|
|
|
|
|
&xwl_set_cursor_timer_callback,
|
|
|
|
|
xwl_seat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static void
|
|
|
|
|
xwl_set_cursor(DeviceIntPtr device,
|
|
|
|
|
ScreenPtr screen, CursorPtr cursor, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_seat *xwl_seat;
|
2016-09-13 15:17:08 +08:00
|
|
|
Bool cursor_visibility_changed;
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
xwl_seat = device->public.devicePrivate;
|
|
|
|
|
if (xwl_seat == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-09-13 15:17:08 +08:00
|
|
|
cursor_visibility_changed = !!xwl_seat->x_cursor ^ !!cursor;
|
|
|
|
|
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
if (!cursor_visibility_changed) {
|
|
|
|
|
/* Cursor remains shown or hidden, apply the change immediately */
|
|
|
|
|
xwl_set_cursor_free_timer(xwl_seat);
|
|
|
|
|
xwl_seat->x_cursor = cursor;
|
|
|
|
|
xwl_seat_update_cursor(xwl_seat);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-04 19:58:04 +01:00
|
|
|
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
xwl_seat->pending_x_cursor = cursor;
|
|
|
|
|
if (cursor) {
|
|
|
|
|
/* Cursor is being shown, delay the change until moved or timed out */
|
|
|
|
|
xwl_set_cursor_delayed(xwl_seat, cursor);
|
|
|
|
|
} else {
|
|
|
|
|
/* Cursor is being hidden, apply the change immediately */
|
|
|
|
|
xwl_seat_update_cursor_visibility(xwl_seat);
|
2016-11-04 19:58:04 +01:00
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_move_cursor(DeviceIntPtr device, ScreenPtr screen, int x, int y)
|
|
|
|
|
{
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
struct xwl_seat *xwl_seat;
|
|
|
|
|
|
|
|
|
|
xwl_seat = device->public.devicePrivate;
|
|
|
|
|
if (xwl_seat == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
xwl_set_cursor_free_timer(xwl_seat);
|
|
|
|
|
|
|
|
|
|
if (xwl_seat->pending_x_cursor)
|
|
|
|
|
xwl_seat_update_cursor_visibility(xwl_seat);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_device_cursor_initialize(DeviceIntPtr device, ScreenPtr screen)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_device_cursor_cleanup(DeviceIntPtr device, ScreenPtr screen)
|
|
|
|
|
{
|
xwayland: Delay cursor visibility update
Xwayland won't emulate XWarpPointer requests if the cursor is visible,
this is to avoid having the cursor jumping on screen and preventing
random X11 clients from controlling the pointer in Wayland, while
allowing games which use that mechanism with a hidden cursor to work in
Xwayland.
There are, however, games which tend to do it in the wrong order, i.e.
show the cursor before moving the pointer, and because Xwayland will not
allow an X11 client to move the pointer while the cursor is visible, the
requests will fail.
Add a workaround for such X11 clients, when the cursor is being shown,
keep it invisible until the cursor is actually moved. This way, X11
clients which show their cursor just before moving it would still have a
chance to succeed.
v2: Add a timeout to show the cursor for well behaved clients.
v3: Some cleanup (Michel)
v4: Do not cancel cursor delay when updating the cursor to avoid
delaying cursor visibility indefinitely if the client keeps
settings different cursors (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Jaap Buurman jaapbuurman@gmail.com
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
2020-12-18 17:53:33 +01:00
|
|
|
struct xwl_seat *xwl_seat;
|
|
|
|
|
|
|
|
|
|
xwl_seat = device->public.devicePrivate;
|
|
|
|
|
if (xwl_seat)
|
|
|
|
|
xwl_set_cursor_free_timer(xwl_seat);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static miPointerSpriteFuncRec xwl_pointer_sprite_funcs = {
|
|
|
|
|
xwl_realize_cursor,
|
|
|
|
|
xwl_unrealize_cursor,
|
|
|
|
|
xwl_set_cursor,
|
|
|
|
|
xwl_move_cursor,
|
|
|
|
|
xwl_device_cursor_initialize,
|
|
|
|
|
xwl_device_cursor_cleanup
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_cursor_off_screen(ScreenPtr *ppScreen, int *x, int *y)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_cross_screen(ScreenPtr pScreen, Bool entering)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_pointer_warp_cursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
|
|
|
|
{
|
2015-08-28 14:28:11 +10:00
|
|
|
miPointerWarpCursor(pDev, pScreen, x, y);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static miPointerScreenFuncRec xwl_pointer_screen_funcs = {
|
|
|
|
|
xwl_cursor_off_screen,
|
|
|
|
|
xwl_cross_screen,
|
|
|
|
|
xwl_pointer_warp_cursor
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
xwl_screen_init_cursor(struct xwl_screen *xwl_screen)
|
|
|
|
|
{
|
|
|
|
|
if (!dixRegisterPrivateKey(&xwl_cursor_private_key, PRIVATE_CURSOR_BITS, 0))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return miPointerInitialize(xwl_screen->screen,
|
|
|
|
|
&xwl_pointer_sprite_funcs,
|
|
|
|
|
&xwl_pointer_screen_funcs, TRUE);
|
|
|
|
|
}
|