Push the tab/workspace popup abstraction completely into screen.c

Also, use MetaWindows as the tab_popup keys rather than using (X) Windows
and then having to map back and forth everywhere, which is silly since
we never actually want the X Window.

http://bugzilla.gnome.org/show_bug.cgi?id=580917
This commit is contained in:
Dan Winship 2009-04-27 11:19:08 -04:00
parent 7b522c0de8
commit 99d0f41d98
4 changed files with 88 additions and 53 deletions

View File

@ -3552,9 +3552,9 @@ meta_display_end_grab_op (MetaDisplay *display,
display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING) display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING)
{ {
if (GRAB_OP_IS_WINDOW_SWITCH (display->grab_op)) if (GRAB_OP_IS_WINDOW_SWITCH (display->grab_op))
meta_screen_destroy_tab_popup (display->grab_screen); meta_screen_tab_popup_destroy (display->grab_screen);
else else
meta_screen_destroy_workspace_popup (display->grab_screen); meta_screen_workspace_popup_destroy (display->grab_screen);
/* If the ungrab here causes an EnterNotify, ignore it for /* If the ungrab here causes an EnterNotify, ignore it for
* sloppy focus * sloppy focus

View File

@ -2045,7 +2045,6 @@ process_tab_grab (MetaDisplay *display,
gboolean popup_not_showing; gboolean popup_not_showing;
gboolean backward; gboolean backward;
gboolean key_used; gboolean key_used;
Window prev_xwindow;
MetaWindow *prev_window; MetaWindow *prev_window;
if (screen != display->grab_screen) if (screen != display->grab_screen)
@ -2130,13 +2129,9 @@ process_tab_grab (MetaDisplay *display,
end_keyboard_grab (display, event->xkey.keycode)) end_keyboard_grab (display, event->xkey.keycode))
{ {
/* We're done, move to the new window. */ /* We're done, move to the new window. */
Window target_xwindow;
MetaWindow *target_window; MetaWindow *target_window;
target_xwindow = target_window = meta_screen_tab_popup_get_selected (screen);
(Window) meta_ui_tab_popup_get_selected (screen->tab_popup);
target_window =
meta_display_lookup_x_window (display, target_xwindow);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending tab operation, primary modifier released\n"); "Ending tab operation, primary modifier released\n");
@ -2172,8 +2167,7 @@ process_tab_grab (MetaDisplay *display,
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, event->xkey.keycode))
return TRUE; return TRUE;
prev_xwindow = (Window) meta_ui_tab_popup_get_selected (screen->tab_popup); prev_window = meta_screen_tab_popup_get_selected (screen);
prev_window = meta_display_lookup_x_window (display, prev_xwindow);
/* Cancel when alt-Escape is pressed during using alt-Tab, and vice /* Cancel when alt-Escape is pressed during using alt-Tab, and vice
* versa. * versa.
@ -2293,25 +2287,21 @@ process_tab_grab (MetaDisplay *display,
backward = !backward; backward = !backward;
if (backward) if (backward)
meta_ui_tab_popup_backward (screen->tab_popup); meta_screen_tab_popup_backward (screen);
else else
meta_ui_tab_popup_forward (screen->tab_popup); meta_screen_tab_popup_forward (screen);
if (popup_not_showing) if (popup_not_showing)
{ {
/* We can't actually change window focus, due to the grab. /* We can't actually change window focus, due to the grab.
* but raise the window. * but raise the window.
*/ */
Window target_xwindow;
MetaWindow *target_window; MetaWindow *target_window;
meta_stack_set_positions (screen->stack, meta_stack_set_positions (screen->stack,
display->grab_old_window_stacking); display->grab_old_window_stacking);
target_xwindow = target_window = meta_screen_tab_popup_get_selected (screen);
(Window) meta_ui_tab_popup_get_selected (screen->tab_popup);
target_window =
meta_display_lookup_x_window (display, target_xwindow);
if (prev_window && prev_window->tab_unminimized) if (prev_window && prev_window->tab_unminimized)
{ {
@ -2739,8 +2729,7 @@ process_workspace_switch_grab (MetaDisplay *display,
/* We're done, move to the new workspace. */ /* We're done, move to the new workspace. */
MetaWorkspace *target_workspace; MetaWorkspace *target_workspace;
target_workspace = target_workspace = meta_screen_workspace_popup_get_selected (screen);
(MetaWorkspace *) meta_ui_tab_popup_get_selected (screen->ws_popup);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending workspace tab operation, primary modifier released\n"); "Ending workspace tab operation, primary modifier released\n");
@ -2775,9 +2764,8 @@ process_workspace_switch_grab (MetaDisplay *display,
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, event->xkey.keycode))
return TRUE; return TRUE;
/* select the next workspace in the tabpopup */ /* select the next workspace in the popup */
workspace = workspace = meta_screen_workspace_popup_get_selected (screen);
(MetaWorkspace *) meta_ui_tab_popup_get_selected (screen->ws_popup);
if (workspace) if (workspace)
{ {
@ -2818,8 +2806,7 @@ process_workspace_switch_grab (MetaDisplay *display,
if (target_workspace) if (target_workspace)
{ {
meta_ui_tab_popup_select (screen->ws_popup, meta_screen_workspace_popup_select (screen, target_workspace);
(MetaTabEntryKey) target_workspace);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Tab key pressed, moving tab focus in popup\n"); "Tab key pressed, moving tab focus in popup\n");
@ -2835,8 +2822,7 @@ process_workspace_switch_grab (MetaDisplay *display,
/* end grab */ /* end grab */
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending workspace tabbing & focusing default window; uninteresting key pressed\n"); "Ending workspace tabbing & focusing default window; uninteresting key pressed\n");
workspace = workspace = meta_screen_workspace_popup_get_selected (screen);
(MetaWorkspace *) meta_ui_tab_popup_get_selected (screen->ws_popup);
meta_workspace_focus_default_window (workspace, NULL, event->xkey.time); meta_workspace_focus_default_window (workspace, NULL, event->xkey.time);
return FALSE; return FALSE;
} }
@ -3076,14 +3062,10 @@ do_choose_window (MetaDisplay *display,
meta_screen_ensure_tab_popup (screen, type, meta_screen_ensure_tab_popup (screen, type,
show_popup ? META_TAB_SHOW_ICON : show_popup ? META_TAB_SHOW_ICON :
META_TAB_SHOW_INSTANTLY); META_TAB_SHOW_INSTANTLY,
initial_selection);
meta_ui_tab_popup_select (screen->tab_popup, if (!show_popup)
(MetaTabEntryKey) initial_selection->xwindow);
if (show_popup)
meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
else
{ {
meta_window_raise (initial_selection); meta_window_raise (initial_selection);
initial_selection->tab_unminimized = initial_selection->tab_unminimized =
@ -3458,13 +3440,7 @@ handle_workspace_switch (MetaDisplay *display,
meta_workspace_activate (next, event->xkey.time); meta_workspace_activate (next, event->xkey.time);
if (grabbed_before_release && !meta_prefs_get_no_tab_popup ()) if (grabbed_before_release && !meta_prefs_get_no_tab_popup ())
{ meta_screen_ensure_workspace_popup (screen, next);
meta_screen_ensure_workspace_popup (screen);
meta_ui_tab_popup_select (screen->ws_popup, (MetaTabEntryKey) next);
/* only after selecting proper space */
meta_ui_tab_popup_set_showing (screen->ws_popup, TRUE);
}
} }
static void static void

View File

@ -164,12 +164,21 @@ void meta_screen_set_cursor (MetaScreen *scree
MetaCursor cursor); MetaCursor cursor);
void meta_screen_update_cursor (MetaScreen *screen); void meta_screen_update_cursor (MetaScreen *screen);
void meta_screen_ensure_tab_popup (MetaScreen *screen, void meta_screen_ensure_tab_popup (MetaScreen *screen,
MetaTabList list_type, MetaTabList list_type,
MetaTabShowType show_type); MetaTabShowType show_type,
void meta_screen_destroy_tab_popup (MetaScreen *screen); MetaWindow *initial_window);
void meta_screen_ensure_workspace_popup (MetaScreen *screen); void meta_screen_tab_popup_forward (MetaScreen *screen);
void meta_screen_destroy_workspace_popup (MetaScreen *screen); void meta_screen_tab_popup_backward (MetaScreen *screen);
MetaWindow* meta_screen_tab_popup_get_selected (MetaScreen *screen);
void meta_screen_tab_popup_destroy (MetaScreen *screen);
void meta_screen_ensure_workspace_popup (MetaScreen *screen,
MetaWorkspace *initial_selection);
void meta_screen_workspace_popup_select (MetaScreen *screen,
MetaWorkspace *workspace);
MetaWorkspace*meta_screen_workspace_popup_get_selected (MetaScreen *screen);
void meta_screen_workspace_popup_destroy (MetaScreen *screen);
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen, MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one); MetaWindow *not_this_one);

View File

@ -1426,7 +1426,8 @@ meta_screen_update_cursor (MetaScreen *screen)
void void
meta_screen_ensure_tab_popup (MetaScreen *screen, meta_screen_ensure_tab_popup (MetaScreen *screen,
MetaTabList list_type, MetaTabList list_type,
MetaTabShowType show_type) MetaTabShowType show_type,
MetaWindow *initial_selection)
{ {
MetaTabEntry *entries; MetaTabEntry *entries;
GList *tab_list; GList *tab_list;
@ -1460,7 +1461,7 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
window = tmp->data; window = tmp->data;
entries[i].key = (MetaTabEntryKey) window->xwindow; entries[i].key = (MetaTabEntryKey) window;
entries[i].title = window->title; entries[i].title = window->title;
entries[i].icon = g_object_ref (window->icon); entries[i].icon = g_object_ref (window->icon);
entries[i].blank = FALSE; entries[i].blank = FALSE;
@ -1531,11 +1532,39 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
g_list_free (tab_list); g_list_free (tab_list);
/* don't show tab popup, since proper window isn't selected yet */ meta_ui_tab_popup_select (screen->tab_popup,
(MetaTabEntryKey) initial_selection);
if (show_type != META_TAB_SHOW_INSTANTLY)
meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
} }
void void
meta_screen_destroy_tab_popup (MetaScreen *screen) meta_screen_tab_popup_forward (MetaScreen *screen)
{
g_return_if_fail (screen->tab_popup != NULL);
meta_ui_tab_popup_forward (screen->tab_popup);
}
void
meta_screen_tab_popup_backward (MetaScreen *screen)
{
g_return_if_fail (screen->tab_popup != NULL);
meta_ui_tab_popup_backward (screen->tab_popup);
}
MetaWindow *
meta_screen_tab_popup_get_selected (MetaScreen *screen)
{
g_return_val_if_fail (screen->tab_popup != NULL, NULL);
return (MetaWindow *) meta_ui_tab_popup_get_selected (screen->tab_popup);
}
void
meta_screen_tab_popup_destroy (MetaScreen *screen)
{ {
if (screen->tab_popup) if (screen->tab_popup)
{ {
@ -1545,7 +1574,8 @@ meta_screen_destroy_tab_popup (MetaScreen *screen)
} }
void void
meta_screen_ensure_workspace_popup (MetaScreen *screen) meta_screen_ensure_workspace_popup (MetaScreen *screen,
MetaWorkspace *initial_selection)
{ {
MetaTabEntry *entries; MetaTabEntry *entries;
int len; int len;
@ -1609,11 +1639,31 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
g_free (entries); g_free (entries);
meta_screen_free_workspace_layout (&layout); meta_screen_free_workspace_layout (&layout);
/* don't show tab popup, since proper space isn't selected yet */ meta_ui_tab_popup_select (screen->ws_popup,
(MetaTabEntryKey) initial_selection);
meta_ui_tab_popup_set_showing (screen->ws_popup, TRUE);
} }
void void
meta_screen_destroy_workspace_popup (MetaScreen *screen) meta_screen_workspace_popup_select (MetaScreen *screen,
MetaWorkspace *workspace)
{
g_return_if_fail (screen->ws_popup != NULL);
meta_ui_tab_popup_select (screen->ws_popup,
(MetaTabEntryKey) workspace);
}
MetaWorkspace *
meta_screen_workspace_popup_get_selected (MetaScreen *screen)
{
g_return_val_if_fail (screen->ws_popup != NULL, NULL);
return (MetaWorkspace *) meta_ui_tab_popup_get_selected (screen->ws_popup);
}
void
meta_screen_workspace_popup_destroy (MetaScreen *screen)
{ {
if (screen->ws_popup) if (screen->ws_popup)
{ {