uh 2.0.0.pre2 → 2.0.0.pre3
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/README.md +18 -0
- data/ext/uh/extconf.rb +1 -2
- data/lib/uh.rb +0 -6
- data/lib/uh/display.rb +16 -0
- data/lib/uh/version.rb +1 -1
- data/lib/uh/window.rb +0 -28
- metadata +24 -29
- data/.gitignore +0 -4
- data/.travis.yml +0 -7
- data/Gemfile +0 -5
- data/Guardfile +0 -7
- data/LICENSE +0 -30
- data/Rakefile +0 -13
- data/ext/uh/color.c +0 -12
- data/ext/uh/display.c +0 -242
- data/ext/uh/event.c +0 -168
- data/ext/uh/font.c +0 -14
- data/ext/uh/pixmap.c +0 -92
- data/ext/uh/screen.c +0 -12
- data/ext/uh/uh.c +0 -143
- data/ext/uh/uh.h +0 -106
- data/ext/uh/window.c +0 -262
- data/lib/uh/drawable.rb +0 -7
- data/lib/uh/pixmap.rb +0 -5
- data/test/test_helper.rb +0 -19
- data/test/uh/test_geo.rb +0 -52
- data/uh.gemspec +0 -23
data/ext/uh/window.c
DELETED
@@ -1,262 +0,0 @@
|
|
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_destroy(VALUE self) {
|
13
|
-
SET_WINDOW(self);
|
14
|
-
|
15
|
-
XDestroyWindow(DPY, WINDOW);
|
16
|
-
|
17
|
-
return Qnil;
|
18
|
-
}
|
19
|
-
|
20
|
-
VALUE window_focus(VALUE self) {
|
21
|
-
SET_WINDOW(self);
|
22
|
-
|
23
|
-
XSetInputFocus(DPY, WINDOW, RevertToPointerRoot, CurrentTime);
|
24
|
-
|
25
|
-
return Qnil;
|
26
|
-
}
|
27
|
-
|
28
|
-
VALUE window_icccm_wm_delete(VALUE self) {
|
29
|
-
XEvent xev;
|
30
|
-
SET_WINDOW(self);
|
31
|
-
|
32
|
-
xev.type = ClientMessage;
|
33
|
-
xev.xclient.window = WINDOW;
|
34
|
-
xev.xclient.message_type = XInternAtom(DPY, "WM_PROTOCOLS", False);
|
35
|
-
xev.xclient.format = 32;
|
36
|
-
xev.xclient.data.l[0] = XInternAtom(DPY, "WM_DELETE_WINDOW", False);
|
37
|
-
xev.xclient.data.l[1] = CurrentTime;
|
38
|
-
XSendEvent(DPY, WINDOW, False, NoEventMask, &xev);
|
39
|
-
|
40
|
-
return Qnil;
|
41
|
-
}
|
42
|
-
|
43
|
-
VALUE window_icccm_wm_protocols(VALUE self) {
|
44
|
-
Atom *win_protocols;
|
45
|
-
int count;
|
46
|
-
int i;
|
47
|
-
char *atom_name;
|
48
|
-
VALUE protocols;
|
49
|
-
SET_WINDOW(self);
|
50
|
-
protocols = rb_ary_new();
|
51
|
-
|
52
|
-
if (XGetWMProtocols(DPY, WINDOW, &win_protocols, &count)) {
|
53
|
-
for (i = 0; i < count; i++) {
|
54
|
-
atom_name = XGetAtomName(DPY, win_protocols[i]);
|
55
|
-
rb_ary_push(protocols, ID2SYM(rb_intern(atom_name)));
|
56
|
-
XFree(atom_name);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
return protocols;
|
61
|
-
}
|
62
|
-
|
63
|
-
VALUE window_kill(VALUE self) {
|
64
|
-
SET_WINDOW(self);
|
65
|
-
|
66
|
-
XKillClient(DPY, WINDOW);
|
67
|
-
|
68
|
-
return Qnil;
|
69
|
-
}
|
70
|
-
|
71
|
-
VALUE window_map(VALUE self) {
|
72
|
-
SET_WINDOW(self);
|
73
|
-
|
74
|
-
XMapWindow(DPY, WINDOW);
|
75
|
-
|
76
|
-
return Qnil;
|
77
|
-
}
|
78
|
-
|
79
|
-
VALUE window_mask(VALUE self) {
|
80
|
-
XWindowAttributes wa;
|
81
|
-
SET_WINDOW(self);
|
82
|
-
|
83
|
-
if (!XGetWindowAttributes(DPY, WINDOW, &wa)) {
|
84
|
-
rb_raise(rb_eArgError, "cannot get window attributes for `0x%08lx'", WINDOW);
|
85
|
-
}
|
86
|
-
|
87
|
-
return LONG2FIX(wa.your_event_mask);
|
88
|
-
}
|
89
|
-
|
90
|
-
VALUE window_mask_set(VALUE self, VALUE mask) {
|
91
|
-
XSetWindowAttributes attrs;
|
92
|
-
SET_WINDOW(self);
|
93
|
-
|
94
|
-
attrs.event_mask = FIX2LONG(mask);
|
95
|
-
XChangeWindowAttributes(DPY, WINDOW, CWEventMask, &attrs);
|
96
|
-
|
97
|
-
return Qnil;
|
98
|
-
}
|
99
|
-
|
100
|
-
VALUE window_name(VALUE self) {
|
101
|
-
char *wxname;
|
102
|
-
VALUE wname;
|
103
|
-
SET_WINDOW(self);
|
104
|
-
|
105
|
-
if (!XFetchName(DPY, WINDOW, &wxname))
|
106
|
-
return Qnil;
|
107
|
-
|
108
|
-
wname = rb_str_new_cstr(wxname);
|
109
|
-
XFree(wxname);
|
110
|
-
|
111
|
-
return wname;
|
112
|
-
}
|
113
|
-
|
114
|
-
VALUE window_name_set(VALUE self, VALUE name) {
|
115
|
-
SET_WINDOW(self);
|
116
|
-
|
117
|
-
XStoreName(DPY, WINDOW, RSTRING_PTR(name));
|
118
|
-
|
119
|
-
return Qnil;
|
120
|
-
}
|
121
|
-
|
122
|
-
VALUE window_override_redirect(VALUE self) {
|
123
|
-
XWindowAttributes wa;
|
124
|
-
SET_WINDOW(self);
|
125
|
-
|
126
|
-
if (!XGetWindowAttributes(DPY, WINDOW, &wa))
|
127
|
-
return Qnil;
|
128
|
-
|
129
|
-
return wa.override_redirect ? Qtrue : Qfalse;
|
130
|
-
}
|
131
|
-
|
132
|
-
VALUE window_raise(VALUE self) {
|
133
|
-
SET_WINDOW(self);
|
134
|
-
|
135
|
-
XRaiseWindow(DPY, WINDOW);
|
136
|
-
|
137
|
-
return Qnil;
|
138
|
-
}
|
139
|
-
|
140
|
-
VALUE window_unmap(VALUE self) {
|
141
|
-
SET_WINDOW(self);
|
142
|
-
|
143
|
-
XUnmapWindow(DPY, WINDOW);
|
144
|
-
|
145
|
-
return Qnil;
|
146
|
-
}
|
147
|
-
|
148
|
-
VALUE window_wclass(VALUE self) {
|
149
|
-
XClassHint ch;
|
150
|
-
VALUE wclass;
|
151
|
-
SET_WINDOW(self);
|
152
|
-
|
153
|
-
if (!XGetClassHint(DPY, WINDOW, &ch))
|
154
|
-
return Qnil;
|
155
|
-
|
156
|
-
wclass = rb_str_new_cstr(ch.res_class);
|
157
|
-
XFree(ch.res_name);
|
158
|
-
XFree(ch.res_class);
|
159
|
-
|
160
|
-
return wclass;
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
VALUE window__configure(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh) {
|
165
|
-
XWindowChanges wc;
|
166
|
-
unsigned int mask;
|
167
|
-
SET_WINDOW(self);
|
168
|
-
|
169
|
-
mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode;
|
170
|
-
wc.x = FIX2INT(rx);
|
171
|
-
wc.y = FIX2INT(ry);
|
172
|
-
wc.width = FIX2INT(rw);
|
173
|
-
wc.height = FIX2INT(rh);
|
174
|
-
wc.border_width = 0;
|
175
|
-
wc.stack_mode = Above;
|
176
|
-
XConfigureWindow(DPY, WINDOW, mask, &wc);
|
177
|
-
|
178
|
-
return Qnil;
|
179
|
-
}
|
180
|
-
|
181
|
-
VALUE window__configure_event(VALUE self, VALUE rx, VALUE ry, VALUE rw, VALUE rh) {
|
182
|
-
XConfigureEvent ev;
|
183
|
-
SET_WINDOW(self);
|
184
|
-
|
185
|
-
ev.type = ConfigureNotify;
|
186
|
-
ev.display = DPY;
|
187
|
-
ev.event = WINDOW;
|
188
|
-
ev.window = WINDOW;
|
189
|
-
ev.x = FIX2INT(rx);
|
190
|
-
ev.y = FIX2INT(ry);
|
191
|
-
ev.width = FIX2INT(rw);
|
192
|
-
ev.height = FIX2INT(rh);
|
193
|
-
ev.border_width = 0;
|
194
|
-
ev.above = None;
|
195
|
-
ev.override_redirect = False;
|
196
|
-
XSendEvent(DPY, WINDOW, False, StructureNotifyMask, (XEvent *)&ev);
|
197
|
-
|
198
|
-
return Qnil;
|
199
|
-
}
|
200
|
-
|
201
|
-
VALUE window__create(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) {
|
202
|
-
Window win;
|
203
|
-
SET_WINDOW(self);
|
204
|
-
|
205
|
-
win = XCreateSimpleWindow(DPY, WINDOW,
|
206
|
-
FIX2INT(x), FIX2INT(y), FIX2INT(w), FIX2INT(h),
|
207
|
-
0, BlackPixel(DPY, SCREEN_DEFAULT), BlackPixel(DPY, SCREEN_DEFAULT)
|
208
|
-
);
|
209
|
-
|
210
|
-
return window_make(DPY, win);
|
211
|
-
}
|
212
|
-
|
213
|
-
VALUE window__create_sub(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h) {
|
214
|
-
XSetWindowAttributes wa;
|
215
|
-
Window sub_win;
|
216
|
-
SET_WINDOW(self);
|
217
|
-
|
218
|
-
wa.override_redirect = True;
|
219
|
-
wa.background_pixmap = ParentRelative;
|
220
|
-
wa.event_mask = ExposureMask;
|
221
|
-
|
222
|
-
sub_win = XCreateWindow(DPY, WINDOW,
|
223
|
-
FIX2INT(x), FIX2INT(y), FIX2INT(w), FIX2INT(h), 0,
|
224
|
-
CopyFromParent, CopyFromParent, CopyFromParent,
|
225
|
-
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa
|
226
|
-
);
|
227
|
-
|
228
|
-
return window_make(DPY, sub_win);
|
229
|
-
}
|
230
|
-
|
231
|
-
VALUE window__moveresize(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) {
|
232
|
-
XWindowChanges wc;
|
233
|
-
SET_WINDOW(self);
|
234
|
-
|
235
|
-
wc.x = NUM2INT(x);
|
236
|
-
wc.y = NUM2INT(y);
|
237
|
-
wc.width = NUM2INT(width);
|
238
|
-
wc.height = NUM2INT(height);
|
239
|
-
XConfigureWindow(DPY, WINDOW, CWX | CWY | CWWidth | CWHeight, &wc);
|
240
|
-
|
241
|
-
return Qnil;
|
242
|
-
}
|
243
|
-
|
244
|
-
|
245
|
-
int window_id(VALUE self) {
|
246
|
-
SET_WINDOW(self);
|
247
|
-
|
248
|
-
return WINDOW;
|
249
|
-
}
|
250
|
-
|
251
|
-
VALUE window_make(Display *display, Window window_id) {
|
252
|
-
UhWindow *window;
|
253
|
-
VALUE obj;
|
254
|
-
|
255
|
-
obj = Data_Make_Struct(cWindow, UhWindow, 0, free, window);
|
256
|
-
window->dpy = display;
|
257
|
-
window->id = window_id;
|
258
|
-
|
259
|
-
rb_ivar_set(obj, rb_intern("@id"), LONG2NUM(window_id));
|
260
|
-
|
261
|
-
return obj;
|
262
|
-
}
|
data/lib/uh/drawable.rb
DELETED
data/lib/uh/pixmap.rb
DELETED
data/test/test_helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#require 'minitest/parallel'
|
2
|
-
require 'minitest/spec'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'minitest/reporters'
|
5
|
-
require 'uh'
|
6
|
-
|
7
|
-
class Minitest::Test
|
8
|
-
# FIXME: SpecReporter output is incorrect with pretty diffs or parallel tests
|
9
|
-
#make_my_diffs_pretty!
|
10
|
-
#parallelize_me!
|
11
|
-
end
|
12
|
-
|
13
|
-
class Minitest::Spec
|
14
|
-
class << self
|
15
|
-
alias context describe
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
data/test/uh/test_geo.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Uh::Geo do
|
4
|
-
subject { Uh::Geo.new(0, 0, 640, 480) }
|
5
|
-
|
6
|
-
describe '.new' do
|
7
|
-
it 'raises error when invalid width is given' do
|
8
|
-
assert_raises(Uh::ArgumentError) { Uh::Geo.new(0, 0, 0, 480) }
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'raises error when invalid height is given' do
|
12
|
-
assert_raises(Uh::ArgumentError) { Uh::Geo.new(0, 0, 640, 0) }
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'builds a geo without arguments' do
|
16
|
-
assert_instance_of Uh::Geo, Uh::Geo.new
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '.format_xgeometry' do
|
21
|
-
it 'formats coordinates and dimensions as X geometry' do
|
22
|
-
assert_equal '640x480+0+0', Uh::Geo.format_xgeometry(0, 0, 640, 480)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'formats missing values as ?' do
|
26
|
-
assert_equal '?x?+?+?', Uh::Geo.format_xgeometry(*[nil] * 4)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#to_s' do
|
31
|
-
it 'returns .format_xgeometry results' do
|
32
|
-
assert_equal Uh::Geo.format_xgeometry(*subject.values), subject.to_s
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
%w[width height].each do |dimension|
|
37
|
-
describe "##{dimension}=" do
|
38
|
-
it 'assigns given value' do
|
39
|
-
subject.send "#{dimension}=", 42
|
40
|
-
assert_equal 42, subject.send(dimension)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'raises error when 0 is given' do
|
44
|
-
assert_raises(Uh::ArgumentError) { subject.send "#{dimension}=", 0 }
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'raises error when negative value is given' do
|
48
|
-
assert_raises(Uh::ArgumentError) { subject.send "#{dimension}=", -42 }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/uh.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/uh/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'uh'
|
5
|
-
s.version = Uh::VERSION.dup
|
6
|
-
s.summary = 'Xlib simplified toolkit'
|
7
|
-
s.description = s.name
|
8
|
-
s.homepage = 'https://rubygems.org/gems/uh'
|
9
|
-
|
10
|
-
s.authors = 'Thibault Jouan'
|
11
|
-
s.email = 'tj@a13.fr'
|
12
|
-
|
13
|
-
s.files = `git ls-files`.split $/
|
14
|
-
s.test_files = s.files.grep /\Atest\//
|
15
|
-
|
16
|
-
s.extensions = %w[ext/uh/extconf.rb]
|
17
|
-
|
18
|
-
|
19
|
-
s.add_development_dependency 'rake', '~> 10.4'
|
20
|
-
s.add_development_dependency 'rake-compiler', '~> 0.9'
|
21
|
-
s.add_development_dependency 'minitest', '~> 5.5'
|
22
|
-
s.add_development_dependency 'minitest-reporters', '~> 1.0'
|
23
|
-
end
|