Commit 43633d6b authored by Marco Trevisan's avatar Marco Trevisan Committed by Marco Trevisan

window: Add is_focusable class method

Implement is_focusable for both x11 and wayland and just use this check
so that we can abstract things more and be less dependent on window backend.

!421
parent fdd531f3
......@@ -1224,10 +1224,7 @@ get_default_focus_window (MetaStack *stack,
if (window->unmaps_pending > 0)
continue;
if (window->unmanaging)
continue;
if (!(window->input || window->take_focus))
if (!meta_window_is_focusable (window))
continue;
if (!meta_window_should_be_showing (window))
......
......@@ -570,6 +570,7 @@ struct _MetaWindowClass
ClutterInputDevice *source);
gboolean (*shortcuts_inhibited) (MetaWindow *window,
ClutterInputDevice *source);
gboolean (*is_focusable) (MetaWindow *window);
gboolean (*is_stackable) (MetaWindow *window);
gboolean (*are_updates_frozen) (MetaWindow *window);
};
......@@ -664,6 +665,8 @@ void meta_window_update_unfocused_button_grabs (MetaWindow *window);
void meta_window_set_focused_internal (MetaWindow *window,
gboolean focused);
gboolean meta_window_is_focusable (MetaWindow *window);
void meta_window_current_workspace_changed (MetaWindow *window);
void meta_window_show_menu (MetaWindow *window,
......
......@@ -2223,7 +2223,7 @@ window_state_on_map (MetaWindow *window,
/* don't initially focus windows that are intended to not accept
* focus
*/
if (!(window->input || window->take_focus))
if (!meta_window_is_focusable (window))
{
*takes_focus = FALSE;
return;
......@@ -8529,6 +8529,15 @@ meta_window_shortcuts_inhibited (MetaWindow *window,
return META_WINDOW_GET_CLASS (window)->shortcuts_inhibited (window, source);
}
gboolean
meta_window_is_focusable (MetaWindow *window)
{
if (window->unmanaging)
return FALSE;
return META_WINDOW_GET_CLASS (window)->is_focusable (window);
}
gboolean
meta_window_is_stackable (MetaWindow *window)
{
......
......@@ -141,7 +141,7 @@ static void
meta_window_wayland_focus (MetaWindow *window,
guint32 timestamp)
{
if (window->input)
if (meta_window_is_focusable (window))
meta_x11_display_set_input_focus_window (window->display->x11_display,
window,
FALSE,
......@@ -585,6 +585,12 @@ meta_window_wayland_shortcuts_inhibited (MetaWindow *window,
return meta_wayland_compositor_is_shortcuts_inhibited (compositor, source);
}
static gboolean
meta_window_wayland_is_focusable (MetaWindow *window)
{
return window->input;
}
static gboolean
meta_window_wayland_is_stackable (MetaWindow *window)
{
......@@ -618,6 +624,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
window_class->get_client_pid = meta_window_wayland_get_client_pid;
window_class->force_restore_shortcuts = meta_window_wayland_force_restore_shortcuts;
window_class->shortcuts_inhibited = meta_window_wayland_shortcuts_inhibited;
window_class->is_focusable = meta_window_wayland_is_focusable;
window_class->is_stackable = meta_window_wayland_is_stackable;
window_class->are_updates_frozen = meta_window_wayland_are_updates_frozen;
}
......
......@@ -752,8 +752,7 @@ meta_window_x11_focus (MetaWindow *window,
* Still, we have to do this or keynav breaks for these windows.
*/
if (window->frame &&
(window->shaded ||
!(window->input || window->take_focus)))
(window->shaded || !meta_window_is_focusable (window)))
{
meta_topic (META_DEBUG_FOCUS,
"Focusing frame of %s\n", window->desc);
......@@ -1629,6 +1628,12 @@ meta_window_x11_shortcuts_inhibited (MetaWindow *window,
return FALSE;
}
static gboolean
meta_window_x11_is_focusable (MetaWindow *window)
{
return window->input || window->take_focus;
}
static gboolean
meta_window_x11_is_stackable (MetaWindow *window)
{
......@@ -1671,6 +1676,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
window_class->get_client_pid = meta_window_x11_get_client_pid;
window_class->force_restore_shortcuts = meta_window_x11_force_restore_shortcuts;
window_class->shortcuts_inhibited = meta_window_x11_shortcuts_inhibited;
window_class->is_focusable = meta_window_x11_is_focusable;
window_class->is_stackable = meta_window_x11_is_stackable;
window_class->are_updates_frozen = meta_window_x11_are_updates_frozen;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment