diff options
author | Havoc Pennington <hp@pobox.com> | 2002-01-03 23:28:19 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2002-01-03 23:28:19 +0000 |
commit | ee1361fb6e874b90a62e6c8c0c47913bf91c3baf (patch) | |
tree | 8d8b74dc3cbaf051904237f22da9a14e17ac8831 /src/stack.c | |
parent | 86e9191d34570535e59f0fd73c39a1697cceac40 (diff) | |
download | metacity-ee1361fb6e874b90a62e6c8c0c47913bf91c3baf.tar.gz metacity-ee1361fb6e874b90a62e6c8c0c47913bf91c3baf.tar.bz2 |
focus top window when switching to a new workspace
2002-01-03 Havoc Pennington <hp@pobox.com>
* src/workspace.c (meta_workspace_activate): focus top window when
switching to a new workspace
* src/util.c (meta_topic): start putting verbose output in
categories
* src/window.c (meta_window_shade): focus frame after we queue
the calc_showing so the maps/unmaps have already happened.
* src/display.c (meta_display_get_current_time): add the "get time
of current event" function and call it occasionally.
* src/window.c (meta_window_free): if we have focus, call
meta_screen_focus_top_window().
(meta_window_minimize): ditto
(meta_window_delete): ditto
* src/screen.c (meta_screen_ensure_tab_popup): fix memory leak -
didn't free tab list
(meta_screen_focus_top_window): new function to use when we unmap
or unmanage a focused window
* src/stack.c (meta_stack_get_default_focus_window): function used
in meta_screen_focus_top_window
Diffstat (limited to 'src/stack.c')
-rw-r--r-- | src/stack.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/stack.c b/src/stack.c index f586577..8f03971 100644 --- a/src/stack.c +++ b/src/stack.c @@ -869,8 +869,62 @@ meta_stack_get_below (MetaStack *stack, return link->next->data; else return find_prev_below_layer (stack, window->layer); +} + +MetaWindow* +meta_stack_get_default_focus_window (MetaStack *stack, + MetaWorkspace *workspace, + MetaWindow *not_this_one) +{ + /* FIXME if stack is frozen this is kind of broken. */ + + /* Find the topmost, focusable, mapped, window. */ + + MetaWindow *topmost_dock; + int layer = META_LAYER_LAST; + + topmost_dock = NULL; + + --layer; + while (layer >= 0) + { + GList *link; + + g_assert (layer >= 0 && layer < META_LAYER_LAST); + + /* top of this layer is at the front of the list */ + link = stack->layers[layer]; + + while (link) + { + MetaWindow *window = link->data; + + if (window && + window != not_this_one && + (workspace == NULL || + meta_window_visible_on_workspace (window, workspace))) + { + if (topmost_dock == NULL && + window->type == META_WINDOW_DOCK) + topmost_dock = window; + else + return window; + } + + link = link->next; + } + + --layer; + } + + /* If we didn't find a window to focus, we use the topmost dock. + * Note that we already tried the desktop - so we prefer focusing + * desktop to focusing the dock. + */ + return topmost_dock; } + #define IN_TAB_CHAIN(w) ((w)->type != META_WINDOW_DOCK && (w)->type != META_WINDOW_DESKTOP) #define GET_XWINDOW(stack, i) (g_array_index ((stack)->windows, \ Window, (i))) |