window: Workaround a stuck frame callback on the cursor surface

It is possible that a client loses the focus between receiving a
pointer.enter event and sending a pointer.set_cursor request. In that
case, the cursor surface might not be mapped and the frame callback
requested on it will never trigger.

Work around this by trying to remap the cursor surface whenever there
is a frame callback and the serial for the enter event is higher than
the cursor serial.
Ander Conselvan de Oliveira 12 years ago committed by Kristian Høgsberg
parent eac9a46012
commit ddca49600f
  1. 17
      clients/window.c

@ -2437,14 +2437,27 @@ static const struct wl_callback_listener pointer_surface_listener = {
void
input_set_pointer_image(struct input *input, int pointer)
{
if (pointer == input->current_cursor &&
input->pointer_enter_serial == input->cursor_serial)
int force = 0;
if (input->pointer_enter_serial > input->cursor_serial)
force = 1;
if (!force && pointer == input->current_cursor)
return;
input->current_cursor = pointer;
input->cursor_serial = input->pointer_enter_serial;
if (!input->cursor_frame_cb)
pointer_surface_frame_callback(input, NULL, 0);
else if (force) {
/* The current frame callback may be stuck if, for instance,
* the set cursor request was processed by the server after
* this client lost the focus. In this case the cursor surface
* might not be mapped and the frame callback wouldn't ever
* complete. Send a set_cursor and attach to try to map the
* cursor surface again so that the callback will finish */
input_set_pointer_image_index(input, 0);
}
}
struct wl_data_device *

Loading…
Cancel
Save