summaryrefslogtreecommitdiff
path: root/src/workspace.c
diff options
context:
space:
mode:
authorRay Strode <halfline@hawaii.rr.com>2003-08-15 22:09:55 +0000
committerRay Strode <halfline@src.gnome.org>2003-08-15 22:09:55 +0000
commit2fc880db192cd995bb86697f999295b20fefeed7 (patch)
treea21363a5325bd4669906754c2c916ed0bebec91b /src/workspace.c
parent60a453f5a01c8b3fdcb38771eed9674e3f007500 (diff)
downloadmetacity-2fc880db192cd995bb86697f999295b20fefeed7.tar.gz
Changed MRU list to be per workspace instead of per display, so sticky
2003-08-15 Ray Strode <halfline@hawaii.rr.com> Changed MRU list to be per workspace instead of per display, so sticky windows don't hijack the window focus after workspace switching (Bug #97635). * src/delete.c (meta_window_delete): Use meta_workspace_focus_top_window instead of meta_screen_focus_top_window. * src/display.c (meta_display_open): Stop using display->mru_list. (find_tab_forward): (find_tab_backward): (meta_display_get_tab_list): Use workspace->mru_list instead of display->mru_list and remove unneeded calls to meta_window_visible_on_workspace * src/display.h: Remove mru_list from MetaDisplay * src/keybindings.c (handle_toggle_desktop): Use meta_workspace_focus_top_window instead of meta_screen_focus_top_window. * src/screen.c (meta_screen_focus_top_window): (meta_screen_focus_default_window): Remove functions. (meta_screen_show_desktop): Use meta_workspace_focus_top_window instead of meta_screen_focus_top_window. * src/screen.h: Remove meta_screen_focus_top_window and meta_screen_focus_default_window declarations. * src/window.c (meta_window_new): Stop using display->mru_list. (meta_window_free): Use meta_workspace_focus_top_window instead of meta_screen_focus_top_window and stop using display->mru_list. (meta_window_stick): Add sticky window to all workspace MRU lists. (meta_window_unstick): Remove non-sticky window from the workspace MRU lists it doesn't belong in. (meta_window_notify_focus): Move newly focused window to the front of active workspace's MRU list. * src/workspace.c (meta_workspace_new): Initialize workspace->mru_list to NULL. (meta_workspace_add_window): Add window to workspace's MRU list. (meta_workspace_remove_window): Remove window from workspace's MRU list. (meta_workspace_activate_with_focus): Use meta_workspace_focus_default_window instead of meta_screen_focus_default_window. (meta_workspace_focus_default_window): (meta_workspace_focus_mru_window): (meta_workspace_focus_top_window): Add functions. * src/workspace.h: Add mru_list to MetaWorkspace and add function declarations for meta_workspace_focus_default_window, meta_workspace_focus_mru_window, meta_workspace_focus_top_window.
Diffstat (limited to 'src/workspace.c')
-rw-r--r--src/workspace.c94
1 files changed, 93 insertions, 1 deletions
diff --git a/src/workspace.c b/src/workspace.c
index 09dc25a5..dc73879f 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -41,6 +41,7 @@ meta_workspace_new (MetaScreen *screen)
workspace->screen->workspaces =
g_list_append (workspace->screen->workspaces, workspace);
workspace->windows = NULL;
+ workspace->mru_list = NULL;
workspace->work_areas = NULL;
workspace->work_areas_invalid = TRUE;
@@ -113,6 +114,8 @@ meta_workspace_add_window (MetaWorkspace *workspace,
workspace->windows = g_list_prepend (workspace->windows, window);
window->workspaces = g_list_prepend (window->workspaces, workspace);
+ workspace->mru_list = g_list_append (workspace->mru_list, window);
+
meta_window_set_current_workspace_hint (window);
meta_window_queue_calc_showing (window);
@@ -138,6 +141,7 @@ meta_workspace_remove_window (MetaWorkspace *workspace,
workspace->windows = g_list_remove (workspace->windows, window);
window->workspaces = g_list_remove (window->workspaces, workspace);
+ workspace->mru_list = g_list_remove (workspace->mru_list, window);
meta_window_set_current_workspace_hint (window);
@@ -239,7 +243,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
else
{
meta_topic (META_DEBUG_FOCUS, "Focusing default window on new workspace\n");
- meta_screen_focus_default_window (workspace->screen, NULL);
+ meta_workspace_focus_default_window (workspace, NULL);
}
}
@@ -687,3 +691,91 @@ meta_workspace_get_name (MetaWorkspace *workspace)
{
return meta_prefs_get_workspace_name (meta_workspace_index (workspace));
}
+
+void
+meta_workspace_focus_default_window (MetaWorkspace *workspace,
+ MetaWindow *not_this_one)
+{
+ if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK)
+ meta_workspace_focus_mru_window (workspace, not_this_one);
+ else
+ meta_screen_focus_mouse_window (workspace->screen, not_this_one);
+}
+
+/* Focus MRU window (or top window if failed) on active workspace */
+void
+meta_workspace_focus_mru_window (MetaWorkspace *workspace,
+ MetaWindow *not_this_one)
+{
+ MetaWindow *window = NULL;
+ GList *tmp;
+
+ if (not_this_one)
+ meta_topic (META_DEBUG_FOCUS,
+ "Focusing MRU window excluding %s\n", not_this_one->desc);
+
+ tmp = workspace->mru_list;
+
+ while (tmp)
+ {
+ if (((MetaWindow*) tmp->data) != not_this_one)
+ {
+ window = tmp->data;
+ break;
+ }
+
+ tmp = tmp->next;
+ }
+
+ if (window)
+ {
+ meta_topic (META_DEBUG_FOCUS,
+ "Focusing workspace MRU window %s\n", window->desc);
+
+ meta_window_focus (window,
+ meta_display_get_current_time (workspace->screen->display));
+
+ /* Also raise the window if in click-to-focus */
+ if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK)
+ meta_window_raise (window);
+ }
+ else
+ {
+ meta_topic (META_DEBUG_FOCUS, "No MRU window to focus found\n");
+ meta_workspace_focus_top_window (workspace, not_this_one);
+ }
+}
+
+/* Focus top window on workspace */
+void
+meta_workspace_focus_top_window (MetaWorkspace *workspace,
+ MetaWindow *not_this_one)
+{
+ MetaWindow *window;
+
+ if (not_this_one)
+ meta_topic (META_DEBUG_FOCUS,
+ "Focusing top window excluding %s\n", not_this_one->desc);
+
+ window = meta_stack_get_default_focus_window (workspace->screen->stack,
+ workspace,
+ not_this_one);
+
+ /* FIXME I'm a loser on the CurrentTime front */
+ if (window)
+ {
+ meta_topic (META_DEBUG_FOCUS,
+ "Focusing top window %s\n", window->desc);
+
+ meta_window_focus (window,
+ meta_display_get_current_time (workspace->screen->display));
+
+ /* Also raise the window if in click-to-focus */
+ if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK)
+ meta_window_raise (window);
+ }
+ else
+ {
+ meta_topic (META_DEBUG_FOCUS, "No top window to focus found\n");
+ }
+}