[mutter] wayland: Move out gtk_shell from meta-wayland-surface.c
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Move out gtk_shell from meta-wayland-surface.c
- Date: Thu, 25 Aug 2016 04:45:20 +0000 (UTC)
commit c73d3d9d8324c1e3681e620b8bce34f8da6f3f1d
Author: Jonas Ådahl <jadahl gmail com>
Date: Tue Jun 28 10:05:55 2016 +0800
wayland: Move out gtk_shell from meta-wayland-surface.c
https://bugzilla.gnome.org/show_bug.cgi?id=769936
src/Makefile.am | 2 +
src/wayland/meta-wayland-gtk-shell.c | 213 ++++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-gtk-shell.h | 27 +++++
src/wayland/meta-wayland-surface.c | 176 +---------------------------
4 files changed, 244 insertions(+), 174 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4a54eed..e6b8bf3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -347,6 +347,8 @@ libmutter_la_SOURCES += \
wayland/meta-wayland-xdg-shell.h \
wayland/meta-wayland-wl-shell.c \
wayland/meta-wayland-wl-shell.h \
+ wayland/meta-wayland-gtk-shell.c \
+ wayland/meta-wayland-gtk-shell.h \
$(NULL)
endif
diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c
new file mode 100644
index 0000000..2edfe7c
--- /dev/null
+++ b/src/wayland/meta-wayland-gtk-shell.c
@@ -0,0 +1,213 @@
+/*
+ * Wayland Support
+ *
+ * Copyright (C) 2012,2013 Intel Corporation
+ * 2013-2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "wayland/meta-wayland-gtk-shell.h"
+
+#include "core/bell.h"
+#include "core/window-private.h"
+#include "wayland/meta-wayland-private.h"
+#include "wayland/meta-wayland-surface.h"
+#include "wayland/meta-wayland-versions.h"
+#include "wayland/meta-window-wayland.h"
+
+#include "gtk-shell-server-protocol.h"
+
+static void
+gtk_surface_destructor (struct wl_resource *resource)
+{
+ MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+
+ surface->gtk_surface = NULL;
+}
+
+static void
+gtk_surface_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)
+{
+ MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+
+ /* Broken client, let it die instead of us */
+ if (!surface->window)
+ {
+ meta_warning ("meta-wayland-surface: set_dbus_properties called with invalid window!\n");
+ return;
+ }
+
+ meta_window_set_gtk_dbus_properties (surface->window,
+ application_id,
+ unique_bus_name,
+ app_menu_path,
+ menubar_path,
+ application_object_path,
+ window_object_path);
+}
+
+static void
+gtk_surface_set_modal (struct wl_client *client,
+ struct wl_resource *resource)
+{
+ MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+
+ if (surface->is_modal)
+ return;
+
+ surface->is_modal = TRUE;
+ meta_window_set_type (surface->window, META_WINDOW_MODAL_DIALOG);
+}
+
+static void
+gtk_surface_unset_modal (struct wl_client *client,
+ struct wl_resource *resource)
+{
+ MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+
+ if (!surface->is_modal)
+ return;
+
+ surface->is_modal = FALSE;
+ meta_window_set_type (surface->window, META_WINDOW_NORMAL);
+}
+
+static void
+gtk_surface_present (struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t timestamp)
+{
+ MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+ MetaWindow *window = surface->window;
+
+ if (!window)
+ return;
+
+ meta_window_activate_full (window, timestamp,
+ META_CLIENT_TYPE_APPLICATION, NULL);
+}
+
+static const struct gtk_surface1_interface meta_wayland_gtk_surface_interface = {
+ gtk_surface_set_dbus_properties,
+ gtk_surface_set_modal,
+ gtk_surface_unset_modal,
+ gtk_surface_present,
+};
+
+static void
+gtk_shell_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->gtk_surface != NULL)
+ {
+ wl_resource_post_error (surface_resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "gtk_shell::get_gtk_surface already requested");
+ return;
+ }
+
+ surface->gtk_surface = wl_resource_create (client,
+ >k_surface1_interface,
+ wl_resource_get_version (resource),
+ id);
+ wl_resource_set_implementation (surface->gtk_surface,
+ &meta_wayland_gtk_surface_interface,
+ surface, gtk_surface_destructor);
+}
+
+static void
+gtk_shell_set_startup_id (struct wl_client *client,
+ struct wl_resource *resource,
+ const char *startup_id)
+{
+ MetaDisplay *display;
+
+ display = meta_get_display ();
+ meta_startup_notification_remove_sequence (display->startup_notification,
+ startup_id);
+}
+
+static void
+gtk_shell_system_bell (struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *gtk_surface_resource)
+{
+ MetaDisplay *display = meta_get_display ();
+
+ if (gtk_surface_resource)
+ {
+ MetaWaylandSurface *surface =
+ wl_resource_get_user_data (gtk_surface_resource);
+
+ if (!surface->window)
+ return;
+
+ meta_bell_notify (display, surface->window);
+ }
+ else
+ {
+ meta_bell_notify (display, NULL);
+ }
+}
+
+static const struct gtk_shell1_interface meta_wayland_gtk_shell_interface = {
+ gtk_shell_get_gtk_surface,
+ gtk_shell_set_startup_id,
+ gtk_shell_system_bell,
+};
+
+static void
+bind_gtk_shell (struct wl_client *client,
+ void *data,
+ guint32 version,
+ guint32 id)
+{
+ struct wl_resource *resource;
+ uint32_t capabilities = 0;
+
+ resource = wl_resource_create (client, >k_shell1_interface, version, id);
+ wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface,
+ data, NULL);
+
+ if (!meta_prefs_get_show_fallback_app_menu ())
+ capabilities = GTK_SHELL1_CAPABILITY_GLOBAL_APP_MENU;
+
+ gtk_shell1_send_capabilities (resource, capabilities);
+}
+
+void
+meta_wayland_gtk_shell_init (MetaWaylandCompositor *compositor)
+{
+ if (wl_global_create (compositor->wayland_display,
+ >k_shell1_interface,
+ META_GTK_SHELL1_VERSION,
+ compositor, bind_gtk_shell) == NULL)
+ g_error ("Failed to register a global gtk-shell object");
+}
diff --git a/src/wayland/meta-wayland-gtk-shell.h b/src/wayland/meta-wayland-gtk-shell.h
new file mode 100644
index 0000000..888ee40
--- /dev/null
+++ b/src/wayland/meta-wayland-gtk-shell.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_WAYLAND_GTK_SHELL_H
+#define META_WAYLAND_GTK_SHELL_H
+
+#include "wayland/meta-wayland.h"
+
+void meta_wayland_gtk_shell_init (MetaWaylandCompositor *compositor);
+
+#endif /* META_WAYLAND_GTK_SHELL_H */
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index f4dfd1f..6ab79c1 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -31,7 +31,6 @@
#include <gobject/gvaluecollector.h>
#include <wayland-server.h>
-#include "gtk-shell-server-protocol.h"
#include "meta-wayland-private.h"
#include "meta-xwayland-private.h"
@@ -44,12 +43,12 @@
#include "meta-wayland-outputs.h"
#include "meta-wayland-xdg-shell.h"
#include "meta-wayland-wl-shell.h"
+#include "meta-wayland-gtk-shell.h"
#include "meta-cursor-tracker-private.h"
#include "display-private.h"
#include "window-private.h"
#include "meta-window-wayland.h"
-#include "bell.h"
#include "compositor/region-utils.h"
@@ -1319,172 +1318,6 @@ meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface,
}
static void
-gtk_surface_destructor (struct wl_resource *resource)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- surface->gtk_surface = NULL;
-}
-
-static void
-gtk_surface_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)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- /* Broken client, let it die instead of us */
- if (!surface->window)
- {
- meta_warning ("meta-wayland-surface: set_dbus_properties called with invalid window!\n");
- return;
- }
-
- meta_window_set_gtk_dbus_properties (surface->window,
- application_id,
- unique_bus_name,
- app_menu_path,
- menubar_path,
- application_object_path,
- window_object_path);
-}
-
-static void
-gtk_surface_set_modal (struct wl_client *client,
- struct wl_resource *resource)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- if (surface->is_modal)
- return;
-
- surface->is_modal = TRUE;
- meta_window_set_type (surface->window, META_WINDOW_MODAL_DIALOG);
-}
-
-static void
-gtk_surface_unset_modal (struct wl_client *client,
- struct wl_resource *resource)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- if (!surface->is_modal)
- return;
-
- surface->is_modal = FALSE;
- meta_window_set_type (surface->window, META_WINDOW_NORMAL);
-}
-
-static void
-gtk_surface_present (struct wl_client *client,
- struct wl_resource *resource,
- uint32_t timestamp)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
- MetaWindow *window = surface->window;
-
- if (!window)
- return;
-
- meta_window_activate_full (window, timestamp,
- META_CLIENT_TYPE_APPLICATION, NULL);
-}
-
-static const struct gtk_surface1_interface meta_wayland_gtk_surface_interface = {
- gtk_surface_set_dbus_properties,
- gtk_surface_set_modal,
- gtk_surface_unset_modal,
- gtk_surface_present,
-};
-
-static void
-gtk_shell_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->gtk_surface != NULL)
- {
- wl_resource_post_error (surface_resource,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "gtk_shell::get_gtk_surface already requested");
- return;
- }
-
- surface->gtk_surface = wl_resource_create (client,
- >k_surface1_interface,
- wl_resource_get_version (resource),
- id);
- wl_resource_set_implementation (surface->gtk_surface, &meta_wayland_gtk_surface_interface, surface,
gtk_surface_destructor);
-}
-
-static void
-gtk_shell_set_startup_id (struct wl_client *client,
- struct wl_resource *resource,
- const char *startup_id)
-{
- MetaDisplay *display;
-
- display = meta_get_display ();
- meta_startup_notification_remove_sequence (display->startup_notification,
- startup_id);
-}
-
-static void
-gtk_shell_system_bell (struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *gtk_surface_resource)
-{
- MetaDisplay *display = meta_get_display ();
-
- if (gtk_surface_resource)
- {
- MetaWaylandSurface *surface =
- wl_resource_get_user_data (gtk_surface_resource);
-
- if (!surface->window)
- return;
-
- meta_bell_notify (display, surface->window);
- }
- else
- {
- meta_bell_notify (display, NULL);
- }
-}
-
-static const struct gtk_shell1_interface meta_wayland_gtk_shell_interface = {
- gtk_shell_get_gtk_surface,
- gtk_shell_set_startup_id,
- gtk_shell_system_bell,
-};
-
-static void
-bind_gtk_shell (struct wl_client *client,
- void *data,
- guint32 version,
- guint32 id)
-{
- struct wl_resource *resource;
- uint32_t capabilities = 0;
-
- resource = wl_resource_create (client, >k_shell1_interface, version, id);
- wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL);
-
- if (!meta_prefs_get_show_fallback_app_menu ())
- capabilities = GTK_SHELL1_CAPABILITY_GLOBAL_APP_MENU;
-
- gtk_shell1_send_capabilities (resource, capabilities);
-}
-
-static void
unparent_actor (MetaWaylandSurface *surface)
{
ClutterActor *parent_actor;
@@ -1734,12 +1567,7 @@ meta_wayland_shell_init (MetaWaylandCompositor *compositor)
{
meta_wayland_xdg_shell_init (compositor);
meta_wayland_wl_shell_init (compositor);
-
- if (wl_global_create (compositor->wayland_display,
- >k_shell1_interface,
- META_GTK_SHELL1_VERSION,
- compositor, bind_gtk_shell) == NULL)
- g_error ("Failed to register a global gtk-shell object");
+ meta_wayland_gtk_shell_init (compositor);
if (wl_global_create (compositor->wayland_display,
&wl_subcompositor_interface,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]