[mutter] wayland/keyboard: Check keyboard presence at set focus call site



commit 133bbdfefab8c8247313d66036d98f36a0a8fed9
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Sep 21 12:00:39 2016 +0800

    wayland/keyboard: Check keyboard presence at set focus call site
    
    Make the caller of focus setting and grab starting check whether there
    is a keyboard to update the focus state or start grabbing. It makes it
    more obvious what to expect, as the call would be a no-op in when no
    keyboard is present.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771646

 src/wayland/meta-wayland-data-device.c |    9 ++++++---
 src/wayland/meta-wayland-keyboard.c    |    4 ----
 src/wayland/meta-wayland-popup.c       |   11 +++++------
 3 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 14fd5bf..478d1c4 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -1195,9 +1195,12 @@ data_device_start_drag (struct wl_client *client,
                                        &drag_grab_interface,
                                        surface, drag_source, icon_surface);
 
-  meta_wayland_keyboard_set_focus (seat->keyboard, NULL);
-  meta_wayland_keyboard_start_grab (seat->keyboard,
-                                    &seat->data_device.current_grab->keyboard_grab);
+  if (meta_wayland_seat_has_keyboard (seat))
+    {
+      meta_wayland_keyboard_set_focus (seat->keyboard, NULL);
+      meta_wayland_keyboard_start_grab (seat->keyboard,
+                                        &seat->data_device.current_grab->keyboard_grab);
+    }
 }
 
 static void
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 56e9576..4998cea 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -825,10 +825,6 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
                                  MetaWaylandSurface *surface)
 {
   MetaWaylandInputDevice *input_device = META_WAYLAND_INPUT_DEVICE (keyboard);
-  MetaWaylandSeat *seat = meta_wayland_input_device_get_seat (input_device);
-
-  if (!meta_wayland_seat_has_keyboard (seat))
-    return;
 
   if (keyboard->focus_surface == surface)
     return;
diff --git a/src/wayland/meta-wayland-popup.c b/src/wayland/meta-wayland-popup.c
index 77860d4..c89b878 100644
--- a/src/wayland/meta-wayland-popup.c
+++ b/src/wayland/meta-wayland-popup.c
@@ -249,12 +249,12 @@ meta_wayland_popup_dismiss (MetaWaylandPopup *popup)
     {
       MetaWaylandSurface *top_popup_surface;
       MetaWaylandSeat *seat;
-      MetaWaylandKeyboard *keyboard;
 
       top_popup_surface = meta_wayland_popup_grab_get_top_popup (popup_grab);
       seat = meta_wayland_pointer_get_seat (popup_grab->generic.pointer);
-      keyboard = seat->keyboard;
-      meta_wayland_keyboard_set_focus (keyboard, top_popup_surface);
+
+      if (meta_wayland_seat_has_keyboard (seat))
+        meta_wayland_keyboard_set_focus (seat->keyboard, top_popup_surface);
     }
 }
 
@@ -272,7 +272,6 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
     meta_wayland_popup_surface_get_surface (popup_surface);
   MetaWaylandPopup *popup;
   MetaWaylandSeat *seat;
-  MetaWaylandKeyboard *keyboard;
 
   /* Don't allow creating popups if the grab has a different client. */
   if (grab->grab_client != wl_resource_get_client (surface->resource))
@@ -285,8 +284,8 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
   wl_list_insert (&grab->all_popups, &popup->link);
 
   seat = meta_wayland_pointer_get_seat (grab->generic.pointer);
-  keyboard = seat->keyboard;
-  meta_wayland_keyboard_set_focus (keyboard, surface);
+  if (meta_wayland_seat_has_keyboard (seat))
+    meta_wayland_keyboard_set_focus (seat->keyboard, surface);
 
   return popup;
 }


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