mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
adapt to virtual modifiers (meta_display_process_mapping_event): we need
2002-07-13 Havoc Pennington <hp@pobox.com> * src/keybindings.c: adapt to virtual modifiers (meta_display_process_mapping_event): we need to reload the binding tables now when the modmap changes. * src/prefs.c (update_binding): parse virtual modifiers, not plain modmask * src/common.h (MetaVirtualModifer): new enum * src/ui.c (meta_ui_parse_accelerator): use egg_accelerator_parse_virtual() * src/Makefile.am: add eggaccelerators.[hc] for the virtual accelerator parsing function
This commit is contained in:
parent
826a0c4e10
commit
812f783084
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2002-07-13 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* src/keybindings.c: adapt to virtual modifiers
|
||||
(meta_display_process_mapping_event): we need to reload the
|
||||
binding tables now when the modmap changes.
|
||||
|
||||
* src/prefs.c (update_binding): parse virtual modifiers, not
|
||||
plain modmask
|
||||
|
||||
* src/common.h (MetaVirtualModifer): new enum
|
||||
|
||||
* src/ui.c (meta_ui_parse_accelerator): use
|
||||
egg_accelerator_parse_virtual()
|
||||
|
||||
* src/Makefile.am: add eggaccelerators.[hc] for the virtual
|
||||
accelerator parsing function
|
||||
|
||||
2002-07-13 Christophe Fergeau <teuf@users.sourceforge.net>
|
||||
|
||||
* configure.in: added fr to ALL_LINGUAS
|
||||
|
@ -3,6 +3,10 @@ SUBDIRS=wm-tester tools themes
|
||||
|
||||
INCLUDES=@METACITY_CFLAGS@ -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS@\" -DMETACITY_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMETACITY_PKGDATADIR=\"$(pkgdatadir)\"
|
||||
|
||||
EGGFILES= \
|
||||
eggaccelerators.c \
|
||||
eggaccelerators.h
|
||||
|
||||
metacity_SOURCES= \
|
||||
common.h \
|
||||
core.c \
|
||||
@ -64,7 +68,8 @@ metacity_SOURCES= \
|
||||
workspace.c \
|
||||
workspace.h \
|
||||
xprops.c \
|
||||
xprops.h
|
||||
xprops.h \
|
||||
$(EGGFILES)
|
||||
|
||||
metacity_theme_viewer_SOURCES= \
|
||||
gradient.c \
|
||||
@ -118,4 +123,9 @@ CLEANFILES = inlinepixbufs.h
|
||||
inlinepixbufs.h: $(IMAGES)
|
||||
$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h
|
||||
|
||||
EXTRA_DIST=$(desktopfiles_DATA) $(IMAGES) $(schema_DATA)
|
||||
EXTRA_DIST=$(desktopfiles_DATA) $(IMAGES) $(schema_DATA) update-from-egg.sh
|
||||
|
||||
EGGDIR=$(srcdir)/../../libegg/libegg
|
||||
|
||||
regenerate-built-sources:
|
||||
EGGFILES="$(EGGFILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh
|
||||
|
17
src/common.h
17
src/common.h
@ -150,6 +150,23 @@ typedef enum
|
||||
META_FRAME_TYPE_LAST
|
||||
} MetaFrameType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* Create gratuitous divergence from regular
|
||||
* X mod bits, to be sure we find bugs
|
||||
*/
|
||||
META_VIRTUAL_SHIFT_MASK = 1 << 5,
|
||||
META_VIRTUAL_CONTROL_MASK = 1 << 6,
|
||||
META_VIRTUAL_ALT_MASK = 1 << 7,
|
||||
META_VIRTUAL_META_MASK = 1 << 8,
|
||||
META_VIRTUAL_SUPER_MASK = 1 << 9,
|
||||
META_VIRTUAL_HYPER_MASK = 1 << 10,
|
||||
META_VIRTUAL_MOD2_MASK = 1 << 11,
|
||||
META_VIRTUAL_MOD3_MASK = 1 << 12,
|
||||
META_VIRTUAL_MOD4_MASK = 1 << 13,
|
||||
META_VIRTUAL_MOD5_MASK = 1 << 14
|
||||
} MetaVirtualModifier;
|
||||
|
||||
/* should investigate changing these to whatever most apps use */
|
||||
#define META_ICON_WIDTH 32
|
||||
#define META_ICON_HEIGHT 32
|
||||
|
@ -218,7 +218,10 @@ struct _MetaDisplay
|
||||
unsigned int ignored_modifier_mask;
|
||||
unsigned int num_lock_mask;
|
||||
unsigned int scroll_lock_mask;
|
||||
|
||||
unsigned int hyper_mask;
|
||||
unsigned int super_mask;
|
||||
unsigned int meta_mask;
|
||||
|
||||
/* Xinerama cache */
|
||||
unsigned int xinerama_cache_invalidated : 1;
|
||||
|
||||
|
657
src/eggaccelerators.c
Normal file
657
src/eggaccelerators.c
Normal file
@ -0,0 +1,657 @@
|
||||
/* eggaccelerators.c
|
||||
* Copyright (C) 2002 Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
|
||||
* Developed by Havoc Pennington, Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "eggaccelerators.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
enum
|
||||
{
|
||||
EGG_MODMAP_ENTRY_SHIFT = 0,
|
||||
EGG_MODMAP_ENTRY_LOCK = 1,
|
||||
EGG_MODMAP_ENTRY_CONTROL = 2,
|
||||
EGG_MODMAP_ENTRY_MOD1 = 3,
|
||||
EGG_MODMAP_ENTRY_MOD2 = 4,
|
||||
EGG_MODMAP_ENTRY_MOD3 = 5,
|
||||
EGG_MODMAP_ENTRY_MOD4 = 6,
|
||||
EGG_MODMAP_ENTRY_MOD5 = 7,
|
||||
EGG_MODMAP_ENTRY_LAST = 8
|
||||
};
|
||||
|
||||
#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
|
||||
|
||||
} EggModmap;
|
||||
|
||||
const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
|
||||
|
||||
static inline gboolean
|
||||
is_alt (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'a' || string[1] == 'A') &&
|
||||
(string[2] == 'l' || string[2] == 'L') &&
|
||||
(string[3] == 't' || string[3] == 'T') &&
|
||||
(string[4] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_ctl (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'c' || string[1] == 'C') &&
|
||||
(string[2] == 't' || string[2] == 'T') &&
|
||||
(string[3] == 'l' || string[3] == 'L') &&
|
||||
(string[4] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_modx (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'm' || string[1] == 'M') &&
|
||||
(string[2] == 'o' || string[2] == 'O') &&
|
||||
(string[3] == 'd' || string[3] == 'D') &&
|
||||
(string[4] >= '1' && string[4] <= '5') &&
|
||||
(string[5] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_ctrl (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'c' || string[1] == 'C') &&
|
||||
(string[2] == 't' || string[2] == 'T') &&
|
||||
(string[3] == 'r' || string[3] == 'R') &&
|
||||
(string[4] == 'l' || string[4] == 'L') &&
|
||||
(string[5] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_shft (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 's' || string[1] == 'S') &&
|
||||
(string[2] == 'h' || string[2] == 'H') &&
|
||||
(string[3] == 'f' || string[3] == 'F') &&
|
||||
(string[4] == 't' || string[4] == 'T') &&
|
||||
(string[5] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_shift (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 's' || string[1] == 'S') &&
|
||||
(string[2] == 'h' || string[2] == 'H') &&
|
||||
(string[3] == 'i' || string[3] == 'I') &&
|
||||
(string[4] == 'f' || string[4] == 'F') &&
|
||||
(string[5] == 't' || string[5] == 'T') &&
|
||||
(string[6] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_control (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'c' || string[1] == 'C') &&
|
||||
(string[2] == 'o' || string[2] == 'O') &&
|
||||
(string[3] == 'n' || string[3] == 'N') &&
|
||||
(string[4] == 't' || string[4] == 'T') &&
|
||||
(string[5] == 'r' || string[5] == 'R') &&
|
||||
(string[6] == 'o' || string[6] == 'O') &&
|
||||
(string[7] == 'l' || string[7] == 'L') &&
|
||||
(string[8] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_release (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'r' || string[1] == 'R') &&
|
||||
(string[2] == 'e' || string[2] == 'E') &&
|
||||
(string[3] == 'l' || string[3] == 'L') &&
|
||||
(string[4] == 'e' || string[4] == 'E') &&
|
||||
(string[5] == 'a' || string[5] == 'A') &&
|
||||
(string[6] == 's' || string[6] == 'S') &&
|
||||
(string[7] == 'e' || string[7] == 'E') &&
|
||||
(string[8] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_meta (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'm' || string[1] == 'M') &&
|
||||
(string[2] == 'e' || string[2] == 'E') &&
|
||||
(string[3] == 't' || string[3] == 'T') &&
|
||||
(string[4] == 'a' || string[4] == 'A') &&
|
||||
(string[8] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_super (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 's' || string[1] == 'S') &&
|
||||
(string[2] == 'u' || string[2] == 'U') &&
|
||||
(string[3] == 'p' || string[3] == 'P') &&
|
||||
(string[4] == 'e' || string[4] == 'E') &&
|
||||
(string[5] == 'r' || string[5] == 'R') &&
|
||||
(string[8] == '>'));
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_hyper (const gchar *string)
|
||||
{
|
||||
return ((string[0] == '<') &&
|
||||
(string[1] == 'h' || string[1] == 'H') &&
|
||||
(string[2] == 'y' || string[2] == 'Y') &&
|
||||
(string[3] == 'p' || string[3] == 'P') &&
|
||||
(string[4] == 'e' || string[4] == 'E') &&
|
||||
(string[5] == 'r' || string[5] == 'R') &&
|
||||
(string[8] == '>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* egg_accelerator_parse_virtual:
|
||||
* @accelerator: string representing an accelerator
|
||||
* @accelerator_key: return location for accelerator keyval
|
||||
* @accelerator_mods: return location for accelerator modifier mask
|
||||
*
|
||||
* Parses a string representing a virtual accelerator. The format
|
||||
* looks like "<Control>a" or "<Shift><Alt>F1" or
|
||||
* "<Release>z" (the last one is for key release). The parser
|
||||
* is fairly liberal and allows lower or upper case, and also
|
||||
* abbreviations such as "<Ctl>" and "<Ctrl>".
|
||||
*
|
||||
* If the parse fails, @accelerator_key and @accelerator_mods will
|
||||
* be set to 0 (zero) and %FALSE will be returned. If the string contains
|
||||
* only modifiers, @accelerator_key will be set to 0 but %TRUE will be
|
||||
* returned.
|
||||
*
|
||||
* The virtual vs. concrete accelerator distinction is a relic of
|
||||
* how the X Window System works; there are modifiers Mod2-Mod5 that
|
||||
* can represent various keyboard keys (numlock, meta, hyper, etc.),
|
||||
* the virtual modifier represents the keyboard key, the concrete
|
||||
* modifier the actual Mod2-Mod5 bits in the key press event.
|
||||
*
|
||||
* Returns: %TRUE on success.
|
||||
*/
|
||||
gboolean
|
||||
egg_accelerator_parse_virtual (const gchar *accelerator,
|
||||
guint *accelerator_key,
|
||||
EggVirtualModifierType *accelerator_mods)
|
||||
{
|
||||
guint keyval;
|
||||
GdkModifierType mods;
|
||||
gint len;
|
||||
gboolean bad_keyval;
|
||||
|
||||
if (accelerator_key)
|
||||
*accelerator_key = 0;
|
||||
if (accelerator_mods)
|
||||
*accelerator_mods = 0;
|
||||
|
||||
g_return_val_if_fail (accelerator != NULL, FALSE);
|
||||
|
||||
bad_keyval = FALSE;
|
||||
|
||||
keyval = 0;
|
||||
mods = 0;
|
||||
len = strlen (accelerator);
|
||||
while (len)
|
||||
{
|
||||
if (*accelerator == '<')
|
||||
{
|
||||
if (len >= 9 && is_release (accelerator))
|
||||
{
|
||||
accelerator += 9;
|
||||
len -= 9;
|
||||
mods |= EGG_VIRTUAL_RELEASE_MASK;
|
||||
}
|
||||
else if (len >= 9 && is_control (accelerator))
|
||||
{
|
||||
accelerator += 9;
|
||||
len -= 9;
|
||||
mods |= EGG_VIRTUAL_CONTROL_MASK;
|
||||
}
|
||||
else if (len >= 7 && is_shift (accelerator))
|
||||
{
|
||||
accelerator += 7;
|
||||
len -= 7;
|
||||
mods |= EGG_VIRTUAL_SHIFT_MASK;
|
||||
}
|
||||
else if (len >= 6 && is_shft (accelerator))
|
||||
{
|
||||
accelerator += 6;
|
||||
len -= 6;
|
||||
mods |= EGG_VIRTUAL_SHIFT_MASK;
|
||||
}
|
||||
else if (len >= 6 && is_ctrl (accelerator))
|
||||
{
|
||||
accelerator += 6;
|
||||
len -= 6;
|
||||
mods |= EGG_VIRTUAL_CONTROL_MASK;
|
||||
}
|
||||
else if (len >= 6 && is_modx (accelerator))
|
||||
{
|
||||
static const guint mod_vals[] = {
|
||||
EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
|
||||
EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
|
||||
};
|
||||
|
||||
len -= 6;
|
||||
accelerator += 4;
|
||||
mods |= mod_vals[*accelerator - '1'];
|
||||
accelerator += 2;
|
||||
}
|
||||
else if (len >= 5 && is_ctl (accelerator))
|
||||
{
|
||||
accelerator += 5;
|
||||
len -= 5;
|
||||
mods |= EGG_VIRTUAL_CONTROL_MASK;
|
||||
}
|
||||
else if (len >= 5 && is_alt (accelerator))
|
||||
{
|
||||
accelerator += 5;
|
||||
len -= 5;
|
||||
mods |= EGG_VIRTUAL_ALT_MASK;
|
||||
}
|
||||
else if (len >= 6 && is_meta (accelerator))
|
||||
{
|
||||
accelerator += 6;
|
||||
len -= 6;
|
||||
mods |= EGG_VIRTUAL_META_MASK;
|
||||
}
|
||||
else if (len >= 7 && is_hyper (accelerator))
|
||||
{
|
||||
accelerator += 7;
|
||||
len -= 7;
|
||||
mods |= EGG_VIRTUAL_HYPER_MASK;
|
||||
}
|
||||
else if (len >= 7 && is_super (accelerator))
|
||||
{
|
||||
accelerator += 7;
|
||||
len -= 7;
|
||||
mods |= EGG_VIRTUAL_SUPER_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar last_ch;
|
||||
|
||||
last_ch = *accelerator;
|
||||
while (last_ch && last_ch != '>')
|
||||
{
|
||||
last_ch = *accelerator;
|
||||
accelerator += 1;
|
||||
len -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
keyval = gdk_keyval_from_name (accelerator);
|
||||
|
||||
if (keyval == 0)
|
||||
bad_keyval = TRUE;
|
||||
|
||||
accelerator += len;
|
||||
len -= len;
|
||||
}
|
||||
}
|
||||
|
||||
if (accelerator_key)
|
||||
*accelerator_key = gdk_keyval_to_lower (keyval);
|
||||
if (accelerator_mods)
|
||||
*accelerator_mods = mods;
|
||||
|
||||
return !bad_keyval && mods != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* egg_virtual_accelerator_name:
|
||||
* @accelerator_key: accelerator keyval
|
||||
* @accelerator_mods: accelerator modifier mask
|
||||
* @returns: a newly-allocated accelerator name
|
||||
*
|
||||
* Converts an accelerator keyval and modifier mask
|
||||
* into a string parseable by egg_accelerator_parse_virtual().
|
||||
* For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK,
|
||||
* this function returns "<Control>q".
|
||||
*
|
||||
* The caller of this function must free the returned string.
|
||||
*/
|
||||
gchar*
|
||||
egg_virtual_accelerator_name (guint accelerator_key,
|
||||
EggVirtualModifierType accelerator_mods)
|
||||
{
|
||||
static const gchar text_release[] = "<Release>";
|
||||
static const gchar text_shift[] = "<Shift>";
|
||||
static const gchar text_control[] = "<Control>";
|
||||
static const gchar text_mod1[] = "<Alt>";
|
||||
static const gchar text_mod2[] = "<Mod2>";
|
||||
static const gchar text_mod3[] = "<Mod3>";
|
||||
static const gchar text_mod4[] = "<Mod4>";
|
||||
static const gchar text_mod5[] = "<Mod5>";
|
||||
static const gchar text_meta[] = "<Meta>";
|
||||
static const gchar text_super[] = "<Super>";
|
||||
static const gchar text_hyper[] = "<Hyper>";
|
||||
guint l;
|
||||
gchar *keyval_name;
|
||||
gchar *accelerator;
|
||||
|
||||
accelerator_mods &= EGG_VIRTUAL_MODIFIER_MASK;
|
||||
|
||||
keyval_name = gdk_keyval_name (gdk_keyval_to_lower (accelerator_key));
|
||||
if (!keyval_name)
|
||||
keyval_name = "";
|
||||
|
||||
l = 0;
|
||||
if (accelerator_mods & EGG_VIRTUAL_RELEASE_MASK)
|
||||
l += sizeof (text_release) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_SHIFT_MASK)
|
||||
l += sizeof (text_shift) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_CONTROL_MASK)
|
||||
l += sizeof (text_control) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_ALT_MASK)
|
||||
l += sizeof (text_mod1) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD2_MASK)
|
||||
l += sizeof (text_mod2) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD3_MASK)
|
||||
l += sizeof (text_mod3) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD4_MASK)
|
||||
l += sizeof (text_mod4) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD5_MASK)
|
||||
l += sizeof (text_mod5) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_META_MASK)
|
||||
l += sizeof (text_meta) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_HYPER_MASK)
|
||||
l += sizeof (text_hyper) - 1;
|
||||
if (accelerator_mods & EGG_VIRTUAL_SUPER_MASK)
|
||||
l += sizeof (text_super) - 1;
|
||||
l += strlen (keyval_name);
|
||||
|
||||
accelerator = g_new (gchar, l + 1);
|
||||
|
||||
l = 0;
|
||||
accelerator[l] = 0;
|
||||
if (accelerator_mods & EGG_VIRTUAL_RELEASE_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_release);
|
||||
l += sizeof (text_release) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_SHIFT_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_shift);
|
||||
l += sizeof (text_shift) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_CONTROL_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_control);
|
||||
l += sizeof (text_control) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_ALT_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_mod1);
|
||||
l += sizeof (text_mod1) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD2_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_mod2);
|
||||
l += sizeof (text_mod2) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD3_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_mod3);
|
||||
l += sizeof (text_mod3) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD4_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_mod4);
|
||||
l += sizeof (text_mod4) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_MOD5_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_mod5);
|
||||
l += sizeof (text_mod5) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_META_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_meta);
|
||||
l += sizeof (text_meta) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_HYPER_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_hyper);
|
||||
l += sizeof (text_hyper) - 1;
|
||||
}
|
||||
if (accelerator_mods & EGG_VIRTUAL_SUPER_MASK)
|
||||
{
|
||||
strcpy (accelerator + l, text_super);
|
||||
l += sizeof (text_super) - 1;
|
||||
}
|
||||
|
||||
strcpy (accelerator + l, keyval_name);
|
||||
|
||||
return accelerator;
|
||||
}
|
||||
|
||||
void
|
||||
egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
|
||||
EggVirtualModifierType virtual_mods,
|
||||
GdkModifierType *concrete_mods)
|
||||
{
|
||||
GdkModifierType concrete;
|
||||
int i;
|
||||
const EggModmap *modmap;
|
||||
|
||||
g_return_if_fail (GDK_IS_KEYMAP (keymap));
|
||||
g_return_if_fail (concrete_mods != NULL);
|
||||
|
||||
modmap = egg_keymap_get_modmap (keymap);
|
||||
|
||||
/* Not so sure about this algorithm. */
|
||||
|
||||
concrete = 0;
|
||||
i = 0;
|
||||
while (i < EGG_MODMAP_ENTRY_LAST)
|
||||
{
|
||||
if (modmap->mapping[i] & virtual_mods)
|
||||
concrete |= (1 << i);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
*concrete_mods = concrete;
|
||||
}
|
||||
|
||||
void
|
||||
egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType concrete_mods,
|
||||
EggVirtualModifierType *virtual_mods)
|
||||
{
|
||||
GdkModifierType virtual;
|
||||
int i;
|
||||
const EggModmap *modmap;
|
||||
|
||||
g_return_if_fail (GDK_IS_KEYMAP (keymap));
|
||||
g_return_if_fail (virtual_mods != NULL);
|
||||
|
||||
modmap = egg_keymap_get_modmap (keymap);
|
||||
|
||||
/* Not so sure about this algorithm. */
|
||||
|
||||
virtual = 0;
|
||||
i = 0;
|
||||
while (i < EGG_MODMAP_ENTRY_LAST)
|
||||
{
|
||||
if ((1 << i) & concrete_mods)
|
||||
{
|
||||
EggVirtualModifierType cleaned;
|
||||
|
||||
cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
|
||||
EGG_VIRTUAL_MOD3_MASK |
|
||||
EGG_VIRTUAL_MOD4_MASK |
|
||||
EGG_VIRTUAL_MOD5_MASK);
|
||||
|
||||
if (cleaned != 0)
|
||||
{
|
||||
virtual |= cleaned;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Rather than dropping mod2->mod5 if not bound,
|
||||
* go ahead and use the concrete names
|
||||
*/
|
||||
virtual |= modmap->mapping[i];
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
*virtual_mods = virtual;
|
||||
}
|
||||
|
||||
static void
|
||||
reload_modmap (GdkKeymap *keymap,
|
||||
EggModmap *modmap)
|
||||
{
|
||||
XModifierKeymap *xmodmap;
|
||||
int map_size;
|
||||
int i;
|
||||
|
||||
/* FIXME multihead */
|
||||
xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
|
||||
|
||||
memset (modmap->mapping, 0, sizeof (modmap->mapping));
|
||||
|
||||
/* there are 8 modifiers, and the first 3 are shift, shift lock,
|
||||
* and control
|
||||
*/
|
||||
map_size = 8 * xmodmap->max_keypermod;
|
||||
i = 3 * xmodmap->max_keypermod;
|
||||
while (i < map_size)
|
||||
{
|
||||
/* get the key code at this point in the map,
|
||||
* see if its keysym is one we're interested in
|
||||
*/
|
||||
int keycode = xmodmap->modifiermap[i];
|
||||
GdkKeymapKey *keys;
|
||||
guint *keyvals;
|
||||
int n_entries;
|
||||
int j;
|
||||
EggVirtualModifierType mask;
|
||||
|
||||
keys = NULL;
|
||||
keyvals = NULL;
|
||||
n_entries = 0;
|
||||
|
||||
gdk_keymap_get_entries_for_keycode (keymap,
|
||||
keycode,
|
||||
&keys, &keyvals, &n_entries);
|
||||
|
||||
mask = 0;
|
||||
j = 0;
|
||||
while (j < n_entries)
|
||||
{
|
||||
if (keyvals[j] == GDK_Num_Lock)
|
||||
mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
|
||||
else if (keyvals[j] == GDK_Scroll_Lock)
|
||||
mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
|
||||
else if (keyvals[j] == GDK_Meta_L ||
|
||||
keyvals[j] == GDK_Meta_R)
|
||||
mask |= EGG_VIRTUAL_META_MASK;
|
||||
else if (keyvals[j] == GDK_Hyper_L ||
|
||||
keyvals[j] == GDK_Hyper_R)
|
||||
mask |= EGG_VIRTUAL_HYPER_MASK;
|
||||
else if (keyvals[j] == GDK_Super_L ||
|
||||
keyvals[j] == GDK_Super_R)
|
||||
mask |= EGG_VIRTUAL_SUPER_MASK;
|
||||
else if (keyvals[j] == GDK_Mode_switch)
|
||||
mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
|
||||
|
||||
++j;
|
||||
}
|
||||
|
||||
/* Mod1Mask is 1 << 3 for example, i.e. the
|
||||
* fourth modifier, i / keyspermod is the modifier
|
||||
* index
|
||||
*/
|
||||
modmap->mapping[i/xmodmap->max_keypermod] |= mask;
|
||||
|
||||
g_free (keyvals);
|
||||
g_free (keys);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
/* Add in the not-really-virtual fixed entries */
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
|
||||
modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
|
||||
|
||||
XFreeModifiermap (xmodmap);
|
||||
}
|
||||
|
||||
const EggModmap*
|
||||
egg_keymap_get_modmap (GdkKeymap *keymap)
|
||||
{
|
||||
EggModmap *modmap;
|
||||
|
||||
/* This is all a hack, much simpler when we can just
|
||||
* modify GDK directly.
|
||||
*/
|
||||
|
||||
modmap = g_object_get_data (G_OBJECT (keymap),
|
||||
"egg-modmap");
|
||||
|
||||
if (modmap == NULL)
|
||||
{
|
||||
modmap = g_new0 (EggModmap, 1);
|
||||
|
||||
/* FIXME modify keymap change events with an event filter
|
||||
* and force a reload if we get one
|
||||
*/
|
||||
|
||||
reload_modmap (keymap, modmap);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (keymap),
|
||||
"egg-modmap",
|
||||
modmap,
|
||||
g_free);
|
||||
}
|
||||
|
||||
g_assert (modmap != NULL);
|
||||
|
||||
return modmap;
|
||||
}
|
87
src/eggaccelerators.h
Normal file
87
src/eggaccelerators.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* eggaccelerators.h
|
||||
* Copyright (C) 2002 Red Hat, Inc.
|
||||
* Developed by Havoc Pennington
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __EGG_ACCELERATORS_H__
|
||||
#define __EGG_ACCELERATORS_H__
|
||||
|
||||
#include <gtk/gtkaccelgroup.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Where a value is also in GdkModifierType we coincide,
|
||||
* otherwise we don't overlap.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EGG_VIRTUAL_SHIFT_MASK = 1 << 0,
|
||||
EGG_VIRTUAL_LOCK_MASK = 1 << 1,
|
||||
EGG_VIRTUAL_CONTROL_MASK = 1 << 2,
|
||||
|
||||
EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */
|
||||
|
||||
EGG_VIRTUAL_MOD2_MASK = 1 << 4,
|
||||
EGG_VIRTUAL_MOD3_MASK = 1 << 5,
|
||||
EGG_VIRTUAL_MOD4_MASK = 1 << 6,
|
||||
EGG_VIRTUAL_MOD5_MASK = 1 << 7,
|
||||
|
||||
#if 0
|
||||
GDK_BUTTON1_MASK = 1 << 8,
|
||||
GDK_BUTTON2_MASK = 1 << 9,
|
||||
GDK_BUTTON3_MASK = 1 << 10,
|
||||
GDK_BUTTON4_MASK = 1 << 11,
|
||||
GDK_BUTTON5_MASK = 1 << 12,
|
||||
/* 13, 14 are used by Xkb for the keyboard group */
|
||||
#endif
|
||||
|
||||
EGG_VIRTUAL_META_MASK = 1 << 24,
|
||||
EGG_VIRTUAL_SUPER_MASK = 1 << 25,
|
||||
EGG_VIRTUAL_HYPER_MASK = 1 << 26,
|
||||
EGG_VIRTUAL_MODE_SWITCH_MASK = 1 << 27,
|
||||
EGG_VIRTUAL_NUM_LOCK_MASK = 1 << 28,
|
||||
EGG_VIRTUAL_SCROLL_LOCK_MASK = 1 << 29,
|
||||
|
||||
/* Also in GdkModifierType */
|
||||
EGG_VIRTUAL_RELEASE_MASK = 1 << 30,
|
||||
|
||||
/* 28-31 24-27 20-23 16-19 12-15 8-11 4-7 0-3
|
||||
* 7 f 0 0 0 0 f f
|
||||
*/
|
||||
EGG_VIRTUAL_MODIFIER_MASK = 0x7f0000ff
|
||||
|
||||
} EggVirtualModifierType;
|
||||
|
||||
gboolean egg_accelerator_parse_virtual (const gchar *accelerator,
|
||||
guint *accelerator_key,
|
||||
EggVirtualModifierType *accelerator_mods);
|
||||
void egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
|
||||
EggVirtualModifierType virtual_mods,
|
||||
GdkModifierType *concrete_mods);
|
||||
void egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType concrete_mods,
|
||||
EggVirtualModifierType *virtual_mods);
|
||||
|
||||
gchar* egg_virtual_accelerator_name (guint accelerator_key,
|
||||
EggVirtualModifierType accelerator_mods);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __EGG_ACCELERATORS_H__ */
|
@ -148,6 +148,7 @@ struct _MetaKeyBinding
|
||||
KeySym keysym;
|
||||
unsigned int mask;
|
||||
int keycode;
|
||||
MetaVirtualModifier modifiers;
|
||||
const MetaKeyHandler *handler;
|
||||
};
|
||||
|
||||
@ -298,6 +299,9 @@ reload_modmap (MetaDisplay *display)
|
||||
/* Multiple bits may get set in each of these */
|
||||
display->num_lock_mask = 0;
|
||||
display->scroll_lock_mask = 0;
|
||||
display->meta_mask = 0;
|
||||
display->hyper_mask = 0;
|
||||
display->super_mask = 0;
|
||||
|
||||
/* there are 8 modifiers, and the first 3 are shift, shift lock,
|
||||
* and control
|
||||
@ -344,6 +348,21 @@ reload_modmap (MetaDisplay *display)
|
||||
{
|
||||
display->scroll_lock_mask |= (1 << ( i / modmap->max_keypermod));
|
||||
}
|
||||
else if (syms[j] == XK_Super_L ||
|
||||
syms[j] == XK_Super_R)
|
||||
{
|
||||
display->super_mask |= (1 << ( i / modmap->max_keypermod));
|
||||
}
|
||||
else if (syms[j] == XK_Hyper_L ||
|
||||
syms[j] == XK_Hyper_R)
|
||||
{
|
||||
display->hyper_mask |= (1 << ( i / modmap->max_keypermod));
|
||||
}
|
||||
else if (syms[j] == XK_Meta_L ||
|
||||
syms[j] == XK_Meta_R)
|
||||
{
|
||||
display->meta_mask |= (1 << ( i / modmap->max_keypermod));
|
||||
}
|
||||
|
||||
++j;
|
||||
}
|
||||
@ -357,10 +376,13 @@ reload_modmap (MetaDisplay *display)
|
||||
LockMask);
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Ignoring modmask 0x%x num lock 0x%x scroll lock 0x%x\n",
|
||||
"Ignoring modmask 0x%x num lock 0x%x scroll lock 0x%x hyper 0x%x super 0x%x meta 0x%x\n",
|
||||
display->ignored_modifier_mask,
|
||||
display->num_lock_mask,
|
||||
display->scroll_lock_mask);
|
||||
display->scroll_lock_mask,
|
||||
display->hyper_mask,
|
||||
display->super_mask,
|
||||
display->meta_mask);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -398,6 +420,72 @@ reload_keycodes (MetaDisplay *display)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
devirtualize_modifiers (MetaDisplay *display,
|
||||
MetaVirtualModifier modifiers,
|
||||
unsigned int *mask)
|
||||
{
|
||||
*mask = 0;
|
||||
|
||||
if (modifiers & META_VIRTUAL_SHIFT_MASK)
|
||||
*mask |= ShiftMask;
|
||||
if (modifiers & META_VIRTUAL_CONTROL_MASK)
|
||||
*mask |= ControlMask;
|
||||
if (modifiers & META_VIRTUAL_ALT_MASK)
|
||||
*mask |= Mod1Mask;
|
||||
if (modifiers & META_VIRTUAL_META_MASK)
|
||||
*mask |= display->meta_mask;
|
||||
if (modifiers & META_VIRTUAL_HYPER_MASK)
|
||||
*mask |= display->hyper_mask;
|
||||
if (modifiers & META_VIRTUAL_SUPER_MASK)
|
||||
*mask |= display->super_mask;
|
||||
if (modifiers & META_VIRTUAL_MOD2_MASK)
|
||||
*mask |= Mod2Mask;
|
||||
if (modifiers & META_VIRTUAL_MOD3_MASK)
|
||||
*mask |= Mod3Mask;
|
||||
if (modifiers & META_VIRTUAL_MOD4_MASK)
|
||||
*mask |= Mod4Mask;
|
||||
if (modifiers & META_VIRTUAL_MOD5_MASK)
|
||||
*mask |= Mod5Mask;
|
||||
}
|
||||
|
||||
static void
|
||||
reload_modifiers (MetaDisplay *display)
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Reloading keycodes for binding tables\n");
|
||||
|
||||
if (display->screen_bindings)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (display->screen_bindings[i].keysym != None)
|
||||
{
|
||||
devirtualize_modifiers (display,
|
||||
display->screen_bindings[i].modifiers,
|
||||
&display->screen_bindings[i].mask);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (display->window_bindings)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (display->window_bindings[i].keysym != None)
|
||||
{
|
||||
devirtualize_modifiers (display,
|
||||
display->window_bindings[i].modifiers,
|
||||
&display->window_bindings[i].mask);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rebuild_screen_binding_table (MetaDisplay *display)
|
||||
{
|
||||
@ -420,7 +508,10 @@ rebuild_screen_binding_table (MetaDisplay *display)
|
||||
{
|
||||
display->screen_bindings[dest].name = prefs[src].name;
|
||||
display->screen_bindings[dest].keysym = prefs[src].keysym;
|
||||
display->screen_bindings[dest].mask = prefs[src].mask;
|
||||
display->screen_bindings[dest].modifiers = prefs[src].modifiers;
|
||||
display->screen_bindings[dest].mask = 0;
|
||||
display->screen_bindings[dest].keycode = 0;
|
||||
|
||||
++dest;
|
||||
}
|
||||
|
||||
@ -456,7 +547,10 @@ rebuild_window_binding_table (MetaDisplay *display)
|
||||
{
|
||||
display->window_bindings[dest].name = prefs[src].name;
|
||||
display->window_bindings[dest].keysym = prefs[src].keysym;
|
||||
display->window_bindings[dest].mask = prefs[src].mask;
|
||||
display->window_bindings[dest].modifiers = prefs[src].modifiers;
|
||||
display->window_bindings[dest].mask = 0;
|
||||
display->window_bindings[dest].keycode = 0;
|
||||
|
||||
++dest;
|
||||
}
|
||||
|
||||
@ -509,6 +603,28 @@ regrab_window_bindings (MetaDisplay *display)
|
||||
g_slist_free (windows);
|
||||
}
|
||||
|
||||
static MetaKeyBindingAction
|
||||
display_get_keybinding_action (MetaDisplay *display,
|
||||
unsigned int keysym,
|
||||
unsigned long mask)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = display->n_screen_bindings - 1;
|
||||
while (i >= 0)
|
||||
{
|
||||
if (display->screen_bindings[i].keysym == keysym &&
|
||||
display->screen_bindings[i].mask == mask)
|
||||
{
|
||||
return meta_prefs_get_keybinding_action (display->screen_bindings[i].name);
|
||||
}
|
||||
|
||||
--i;
|
||||
}
|
||||
|
||||
return META_KEYBINDING_ACTION_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_process_mapping_event (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
@ -519,6 +635,8 @@ meta_display_process_mapping_event (MetaDisplay *display,
|
||||
"Received MappingModifier event, will reload modmap and redo keybindings\n");
|
||||
|
||||
reload_modmap (display);
|
||||
|
||||
reload_modifiers (display);
|
||||
|
||||
regrab_screen_bindings (display);
|
||||
regrab_window_bindings (display);
|
||||
@ -551,11 +669,13 @@ bindings_changed_callback (MetaPreference pref,
|
||||
case META_PREF_SCREEN_KEYBINDINGS:
|
||||
rebuild_screen_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);
|
||||
break;
|
||||
default:
|
||||
@ -576,6 +696,9 @@ meta_display_init_keys (MetaDisplay *display)
|
||||
display->ignored_modifier_mask = 0;
|
||||
display->num_lock_mask = 0;
|
||||
display->scroll_lock_mask = 0;
|
||||
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;
|
||||
@ -597,7 +720,8 @@ meta_display_init_keys (MetaDisplay *display)
|
||||
rebuild_screen_binding_table (display);
|
||||
|
||||
reload_keycodes (display);
|
||||
|
||||
reload_modifiers (display);
|
||||
|
||||
/* Keys are actually grabbed in meta_screen_grab_keys() */
|
||||
|
||||
meta_prefs_add_listener (bindings_changed_callback, display);
|
||||
@ -1785,8 +1909,9 @@ process_tab_grab (MetaDisplay *display,
|
||||
if (is_modifier (display, event->xkey.keycode))
|
||||
return TRUE;
|
||||
|
||||
action = meta_prefs_get_keybinding_action (keysym,
|
||||
display->grab_mask);
|
||||
action = display_get_keybinding_action (display,
|
||||
keysym,
|
||||
display->grab_mask);
|
||||
|
||||
/* FIXME weird side effect here is that you can use the Escape
|
||||
* key while tabbing, or the tab key while escaping
|
||||
@ -2059,8 +2184,9 @@ process_workspace_switch_grab (MetaDisplay *display,
|
||||
MetaWorkspace *target_workspace;
|
||||
MetaKeyBindingAction action;
|
||||
|
||||
action = meta_prefs_get_keybinding_action (keysym,
|
||||
display->grab_mask);
|
||||
action = display_get_keybinding_action (display,
|
||||
keysym,
|
||||
display->grab_mask);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
|
23
src/prefs.c
23
src/prefs.c
@ -831,6 +831,7 @@ meta_prefs_set_num_workspaces (int n_workspaces)
|
||||
}
|
||||
}
|
||||
|
||||
/* Indexes must correspond to MetaKeybindingAction */
|
||||
static MetaKeyPref screen_bindings[] = {
|
||||
{ META_KEYBINDING_WORKSPACE_1, 0, 0 },
|
||||
{ META_KEYBINDING_WORKSPACE_2, 0, 0 },
|
||||
@ -979,7 +980,7 @@ update_binding (MetaKeyPref *binding,
|
||||
const char *value)
|
||||
{
|
||||
unsigned int keysym;
|
||||
unsigned long mask;
|
||||
MetaVirtualModifier mods;
|
||||
gboolean changed;
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
@ -987,10 +988,10 @@ update_binding (MetaKeyPref *binding,
|
||||
binding->name, value ? value : "none");
|
||||
|
||||
keysym = 0;
|
||||
mask = 0;
|
||||
mods = 0;
|
||||
if (value)
|
||||
{
|
||||
if (!meta_ui_parse_accelerator (value, &keysym, &mask))
|
||||
if (!meta_ui_parse_accelerator (value, &keysym, &mods))
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Failed to parse new gconf value\n");
|
||||
@ -1001,16 +1002,16 @@ update_binding (MetaKeyPref *binding,
|
||||
|
||||
changed = FALSE;
|
||||
if (keysym != binding->keysym ||
|
||||
mask != binding->mask)
|
||||
mods != binding->modifiers)
|
||||
{
|
||||
changed = TRUE;
|
||||
|
||||
binding->keysym = keysym;
|
||||
binding->mask = mask;
|
||||
binding->modifiers = mods;
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"New keybinding for \"%s\" is keysym = 0x%x mask = 0x%lx\n",
|
||||
binding->name, binding->keysym, binding->mask);
|
||||
"New keybinding for \"%s\" is keysym = 0x%x mods = 0x%x\n",
|
||||
binding->name, binding->keysym, binding->modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1166,16 +1167,14 @@ meta_prefs_get_auto_raise_delay ()
|
||||
}
|
||||
|
||||
MetaKeyBindingAction
|
||||
meta_prefs_get_keybinding_action (unsigned int keysym,
|
||||
unsigned long mask)
|
||||
meta_prefs_get_keybinding_action (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = G_N_ELEMENTS (screen_bindings) - 1;
|
||||
i = G_N_ELEMENTS (screen_bindings) - 2; /* -2 for dummy entry at end */
|
||||
while (i >= 0)
|
||||
{
|
||||
if (screen_bindings[i].keysym == keysym &&
|
||||
screen_bindings[i].mask == mask)
|
||||
if (strcmp (screen_bindings[i].name, name) == 0)
|
||||
return (MetaKeyBindingAction) i;
|
||||
|
||||
--i;
|
||||
|
@ -173,7 +173,7 @@ typedef struct
|
||||
{
|
||||
const char *name;
|
||||
unsigned int keysym;
|
||||
unsigned long mask;
|
||||
MetaVirtualModifier modifiers;
|
||||
} MetaKeyPref;
|
||||
|
||||
void meta_prefs_get_screen_bindings (const MetaKeyPref **bindings,
|
||||
@ -181,8 +181,7 @@ void meta_prefs_get_screen_bindings (const MetaKeyPref **bindings,
|
||||
void meta_prefs_get_window_bindings (const MetaKeyPref **bindings,
|
||||
int *n_bindings);
|
||||
|
||||
MetaKeyBindingAction meta_prefs_get_keybinding_action (unsigned int keysym,
|
||||
unsigned long mask);
|
||||
MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name);
|
||||
|
||||
#endif
|
||||
|
||||
|
53
src/ui.c
53
src/ui.c
@ -27,6 +27,8 @@
|
||||
#include "core.h"
|
||||
#include "theme.h"
|
||||
|
||||
#include "eggaccelerators.h"
|
||||
|
||||
#include "inlinepixbufs.h"
|
||||
|
||||
#include <pango/pangox.h>
|
||||
@ -613,11 +615,11 @@ meta_ui_have_a_theme (void)
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_ui_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
unsigned long *mask)
|
||||
meta_ui_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
MetaVirtualModifier *mask)
|
||||
{
|
||||
GdkModifierType gdk_mask = 0;
|
||||
EggVirtualModifierType gdk_mask = 0;
|
||||
guint gdk_sym = 0;
|
||||
|
||||
*keysym = 0;
|
||||
@ -626,32 +628,37 @@ meta_ui_parse_accelerator (const char *accel,
|
||||
if (strcmp (accel, "disabled") == 0)
|
||||
return TRUE;
|
||||
|
||||
gtk_accelerator_parse (accel, &gdk_sym, &gdk_mask);
|
||||
if (!egg_accelerator_parse_virtual (accel, &gdk_sym, &gdk_mask))
|
||||
return FALSE;
|
||||
|
||||
if (gdk_sym == None)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_mask & GDK_RELEASE_MASK) /* we don't allow this */
|
||||
if (gdk_mask & EGG_VIRTUAL_RELEASE_MASK) /* we don't allow this */
|
||||
return FALSE;
|
||||
|
||||
*keysym = gdk_sym;
|
||||
|
||||
if (gdk_mask & GDK_SHIFT_MASK)
|
||||
*mask |= ShiftMask;
|
||||
if (gdk_mask & GDK_LOCK_MASK)
|
||||
*mask |= LockMask;
|
||||
if (gdk_mask & GDK_CONTROL_MASK)
|
||||
*mask |= ControlMask;
|
||||
if (gdk_mask & GDK_MOD1_MASK)
|
||||
*mask |= Mod1Mask;
|
||||
if (gdk_mask & GDK_MOD2_MASK)
|
||||
*mask |= Mod2Mask;
|
||||
if (gdk_mask & GDK_MOD3_MASK)
|
||||
*mask |= Mod3Mask;
|
||||
if (gdk_mask & GDK_MOD4_MASK)
|
||||
*mask |= Mod4Mask;
|
||||
if (gdk_mask & GDK_MOD5_MASK)
|
||||
*mask |= Mod5Mask;
|
||||
|
||||
if (gdk_mask & EGG_VIRTUAL_SHIFT_MASK)
|
||||
*mask |= META_VIRTUAL_SHIFT_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_CONTROL_MASK)
|
||||
*mask |= META_VIRTUAL_CONTROL_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_ALT_MASK)
|
||||
*mask |= META_VIRTUAL_ALT_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_MOD2_MASK)
|
||||
*mask |= META_VIRTUAL_MOD2_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_MOD3_MASK)
|
||||
*mask |= META_VIRTUAL_MOD3_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_MOD4_MASK)
|
||||
*mask |= META_VIRTUAL_MOD4_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_MOD5_MASK)
|
||||
*mask |= META_VIRTUAL_MOD5_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_SUPER_MASK)
|
||||
*mask |= META_VIRTUAL_SUPER_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_HYPER_MASK)
|
||||
*mask |= META_VIRTUAL_HYPER_MASK;
|
||||
if (gdk_mask & EGG_VIRTUAL_META_MASK)
|
||||
*mask |= META_VIRTUAL_META_MASK;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
6
src/ui.h
6
src/ui.h
@ -153,9 +153,9 @@ void meta_ui_set_current_theme (const char *name,
|
||||
gboolean force_reload);
|
||||
gboolean meta_ui_have_a_theme (void);
|
||||
|
||||
gboolean meta_ui_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
unsigned long *mask);
|
||||
gboolean meta_ui_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
MetaVirtualModifier *mask);
|
||||
|
||||
#include "tabpopup.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user