grab keys on all the screens for the current display
2003-07-03 Bastien Nocera <hadess@hadess.net> * gnome-settings-keybindings.c: (get_screens_list), (screen_exec_display_string), (grab_key), (do_grab), (gnome_settings_keybindings_load): grab keys on all the screens for the current display
This commit is contained in:
parent
73930e8c2a
commit
6b1e429fcd
2 changed files with 56 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2003-07-03 Bastien Nocera <hadess@hadess.net>
|
||||||
|
|
||||||
|
* gnome-settings-keybindings.c: (get_screens_list),
|
||||||
|
(screen_exec_display_string), (grab_key), (do_grab),
|
||||||
|
(gnome_settings_keybindings_load): grab keys on all the screens for the
|
||||||
|
current display
|
||||||
|
|
||||||
Thu Jun 26 07:37:20 2003 Jonathan Blandford <jrb@gnome.org>
|
Thu Jun 26 07:37:20 2003 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
* gnome-settings-typing-break.c: new module to handle the
|
* gnome-settings-typing-break.c: new module to handle the
|
||||||
|
|
|
@ -35,6 +35,30 @@ typedef struct {
|
||||||
} Binding;
|
} Binding;
|
||||||
|
|
||||||
static GSList *binding_list = NULL;
|
static GSList *binding_list = NULL;
|
||||||
|
static GSList *screens = NULL;
|
||||||
|
|
||||||
|
static GSList *
|
||||||
|
get_screens_list (void)
|
||||||
|
{
|
||||||
|
GdkDisplay *display = gdk_display_get_default();
|
||||||
|
GSList *list = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (gdk_display_get_n_screens (display) == 1) {
|
||||||
|
list = g_slist_append (list, gdk_screen_get_default ());
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < gdk_display_get_n_screens (display); i++) {
|
||||||
|
GdkScreen *screen;
|
||||||
|
|
||||||
|
screen = gdk_display_get_screen (display, i);
|
||||||
|
if (screen != NULL) {
|
||||||
|
list = g_slist_append (list, screen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
screen_exec_display_string (XEvent *xevent)
|
screen_exec_display_string (XEvent *xevent)
|
||||||
|
@ -44,8 +68,6 @@ screen_exec_display_string (XEvent *xevent)
|
||||||
char *retval;
|
char *retval;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
#ifdef HAVE_GTK_MULTIHEAD
|
|
||||||
|
|
||||||
GdkScreen *screen = NULL;
|
GdkScreen *screen = NULL;
|
||||||
|
|
||||||
GdkWindow *window = gdk_xid_table_lookup (xevent->xkey.root);
|
GdkWindow *window = gdk_xid_table_lookup (xevent->xkey.root);
|
||||||
|
@ -71,9 +93,6 @@ screen_exec_display_string (XEvent *xevent)
|
||||||
g_string_free (str, FALSE);
|
g_string_free (str, FALSE);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return g_strdup ("DISPLAY=:0.0");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -214,6 +233,23 @@ key_already_used (Binding *binding)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grab_key (GdkWindow *root, Key *key, int result, gboolean grab)
|
||||||
|
{
|
||||||
|
gdk_error_trap_push ();
|
||||||
|
if (grab)
|
||||||
|
XGrabKey (GDK_DISPLAY(), key->keycode, (result | key->state),
|
||||||
|
GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
else
|
||||||
|
XUngrabKey(GDK_DISPLAY(), key->keycode, (result | key->state),
|
||||||
|
GDK_WINDOW_XID (root));
|
||||||
|
gdk_flush ();
|
||||||
|
if (gdk_error_trap_pop ()) {
|
||||||
|
g_warning (_("It seems that another application already has"
|
||||||
|
" access to key '%d'."), key->keycode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* inspired from all_combinations from gnome-panel/gnome-panel/global-keys.c */
|
/* inspired from all_combinations from gnome-panel/gnome-panel/global-keys.c */
|
||||||
#define N_BITS 32
|
#define N_BITS 32
|
||||||
static void
|
static void
|
||||||
|
@ -235,19 +271,19 @@ do_grab (gboolean grab,
|
||||||
|
|
||||||
uppervalue = 1<<bits_set_cnt;
|
uppervalue = 1<<bits_set_cnt;
|
||||||
for (i = 0; i < uppervalue; i++) {
|
for (i = 0; i < uppervalue; i++) {
|
||||||
|
GSList *l;
|
||||||
int j, result = 0;
|
int j, result = 0;
|
||||||
|
|
||||||
for (j = 0; j < bits_set_cnt; j++) {
|
for (j = 0; j < bits_set_cnt; j++) {
|
||||||
if (i & (1<<j))
|
if (i & (1<<j))
|
||||||
result |= (1<<indexes[j]);
|
result |= (1<<indexes[j]);
|
||||||
}
|
}
|
||||||
/* FIXME need to grab for all root windows for the display */
|
|
||||||
if (grab)
|
for (l = screens; l ; l = l->next) {
|
||||||
XGrabKey (GDK_DISPLAY(), key->keycode, (result | key->state),
|
GdkScreen *screen = l->data;
|
||||||
GDK_ROOT_WINDOW(), True, GrabModeAsync, GrabModeAsync);
|
grab_key (gdk_screen_get_root_window (screen), key, result,
|
||||||
else
|
grab);
|
||||||
XUngrabKey(GDK_DISPLAY(), key->keycode, (result | key->state),
|
}
|
||||||
GDK_ROOT_WINDOW());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,6 +421,7 @@ gnome_settings_keybindings_load (GConfClient *client)
|
||||||
GSList *list, *li;
|
GSList *list, *li;
|
||||||
|
|
||||||
list = gconf_client_all_dirs (client, GCONF_BINDING_DIR, NULL);
|
list = gconf_client_all_dirs (client, GCONF_BINDING_DIR, NULL);
|
||||||
|
screens = get_screens_list ();
|
||||||
|
|
||||||
for (li = list; li != NULL; li = li->next)
|
for (li = list; li != NULL; li = li->next)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue