Mercurial > audlegacy-plugins
annotate src/hotkey/grab.c @ 2336:ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
author | Sascha Hlusiak <contact@saschahlusiak.de> |
---|---|
date | Wed, 23 Jan 2008 19:37:05 +0100 |
parents | 0be42d832217 |
children | a9f52daf13ba |
rev | line source |
---|---|
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
1 /* |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
2 * This file is part of audacious-hotkey plugin for audacious |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
3 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
4 * Copyright (c) 2007 - 2008 Sascha Hlusiak <contact@saschahlusiak.de> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
5 * Name: grab.c |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
6 * Description: grab.c |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
7 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
8 * Part of this code is from itouch-ctrl plugin. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
9 * Authors of itouch-ctrl are listed below: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
10 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
11 * Copyright (c) 2006 - 2007 Vladimir Paskov <vlado.paskov@gmail.com> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
12 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
13 * Part of this code are from xmms-itouch plugin. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
14 * Authors of xmms-itouch are listed below: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
15 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
16 * Copyright (C) 2000-2002 Ville Syrjälä <syrjala@sci.fi> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
17 * Bryn Davies <curious@ihug.com.au> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
18 * Jonathan A. Davis <davis@jdhouse.org> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
19 * Jeremy Tan <nsx@nsx.homeip.net> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
20 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
21 * audacious-hotkey is free software; you can redistribute it and/or modify |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
22 * it under the terms of the GNU General Public License as published by |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
23 * the Free Software Foundation; either version 2 of the License, or |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
24 * (at your option) any later version. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
25 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
26 * audacious-hotkey is distributed in the hope that it will be useful, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
29 * GNU General Public License for more details. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
30 * |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
31 * You should have received a copy of the GNU General Public License |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
32 * along with audacious-hotkey; if not, write to the Free Software |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
34 */ |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
35 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
36 #include <config.h> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
37 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
38 #include <gtk/gtk.h> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
39 #include <gdk/gdkx.h> |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
40 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
41 #include "grab.h" |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
42 #include "plugin.h" |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
43 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
44 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
45 static gint grabbed = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
46 static unsigned int numlock_mask = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
47 static unsigned int scrolllock_mask = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
48 static unsigned int capslock_mask = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
49 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
50 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
51 /* Taken from xbindkeys */ |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
52 static void get_offending_modifiers (Display * dpy) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
53 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
54 int i; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
55 XModifierKeymap *modmap; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
56 KeyCode nlock, slock; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
57 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
58 static int mask_table[8] = { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
59 ShiftMask, LockMask, ControlMask, Mod1Mask, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
60 Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
61 }; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
62 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
63 nlock = XKeysymToKeycode (dpy, XK_Num_Lock); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
64 slock = XKeysymToKeycode (dpy, XK_Scroll_Lock); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
65 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
66 /* |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
67 * Find out the masks for the NumLock and ScrollLock modifiers, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
68 * so that we can bind the grabs for when they are enabled too. |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
69 */ |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
70 modmap = XGetModifierMapping (dpy); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
71 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
72 if (modmap != NULL && modmap->max_keypermod > 0) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
73 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
74 for (i = 0; i < 8 * modmap->max_keypermod; i++) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
75 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
76 if (modmap->modifiermap[i] == nlock && nlock != 0) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
77 numlock_mask = mask_table[i / modmap->max_keypermod]; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
78 else if (modmap->modifiermap[i] == slock && slock != 0) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
79 scrolllock_mask = mask_table[i / modmap->max_keypermod]; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
80 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
81 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
82 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
83 capslock_mask = LockMask; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
84 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
85 if (modmap) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
86 XFreeModifiermap (modmap); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
87 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
88 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
89 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
90 static int x11_error_handler (Display *dpy, XErrorEvent *error) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
91 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
92 return 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
93 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
94 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
95 /* grab required keys */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
96 static void grab_key(const HotkeyConfiguration *hotkey, Display *xdisplay, Window x_root_window) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
97 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
98 unsigned int modifier = hotkey->mask & ~(numlock_mask | capslock_mask | scrolllock_mask); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
99 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
100 if (hotkey->key == 0) return; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
101 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
102 if (hotkey->type == TYPE_KEY) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
103 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
104 XGrabKey (xdisplay, hotkey->key, modifier, x_root_window, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
105 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
106 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
107 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
108 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
109 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
110 if (numlock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
111 XGrabKey (xdisplay, hotkey->key, modifier | numlock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
112 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
113 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
114 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
115 if (capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
116 XGrabKey (xdisplay, hotkey->key, modifier | capslock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
117 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
118 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
119 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
120 if (scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
121 XGrabKey (xdisplay, hotkey->key, modifier | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
122 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
123 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
124 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
125 if (numlock_mask && capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
126 XGrabKey (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
127 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
128 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
129 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
130 if (numlock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
131 XGrabKey (xdisplay, hotkey->key, modifier | numlock_mask | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
132 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
133 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
134 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
135 if (capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
136 XGrabKey (xdisplay, hotkey->key, modifier | capslock_mask | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
137 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
138 False, GrabModeAsync, GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
139 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
140 if (numlock_mask && capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
141 XGrabKey (xdisplay, hotkey->key, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
142 modifier | numlock_mask | capslock_mask | scrolllock_mask, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
143 x_root_window, False, GrabModeAsync, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
144 GrabModeAsync); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
145 } |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
146 if (hotkey->type == TYPE_MOUSE) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
147 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
148 XGrabButton (xdisplay, hotkey->key, modifier, x_root_window, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
149 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
150 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
151 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
152 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
153 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
154 if (numlock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
155 XGrabButton (xdisplay, hotkey->key, modifier | numlock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
156 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
157 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
158 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
159 if (capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
160 XGrabButton (xdisplay, hotkey->key, modifier | capslock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
161 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
162 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
163 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
164 if (scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
165 XGrabButton (xdisplay, hotkey->key, modifier | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
166 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
167 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
168 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
169 if (numlock_mask && capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
170 XGrabButton (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
171 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
172 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
173 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
174 if (numlock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
175 XGrabButton (xdisplay, hotkey->key, modifier | numlock_mask | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
176 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
177 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
178 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
179 if (capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
180 XGrabButton (xdisplay, hotkey->key, modifier | capslock_mask | scrolllock_mask, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
181 x_root_window, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
182 False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
183 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
184 if (numlock_mask && capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
185 XGrabButton (xdisplay, hotkey->key, |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
186 modifier | numlock_mask | capslock_mask | scrolllock_mask, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
187 x_root_window, False, ButtonPressMask, GrabModeAsync, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
188 GrabModeAsync, None, None); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
189 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
190 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
191 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
192 void grab_keys ( ) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
193 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
194 Display* xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
195 Window x_root_window = GDK_WINDOW_XID(gdk_get_default_root_window()); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
196 PluginConfig* plugin_cfg = get_config(); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
197 HotkeyConfiguration *hotkey; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
198 XErrorHandler old_handler = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
199 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
200 if (grabbed) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
201 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
202 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
203 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
204 old_handler = XSetErrorHandler (x11_error_handler); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
205 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
206 get_offending_modifiers(xdisplay); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
207 hotkey = &(plugin_cfg->first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
208 while (hotkey) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
209 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
210 grab_key(hotkey, xdisplay, x_root_window); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
211 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
212 } |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
213 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
214 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
215 XSetErrorHandler (old_handler); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
216 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
217 grabbed = 1; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
218 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
219 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
220 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
221 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
222 /* grab required keys */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
223 static void ungrab_key(HotkeyConfiguration *hotkey, Display* xdisplay, Window x_root_window) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
224 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
225 unsigned int modifier = hotkey->mask & ~(numlock_mask | capslock_mask | scrolllock_mask); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
226 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
227 if (hotkey->key == 0) return; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
228 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
229 if (hotkey->type == TYPE_KEY) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
230 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
231 XUngrabKey (xdisplay, hotkey->key, modifier, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
232 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
233 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
234 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
235 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
236 if (numlock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
237 XUngrabKey (xdisplay, hotkey->key, modifier | numlock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
238 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
239 if (capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
240 XUngrabKey (xdisplay, hotkey->key, modifier | capslock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
241 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
242 if (scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
243 XUngrabKey (xdisplay, hotkey->key, modifier | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
244 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
245 if (numlock_mask && capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
246 XUngrabKey (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
247 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
248 if (numlock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
249 XUngrabKey (xdisplay, hotkey->key, modifier | numlock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
250 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
251 if (capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
252 XUngrabKey (xdisplay, hotkey->key, modifier | capslock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
253 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
254 if (numlock_mask && capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
255 XUngrabKey (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
256 } |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
257 if (hotkey->type == TYPE_MOUSE) |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
258 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
259 XUngrabButton (xdisplay, hotkey->key, modifier, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
260 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
261 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
262 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
263 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
264 if (numlock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
265 XUngrabButton (xdisplay, hotkey->key, modifier | numlock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
266 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
267 if (capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
268 XUngrabButton (xdisplay, hotkey->key, modifier | capslock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
269 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
270 if (scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
271 XUngrabButton (xdisplay, hotkey->key, modifier | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
272 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
273 if (numlock_mask && capslock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
274 XUngrabButton (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
275 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
276 if (numlock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
277 XUngrabButton (xdisplay, hotkey->key, modifier | numlock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
278 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
279 if (capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
280 XUngrabButton (xdisplay, hotkey->key, modifier | capslock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
281 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
282 if (numlock_mask && capslock_mask && scrolllock_mask) |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
283 XUngrabButton (xdisplay, hotkey->key, modifier | numlock_mask | capslock_mask | scrolllock_mask, x_root_window); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
284 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
285 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
286 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
287 void ungrab_keys ( ) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
288 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
289 XErrorHandler old_handler = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
290 Display* xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
291 Window x_root_window = GDK_WINDOW_XID(gdk_get_default_root_window()); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
292 PluginConfig* plugin_cfg = get_config(); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
293 HotkeyConfiguration *hotkey; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
294 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
295 if (!grabbed) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
296 if (!xdisplay) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
297 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
298 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
299 old_handler = XSetErrorHandler (x11_error_handler); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
300 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
301 get_offending_modifiers(xdisplay); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
302 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
303 hotkey = &(plugin_cfg->first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
304 while (hotkey) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
305 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
306 ungrab_key(hotkey, xdisplay, x_root_window); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
307 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
308 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
309 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
310 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
311 XSetErrorHandler (old_handler); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
312 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
313 grabbed = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
314 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
315 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
316 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
317 static GdkFilterReturn |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
318 gdk_filter(GdkXEvent *xevent, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
319 GdkEvent *event, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
320 gpointer data) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
321 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
322 HotkeyConfiguration *hotkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
323 hotkey = &(get_config()->first); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
324 switch (((XEvent*)xevent)->type) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
325 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
326 case KeyPress: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
327 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
328 XKeyEvent *keyevent = (XKeyEvent*)xevent; |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
329 while (hotkey) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
330 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
331 if ((hotkey->key == keyevent->keycode) && |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
332 (hotkey->mask == (keyevent->state & ~(scrolllock_mask | numlock_mask | capslock_mask))) && |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
333 (hotkey->type == TYPE_KEY)) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
334 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
335 if (handle_keyevent(hotkey->event)) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
336 return GDK_FILTER_REMOVE; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
337 break; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
338 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
339 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
340 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
341 } |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
342 break; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
343 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
344 case ButtonPress: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
345 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
346 XButtonEvent *buttonevent = (XButtonEvent*)xevent; |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
347 while (hotkey) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
348 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
349 if ((hotkey->key == buttonevent->button) && |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
350 (hotkey->mask == (buttonevent->state & ~(scrolllock_mask | numlock_mask | capslock_mask))) && |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
351 (hotkey->type == TYPE_MOUSE)) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
352 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
353 if (handle_keyevent(hotkey->event)) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
354 return GDK_FILTER_REMOVE; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
355 break; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
356 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
357 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
358 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
359 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
360 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
361 break; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
362 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
363 default: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
364 return -1; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
365 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
366 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
367 return GDK_FILTER_CONTINUE; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
368 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
369 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
370 gboolean setup_filter() |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
371 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
372 gdk_window_add_filter(gdk_get_default_root_window(), |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
373 gdk_filter, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
374 NULL); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
375 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
376 return TRUE; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
377 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
378 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
379 void release_filter() |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
380 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
381 gdk_window_remove_filter(gdk_get_default_root_window(), |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
382 gdk_filter, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
383 NULL); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
384 } |