Fix broken workspace switching from my previous commit.

2002-07-01  Mark McLoughlin  <mark@skynet.ie>

        Fix broken workspace switching from my previous commit.

        * src/display.c: (meta_display_begin_grab_op): don't
        leak a pointer grab if we fail to grab the keyboard.

        * src/keybindings.c: (meta_screen_grab_keys): check
        screen->all_keys_grabbed.
        (meta_screen_grab_all_keys): regrab our standard
        bindings if we fail.
        (handle_workspace_switch): revert to our previous
        behaviour of using the last focused window to do
        the grab upon. Only use the RootWindow if there
        isn't anything else to use.

        * src/screen.c: (meta_screen_new): initialise
        all_keys_grabbed.
This commit is contained in:
Mark McLoughlin 2002-07-01 03:20:29 +00:00 committed by Mark McLoughlin
parent 6b72d622a5
commit 086f3d807e
4 changed files with 60 additions and 14 deletions

View File

@ -1,3 +1,22 @@
2002-07-01 Mark McLoughlin <mark@skynet.ie>
Fix broken workspace switching from my previous commit.
* src/display.c: (meta_display_begin_grab_op): don't
leak a pointer grab if we fail to grab the keyboard.
* src/keybindings.c: (meta_screen_grab_keys): check
screen->all_keys_grabbed.
(meta_screen_grab_all_keys): regrab our standard
bindings if we fail.
(handle_workspace_switch): revert to our previous
behaviour of using the last focused window to do
the grab upon. Only use the RootWindow if there
isn't anything else to use.
* src/screen.c: (meta_screen_new): initialise
all_keys_grabbed.
2002-06-26 Mark McLoughlin <mark@skynet.ie> 2002-06-26 Mark McLoughlin <mark@skynet.ie>
Fixes not being able to tab out of a Fixes not being able to tab out of a

View File

@ -2199,6 +2199,12 @@ meta_display_begin_grab_op (MetaDisplay *display,
return FALSE; return FALSE;
} }
/* FIXME:
* If we have no MetaWindow we do our best
* and try to do the grab on the RootWindow.
* This will fail if anyone else has any
* key grab on the RootWindow.
*/
if (window) if (window)
grab_xwindow = window->frame ? window->frame->xwindow : window->xwindow; grab_xwindow = window->frame ? window->frame->xwindow : window->xwindow;
else else
@ -2250,13 +2256,16 @@ meta_display_begin_grab_op (MetaDisplay *display,
display->grab_have_keyboard = display->grab_have_keyboard =
meta_window_grab_all_keys (window); meta_window_grab_all_keys (window);
else if (meta_screen_grab_all_keys (screen)) else
display->grab_have_keyboard = TRUE; display->grab_have_keyboard =
meta_screen_grab_all_keys (screen);
if (!display->grab_have_keyboard) if (!display->grab_have_keyboard)
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"grabbing all keys failed\n"); "grabbing all keys failed, ungrabbing pointer\n");
XUngrabPointer (display->xdisplay, CurrentTime);
display->grab_have_pointer = FALSE;
return FALSE; return FALSE;
} }
} }

View File

@ -718,6 +718,9 @@ ungrab_all_keys (MetaDisplay *display,
void void
meta_screen_grab_keys (MetaScreen *screen) meta_screen_grab_keys (MetaScreen *screen)
{ {
if (screen->all_keys_grabbed)
return;
if (screen->keys_grabbed) if (screen->keys_grabbed)
return; return;
@ -859,10 +862,9 @@ meta_screen_grab_all_keys (MetaScreen *screen)
retval = grab_all_keys_and_keyboard (screen->display, retval = grab_all_keys_and_keyboard (screen->display,
screen->xroot); screen->xroot);
if (retval) if (retval)
{ screen->all_keys_grabbed = TRUE;
screen->keys_grabbed = FALSE; else
screen->all_keys_grabbed = TRUE; meta_screen_grab_keys (screen);
}
return retval; return retval;
} }
@ -2334,12 +2336,26 @@ handle_workspace_switch (MetaDisplay *display,
if (screen == NULL) if (screen == NULL)
return; return;
/* FIXME this is all broken, that you need a window to grab on.
* There's no reason we need a window here, in fact it's broken
* that you have to have one.
*/
if (display->focus_window != NULL)
{
window = display->focus_window;
}
else if (window == NULL)
{
window = get_previous_focus_window (display, screen);
}
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Starting tab between workspaces, showing popup\n"); "Starting tab between workspaces, showing popup\n");
if (meta_display_begin_grab_op (display, if (meta_display_begin_grab_op (display,
screen, screen,
NULL, window,
META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING, META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING,
FALSE, FALSE,
0, 0,
@ -2348,16 +2364,17 @@ handle_workspace_switch (MetaDisplay *display,
0, 0)) 0, 0))
{ {
MetaWorkspace *next; MetaWorkspace *next;
next = meta_workspace_get_neighbor (screen->active_workspace, next = meta_workspace_get_neighbor (window->screen->active_workspace,
motion); motion);
g_assert (next); g_assert (next);
meta_ui_tab_popup_select (screen->tab_popup, meta_ui_tab_popup_select (window->screen->tab_popup,
(MetaTabEntryKey) next); (MetaTabEntryKey) next);
/* only after selecting proper window */ /* only after selecting proper window */
meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE); meta_ui_tab_popup_set_showing (window->screen->tab_popup,
TRUE);
} }
} }

View File

@ -470,6 +470,7 @@ meta_screen_new (MetaDisplay *display,
screen->active_workspace = meta_workspace_new (screen); screen->active_workspace = meta_workspace_new (screen);
update_num_workspaces (screen); update_num_workspaces (screen);
screen->all_keys_grabbed = FALSE;
screen->keys_grabbed = FALSE; screen->keys_grabbed = FALSE;
meta_screen_grab_keys (screen); meta_screen_grab_keys (screen);