put _NET_DESKTOP_NAMES in the array of atom names, so desktop names might

2002-07-06  Havoc Pennington  <hp@pobox.com>

	* src/display.c (meta_display_open): put _NET_DESKTOP_NAMES in the
	array of atom names, so desktop names might work and we don't read
	uninitialized memory.

	* src/main.c (main): add VERSION/timestamp verbose message.

	* src/keybindings.c: implement cycle_windows cycle_panels

	* src/metacity.schemas.in: add the cycle_windows cycle_panels
	keybindings

	* src/prefs.h (META_KEYBINDING_FOCUS_PREVIOUS): replace
	FOCUS_PREVIOUS key binding with CYCLE_WINDOWS and CYCLE_PANELS
	(not good names really, but I don't have ideas).

	* src/common.h: add a grab op for alt+esc window cycling
This commit is contained in:
Havoc Pennington 2002-07-06 16:50:48 +00:00 committed by Havoc Pennington
parent efeedae712
commit 8c3437fd27
9 changed files with 177 additions and 104 deletions

View File

@ -1,3 +1,22 @@
2002-07-06 Havoc Pennington <hp@pobox.com>
* src/display.c (meta_display_open): put _NET_DESKTOP_NAMES in the
array of atom names, so desktop names might work and we don't read
uninitialized memory.
* src/main.c (main): add VERSION/timestamp verbose message.
* src/keybindings.c: implement cycle_windows cycle_panels
* src/metacity.schemas.in: add the cycle_windows cycle_panels
keybindings
* src/prefs.h (META_KEYBINDING_FOCUS_PREVIOUS): replace
FOCUS_PREVIOUS key binding with CYCLE_WINDOWS and CYCLE_PANELS
(not good names really, but I don't have ideas).
* src/common.h: add a grab op for alt+esc window cycling
2002-07-05 Havoc Pennington <hp@pobox.com>
* src/themes/Makefile.am (THEMES): Take Gorilla out until it gets

View File

@ -99,9 +99,14 @@ typedef enum
META_GRAB_OP_KEYBOARD_RESIZING_SW,
META_GRAB_OP_KEYBOARD_RESIZING_NW,
/* Alt+Tab */
META_GRAB_OP_KEYBOARD_TABBING_NORMAL,
META_GRAB_OP_KEYBOARD_TABBING_DOCK,
/* Alt+Esc */
META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL,
META_GRAB_OP_KEYBOARD_ESCAPING_DOCK,
META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING,
/* Frame button ops */

View File

@ -226,7 +226,8 @@ meta_display_open (const char *name)
"MULTIPLE",
"TIMESTAMP",
"VERSION",
"ATOM_PAIR"
"ATOM_PAIR",
"_NET_DESKTOP_NAMES"
};
Atom atoms[G_N_ELEMENTS(atom_names)];
@ -783,6 +784,8 @@ grab_op_is_keyboard (MetaGrabOp op)
case META_GRAB_OP_KEYBOARD_RESIZING_NW:
case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
case META_GRAB_OP_KEYBOARD_TABBING_DOCK:
case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL:
case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING:
return TRUE;
break;
@ -2297,11 +2300,13 @@ meta_display_begin_grab_op (MetaDisplay *display,
switch (op)
{
case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL:
meta_screen_ensure_tab_popup (screen,
META_TAB_LIST_NORMAL);
break;
case META_GRAB_OP_KEYBOARD_TABBING_DOCK:
case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
meta_screen_ensure_tab_popup (screen,
META_TAB_LIST_DOCKS);
break;
@ -2324,11 +2329,15 @@ void
meta_display_end_grab_op (MetaDisplay *display,
Time timestamp)
{
meta_verbose ("Ending grab op %d at time %ld\n", display->grab_op, timestamp);
if (display->grab_op == META_GRAB_OP_NONE)
return;
if (display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_NORMAL ||
display->grab_op == META_GRAB_OP_KEYBOARD_TABBING_DOCK ||
display->grab_op == META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL ||
display->grab_op == META_GRAB_OP_KEYBOARD_ESCAPING_DOCK ||
display->grab_op == META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING)
{
meta_ui_tab_popup_free (display->grab_screen->tab_popup);

View File

@ -50,7 +50,7 @@ static void handle_tab_forward (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
static void handle_focus_previous (MetaDisplay *display,
static void handle_cycle_forward (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
MetaKeyBinding *binding);
@ -184,8 +184,10 @@ static const MetaKeyHandler screen_handlers[] = {
GINT_TO_POINTER (META_TAB_LIST_NORMAL) },
{ META_KEYBINDING_SWITCH_PANELS, handle_tab_forward,
GINT_TO_POINTER (META_TAB_LIST_DOCKS) },
{ META_KEYBINDING_FOCUS_PREVIOUS, handle_focus_previous,
NULL },
{ META_KEYBINDING_CYCLE_WINDOWS, handle_cycle_forward,
GINT_TO_POINTER (META_TAB_LIST_NORMAL) },
{ META_KEYBINDING_CYCLE_PANELS, handle_cycle_forward,
GINT_TO_POINTER (META_TAB_LIST_DOCKS) },
{ META_KEYBINDING_SHOW_DESKTOP, handle_toggle_desktop,
NULL },
{ NULL, NULL, NULL }
@ -1188,11 +1190,14 @@ meta_display_process_key_event (MetaDisplay *display,
case META_GRAB_OP_KEYBOARD_TABBING_NORMAL:
case META_GRAB_OP_KEYBOARD_TABBING_DOCK:
case META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL:
case META_GRAB_OP_KEYBOARD_ESCAPING_DOCK:
meta_topic (META_DEBUG_KEYBINDINGS,
"Processing event for keyboard tabbing\n");
"Processing event for keyboard tabbing/cycling\n");
g_assert (window != NULL);
handled = process_tab_grab (display, window, event, keysym);
break;
case META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING:
meta_topic (META_DEBUG_KEYBINDINGS,
"Processing event for keyboard workspace switching\n");
@ -1701,7 +1706,8 @@ process_tab_grab (MetaDisplay *display,
{
MetaScreen *screen;
MetaKeyBindingAction action;
gboolean popup_not_showing;
window = NULL; /* be sure we don't use this, it's irrelevant */
screen = display->grab_window->screen;
@ -1754,18 +1760,45 @@ process_tab_grab (MetaDisplay *display,
action = meta_prefs_get_keybinding_action (keysym,
display->grab_mask);
/* FIXME weird side effect here is that you can use the Escape
* key while tabbing, or the tab key while escaping
*/
popup_not_showing = FALSE;
switch (action)
{
case META_KEYBINDING_ACTION_CYCLE_PANELS:
case META_KEYBINDING_ACTION_CYCLE_WINDOWS:
popup_not_showing = TRUE;
/* FALL THRU */
case META_KEYBINDING_ACTION_SWITCH_PANELS:
case META_KEYBINDING_ACTION_SWITCH_WINDOWS:
meta_topic (META_DEBUG_KEYBINDINGS,
"Key pressed, moving tab focus in popup\n");
if (event->xkey.state & ShiftMask)
meta_ui_tab_popup_backward (screen->tab_popup);
else
meta_ui_tab_popup_forward (screen->tab_popup);
/* continue grab */
meta_topic (META_DEBUG_KEYBINDINGS,
"Tab key pressed, moving tab focus in popup\n");
if (popup_not_showing)
{
/* We can't actually change window focus, due to the grab.
* but raise the window.
*/
Window target_xwindow;
MetaWindow *target_window;
target_xwindow =
(Window) meta_ui_tab_popup_get_selected (screen->tab_popup);
target_window =
meta_display_lookup_x_window (display, target_xwindow);
if (target_window)
{
meta_window_raise (target_window);
}
}
return TRUE;
break;
@ -1775,7 +1808,7 @@ process_tab_grab (MetaDisplay *display,
/* end grab */
meta_topic (META_DEBUG_KEYBINDINGS,
"Ending tabbing, uninteresting key pressed\n");
"Ending tabbing/cycling, uninteresting key pressed\n");
return FALSE;
}
@ -1997,7 +2030,7 @@ handle_activate_menu (MetaDisplay *display,
}
static MetaGrabOp
op_from_tab_type (MetaTabList type)
tab_op_from_tab_type (MetaTabList type)
{
switch (type)
{
@ -2012,11 +2045,28 @@ op_from_tab_type (MetaTabList type)
return 0;
}
static MetaGrabOp
cycle_op_from_tab_type (MetaTabList type)
{
switch (type)
{
case META_TAB_LIST_NORMAL:
return META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL;
case META_TAB_LIST_DOCKS:
return META_GRAB_OP_KEYBOARD_ESCAPING_DOCK;
}
g_assert_not_reached ();
return 0;
}
static void
handle_tab_forward (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
MetaKeyBinding *binding)
do_choose_window (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
MetaKeyBinding *binding,
gboolean show_popup)
{
MetaWindow *window;
MetaTabList type;
@ -2025,7 +2075,7 @@ handle_tab_forward (MetaDisplay *display,
type = GPOINTER_TO_INT (binding->handler->data);
meta_topic (META_DEBUG_KEYBINDINGS,
"Tab type = %d\n", type);
"Tab list = %d show_popup = %d\n", type, show_popup);
/* backward if shift is down, this isn't configurable */
backward = (event->xkey.state & ShiftMask) != 0;
@ -2066,13 +2116,15 @@ handle_tab_forward (MetaDisplay *display,
if (window)
{
meta_topic (META_DEBUG_KEYBINDINGS,
"Starting tab between windows, showing popup\n");
"Starting tab/cycle between windows\n");
if (meta_display_begin_grab_op (window->display,
window->screen,
display->focus_window ?
display->focus_window : window,
op_from_tab_type (type),
show_popup ?
tab_op_from_tab_type (type) :
cycle_op_from_tab_type (type),
FALSE,
0,
event->xkey.state & ~(display->ignored_modifier_mask),
@ -2081,84 +2133,32 @@ handle_tab_forward (MetaDisplay *display,
{
meta_ui_tab_popup_select (window->screen->tab_popup,
(MetaTabEntryKey) window->xwindow);
/* only after selecting proper window */
meta_ui_tab_popup_set_showing (window->screen->tab_popup,
TRUE);
if (show_popup)
meta_ui_tab_popup_set_showing (window->screen->tab_popup,
TRUE);
else
meta_window_raise (window);
}
}
}
static MetaWindow *
get_previous_focus_window (MetaDisplay *display,
MetaScreen *screen)
static void
handle_tab_forward (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
MetaKeyBinding *binding)
{
MetaWindow *window = NULL;
/* get previously-focused window, front of list is currently
* focused window
*/
if (display->mru_list &&
display->mru_list->next)
{
window = display->mru_list->next->data;
}
if (window &&
!meta_window_visible_on_workspace (window,
screen->active_workspace))
{
window = NULL;
}
if (window == NULL)
{
/* Pick first window in tab order */
window = meta_display_get_tab_next (screen->display,
META_TAB_LIST_NORMAL,
screen,
screen->active_workspace,
NULL,
TRUE);
}
if (window &&
!meta_window_visible_on_workspace (window,
screen->active_workspace))
{
window = NULL;
}
return window;
do_choose_window (display, event_window, event, binding, TRUE);
}
static void
handle_focus_previous (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
MetaKeyBinding *binding)
handle_cycle_forward (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
MetaKeyBinding *binding)
{
MetaWindow *window;
MetaScreen *screen;
meta_topic (META_DEBUG_KEYBINDINGS,
"Focus previous window\n");
screen = meta_display_screen_for_root (display,
event->xkey.root);
if (screen == NULL)
return;
window = get_previous_focus_window (display, screen);
if (window)
{
meta_window_raise (window);
meta_topic (META_DEBUG_FOCUS,
"Focusing %s due to 'focus previous' keybinding\n",
window->desc);
meta_window_focus (window, event->xkey.time);
}
do_choose_window (display, event_window, event, binding, FALSE);
}
static void
@ -2405,7 +2405,7 @@ handle_workspace_switch (MetaDisplay *display,
meta_ui_tab_popup_select (screen->tab_popup, (MetaTabEntryKey) next);
/* only after selecting proper window */
/* only after selecting proper space */
meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
}
}

View File

@ -39,6 +39,7 @@
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <time.h>
static MetaExitCode meta_exit_code = META_EXIT_SUCCESS;
static GMainLoop *meta_main_loop = NULL;
@ -98,6 +99,15 @@ main (int argc, char **argv)
if (g_getenv ("METACITY_DEBUG"))
meta_set_debugging (TRUE);
meta_set_syncing (g_getenv ("METACITY_SYNC") != NULL);
{
char buf[256];
GDate d;
g_date_clear (&d, 1);
g_date_set_time (&d, time (NULL));
g_date_strftime (buf, sizeof (buf), "%x", &d);
meta_verbose ("Metacity version %s running on %s\n", VERSION, buf);
}
{
const char *charset;
@ -105,7 +115,7 @@ main (int argc, char **argv)
meta_verbose ("Running in locale \"%s\" with encoding \"%s\"\n",
setlocale (LC_ALL, NULL), charset);
}
bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
@ -269,7 +279,6 @@ main (int argc, char **argv)
g_log_set_handler ("GThread",
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
log_handler, NULL);
#endif
if (g_getenv ("METACITY_G_FATAL_WARNINGS") != NULL)

View File

@ -729,7 +729,8 @@ you set
<locale name="C">
<short>Move focus between windows</short>
<long>
The keybinding used to move focus between windows.
The keybinding used to move focus between windows, using
a popup window.
(Traditionally &lt;Alt&gt;Tab)
The format looks like "&lt;Control&gt;a" or
@ -754,7 +755,7 @@ you set
<short>Move focus between panels and the desktop</short>
<long>
The keybinding used to move focus between panels and
the desktop.
the desktop, using a popup window.
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
@ -769,16 +770,17 @@ you set
</schema>
<schema>
<key>/schemas/apps/metacity/global_keybindings/focus_previous_window</key>
<applyto>/apps/metacity/global_keybindings/focus_previous_window</applyto>
<key>/schemas/apps/metacity/global_keybindings/cycle_windows</key>
<applyto>/apps/metacity/global_keybindings/cycle_windows</applyto>
<owner>metacity</owner>
<type>string</type>
<default>&lt;Alt&gt;Escape</default>
<locale name="C">
<short>Move focus to the previously-focused window</short>
<short>Move focus between windows</short>
<long>
The keybinding used to move focus back to the window which last
had the focus.
The keybinding used to move focus between windows without
a popup window.
(Traditionally &lt;Alt&gt;Escape)
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
@ -791,7 +793,30 @@ you set
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/global_keybindings/cycle_panels</key>
<applyto>/apps/metacity/global_keybindings/cycle_panels</applyto>
<owner>metacity</owner>
<type>string</type>
<default>&lt;Control&gt;&lt;Alt&gt;Escape</default>
<locale name="C">
<short>Move focus between panels and the desktop</short>
<long>
The keybinding used to move focus between panels and
the desktop, without a popup window.
The format looks like "&lt;Control&gt;a" or
"&lt;Shift&gt;&lt;Alt&gt;F1.
The parser is fairly liberal and allows lower or upper case,
and also abbreviations such as "&lt;Ctl&gt;" and
"&lt;Ctrl&gt;". If you set the option to the special string
"disabled", then there will be no keybinding for this
action.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/metacity/global_keybindings/show_desktop</key>

View File

@ -1,7 +1,7 @@
/* Metacity preferences */
/*
* Copyright (C) 2001 Havoc Pennington
* Copyright (C) 2001 Havoc Pennington, Copyright (C) 2002 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -819,7 +819,8 @@ static MetaKeyPref screen_bindings[] = {
{ META_KEYBINDING_WORKSPACE_DOWN, 0, 0 },
{ META_KEYBINDING_SWITCH_WINDOWS, 0, 0 },
{ META_KEYBINDING_SWITCH_PANELS, 0, 0 },
{ META_KEYBINDING_FOCUS_PREVIOUS, 0, 0 },
{ META_KEYBINDING_CYCLE_WINDOWS, 0, 0 },
{ META_KEYBINDING_CYCLE_PANELS, 0, 0 },
{ META_KEYBINDING_SHOW_DESKTOP, 0, 0 },
{ NULL, 0, 0 }
};

View File

@ -82,7 +82,8 @@ void meta_prefs_set_num_workspaces (int n_workspaces);
#define META_KEYBINDING_WORKSPACE_DOWN "switch_to_workspace_down"
#define META_KEYBINDING_SWITCH_WINDOWS "switch_windows"
#define META_KEYBINDING_SWITCH_PANELS "switch_panels"
#define META_KEYBINDING_FOCUS_PREVIOUS "focus_previous_window"
#define META_KEYBINDING_CYCLE_WINDOWS "cycle_windows"
#define META_KEYBINDING_CYCLE_PANELS "cycle_panels"
#define META_KEYBINDING_SHOW_DESKTOP "show_desktop"
/* Window bindings */
@ -134,7 +135,8 @@ typedef enum _MetaKeyBindingAction
META_KEYBINDING_ACTION_WORKSPACE_DOWN,
META_KEYBINDING_ACTION_SWITCH_WINDOWS,
META_KEYBINDING_ACTION_SWITCH_PANELS,
META_KEYBINDING_ACTION_FOCUS_PREVIOUS,
META_KEYBINDING_ACTION_CYCLE_WINDOWS,
META_KEYBINDING_ACTION_CYCLE_PANELS,
META_KEYBINDING_ACTION_SHOW_DESKTOP
} MetaKeyBindingAction;

View File

@ -299,9 +299,12 @@ meta_ui_tab_popup_set_showing (MetaTabPopup *popup,
}
else
{
meta_verbose ("Hiding tab popup window\n");
gtk_widget_hide (popup->window);
meta_core_increment_event_serial (gdk_display);
if (GTK_WIDGET_VISIBLE (popup->window))
{
meta_verbose ("Hiding tab popup window\n");
gtk_widget_hide (popup->window);
meta_core_increment_event_serial (gdk_display);
}
}
}