(Apologies for huge commit; these were done on a transatlantic flight. This is why we need bzr.)

2008-11-22  Thomas Thurman  <tthurman@gnome.org>

        * src/core/all-keybindings.h: "backward", not "backwards" throughout.

2008-11-20  Thomas Thurman  <tthurman@gnome.org>

        * configure.in: turned on -Wall and -Werror in order to
          trap as many problems as possible.
        * src/ui/resizepopup.c: added correct #include.
        * src/ui/theme-viewer.c: initialised variable.
        * src/core/xprops.c: corrected cast.
        * src/core/main.c: added warning if chdir() fails.
        * src/core/schema-bindings.c: checking the return
          result of fgets().

2008-11-20  Thomas Thurman  <tthurman@gnome.org>

        Merged screen and window keybinding tables so that
        we can use just one file for the both.  Also incidentally
        closes #528337.  Further efficiencies of scale to come.

        * src/include/prefs.h: replace META_PREF_*_KEYBINDINGS
          with META_PREF_KEYBINDINGS
        * src/core/keybindings.c: replace *_bindings with key_bindings
          and similar throughout; all window-based functions are now
          guaranteed to receive a window so don't need to check for
          themselves
          (find_handler): moved so it can also be called from
                          rebuild_binding_table
        * src/core/display-private.h: replace *_bindings with key_bindings
        * src/core/prefs.c: update_*_binding becomes update_key_binding;
          (change_notify): tidy up references to "enormous if statement"
                           since it's almost entirely gone now
        * src/core/all-keybindings.h: new merged version of
                           screen-bindings.h and window-bindings.h.


svn path=/trunk/; revision=4022
This commit is contained in:
Thomas Thurman 2008-11-22 19:02:54 +00:00 committed by Thomas James Alexander Thurman
parent a06d96316e
commit ac365b4ead
15 changed files with 351 additions and 1017 deletions

View File

@ -1,3 +1,39 @@
2008-11-22 Thomas Thurman <tthurman@gnome.org>
* src/core/all-keybindings.h: "backward", not "backwards" throughout.
2008-11-20 Thomas Thurman <tthurman@gnome.org>
* configure.in: turned on -Wall and -Werror in order to
trap as many problems as possible.
* src/ui/resizepopup.c: added correct #include.
* src/ui/theme-viewer.c: initialised variable.
* src/core/xprops.c: corrected cast.
* src/core/main.c: added warning if chdir() fails.
* src/core/schema-bindings.c: checking the return
result of fgets().
2008-11-20 Thomas Thurman <tthurman@gnome.org>
Merged screen and window keybinding tables so that
we can use just one file for the both. Also incidentally
closes #528337. Further efficiencies of scale to come.
* src/include/prefs.h: replace META_PREF_*_KEYBINDINGS
with META_PREF_KEYBINDINGS
* src/core/keybindings.c: replace *_bindings with key_bindings
and similar throughout; all window-based functions are now
guaranteed to receive a window so don't need to check for
themselves
(find_handler): moved so it can also be called from
rebuild_binding_table
* src/core/display-private.h: replace *_bindings with key_bindings
* src/core/prefs.c: update_*_binding becomes update_key_binding;
(change_notify): tidy up references to "enormous if statement"
since it's almost entirely gone now
* src/core/all-keybindings.h: new merged version of
screen-bindings.h and window-bindings.h.
2008-11-16 David Trowbridge <trowbrds@gmail.com> 2008-11-16 David Trowbridge <trowbrds@gmail.com>
This change adds support for the new _NET_WM_FULLSCREEN_MONITORS This change adds support for the new _NET_WM_FULLSCREEN_MONITORS

View File

@ -480,9 +480,12 @@ AC_ARG_ENABLE(debug,
[ --enable-debug enable debugging],, [ --enable-debug enable debugging],,
enable_debug=no) enable_debug=no)
if test "x$enable_debug" = "xyes"; then if test "x$enable_debug" = "xyes"; then
CFLAGS="$CFLAGS -g -O -Wall" CFLAGS="$CFLAGS -g -O"
fi fi
# Warnings are there for a reason
CFLAGS="$CFLAGS -Wall -Werror"
# Use gnome-doc-utils: # Use gnome-doc-utils:
GNOME_DOC_INIT([0.9.0]) GNOME_DOC_INIT([0.9.0])

View File

@ -97,8 +97,7 @@ metacity_SOURCES= \
ui/themewidget.c \ ui/themewidget.c \
ui/themewidget.h \ ui/themewidget.h \
ui/ui.c \ ui/ui.c \
include/window-bindings.h \ include/all-keybindings.h
include/screen-bindings.h
# by setting libmetacity_private_la_CFLAGS, the files shared with # by setting libmetacity_private_la_CFLAGS, the files shared with
# metacity proper will be compiled with different names. # metacity proper will be compiled with different names.

View File

@ -201,10 +201,8 @@ struct _MetaDisplay
int grab_resize_timeout_id; int grab_resize_timeout_id;
/* Keybindings stuff */ /* Keybindings stuff */
MetaKeyBinding *screen_bindings; MetaKeyBinding *key_bindings;
int n_screen_bindings; int n_key_bindings;
MetaKeyBinding *window_bindings;
int n_window_bindings;
int min_keycode; int min_keycode;
int max_keycode; int max_keycode;
KeySym *keymap; KeySym *keymap;

View File

@ -63,8 +63,7 @@ handler (MetaDisplay *display,\
MetaWindow *window,\ MetaWindow *window,\
XEvent *event,\ XEvent *event,\
MetaKeyBinding *binding); MetaKeyBinding *binding);
#include "window-bindings.h" #include "all-keybindings.h"
#include "screen-bindings.h"
#undef keybind #undef keybind
/* These can't be bound to anything, but they are used to handle /* These can't be bound to anything, but they are used to handle
@ -106,8 +105,7 @@ static gboolean process_workspace_switch_grab (MetaDisplay *display,
XEvent *event, XEvent *event,
KeySym keysym); KeySym keysym);
static void regrab_screen_bindings (MetaDisplay *display); static void regrab_key_bindings (MetaDisplay *display);
static void regrab_window_bindings (MetaDisplay *display);
typedef struct typedef struct
{ {
@ -128,16 +126,8 @@ struct _MetaKeyBinding
#define keybind(name, handler, param, flags, stroke, description) \ #define keybind(name, handler, param, flags, stroke, description) \
{ #name, handler, param, flags }, { #name, handler, param, flags },
static const MetaKeyHandler screen_handlers[] = { static const MetaKeyHandler key_handlers[] = {
#include "screen-bindings.h" #include "all-keybindings.h"
{ NULL, NULL, 0, 0 }
};
static const MetaKeyHandler window_handlers[] = {
/* TODO: Are window bindings only ever called on non-null windows?
* If so, we can remove the check from all of them.
*/
#include "window-bindings.h"
{ NULL, NULL, 0, 0 } { NULL, NULL, 0, 0 }
}; };
#undef keybind #undef keybind
@ -265,31 +255,16 @@ reload_keycodes (MetaDisplay *display)
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Reloading keycodes for binding tables\n"); "Reloading keycodes for binding tables\n");
if (display->screen_bindings) if (display->key_bindings)
{ {
int i; int i;
i = 0; i = 0;
while (i < display->n_screen_bindings) while (i < display->n_key_bindings)
{ {
if (display->screen_bindings[i].keycode == 0) if (display->key_bindings[i].keycode == 0)
display->screen_bindings[i].keycode = XKeysymToKeycode ( display->key_bindings[i].keycode = XKeysymToKeycode (
display->xdisplay, display->screen_bindings[i].keysym); display->xdisplay, display->key_bindings[i].keysym);
++i;
}
}
if (display->window_bindings)
{
int i;
i = 0;
while (i < display->n_window_bindings)
{
if (display->window_bindings[i].keycode == 0)
display->window_bindings[i].keycode = XKeysymToKeycode (
display->xdisplay, display->window_bindings[i].keysym);
++i; ++i;
} }
@ -302,49 +277,29 @@ reload_modifiers (MetaDisplay *display)
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Reloading keycodes for binding tables\n"); "Reloading keycodes for binding tables\n");
if (display->screen_bindings) if (display->key_bindings)
{ {
int i; int i;
i = 0; i = 0;
while (i < display->n_screen_bindings) while (i < display->n_key_bindings)
{ {
meta_display_devirtualize_modifiers (display, meta_display_devirtualize_modifiers (display,
display->screen_bindings[i].modifiers, display->key_bindings[i].modifiers,
&display->screen_bindings[i].mask); &display->key_bindings[i].mask);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
" Devirtualized mods 0x%x -> 0x%x (%s)\n", " Devirtualized mods 0x%x -> 0x%x (%s)\n",
display->screen_bindings[i].modifiers, display->key_bindings[i].modifiers,
display->screen_bindings[i].mask, display->key_bindings[i].mask,
display->screen_bindings[i].name); display->key_bindings[i].name);
++i;
}
}
if (display->window_bindings)
{
int i;
i = 0;
while (i < display->n_window_bindings)
{
meta_display_devirtualize_modifiers (display,
display->window_bindings[i].modifiers,
&display->window_bindings[i].mask);
meta_topic (META_DEBUG_KEYBINDINGS,
" Devirtualized mods 0x%x -> 0x%x (%s)\n",
display->window_bindings[i].modifiers,
display->window_bindings[i].mask,
display->window_bindings[i].name);
++i; ++i;
} }
} }
} }
static int static int
count_bindings (const MetaKeyPref *prefs, count_bindings (const MetaKeyPref *prefs,
int n_prefs) int n_prefs)
@ -380,6 +335,25 @@ count_bindings (const MetaKeyPref *prefs,
return count; return count;
} }
/* FIXME: replace this with a temporary hash */
static const MetaKeyHandler*
find_handler (const MetaKeyHandler *handlers,
const char *name)
{
const MetaKeyHandler *iter;
iter = handlers;
while (iter->name)
{
if (strcmp (iter->name, name) == 0)
return iter;
++iter;
}
return NULL;
}
static void static void
rebuild_binding_table (MetaDisplay *display, rebuild_binding_table (MetaDisplay *display,
MetaKeyBinding **bindings_p, MetaKeyBinding **bindings_p,
@ -406,7 +380,10 @@ rebuild_binding_table (MetaDisplay *display,
if (combo && (combo->keysym != None || combo->keycode != 0)) if (combo && (combo->keysym != None || combo->keycode != 0))
{ {
const MetaKeyHandler *handler = find_handler (key_handlers, prefs[src].name);
(*bindings_p)[dest].name = prefs[src].name; (*bindings_p)[dest].name = prefs[src].name;
(*bindings_p)[dest].handler = handler;
(*bindings_p)[dest].keysym = combo->keysym; (*bindings_p)[dest].keysym = combo->keysym;
(*bindings_p)[dest].keycode = combo->keycode; (*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers; (*bindings_p)[dest].modifiers = combo->modifiers;
@ -422,6 +399,7 @@ rebuild_binding_table (MetaDisplay *display,
prefs[src].name); prefs[src].name);
(*bindings_p)[dest].name = prefs[src].name; (*bindings_p)[dest].name = prefs[src].name;
(*bindings_p)[dest].handler = handler;
(*bindings_p)[dest].keysym = combo->keysym; (*bindings_p)[dest].keysym = combo->keysym;
(*bindings_p)[dest].keycode = combo->keycode; (*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers | (*bindings_p)[dest].modifiers = combo->modifiers |
@ -448,41 +426,26 @@ rebuild_binding_table (MetaDisplay *display,
} }
static void static void
rebuild_screen_binding_table (MetaDisplay *display) rebuild_key_binding_table (MetaDisplay *display)
{ {
const MetaKeyPref *prefs; const MetaKeyPref *prefs;
int n_prefs; int n_prefs;
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Rebuilding screen binding table from preferences\n"); "Rebuilding key binding table from preferences\n");
meta_prefs_get_screen_bindings (&prefs, &n_prefs); meta_prefs_get_key_bindings (&prefs, &n_prefs);
rebuild_binding_table (display, rebuild_binding_table (display,
&display->screen_bindings, &display->key_bindings,
&display->n_screen_bindings, &display->n_key_bindings,
prefs, n_prefs); prefs, n_prefs);
} }
static void static void
rebuild_window_binding_table (MetaDisplay *display) regrab_key_bindings (MetaDisplay *display)
{
const MetaKeyPref *prefs;
int n_prefs;
meta_topic (META_DEBUG_KEYBINDINGS,
"Rebuilding window binding table from preferences\n");
meta_prefs_get_window_bindings (&prefs, &n_prefs);
rebuild_binding_table (display,
&display->window_bindings,
&display->n_window_bindings,
prefs, n_prefs);
}
static void
regrab_screen_bindings (MetaDisplay *display)
{ {
GSList *tmp; GSList *tmp;
GSList *windows;
meta_error_trap_push (display); /* for efficiency push outer trap */ meta_error_trap_push (display); /* for efficiency push outer trap */
@ -497,18 +460,7 @@ regrab_screen_bindings (MetaDisplay *display)
tmp = tmp->next; tmp = tmp->next;
} }
meta_error_trap_pop (display, FALSE);
}
static void
regrab_window_bindings (MetaDisplay *display)
{
GSList *windows;
GSList *tmp;
windows = meta_display_list_windows (display); windows = meta_display_list_windows (display);
meta_error_trap_push (display); /* for efficiency push outer trap */
tmp = windows; tmp = windows;
while (tmp != NULL) while (tmp != NULL)
{ {
@ -532,14 +484,14 @@ display_get_keybinding_action (MetaDisplay *display,
{ {
int i; int i;
i = display->n_screen_bindings - 1; i = display->n_key_bindings - 1;
while (i >= 0) while (i >= 0)
{ {
if (display->screen_bindings[i].keysym == keysym && if (display->key_bindings[i].keysym == keysym &&
display->screen_bindings[i].keycode == keycode && display->key_bindings[i].keycode == keycode &&
display->screen_bindings[i].mask == mask) display->key_bindings[i].mask == mask)
{ {
return meta_prefs_get_keybinding_action (display->screen_bindings[i].name); return meta_prefs_get_keybinding_action (display->key_bindings[i].name);
} }
--i; --i;
@ -561,8 +513,7 @@ meta_display_process_mapping_event (MetaDisplay *display,
reload_modifiers (display); reload_modifiers (display);
regrab_screen_bindings (display); regrab_key_bindings (display);
regrab_window_bindings (display);
} }
else if (event->xmapping.request == MappingKeyboard) else if (event->xmapping.request == MappingKeyboard)
{ {
@ -574,8 +525,7 @@ meta_display_process_mapping_event (MetaDisplay *display,
reload_keycodes (display); reload_keycodes (display);
regrab_screen_bindings (display); regrab_key_bindings (display);
regrab_window_bindings (display);
} }
} }
@ -589,17 +539,11 @@ bindings_changed_callback (MetaPreference pref,
switch (pref) switch (pref)
{ {
case META_PREF_SCREEN_KEYBINDINGS: case META_PREF_KEYBINDINGS:
rebuild_screen_binding_table (display); rebuild_key_binding_table (display);
reload_keycodes (display); reload_keycodes (display);
reload_modifiers (display); reload_modifiers (display);
regrab_screen_bindings (display); regrab_key_bindings (display);
break;
case META_PREF_WINDOW_KEYBINDINGS:
rebuild_window_binding_table (display);
reload_keycodes (display);
reload_modifiers (display);
regrab_window_bindings (display);
break; break;
default: default:
break; break;
@ -622,10 +566,8 @@ meta_display_init_keys (MetaDisplay *display)
display->hyper_mask = 0; display->hyper_mask = 0;
display->super_mask = 0; display->super_mask = 0;
display->meta_mask = 0; display->meta_mask = 0;
display->screen_bindings = NULL; display->key_bindings = NULL;
display->n_screen_bindings = 0; display->n_key_bindings = 0;
display->window_bindings = NULL;
display->n_window_bindings = 0;
XDisplayKeycodes (display->xdisplay, XDisplayKeycodes (display->xdisplay,
&display->min_keycode, &display->min_keycode,
@ -639,8 +581,7 @@ meta_display_init_keys (MetaDisplay *display)
reload_keymap (display); reload_keymap (display);
reload_modmap (display); reload_modmap (display);
rebuild_window_binding_table (display); rebuild_key_binding_table (display);
rebuild_screen_binding_table (display);
reload_keycodes (display); reload_keycodes (display);
reload_modifiers (display); reload_modifiers (display);
@ -662,8 +603,7 @@ meta_display_shutdown_keys (MetaDisplay *display)
if (display->modmap) if (display->modmap)
XFreeModifiermap (display->modmap); XFreeModifiermap (display->modmap);
g_free (display->screen_bindings); g_free (display->key_bindings);
g_free (display->window_bindings);
} }
static const char* static const char*
@ -765,7 +705,8 @@ static void
grab_keys (MetaKeyBinding *bindings, grab_keys (MetaKeyBinding *bindings,
int n_bindings, int n_bindings,
MetaDisplay *display, MetaDisplay *display,
Window xwindow) Window xwindow,
gboolean binding_per_window)
{ {
int i; int i;
@ -776,7 +717,9 @@ grab_keys (MetaKeyBinding *bindings,
i = 0; i = 0;
while (i < n_bindings) while (i < n_bindings)
{ {
if (bindings[i].keycode != 0) if (!!binding_per_window ==
!!(bindings[i].handler->flags & BINDING_PER_WINDOW) &&
bindings[i].keycode != 0)
{ {
meta_grab_key (display, xwindow, meta_grab_key (display, xwindow,
bindings[i].keysym, bindings[i].keysym,
@ -825,9 +768,10 @@ meta_screen_grab_keys (MetaScreen *screen)
if (screen->keys_grabbed) if (screen->keys_grabbed)
return; return;
grab_keys (screen->display->screen_bindings, grab_keys (screen->display->key_bindings,
screen->display->n_screen_bindings, screen->display->n_key_bindings,
screen->display, screen->xroot); screen->display, screen->xroot,
FALSE);
screen->keys_grabbed = TRUE; screen->keys_grabbed = TRUE;
} }
@ -867,10 +811,11 @@ meta_window_grab_keys (MetaWindow *window)
return; /* already all good */ return; /* already all good */
} }
grab_keys (window->display->window_bindings, grab_keys (window->display->key_bindings,
window->display->n_window_bindings, window->display->n_key_bindings,
window->display, window->display,
window->frame ? window->frame->xwindow : window->xwindow); window->frame ? window->frame->xwindow : window->xwindow,
TRUE);
window->keys_grabbed = TRUE; window->keys_grabbed = TRUE;
window->grab_on_frame = window->frame != NULL; window->grab_on_frame = window->frame != NULL;
@ -1214,34 +1159,16 @@ primary_modifier_still_pressed (MetaDisplay *display,
return TRUE; return TRUE;
} }
static const MetaKeyHandler* /* now called from only one place, may be worth merging */
find_handler (const MetaKeyHandler *handlers,
const char *name)
{
const MetaKeyHandler *iter;
iter = handlers;
while (iter->name)
{
if (strcmp (iter->name,
name) == 0)
return iter;
++iter;
}
return NULL;
}
static gboolean static gboolean
process_event (MetaKeyBinding *bindings, process_event (MetaKeyBinding *bindings,
int n_bindings, int n_bindings,
const MetaKeyHandler *handlers,
MetaDisplay *display, MetaDisplay *display,
MetaScreen *screen, MetaScreen *screen,
MetaWindow *window, MetaWindow *window,
XEvent *event, XEvent *event,
KeySym keysym) KeySym keysym,
gboolean on_window)
{ {
int i; int i;
@ -1249,48 +1176,50 @@ process_event (MetaKeyBinding *bindings,
if (event->type == KeyRelease) if (event->type == KeyRelease)
return FALSE; return FALSE;
i = 0; /*
while (i < n_bindings) * TODO: This would be better done with a hash table;
* it doesn't suit to use O(n) for such a common operation.
*/
for (i=0; i<n_bindings; i++)
{ {
if (bindings[i].keycode == event->xkey.keycode && const MetaKeyHandler *handler = bindings[i].handler;
((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) ==
bindings[i].mask) &&
event->type == KeyPress)
{
const MetaKeyHandler *handler;
meta_topic (META_DEBUG_KEYBINDINGS, if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
"Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n", event->type != KeyPress ||
bindings[i].keycode, bindings[i].mask, bindings[i].keycode != event->xkey.keycode ||
event->xkey.keycode, event->xkey.state); ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) !=
bindings[i].mask))
continue;
if (bindings[i].handler) /*
handler = bindings[i].handler; * window must be non-NULL for on_window to be true,
else * and so also window must be non-NULL if we get here and
{ * this is a BINDING_PER_WINDOW binding.
handler = find_handler (handlers, bindings[i].name); */
bindings[i].handler = handler; /* cache */
}
if (handler == NULL) meta_topic (META_DEBUG_KEYBINDINGS,
meta_bug ("Binding %s has no handler\n", bindings[i].name); "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n",
else bindings[i].keycode, bindings[i].mask,
meta_topic (META_DEBUG_KEYBINDINGS, event->xkey.keycode, event->xkey.state);
"Running handler for %s\n",
bindings[i].name);
/* Global keybindings count as a let-the-terminal-lose-focus if (handler == NULL)
* due to new window mapping until the user starts meta_bug ("Binding %s has no handler\n", bindings[i].name);
* interacting with the terminal again. else
*/ meta_topic (META_DEBUG_KEYBINDINGS,
display->allow_terminal_deactivation = TRUE; "Running handler for %s\n",
bindings[i].name);
(* handler->func) (display, screen, window, event, /* Global keybindings count as a let-the-terminal-lose-focus
&bindings[i]); * due to new window mapping until the user starts
return TRUE; * interacting with the terminal again.
} */
display->allow_terminal_deactivation = TRUE;
++i; (* handler->func) (display, screen,
bindings[i].handler->flags & BINDING_PER_WINDOW? window: NULL,
event,
&bindings[i]);
return TRUE;
} }
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
@ -1315,7 +1244,6 @@ meta_display_process_key_event (MetaDisplay *display,
XEvent *event) XEvent *event)
{ {
KeySym keysym; KeySym keysym;
gboolean handled;
gboolean keep_grab; gboolean keep_grab;
gboolean all_keys_grabbed; gboolean all_keys_grabbed;
const char *str; const char *str;
@ -1349,6 +1277,7 @@ meta_display_process_key_event (MetaDisplay *display,
str = XKeysymToString (keysym); str = XKeysymToString (keysym);
/* was topic */
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Processing key %s event, keysym: %s state: 0x%x window: %s\n", "Processing key %s event, keysym: %s state: 0x%x window: %s\n",
event->type == KeyPress ? "press" : "release", event->type == KeyPress ? "press" : "release",
@ -1441,16 +1370,10 @@ meta_display_process_key_event (MetaDisplay *display,
} }
} }
/* Do the normal keybindings */ /* Do the normal keybindings */
handled = process_event (display->screen_bindings, process_event (display->key_bindings,
display->n_screen_bindings, display->n_key_bindings,
screen_handlers, display, screen, window, event, keysym,
display, screen, NULL, event, keysym); !all_keys_grabbed && window);
if (!all_keys_grabbed && !handled && window)
handled = process_event (display->window_bindings,
display->n_window_bindings,
window_handlers,
display, screen, window, event, keysym);
} }
static gboolean static gboolean
@ -2480,7 +2403,7 @@ handle_maximize_vertically (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window && window->has_resize_func) if (window->has_resize_func)
{ {
if (window->maximized_vertically) if (window->maximized_vertically)
meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL); meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
@ -2496,7 +2419,7 @@ handle_maximize_horizontally (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window && window->has_resize_func) if (window->has_resize_func)
{ {
if (window->maximized_horizontally) if (window->maximized_horizontally)
meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL); meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
@ -2564,10 +2487,7 @@ handle_move_to_corner_nw (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, FALSE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, FALSE);
}
} }
static void static void
@ -2577,10 +2497,7 @@ handle_move_to_corner_ne (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, FALSE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, FALSE);
}
} }
static void static void
@ -2590,10 +2507,7 @@ handle_move_to_corner_sw (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, TRUE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, FALSE, TRUE);
}
} }
static void static void
@ -2603,10 +2517,7 @@ handle_move_to_corner_se (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, TRUE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, TRUE, TRUE, TRUE);
}
} }
static void static void
@ -2616,10 +2527,7 @@ handle_move_to_side_n (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, FALSE);
{
handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, FALSE);
}
} }
static void static void
@ -2629,10 +2537,7 @@ handle_move_to_side_s (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, TRUE);
{
handle_move_to_corner_backend (display, screen, window, FALSE, TRUE, FALSE, TRUE);
}
} }
static void static void
@ -2642,10 +2547,7 @@ handle_move_to_side_e (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, TRUE, FALSE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, TRUE, FALSE);
}
} }
static void static void
@ -2655,10 +2557,7 @@ handle_move_to_side_w (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, FALSE, FALSE);
{
handle_move_to_corner_backend (display, screen, window, TRUE, FALSE, FALSE, FALSE);
}
} }
static void static void
@ -2673,9 +2572,6 @@ handle_move_to_center (MetaDisplay *display,
int orig_x, orig_y; int orig_x, orig_y;
int frame_width, frame_height; int frame_width, frame_height;
if (!window)
return;
meta_window_get_work_area_all_xineramas (window, &work_area); meta_window_get_work_area_all_xineramas (window, &work_area);
meta_window_get_outer_rect (window, &outer); meta_window_get_outer_rect (window, &outer);
meta_window_get_position (window, &orig_x, &orig_y); meta_window_get_position (window, &orig_x, &orig_y);
@ -3074,13 +2970,10 @@ handle_toggle_fullscreen (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->fullscreen)
{ meta_window_unmake_fullscreen (window);
if (window->fullscreen) else if (window->has_fullscreen_func)
meta_window_unmake_fullscreen (window); meta_window_make_fullscreen (window);
else if (window->has_fullscreen_func)
meta_window_make_fullscreen (window);
}
} }
static void static void
@ -3090,13 +2983,10 @@ handle_toggle_above (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->wm_state_above)
{ meta_window_unmake_above (window);
if (window->wm_state_above) else
meta_window_unmake_above (window); meta_window_make_above (window);
else
meta_window_make_above (window);
}
} }
static void static void
@ -3106,17 +2996,14 @@ handle_toggle_maximized (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (META_WINDOW_MAXIMIZED (window))
{ meta_window_unmaximize (window,
if (META_WINDOW_MAXIMIZED (window)) META_MAXIMIZE_HORIZONTAL |
meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
META_MAXIMIZE_HORIZONTAL | else if (window->has_maximize_func)
META_MAXIMIZE_VERTICAL); meta_window_maximize (window,
else if (window->has_maximize_func) META_MAXIMIZE_HORIZONTAL |
meta_window_maximize (window, META_MAXIMIZE_VERTICAL);
META_MAXIMIZE_HORIZONTAL |
META_MAXIMIZE_VERTICAL);
}
} }
static void static void
@ -3126,13 +3013,10 @@ handle_maximize (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->has_maximize_func)
{ meta_window_maximize (window,
if (window->has_maximize_func) META_MAXIMIZE_HORIZONTAL |
meta_window_maximize (window, META_MAXIMIZE_VERTICAL);
META_MAXIMIZE_HORIZONTAL |
META_MAXIMIZE_VERTICAL);
}
} }
static void static void
@ -3142,13 +3026,10 @@ handle_unmaximize (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->maximized_vertically || window->maximized_horizontally)
{ meta_window_unmaximize (window,
if (window->maximized_vertically || window->maximized_horizontally) META_MAXIMIZE_HORIZONTAL |
meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
META_MAXIMIZE_HORIZONTAL |
META_MAXIMIZE_VERTICAL);
}
} }
static void static void
@ -3158,13 +3039,10 @@ handle_toggle_shaded (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->shaded)
{ meta_window_unshade (window, event->xkey.time);
if (window->shaded) else if (window->has_shade_func)
meta_window_unshade (window, event->xkey.time); meta_window_shade (window, event->xkey.time);
else if (window->has_shade_func)
meta_window_shade (window, event->xkey.time);
}
} }
static void static void
@ -3174,9 +3052,8 @@ handle_close (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->has_close_func)
if (window->has_close_func) meta_window_delete (window, event->xkey.time);
meta_window_delete (window, event->xkey.time);
} }
static void static void
@ -3186,9 +3063,8 @@ handle_minimize (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->has_minimize_func)
if (window->has_minimize_func) meta_window_minimize (window);
meta_window_minimize (window);
} }
static void static void
@ -3198,7 +3074,7 @@ handle_begin_move (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window && window->has_move_func) if (window->has_move_func)
{ {
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_MOVING, META_GRAB_OP_KEYBOARD_MOVING,
@ -3214,7 +3090,7 @@ handle_begin_resize (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window && window->has_resize_func) if (window->has_resize_func)
{ {
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN, META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
@ -3230,13 +3106,10 @@ handle_toggle_on_all_workspaces (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) if (window->on_all_workspaces)
{ meta_window_unstick (window);
if (window->on_all_workspaces) else
meta_window_unstick (window); meta_window_stick (window);
else
meta_window_stick (window);
}
} }
static void static void
@ -3258,7 +3131,7 @@ handle_move_to_workspace (MetaDisplay *display,
* all of whose members are negative. Such a change is called a flip. * all of whose members are negative. Such a change is called a flip.
*/ */
if (window == NULL || window->always_sticky) if (window->always_sticky)
return; return;
workspace = NULL; workspace = NULL;
@ -3302,44 +3175,41 @@ handle_raise_or_lower (MetaDisplay *display,
{ {
/* Get window at pointer */ /* Get window at pointer */
if (window) MetaWindow *above = NULL;
/* Check if top */
if (meta_stack_get_top (window->screen->stack) == window)
{ {
MetaWindow *above = NULL;
/* Check if top */
if (meta_stack_get_top (window->screen->stack) == window)
{
meta_window_lower (window);
return;
}
/* else check if windows in same layer are intersecting it */
above = meta_stack_get_above (window->screen->stack, window, TRUE);
while (above)
{
MetaRectangle tmp, win_rect, above_rect;
if (above->mapped)
{
meta_window_get_outer_rect (window, &win_rect);
meta_window_get_outer_rect (above, &above_rect);
/* Check if obscured */
if (meta_rectangle_intersect (&win_rect, &above_rect, &tmp))
{
meta_window_raise (window);
return;
}
}
above = meta_stack_get_above (window->screen->stack, above, TRUE);
}
/* window is not obscured */
meta_window_lower (window); meta_window_lower (window);
return;
} }
/* else check if windows in same layer are intersecting it */
above = meta_stack_get_above (window->screen->stack, window, TRUE);
while (above)
{
MetaRectangle tmp, win_rect, above_rect;
if (above->mapped)
{
meta_window_get_outer_rect (window, &win_rect);
meta_window_get_outer_rect (above, &above_rect);
/* Check if obscured */
if (meta_rectangle_intersect (&win_rect, &above_rect, &tmp))
{
meta_window_raise (window);
return;
}
}
above = meta_stack_get_above (window->screen->stack, above, TRUE);
}
/* window is not obscured */
meta_window_lower (window);
} }
static void static void
@ -3349,10 +3219,7 @@ handle_raise (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) meta_window_raise (window);
{
meta_window_raise (window);
}
} }
static void static void
@ -3362,10 +3229,7 @@ handle_lower (MetaDisplay *display,
XEvent *event, XEvent *event,
MetaKeyBinding *binding) MetaKeyBinding *binding)
{ {
if (window) meta_window_lower (window);
{
meta_window_lower (window);
}
} }
static void static void

View File

@ -403,7 +403,9 @@ main (int argc, char **argv)
meta_set_debugging (TRUE); meta_set_debugging (TRUE);
if (g_get_home_dir ()) if (g_get_home_dir ())
chdir (g_get_home_dir ()); if (chdir (g_get_home_dir ()) < 0)
meta_warning ("Could not change to home directory %s.\n",
g_get_home_dir ());
meta_print_self_identity (); meta_print_self_identity ();

View File

@ -108,17 +108,13 @@ static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, };
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
static gboolean handle_preference_update_enum (const gchar *key, GConfValue *value); static gboolean handle_preference_update_enum (const gchar *key, GConfValue *value);
static gboolean update_window_binding (const char *name, static gboolean update_key_binding (const char *name,
const char *value); const char *value);
static gboolean update_screen_binding (const char *name,
const char *value);
static gboolean find_and_update_list_binding (MetaKeyPref *bindings, static gboolean find_and_update_list_binding (MetaKeyPref *bindings,
const char *name, const char *name,
GSList *value); GSList *value);
static gboolean update_window_list_binding (const char *name, static gboolean update_key_list_binding (const char *name,
GSList *value); GSList *value);
static gboolean update_screen_list_binding (const char *name,
GSList *value);
static gboolean update_command (const char *name, static gboolean update_command (const char *name,
const char *value); const char *value);
static gboolean update_workspace_name (const char *name, static gboolean update_workspace_name (const char *name,
@ -1091,17 +1087,13 @@ change_notify (GConfClient *client,
while (preference_update_handler[i]!=NULL) while (preference_update_handler[i]!=NULL)
{ {
if (preference_update_handler[i] (key, value)) if (preference_update_handler[i] (key, value))
goto out; /* Get rid of this when we're done with the if */ goto out; /* Get rid of this eventually */
i++; i++;
} }
/* Otherwise, use the enormous if statement. We'll move entries if (g_str_has_prefix (key, KEY_WINDOW_BINDINGS_PREFIX) ||
* out of here as it becomes possible to deal with them in a g_str_has_prefix (key, KEY_SCREEN_BINDINGS_PREFIX))
* more general way.
*/
if (g_str_has_prefix (key, KEY_WINDOW_BINDINGS_PREFIX))
{ {
if (g_str_has_suffix (key, KEY_LIST_BINDINGS_SUFFIX)) if (g_str_has_suffix (key, KEY_LIST_BINDINGS_SUFFIX))
{ {
@ -1116,8 +1108,8 @@ change_notify (GConfClient *client,
list = value ? gconf_value_get_list (value) : NULL; list = value ? gconf_value_get_list (value) : NULL;
if (update_window_list_binding (key, list)) if (update_key_list_binding (key, list))
queue_changed (META_PREF_WINDOW_KEYBINDINGS); queue_changed (META_PREF_KEYBINDINGS);
} }
else else
{ {
@ -1132,43 +1124,8 @@ change_notify (GConfClient *client,
str = value ? gconf_value_get_string (value) : NULL; str = value ? gconf_value_get_string (value) : NULL;
if (update_window_binding (key, str)) if (update_key_binding (key, str))
queue_changed (META_PREF_WINDOW_KEYBINDINGS); queue_changed (META_PREF_KEYBINDINGS);
}
}
else if (g_str_has_prefix (key, KEY_SCREEN_BINDINGS_PREFIX))
{
if (g_str_has_suffix (key, KEY_LIST_BINDINGS_SUFFIX))
{
GSList *list;
if (value && value->type != GCONF_VALUE_LIST)
{
meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
key);
goto out;
}
list = value ? gconf_value_get_list (value) : NULL;
if (update_screen_list_binding (key, list))
queue_changed (META_PREF_SCREEN_KEYBINDINGS);
}
else
{
const char *str;
if (value && value->type != GCONF_VALUE_STRING)
{
meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
key);
goto out;
}
str = value ? gconf_value_get_string (value) : NULL;
if (update_screen_binding (key, str))
queue_changed (META_PREF_SCREEN_KEYBINDINGS);
} }
} }
else if (g_str_has_prefix (key, KEY_COMMAND_PREFIX)) else if (g_str_has_prefix (key, KEY_COMMAND_PREFIX))
@ -1722,11 +1679,8 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_APPLICATION_BASED: case META_PREF_APPLICATION_BASED:
return "APPLICATION_BASED"; return "APPLICATION_BASED";
case META_PREF_SCREEN_KEYBINDINGS: case META_PREF_KEYBINDINGS:
return "SCREEN_KEYBINDINGS"; return "KEYBINDINGS";
case META_PREF_WINDOW_KEYBINDINGS:
return "WINDOW_KEYBINDINGS";
case META_PREF_DISABLE_WORKAROUNDS: case META_PREF_DISABLE_WORKAROUNDS:
return "DISABLE_WORKAROUNDS"; return "DISABLE_WORKAROUNDS";
@ -1821,19 +1775,21 @@ meta_prefs_set_num_workspaces (int n_workspaces)
} }
#define keybind(name, handler, param, flags, stroke, description) \ #define keybind(name, handler, param, flags, stroke, description) \
{ #name, NULL, flags & BINDING_REVERSES }, { #name, NULL, !!(flags & BINDING_REVERSES), !!(flags & BINDING_PER_WINDOW) },
static MetaKeyPref screen_bindings[] = { static MetaKeyPref key_bindings[] = {
#include "screen-bindings.h" #include "all-keybindings.h"
{ NULL, NULL, FALSE}
};
static MetaKeyPref window_bindings[] = {
#include "window-bindings.h"
{ NULL, NULL, FALSE } { NULL, NULL, FALSE }
}; };
#undef keybind #undef keybind
#ifndef HAVE_GCONF #ifndef HAVE_GCONF
/**
* A type to map names of keybindings (such as "switch_windows")
* to the binding strings themselves (such as "<Alt>Tab").
* It exists only when GConf is turned off in ./configure and
* functions as a sort of ersatz GConf.
*/
typedef struct typedef struct
{ {
const char *name; const char *name;
@ -1849,16 +1805,11 @@ typedef struct
*/ */
#define keybind(name, handler, param, flags, stroke, description) \ #define keybind(name, handler, param, flags, stroke, description) \
{ #name, keystroke }, { #name, stroke },
static MetaSimpleKeyMapping screen_string_bindings[] = { static MetaSimpleKeyMapping key_string_bindings[] = {
#include "screen-bindings.h" #include "all-keybindings.h"
{ NULL, NULL } { NULL, NULL }
};
static MetaSimpleKeyMapping window_string_bindings[] = {
#include "window-bindings.h"
{ NULL, NULL }
}; };
#undef keybind #undef keybind
@ -1868,30 +1819,35 @@ static void
init_bindings (void) init_bindings (void)
{ {
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
int i; int i = 0;
GError *err; GError *err;
i = 0; while (key_bindings[i].name)
while (window_bindings[i].name)
{ {
GSList *list_val, *tmp; GSList *list_val, *tmp;
char *str_val; char *str_val;
char *key; char *key;
key = g_strconcat (KEY_WINDOW_BINDINGS_PREFIX, "/", key = g_strconcat (key_bindings[i].per_window?
window_bindings[i].name, NULL); KEY_WINDOW_BINDINGS_PREFIX:
KEY_SCREEN_BINDINGS_PREFIX,
"/",
key_bindings[i].name, NULL);
err = NULL; err = NULL;
str_val = gconf_client_get_string (default_client, key, &err); str_val = gconf_client_get_string (default_client, key, &err);
cleanup_error (&err); cleanup_error (&err);
update_binding (&window_bindings[i], str_val); update_binding (&key_bindings[i], str_val);
g_free (str_val); g_free (str_val);
g_free (key); g_free (key);
key = g_strconcat (KEY_WINDOW_BINDINGS_PREFIX, "/", key = g_strconcat (key_bindings[i].per_window?
window_bindings[i].name, KEY_WINDOW_BINDINGS_PREFIX:
KEY_SCREEN_BINDINGS_PREFIX,
"/",
key_bindings[i].name,
KEY_LIST_BINDINGS_SUFFIX, NULL); KEY_LIST_BINDINGS_SUFFIX, NULL);
err = NULL; err = NULL;
@ -1899,49 +1855,7 @@ init_bindings (void)
list_val = gconf_client_get_list (default_client, key, GCONF_VALUE_STRING, &err); list_val = gconf_client_get_list (default_client, key, GCONF_VALUE_STRING, &err);
cleanup_error (&err); cleanup_error (&err);
update_list_binding (&window_bindings[i], list_val, META_LIST_OF_STRINGS); update_list_binding (&key_bindings[i], list_val, META_LIST_OF_STRINGS);
tmp = list_val;
while (tmp)
{
g_free (tmp->data);
tmp = tmp->next;
}
g_slist_free (list_val);
g_free (key);
++i;
}
i = 0;
while (screen_bindings[i].name)
{
GSList *list_val, *tmp;
char *str_val;
char *key;
key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/",
screen_bindings[i].name, NULL);
err = NULL;
str_val = gconf_client_get_string (default_client, key, &err);
cleanup_error (&err);
update_binding (&screen_bindings[i], str_val);
g_free (str_val);
g_free (key);
key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/",
screen_bindings[i].name,
KEY_LIST_BINDINGS_SUFFIX, NULL);
err = NULL;
list_val = gconf_client_get_list (default_client, key, GCONF_VALUE_STRING, &err);
cleanup_error (&err);
update_list_binding (&screen_bindings[i], list_val, META_LIST_OF_STRINGS);
tmp = list_val; tmp = list_val;
while (tmp) while (tmp)
@ -1957,42 +1871,18 @@ init_bindings (void)
#else /* HAVE_GCONF */ #else /* HAVE_GCONF */
int i = 0; int i = 0;
int which = 0; int which = 0;
while (window_string_bindings[i].name) while (key_string_bindings[i].name)
{ {
if (window_string_bindings[i].keybinding == NULL) if (key_string_bindings[i].keybinding == NULL)
continue; continue;
/* Find which window_bindings entry this window_string_bindings entry while (strcmp(key_bindings[which].name,
* corresponds to. key_string_bindings[i].name) != 0)
*/
while (strcmp(window_bindings[which].name,
window_string_bindings[i].name) != 0)
which++; which++;
/* Set the binding */ /* Set the binding */
update_binding (&window_bindings[which], update_binding (&key_bindings[which],
window_string_bindings[i].keybinding); key_string_bindings[i].keybinding);
++i;
}
i = 0;
which = 0;
while (screen_string_bindings[i].name)
{
if (screen_string_bindings[i].keybinding == NULL)
continue;
/* Find which window_bindings entry this window_string_bindings entry
* corresponds to.
*/
while (strcmp(screen_bindings[which].name,
screen_string_bindings[i].name) != 0)
which++;
/* Set the binding */
update_binding (&screen_bindings[which],
screen_string_bindings[i].keybinding);
++i; ++i;
} }
@ -2112,8 +2002,8 @@ update_binding (MetaKeyPref *binding,
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
/* Bug 329676: Bindings which can be shifted must not have no modifiers, /* Bug 329676: Bindings which can be shifted must not have no modifiers,
* nor only SHIFT as a modifier. * nor only SHIFT as a modifier.
*/ */
if (binding->add_shift && if (binding->add_shift &&
0 != keysym && 0 != keysym &&
@ -2147,6 +2037,11 @@ update_binding (MetaKeyPref *binding,
binding->name, binding->name,
old_setting); old_setting);
/* FIXME: add_shift is currently screen_bindings only, but
* there's no really good reason it should always be.
* So we shouldn't blindly add KEY_SCREEN_BINDINGS_PREFIX
* onto here.
*/
key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/", key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/",
binding->name, NULL); binding->name, NULL);
@ -2350,17 +2245,10 @@ find_and_update_binding (MetaKeyPref *bindings,
} }
static gboolean static gboolean
update_window_binding (const char *name, update_key_binding (const char *name,
const char *value) const char *value)
{ {
return find_and_update_binding (window_bindings, name, value); return find_and_update_binding (key_bindings, name, value);
}
static gboolean
update_screen_binding (const char *name,
const char *value)
{
return find_and_update_binding (screen_bindings, name, value);
} }
static gboolean static gboolean
@ -2393,17 +2281,10 @@ find_and_update_list_binding (MetaKeyPref *bindings,
} }
static gboolean static gboolean
update_window_list_binding (const char *name, update_key_list_binding (const char *name,
GSList *value) GSList *value)
{ {
return find_and_update_list_binding (window_bindings, name, value); return find_and_update_list_binding (key_bindings, name, value);
}
static gboolean
update_screen_list_binding (const char *name,
GSList *value)
{
return find_and_update_list_binding (screen_bindings, name, value);
} }
static gboolean static gboolean
@ -2706,20 +2587,12 @@ meta_prefs_get_visual_bell_type (void)
} }
void void
meta_prefs_get_screen_bindings (const MetaKeyPref **bindings, meta_prefs_get_key_bindings (const MetaKeyPref **bindings,
int *n_bindings) int *n_bindings)
{ {
*bindings = screen_bindings; *bindings = key_bindings;
*n_bindings = (int) G_N_ELEMENTS (screen_bindings) - 1; *n_bindings = (int) G_N_ELEMENTS (key_bindings) - 1;
}
void
meta_prefs_get_window_bindings (const MetaKeyPref **bindings,
int *n_bindings)
{
*bindings = window_bindings;
*n_bindings = (int) G_N_ELEMENTS (window_bindings) - 1;
} }
MetaActionTitlebar MetaActionTitlebar
@ -2775,10 +2648,10 @@ meta_prefs_get_keybinding_action (const char *name)
{ {
int i; int i;
i = G_N_ELEMENTS (screen_bindings) - 2; /* -2 for dummy entry at end */ i = G_N_ELEMENTS (key_bindings) - 2; /* -2 for dummy entry at end */
while (i >= 0) while (i >= 0)
{ {
if (strcmp (screen_bindings[i].name, name) == 0) if (strcmp (key_bindings[i].name, name) == 0)
return (MetaKeyBindingAction) i; return (MetaKeyBindingAction) i;
--i; --i;
@ -2798,12 +2671,13 @@ meta_prefs_get_window_binding (const char *name,
{ {
int i; int i;
i = G_N_ELEMENTS (window_bindings) - 2; /* -2 for dummy entry at end */ i = G_N_ELEMENTS (key_bindings) - 2; /* -2 for dummy entry at end */
while (i >= 0) while (i >= 0)
{ {
if (strcmp (window_bindings[i].name, name) == 0) if (key_bindings[i].per_window &&
strcmp (key_bindings[i].name, name) == 0)
{ {
GSList *s = window_bindings[i].bindings; GSList *s = key_bindings[i].bindings;
while (s) while (s)
{ {

View File

@ -21,8 +21,8 @@
/** \file Schema bindings generator. /** \file Schema bindings generator.
* *
* This program simply takes the items given in the binding lists in * This program simply takes the items given in the binding list in
* window-bindings.h and scheme-bindings.h and turns them into a portion of * all-keybindings.h and turns them into a portion of
* the GConf .schemas file. * the GConf .schemas file.
* *
* FIXME: also need to make 50-metacity-desktop-key.xml * FIXME: also need to make 50-metacity-desktop-key.xml
@ -92,6 +92,11 @@ static void produce_bindings ();
static void static void
produce_bindings () produce_bindings ()
{ {
/* 10240 is ridiculous overkill; we're writing the input file and
* the lines are always 80 chars or less.
*/
char buffer[10240];
source_file = fopen(source_filename, "r"); source_file = fopen(source_filename, "r");
if (!source_file) if (!source_file)
@ -108,15 +113,8 @@ produce_bindings ()
target_filename, strerror (errno)); target_filename, strerror (errno));
} }
while (!feof (source_file)) while (fgets (buffer, sizeof (buffer), source_file))
{ {
/* 10240 is ridiculous overkill; we're writing the input file and
* the lines are always 80 chars or less.
*/
char buffer[10240];
fgets (buffer, sizeof (buffer), source_file);
if (strstr (buffer, "<!-- GENERATED -->")) if (strstr (buffer, "<!-- GENERATED -->"))
break; break;
@ -132,19 +130,12 @@ produce_bindings ()
stroke, \ stroke, \
flags & BINDING_REVERSES, \ flags & BINDING_REVERSES, \
description); description);
#include "window-bindings.h" #include "all-keybindings.h"
#include "screen-bindings.h"
#undef keybind #undef keybind
} }
while (!feof (source_file)) while (fgets (buffer, sizeof (buffer), source_file))
{
char buffer[10240];
fgets (buffer, sizeof (buffer), source_file);
fprintf (target_file, "%s", buffer); fprintf (target_file, "%s", buffer);
}
if (fclose (source_file)!=0) if (fclose (source_file)!=0)
g_error ("Cannot close %s: %s\n", g_error ("Cannot close %s: %s\n",

View File

@ -1051,7 +1051,7 @@ meta_prop_get_values (MetaDisplay *display,
&results.type, &results.format, &results.type, &results.format,
&results.n_items, &results.n_items,
&results.bytes_after, &results.bytes_after,
(unsigned char **)(&results.prop)) != Success || (char **)(&results.prop)) != Success ||
results.type == None) results.type == None)
{ {
values[i].type = META_PROP_VALUE_INVALID; values[i].type = META_PROP_VALUE_INVALID;

View File

@ -44,8 +44,7 @@ typedef enum
META_PREF_TITLEBAR_FONT, META_PREF_TITLEBAR_FONT,
META_PREF_NUM_WORKSPACES, META_PREF_NUM_WORKSPACES,
META_PREF_APPLICATION_BASED, META_PREF_APPLICATION_BASED,
META_PREF_WINDOW_KEYBINDINGS, META_PREF_KEYBINDINGS,
META_PREF_SCREEN_KEYBINDINGS,
META_PREF_DISABLE_WORKAROUNDS, META_PREF_DISABLE_WORKAROUNDS,
META_PREF_COMMANDS, META_PREF_COMMANDS,
META_PREF_TERMINAL_COMMAND, META_PREF_TERMINAL_COMMAND,
@ -183,7 +182,8 @@ typedef struct
typedef struct typedef struct
{ {
const char *name; const char *name;
/* a list of MetaKeyCombos. Each of them is bound to /**
* A list of MetaKeyCombos. Each of them is bound to
* this keypref. If one has keysym==modifiers==0, it is * this keypref. If one has keysym==modifiers==0, it is
* ignored. For historical reasons, the first entry is * ignored. For historical reasons, the first entry is
* governed by the pref FOO and the remainder are * governed by the pref FOO and the remainder are
@ -191,14 +191,15 @@ typedef struct
*/ */
GSList *bindings; GSList *bindings;
/* for keybindings that can have shift or not like Alt+Tab */ /** for keybindings that can have shift or not like Alt+Tab */
gboolean add_shift; gboolean add_shift:1;
/** for keybindings that apply only to a window */
gboolean per_window:1;
} MetaKeyPref; } MetaKeyPref;
void meta_prefs_get_screen_bindings (const MetaKeyPref **bindings, void meta_prefs_get_key_bindings (const MetaKeyPref **bindings,
int *n_bindings); int *n_bindings);
void meta_prefs_get_window_bindings (const MetaKeyPref **bindings,
int *n_bindings);
MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name); MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name);

View File

@ -1,258 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2008 Thomas Thurman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/**
* A list of screen keybinding information.
*
* Each action which can have a keystroke bound to it is listed below.
* To use this file, define keybind() to be a seven-argument macro (you can
* throw any of the arguments you please away), include this file,
* and then undefine the macro again.
*
* (If you aren't familiar with this technique, sometimes called "x-macros",
* see DDJ of May 2001: <http://www.ddj.com/cpp/184401387>.)
*
* This makes it possible to keep all information about all the keybindings
* in the same place. The only exception is the code to run when an action
* is actually invoked; while we *could* have put that in this file, it would
* have made debugging ridiculously difficult. Instead, each action should
* have a corresponding static function named handle_<name>() in
* keybindings.c.
*
* (This may merge with window-bindings.h at some point, but traditionally
* they have been separate concerns. Meanwhile, it is important that actions
* don't have names which clash between the two.)
*
* Currently, the GConf schemas in src/metacity.schemas also need to be
* updated separately. There is a program called schema-bindings.c in this
* directory which will fix that, but it needs integrating into the build
* process.
*
* The arguments to keybind() are:
* 1) the name of the binding; a bareword identifier
* (it's fine if it happens to clash with a C reserved word)
* 2) the name of the function which implements it.
* Clearly we could have guessed this from the binding very often,
* but we choose to write it in full for the benefit of grep.
* 3) an integer parameter to pass to the handler
* 4) a set of boolean flags, ORed together:
* BINDING_PER_WINDOW - this is a window-based binding
* (all in window-bindings.h use this,
* and none in screen-bindings.h)
* BINDING_REVERSES - the binding can reverse if you hold down Shift
* BINDING_IS_REVERSED - the same, but the senses are reversed from the
* handler's point of view (let me know if I should
* explain this better)
* or 0 if no flag applies.
*
* 5) a string representing the default binding.
* If this is NULL, the action is unbound by default.
* Please use NULL and not "disabled".
* 6) a short description.
* It must be marked translatable (i.e. inside "_(...)").
*
* Don't try to do XML entity escaping anywhere in the strings.
*/
#ifndef keybind
#error "keybind () must be defined when you include screen-bindings.h"
#endif
/***********************************/
#ifndef _BINDINGS_DEFINED_CONSTANTS
#define _BINDINGS_DEFINED_CONSTANTS 1
#define BINDING_PER_WINDOW 0x01
#define BINDING_REVERSES 0x02
#define BINDING_IS_REVERSED 0x04
#endif /* _BINDINGS_DEFINED_CONSTANTS */
/***********************************/
/* convenience, since in this file they must always be set together */
#define REVERSES_AND_REVERSED (BINDING_REVERSES | BINDING_IS_REVERSED)
keybind (switch_to_workspace_1, handle_switch_to_workspace, 0, 0, NULL,
_("Switch to workspace 1"))
keybind (switch_to_workspace_2, handle_switch_to_workspace, 1, 0, NULL,
_("Switch to workspace 2"))
keybind (switch_to_workspace_3, handle_switch_to_workspace, 2, 0, NULL,
_("Switch to workspace 3"))
keybind (switch_to_workspace_4, handle_switch_to_workspace, 3, 0, NULL,
_("Switch to workspace 4"))
keybind (switch_to_workspace_5, handle_switch_to_workspace, 4, 0, NULL,
_("Switch to workspace 5"))
keybind (switch_to_workspace_6, handle_switch_to_workspace, 5, 0, NULL,
_("Switch to workspace 6"))
keybind (switch_to_workspace_7, handle_switch_to_workspace, 6, 0, NULL,
_("Switch to workspace 7"))
keybind (switch_to_workspace_8, handle_switch_to_workspace, 7, 0, NULL,
_("Switch to workspace 8"))
keybind (switch_to_workspace_9, handle_switch_to_workspace, 8, 0, NULL,
_("Switch to workspace 9"))
keybind (switch_to_workspace_10, handle_switch_to_workspace, 9, 0, NULL,
_("Switch to workspace 10"))
keybind (switch_to_workspace_11, handle_switch_to_workspace, 10, 0, NULL,
_("Switch to workspace 11"))
keybind (switch_to_workspace_12, handle_switch_to_workspace, 11, 0, NULL,
_("Switch to workspace 12"))
/* META_MOTION_* are negative, and so distinct from workspace numbers,
* which are always zero or positive.
* If you make use of these constants, you will need to include workspace.h
* (which you're probably using already for other reasons anyway).
* If your definition of keybind() throws them away, you don't need to include
* workspace.h, of course.
*/
keybind (switch_to_workspace_left, handle_switch_to_workspace,
META_MOTION_LEFT, 0, "<Control><Alt>Left",
_("Switch to workspace on the left of the current workspace"))
keybind (switch_to_workspace_right, handle_switch_to_workspace,
META_MOTION_RIGHT, 0, "<Control><Alt>Right",
_("Switch to workspace on the right of the current workspace"))
keybind (switch_to_workspace_up, handle_switch_to_workspace,
META_MOTION_UP, 0, "<Control><Alt>Up",
_("Switch to workspace above the current workspace"))
keybind (switch_to_workspace_down, handle_switch_to_workspace,
META_MOTION_DOWN, 0, "<Control><Alt>Down",
_("Switch to workspace below the current workspace"))
/***********************************/
/* The ones which have inverses. These can't be bound to any keystroke
* containing Shift because Shift will invert their "backwards" state.
*
* TODO: "NORMAL" and "DOCKS" should be renamed to the same name as their
* action, for obviousness.
*
* TODO: handle_switch and handle_cycle should probably really be the
* same function checking a bit in the parameter for difference.
*/
keybind (switch_group, handle_switch, META_TAB_LIST_GROUP,
BINDING_REVERSES, NULL,
_("Move between windows of an application, using a popup window"))
keybind (switch_group_backwards, handle_switch, META_TAB_LIST_GROUP,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows of an application, "
"using a popup window"))
keybind (switch_windows, handle_switch, META_TAB_LIST_NORMAL,
BINDING_REVERSES, "<Alt>Tab",
_("Move between windows, using a popup window"))
keybind (switch_windows_backwards, handle_switch, META_TAB_LIST_NORMAL,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows, using a popup window"))
keybind (switch_panels, handle_switch, META_TAB_LIST_DOCKS,
BINDING_REVERSES, "<Control><Alt>Tab",
_("Move between panels and the desktop, using a popup window"))
keybind (switch_panels_backwards, handle_switch, META_TAB_LIST_DOCKS,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between panels and the desktop, "
"using a popup window"))
keybind (cycle_group, handle_cycle, META_TAB_LIST_GROUP,
BINDING_REVERSES, "<Alt>F6",
_("Move between windows of an application immediately"))
keybind (cycle_group_backwards, handle_cycle, META_TAB_LIST_GROUP,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows of an application immediately"))
keybind (cycle_windows, handle_cycle, META_TAB_LIST_NORMAL,
BINDING_REVERSES, "<Alt>Escape",
_("Move between windows immediately"))
keybind (cycle_windows_backwards, handle_cycle, META_TAB_LIST_NORMAL,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between windows immediately"))
keybind (cycle_panels, handle_cycle, META_TAB_LIST_DOCKS,
BINDING_REVERSES, "<Control><Alt>Escape",
_("Move between panels and the desktop immediately"))
keybind (cycle_panels_backwards, handle_cycle, META_TAB_LIST_DOCKS,
REVERSES_AND_REVERSED, NULL,
_("Move backwards between panels and the desktop immediately"))
/***********************************/
keybind (show_desktop, handle_show_desktop, 0, 0, "<Control><Alt>d",
_("Hide all normal windows and set focus to the desktop background"))
keybind (panel_main_menu, handle_panel,
META_KEYBINDING_ACTION_PANEL_MAIN_MENU, 0, "<Alt>F1",
_("Show the panel's main menu"))
keybind (panel_run_dialog, handle_panel,
META_KEYBINDING_ACTION_PANEL_RUN_DIALOG, 0, "<Alt>F2",
_("Show the panel's \"Run Application\" dialog box"))
/* Yes, the param is offset by one. Historical reasons. (Maybe worth fixing
* at some point.) The description is NULL here because the stanza is
* irregularly shaped in metacity.schemas.in. This will probably be fixed
* as well.
*/
keybind (run_command_1, handle_run_command, 0, 0, NULL, NULL)
keybind (run_command_2, handle_run_command, 1, 0, NULL, NULL)
keybind (run_command_3, handle_run_command, 2, 0, NULL, NULL)
keybind (run_command_4, handle_run_command, 3, 0, NULL, NULL)
keybind (run_command_5, handle_run_command, 4, 0, NULL, NULL)
keybind (run_command_6, handle_run_command, 5, 0, NULL, NULL)
keybind (run_command_7, handle_run_command, 6, 0, NULL, NULL)
keybind (run_command_8, handle_run_command, 7, 0, NULL, NULL)
keybind (run_command_9, handle_run_command, 8, 0, NULL, NULL)
keybind (run_command_10, handle_run_command, 9, 0, NULL, NULL)
keybind (run_command_11, handle_run_command, 10, 0, NULL, NULL)
keybind (run_command_12, handle_run_command, 11, 0, NULL, NULL)
keybind (run_command_13, handle_run_command, 12, 0, NULL, NULL)
keybind (run_command_14, handle_run_command, 13, 0, NULL, NULL)
keybind (run_command_15, handle_run_command, 14, 0, NULL, NULL)
keybind (run_command_16, handle_run_command, 15, 0, NULL, NULL)
keybind (run_command_17, handle_run_command, 16, 0, NULL, NULL)
keybind (run_command_18, handle_run_command, 17, 0, NULL, NULL)
keybind (run_command_19, handle_run_command, 18, 0, NULL, NULL)
keybind (run_command_20, handle_run_command, 19, 0, NULL, NULL)
keybind (run_command_21, handle_run_command, 20, 0, NULL, NULL)
keybind (run_command_22, handle_run_command, 21, 0, NULL, NULL)
keybind (run_command_23, handle_run_command, 22, 0, NULL, NULL)
keybind (run_command_24, handle_run_command, 23, 0, NULL, NULL)
keybind (run_command_25, handle_run_command, 24, 0, NULL, NULL)
keybind (run_command_26, handle_run_command, 25, 0, NULL, NULL)
keybind (run_command_27, handle_run_command, 26, 0, NULL, NULL)
keybind (run_command_28, handle_run_command, 27, 0, NULL, NULL)
keybind (run_command_29, handle_run_command, 28, 0, NULL, NULL)
keybind (run_command_30, handle_run_command, 29, 0, NULL, NULL)
keybind (run_command_31, handle_run_command, 30, 0, NULL, NULL)
keybind (run_command_32, handle_run_command, 31, 0, NULL, NULL)
keybind (run_command_screenshot, handle_run_command, 32, 0, "Print",
_("Take a screenshot"))
keybind (run_command_window_screenshot, handle_run_command, 33, 0,"<Alt>Print",
_("Take a screenshot of a window"))
keybind (run_command_terminal, handle_run_terminal, 0, 0, NULL, _("Run a terminal"))
/* No description because this is undocumented */
keybind (set_spew_mark, handle_set_spew_mark, 0, 0, NULL, NULL)
#undef REVERSES_AND_REVERSED
/* eof screen-bindings.h */

View File

@ -1,177 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2008 Thomas Thurman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/**
* A list of window keybinding information.
*
* Information about how this file works is in screen-bindings.h.
*/
#ifndef keybind
#error "keybind () must be defined when you include window-bindings.h"
#endif
/***********************************/
/* FIXME: this is duplicated from screen-bindings.h; find a better
* solution, which may involve merging the two files */
#ifndef _BINDINGS_DEFINED_CONSTANTS
#define _BINDINGS_DEFINED_CONSTANTS 1
#define BINDING_PER_WINDOW 0x01
#define BINDING_REVERSES 0x02
#define BINDING_IS_REVERSED 0x04
#endif /* _BINDINGS_DEFINED_CONSTANTS */
keybind (activate_window_menu, handle_activate_window_menu, 0,
BINDING_PER_WINDOW, "<Alt>space",
_("Activate the window menu"))
keybind (toggle_fullscreen, handle_toggle_fullscreen, 0, BINDING_PER_WINDOW,
NULL,
_("Toggle fullscreen mode"))
keybind (toggle_maximized, handle_toggle_maximized, 0, BINDING_PER_WINDOW, NULL,
_("Toggle maximization state"))
keybind (toggle_above, handle_toggle_above, 0, BINDING_PER_WINDOW, NULL,
_("Toggle whether a window will always be visible over other windows"))
keybind (maximize, handle_maximize, 0, BINDING_PER_WINDOW, "<Alt>F10",
_("Maximize window"))
keybind (unmaximize, handle_unmaximize, 0, BINDING_PER_WINDOW, "<Alt>F5",
_("Unmaximize window"))
keybind (toggle_shaded, handle_toggle_shaded, 0, BINDING_PER_WINDOW, NULL,
_("Toggle shaded state"))
keybind (minimize, handle_minimize, 0, BINDING_PER_WINDOW, "<Alt>F9",
_("Minimize window"))
keybind (close, handle_close, 0, BINDING_PER_WINDOW, "<Alt>F4",
_("Close window"))
keybind (begin_move, handle_begin_move, 0, BINDING_PER_WINDOW, "<Alt>F7",
_("Move window"))
keybind (begin_resize, handle_begin_resize, 0, BINDING_PER_WINDOW, "<Alt>F8",
_("Resize window"))
keybind (toggle_on_all_workspaces, handle_toggle_on_all_workspaces, 0,
BINDING_PER_WINDOW, NULL,
_("Toggle whether window is on all workspaces or just one"))
keybind (move_to_workspace_1, handle_move_to_workspace, 0, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 1"))
keybind (move_to_workspace_2, handle_move_to_workspace, 1, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 2"))
keybind (move_to_workspace_3, handle_move_to_workspace, 2, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 3"))
keybind (move_to_workspace_4, handle_move_to_workspace, 3, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 4"))
keybind (move_to_workspace_5, handle_move_to_workspace, 4, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 5"))
keybind (move_to_workspace_6, handle_move_to_workspace, 5, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 6"))
keybind (move_to_workspace_7, handle_move_to_workspace, 6, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 7"))
keybind (move_to_workspace_8, handle_move_to_workspace, 7, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 8"))
keybind (move_to_workspace_9, handle_move_to_workspace, 8, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 9"))
keybind (move_to_workspace_10, handle_move_to_workspace, 9, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 10"))
keybind (move_to_workspace_11, handle_move_to_workspace, 10, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 11"))
keybind (move_to_workspace_12, handle_move_to_workspace, 11, BINDING_PER_WINDOW,
NULL,
_("Move window to workspace 12"))
/* META_MOTION_* are negative, and so distinct from workspace numbers,
* which are always zero or positive.
* If you make use of these constants, you will need to include workspace.h
* (which you're probably using already for other reasons anyway).
* If your definition of keybind() throws them away, you don't need to include
* workspace.h, of course.
*/
keybind (move_to_workspace_left, handle_move_to_workspace,
META_MOTION_LEFT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Left",
_("Move window one workspace to the left"))
keybind (move_to_workspace_right, handle_move_to_workspace,
META_MOTION_RIGHT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Right",
_("Move window one workspace to the right"))
keybind (move_to_workspace_up, handle_move_to_workspace,
META_MOTION_UP, BINDING_PER_WINDOW, "<Control><Shift><Alt>Up",
_("Move window one workspace up"))
keybind (move_to_workspace_down, handle_move_to_workspace,
META_MOTION_DOWN, BINDING_PER_WINDOW, "<Control><Shift><Alt>Down",
_("Move window one workspace down"))
keybind (raise_or_lower, handle_raise_or_lower, 0, BINDING_PER_WINDOW, NULL,
_("Raise window if it's covered by another window, otherwise lower it"))
keybind (raise, handle_raise, 0, BINDING_PER_WINDOW, NULL,
_("Raise window above other windows"))
keybind (lower, handle_lower, 0, BINDING_PER_WINDOW, NULL,
_("Lower window below other windows"))
keybind (maximize_vertically, handle_maximize_vertically, 0,
BINDING_PER_WINDOW, NULL,
_("Maximize window vertically"))
keybind (maximize_horizontally, handle_maximize_horizontally, 0,
BINDING_PER_WINDOW, NULL,
_("Maximize window horizontally"))
keybind (move_to_corner_nw, handle_move_to_corner_nw, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to north-west (top left) corner"))
keybind (move_to_corner_ne, handle_move_to_corner_ne, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to north-east (top right) corner"))
keybind (move_to_corner_sw, handle_move_to_corner_sw, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to south-west (bottom left) corner"))
keybind (move_to_corner_nw, handle_move_to_corner_se, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to south-east (bottom right) corner"))
keybind (move_to_side_n, handle_move_to_side_n, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to north (top) side of screen"))
keybind (move_to_side_s, handle_move_to_side_s, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to south (bottom) side of screen"))
keybind (move_to_side_e, handle_move_to_side_e, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to east (right) side of screen"))
keybind (move_to_side_w, handle_move_to_side_w, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to west (left) side of screen"))
keybind (move_to_center, handle_move_to_center, 0,
BINDING_PER_WINDOW, NULL,
_("Move window to center of screen"))
/* eof window-bindings.h */

View File

@ -25,6 +25,7 @@
#include "resizepopup.h" #include "resizepopup.h"
#include "util.h" #include "util.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h>
struct _MetaResizePopup struct _MetaResizePopup
{ {

View File

@ -486,7 +486,7 @@ preview_collection (int font_size,
i = 0; i = 0;
while (i < META_FRAME_TYPE_LAST) while (i < META_FRAME_TYPE_LAST)
{ {
const char *title; const char *title = NULL;
GtkWidget *contents; GtkWidget *contents;
GtkWidget *align; GtkWidget *align;
double xalign, yalign; double xalign, yalign;

View File

@ -68,7 +68,7 @@ get_size (Display *d, Drawable draw,
int *xp, int *yp, int *widthp, int *heightp) int *xp, int *yp, int *widthp, int *heightp)
{ {
int x, y; int x, y;
unsigned int width, height, border, depth; unsigned int width=0, height=0, border=0, depth=0;
Window root; Window root;
XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth); XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);