mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
wayland: Move out gtk_shell from meta-wayland-surface.c
https://bugzilla.gnome.org/show_bug.cgi?id=769936
This commit is contained in:
parent
8833991201
commit
c73d3d9d83
@ -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
|
||||
|
||||
|
213
src/wayland/meta-wayland-gtk-shell.c
Normal file
213
src/wayland/meta-wayland-gtk-shell.c
Normal file
@ -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");
|
||||
}
|
27
src/wayland/meta-wayland-gtk-shell.h
Normal file
27
src/wayland/meta-wayland-gtk-shell.h
Normal file
@ -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 */
|
@ -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"
|
||||
|
||||
@ -1318,172 +1317,6 @@ meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface,
|
||||
x, y);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user