gtk-shell: extend the protocol with shell capabilities

Add the concept of shell capabilities, which allow the compositor
to advertise support for the app menu and the global menubar,
which are then propagated as GdkSettings.

https://bugzilla.gnome.org/show_bug.cgi?id=707129
This commit is contained in:
Giovanni Campagna 2013-09-03 09:54:53 +02:00
parent ed9f55d521
commit 7f8bf41633
4 changed files with 56 additions and 0 deletions

View File

@ -170,6 +170,9 @@ gdk_registry_handle_global(void *data, struct wl_registry *registry, uint32_t id
} else if (strcmp(interface, "gtk_shell") == 0) {
display_wayland->gtk_shell =
wl_registry_bind(display_wayland->wl_registry, id, &gtk_shell_interface, 1);
_gdk_wayland_screen_set_has_gtk_shell (display_wayland->screen);
/* We need another roundtrip to receive the shell capabilities */
wait_for_roundtrip(display_wayland);
} else if (strcmp(interface, "wl_output") == 0) {
output =
wl_registry_bind(display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2));

View File

@ -171,6 +171,8 @@ int _gdk_wayland_screen_get_output_refresh_rate (GdkScreen *screen,
guint32 _gdk_wayland_screen_get_output_scale (GdkScreen *screen,
struct wl_output *output);
void _gdk_wayland_screen_set_has_gtk_shell (GdkScreen *screen);
void _gdk_wayland_window_set_device_grabbed (GdkWindow *window,
GdkDevice *device,
struct wl_seat *seat,

View File

@ -68,6 +68,8 @@ struct _GdkWaylandScreen
GHashTable *settings;
GsdXftSettings xft_settings;
guint32 shell_capabilities;
};
struct _GdkWaylandScreenClass
@ -604,6 +606,28 @@ init_settings (GdkScreen *screen)
update_xft_settings (screen);
}
static void
gtk_shell_handle_capabilities (void *data,
struct gtk_shell *shell,
uint32_t capabilities)
{
GdkWaylandScreen *screen_wayland = data;
screen_wayland->shell_capabilities = capabilities;
}
struct gtk_shell_listener gdk_screen_gtk_shell_listener = {
gtk_shell_handle_capabilities
};
void
_gdk_wayland_screen_set_has_gtk_shell (GdkScreen *screen)
{
GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (GDK_WAYLAND_SCREEN (screen)->display);
gtk_shell_add_listener (wayland_display->gtk_shell, &gdk_screen_gtk_shell_listener, screen);
}
static void
set_value_from_entry (GdkScreen *screen,
TranslationEntry *entry,
@ -657,6 +681,18 @@ set_value_from_entry (GdkScreen *screen,
}
}
static gboolean
set_capability_setting (GdkScreen *screen,
GValue *value,
enum gtk_shell_capability test)
{
GdkWaylandScreen *wayland_screen = GDK_WAYLAND_SCREEN (screen);
g_value_set_boolean (value, (wayland_screen->shell_capabilities & test) == test);
return TRUE;
}
static gboolean
gdk_wayland_screen_get_setting (GdkScreen *screen,
const gchar *name,
@ -673,6 +709,12 @@ gdk_wayland_screen_get_setting (GdkScreen *screen,
return TRUE;
}
if (strcmp (name, "gtk-shell-shows-app-menu") == 0)
return set_capability_setting (screen, value, GTK_SHELL_CAPABILITY_GLOBAL_APP_MENU);
if (strcmp (name, "gtk-shell-shows-menubar") == 0)
return set_capability_setting (screen, value, GTK_SHELL_CAPABILITY_GLOBAL_MENU_BAR);
return FALSE;
}

View File

@ -1,6 +1,15 @@
<protocol name="gtk">
<interface name="gtk_shell" version="1">
<enum name="capability">
<entry name="global_app_menu" value="1"/>
<entry name="global_menu_bar" value="2"/>
</enum>
<event name="capabilities">
<arg name="capabilities" type="uint"/>
</event>
<request name="get_gtk_surface">
<arg name="gtk_surface" type="new_id" interface="gtk_surface"/>
<arg name="surface" type="object" interface="wl_surface"/>