[mutter/wip/tablet-protocol-v2: 7/8] wayland: Add focus management to pads



commit 54915ca7fe0540e5cedf903ba29d74e7e878733f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 10 17:29:57 2016 +0200

    wayland: Add focus management to pads
    
    All pads will share the same focus than the keyboard, so this means that:
    - The focus changes in-sync for keyboard and all pad devices, and
    - Newly plugged pads will be immediately focused on that same surface

 src/wayland/meta-wayland-seat.c        |   15 +++++++++++----
 src/wayland/meta-wayland-tablet-seat.c |   16 ++++++++++++++++
 src/wayland/meta-wayland-tablet-seat.h |    3 +++
 3 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 9a7fa2e..a235a81 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -26,6 +26,7 @@
 #include "meta-wayland-private.h"
 #include "meta-wayland-versions.h"
 #include "meta-wayland-data-device.h"
+#include "meta-wayland-tablet-seat.h"
 
 #define CAPABILITY_ENABLED(prev, cur, capability) ((cur & (capability)) && !(prev & (capability)))
 #define CAPABILITY_DISABLED(prev, cur, capability) ((prev & (capability)) && !(cur & (capability)))
@@ -369,11 +370,17 @@ void
 meta_wayland_seat_set_input_focus (MetaWaylandSeat    *seat,
                                    MetaWaylandSurface *surface)
 {
-  if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) == 0)
-    return;
+  MetaWaylandTabletSeat *tablet_seat;
+  MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
+
+  if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) != 0)
+    {
+      meta_wayland_keyboard_set_focus (&seat->keyboard, surface);
+      meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
+    }
 
-  meta_wayland_keyboard_set_focus (&seat->keyboard, surface);
-  meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
+  tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
+  meta_wayland_tablet_seat_set_pad_focus (tablet_seat, surface);
 }
 
 gboolean
diff --git a/src/wayland/meta-wayland-tablet-seat.c b/src/wayland/meta-wayland-tablet-seat.c
index cc1d28a..1835d11 100644
--- a/src/wayland/meta-wayland-tablet-seat.c
+++ b/src/wayland/meta-wayland-tablet-seat.c
@@ -213,6 +213,9 @@ meta_wayland_tablet_seat_device_added (MetaWaylandTabletSeat *tablet_seat,
       pad = meta_wayland_tablet_pad_new (device, tablet_seat);
       g_hash_table_insert (tablet_seat->pads, device, pad);
       broadcast_pad_added (tablet_seat, device);
+
+      meta_wayland_tablet_pad_set_focus (pad,
+                                         tablet_seat->seat->keyboard.focus_surface);
     }
 }
 
@@ -440,3 +443,16 @@ meta_wayland_tablet_seat_notify_tool (MetaWaylandTabletSeat *tablet_seat,
   if (resource)
     notify_tool_added (tablet_seat, resource, tool);
 }
+
+void
+meta_wayland_tablet_seat_set_pad_focus (MetaWaylandTabletSeat *tablet_seat,
+                                        MetaWaylandSurface    *surface)
+{
+  MetaWaylandTabletPad *pad;
+  GHashTableIter iter;
+
+  g_hash_table_iter_init (&iter, tablet_seat->pads);
+
+  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &pad))
+    meta_wayland_tablet_pad_set_focus (pad, surface);
+}
diff --git a/src/wayland/meta-wayland-tablet-seat.h b/src/wayland/meta-wayland-tablet-seat.h
index 653f695..161e20e 100644
--- a/src/wayland/meta-wayland-tablet-seat.h
+++ b/src/wayland/meta-wayland-tablet-seat.h
@@ -69,4 +69,7 @@ void                   meta_wayland_tablet_seat_notify_tool         (MetaWayland
                                                                      MetaWaylandTabletTool *tool,
                                                                      struct wl_client      *client);
 
+void                   meta_wayland_tablet_seat_set_pad_focus       (MetaWaylandTabletSeat *tablet_seat,
+                                                                     MetaWaylandSurface    *surface);
+
 #endif /* META_WAYLAND_TABLET_SEAT_H */


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