Add Alt + left/right arrow to move between workspaces.

2001-08-03  Havoc Pennington  <hp@pobox.com>

	* src/keybindings.c: Add Alt + left/right arrow to
	move between workspaces.

	* src/screen.c (set_wm_check_hint): put property pointing back to
	itself on the _WIN_SUPPORTING_WM_CHECK window.
This commit is contained in:
Havoc Pennington 2001-08-03 13:56:39 +00:00 committed by rhp
parent 204cf63805
commit 0ee26a5168
5 changed files with 141 additions and 43 deletions

View File

@ -1,3 +1,11 @@
2001-08-03 Havoc Pennington <hp@pobox.com>
* src/keybindings.c: Add Alt + left/right arrow to
move between workspaces.
* src/screen.c (set_wm_check_hint): put property pointing back to
itself on the _WIN_SUPPORTING_WM_CHECK window.
2001-08-03 Havoc Pennington <hp@pobox.com>
* src/display.c (event_callback): push error trap around configure

11
README
View File

@ -42,6 +42,8 @@ METACITY FEATURES
Alt-Tab forward cycle window focus
Alt-Shift-Tab backward cycle focus
Alt-Escape focus previous window
Alt-Left Arrow previous workspace
Alt-Right Arrow next workspace
- Window keybindings:
Alt-space window menu
@ -195,15 +197,6 @@ METACITY BUGS, NON-FEATURES, AND CAVEATS
window cycling that I would like to copy. (The little
popup window thing.)
- People seem to like shortcuts using arrow keys for moving
between workspaces. My only question here is that I'm not sure
what the spatial relationship between workspaces is.
(Are they in a grid, or a horizontal row, or what.)
I think we may need a window manager spec extension to
share this information between the WM and the pager.
We could add left/right arrow and pretend they're in
a row for the short term though.
- Should Metacity support flipping in right-to-left locales?
I don't know what window managers look like in a right-to-left
locale. I assume the window titles should be right-justified;

View File

@ -1288,6 +1288,10 @@ meta_display_get_workspace_by_index (MetaDisplay *display,
{
GList *tmp;
/* should be robust, index is maybe from an app */
if (index < 0)
return NULL;
tmp = g_list_nth (display->workspaces, index);
if (tmp == NULL)
@ -1304,6 +1308,10 @@ meta_display_get_workspace_by_screen_index (MetaDisplay *display,
GList *tmp;
int i;
/* should be robust, index is maybe from an app */
if (index < 0)
return NULL;
i = 0;
tmp = display->workspaces;
while (tmp != NULL)

View File

@ -57,6 +57,14 @@ static void handle_focus_previous (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data);
static void handle_workspace_left (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data);
static void handle_workspace_right (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data);
typedef struct _MetaKeyBinding MetaKeyBinding;
@ -89,6 +97,8 @@ static MetaKeyBinding screen_bindings[] = {
{ XK_ISO_Left_Tab, ShiftMask | Mod1Mask, KeyPress, handle_tab_backward, NULL, 0 },
{ XK_Tab, ShiftMask | Mod1Mask, KeyPress, handle_tab_backward, NULL, 0 },
{ XK_Escape, Mod1Mask, KeyPress, handle_focus_previous, NULL, 0 },
{ XK_Left, Mod1Mask, KeyPress, handle_workspace_left, NULL, 0 },
{ XK_Right, Mod1Mask, KeyPress, handle_workspace_right, NULL, 0 },
{ None, 0, 0, NULL, NULL, 0 }
};
@ -500,20 +510,9 @@ meta_display_process_key_event (MetaDisplay *display,
}
static void
handle_activate_workspace (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
gpointer data)
switch_to_workspace (MetaDisplay *display,
MetaWorkspace *workspace)
{
int which;
MetaWorkspace *workspace;
which = GPOINTER_TO_INT (data);
workspace = meta_display_get_workspace_by_index (display, which);
if (workspace)
{
MetaWindow *move_window;
move_window = NULL;
@ -549,6 +548,86 @@ handle_activate_workspace (MetaDisplay *display,
meta_workspace_remove_window (move_window->workspaces->next->data,
move_window);
}
}
static void
handle_activate_workspace (MetaDisplay *display,
MetaWindow *event_window,
XEvent *event,
gpointer data)
{
int which;
MetaWorkspace *workspace;
which = GPOINTER_TO_INT (data);
workspace = meta_display_get_workspace_by_index (display, which);
if (workspace)
{
switch_to_workspace (display, workspace);
}
else
{
/* We could offer to create it I suppose */
}
}
static void
handle_workspace_left (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data)
{
MetaWorkspace *workspace;
MetaScreen *screen;
int i;
screen = meta_display_screen_for_root (display,
event->xkey.root);
if (screen == NULL)
return;
i = meta_workspace_index (screen->active_workspace);
--i;
workspace = meta_display_get_workspace_by_index (display, i);
if (workspace)
{
switch_to_workspace (display, workspace);
}
else
{
/* We could offer to create it I suppose */
}
}
static void
handle_workspace_right (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data)
{
MetaWorkspace *workspace;
MetaScreen *screen;
int i;
screen = meta_display_screen_for_root (display,
event->xkey.root);
if (screen == NULL)
return;
i = meta_workspace_index (screen->active_workspace);
++i;
workspace = meta_display_get_workspace_by_index (display, i);
if (workspace)
{
switch_to_workspace (display, workspace);
}
else
{

View File

@ -50,7 +50,17 @@ set_wm_check_hint (MetaScreen *screen)
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
/* Legacy GNOME hint */
/* Legacy GNOME hint (uses cardinal, dunno why) */
/* legacy hint window should have property containing self */
XChangeProperty (screen->display->xdisplay, screen->display->leader_window,
screen->display->atom_win_supporting_wm_check,
XA_CARDINAL,
32, PropModeReplace, (guchar*) data, 1);
/* do this after setting up window fully, to avoid races
* with clients listening to property notify on root.
*/
XChangeProperty (screen->display->xdisplay, screen->xroot,
screen->display->atom_win_supporting_wm_check,
XA_CARDINAL,