diff --git a/src/core/display.c b/src/core/display.c index 8b5dc5a07..71daeea14 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1613,7 +1613,6 @@ meta_display_timestamp_too_old (MetaDisplay *display, void meta_display_set_input_focus (MetaDisplay *display, MetaWindow *window, - gboolean focus_frame, guint32 timestamp) { if (meta_display_timestamp_too_old (display, ×tamp)) @@ -1623,7 +1622,7 @@ meta_display_set_input_focus (MetaDisplay *display, if (display->x11_display) { meta_x11_display_set_input_focus (display->x11_display, window, - focus_frame, timestamp); + timestamp); } #endif @@ -1639,7 +1638,7 @@ void meta_display_unset_input_focus (MetaDisplay *display, guint32 timestamp) { - meta_display_set_input_focus (display, NULL, FALSE, timestamp); + meta_display_set_input_focus (display, NULL, timestamp); } void diff --git a/src/meta/display.h b/src/meta/display.h index 12542782d..9e2f2f0f5 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -302,7 +302,6 @@ MetaSelection * meta_display_get_selection (MetaDisplay *display); META_EXPORT void meta_display_set_input_focus (MetaDisplay *display, MetaWindow *window, - gboolean focus_frame, guint32 timestamp); META_EXPORT void meta_display_unset_input_focus (MetaDisplay *display, diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 738c367b1..ba58b883d 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -185,7 +185,6 @@ meta_window_wayland_focus (MetaWindow *window, { meta_display_set_input_focus (window->display, window, - FALSE, timestamp); } } diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h index 0e8820d88..24860e8a7 100644 --- a/src/x11/meta-x11-display-private.h +++ b/src/x11/meta-x11-display-private.h @@ -247,7 +247,6 @@ void meta_x11_display_update_focus_window (MetaX11Display *x11_display, gboolean focused_by_us); void meta_x11_display_set_input_focus (MetaX11Display *x11_display, MetaWindow *window, - gboolean focus_frame, uint32_t timestamp); MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display); diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c index 17be6f4f2..1c4ee1efe 100644 --- a/src/x11/meta-x11-display.c +++ b/src/x11/meta-x11-display.c @@ -2089,16 +2089,28 @@ meta_x11_display_set_input_focus_internal (MetaX11Display *x11_display, void meta_x11_display_set_input_focus (MetaX11Display *x11_display, MetaWindow *window, - gboolean focus_frame, uint32_t timestamp) { Window xwindow; gulong serial; if (window) - xwindow = focus_frame ? window->frame->xwindow : window->xwindow; + { + /* For output-only windows, focus the frame. + * This seems to result in the client window getting key events + * though, so I don't know if it's icccm-compliant. + * + * Still, we have to do this or keynav breaks for these windows. + */ + if (window->frame && !meta_window_is_focusable (window)) + xwindow = window->frame->xwindow; + else + xwindow = window->xwindow; + } else - xwindow = x11_display->no_focus_window; + { + xwindow = x11_display->no_focus_window; + } meta_topic (META_DEBUG_FOCUS, "Setting X11 input focus for window %s to 0x%lx", window ? window->desc : "none", xwindow); diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index c02fef861..a10dfdfbb 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -985,64 +985,59 @@ meta_window_x11_focus (MetaWindow *window, MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11); - /* For output-only windows, focus the frame. - * This seems to result in the client window getting key events - * though, so I don't know if it's icccm-compliant. - * - * Still, we have to do this or keynav breaks for these windows. - */ - if (window->frame && !meta_window_is_focusable (window)) - { - meta_topic (META_DEBUG_FOCUS, - "Focusing frame of %s", window->desc); - meta_display_set_input_focus (window->display, - window, - TRUE, - timestamp); - } - else + gboolean is_output_only_with_frame; + + is_output_only_with_frame = + window->frame && !meta_window_is_focusable (window); + + if (window->input || is_output_only_with_frame) { if (window->input) { meta_topic (META_DEBUG_FOCUS, "Setting input focus on %s since input = true", window->desc); - meta_display_set_input_focus (window->display, - window, - FALSE, - timestamp); } - - if (priv->wm_take_focus) + else if (is_output_only_with_frame) { meta_topic (META_DEBUG_FOCUS, - "Sending WM_TAKE_FOCUS to %s since take_focus = true", - window->desc); - - if (!window->input) - { - /* The "Globally Active Input" window case, where the window - * doesn't want us to call XSetInputFocus on it, but does - * want us to send a WM_TAKE_FOCUS. - * - * Normally, we want to just leave the focus undisturbed until - * the window responds to WM_TAKE_FOCUS, but if we're unmanaging - * the current focus window we *need* to move the focus away, so - * we focus the no focus window before sending WM_TAKE_FOCUS, - * and eventually the default focus window excluding this one, - * if meanwhile we don't get any focus request. - */ - if (window->display->focus_window != NULL && - window->display->focus_window->unmanaging) - { - meta_display_unset_input_focus (window->display, timestamp); - maybe_focus_default_window (window->display, window, - timestamp); - } - } - - request_take_focus (window, timestamp); + "Focusing frame of %s", window->desc); } + + meta_display_set_input_focus (window->display, + window, + timestamp); + } + + if (priv->wm_take_focus) + { + meta_topic (META_DEBUG_FOCUS, + "Sending WM_TAKE_FOCUS to %s since take_focus = true", + window->desc); + + if (!window->input) + { + /* The "Globally Active Input" window case, where the window + * doesn't want us to call XSetInputFocus on it, but does + * want us to send a WM_TAKE_FOCUS. + * + * Normally, we want to just leave the focus undisturbed until + * the window responds to WM_TAKE_FOCUS, but if we're unmanaging + * the current focus window we *need* to move the focus away, so + * we focus the no focus window before sending WM_TAKE_FOCUS, + * and eventually the default focus window excluding this one, + * if meanwhile we don't get any focus request. + */ + if (window->display->focus_window != NULL && + window->display->focus_window->unmanaging) + { + meta_display_unset_input_focus (window->display, timestamp); + maybe_focus_default_window (window->display, window, + timestamp); + } + } + + request_take_focus (window, timestamp); } }