[mutter] keyboard/pointer: Calculate the serial once per event



commit 48dfde20738b7d20659522120c41dccfe8a23b78
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Sep 17 17:51:27 2014 -0600

    keyboard/pointer: Calculate the serial once per event
    
    Some applications, like totem, create keyboard/pointer objects from the
    same client, and expect it to work. We made this work a while ago, but
    due to an oversight in the code, we increment the serial on button press
    for every resource that we need to send events to.
    
    Since operations like move/resize use the grab serial of the devices to
    determine whether the operation is exact, we need to make sure the same
    serial goes to all devices.
    
    Restructure the code so that all that's in the resource loop is the
    sending of the event -- all the calculation that's needed happens
    outside.
    
    This fixes moving / resizing the Totem window not working sometimes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736840

 src/wayland/meta-wayland-keyboard.c |   19 ++++++++++++-------
 src/wayland/meta-wayland-pointer.c  |   12 ++++++++----
 2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 068ab71..59c9fe3 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -273,14 +273,19 @@ notify_modifiers (MetaWaylandKeyboard *keyboard)
   state = keyboard->xkb_info.state;
 
   l = &keyboard->focus_resource_list;
-  wl_resource_for_each (resource, l)
+  if (!wl_list_empty (l))
     {
-      wl_keyboard_send_modifiers (resource,
-                                  wl_display_next_serial (keyboard->display),
-                                  xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
-                                  xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
-                                  xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
-                                  xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
+      uint32_t serial = wl_display_next_serial (keyboard->display);
+
+      wl_resource_for_each (resource, l)
+        {
+          wl_keyboard_send_modifiers (resource,
+                                      serial,
+                                      xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
+                                      xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
+                                      xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
+                                      xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
+        }
     }
 }
 
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index ca1952a..3fc05ec 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -142,7 +142,7 @@ default_grab_button (MetaWaylandPointerGrab *grab,
   event_type = clutter_event_type (event);
 
   l = &grab->pointer->focus_resource_list;
-  wl_resource_for_each(resource, l)
+  if (!wl_list_empty (l))
     {
       struct wl_client *client = wl_resource_get_client (pointer->focus_surface->resource);
       struct wl_display *display = wl_client_get_display (client);
@@ -168,9 +168,13 @@ default_grab_button (MetaWaylandPointerGrab *grab,
        }
 
       serial = wl_display_next_serial (display);
-      wl_pointer_send_button (resource, serial,
-                             clutter_event_get_time (event), button,
-                             event_type == CLUTTER_BUTTON_PRESS ? 1 : 0);
+
+      wl_resource_for_each(resource, l)
+        {
+          wl_pointer_send_button (resource, serial,
+                                  clutter_event_get_time (event), button,
+                                  event_type == CLUTTER_BUTTON_PRESS ? 1 : 0);
+        }
     }
 
   if (pointer->button_count == 0 && event_type == CLUTTER_BUTTON_RELEASE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]