diff --git a/src/core/window.c b/src/core/window.c index ea56f3328..3d6241e38 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -5176,6 +5176,62 @@ meta_window_lower (MetaWindow *window) meta_stack_lower (window->display->stack, window); } +static gboolean +lower_window_and_transients (MetaWindow *window, + gpointer user_data) +{ + MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; + + meta_window_lower (window); + + meta_window_foreach_transient (window, lower_window_and_transients, NULL); + + if (meta_prefs_get_raise_on_click ()) + { + /* Move window to the back of the focusing workspace's MRU list. + * Do extra sanity checks to avoid possible race conditions. + * (Borrowed from window.c.) + */ + if (workspace_manager->active_workspace && + meta_window_located_on_workspace (window, + workspace_manager->active_workspace)) + { + GList *link; + link = g_list_find (workspace_manager->active_workspace->mru_list, + window); + g_assert (link); + + workspace_manager->active_workspace->mru_list = + g_list_remove_link (workspace_manager->active_workspace->mru_list, + link); + g_list_free (link); + + workspace_manager->active_workspace->mru_list = + g_list_append (workspace_manager->active_workspace->mru_list, + window); + } + } + + return FALSE; +} + +void +meta_window_lower_with_transients (MetaWindow *window, + uint32_t timestamp) +{ + MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; + + lower_window_and_transients (window, NULL); + + /* Rather than try to figure that out whether we just lowered + * the focus window, assume that's always the case. (Typically, + * this will be invoked via keyboard action or by a mouse action; + * in either case the window or a modal child will have been focused.) */ + meta_workspace_focus_default_window (workspace_manager->active_workspace, + NULL, + timestamp); +} + /* * Move window to the requested workspace; append controls whether new WS * should be created if one does not exist. diff --git a/src/meta/window.h b/src/meta/window.h index 3157d44ee..2b69269d1 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -311,6 +311,10 @@ void meta_window_raise (MetaWindow *window); META_EXPORT void meta_window_lower (MetaWindow *window); +META_EXPORT +void meta_window_lower_with_transients (MetaWindow *window, + uint32_t timestamp); + META_EXPORT const char *meta_window_get_title (MetaWindow *window); diff --git a/src/x11/meta-x11-window-control.c b/src/x11/meta-x11-window-control.c index 3af43ce0c..4754be549 100644 --- a/src/x11/meta-x11-window-control.c +++ b/src/x11/meta-x11-window-control.c @@ -61,62 +61,14 @@ meta_x11_wm_queue_frame_resize (MetaX11Display *x11_display, meta_window_frame_size_changed (window); } -static gboolean -lower_window_and_transients (MetaWindow *window, - gpointer data) -{ - MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; - - meta_window_lower (window); - - meta_window_foreach_transient (window, lower_window_and_transients, NULL); - - if (meta_prefs_get_raise_on_click ()) - { - /* Move window to the back of the focusing workspace's MRU list. - * Do extra sanity checks to avoid possible race conditions. - * (Borrowed from window.c.) - */ - if (workspace_manager->active_workspace && - meta_window_located_on_workspace (window, - workspace_manager->active_workspace)) - { - GList* link; - link = g_list_find (workspace_manager->active_workspace->mru_list, - window); - g_assert (link); - - workspace_manager->active_workspace->mru_list = - g_list_remove_link (workspace_manager->active_workspace->mru_list, - link); - g_list_free (link); - - workspace_manager->active_workspace->mru_list = - g_list_append (workspace_manager->active_workspace->mru_list, - window); - } - } - - return FALSE; -} - void meta_x11_wm_user_lower_and_unfocus (MetaX11Display *x11_display, Window frame_xwindow, uint32_t timestamp) { MetaWindow *window = window_from_frame (x11_display, frame_xwindow); - MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; - lower_window_and_transients (window, NULL); - - /* Rather than try to figure that out whether we just lowered - * the focus window, assume that's always the case. (Typically, - * this will be invoked via keyboard action or by a mouse action; - * in either case the window or a modal child will have been focused.) */ - meta_workspace_focus_default_window (workspace_manager->active_workspace, - NULL, - timestamp); + meta_window_lower_with_transients (window, timestamp); } void