Mercurial > audlegacy-plugins
annotate src/hotkey/grab.c @ 2512:1f6b5f5768e2
Remove some completely useless null-pointer checks, g_free() checks the pointer anyway.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 22:58:35 +0300 |
parents | b2a2ca9fceda |
children | c1258ae018ee |
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 { |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
194 Display* xdisplay; |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
195 int screen; |
2330
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; |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
198 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
199 XErrorHandler old_handler = 0; |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
200 xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); |
2330
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 if (grabbed) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
203 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
204 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
205 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
206 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
|
207 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
212 for (screen=0;screen<ScreenCount(xdisplay);screen++) |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
213 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
214 grab_key(hotkey, xdisplay, RootWindow(xdisplay, screen)); |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
215 } |
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
|
216 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
|
217 } |
2330
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 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
220 XSetErrorHandler (old_handler); |
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 grabbed = 1; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
223 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
224 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
225 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
226 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
227 /* 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
|
228 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
|
229 { |
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
|
230 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
|
231 |
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
|
232 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
|
233 |
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
|
234 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
|
235 { |
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
|
236 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
|
237 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
238 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
239 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
240 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
241 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
|
242 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
|
243 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
244 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
|
245 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
|
246 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
247 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
|
248 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
|
249 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
250 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
|
251 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
|
252 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
253 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
|
254 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
|
255 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
256 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
|
257 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
|
258 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
259 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
|
260 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
|
261 } |
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
|
262 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
|
263 { |
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
|
264 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
|
265 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
266 if (modifier == AnyModifier) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
267 return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
268 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
269 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
|
270 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
|
271 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
272 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
|
273 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
|
274 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
275 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
|
276 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
|
277 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
278 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
|
279 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
|
280 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
281 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
|
282 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
|
283 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
284 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
|
285 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
|
286 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
287 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
|
288 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
|
289 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
290 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
291 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
292 void ungrab_keys ( ) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
293 { |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
294 Display* xdisplay; |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
295 int screen; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
296 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
|
297 HotkeyConfiguration *hotkey; |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
298 |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
299 XErrorHandler old_handler = 0; |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
300 xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
301 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
302 if (!grabbed) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
303 if (!xdisplay) return; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
304 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
305 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
306 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
|
307 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
308 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
|
309 |
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
|
310 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
|
311 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
|
312 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
313 for (screen=0;screen<ScreenCount(xdisplay);screen++) |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
314 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
315 ungrab_key(hotkey, xdisplay, RootWindow(xdisplay, screen)); |
2338
a9f52daf13ba
Grab keys on all screens, not only the default one. Should fix #119.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2336
diff
changeset
|
316 } |
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
|
317 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
|
318 } |
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
|
319 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
320 XSync(xdisplay, False); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
321 XSetErrorHandler (old_handler); |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
322 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
323 grabbed = 0; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
324 } |
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 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
327 static GdkFilterReturn |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
328 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
|
329 GdkEvent *event, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
330 gpointer data) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
331 { |
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
|
332 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
|
333 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
|
334 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
|
335 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
336 case KeyPress: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
337 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
338 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
|
339 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
|
340 { |
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 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
|
342 (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
|
343 (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
|
344 { |
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
|
345 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
|
346 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
|
347 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
|
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 |
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 = 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
|
351 } |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
352 break; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
353 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
354 case ButtonPress: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
355 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
356 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
|
357 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
|
358 { |
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 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
|
360 (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
|
361 (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
|
362 { |
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
|
363 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
|
364 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
|
365 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
|
366 } |
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
|
367 |
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
|
368 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
|
369 } |
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
|
370 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
371 break; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
372 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
373 default: |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
374 return -1; |
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 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
377 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
|
378 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
379 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
380 gboolean setup_filter() |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
381 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
382 GdkDisplay *display; |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
383 int screen; |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
384 |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
385 display = gdk_display_get_default(); |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
386 |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
387 for (screen = 0; screen<gdk_display_get_n_screens(display); screen++) |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
388 { |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
389 gdk_window_add_filter(gdk_screen_get_root_window(gdk_display_get_screen(display, screen)), |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
390 gdk_filter, |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
391 NULL); |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
392 } |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
393 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
394 return TRUE; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
395 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
396 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
397 void release_filter() |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
398 { |
2339
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
399 GdkDisplay *display; |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
400 int screen; |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
401 |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
402 display = gdk_display_get_default(); |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
403 |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
404 for (screen = 0; screen<gdk_display_get_n_screens(display); screen++) |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
405 { |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
406 gdk_window_remove_filter(gdk_screen_get_root_window(gdk_display_get_screen(display, screen)), |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
407 gdk_filter, |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
408 NULL); |
b2a2ca9fceda
Hotkey: Setup event filter on all screens as well to grab all key events. Should fix bug #119 now.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2338
diff
changeset
|
409 } |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
410 } |