This commit is contained in:
rhp 2001-06-24 03:41:44 +00:00
parent beaac99991
commit 1b3a58c951
6 changed files with 136 additions and 33 deletions

View File

@ -163,6 +163,9 @@ meta_display_open (const char *name)
display->server_grab_count = 0; display->server_grab_count = 0;
display->workspaces = NULL; display->workspaces = NULL;
display->focus_window = NULL;
display->prev_focus_window = NULL;
/* we have to go ahead and do this so error handlers work */ /* we have to go ahead and do this so error handlers work */
all_displays = g_slist_prepend (all_displays, display); all_displays = g_slist_prepend (all_displays, display);

View File

@ -100,6 +100,9 @@ struct _MetaDisplay
*/ */
MetaWindow *focus_window; MetaWindow *focus_window;
/* Previous focus window */
MetaWindow *prev_focus_window;
GList *workspaces; GList *workspaces;
/*< private-ish >*/ /*< private-ish >*/

View File

@ -324,28 +324,34 @@ handle_tab_forward (MetaDisplay *display,
if (display->focus_window != NULL) if (display->focus_window != NULL)
{ {
window = meta_stack_get_above (display->focus_window->screen->stack, window = meta_stack_get_tab_next (display->focus_window->screen->stack,
display->focus_window); display->focus_window,
FALSE);
} }
if (window == NULL) if (window == NULL)
{
if (event_window)
window = meta_stack_get_bottom (event_window->screen->stack);
else
{ {
MetaScreen *screen; MetaScreen *screen;
screen = meta_display_screen_for_root (display, screen = meta_display_screen_for_root (display,
event->xkey.window); event->xkey.root);
/* We get the screen because event_window may be NULL,
* in which case we can't use event_window->screen
*/
if (screen) if (screen)
window = meta_stack_get_bottom (screen->stack); {
window = meta_stack_get_tab_next (screen->stack,
event_window,
FALSE);
} }
} }
if (window && window != display->focus_window) if (window)
{
meta_window_raise (window);
meta_window_focus (window, event->xkey.time); meta_window_focus (window, event->xkey.time);
}
} }
static void static void
@ -362,29 +368,34 @@ handle_tab_backward (MetaDisplay *display,
if (display->focus_window != NULL) if (display->focus_window != NULL)
{ {
window = meta_stack_get_below (display->focus_window->screen->stack, window = meta_stack_get_tab_next (display->focus_window->screen->stack,
display->focus_window); display->focus_window,
TRUE);
} }
if (window == NULL)
{
if (event_window)
window = meta_stack_get_top (event_window->screen->stack);
if (window == NULL) if (window == NULL)
{ {
MetaScreen *screen; MetaScreen *screen;
screen = meta_display_screen_for_root (display, screen = meta_display_screen_for_root (display,
event->xkey.window); event->xkey.root);
/* We get the screen because event_window may be NULL,
* in which case we can't use event_window->screen
*/
if (screen) if (screen)
window = meta_stack_get_top (screen->stack); {
window = meta_stack_get_tab_next (screen->stack,
event_window,
TRUE);
} }
} }
if (window && window != display->focus_window) if (window)
{
meta_window_raise (window);
meta_window_focus (window, event->xkey.time); meta_window_focus (window, event->xkey.time);
}
} }
static void static void
@ -399,8 +410,28 @@ handle_focus_previous (MetaDisplay *display,
window = display->prev_focus_window; window = display->prev_focus_window;
if (window == NULL)
{
/* Pick first window in tab order */
MetaScreen *screen;
screen = meta_display_screen_for_root (display,
event->xkey.root);
/* We get the screen because event_window may be NULL,
* in which case we can't use event_window->screen
*/
if (screen)
{
window = meta_stack_get_tab_next (screen->stack,
event_window,
TRUE);
}
}
if (window) if (window)
{
meta_window_raise (window);
meta_window_focus (window, event->xkey.time); meta_window_focus (window, event->xkey.time);
}
} }

View File

@ -760,3 +760,63 @@ meta_stack_get_below (MetaStack *stack,
else else
return find_prev_below_layer (stack, window->layer); return find_prev_below_layer (stack, window->layer);
} }
MetaWindow*
meta_stack_get_tab_next (MetaStack *stack,
MetaWindow *window,
gboolean backward)
{
int i;
if (stack->windows->len == 0)
return NULL;
if (window != NULL)
{
i = 0;
while (i < stack->windows->len)
{
Window w;
w = g_array_index (stack->windows, Window, i);
if (w == window->xwindow)
{
if (backward && i == 0)
goto out;
else if (!backward && i == (stack->windows->len - 1))
goto out;
else
{
if (backward)
--i;
else
++i;
return meta_display_lookup_x_window (stack->screen->display,
g_array_index (stack->windows,
Window,
i));
}
}
++i;
}
}
out:
/* window may be NULL, or maybe the origin window was already the last/first
* window and we need to wrap around
*/
if (backward)
return meta_display_lookup_x_window (stack->screen->display,
g_array_index (stack->windows,
Window,
stack->windows->len - 1));
else
return meta_display_lookup_x_window (stack->screen->display,
g_array_index (stack->windows,
Window,
0));
}

View File

@ -92,6 +92,9 @@ MetaWindow* meta_stack_get_above (MetaStack *stack,
MetaWindow* meta_stack_get_below (MetaStack *stack, MetaWindow* meta_stack_get_below (MetaStack *stack,
MetaWindow *window); MetaWindow *window);
MetaWindow* meta_stack_get_tab_next (MetaStack *stack,
MetaWindow *window,
gboolean backward);
#endif #endif

View File

@ -1618,7 +1618,10 @@ meta_window_notify_focus (MetaWindow *window,
*/ */
if (event->xfocus.mode == NotifyGrab || if (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab) event->xfocus.mode == NotifyUngrab)
{
meta_verbose ("Ignoring focus event generated by a grab\n");
return TRUE; return TRUE;
}
if (event->type == FocusIn) if (event->type == FocusIn)
{ {