uh 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -15
- data/ext/uh/display.c +1 -1
- data/ext/uh/event.c +22 -1
- data/ext/uh/extconf.rb +1 -1
- data/ext/uh/image.c +74 -0
- data/ext/uh/pixmap.c +0 -1
- data/ext/uh/uh.c +19 -0
- data/ext/uh/uh.h +16 -2
- data/ext/uh/window.c +10 -0
- data/lib/uh.rb +92 -0
- data/lib/uh/display.rb +24 -7
- data/lib/uh/geo.rb +7 -7
- data/lib/uh/screen.rb +1 -1
- data/lib/uh/version.rb +1 -1
- data/lib/uh/window.rb +5 -1
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b8a1fabce6c90b7171ae772bb59981a4a28c66
|
4
|
+
data.tar.gz: 7d25eeec5e12d68dbb23cd63e031ab62df4f89e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d98e8cf49dae6a056339fe944beb1d25ed2f21dea828adb4650373c68c82e90db6f8d32a4296311b21c7270371c52b8f7b1dae12c9b97c256ab21217198f4e
|
7
|
+
data.tar.gz: 407e4325a030e84365277cc076d1ca37d0ec1f8a3252a90d35b372efca9f178bb90cf5225a3b23bcf329237d04baffda14c7151bcd1528868addbd6209cf5535
|
data/README.md
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
uh
|
2
2
|
==
|
3
3
|
|
4
|
-
[![Version ][badge-version-img]][badge-version-uri]
|
5
|
-
[![Build status ][badge-build-img]][badge-build-uri]
|
6
|
-
[![Code Climate ][badge-cclimate-img]][badge-cclimate-uri]
|
7
|
-
|
8
|
-
|
9
4
|
Minimalistic Xlib toolkit.
|
10
5
|
|
11
6
|
|
@@ -18,17 +13,7 @@ Similar or related code
|
|
18
13
|
* https://github.com/christopheraue/ruby-xlib (gem, FFI)
|
19
14
|
* https://github.com/rkh/ruby-xlib (C ext)
|
20
15
|
* https://github.com/rramsden/ruby-x11 (pure ruby)
|
21
|
-
|
22
16
|
* http://ruby-xlib-wrap.sourceforge.net/ (ext, SWIG)
|
23
17
|
* http://www.moriq.com/ruby/xlib/
|
24
18
|
* http://artengine.ca/matju/RubyX11/
|
25
19
|
* https://github.com/mhanne/ruby-xcb (XCB, FFI)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
[badge-version-img]: https://img.shields.io/gem/v/uh.svg?style=flat-square
|
30
|
-
[badge-version-uri]: https://rubygems.org/gems/uh
|
31
|
-
[badge-build-img]: https://img.shields.io/travis/tjouan/uh/master.svg?style=flat-square
|
32
|
-
[badge-build-uri]: https://travis-ci.org/tjouan/uh
|
33
|
-
[badge-cclimate-img]: https://img.shields.io/codeclimate/github/tjouan/uh.svg?style=flat-square
|
34
|
-
[badge-cclimate-uri]: https://codeclimate.com/github/tjouan/uh
|
data/ext/uh/display.c
CHANGED
@@ -133,7 +133,7 @@ VALUE display_open(VALUE self) {
|
|
133
133
|
SET_DISPLAY(self);
|
134
134
|
|
135
135
|
if (!(DPY = XOpenDisplay(NULL))) {
|
136
|
-
rb_raise(eDisplayError, "cannot open display");
|
136
|
+
rb_raise(eDisplayError, "cannot open display %s", getenv("DISPLAY"));
|
137
137
|
}
|
138
138
|
|
139
139
|
XSetErrorHandler(display_x_error_handler);
|
data/ext/uh/event.c
CHANGED
@@ -7,7 +7,9 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
VALUE event_make_event(VALUE klass, XEvent *xev);
|
10
|
+
void event_make_configure_notify(VALUE self);
|
10
11
|
void event_make_configure_request(VALUE self);
|
12
|
+
void event_make_expose(VALUE self);
|
11
13
|
void event_make_key_any(VALUE self);
|
12
14
|
void event_make_win_any(VALUE self);
|
13
15
|
|
@@ -19,9 +21,10 @@ VALUE event_make(XEvent *xev) {
|
|
19
21
|
void (*function)(VALUE self);
|
20
22
|
} EvClass;
|
21
23
|
EvClass ev_classes[] = {
|
24
|
+
{ConfigureNotify, cConfigureNotify, event_make_configure_notify},
|
22
25
|
{ConfigureRequest, cConfigureRequest, event_make_configure_request},
|
23
26
|
{DestroyNotify, cDestroyNotify, NULL},
|
24
|
-
{Expose, cExpose,
|
27
|
+
{Expose, cExpose, event_make_expose},
|
25
28
|
{KeyPress, cKeyPress, event_make_key_any},
|
26
29
|
{KeyRelease, cKeyRelease, event_make_key_any},
|
27
30
|
{MapRequest, cMapRequest, NULL},
|
@@ -93,6 +96,15 @@ VALUE event_make_event(VALUE klass, XEvent *xev) {
|
|
93
96
|
return event;
|
94
97
|
}
|
95
98
|
|
99
|
+
void event_make_configure_notify(VALUE self) {
|
100
|
+
SET_XEV(self);
|
101
|
+
|
102
|
+
rb_ivar_set(self, rb_intern("@x"), INT2FIX(xev->xconfigure.x));
|
103
|
+
rb_ivar_set(self, rb_intern("@y"), INT2FIX(xev->xconfigure.y));
|
104
|
+
rb_ivar_set(self, rb_intern("@width"), INT2FIX(xev->xconfigure.width));
|
105
|
+
rb_ivar_set(self, rb_intern("@height"), INT2FIX(xev->xconfigure.height));
|
106
|
+
}
|
107
|
+
|
96
108
|
void event_make_configure_request(VALUE self) {
|
97
109
|
SET_XEV(self);
|
98
110
|
|
@@ -118,6 +130,15 @@ void event_make_configure_request(VALUE self) {
|
|
118
130
|
LONG2NUM(xev->xconfigurerequest.detail));
|
119
131
|
}
|
120
132
|
|
133
|
+
void event_make_expose(VALUE self) {
|
134
|
+
SET_XEV(self);
|
135
|
+
|
136
|
+
rb_ivar_set(self, rb_intern("@x"), INT2FIX(xev->xexpose.x));
|
137
|
+
rb_ivar_set(self, rb_intern("@y"), INT2FIX(xev->xexpose.y));
|
138
|
+
rb_ivar_set(self, rb_intern("@width"), INT2FIX(xev->xexpose.width));
|
139
|
+
rb_ivar_set(self, rb_intern("@height"), INT2FIX(xev->xexpose.height));
|
140
|
+
}
|
141
|
+
|
121
142
|
void event_make_key_any(VALUE self) {
|
122
143
|
KeySym ks;
|
123
144
|
SET_XEV(self);
|
data/ext/uh/extconf.rb
CHANGED
data/ext/uh/image.c
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#include "uh.h"
|
2
|
+
|
3
|
+
|
4
|
+
#define SET_IMAGE(x) \
|
5
|
+
UhImage *image;\
|
6
|
+
Data_Get_Struct(x, UhImage, image);
|
7
|
+
|
8
|
+
#define DPY image->dpy
|
9
|
+
#define IMAGE image->image
|
10
|
+
#define GC image->gc
|
11
|
+
|
12
|
+
|
13
|
+
void image_deallocate(UhImage *image);
|
14
|
+
|
15
|
+
|
16
|
+
VALUE image_s_new(VALUE klass, VALUE rdisplay, VALUE rwidth, VALUE rheight, VALUE rdata) {
|
17
|
+
VALUE rimage;
|
18
|
+
SET_DISPLAY(rdisplay);
|
19
|
+
|
20
|
+
rb_funcall(rdisplay, rb_intern("check!"), 0);
|
21
|
+
|
22
|
+
StringValue(rdata);
|
23
|
+
rimage = image_make(
|
24
|
+
display->dpy,
|
25
|
+
FIX2INT(rwidth),
|
26
|
+
FIX2INT(rheight),
|
27
|
+
RSTRING_PTR(rdata)
|
28
|
+
);
|
29
|
+
|
30
|
+
return rimage;
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
VALUE image_put(VALUE self, VALUE rwindow) {
|
35
|
+
SET_IMAGE(self);
|
36
|
+
|
37
|
+
XPutImage(
|
38
|
+
DPY,
|
39
|
+
FIX2INT(rb_funcall(rwindow, rb_intern("id"), 0)),
|
40
|
+
GC,
|
41
|
+
IMAGE,
|
42
|
+
0, 0,
|
43
|
+
0, 0,
|
44
|
+
IMAGE->width, IMAGE->height
|
45
|
+
);
|
46
|
+
|
47
|
+
return Qnil;
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
VALUE image_make(Display *dpy, int width, int height, char *data) {
|
52
|
+
UhImage *image;
|
53
|
+
VALUE rimage;
|
54
|
+
|
55
|
+
rimage = Data_Make_Struct(cImage, UhImage, 0, image_deallocate, image);
|
56
|
+
image->dpy = dpy;
|
57
|
+
image->gc = XCreateGC(dpy, ROOT_DEFAULT, 0, NULL);
|
58
|
+
image->image = XCreateImage(
|
59
|
+
DPY,
|
60
|
+
DefaultVisual(DPY, DefaultScreen(DPY)),
|
61
|
+
DEPTH_DEFAULT,
|
62
|
+
ZPixmap, 0,
|
63
|
+
data, width, height,
|
64
|
+
32, 0
|
65
|
+
);
|
66
|
+
|
67
|
+
return rimage;
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
void image_deallocate(UhImage *image) {
|
72
|
+
XDestroyImage(IMAGE);
|
73
|
+
free(image);
|
74
|
+
}
|
data/ext/uh/pixmap.c
CHANGED
data/ext/uh/uh.c
CHANGED
@@ -5,6 +5,7 @@ void uh_color();
|
|
5
5
|
void uh_display();
|
6
6
|
void uh_events();
|
7
7
|
void uh_font();
|
8
|
+
void uh_image();
|
8
9
|
void uh_pixmap();
|
9
10
|
void uh_screen();
|
10
11
|
void uh_window();
|
@@ -22,6 +23,7 @@ void Init_uh(void) {
|
|
22
23
|
uh_display();
|
23
24
|
uh_events();
|
24
25
|
uh_font();
|
26
|
+
uh_image();
|
25
27
|
uh_pixmap();
|
26
28
|
uh_screen();
|
27
29
|
uh_window();
|
@@ -61,6 +63,12 @@ void uh_events() {
|
|
61
63
|
rb_define_attr(cEvent, "type", 1, 0);
|
62
64
|
rb_define_attr(cEvent, "window", 1, 0);
|
63
65
|
|
66
|
+
cConfigureNotify = rb_define_class_under(mEvents, "ConfigureNotify", cEvent);
|
67
|
+
rb_define_attr(cConfigureNotify, "x", 1, 0);
|
68
|
+
rb_define_attr(cConfigureNotify, "y", 1, 0);
|
69
|
+
rb_define_attr(cConfigureNotify, "width", 1, 0);
|
70
|
+
rb_define_attr(cConfigureNotify, "height", 1, 0);
|
71
|
+
|
64
72
|
cConfigureRequest = rb_define_class_under(mEvents, "ConfigureRequest", cEvent);
|
65
73
|
rb_define_attr(cConfigureRequest, "x", 1, 0);
|
66
74
|
rb_define_attr(cConfigureRequest, "y", 1, 0);
|
@@ -73,6 +81,10 @@ void uh_events() {
|
|
73
81
|
cDestroyNotify = rb_define_class_under(mEvents, "DestroyNotify", cEvent);
|
74
82
|
|
75
83
|
cExpose = rb_define_class_under(mEvents, "Expose", cEvent);
|
84
|
+
rb_define_attr(cExpose, "x", 1, 0);
|
85
|
+
rb_define_attr(cExpose, "y", 1, 0);
|
86
|
+
rb_define_attr(cExpose, "width", 1, 0);
|
87
|
+
rb_define_attr(cExpose, "height", 1, 0);
|
76
88
|
|
77
89
|
cKeyPress = rb_define_class_under(mEvents, "KeyPress", cEvent);
|
78
90
|
rb_define_attr(cKeyPress, "key", 1, 0);
|
@@ -97,6 +109,12 @@ void uh_font() {
|
|
97
109
|
rb_define_attr(cFont, "descent", 1, 0);
|
98
110
|
}
|
99
111
|
|
112
|
+
void uh_image() {
|
113
|
+
cImage = rb_define_class_under(mUh, "Image", rb_cObject);
|
114
|
+
rb_define_singleton_method(cImage, "new", image_s_new, 4);
|
115
|
+
rb_define_method(cImage, "put", image_put, 1);
|
116
|
+
}
|
117
|
+
|
100
118
|
void uh_pixmap() {
|
101
119
|
cPixmap = rb_define_class_under(mUh, "Pixmap", rb_cObject);
|
102
120
|
rb_define_singleton_method(cPixmap, "new", pixmap_s_new, 3);
|
@@ -128,6 +146,7 @@ void uh_window() {
|
|
128
146
|
rb_define_method(cWindow, "configure_event", window_configure_event, 1);
|
129
147
|
rb_define_method(cWindow, "create", window_create, 1);
|
130
148
|
rb_define_method(cWindow, "create_sub", window_create_sub, 1);
|
149
|
+
rb_define_method(cWindow, "cursor=", window_cursor_set, 1);
|
131
150
|
rb_define_method(cWindow, "destroy", window_destroy, 0);
|
132
151
|
rb_define_method(cWindow, "focus", window_focus, 0);
|
133
152
|
rb_define_method(cWindow, "icccm_wm_delete", window_icccm_wm_delete, 0);
|
data/ext/uh/uh.h
CHANGED
@@ -15,9 +15,11 @@
|
|
15
15
|
|
16
16
|
#define ROOT_DEFAULT DefaultRootWindow(DPY)
|
17
17
|
#define SCREEN_DEFAULT DefaultScreen(DPY)
|
18
|
+
#define DEPTH_DEFAULT DefaultDepth(DPY, SCREEN_DEFAULT)
|
18
19
|
|
19
20
|
|
20
21
|
typedef struct s_display UhDisplay;
|
22
|
+
typedef struct s_image UhImage;
|
21
23
|
typedef struct s_pixmap UhPixmap;
|
22
24
|
typedef struct s_window UhWindow;
|
23
25
|
|
@@ -25,6 +27,12 @@ struct s_display {
|
|
25
27
|
Display *dpy;
|
26
28
|
};
|
27
29
|
|
30
|
+
struct s_image {
|
31
|
+
Display *dpy;
|
32
|
+
GC gc;
|
33
|
+
XImage *image;
|
34
|
+
};
|
35
|
+
|
28
36
|
struct s_pixmap {
|
29
37
|
Display *dpy;
|
30
38
|
Pixmap pixmap;
|
@@ -40,9 +48,10 @@ struct s_window {
|
|
40
48
|
VALUE mUh, mEvents,
|
41
49
|
cColor,
|
42
50
|
cDisplay,
|
43
|
-
cEvent, cConfigureRequest, cDestroyNotify, cExpose,
|
44
|
-
cMapRequest, cPropertyNotify, cUnmapNotify,
|
51
|
+
cEvent, cConfigureNotify, cConfigureRequest, cDestroyNotify, cExpose,
|
52
|
+
cKeyPress, cKeyRelease, cMapRequest, cPropertyNotify, cUnmapNotify,
|
45
53
|
cFont,
|
54
|
+
cImage,
|
46
55
|
cPixmap,
|
47
56
|
cScreen,
|
48
57
|
cWindow,
|
@@ -72,6 +81,10 @@ VALUE event_make(XEvent *xev);
|
|
72
81
|
|
73
82
|
VALUE font_s_new(VALUE klass, VALUE rdisplay);
|
74
83
|
|
84
|
+
VALUE image_s_new(VALUE klass, VALUE rdisplay, VALUE rwidth, VALUE rheight, VALUE rdata);
|
85
|
+
VALUE image_make(Display *dpy, int w, int h, char *data);
|
86
|
+
VALUE image_put(VALUE self, VALUE rwindow);
|
87
|
+
|
75
88
|
VALUE pixmap_s_new(VALUE klass, VALUE rdisplay, VALUE rwidth, VALUE rheight);
|
76
89
|
VALUE pixmap_copy(VALUE self, VALUE rwindow);
|
77
90
|
VALUE pixmap_draw_rect(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h);
|
@@ -88,6 +101,7 @@ VALUE window_configure(VALUE self, VALUE rgeo);
|
|
88
101
|
VALUE window_configure_event(VALUE self, VALUE rgeo);
|
89
102
|
VALUE window_create(VALUE self, VALUE rgeo);
|
90
103
|
VALUE window_create_sub(VALUE self, VALUE rgeo);
|
104
|
+
VALUE window_cursor_set(VALUE self, VALUE cursor);
|
91
105
|
VALUE window_destroy(VALUE self);
|
92
106
|
VALUE window_focus(VALUE self);
|
93
107
|
VALUE window_icccm_wm_delete(VALUE self);
|
data/ext/uh/window.c
CHANGED
@@ -92,6 +92,16 @@ VALUE window_create_sub(VALUE self, VALUE rgeo) {
|
|
92
92
|
return window_make(DPY, sub_win);
|
93
93
|
}
|
94
94
|
|
95
|
+
VALUE window_cursor_set(VALUE self, VALUE rcursor) {
|
96
|
+
Cursor cursor;
|
97
|
+
SET_WINDOW(self);
|
98
|
+
|
99
|
+
cursor = XCreateFontCursor(DPY, FIX2INT(rcursor));
|
100
|
+
XDefineCursor(DPY, WINDOW, cursor);
|
101
|
+
|
102
|
+
return Qnil;
|
103
|
+
}
|
104
|
+
|
95
105
|
VALUE window_destroy(VALUE self) {
|
96
106
|
SET_WINDOW(self);
|
97
107
|
|
data/lib/uh.rb
CHANGED
@@ -10,6 +10,87 @@ require 'uh/version'
|
|
10
10
|
require 'uh/window'
|
11
11
|
|
12
12
|
module Uh
|
13
|
+
CURSORS = {
|
14
|
+
num_glyphs: 154,
|
15
|
+
x_cursor: 0,
|
16
|
+
arrow: 2,
|
17
|
+
based_arrow_down: 4,
|
18
|
+
based_arrow_up: 6,
|
19
|
+
boat: 8,
|
20
|
+
bogosity: 10,
|
21
|
+
bottom_left_corner: 12,
|
22
|
+
bottom_right_corner: 14,
|
23
|
+
bottom_side: 16,
|
24
|
+
bottom_tee: 18,
|
25
|
+
box_spiral: 20,
|
26
|
+
center_ptr: 22,
|
27
|
+
circle: 24,
|
28
|
+
clock: 26,
|
29
|
+
coffee_mug: 28,
|
30
|
+
cross: 30,
|
31
|
+
cross_reverse: 32,
|
32
|
+
crosshair: 34,
|
33
|
+
diamond_cross: 36,
|
34
|
+
dot: 38,
|
35
|
+
dotbox: 40,
|
36
|
+
double_arrow: 42,
|
37
|
+
draft_large: 44,
|
38
|
+
draft_small: 46,
|
39
|
+
draped_box: 48,
|
40
|
+
exchange: 50,
|
41
|
+
fleur: 52,
|
42
|
+
gobbler: 54,
|
43
|
+
gumby: 56,
|
44
|
+
hand1: 58,
|
45
|
+
hand2: 60,
|
46
|
+
heart: 62,
|
47
|
+
icon: 64,
|
48
|
+
iron_cross: 66,
|
49
|
+
left_ptr: 68,
|
50
|
+
left_side: 70,
|
51
|
+
left_tee: 72,
|
52
|
+
leftbutton: 74,
|
53
|
+
ll_angle: 76,
|
54
|
+
lr_angle: 78,
|
55
|
+
man: 80,
|
56
|
+
middlebutton: 82,
|
57
|
+
mouse: 84,
|
58
|
+
pencil: 86,
|
59
|
+
pirate: 88,
|
60
|
+
plus: 90,
|
61
|
+
question_arrow: 92,
|
62
|
+
right_ptr: 94,
|
63
|
+
right_side: 96,
|
64
|
+
right_tee: 98,
|
65
|
+
rightbutton: 100,
|
66
|
+
rtl_logo: 102,
|
67
|
+
sailboat: 104,
|
68
|
+
sb_down_arrow: 106,
|
69
|
+
sb_h_double_arrow: 108,
|
70
|
+
sb_left_arrow: 110,
|
71
|
+
sb_right_arrow: 112,
|
72
|
+
sb_up_arrow: 114,
|
73
|
+
sb_v_double_arrow: 116,
|
74
|
+
shuttle: 118,
|
75
|
+
sizing: 120,
|
76
|
+
spider: 122,
|
77
|
+
spraycan: 124,
|
78
|
+
star: 126,
|
79
|
+
target: 128,
|
80
|
+
tcross: 130,
|
81
|
+
top_left_arrow: 132,
|
82
|
+
top_left_corner: 134,
|
83
|
+
top_right_corner: 136,
|
84
|
+
top_side: 138,
|
85
|
+
top_tee: 140,
|
86
|
+
trek: 142,
|
87
|
+
ul_angle: 144,
|
88
|
+
umbrella: 146,
|
89
|
+
ur_angle: 148,
|
90
|
+
watch: 150,
|
91
|
+
xterm: 152,
|
92
|
+
}
|
93
|
+
|
13
94
|
KEY_MODIFIERS = {
|
14
95
|
shift: 1 << 0,
|
15
96
|
lock: 1 << 1,
|
@@ -20,4 +101,15 @@ module Uh
|
|
20
101
|
mod4: 1 << 6,
|
21
102
|
mod5: 1 << 7
|
22
103
|
}.freeze
|
104
|
+
|
105
|
+
class << self
|
106
|
+
def open
|
107
|
+
display = Display.new.tap &:open
|
108
|
+
begin
|
109
|
+
yield display
|
110
|
+
ensure
|
111
|
+
display.close
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
23
115
|
end
|
data/lib/uh/display.rb
CHANGED
@@ -8,19 +8,23 @@ module Uh
|
|
8
8
|
fail DisplayError, 'display not opened' unless opened?
|
9
9
|
end
|
10
10
|
|
11
|
-
def color_by_name
|
12
|
-
Color.new
|
11
|
+
def color_by_name color_name
|
12
|
+
Color.new self, color_name
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
15
|
+
def create_image width, height, image
|
16
|
+
Image.new self, width, height, image
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def create_pixmap width, height
|
20
|
+
Pixmap.new self, width, height
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_window geo
|
20
24
|
root.create geo
|
21
25
|
end
|
22
26
|
|
23
|
-
def create_subwindow
|
27
|
+
def create_subwindow geo
|
24
28
|
root.create_sub geo
|
25
29
|
end
|
26
30
|
|
@@ -33,7 +37,20 @@ module Uh
|
|
33
37
|
end
|
34
38
|
|
35
39
|
def query_font
|
36
|
-
Font.new
|
40
|
+
Font.new self
|
41
|
+
end
|
42
|
+
|
43
|
+
def window **opts
|
44
|
+
window = create_window Geo.new 0, 0, 320, 240
|
45
|
+
listen_events window, opts[:events] if opts.key? :events
|
46
|
+
window.cursor opts[:cursor] if opts.key? :cursor
|
47
|
+
window.map
|
48
|
+
begin
|
49
|
+
yield window
|
50
|
+
ensure
|
51
|
+
window.unmap
|
52
|
+
window.destroy
|
53
|
+
end
|
37
54
|
end
|
38
55
|
end
|
39
56
|
end
|
data/lib/uh/geo.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Uh
|
2
|
-
class Geo < Struct.new
|
2
|
+
class Geo < Struct.new :x, :y, :width, :height
|
3
3
|
class << self
|
4
|
-
def format_xgeometry
|
4
|
+
def format_xgeometry x, y, width, height
|
5
5
|
'%sx%s+%s+%s' % [
|
6
6
|
width ? width.to_s : ??,
|
7
7
|
height ? height.to_s : ??,
|
@@ -11,7 +11,7 @@ module Uh
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize
|
14
|
+
def initialize *args
|
15
15
|
super
|
16
16
|
%i[width height].each do |dimension|
|
17
17
|
check_value dimension, send(dimension)
|
@@ -22,20 +22,20 @@ module Uh
|
|
22
22
|
self.class.format_xgeometry *values
|
23
23
|
end
|
24
24
|
|
25
|
-
def width=
|
25
|
+
def width= value
|
26
26
|
check_value :width, value
|
27
27
|
super value
|
28
28
|
end
|
29
29
|
|
30
|
-
def height=
|
30
|
+
def height= value
|
31
31
|
check_value :height, value
|
32
32
|
super value
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
|
36
|
+
private
|
37
37
|
|
38
|
-
def check_value
|
38
|
+
def check_value name, value
|
39
39
|
return if value.nil?
|
40
40
|
fail ArgumentError, "invalid #{name.to_s}: #{value}" unless value > 0
|
41
41
|
end
|
data/lib/uh/screen.rb
CHANGED
data/lib/uh/version.rb
CHANGED
data/lib/uh/window.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '1.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,21 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
|
-
|
70
|
-
name: headless
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.0'
|
83
|
-
description: uh
|
69
|
+
description:
|
84
70
|
email: tj@a13.fr
|
85
71
|
executables: []
|
86
72
|
extensions:
|
@@ -94,6 +80,7 @@ files:
|
|
94
80
|
- ext/uh/event.c
|
95
81
|
- ext/uh/extconf.rb
|
96
82
|
- ext/uh/font.c
|
83
|
+
- ext/uh/image.c
|
97
84
|
- ext/uh/pixmap.c
|
98
85
|
- ext/uh/screen.c
|
99
86
|
- ext/uh/uh.c
|
@@ -129,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
116
|
version: '0'
|
130
117
|
requirements: []
|
131
118
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.6.14
|
133
120
|
signing_key:
|
134
121
|
specification_version: 4
|
135
122
|
summary: Xlib simplified toolkit
|