mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
...
This commit is contained in:
parent
beaac99991
commit
1b3a58c951
@ -162,6 +162,9 @@ meta_display_open (const char *name)
|
||||
display->error_traps = NULL;
|
||||
display->server_grab_count = 0;
|
||||
display->workspaces = NULL;
|
||||
|
||||
display->focus_window = NULL;
|
||||
display->prev_focus_window = NULL;
|
||||
|
||||
/* we have to go ahead and do this so error handlers work */
|
||||
all_displays = g_slist_prepend (all_displays, display);
|
||||
|
@ -100,6 +100,9 @@ struct _MetaDisplay
|
||||
*/
|
||||
MetaWindow *focus_window;
|
||||
|
||||
/* Previous focus window */
|
||||
MetaWindow *prev_focus_window;
|
||||
|
||||
GList *workspaces;
|
||||
|
||||
/*< private-ish >*/
|
||||
|
@ -324,28 +324,34 @@ handle_tab_forward (MetaDisplay *display,
|
||||
|
||||
if (display->focus_window != NULL)
|
||||
{
|
||||
window = meta_stack_get_above (display->focus_window->screen->stack,
|
||||
display->focus_window);
|
||||
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
||||
display->focus_window,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
if (window == NULL)
|
||||
{
|
||||
if (event_window)
|
||||
window = meta_stack_get_bottom (event_window->screen->stack);
|
||||
else
|
||||
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)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xkey.window);
|
||||
|
||||
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)
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
if (window)
|
||||
{
|
||||
meta_window_raise (window);
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -362,29 +368,34 @@ handle_tab_backward (MetaDisplay *display,
|
||||
|
||||
if (display->focus_window != NULL)
|
||||
{
|
||||
window = meta_stack_get_below (display->focus_window->screen->stack,
|
||||
display->focus_window);
|
||||
window = meta_stack_get_tab_next (display->focus_window->screen->stack,
|
||||
display->focus_window,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (window == NULL)
|
||||
{
|
||||
if (event_window)
|
||||
window = meta_stack_get_top (event_window->screen->stack);
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xkey.root);
|
||||
|
||||
if (window == NULL)
|
||||
/* We get the screen because event_window may be NULL,
|
||||
* in which case we can't use event_window->screen
|
||||
*/
|
||||
if (screen)
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
screen = meta_display_screen_for_root (display,
|
||||
event->xkey.window);
|
||||
|
||||
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)
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
if (window)
|
||||
{
|
||||
meta_window_raise (window);
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -399,8 +410,28 @@ handle_focus_previous (MetaDisplay *display,
|
||||
|
||||
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)
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
{
|
||||
meta_window_raise (window);
|
||||
meta_window_focus (window, event->xkey.time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
60
src/stack.c
60
src/stack.c
@ -760,3 +760,63 @@ meta_stack_get_below (MetaStack *stack,
|
||||
else
|
||||
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));
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ MetaWindow* meta_stack_get_above (MetaStack *stack,
|
||||
MetaWindow* meta_stack_get_below (MetaStack *stack,
|
||||
MetaWindow *window);
|
||||
|
||||
MetaWindow* meta_stack_get_tab_next (MetaStack *stack,
|
||||
MetaWindow *window,
|
||||
gboolean backward);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1618,7 +1618,10 @@ meta_window_notify_focus (MetaWindow *window,
|
||||
*/
|
||||
if (event->xfocus.mode == NotifyGrab ||
|
||||
event->xfocus.mode == NotifyUngrab)
|
||||
return TRUE;
|
||||
{
|
||||
meta_verbose ("Ignoring focus event generated by a grab\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (event->type == FocusIn)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user