summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/core/display-private.h6
-rw-r--r--src/core/keybindings.c540
-rw-r--r--src/core/main.c4
-rw-r--r--src/core/prefs.c272
-rw-r--r--src/core/schema-bindings.c29
-rw-r--r--src/core/xprops.c2
-rw-r--r--src/include/prefs.h19
-rw-r--r--src/include/screen-bindings.h258
-rw-r--r--src/include/window-bindings.h177
-rw-r--r--src/ui/resizepopup.c1
-rw-r--r--src/ui/theme-viewer.c2
-rw-r--r--src/wm-tester/test-resizing.c2
13 files changed, 305 insertions, 1010 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0615a62..3ce00f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,8 +97,7 @@ metacity_SOURCES= \
ui/themewidget.c \
ui/themewidget.h \
ui/ui.c \
- include/window-bindings.h \
- include/screen-bindings.h
+ include/all-keybindings.h
# by setting libmetacity_private_la_CFLAGS, the files shared with
# metacity proper will be compiled with different names.
diff --git a/src/core/display-private.h b/src/core/display-private.h
index add2e40..5f7dc48 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -201,10 +201,8 @@ struct _MetaDisplay
int grab_resize_timeout_id;
/* Keybindings stuff */
- MetaKeyBinding *screen_bindings;
- int n_screen_bindings;
- MetaKeyBinding *window_bindings;
- int n_window_bindings;
+ MetaKeyBinding *key_bindings;
+ int n_key_bindings;
int min_keycode;
int max_keycode;
KeySym *keymap;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 6b733d7..66b8294 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -63,8 +63,7 @@ handler (MetaDisplay *display,\
MetaWindow *window,\
XEvent *event,\
MetaKeyBinding *binding);
-#include "window-bindings.h"
-#include "screen-bindings.h"
+#include "all-keybindings.h"
#undef keybind
/* 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,
KeySym keysym);
-static void regrab_screen_bindings (MetaDisplay *display);
-static void regrab_window_bindings (MetaDisplay *display);
+static void regrab_key_bindings (MetaDisplay *display);
typedef struct
{
@@ -128,16 +126,8 @@ struct _MetaKeyBinding
#define keybind(name, handler, param, flags, stroke, description) \
{ #name, handler, param, flags },
-static const MetaKeyHandler screen_handlers[] = {
-#include "screen-bindings.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"
+static const MetaKeyHandler key_handlers[] = {
+#include "all-keybindings.h"
{ NULL, NULL, 0, 0 }
};
#undef keybind
@@ -264,32 +254,17 @@ reload_keycodes (MetaDisplay *display)
{
meta_topic (META_DEBUG_KEYBINDINGS,
"Reloading keycodes for binding tables\n");
-
- if (display->screen_bindings)
- {
- int i;
-
- i = 0;
- while (i < display->n_screen_bindings)
- {
- if (display->screen_bindings[i].keycode == 0)
- display->screen_bindings[i].keycode = XKeysymToKeycode (
- display->xdisplay, display->screen_bindings[i].keysym);
-
- ++i;
- }
- }
- if (display->window_bindings)
+ if (display->key_bindings)
{
int i;
i = 0;
- while (i < display->n_window_bindings)
+ while (i < display->n_key_bindings)
{
- if (display->window_bindings[i].keycode == 0)
- display->window_bindings[i].keycode = XKeysymToKeycode (
- display->xdisplay, display->window_bindings[i].keysym);
+ if (display->key_bindings[i].keycode == 0)
+ display->key_bindings[i].keycode = XKeysymToKeycode (
+ display->xdisplay, display->key_bindings[i].keysym);
++i;
}
@@ -302,49 +277,29 @@ reload_modifiers (MetaDisplay *display)
meta_topic (META_DEBUG_KEYBINDINGS,
"Reloading keycodes for binding tables\n");
- if (display->screen_bindings)
- {
- int i;
-
- i = 0;
- while (i < display->n_screen_bindings)
- {
- meta_display_devirtualize_modifiers (display,
- display->screen_bindings[i].modifiers,
- &display->screen_bindings[i].mask);
-
- meta_topic (META_DEBUG_KEYBINDINGS,
- " Devirtualized mods 0x%x -> 0x%x (%s)\n",
- display->screen_bindings[i].modifiers,
- display->screen_bindings[i].mask,
- display->screen_bindings[i].name);
-
- ++i;
- }
- }
-
- if (display->window_bindings)
+ if (display->key_bindings)
{
int i;
i = 0;
- while (i < display->n_window_bindings)
+ while (i < display->n_key_bindings)
{
meta_display_devirtualize_modifiers (display,
- display->window_bindings[i].modifiers,
- &display->window_bindings[i].mask);
+ display->key_bindings[i].modifiers,
+ &display->key_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);
+ display->key_bindings[i].modifiers,
+ display->key_bindings[i].mask,
+ display->key_bindings[i].name);
++i;
}
}
}
+
static int
count_bindings (const MetaKeyPref *prefs,
int n_prefs)
@@ -380,6 +335,25 @@ count_bindings (const MetaKeyPref *prefs,
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
rebuild_binding_table (MetaDisplay *display,
MetaKeyBinding **bindings_p,
@@ -406,7 +380,10 @@ rebuild_binding_table (MetaDisplay *display,
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].handler = handler;
(*bindings_p)[dest].keysym = combo->keysym;
(*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers;
@@ -422,6 +399,7 @@ rebuild_binding_table (MetaDisplay *display,
prefs[src].name);
(*bindings_p)[dest].name = prefs[src].name;
+ (*bindings_p)[dest].handler = handler;
(*bindings_p)[dest].keysym = combo->keysym;
(*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers |
@@ -448,41 +426,26 @@ rebuild_binding_table (MetaDisplay *display,
}
static void
-rebuild_screen_binding_table (MetaDisplay *display)
+rebuild_key_binding_table (MetaDisplay *display)
{
const MetaKeyPref *prefs;
int n_prefs;
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,
- &display->screen_bindings,
- &display->n_screen_bindings,
+ &display->key_bindings,
+ &display->n_key_bindings,
prefs, n_prefs);
}
static void
-rebuild_window_binding_table (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)
+regrab_key_bindings (MetaDisplay *display)
{
GSList *tmp;
+ GSList *windows;
meta_error_trap_push (display); /* for efficiency push outer trap */
@@ -497,18 +460,7 @@ regrab_screen_bindings (MetaDisplay *display)
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);
-
- meta_error_trap_push (display); /* for efficiency push outer trap */
tmp = windows;
while (tmp != NULL)
{
@@ -532,14 +484,14 @@ display_get_keybinding_action (MetaDisplay *display,
{
int i;
- i = display->n_screen_bindings - 1;
+ i = display->n_key_bindings - 1;
while (i >= 0)
{
- if (display->screen_bindings[i].keysym == keysym &&
- display->screen_bindings[i].keycode == keycode &&
- display->screen_bindings[i].mask == mask)
+ if (display->key_bindings[i].keysym == keysym &&
+ display->key_bindings[i].keycode == keycode &&
+ 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;
@@ -561,8 +513,7 @@ meta_display_process_mapping_event (MetaDisplay *display,
reload_modifiers (display);
- regrab_screen_bindings (display);
- regrab_window_bindings (display);
+ regrab_key_bindings (display);
}
else if (event->xmapping.request == MappingKeyboard)
{
@@ -574,8 +525,7 @@ meta_display_process_mapping_event (MetaDisplay *display,
reload_keycodes (display);
- regrab_screen_bindings (display);
- regrab_window_bindings (display);
+ regrab_key_bindings (display);
}
}
@@ -589,17 +539,11 @@ bindings_changed_callback (MetaPreference pref,
switch (pref)
{
- case META_PREF_SCREEN_KEYBINDINGS:
- rebuild_screen_binding_table (display);
+ case META_PREF_KEYBINDINGS:
+ rebuild_key_binding_table (display);
reload_keycodes (display);
reload_modifiers (display);
- regrab_screen_bindings (display);
- break;
- case META_PREF_WINDOW_KEYBINDINGS:
- rebuild_window_binding_table (display);
- reload_keycodes (display);
- reload_modifiers (display);
- regrab_window_bindings (display);
+ regrab_key_bindings (display);
break;
default:
break;
@@ -622,10 +566,8 @@ meta_display_init_keys (MetaDisplay *display)
display->hyper_mask = 0;
display->super_mask = 0;
display->meta_mask = 0;
- display->screen_bindings = NULL;
- display->n_screen_bindings = 0;
- display->window_bindings = NULL;
- display->n_window_bindings = 0;
+ display->key_bindings = NULL;
+ display->n_key_bindings = 0;
XDisplayKeycodes (display->xdisplay,
&display->min_keycode,
@@ -639,8 +581,7 @@ meta_display_init_keys (MetaDisplay *display)
reload_keymap (display);
reload_modmap (display);
- rebuild_window_binding_table (display);
- rebuild_screen_binding_table (display);
+ rebuild_key_binding_table (display);
reload_keycodes (display);
reload_modifiers (display);
@@ -662,8 +603,7 @@ meta_display_shutdown_keys (MetaDisplay *display)
if (display->modmap)
XFreeModifiermap (display->modmap);
- g_free (display->screen_bindings);
- g_free (display->window_bindings);
+ g_free (display->key_bindings);
}
static const char*
@@ -765,7 +705,8 @@ static void
grab_keys (MetaKeyBinding *bindings,
int n_bindings,
MetaDisplay *display,
- Window xwindow)
+ Window xwindow,
+ gboolean binding_per_window)
{
int i;
@@ -776,7 +717,9 @@ grab_keys (MetaKeyBinding *bindings,
i = 0;
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,
bindings[i].keysym,
@@ -825,9 +768,10 @@ meta_screen_grab_keys (MetaScreen *screen)
if (screen->keys_grabbed)
return;
- grab_keys (screen->display->screen_bindings,
- screen->display->n_screen_bindings,
- screen->display, screen->xroot);
+ grab_keys (screen->display->key_bindings,
+ screen->display->n_key_bindings,
+ screen->display, screen->xroot,
+ FALSE);
screen->keys_grabbed = TRUE;
}
@@ -867,10 +811,11 @@ meta_window_grab_keys (MetaWindow *window)
return; /* already all good */
}
- grab_keys (window->display->window_bindings,
- window->display->n_window_bindings,
+ grab_keys (window->display->key_bindings,
+ window->display->n_key_bindings,
window->display,
- window->frame ? window->frame->xwindow : window->xwindow);
+ window->frame ? window->frame->xwindow : window->xwindow,
+ TRUE);
window->keys_grabbed = TRUE;
window->grab_on_frame = window->frame != NULL;
@@ -1214,83 +1159,67 @@ primary_modifier_still_pressed (MetaDisplay *display,
return TRUE;
}
-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;
-}
-
+/* now called from only one place, may be worth merging */
static gboolean
process_event (MetaKeyBinding *bindings,
int n_bindings,
- const MetaKeyHandler *handlers,
MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
XEvent *event,
- KeySym keysym)
+ KeySym keysym,
+ gboolean on_window)
{
int i;
/* we used to have release-based bindings but no longer. */
if (event->type == KeyRelease)
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 &&
- ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) ==
- bindings[i].mask) &&
- event->type == KeyPress)
- {
- const MetaKeyHandler *handler;
+ const MetaKeyHandler *handler = bindings[i].handler;
- meta_topic (META_DEBUG_KEYBINDINGS,
- "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n",
- bindings[i].keycode, bindings[i].mask,
- event->xkey.keycode, event->xkey.state);
-
- if (bindings[i].handler)
- handler = bindings[i].handler;
- else
- {
- handler = find_handler (handlers, bindings[i].name);
- bindings[i].handler = handler; /* cache */
- }
+ if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
+ event->type != KeyPress ||
+ bindings[i].keycode != event->xkey.keycode ||
+ ((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) !=
+ bindings[i].mask))
+ continue;
+
+ /*
+ * window must be non-NULL for on_window to be true,
+ * and so also window must be non-NULL if we get here and
+ * this is a BINDING_PER_WINDOW binding.
+ */
- if (handler == NULL)
- meta_bug ("Binding %s has no handler\n", bindings[i].name);
- else
- meta_topic (META_DEBUG_KEYBINDINGS,
- "Running handler for %s\n",
- bindings[i].name);
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n",
+ bindings[i].keycode, bindings[i].mask,
+ event->xkey.keycode, event->xkey.state);
+
+ if (handler == NULL)
+ meta_bug ("Binding %s has no handler\n", bindings[i].name);
+ else
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Running handler for %s\n",
+ bindings[i].name);
- /* Global keybindings count as a let-the-terminal-lose-focus
- * due to new window mapping until the user starts
- * interacting with the terminal again.
- */
- display->allow_terminal_deactivation = TRUE;
+ /* Global keybindings count as a let-the-terminal-lose-focus
+ * due to new window mapping until the user starts
+ * interacting with the terminal again.
+ */
+ display->allow_terminal_deactivation = TRUE;
- (* handler->func) (display, screen, window, event,
- &bindings[i]);
- return 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,
@@ -1315,12 +1244,11 @@ meta_display_process_key_event (MetaDisplay *display,
XEvent *event)
{
KeySym keysym;
- gboolean handled;
gboolean keep_grab;
gboolean all_keys_grabbed;
const char *str;
MetaScreen *screen;
-
+
XAllowEvents (display->xdisplay,
all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
event->xkey.time);
@@ -1349,6 +1277,7 @@ meta_display_process_key_event (MetaDisplay *display,
str = XKeysymToString (keysym);
+ /* was topic */
meta_topic (META_DEBUG_KEYBINDINGS,
"Processing key %s event, keysym: %s state: 0x%x window: %s\n",
event->type == KeyPress ? "press" : "release",
@@ -1441,16 +1370,10 @@ meta_display_process_key_event (MetaDisplay *display,
}
}
/* Do the normal keybindings */
- handled = process_event (display->screen_bindings,
- display->n_screen_bindings,
- screen_handlers,
- display, screen, NULL, event, keysym);
-
- if (!all_keys_grabbed && !handled && window)
- handled = process_event (display->window_bindings,
- display->n_window_bindings,
- window_handlers,
- display, screen, window, event, keysym);
+ process_event (display->key_bindings,
+ display->n_key_bindings,
+ display, screen, window, event, keysym,
+ !all_keys_grabbed && window);
}
static gboolean
@@ -2480,7 +2403,7 @@ handle_maximize_vertically (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window && window->has_resize_func)
+ if (window->has_resize_func)
{
if (window->maximized_vertically)
meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
@@ -2496,7 +2419,7 @@ handle_maximize_horizontally (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window && window->has_resize_func)
+ if (window->has_resize_func)
{
if (window->maximized_horizontally)
meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
@@ -2564,10 +2487,7 @@ handle_move_to_corner_nw (MetaDisplay *display,
XEvent *event,
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
@@ -2577,10 +2497,7 @@ handle_move_to_corner_ne (MetaDisplay *display,
XEvent *event,
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
@@ -2590,10 +2507,7 @@ handle_move_to_corner_sw (MetaDisplay *display,
XEvent *event,
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
@@ -2603,10 +2517,7 @@ handle_move_to_corner_se (MetaDisplay *display,
XEvent *event,
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
@@ -2616,10 +2527,7 @@ handle_move_to_side_n (MetaDisplay *display,
XEvent *event,
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
@@ -2629,10 +2537,7 @@ handle_move_to_side_s (MetaDisplay *display,
XEvent *event,
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
@@ -2642,10 +2547,7 @@ handle_move_to_side_e (MetaDisplay *display,
XEvent *event,
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
@@ -2655,10 +2557,7 @@ handle_move_to_side_w (MetaDisplay *display,
XEvent *event,
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
@@ -2673,9 +2572,6 @@ handle_move_to_center (MetaDisplay *display,
int orig_x, orig_y;
int frame_width, frame_height;
- if (!window)
- return;
-
meta_window_get_work_area_all_xineramas (window, &work_area);
meta_window_get_outer_rect (window, &outer);
meta_window_get_position (window, &orig_x, &orig_y);
@@ -3074,13 +2970,10 @@ handle_toggle_fullscreen (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->fullscreen)
- meta_window_unmake_fullscreen (window);
- else if (window->has_fullscreen_func)
- meta_window_make_fullscreen (window);
- }
+ if (window->fullscreen)
+ meta_window_unmake_fullscreen (window);
+ else if (window->has_fullscreen_func)
+ meta_window_make_fullscreen (window);
}
static void
@@ -3090,13 +2983,10 @@ handle_toggle_above (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->wm_state_above)
- meta_window_unmake_above (window);
- else
- meta_window_make_above (window);
- }
+ if (window->wm_state_above)
+ meta_window_unmake_above (window);
+ else
+ meta_window_make_above (window);
}
static void
@@ -3106,17 +2996,14 @@ handle_toggle_maximized (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (META_WINDOW_MAXIMIZED (window))
- meta_window_unmaximize (window,
- META_MAXIMIZE_HORIZONTAL |
- META_MAXIMIZE_VERTICAL);
- else if (window->has_maximize_func)
- meta_window_maximize (window,
- META_MAXIMIZE_HORIZONTAL |
- META_MAXIMIZE_VERTICAL);
- }
+ if (META_WINDOW_MAXIMIZED (window))
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
+ else if (window->has_maximize_func)
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
static void
@@ -3126,13 +3013,10 @@ handle_maximize (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->has_maximize_func)
- meta_window_maximize (window,
- META_MAXIMIZE_HORIZONTAL |
- META_MAXIMIZE_VERTICAL);
- }
+ if (window->has_maximize_func)
+ meta_window_maximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
static void
@@ -3142,13 +3026,10 @@ handle_unmaximize (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->maximized_vertically || window->maximized_horizontally)
- meta_window_unmaximize (window,
- META_MAXIMIZE_HORIZONTAL |
- META_MAXIMIZE_VERTICAL);
- }
+ if (window->maximized_vertically || window->maximized_horizontally)
+ meta_window_unmaximize (window,
+ META_MAXIMIZE_HORIZONTAL |
+ META_MAXIMIZE_VERTICAL);
}
static void
@@ -3158,13 +3039,10 @@ handle_toggle_shaded (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->shaded)
- meta_window_unshade (window, event->xkey.time);
- else if (window->has_shade_func)
- meta_window_shade (window, event->xkey.time);
- }
+ if (window->shaded)
+ meta_window_unshade (window, event->xkey.time);
+ else if (window->has_shade_func)
+ meta_window_shade (window, event->xkey.time);
}
static void
@@ -3174,9 +3052,8 @@ handle_close (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- if (window->has_close_func)
- meta_window_delete (window, event->xkey.time);
+ if (window->has_close_func)
+ meta_window_delete (window, event->xkey.time);
}
static void
@@ -3186,9 +3063,8 @@ handle_minimize (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- if (window->has_minimize_func)
- meta_window_minimize (window);
+ if (window->has_minimize_func)
+ meta_window_minimize (window);
}
static void
@@ -3198,7 +3074,7 @@ handle_begin_move (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window && window->has_move_func)
+ if (window->has_move_func)
{
meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_MOVING,
@@ -3214,7 +3090,7 @@ handle_begin_resize (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window && window->has_resize_func)
+ if (window->has_resize_func)
{
meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
@@ -3230,13 +3106,10 @@ handle_toggle_on_all_workspaces (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- if (window->on_all_workspaces)
- meta_window_unstick (window);
- else
- meta_window_stick (window);
- }
+ if (window->on_all_workspaces)
+ meta_window_unstick (window);
+ else
+ meta_window_stick (window);
}
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.
*/
- if (window == NULL || window->always_sticky)
+ if (window->always_sticky)
return;
workspace = NULL;
@@ -3302,44 +3175,41 @@ handle_raise_or_lower (MetaDisplay *display,
{
/* Get window at pointer */
- if (window)
- {
- MetaWindow *above = NULL;
-
- /* Check if top */
- if (meta_stack_get_top (window->screen->stack) == window)
- {
- meta_window_lower (window);
- return;
- }
+ MetaWindow *above = NULL;
- /* else check if windows in same layer are intersecting it */
+ /* Check if top */
+ if (meta_stack_get_top (window->screen->stack) == window)
+ {
+ meta_window_lower (window);
+ return;
+ }
- above = meta_stack_get_above (window->screen->stack, window, TRUE);
-
- while (above)
- {
- MetaRectangle tmp, win_rect, above_rect;
+ /* else check if windows in same layer are intersecting it */
+
+ above = meta_stack_get_above (window->screen->stack, window, TRUE);
- if (above->mapped)
+ 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_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;
- }
+ meta_window_raise (window);
+ return;
}
+ }
- above = meta_stack_get_above (window->screen->stack, above, TRUE);
- }
-
- /* window is not obscured */
- meta_window_lower (window);
+ above = meta_stack_get_above (window->screen->stack, above, TRUE);
}
+
+ /* window is not obscured */
+ meta_window_lower (window);
}
static void
@@ -3349,10 +3219,7 @@ handle_raise (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- meta_window_raise (window);
- }
+ meta_window_raise (window);
}
static void
@@ -3362,10 +3229,7 @@ handle_lower (MetaDisplay *display,
XEvent *event,
MetaKeyBinding *binding)
{
- if (window)
- {
- meta_window_lower (window);
- }
+ meta_window_lower (window);
}
static void
diff --git a/src/core/main.c b/src/core/main.c
index 173be28..29a7d0c 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -403,7 +403,9 @@ main (int argc, char **argv)
meta_set_debugging (TRUE);
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 ();
diff --git a/src/core/prefs.c b/src/core/prefs.c
index e3de2fc..02f38a2 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -108,17 +108,13 @@ static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, };
#ifdef HAVE_GCONF
static gboolean handle_preference_update_enum (const gchar *key, GConfValue *value);
-static gboolean update_window_binding (const char *name,
- const char *value);
-static gboolean update_screen_binding (const char *name,
- const char *value);
+static gboolean update_key_binding (const char *name,
+ const char *value);
static gboolean find_and_update_list_binding (MetaKeyPref *bindings,
const char *name,
GSList *value);
-static gboolean update_window_list_binding (const char *name,
- GSList *value);
-static gboolean update_screen_list_binding (const char *name,
- GSList *value);
+static gboolean update_key_list_binding (const char *name,
+ GSList *value);
static gboolean update_command (const char *name,
const char *value);
static gboolean update_workspace_name (const char *name,
@@ -1091,17 +1087,13 @@ change_notify (GConfClient *client,
while (preference_update_handler[i]!=NULL)
{
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++;
}
-
- /* Otherwise, use the enormous if statement. We'll move entries
- * out of here as it becomes possible to deal with them in a
- * more general way.
- */
-
- if (g_str_has_prefix (key, KEY_WINDOW_BINDINGS_PREFIX))
+
+ if (g_str_has_prefix (key, KEY_WINDOW_BINDINGS_PREFIX) ||
+ g_str_has_prefix (key, KEY_SCREEN_BINDINGS_PREFIX))
{
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;
- if (update_window_list_binding (key, list))
- queue_changed (META_PREF_WINDOW_KEYBINDINGS);
+ if (update_key_list_binding (key, list))
+ queue_changed (META_PREF_KEYBINDINGS);
}
else
{
@@ -1132,43 +1124,8 @@ change_notify (GConfClient *client,
str = value ? gconf_value_get_string (value) : NULL;
- if (update_window_binding (key, str))
- queue_changed (META_PREF_WINDOW_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);
+ if (update_key_binding (key, str))
+ queue_changed (META_PREF_KEYBINDINGS);
}
}
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:
return "APPLICATION_BASED";
- case META_PREF_SCREEN_KEYBINDINGS:
- return "SCREEN_KEYBINDINGS";
-
- case META_PREF_WINDOW_KEYBINDINGS:
- return "WINDOW_KEYBINDINGS";
+ case META_PREF_KEYBINDINGS:
+ return "KEYBINDINGS";
case META_PREF_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) \
- { #name, NULL, flags & BINDING_REVERSES },
-static MetaKeyPref screen_bindings[] = {
-#include "screen-bindings.h"
- { NULL, NULL, FALSE}
-};
-
-static MetaKeyPref window_bindings[] = {
-#include "window-bindings.h"
+ { #name, NULL, !!(flags & BINDING_REVERSES), !!(flags & BINDING_PER_WINDOW) },
+static MetaKeyPref key_bindings[] = {
+#include "all-keybindings.h"
{ NULL, NULL, FALSE }
};
#undef keybind
#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
{
const char *name;
@@ -1849,16 +1805,11 @@ typedef struct
*/
#define keybind(name, handler, param, flags, stroke, description) \
- { #name, keystroke },
+ { #name, stroke },
-static MetaSimpleKeyMapping screen_string_bindings[] = {
-#include "screen-bindings.h"
- { NULL, NULL }
-};
-
-static MetaSimpleKeyMapping window_string_bindings[] = {
-#include "window-bindings.h"
- { NULL, NULL }
+static MetaSimpleKeyMapping key_string_bindings[] = {
+#include "all-keybindings.h"
+ { NULL, NULL }
};
#undef keybind
@@ -1867,81 +1818,44 @@ static MetaSimpleKeyMapping window_string_bindings[] = {
static void
init_bindings (void)
{
-#ifdef HAVE_GCONF
- int i;
+#ifdef HAVE_GCONF
+ int i = 0;
GError *err;
-
- i = 0;
- while (window_bindings[i].name)
- {
- GSList *list_val, *tmp;
- char *str_val;
- char *key;
-
- key = g_strconcat (KEY_WINDOW_BINDINGS_PREFIX, "/",
- window_bindings[i].name, NULL);
-
- err = NULL;
- str_val = gconf_client_get_string (default_client, key, &err);
- cleanup_error (&err);
- update_binding (&window_bindings[i], str_val);
-
- g_free (str_val);
- g_free (key);
-
- key = g_strconcat (KEY_WINDOW_BINDINGS_PREFIX, "/",
- window_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 (&window_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)
+ while (key_bindings[i].name)
{
GSList *list_val, *tmp;
char *str_val;
char *key;
-
- key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/",
- screen_bindings[i].name, NULL);
-
+
+ key = g_strconcat (key_bindings[i].per_window?
+ KEY_WINDOW_BINDINGS_PREFIX:
+ KEY_SCREEN_BINDINGS_PREFIX,
+ "/",
+ key_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);
+ update_binding (&key_bindings[i], str_val);
g_free (str_val);
g_free (key);
- key = g_strconcat (KEY_SCREEN_BINDINGS_PREFIX, "/",
- screen_bindings[i].name,
+ key = g_strconcat (key_bindings[i].per_window?
+ KEY_WINDOW_BINDINGS_PREFIX:
+ KEY_SCREEN_BINDINGS_PREFIX,
+ "/",
+ key_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);
+
+ update_list_binding (&key_bindings[i], list_val, META_LIST_OF_STRINGS);
tmp = list_val;
while (tmp)
@@ -1957,42 +1871,18 @@ init_bindings (void)
#else /* HAVE_GCONF */
int i = 0;
int which = 0;
- while (window_string_bindings[i].name)
+ while (key_string_bindings[i].name)
{
- if (window_string_bindings[i].keybinding == NULL)
- continue;
-
- /* Find which window_bindings entry this window_string_bindings entry
- * corresponds to.
- */
- while (strcmp(window_bindings[which].name,
- window_string_bindings[i].name) != 0)
- which++;
-
- /* Set the binding */
- update_binding (&window_bindings[which],
- window_string_bindings[i].keybinding);
-
- ++i;
- }
-
- i = 0;
- which = 0;
- while (screen_string_bindings[i].name)
- {
- if (screen_string_bindings[i].keybinding == NULL)
+ if (key_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)
+ while (strcmp(key_bindings[which].name,
+ key_string_bindings[i].name) != 0)
which++;
/* Set the binding */
- update_binding (&screen_bindings[which],
- screen_string_bindings[i].keybinding);
+ update_binding (&key_bindings[which],
+ key_string_bindings[i].keybinding);
++i;
}
@@ -2079,7 +1969,7 @@ update_binding (MetaKeyPref *binding,
MetaVirtualModifier mods;
MetaKeyCombo *combo;
gboolean changed;
-
+
meta_topic (META_DEBUG_KEYBINDINGS,
"Binding \"%s\" has new gconf value \"%s\"\n",
binding->name, value ? value : "none");
@@ -2112,8 +2002,8 @@ update_binding (MetaKeyPref *binding,
#ifdef HAVE_GCONF
/* 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 &&
0 != keysym &&
@@ -2147,6 +2037,11 @@ update_binding (MetaKeyPref *binding,
binding->name,
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, "/",
binding->name, NULL);
@@ -2350,17 +2245,10 @@ find_and_update_binding (MetaKeyPref *bindings,
}
static gboolean
-update_window_binding (const char *name,
- const char *value)
-{
- return find_and_update_binding (window_bindings, name, value);
-}
-
-static gboolean
-update_screen_binding (const char *name,
+update_key_binding (const char *name,
const char *value)
{
- return find_and_update_binding (screen_bindings, name, value);
+ return find_and_update_binding (key_bindings, name, value);
}
static gboolean
@@ -2393,17 +2281,10 @@ find_and_update_list_binding (MetaKeyPref *bindings,
}
static gboolean
-update_window_list_binding (const char *name,
- GSList *value)
-{
- return find_and_update_list_binding (window_bindings, name, value);
-}
-
-static gboolean
-update_screen_list_binding (const char *name,
+update_key_list_binding (const char *name,
GSList *value)
{
- return find_and_update_list_binding (screen_bindings, name, value);
+ return find_and_update_list_binding (key_bindings, name, value);
}
static gboolean
@@ -2706,20 +2587,12 @@ meta_prefs_get_visual_bell_type (void)
}
void
-meta_prefs_get_screen_bindings (const MetaKeyPref **bindings,
+meta_prefs_get_key_bindings (const MetaKeyPref **bindings,
int *n_bindings)
{
- *bindings = screen_bindings;
- *n_bindings = (int) G_N_ELEMENTS (screen_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;
+ *bindings = key_bindings;
+ *n_bindings = (int) G_N_ELEMENTS (key_bindings) - 1;
}
MetaActionTitlebar
@@ -2775,10 +2648,10 @@ meta_prefs_get_keybinding_action (const char *name)
{
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)
{
- if (strcmp (screen_bindings[i].name, name) == 0)
+ if (strcmp (key_bindings[i].name, name) == 0)
return (MetaKeyBindingAction) i;
--i;
@@ -2798,12 +2671,13 @@ meta_prefs_get_window_binding (const char *name,
{
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)
{
- 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)
{
diff --git a/src/core/schema-bindings.c b/src/core/schema-bindings.c
index 09869bc..77a4289 100644
--- a/src/core/schema-bindings.c
+++ b/src/core/schema-bindings.c
@@ -21,8 +21,8 @@
/** \file Schema bindings generator.
*
- * This program simply takes the items given in the binding lists in
- * window-bindings.h and scheme-bindings.h and turns them into a portion of
+ * This program simply takes the items given in the binding list in
+ * all-keybindings.h and turns them into a portion of
* the GConf .schemas file.
*
* FIXME: also need to make 50-metacity-desktop-key.xml
@@ -92,6 +92,11 @@ static void produce_bindings ();
static void
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");
if (!source_file)
@@ -108,15 +113,8 @@ produce_bindings ()
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 -->"))
break;
@@ -132,19 +130,12 @@ produce_bindings ()
stroke, \
flags & BINDING_REVERSES, \
description);
-#include "window-bindings.h"
-#include "screen-bindings.h"
+#include "all-keybindings.h"
#undef keybind
}
- while (!feof (source_file))
- {
- char buffer[10240];
-
- fgets (buffer, sizeof (buffer), source_file);
-
+ while (fgets (buffer, sizeof (buffer), source_file))
fprintf (target_file, "%s", buffer);
- }
if (fclose (source_file)!=0)
g_error ("Cannot close %s: %s\n",
diff --git a/src/core/xprops.c b/src/core/xprops.c
index d2edc55..7bb4257 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -1051,7 +1051,7 @@ meta_prop_get_values (MetaDisplay *display,
&results.type, &results.format,
&results.n_items,
&results.bytes_after,
- (unsigned char **)(&results.prop)) != Success ||
+ (char **)(&results.prop)) != Success ||
results.type == None)
{
values[i].type = META_PROP_VALUE_INVALID;
diff --git a/src/include/prefs.h b/src/include/prefs.h
index 69f978c..5acad23 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -44,8 +44,7 @@ typedef enum
META_PREF_TITLEBAR_FONT,
META_PREF_NUM_WORKSPACES,
META_PREF_APPLICATION_BASED,
- META_PREF_WINDOW_KEYBINDINGS,
- META_PREF_SCREEN_KEYBINDINGS,
+ META_PREF_KEYBINDINGS,
META_PREF_DISABLE_WORKAROUNDS,
META_PREF_COMMANDS,
META_PREF_TERMINAL_COMMAND,
@@ -183,7 +182,8 @@ typedef struct
typedef struct
{
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
* ignored. For historical reasons, the first entry is
* governed by the pref FOO and the remainder are
@@ -191,14 +191,15 @@ typedef struct
*/
GSList *bindings;
- /* for keybindings that can have shift or not like Alt+Tab */
- gboolean add_shift;
+ /** for keybindings that can have shift or not like Alt+Tab */
+ gboolean add_shift:1;
+
+ /** for keybindings that apply only to a window */
+ gboolean per_window:1;
} MetaKeyPref;
-void meta_prefs_get_screen_bindings (const MetaKeyPref **bindings,
- int *n_bindings);
-void meta_prefs_get_window_bindings (const MetaKeyPref **bindings,
- int *n_bindings);
+void meta_prefs_get_key_bindings (const MetaKeyPref **bindings,
+ int *n_bindings);
MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name);
diff --git a/src/include/screen-bindings.h b/src/include/screen-bindings.h
deleted file mode 100644
index d15c0bf..0000000
--- a/src/include/screen-bindings.h
+++ /dev/null
@@ -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 */
-
diff --git a/src/include/window-bindings.h b/src/include/window-bindings.h
deleted file mode 100644
index a75d582..0000000
--- a/src/include/window-bindings.h
+++ /dev/null
@@ -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 */
-
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index cca4708..11698e8 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -25,6 +25,7 @@
#include "resizepopup.h"
#include "util.h"
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
struct _MetaResizePopup
{
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index a5a9497..5787ad4 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -486,7 +486,7 @@ preview_collection (int font_size,
i = 0;
while (i < META_FRAME_TYPE_LAST)
{
- const char *title;
+ const char *title = NULL;
GtkWidget *contents;
GtkWidget *align;
double xalign, yalign;
diff --git a/src/wm-tester/test-resizing.c b/src/wm-tester/test-resizing.c
index 6bf5993..f948100 100644
--- a/src/wm-tester/test-resizing.c
+++ b/src/wm-tester/test-resizing.c
@@ -68,7 +68,7 @@ get_size (Display *d, Drawable draw,
int *xp, int *yp, int *widthp, int *heightp)
{
int x, y;
- unsigned int width, height, border, depth;
+ unsigned int width=0, height=0, border=0, depth=0;
Window root;
XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);