globalhotkeys 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/ChangeLog +5 -0
- data/extconf.rb +3 -0
- data/globalhotkeys.c +36 -1
- data/lib/globalhotkeys.rb +1 -1
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
data/extconf.rb
CHANGED
@@ -34,6 +34,9 @@ $CFLAGS+=gtk_cflags
|
|
34
34
|
find_library('X11', 'XKeysymToKeycode') or exit 1
|
35
35
|
find_library('gobject-2.0', 'g_type_init') or exit 1
|
36
36
|
find_library('gdk-x11-2.0', '') or exit 1
|
37
|
+
find_header('string.h') or exit 1
|
38
|
+
find_header('X11/X.h') or exit 1
|
39
|
+
find_header('X11/Xlib.h') or exit 1
|
37
40
|
find_header('gdk/gdkwindow.h') or exit 1
|
38
41
|
find_header('gdk/gdkevents.h') or exit 1
|
39
42
|
find_header('gdk/gdkx.h') or exit 1
|
data/globalhotkeys.c
CHANGED
@@ -19,7 +19,10 @@ This file is part of rghk.
|
|
19
19
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
20
|
*/
|
21
21
|
|
22
|
+
#include <string.h>
|
22
23
|
#include <ruby.h>
|
24
|
+
#include <X11/Xlib.h>
|
25
|
+
#include <X11/X.h>
|
23
26
|
#include <gdk/gdkkeysyms.h>
|
24
27
|
#include <gdk/gdkwindow.h>
|
25
28
|
#include <gdk/gdkx.h>
|
@@ -43,10 +46,12 @@ enum Modifier
|
|
43
46
|
};
|
44
47
|
|
45
48
|
GdkWindow * root_window;
|
49
|
+
char xlib_error[256];
|
46
50
|
VALUE mGlobalHotKeys;
|
47
51
|
VALUE eInitFailed;
|
48
52
|
VALUE eInvalidKeyVal;
|
49
53
|
VALUE eBinded;
|
54
|
+
VALUE eXlibError;
|
50
55
|
VALUE mKeyVal;
|
51
56
|
VALUE mModifier;
|
52
57
|
VALUE cKeyBinder;
|
@@ -66,6 +71,28 @@ keyval_from_name(VALUE self, VALUE name)
|
|
66
71
|
return INT2FIX(keyval);
|
67
72
|
}
|
68
73
|
|
74
|
+
int
|
75
|
+
xlib_error_handler(Display *display, XErrorEvent *error)
|
76
|
+
{
|
77
|
+
//FIXME : cannot ungrab possible grabbed key in incriminate call of kb_bind_common function : this function should not generate internal X protocol requests
|
78
|
+
char buff[256];
|
79
|
+
|
80
|
+
if (error->error_code==BadAccess)
|
81
|
+
{
|
82
|
+
strcpy(xlib_error, "Xlib BadAccess error (key must be grabbed by another programm)");
|
83
|
+
}
|
84
|
+
else
|
85
|
+
{
|
86
|
+
if (strcmp(xlib_error, "")==0)
|
87
|
+
{
|
88
|
+
XGetErrorText(GDK_WINDOW_XDISPLAY(root_window), error->error_code,
|
89
|
+
buff, sizeof(buff));
|
90
|
+
strcpy(xlib_error, buff);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return 0;
|
94
|
+
}
|
95
|
+
|
69
96
|
void
|
70
97
|
kb_bind_common(VALUE self, VALUE key, VALUE modifier, VALUE block)
|
71
98
|
{
|
@@ -76,6 +103,7 @@ kb_bind_common(VALUE self, VALUE key, VALUE modifier, VALUE block)
|
|
76
103
|
RGHK_LOCK_MASK|RGHK_NUM_LOCK_MASK|RGHK_SCROLL_LOCK};*/
|
77
104
|
uint ignored[]={0, RGHK_LOCK_MASK, RGHK_NUM_LOCK_MASK, RGHK_LOCK_MASK|RGHK_NUM_LOCK_MASK};
|
78
105
|
uint mod;
|
106
|
+
XErrorHandler handler;
|
79
107
|
|
80
108
|
if (rb_funcall(rb_cv_get(cKeyBinder, "@@stock"), rb_intern("include?"), 1, self)==Qtrue)
|
81
109
|
rb_raise(eBinded, "KeyBinder allready binded.");
|
@@ -91,12 +119,18 @@ kb_bind_common(VALUE self, VALUE key, VALUE modifier, VALUE block)
|
|
91
119
|
else
|
92
120
|
mod=NUM2UINT(modifier);
|
93
121
|
|
122
|
+
strcpy(xlib_error, "");
|
123
|
+
handler=XSetErrorHandler(xlib_error_handler);
|
94
124
|
int i;
|
95
125
|
for (i=0; i<4 ; i++)
|
96
126
|
{
|
97
127
|
XGrabKey(xdisplay, keycode, mod|ignored[i], GDK_WINDOW_XWINDOW(root_window), False,
|
98
128
|
GrabModeAsync, GrabModeAsync);
|
99
129
|
}
|
130
|
+
XSync(xdisplay, FALSE);
|
131
|
+
XSetErrorHandler(handler);
|
132
|
+
if (strcmp(xlib_error, "")!=0)
|
133
|
+
rb_raise(eXlibError, xlib_error);
|
100
134
|
//XGrabKey(xdisplay, keycode, AnyModifier, GDK_WINDOW_XWINDOW(root_window), False, GrabModeAsync, GrabModeAsync);
|
101
135
|
|
102
136
|
rb_iv_set(self, "@key", key);
|
@@ -167,7 +201,7 @@ kb_unbind(VALUE self)
|
|
167
201
|
}
|
168
202
|
|
169
203
|
/*
|
170
|
-
* Unset
|
204
|
+
* Unset all global hotkeys.
|
171
205
|
*/
|
172
206
|
VALUE
|
173
207
|
kb_unbind_all(VALUE self)
|
@@ -248,6 +282,7 @@ Init_globalhotkeys()
|
|
248
282
|
eInitFailed=rb_define_class_under(mGlobalHotKeys, "InitFailed", rb_eException);
|
249
283
|
eInvalidKeyVal=rb_define_class_under(mGlobalHotKeys, "InvalidKeyVal", rb_eException);
|
250
284
|
eBinded=rb_define_class_under(mGlobalHotKeys, "Binded", rb_eException);
|
285
|
+
eXlibError=rb_define_class_under(mGlobalHotKeys, "XlibError", rb_eException);
|
251
286
|
|
252
287
|
mKeyVal=rb_define_module_under(mGlobalHotKeys, "KeyVal");
|
253
288
|
rb_define_module_function(mKeyVal, "from_name", keyval_from_name, 1);
|
data/lib/globalhotkeys.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalhotkeys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vincent Carmona
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
oxzIRXlS
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-03-
|
39
|
+
date: 2011-03-20 00:00:00 +01:00
|
40
40
|
default_executable:
|
41
41
|
dependencies: []
|
42
42
|
|
metadata.gz.sig
CHANGED
Binary file
|