Window xwindow,
const gchar *name);
static void move_to_current_desktop (GdkSurface *surface);
+static void gdk_x11_toplevel_state_callback (GdkSurface *surface);
/* Return whether time1 is considered later than time2 as far as xserver
* time is concerned. Accounts for wraparound.
{
impl->toplevel = g_new0 (GdkToplevelX11, 1);
impl->toplevel->have_focused = FALSE;
+ g_signal_connect (surface, "notify::state",
+ G_CALLBACK (gdk_x11_toplevel_state_callback),
+ NULL);
}
return impl->toplevel;
if (impl->toplevel->in_frame)
unhook_surface_changed (GDK_SURFACE (impl));
+ g_signal_handlers_disconnect_by_func (GDK_SURFACE (impl),
+ gdk_x11_toplevel_state_callback,
+ NULL);
+
_gdk_x11_surface_grab_check_destroy (GDK_SURFACE (impl));
if (!GDK_SURFACE_DESTROYED (impl))
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
+ case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_value_set_enum (value, surface->fullscreen_mode);
break;
+ case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
+ g_value_set_boolean (value, surface->shortcuts_inhibited);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
return gdk_x11_surface_supports_edge_constraints (GDK_SURFACE (toplevel));
}
+static void
+gdk_x11_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
+ GdkEvent *gdk_event)
+{
+ GdkSurface *surface = GDK_SURFACE (toplevel);
+ GdkSeat *gdk_seat;
+ GdkGrabStatus status;
+
+ if (surface->shortcuts_inhibited)
+ return; /* Already inhibited */
+
+ if (!(surface->state & GDK_SURFACE_STATE_FOCUSED))
+ return;
+
+ gdk_seat = gdk_surface_get_seat_from_event (surface, gdk_event);
+
+ if (!(gdk_seat_get_capabilities (gdk_seat) & GDK_SEAT_CAPABILITY_KEYBOARD))
+ return;
+
+ status = gdk_seat_grab (gdk_seat, surface, GDK_SEAT_CAPABILITY_KEYBOARD,
+ TRUE, NULL, gdk_event, NULL, NULL);
+
+ if (status != GDK_GRAB_SUCCESS)
+ return;
+
+ surface->shortcuts_inhibited = TRUE;
+ surface->current_shortcuts_inhibited_seat = gdk_seat;
+ g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
+}
+
+static void
+gdk_x11_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
+{
+ GdkSurface *surface = GDK_SURFACE (toplevel);
+ GdkSeat *gdk_seat;
+
+ if (!surface->shortcuts_inhibited)
+ return; /* Not inhibited */
+
+ gdk_seat = surface->current_shortcuts_inhibited_seat;
+ gdk_seat_ungrab (gdk_seat);
+ surface->current_shortcuts_inhibited_seat = NULL;
+
+ surface->shortcuts_inhibited = FALSE;
+ g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
+}
+
+static void
+gdk_x11_toplevel_state_callback (GdkSurface *surface)
+{
+ if (surface->state & GDK_SURFACE_STATE_FOCUSED)
+ return;
+
+ if (surface->shortcuts_inhibited)
+ gdk_x11_toplevel_restore_system_shortcuts (GDK_TOPLEVEL (surface));
+}
+
static void
gdk_x11_toplevel_iface_init (GdkToplevelInterface *iface)
{
iface->focus = gdk_x11_toplevel_focus;
iface->show_window_menu = gdk_x11_toplevel_show_window_menu;
iface->supports_edge_constraints = gdk_x11_toplevel_supports_edge_constraints;
+ iface->inhibit_system_shortcuts = gdk_x11_toplevel_inhibit_system_shortcuts;
+ iface->restore_system_shortcuts = gdk_x11_toplevel_restore_system_shortcuts;
}
typedef struct {