uh 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/ext/uh/extconf.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'mkmf'
2
+
3
+ fail 'libX11 is required' unless have_library 'X11'
4
+ fail 'libXinerama is required' unless have_library 'Xinerama'
5
+
6
+ # FIXME: -pendantic will warn "named variadic macros are a GNU extension"
7
+ #$CFLAGS << ' -std=c99 -pedantic -Wall'
8
+ $CFLAGS << ' -std=c99 -Wall'
9
+ if %w[DEBUG VALGRIND].any? { |e| ENV.key? e }
10
+ $CFLAGS.gsub! /-O\d\s/, '-g '
11
+ end
12
+
13
+ create_makefile 'uh'
data/ext/uh/font.c ADDED
@@ -0,0 +1,14 @@
1
+ #include "uh.h"
2
+
3
+
4
+ VALUE font_make(int width, int ascent, int descent) {
5
+ VALUE obj;
6
+ VALUE args[0];
7
+
8
+ obj = rb_class_new_instance(0, args, cFont);
9
+ rb_ivar_set(obj, rb_intern("@width"), INT2FIX(width));
10
+ rb_ivar_set(obj, rb_intern("@ascent"), INT2FIX(ascent));
11
+ rb_ivar_set(obj, rb_intern("@descent"), INT2FIX(descent));
12
+
13
+ return obj;
14
+ }
data/ext/uh/pixmap.c ADDED
@@ -0,0 +1,92 @@
1
+ #include "uh.h"
2
+
3
+
4
+ #define set_pixmap(x) \
5
+ UhPixmap *pixmap;\
6
+ Data_Get_Struct(x, UhPixmap, pixmap);
7
+
8
+ #define DPY pixmap->dpy
9
+ #define PIXMAP pixmap->pixmap
10
+ #define GC pixmap->gc
11
+
12
+
13
+ void pixmap_deallocate(UhPixmap *p);
14
+
15
+
16
+ VALUE pixmap_draw_rect(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) {
17
+ set_pixmap(self);
18
+
19
+ XFillRectangle(DPY, PIXMAP, GC,
20
+ FIX2INT(x), FIX2INT(y), FIX2INT(w), FIX2INT(h)
21
+ );
22
+
23
+ return Qnil;
24
+ }
25
+
26
+ VALUE pixmap_draw_string(VALUE self, VALUE x, VALUE y, VALUE str) {
27
+ set_pixmap(self);
28
+
29
+ XDrawString(DPY, PIXMAP, GC,
30
+ FIX2INT(x), FIX2INT(y), RSTRING_PTR(str), RSTRING_LEN(str)
31
+ );
32
+
33
+ return Qnil;
34
+ }
35
+
36
+ VALUE pixmap_gc_black(VALUE self) {
37
+ set_pixmap(self);
38
+
39
+ XSetForeground(DPY, GC, BlackPixel(DPY, SCREEN_DEFAULT));
40
+
41
+ return Qnil;
42
+ }
43
+
44
+ VALUE pixmap_gc_color(VALUE self, VALUE rcolor) {
45
+ set_pixmap(self);
46
+
47
+ XSetForeground(DPY, GC, NUM2LONG(rb_ivar_get(rcolor, rb_intern("@pixel"))));
48
+
49
+ return Qnil;
50
+ }
51
+
52
+ VALUE pixmap_gc_white(VALUE self) {
53
+ set_pixmap(self);
54
+
55
+ XSetForeground(DPY, GC, WhitePixel(DPY, SCREEN_DEFAULT));
56
+
57
+ return Qnil;
58
+ }
59
+
60
+
61
+ VALUE pixmap__copy(VALUE self, VALUE rwindow_id, VALUE rwidth, VALUE rheight) {
62
+ set_pixmap(self);
63
+
64
+ XCopyArea(DPY, PIXMAP, FIX2INT(rwindow_id), GC,
65
+ 0, 0, FIX2INT(rwidth), FIX2INT(rheight), 0, 0
66
+ );
67
+
68
+ return Qnil;
69
+ }
70
+
71
+
72
+ VALUE pixmap_make(Display *display, Pixmap xpixmap, VALUE width, VALUE height) {
73
+ UhPixmap *pixmap;
74
+ VALUE obj;
75
+
76
+ obj = Data_Make_Struct(cPixmap, UhPixmap, 0, pixmap_deallocate, pixmap);
77
+ pixmap->dpy = display;
78
+ pixmap->pixmap = xpixmap;
79
+ pixmap->gc = XCreateGC(display, DefaultRootWindow(display), 0, NULL);
80
+
81
+ rb_ivar_set(obj, rb_intern("@width"), width);
82
+ rb_ivar_set(obj, rb_intern("@height"), height);
83
+
84
+ return obj;
85
+ }
86
+
87
+
88
+ void pixmap_deallocate(UhPixmap *pixmap) {
89
+ XFreePixmap(DPY, PIXMAP);
90
+ XFreeGC(DPY, GC);
91
+ free(pixmap);
92
+ }
data/ext/uh/screen.c ADDED
@@ -0,0 +1,12 @@
1
+ #include "uh.h"
2
+
3
+
4
+ VALUE screen_init(VALUE self, VALUE id, VALUE x, VALUE y, VALUE w, VALUE h) {
5
+ rb_ivar_set(self, rb_intern("@id"), id);
6
+ rb_ivar_set(self, rb_intern("@x"), x);
7
+ rb_ivar_set(self, rb_intern("@y"), y);
8
+ rb_ivar_set(self, rb_intern("@width"), w);
9
+ rb_ivar_set(self, rb_intern("@height"), h);
10
+
11
+ return self;
12
+ }
data/ext/uh/uh.c ADDED
@@ -0,0 +1,139 @@
1
+ #include "uh.h"
2
+
3
+
4
+ void uh_color();
5
+ void uh_display();
6
+ void uh_events();
7
+ void uh_font();
8
+ void uh_pixmap();
9
+ void uh_screen();
10
+ void uh_window();
11
+
12
+
13
+ void Init_uh(void) {
14
+ mUh = rb_define_module("Uh");
15
+
16
+ eDisplayError = rb_define_class_under(
17
+ mUh, "DisplayError", rb_eStandardError
18
+ );
19
+
20
+ uh_color();
21
+ uh_display();
22
+ uh_events();
23
+ uh_font();
24
+ uh_pixmap();
25
+ uh_screen();
26
+ uh_window();
27
+ }
28
+
29
+ void uh_color() {
30
+ cColor = rb_define_class_under(mUh, "Color", rb_cObject);
31
+ rb_define_attr(cColor, "pixel", 1, 0);
32
+ }
33
+
34
+ void uh_display() {
35
+ cDisplay = rb_define_class_under(mUh, "Display", rb_cObject);
36
+ rb_define_singleton_method(cDisplay, "on_error", display_s_on_error, 1);
37
+ rb_define_alloc_func(cDisplay, display_alloc);
38
+ rb_define_attr(cDisplay, "name", 1, 0);
39
+ rb_define_method(cDisplay, "close", display_close, 0);
40
+ rb_define_method(cDisplay, "color_by_name", display_color_by_name, 1);
41
+ rb_define_method(cDisplay, "create_pixmap", display_create_pixmap, 2);
42
+ rb_define_method(cDisplay, "fileno", display_fileno, 0);
43
+ rb_define_method(cDisplay, "flush", display_flush, 0);
44
+ rb_define_method(cDisplay, "grab_key", display_grab_key, 2);
45
+ rb_define_method(cDisplay, "listen_events", display_listen_events, -1);
46
+ rb_define_method(cDisplay, "each_event", display_each_event, 0);
47
+ rb_define_method(cDisplay, "next_event", display_next_event, 0);
48
+ rb_define_method(cDisplay, "open", display_open, 0);
49
+ rb_define_method(cDisplay, "pending", display_pending, 0);
50
+ rb_define_method(cDisplay, "query_font", display_query_font, 0);
51
+ rb_define_method(cDisplay, "root", display_root, 0);
52
+ rb_define_method(cDisplay, "screens", display_screens, 0);
53
+ rb_define_method(cDisplay, "sync", display_sync, 1);
54
+ }
55
+
56
+ void uh_events() {
57
+ mEvents = rb_define_module_under(mUh, "Events");
58
+
59
+ cEvent = rb_define_class_under(mEvents, "Event", rb_cObject);
60
+ rb_define_attr(cEvent, "type", 1, 0);
61
+ rb_define_attr(cEvent, "window", 1, 0);
62
+
63
+ cConfigureRequest = rb_define_class_under(mEvents, "ConfigureRequest", cEvent);
64
+ rb_define_attr(cConfigureRequest, "x", 1, 0);
65
+ rb_define_attr(cConfigureRequest, "y", 1, 0);
66
+ rb_define_attr(cConfigureRequest, "width", 1, 0);
67
+ rb_define_attr(cConfigureRequest, "height", 1, 0);
68
+ rb_define_attr(cConfigureRequest, "above_window_id", 1, 0);
69
+ rb_define_attr(cConfigureRequest, "detail", 1, 0);
70
+ rb_define_attr(cConfigureRequest, "value_mask", 1, 0);
71
+
72
+ cDestroyNotify = rb_define_class_under(mEvents, "DestroyNotify", cEvent);
73
+
74
+ cExpose = rb_define_class_under(mEvents, "Expose", cEvent);
75
+
76
+ cKeyPress = rb_define_class_under(mEvents, "KeyPress", cEvent);
77
+ rb_define_attr(cKeyPress, "key", 1, 0);
78
+ rb_define_attr(cKeyPress, "modifier_mask", 1, 0);
79
+
80
+ cKeyRelease = rb_define_class_under(mEvents, "KeyRelease", cEvent);
81
+ rb_define_attr(cKeyRelease, "key", 1, 0);
82
+ rb_define_attr(cKeyRelease, "modifier_mask", 1, 0);
83
+
84
+ cMapRequest = rb_define_class_under(mEvents, "MapRequest", cEvent);
85
+
86
+ cPropertyNotify = rb_define_class_under(mEvents, "PropertyNotify", cEvent);
87
+
88
+ cUnmapNotify = rb_define_class_under(mEvents, "UnmapNotify", cEvent);
89
+ }
90
+
91
+ void uh_font() {
92
+ cFont = rb_define_class_under(mUh, "Font", rb_cObject);
93
+ rb_define_attr(cFont, "width", 1, 0);
94
+ rb_define_attr(cFont, "ascent", 1, 0);
95
+ rb_define_attr(cFont, "descent", 1, 0);
96
+ }
97
+
98
+ void uh_pixmap() {
99
+ cPixmap = rb_define_class_under(mUh, "Pixmap", rb_cObject);
100
+ rb_define_attr(cPixmap, "width", 1, 0);
101
+ rb_define_attr(cPixmap, "height", 1, 0);
102
+ rb_define_method(cPixmap, "draw_rect", pixmap_draw_rect, 4);
103
+ rb_define_method(cPixmap, "draw_string", pixmap_draw_string, 3);
104
+ rb_define_method(cPixmap, "gc_black", pixmap_gc_black, 0);
105
+ rb_define_method(cPixmap, "gc_color", pixmap_gc_color, 1);
106
+ rb_define_method(cPixmap, "gc_white", pixmap_gc_white, 0);
107
+ rb_define_private_method(cPixmap, "_copy", pixmap__copy, 3);
108
+ }
109
+
110
+ void uh_screen() {
111
+ cScreen = rb_define_class_under(mUh, "Screen", rb_cObject);
112
+ rb_define_method(cScreen, "initialize", screen_init, 5);
113
+ rb_define_attr(cScreen, "id", 1, 0);
114
+ rb_define_attr(cScreen, "x", 1, 0);
115
+ rb_define_attr(cScreen, "y", 1, 0);
116
+ rb_define_attr(cScreen, "width", 1, 0);
117
+ rb_define_attr(cScreen, "height", 1, 0);
118
+ }
119
+
120
+ void uh_window() {
121
+ cWindow = rb_define_class_under(mUh, "Window", rb_cObject);
122
+ rb_define_attr(cWindow, "id", 1, 0);
123
+ rb_define_method(cWindow, "focus", window_focus, 0);
124
+ rb_define_method(cWindow, "kill", window_kill, 0);
125
+ rb_define_method(cWindow, "map", window_map, 0);
126
+ rb_define_method(cWindow, "mask=", window_mask_set, 1);
127
+ rb_define_method(cWindow, "name", window_name, 0);
128
+ rb_define_method(cWindow, "override_redirect?", window_override_redirect, 0);
129
+ rb_define_method(cWindow, "raise", window_raise, 0);
130
+ rb_define_method(cWindow, "unmap", window_unmap, 0);
131
+ rb_define_method(cWindow, "wclass", window_wclass, 0);
132
+ rb_define_method(cWindow, "icccm_wm_delete", window_icccm_wm_delete, 0);
133
+ rb_define_method(cWindow, "icccm_wm_protocols", window_icccm_wm_protocols, 0);
134
+ rb_define_private_method(cWindow, "_configure", window__configure, 4);
135
+ rb_define_private_method(cWindow, "_configure_event",
136
+ window__configure_event, 4);
137
+ rb_define_private_method(cWindow, "_create_sub", window__create_sub, 4);
138
+ rb_define_private_method(cWindow, "_moveresize", window__moveresize, 4);
139
+ }
data/ext/uh/uh.h ADDED
@@ -0,0 +1,106 @@
1
+ #ifndef RUBY_UH
2
+ #define RUBY_UH
3
+
4
+ #include <ruby.h>
5
+
6
+ #include <X11/Xlib.h>
7
+ #include <X11/XKBlib.h>
8
+ #include <X11/Xutil.h>
9
+ #include <X11/extensions/Xinerama.h>
10
+
11
+
12
+ #define set_display(x) \
13
+ UhDisplay *display;\
14
+ Data_Get_Struct(x, UhDisplay, display);
15
+
16
+ #define ROOT_DEFAULT DefaultRootWindow(DPY)
17
+ #define SCREEN_DEFAULT DefaultScreen(DPY)
18
+
19
+
20
+ typedef struct s_display UhDisplay;
21
+ typedef struct s_pixmap UhPixmap;
22
+ typedef struct s_window UhWindow;
23
+
24
+ struct s_display {
25
+ Display *dpy;
26
+ };
27
+
28
+ struct s_pixmap {
29
+ Display *dpy;
30
+ Pixmap pixmap;
31
+ GC gc;
32
+ };
33
+
34
+ struct s_window {
35
+ Display *dpy;
36
+ Window id;
37
+ };
38
+
39
+
40
+ VALUE mUh, mEvents,
41
+ cColor,
42
+ cDisplay,
43
+ cEvent, cConfigureRequest, cDestroyNotify, cExpose, cKeyPress, cKeyRelease,
44
+ cMapRequest, cPropertyNotify, cUnmapNotify,
45
+ cFont,
46
+ cPixmap,
47
+ cScreen,
48
+ cWindow,
49
+ eDisplayError;
50
+
51
+
52
+ VALUE color_make(unsigned long pixel);
53
+
54
+ VALUE display_s_on_error(VALUE klass, VALUE handler);
55
+ VALUE display_alloc(VALUE klass);
56
+ VALUE display_close(VALUE self);
57
+ VALUE display_color_by_name(VALUE self, VALUE rcolor);
58
+ VALUE display_create_pixmap(VALUE self, VALUE w, VALUE h);
59
+ VALUE display_each_event(VALUE self);
60
+ VALUE display_fileno(VALUE self);
61
+ VALUE display_flush(VALUE self);
62
+ VALUE display_grab_key(VALUE self, VALUE key, VALUE modifier);
63
+ VALUE display_listen_events(int argc, VALUE *argv, VALUE self);
64
+ VALUE display_next_event(VALUE self);
65
+ VALUE display_open(VALUE self);
66
+ VALUE display_pending(VALUE self);
67
+ VALUE display_query_font(VALUE self);
68
+ VALUE display_root(VALUE self);
69
+ VALUE display_root_change_attributes(VALUE self, VALUE mask);
70
+ VALUE display_screens(VALUE self);
71
+ VALUE display_sync(VALUE self, VALUE discard);
72
+
73
+ VALUE event_make(XEvent *xev);
74
+
75
+ VALUE font_make(int width, int ascent, int descent);
76
+
77
+ VALUE pixmap__copy(VALUE self, VALUE rwindow_id, VALUE rwidth, VALUE rheight);
78
+ VALUE pixmap_draw_rect(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h);
79
+ VALUE pixmap_draw_string(VALUE self, VALUE x, VALUE y, VALUE str);
80
+ VALUE pixmap_gc_black(VALUE self);
81
+ VALUE pixmap_gc_color(VALUE self, VALUE rcolor);
82
+ VALUE pixmap_gc_white(VALUE self);
83
+ VALUE pixmap_make(Display *display, Pixmap xpixmap, VALUE width, VALUE height);
84
+
85
+ VALUE screen_init(VALUE self, VALUE id, VALUE x, VALUE y, VALUE w, VALUE h);
86
+
87
+ VALUE window_focus(VALUE self);
88
+ VALUE window_icccm_wm_delete(VALUE self);
89
+ VALUE window_icccm_wm_protocols(VALUE self);
90
+ VALUE window_kill(VALUE self);
91
+ VALUE window_map(VALUE self);
92
+ VALUE window_mask_set(VALUE self, VALUE mask);
93
+ VALUE window_name(VALUE self);
94
+ VALUE window_override_redirect(VALUE self);
95
+ VALUE window_raise(VALUE self);
96
+ VALUE window_unmap(VALUE self);
97
+ VALUE window_wclass(VALUE self);
98
+ VALUE window__configure(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh);
99
+ VALUE window__configure_event(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh);
100
+ VALUE window__create_sub(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h);
101
+ VALUE window__moveresize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height);
102
+ int window_id(VALUE window);
103
+ VALUE window_make(Display *display, Window window_id);
104
+
105
+
106
+ #endif
data/ext/uh/window.c ADDED
@@ -0,0 +1,222 @@
1
+ #include "uh.h"
2
+
3
+
4
+ #define set_window(x) \
5
+ UhWindow *window;\
6
+ Data_Get_Struct(x, UhWindow, window);
7
+
8
+ #define DPY window->dpy
9
+ #define WINDOW window->id
10
+
11
+
12
+ VALUE window_focus(VALUE self) {
13
+ set_window(self);
14
+
15
+ XSetInputFocus(DPY, WINDOW, RevertToPointerRoot, CurrentTime);
16
+
17
+ return Qnil;
18
+ }
19
+
20
+ VALUE window_icccm_wm_delete(VALUE self) {
21
+ set_window(self);
22
+ XEvent xev;
23
+
24
+ xev.type = ClientMessage;
25
+ xev.xclient.window = WINDOW;
26
+ xev.xclient.message_type = XInternAtom(DPY, "WM_PROTOCOLS", False);
27
+ xev.xclient.format = 32;
28
+ xev.xclient.data.l[0] = XInternAtom(DPY, "WM_DELETE_WINDOW", False);
29
+ xev.xclient.data.l[1] = CurrentTime;
30
+ XSendEvent(DPY, WINDOW, False, NoEventMask, &xev);
31
+
32
+ return Qnil;
33
+ }
34
+
35
+ VALUE window_icccm_wm_protocols(VALUE self) {
36
+ set_window(self);
37
+ Atom *win_protocols;
38
+ int count;
39
+ int i;
40
+ char *atom_name;
41
+ VALUE protocols = rb_ary_new();
42
+
43
+ if (XGetWMProtocols(DPY, WINDOW, &win_protocols, &count)) {
44
+ for (i = 0; i < count; i++) {
45
+ atom_name = XGetAtomName(DPY, win_protocols[i]);
46
+ rb_ary_push(protocols, ID2SYM(rb_intern(atom_name)));
47
+ XFree(atom_name);
48
+ }
49
+ }
50
+
51
+ return protocols;
52
+ }
53
+
54
+ VALUE window_kill(VALUE self) {
55
+ set_window(self);
56
+
57
+ XKillClient(DPY, WINDOW);
58
+
59
+ return Qnil;
60
+ }
61
+
62
+ VALUE window_map(VALUE self) {
63
+ set_window(self);
64
+
65
+ XMapWindow(DPY, WINDOW);
66
+
67
+ return Qnil;
68
+ }
69
+
70
+ VALUE window_mask_set(VALUE self, VALUE mask) {
71
+ set_window(self);
72
+ XSetWindowAttributes attrs;
73
+
74
+ attrs.event_mask = FIX2LONG(mask);
75
+ XChangeWindowAttributes(DPY, WINDOW, CWEventMask, &attrs);
76
+
77
+ return Qnil;
78
+ }
79
+
80
+ VALUE window_name(VALUE self) {
81
+ set_window(self);
82
+ char *wxname;
83
+ VALUE wname;
84
+
85
+ if (!XFetchName(DPY, WINDOW, &wxname))
86
+ return Qnil;
87
+
88
+ wname = rb_str_new_cstr(wxname);
89
+ XFree(wxname);
90
+
91
+ return wname;
92
+ }
93
+
94
+ VALUE window_override_redirect(VALUE self) {
95
+ set_window(self);
96
+ XWindowAttributes wa;
97
+
98
+ if (!XGetWindowAttributes(DPY, WINDOW, &wa))
99
+ return Qnil;
100
+
101
+ return wa.override_redirect ? Qtrue : Qfalse;
102
+ }
103
+
104
+ VALUE window_raise(VALUE self) {
105
+ set_window(self);
106
+
107
+ XRaiseWindow(DPY, WINDOW);
108
+
109
+ return Qnil;
110
+ }
111
+
112
+ VALUE window_unmap(VALUE self) {
113
+ set_window(self);
114
+
115
+ XUnmapWindow(DPY, WINDOW);
116
+
117
+ return Qnil;
118
+ }
119
+
120
+ VALUE window_wclass(VALUE self) {
121
+ set_window(self);
122
+ XClassHint ch;
123
+ VALUE wclass;
124
+
125
+ if (!XGetClassHint(DPY, WINDOW, &ch))
126
+ return Qnil;
127
+
128
+ wclass = rb_str_new_cstr(ch.res_class);
129
+ XFree(ch.res_name);
130
+ XFree(ch.res_class);
131
+
132
+ return wclass;
133
+ }
134
+
135
+
136
+ VALUE window__configure(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh) {
137
+ set_window(self);
138
+ XWindowChanges wc;
139
+ unsigned int mask;
140
+
141
+ mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode;
142
+ wc.x = FIX2INT(rx);
143
+ wc.y = FIX2INT(ry);
144
+ wc.width = FIX2INT(rw);
145
+ wc.height = FIX2INT(rh);
146
+ wc.border_width = 0;
147
+ wc.stack_mode = Above;
148
+ XConfigureWindow(DPY, WINDOW, mask, &wc);
149
+
150
+ return Qnil;
151
+ }
152
+
153
+ VALUE window__configure_event(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh) {
154
+ set_window(self);
155
+ XConfigureEvent ev;
156
+
157
+ ev.type = ConfigureNotify;
158
+ ev.display = DPY;
159
+ ev.event = WINDOW;
160
+ ev.window = WINDOW;
161
+ ev.x = FIX2INT(rx);
162
+ ev.y = FIX2INT(ry);
163
+ ev.width = FIX2INT(rw);
164
+ ev.height = FIX2INT(rh);
165
+ ev.border_width = 0;
166
+ ev.above = None;
167
+ ev.override_redirect = False;
168
+ XSendEvent(DPY, WINDOW, False, StructureNotifyMask, (XEvent *)&ev);
169
+
170
+ return Qnil;
171
+ }
172
+
173
+ VALUE window__create_sub(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) {
174
+ set_window(self);
175
+ XSetWindowAttributes wa;
176
+ Window sub_win;
177
+
178
+ wa.override_redirect = True;
179
+ wa.background_pixmap = ParentRelative;
180
+ wa.event_mask = ExposureMask;
181
+
182
+ sub_win = XCreateWindow(DPY, WINDOW,
183
+ FIX2INT(x), FIX2INT(y), FIX2INT(w), FIX2INT(h), 0,
184
+ CopyFromParent, CopyFromParent, CopyFromParent,
185
+ CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa
186
+ );
187
+
188
+ return window_make(DPY, sub_win);
189
+ }
190
+
191
+ VALUE window__moveresize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) {
192
+ set_window(self);
193
+ XWindowChanges wc;
194
+
195
+ wc.x = NUM2INT(x);
196
+ wc.y = NUM2INT(y);
197
+ wc.width = NUM2INT(width);
198
+ wc.height = NUM2INT(height);
199
+ XConfigureWindow(DPY, WINDOW, CWX | CWY | CWWidth | CWHeight, &wc);
200
+
201
+ return Qnil;
202
+ }
203
+
204
+
205
+ int window_id(VALUE self) {
206
+ set_window(self);
207
+
208
+ return WINDOW;
209
+ }
210
+
211
+ VALUE window_make(Display *display, Window window_id) {
212
+ UhWindow *window;
213
+ VALUE obj;
214
+
215
+ obj = Data_Make_Struct(cWindow, UhWindow, 0, free, window);
216
+ window->dpy = display;
217
+ window->id = window_id;
218
+
219
+ rb_ivar_set(obj, rb_intern("@id"), LONG2NUM(window_id));
220
+
221
+ return obj;
222
+ }