libx11 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -5
- data/.travis.yml +1 -1
- data/Rakefile +1 -9
- data/example/aliases.rb +2 -0
- data/example/create_window.rb +15 -13
- data/example/window_manager.rb +30 -22
- data/lib/libx11.rb +4 -2
- data/lib/libx11/keysymdef.rb +2272 -0
- data/lib/libx11/version.rb +1 -1
- data/lib/libx11/x.rb +148 -0
- data/lib/libx11/xlib.rb +42 -0
- data/lib/libx11/xlib/display.rb +52 -0
- data/lib/libx11/xlib/xany_event.rb +13 -0
- data/lib/libx11/xlib/xbutton_event.rb +23 -0
- data/lib/libx11/xlib/xcirculate_event.rb +15 -0
- data/lib/libx11/xlib/xcirculate_request_event.rb +15 -0
- data/lib/libx11/xlib/xclient_message_event.rb +24 -0
- data/lib/libx11/xlib/xcolormap_event.rb +16 -0
- data/lib/libx11/xlib/xconfigure_event.rb +21 -0
- data/lib/libx11/xlib/xconfigure_request_event.rb +22 -0
- data/lib/libx11/xlib/xcreate_window_event.rb +20 -0
- data/lib/libx11/xlib/xcrossing_event.rb +25 -0
- data/lib/libx11/xlib/xdestroy_window_event.rb +14 -0
- data/lib/libx11/xlib/xerror_event.rb +15 -0
- data/lib/libx11/xlib/xevent.rb +77 -0
- data/lib/libx11/xlib/xexpose_event.rb +18 -0
- data/lib/libx11/xlib/xfocus_change_event.rb +15 -0
- data/lib/libx11/xlib/xgeneric_event.rb +14 -0
- data/lib/libx11/xlib/xgeneric_event_cookie.rb +16 -0
- data/lib/libx11/xlib/xgraphics_expose_event.rb +21 -0
- data/lib/libx11/xlib/xgravity_event.rb +16 -0
- data/lib/libx11/xlib/xkey_event.rb +23 -0
- data/lib/libx11/xlib/xkeymap_event.rb +14 -0
- data/lib/libx11/xlib/xmap_event.rb +15 -0
- data/lib/libx11/xlib/xmap_request_event.rb +18 -0
- data/lib/libx11/xlib/xmapping_event.rb +16 -0
- data/lib/libx11/xlib/xmotion_event.rb +23 -0
- data/lib/libx11/xlib/xno_expose_event.rb +15 -0
- data/lib/libx11/xlib/xproperty_event.rb +16 -0
- data/lib/libx11/xlib/xreparent_event.rb +18 -0
- data/lib/libx11/xlib/xresize_request_event.rb +15 -0
- data/lib/libx11/xlib/xselection_clear_event.rb +15 -0
- data/lib/libx11/xlib/xselection_event.rb +17 -0
- data/lib/libx11/xlib/xselection_request_event.rb +18 -0
- data/lib/libx11/xlib/xunmap_event.rb +15 -0
- data/lib/libx11/xlib/xvisibility_event.rb +14 -0
- data/libx11.gemspec +1 -1
- metadata +56 -13
- data/HACKING.md +0 -14
- data/ext/libx11_ruby/constants.c +0 -182
- data/ext/libx11_ruby/display.c +0 -197
- data/ext/libx11_ruby/extconf.rb +0 -6
- data/ext/libx11_ruby/libx11_ruby.c +0 -13
- data/ext/libx11_ruby/libx11_ruby.h +0 -14
- data/ext/libx11_ruby/window.c +0 -33
- data/ext/libx11_ruby/xerror_event.c +0 -104
- data/ext/libx11_ruby/xevent.c +0 -134
data/ext/libx11_ruby/extconf.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#ifndef LIBX11_RUBY_H
|
2
|
-
#define LIBX11_RUBY_H 1
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
VALUE rb_mLibX11;
|
7
|
-
|
8
|
-
void Init_libx11_constants(void);
|
9
|
-
void Init_libx11_display(void);
|
10
|
-
void Init_libx11_window(void);
|
11
|
-
void Init_libx11_xerror_event(void);
|
12
|
-
void Init_libx11_xevent(void);
|
13
|
-
|
14
|
-
#endif /* LIBX11_RUBY_H */
|
data/ext/libx11_ruby/window.c
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#include "libx11_ruby.h"
|
2
|
-
#include <X11/Xlib.h>
|
3
|
-
|
4
|
-
extern Display* get_display_struct(VALUE);
|
5
|
-
|
6
|
-
/*
|
7
|
-
* Xlib XCreateSimpleWindow
|
8
|
-
*/
|
9
|
-
static VALUE
|
10
|
-
rb_libx11_xcreate_simple_window(VALUE self, VALUE display_obj, VALUE parent_window, VALUE x, VALUE y,
|
11
|
-
VALUE width, VALUE height, VALUE border_width, VALUE border_color, VALUE background_color)
|
12
|
-
{
|
13
|
-
Window ret = XCreateSimpleWindow(get_display_struct(display_obj), NUM2ULONG(parent_window), NUM2INT(x), NUM2INT(y),
|
14
|
-
NUM2UINT(width), NUM2UINT(height), FIX2UINT(border_width), NUM2ULONG(border_color), NUM2ULONG(background_color));
|
15
|
-
return ULONG2NUM(ret);
|
16
|
-
}
|
17
|
-
|
18
|
-
/*
|
19
|
-
* Xlib XDestroyWindow
|
20
|
-
*/
|
21
|
-
static VALUE
|
22
|
-
rb_libx11_xdestroy_window(VALUE self, VALUE display_obj, VALUE window)
|
23
|
-
{
|
24
|
-
int ret = XDestroyWindow(get_display_struct(display_obj), NUM2ULONG(window));
|
25
|
-
return INT2NUM(ret);
|
26
|
-
}
|
27
|
-
|
28
|
-
void
|
29
|
-
Init_libx11_window(void)
|
30
|
-
{
|
31
|
-
rb_define_singleton_method(rb_mLibX11, "xcreate_simple_window", rb_libx11_xcreate_simple_window, 9);
|
32
|
-
rb_define_singleton_method(rb_mLibX11, "xdestroy_window", rb_libx11_xdestroy_window, 2);
|
33
|
-
}
|
@@ -1,104 +0,0 @@
|
|
1
|
-
#include "libx11_ruby.h"
|
2
|
-
#include <X11/Xlib.h>
|
3
|
-
|
4
|
-
extern VALUE rb_cDisplay;
|
5
|
-
VALUE rb_cXErrorEvent;
|
6
|
-
|
7
|
-
extern rb_data_type_t display_type;
|
8
|
-
|
9
|
-
static size_t
|
10
|
-
xerror_event_dsize(const void *arg)
|
11
|
-
{
|
12
|
-
const XErrorEvent *event = arg;
|
13
|
-
return sizeof(event);
|
14
|
-
}
|
15
|
-
|
16
|
-
const rb_data_type_t xerror_event_type = {
|
17
|
-
.wrap_struct_name = "libx11_xerror_event",
|
18
|
-
.function = {
|
19
|
-
.dmark = NULL,
|
20
|
-
.dfree = NULL,
|
21
|
-
.dsize = xerror_event_dsize,
|
22
|
-
.reserved = { NULL, NULL },
|
23
|
-
},
|
24
|
-
.parent = NULL,
|
25
|
-
.data = NULL,
|
26
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
27
|
-
};
|
28
|
-
|
29
|
-
static VALUE error_handler_proc = Qnil;
|
30
|
-
|
31
|
-
static int
|
32
|
-
error_handler_func(Display *display, XErrorEvent *event)
|
33
|
-
{
|
34
|
-
if (NIL_P(error_handler_proc)) {
|
35
|
-
return 1;
|
36
|
-
} else {
|
37
|
-
VALUE args = rb_ary_new();
|
38
|
-
rb_ary_push(args, TypedData_Wrap_Struct(rb_cDisplay, &display_type, display));
|
39
|
-
rb_ary_push(args, TypedData_Wrap_Struct(rb_cXErrorEvent, &xerror_event_type, event));
|
40
|
-
rb_proc_call(error_handler_proc, args);
|
41
|
-
return 0;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
/*
|
46
|
-
* Xlib XSetErrorHandler
|
47
|
-
*/
|
48
|
-
static VALUE
|
49
|
-
rb_libx11_xset_error_handler(int argc, VALUE *argv, VALUE self)
|
50
|
-
{
|
51
|
-
rb_check_arity(argc, 0, 0);
|
52
|
-
rb_scan_args(argc, argv, "00&", &error_handler_proc);
|
53
|
-
|
54
|
-
XSetErrorHandler(error_handler_func);
|
55
|
-
return Qnil;
|
56
|
-
}
|
57
|
-
|
58
|
-
static VALUE
|
59
|
-
rb_xerror_event_error_code(VALUE self)
|
60
|
-
{
|
61
|
-
XErrorEvent *event;
|
62
|
-
TypedData_Get_Struct(self, XErrorEvent, &xerror_event_type, event);
|
63
|
-
return INT2FIX(event->error_code);
|
64
|
-
}
|
65
|
-
|
66
|
-
static VALUE
|
67
|
-
rb_xerror_event_type(VALUE self)
|
68
|
-
{
|
69
|
-
XErrorEvent *event;
|
70
|
-
TypedData_Get_Struct(self, XErrorEvent, &xerror_event_type, event);
|
71
|
-
return INT2FIX(event->type);
|
72
|
-
}
|
73
|
-
|
74
|
-
void
|
75
|
-
Init_libx11_xerror_event(void)
|
76
|
-
{
|
77
|
-
rb_define_singleton_method(rb_mLibX11, "xset_error_handler", rb_libx11_xset_error_handler, -1);
|
78
|
-
|
79
|
-
rb_cXErrorEvent = rb_define_class_under(rb_mLibX11, "XErrorEvent", rb_cData);
|
80
|
-
rb_define_method(rb_cXErrorEvent, "error_code", rb_xerror_event_error_code, 0);
|
81
|
-
rb_define_method(rb_cXErrorEvent, "type", rb_xerror_event_type, 0);
|
82
|
-
|
83
|
-
// error codes
|
84
|
-
rb_define_const(rb_cXErrorEvent, "SUCCESS", INT2FIX(Success));
|
85
|
-
rb_define_const(rb_cXErrorEvent, "BAD_REQUEST", INT2FIX(BadRequest));
|
86
|
-
rb_define_const(rb_cXErrorEvent, "BAD_VALUE", INT2FIX(BadValue));
|
87
|
-
rb_define_const(rb_cXErrorEvent, "BAD_WINDOW", INT2FIX(BadWindow));
|
88
|
-
rb_define_const(rb_cXErrorEvent, "BAD_PIXMAP", INT2FIX(BadPixmap));
|
89
|
-
rb_define_const(rb_cXErrorEvent, "BAD_ATOM", INT2FIX(BadAtom));
|
90
|
-
rb_define_const(rb_cXErrorEvent, "BAD_CURSOR", INT2FIX(BadCursor));
|
91
|
-
rb_define_const(rb_cXErrorEvent, "BAD_FONT", INT2FIX(BadFont));
|
92
|
-
rb_define_const(rb_cXErrorEvent, "BAD_MATCH", INT2FIX(BadMatch));
|
93
|
-
rb_define_const(rb_cXErrorEvent, "BAD_DRAWABLE", INT2FIX(BadDrawable));
|
94
|
-
rb_define_const(rb_cXErrorEvent, "BAD_ACCESS", INT2FIX(BadAccess));
|
95
|
-
rb_define_const(rb_cXErrorEvent, "BAD_ALLOC", INT2FIX(BadAlloc));
|
96
|
-
rb_define_const(rb_cXErrorEvent, "BAD_COLOR", INT2FIX(BadColor));
|
97
|
-
rb_define_const(rb_cXErrorEvent, "BAD_GC", INT2FIX(BadGC));
|
98
|
-
rb_define_const(rb_cXErrorEvent, "BAD_ID_CHOICE", INT2FIX(BadIDChoice));
|
99
|
-
rb_define_const(rb_cXErrorEvent, "BAD_NAME", INT2FIX(BadName));
|
100
|
-
rb_define_const(rb_cXErrorEvent, "BAD_LENGTH", INT2FIX(BadLength));
|
101
|
-
rb_define_const(rb_cXErrorEvent, "BAD_IMPLEMENTATION", INT2FIX(BadImplementation));
|
102
|
-
rb_define_const(rb_cXErrorEvent, "FIRST_EXTENSION_ERROR", INT2FIX(FirstExtensionError));
|
103
|
-
rb_define_const(rb_cXErrorEvent, "LAST_EXTENSION_ERROR", INT2FIX(LastExtensionError));
|
104
|
-
}
|
data/ext/libx11_ruby/xevent.c
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
#include "libx11_ruby.h"
|
2
|
-
#include <X11/Xlib.h>
|
3
|
-
|
4
|
-
VALUE rb_cXEvent, rb_cXKeyEvent;
|
5
|
-
|
6
|
-
extern Display* get_display_struct(VALUE);
|
7
|
-
|
8
|
-
static void
|
9
|
-
xevent_dfree(void *arg)
|
10
|
-
{
|
11
|
-
XEvent *event = arg;
|
12
|
-
free(event);
|
13
|
-
}
|
14
|
-
|
15
|
-
static size_t
|
16
|
-
xevent_dsize(const void *arg)
|
17
|
-
{
|
18
|
-
const XEvent *event = arg;
|
19
|
-
return sizeof(event);
|
20
|
-
}
|
21
|
-
|
22
|
-
const rb_data_type_t xevent_type = {
|
23
|
-
.wrap_struct_name = "libx11_xevent",
|
24
|
-
.function = {
|
25
|
-
.dmark = NULL,
|
26
|
-
.dfree = xevent_dfree,
|
27
|
-
.dsize = xevent_dsize,
|
28
|
-
.reserved = { NULL, NULL },
|
29
|
-
},
|
30
|
-
.parent = NULL,
|
31
|
-
.data = NULL,
|
32
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
33
|
-
};
|
34
|
-
|
35
|
-
/*
|
36
|
-
* Xlib XNextEvent
|
37
|
-
*/
|
38
|
-
static VALUE
|
39
|
-
rb_libx11_xnext_event(VALUE self, VALUE obj)
|
40
|
-
{
|
41
|
-
XEvent *event = (XEvent *)malloc(sizeof(XEvent));
|
42
|
-
XNextEvent(get_display_struct(obj), event);
|
43
|
-
switch (event->type) {
|
44
|
-
case KeyPress:
|
45
|
-
return TypedData_Wrap_Struct(rb_cXKeyEvent, &xevent_type, event);
|
46
|
-
default:
|
47
|
-
return TypedData_Wrap_Struct(rb_cXEvent, &xevent_type, event);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
static VALUE
|
52
|
-
rb_xevent_type(VALUE self)
|
53
|
-
{
|
54
|
-
XEvent *event;
|
55
|
-
|
56
|
-
TypedData_Get_Struct(self, XEvent, &xevent_type, event);
|
57
|
-
return INT2NUM(event->type);
|
58
|
-
}
|
59
|
-
|
60
|
-
static VALUE
|
61
|
-
rb_xkey_event_state(VALUE self)
|
62
|
-
{
|
63
|
-
XEvent *event;
|
64
|
-
|
65
|
-
TypedData_Get_Struct(self, XEvent, &xevent_type, event);
|
66
|
-
return UINT2NUM(event->xkey.state);
|
67
|
-
}
|
68
|
-
|
69
|
-
/*
|
70
|
-
* KeySym XLookupKeysym(
|
71
|
-
* XKeyEvent* key_event,
|
72
|
-
* int index
|
73
|
-
* );
|
74
|
-
*/
|
75
|
-
static VALUE
|
76
|
-
rb_libx11_xlookup_keysym(VALUE self, VALUE event_obj, VALUE index)
|
77
|
-
{
|
78
|
-
XEvent *event;
|
79
|
-
unsigned long keysym;
|
80
|
-
|
81
|
-
TypedData_Get_Struct(event_obj, XEvent, &xevent_type, event);
|
82
|
-
keysym = XLookupKeysym(&event->xkey, NUM2INT(index));
|
83
|
-
return ULONG2NUM(keysym);
|
84
|
-
}
|
85
|
-
|
86
|
-
void
|
87
|
-
Init_libx11_xevent(void)
|
88
|
-
{
|
89
|
-
rb_define_singleton_method(rb_mLibX11, "xnext_event", rb_libx11_xnext_event, 1);
|
90
|
-
rb_define_singleton_method(rb_mLibX11, "xlookup_keysym", rb_libx11_xlookup_keysym, 2);
|
91
|
-
|
92
|
-
rb_cXEvent = rb_define_class_under(rb_mLibX11, "XEvent", rb_cData);
|
93
|
-
rb_define_method(rb_cXEvent, "type", rb_xevent_type, 0);
|
94
|
-
|
95
|
-
rb_cXKeyEvent = rb_define_class_under(rb_mLibX11, "XKeyEvent", rb_cXEvent);
|
96
|
-
rb_define_method(rb_cXKeyEvent, "state", rb_xkey_event_state, 0);
|
97
|
-
|
98
|
-
// event
|
99
|
-
rb_define_const(rb_cXEvent, "KEY_PRESS", INT2FIX(KeyPress));
|
100
|
-
rb_define_const(rb_cXEvent, "KEY_RELEASE", INT2FIX(KeyRelease));
|
101
|
-
rb_define_const(rb_cXEvent, "BUTTON_PRESS", INT2FIX(ButtonPress));
|
102
|
-
rb_define_const(rb_cXEvent, "BUTTON_RELEASE", INT2FIX(ButtonRelease));
|
103
|
-
rb_define_const(rb_cXEvent, "MOTION_NOTIFY", INT2FIX(MotionNotify));
|
104
|
-
rb_define_const(rb_cXEvent, "ENTER_NOTIFY", INT2FIX(EnterNotify));
|
105
|
-
rb_define_const(rb_cXEvent, "LEAVE_NOTIFY", INT2FIX(LeaveNotify));
|
106
|
-
rb_define_const(rb_cXEvent, "FOCUS_IN", INT2FIX(FocusIn));
|
107
|
-
rb_define_const(rb_cXEvent, "FOCUS_OUT", INT2FIX(FocusOut));
|
108
|
-
rb_define_const(rb_cXEvent, "KEYMAP_NOTIFY", INT2FIX(KeymapNotify));
|
109
|
-
rb_define_const(rb_cXEvent, "EXPOSE", INT2FIX(Expose));
|
110
|
-
rb_define_const(rb_cXEvent, "GRAPHICS_EXPOSE", INT2FIX(GraphicsExpose));
|
111
|
-
rb_define_const(rb_cXEvent, "NO_EXPOSE", INT2FIX(NoExpose));
|
112
|
-
rb_define_const(rb_cXEvent, "VISIBILITY_NOTIFY", INT2FIX(VisibilityNotify));
|
113
|
-
rb_define_const(rb_cXEvent, "CREATE_NOTIFY", INT2FIX(CreateNotify));
|
114
|
-
rb_define_const(rb_cXEvent, "DESTROY_NOTIFY", INT2FIX(DestroyNotify));
|
115
|
-
rb_define_const(rb_cXEvent, "UNMAP_NOTIFY", INT2FIX(UnmapNotify));
|
116
|
-
rb_define_const(rb_cXEvent, "MAP_NOTIFY", INT2FIX(MapNotify));
|
117
|
-
rb_define_const(rb_cXEvent, "MAP_REQUEST", INT2FIX(MapRequest));
|
118
|
-
rb_define_const(rb_cXEvent, "REPARENT_NOTIFY", INT2FIX(ReparentNotify));
|
119
|
-
rb_define_const(rb_cXEvent, "CONFIGURE_NOTIFY", INT2FIX(ConfigureNotify));
|
120
|
-
rb_define_const(rb_cXEvent, "CONFIGURE_REQUEST", INT2FIX(ConfigureRequest));
|
121
|
-
rb_define_const(rb_cXEvent, "GRAVITY_NOTIFY", INT2FIX(GravityNotify));
|
122
|
-
rb_define_const(rb_cXEvent, "RESIZE_REQUEST", INT2FIX(ResizeRequest));
|
123
|
-
rb_define_const(rb_cXEvent, "CIRCULATE_NOTIFY", INT2FIX(CirculateNotify));
|
124
|
-
rb_define_const(rb_cXEvent, "CIRCULATE_REQUEST", INT2FIX(CirculateRequest));
|
125
|
-
rb_define_const(rb_cXEvent, "PROPERTY_NOTIFY", INT2FIX(PropertyNotify));
|
126
|
-
rb_define_const(rb_cXEvent, "SELECTION_CLEAR", INT2FIX(SelectionClear));
|
127
|
-
rb_define_const(rb_cXEvent, "SELECTION_REQUEST", INT2FIX(SelectionRequest));
|
128
|
-
rb_define_const(rb_cXEvent, "SELKECTION_NOTIFY", INT2FIX(SelectionNotify));
|
129
|
-
rb_define_const(rb_cXEvent, "COLORMAP_NOTIFY", INT2FIX(ColormapNotify));
|
130
|
-
rb_define_const(rb_cXEvent, "CLIENT_MESSAGE", INT2FIX(ClientMessage));
|
131
|
-
rb_define_const(rb_cXEvent, "MAPPING_NOTIFY", INT2FIX(MappingNotify));
|
132
|
-
rb_define_const(rb_cXEvent, "GENERIC_EVENT", INT2FIX(GenericEvent));
|
133
|
-
rb_define_const(rb_cXEvent, "LAST_EVENT", INT2FIX(LASTEvent));
|
134
|
-
}
|