[mutter/wayland] wayland: Remove special code for modal grabs



commit dd8d8e436d703348db2a4ec64162bf4f510ff8b9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 10 14:49:41 2014 -0400

    wayland: Remove special code for modal grabs
    
    Since we never pass any Clutter events to Wayland, it's not needed.

 src/compositor/compositor.c         |   51 +-------------
 src/wayland/meta-wayland-keyboard.c |  131 ++---------------------------------
 src/wayland/meta-wayland-keyboard.h |    7 --
 src/wayland/meta-wayland-pointer.c  |   55 ---------------
 src/wayland/meta-wayland-pointer.h  |    5 --
 5 files changed, 9 insertions(+), 240 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 4c6f0e2..fdbf6d6 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -436,45 +436,6 @@ begin_modal_x11 (MetaScreen       *screen,
   return FALSE;
 }
 
-static gboolean
-begin_modal_wayland (MetaScreen       *screen,
-                     MetaPlugin       *plugin,
-                     MetaModalOptions  options,
-                     guint32           timestamp)
-{
-  MetaWaylandCompositor *compositor;
-  gboolean pointer_grabbed = FALSE;
-  gboolean keyboard_grabbed = FALSE;
-
-  compositor = meta_wayland_compositor_get_default ();
-
-  if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
-    {
-      if (!meta_wayland_pointer_begin_modal (&compositor->seat->pointer))
-        goto fail;
-
-      pointer_grabbed = TRUE;
-    }
-  if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
-    {
-      if (!meta_wayland_keyboard_begin_modal (&compositor->seat->keyboard,
-                                              timestamp))
-        goto fail;
-
-      keyboard_grabbed = TRUE;
-    }
-
-  return TRUE;
-
- fail:
-  if (pointer_grabbed)
-    meta_wayland_pointer_end_modal (&compositor->seat->pointer);
-  if (keyboard_grabbed)
-    meta_wayland_keyboard_end_modal (&compositor->seat->keyboard, timestamp);
-
-  return FALSE;
-}
-
 gboolean
 meta_begin_modal_for_plugin (MetaScreen       *screen,
                              MetaPlugin       *plugin,
@@ -493,7 +454,7 @@ meta_begin_modal_for_plugin (MetaScreen       *screen,
     return FALSE;
 
   if (meta_is_wayland_compositor ())
-    ok = begin_modal_wayland (screen, plugin, options, timestamp);
+    ok = TRUE;
   else
     ok = begin_modal_x11 (screen, plugin, options, timestamp);
   if (!ok)
@@ -521,15 +482,7 @@ meta_end_modal_for_plugin (MetaScreen     *screen,
 
   g_return_if_fail (compositor->modal_plugin == plugin);
 
-  if (meta_is_wayland_compositor ())
-    {
-      MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
-
-      meta_wayland_pointer_end_modal (&compositor->seat->pointer);
-      meta_wayland_keyboard_end_modal (&compositor->seat->keyboard,
-                                       timestamp);
-    }
-  else
+  if (!meta_is_wayland_compositor ())
     {
       XIUngrabDevice (xdpy, META_VIRTUAL_CORE_POINTER_ID, timestamp);
       XIUngrabDevice (xdpy, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 19faa8c..c5c3b2a 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -281,31 +281,6 @@ static const MetaWaylandKeyboardGrabInterface
   default_grab_modifiers,
 };
 
-static gboolean
-modal_key (MetaWaylandKeyboardGrab *grab,
-          uint32_t                 time,
-          uint32_t                 key,
-          uint32_t                 state)
-{
-  /* FALSE means: let the event through to clutter */
-  return FALSE;
-}
-
-static void
-modal_modifiers (MetaWaylandKeyboardGrab *grab,
-                uint32_t                 serial,
-                uint32_t                 mods_depressed,
-                uint32_t                 mods_latched,
-                uint32_t                 mods_locked,
-                uint32_t                 group)
-{
-}
-
-static MetaWaylandKeyboardGrabInterface modal_grab = {
-  modal_key,
-  modal_modifiers,
-};
-
 gboolean
 meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
                             struct wl_display   *display)
@@ -521,26 +496,13 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
           struct wl_display *display = wl_client_get_display (client);
           uint32_t serial = wl_display_next_serial (display);
 
-          /* If we're in a modal grab, the client is focused but doesn't see
-             modifiers or pressed keys (and fix that up when we exit the modal) */
-          if (keyboard->grab->interface == &modal_grab)
-            {
-              struct wl_array empty;
-              wl_array_init (&empty);
-
-              wl_keyboard_send_modifiers (keyboard->focus_resource, serial, 0, 0, 0, 0);
-              wl_keyboard_send_enter (keyboard->focus_resource, serial, keyboard->focus_surface->resource, 
&empty);
-            }
-          else
-            {
-              wl_keyboard_send_modifiers (keyboard->focus_resource, serial,
-                                          keyboard->modifier_state.mods_depressed,
-                                          keyboard->modifier_state.mods_latched,
-                                          keyboard->modifier_state.mods_locked,
-                                          keyboard->modifier_state.group);
-              wl_keyboard_send_enter (keyboard->focus_resource, serial, keyboard->focus_surface->resource,
-                                      &keyboard->keys);
-            }
+          wl_keyboard_send_modifiers (keyboard->focus_resource, serial,
+                                      keyboard->modifier_state.mods_depressed,
+                                      keyboard->modifier_state.mods_latched,
+                                      keyboard->modifier_state.mods_locked,
+                                      keyboard->modifier_state.group);
+          wl_keyboard_send_enter (keyboard->focus_resource, serial, keyboard->focus_surface->resource,
+                                  &keyboard->keys);
 
           wl_resource_add_destroy_listener (keyboard->focus_resource, &keyboard->focus_resource_listener);
           keyboard->focus_serial = serial;
@@ -574,85 +536,6 @@ meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard)
   wl_array_release (&keyboard->keys);
 }
 
-gboolean
-meta_wayland_keyboard_begin_modal (MetaWaylandKeyboard *keyboard,
-                                  guint32              timestamp)
-{
-  MetaWaylandKeyboardGrab *grab;
-  uint32_t *end = (void *) ((char *) keyboard->keys.data +
-                           keyboard->keys.size);
-  uint32_t *k;
-  uint32_t serial;
-
-  meta_verbose ("Asked to acquire modal keyboard grab, timestamp %d\n", timestamp);
-
-  if (keyboard->grab != &keyboard->default_grab)
-    return FALSE;
-
-  if (keyboard->focus_surface)
-    {
-      /* Fake key release events for the focused app */
-      serial = wl_display_next_serial (keyboard->display);
-      keyboard->grab->interface->modifiers (keyboard->grab,
-                                           serial,
-                                           0, 0, 0, 0);
-
-      for (k = keyboard->keys.data; k < end; k++)
-       {
-         keyboard->grab->interface->key (keyboard->grab,
-                                         timestamp,
-                                         *k, 0);
-       }
-    }
-
-  grab = g_slice_new0 (MetaWaylandKeyboardGrab);
-  grab->interface = &modal_grab;
-  meta_wayland_keyboard_start_grab (keyboard, grab);
-
-  meta_verbose ("Acquired modal keyboard grab, timestamp %d\n", timestamp);
-
-  return TRUE;
-}
-
-void
-meta_wayland_keyboard_end_modal (MetaWaylandKeyboard *keyboard,
-                                guint32              timestamp)
-{
-  MetaWaylandKeyboardGrab *grab;
-  uint32_t *end = (void *) ((char *) keyboard->keys.data +
-                           keyboard->keys.size);
-  uint32_t *k;
-  uint32_t serial;
-
-  grab = keyboard->grab;
-
-  g_assert (grab->interface == &modal_grab);
-
-  meta_wayland_keyboard_end_grab (keyboard);
-  g_slice_free (MetaWaylandKeyboardGrab, grab);
-
-  if (keyboard->focus_surface)
-    {
-      /* Fake key press events for the focused app */
-      serial = wl_display_next_serial (keyboard->display);
-      keyboard->grab->interface->modifiers (keyboard->grab,
-                                           serial,
-                                           keyboard->modifier_state.mods_depressed,
-                                           keyboard->modifier_state.mods_latched, 
-                                           keyboard->modifier_state.mods_locked,
-                                           keyboard->modifier_state.group);
-
-      for (k = keyboard->keys.data; k < end; k++)
-       {
-         keyboard->grab->interface->key (keyboard->grab,
-                                         timestamp,
-                                         *k, 1);
-       }
-    }
-
-  meta_verbose ("Released modal keyboard grab, timestamp %d\n", timestamp);
-}
-
 void
 meta_wayland_keyboard_set_keymap_names (MetaWaylandKeyboard *keyboard,
                                        const char          *rules,
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index 969e4b2..24b36af 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -142,13 +142,6 @@ meta_wayland_keyboard_start_grab (MetaWaylandKeyboard *device,
 void
 meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard);
 
-gboolean
-meta_wayland_keyboard_begin_modal (MetaWaylandKeyboard *keyboard,
-                                  guint32              timestamp);
-void
-meta_wayland_keyboard_end_modal   (MetaWaylandKeyboard *keyboard,
-                                  guint32              timestamp);
-
 void
 meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard);
 
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 2692c85..7d15ce4 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -398,61 +398,6 @@ meta_wayland_pointer_end_grab (MetaWaylandPointer *pointer)
   interface->focus (pointer->grab, pointer->current, NULL);
 }
 
-static void
-modal_focus (MetaWaylandPointerGrab *grab,
-            MetaWaylandSurface     *surface,
-            const ClutterEvent     *event)
-{
-}
-
-static void
-modal_motion (MetaWaylandPointerGrab *grab,
-             const ClutterEvent     *event)
-{
-}
-
-static void
-modal_button (MetaWaylandPointerGrab *grab,
-             const ClutterEvent     *event)
-{
-}
-
-static MetaWaylandPointerGrabInterface modal_grab = {
-  modal_focus,
-  modal_motion,
-  modal_button
-};
-
-gboolean
-meta_wayland_pointer_begin_modal (MetaWaylandPointer *pointer)
-{
-  MetaWaylandPointerGrab *grab;
-
-  if (pointer->grab != &pointer->default_grab)
-    return FALSE;
-
-  meta_wayland_pointer_set_focus (pointer, NULL);
-
-  grab = g_slice_new0 (MetaWaylandPointerGrab);
-  grab->interface = &modal_grab;
-  meta_wayland_pointer_start_grab (pointer, grab);
-
-  return TRUE;
-}
-
-void
-meta_wayland_pointer_end_modal (MetaWaylandPointer *pointer)
-{
-  MetaWaylandPointerGrab *grab;
-
-  grab = pointer->grab;
-
-  g_assert (grab->interface == &modal_grab);
-
-  meta_wayland_pointer_end_grab (pointer);
-  g_slice_free (MetaWaylandPointerGrab, grab);
-}
-
 typedef struct {
   MetaWaylandPointerGrab  generic;
 
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 7fa9bf5..08b6988 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -86,11 +86,6 @@ void
 meta_wayland_pointer_end_grab (MetaWaylandPointer *pointer);
 
 gboolean
-meta_wayland_pointer_begin_modal (MetaWaylandPointer *pointer);
-void
-meta_wayland_pointer_end_modal   (MetaWaylandPointer *pointer);
-
-gboolean
 meta_wayland_pointer_start_popup_grab (MetaWaylandPointer *pointer,
                                       MetaWaylandSurface *popup);
 


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