[mutter/wip/wayland-work: 48/54] Add a private gtk-mutter protocol



commit 42d0f6da9755e898ba7c30a5c77737f56cdb341c
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Fri Aug 30 09:40:36 2013 +0200

    Add a private gtk-mutter protocol
    
    Add a new interface, gtk_shell, than can be used by gtk to
    retrieve a surface extension called gtk_surface, which will be
    used to communicate with mutter all the GTK extensions to EWMH
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707128

 protocol/gtk-shell.xml             |   21 ++++++++++++
 src/Makefile.am                    |    3 ++
 src/wayland/meta-wayland-private.h |    1 +
 src/wayland/meta-wayland.c         |   62 ++++++++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/protocol/gtk-shell.xml b/protocol/gtk-shell.xml
new file mode 100644
index 0000000..ccec34a
--- /dev/null
+++ b/protocol/gtk-shell.xml
@@ -0,0 +1,21 @@
+<protocol name="gtk">
+
+  <interface name="gtk_shell" version="1">
+    <request name="get_gtk_surface">
+      <arg name="gtk_surface" type="new_id" interface="gtk_surface"/>
+      <arg name="surface" type="object" interface="wl_surface"/>
+    </request>
+  </interface>
+
+  <interface name="gtk_surface" version="1">
+    <request name="set_dbus_properties">
+      <arg name="application_id" type="string" allow-null="true"/>
+      <arg name="app_menu_path" type="string" allow-null="true"/>
+      <arg name="menubar_path" type="string" allow-null="true"/>
+      <arg name="window_object_path" type="string" allow-null="true">
+      <arg name="application_object_path" type="string" allow-null="true"/>
+      <arg name="unique_bus_name" type="string" allow-null="true"/>
+    </request>
+  </interface>
+
+</protocol>
diff --git a/src/Makefile.am b/src/Makefile.am
index cf4c6df..a79ed52 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,6 +40,9 @@ mutter_built_sources = \
        $(dbus_xrandr_built_sources)            \
        mutter-enum-types.h                     \
        mutter-enum-types.c                     \
+       wayland/gtk-shell-protocol.c            \
+       wayland/gtk-shell-server-protocol.h     \
+       wayland/gtk-shell-client-protocol.h     \
        wayland/xserver-protocol.c              \
        wayland/xserver-server-protocol.h       \
        wayland/xserver-client-protocol.h
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index cdf5ae8..58e05c8 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -75,6 +75,7 @@ struct _MetaWaylandSurface
   MetaWaylandBufferReference buffer_ref;
   MetaWindow *window;
   gboolean has_shell_surface;
+  gboolean has_gtk_surface;
 
   /* All the pending state, that wl_surface.commit will apply. */
   struct
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 6de434b..4e6e0ff 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -36,6 +36,7 @@
 #include <unistd.h>
 
 #include <wayland-server.h>
+#include "gtk-shell-server-protocol.h"
 
 #include "meta-wayland-private.h"
 #include "meta-xwayland-private.h"
@@ -1300,6 +1301,62 @@ bind_shell (struct wl_client *client,
 }
 
 static void
+set_dbus_properties (struct wl_client   *client,
+                    struct wl_resource *resource,
+                    const char         *application_id,
+                    const char         *app_menu_path,
+                    const char         *menubar_path,
+                    const char         *window_object_path,
+                    const char         *application_object_path,
+                    const char         *unique_bus_name)
+{
+}
+
+static const struct gtk_surface_interface meta_wayland_gtk_surface_interface =
+{
+  set_dbus_properties
+};
+
+static void
+get_gtk_surface (struct wl_client *client,
+                struct wl_resource *resource,
+                guint32 id,
+                struct wl_resource *surface_resource)
+{
+  MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
+
+  if (surface->has_gtk_surface)
+    {
+      wl_resource_post_error (surface_resource,
+                              WL_DISPLAY_ERROR_INVALID_OBJECT,
+                              "wl_shell::get_gtk_surface already requested");
+      return;
+    }
+
+  create_surface_extension (client, resource, id, surface,
+                           &gtk_surface_interface,
+                           &meta_wayland_gtk_surface_interface);
+  surface->has_gtk_surface = TRUE;
+}
+
+static const struct gtk_shell_interface meta_wayland_gtk_shell_interface =
+{
+  get_gtk_surface
+};
+
+static void
+bind_gtk_shell (struct wl_client *client,
+               void             *data,
+               guint32           version,
+               guint32           id)
+{
+  struct wl_resource *resource;
+
+  resource = wl_resource_create (client, &gtk_shell_interface, version, id);
+  wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL);
+}
+
+static void
 stage_destroy_cb (void)
 {
   meta_quit (META_EXIT_SUCCESS);
@@ -1722,6 +1779,11 @@ meta_wayland_init (void)
                        compositor, bind_shell) == NULL)
     g_error ("Failed to register a global shell object");
 
+  if (wl_global_create (compositor->wayland_display,
+                       &gtk_shell_interface, 1,
+                       compositor, bind_gtk_shell) == NULL)
+    g_error ("Failed to register a global gtk-shell object");
+
   clutter_actor_show (compositor->stage);
 
   if (wl_display_add_socket (compositor->wayland_display, "wayland-0"))


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