pure-x11 0.0.2

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.
@@ -0,0 +1,328 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module X11
4
+ # From /usr/lib/X11; FIXME: Not complete
5
+ KeySyms = {
6
+ 0x01b7 => :XK_caron,
7
+ 0x01bd => :XK_doubleacute,
8
+
9
+ 0xff08 => :backspace,
10
+ 0xff09 => :tab,
11
+ 0xff0a => :linefeed,
12
+ 0xff0b => :clear,
13
+ 0xff0d => :enter,
14
+ 0xfe01 => :XK_ISO_Lock,
15
+ 0xfe02 => :XK_ISO_Level2_Latch,
16
+ 0xfe03 => :XK_ISO_Level3_Shift,
17
+ 0xfe04 => :XK_ISO_Level3_Latch,
18
+ 0xfe05 => :XK_ISO_Level3_Lock,
19
+ 0xfe06 => :XK_ISO_Group_Latch,
20
+ 0xfe07 => :XK_ISO_Group_Lock,
21
+ 0xfe08 => :XK_ISO_Next_Group,
22
+ 0xfe09 => :XK_ISO_Next_Group_Lock,
23
+ 0xfe0a => :XK_ISO_Prev_Group,
24
+ 0xfe0b => :XK_ISO_Prev_Group_Lock,
25
+ 0xfe0c => :XK_ISO_First_Group,
26
+ 0xfe0d => :XK_ISO_First_Group_Lock,
27
+ 0xfe0e => :XK_ISO_Last_Group,
28
+ 0xfe0f => :XK_ISO_Last_Group_Lock,
29
+ 0xfe11 => :XK_ISO_Level5_Shift,
30
+ 0xfe12 => :XK_ISO_Level5_Latch,
31
+ 0xfe13 => :XK_ISO_Level5_Lock,
32
+ 0xfe20 => :XK_ISO_Left_Tab,
33
+ 0xfe21 => :XK_ISO_Move_Line_Up,
34
+ 0xfe22 => :XK_ISO_Move_Line_Down,
35
+ 0xfe23 => :XK_ISO_Partial_Line_Up,
36
+ 0xfe24 => :XK_ISO_Partial_Line_Down,
37
+ 0xfe25 => :XK_ISO_Partial_Space_Left,
38
+ 0xfe26 => :XK_ISO_Partial_Space_Right,
39
+ 0xfe27 => :XK_ISO_Set_Margin_Left,
40
+ 0xfe28 => :XK_ISO_Set_Margin_Right,
41
+ 0xfe29 => :XK_ISO_Release_Margin_Left,
42
+ 0xfe2a => :XK_ISO_Release_Margin_Right,
43
+ 0xfe2b => :XK_ISO_Release_Both_Margins,
44
+ 0xfe2c => :XK_ISO_Fast_Cursor_Left,
45
+ 0xfe2d => :XK_ISO_Fast_Cursor_Right,
46
+ 0xfe2e => :XK_ISO_Fast_Cursor_Up,
47
+ 0xfe2f => :XK_ISO_Fast_Cursor_Down,
48
+ 0xfe30 => :XK_ISO_Continuous_Underline,
49
+ 0xfe31 => :XK_ISO_Discontinuous_Underline,
50
+ 0xfe32 => :XK_ISO_Emphasize,
51
+ 0xfe33 => :XK_ISO_Center_Object,
52
+ 0xfe34 => :XK_ISO_Enter,
53
+ 0xff13 => :XK_Pause,
54
+ 0xff14 => :XK_Scroll_Lock,
55
+ 0xff15 => :XK_Sys_Req,
56
+ 0xff1b => :XK_Escape,
57
+ 0xffff => :XK_Delete,
58
+ 0xff20 => :XK_Multi_key,
59
+ 0xff21 => :XK_Kanji,
60
+ 0xff22 => :XK_Muhenkan,
61
+ 0xff23 => :XK_Henkan,
62
+ 0xff24 => :XK_Romaji,
63
+ 0xff25 => :XK_Hiragana,
64
+ 0xff26 => :XK_Katakana,
65
+ 0xff27 => :XK_Hiragana_Katakana,
66
+ 0xff28 => :XK_Zenkaku,
67
+ 0xff29 => :XK_Hankaku,
68
+ 0xff2a => :XK_Zenkaku_Hankaku,
69
+ 0xff2b => :XK_Touroku,
70
+ 0xff2c => :XK_Massyo,
71
+ 0xff2d => :XK_Kana_Lock,
72
+ 0xff2e => :XK_Kana_Shift,
73
+ 0xff2f => :XK_Eisu_Shift,
74
+ 0xff30 => :XK_Eisu_toggle,
75
+ 0xff31 => :Unknown_FF31,
76
+ 0xff34 => :Unknown_FF34,
77
+ 0xff37 => :XK_Codeinput,
78
+ 0xff3c => :XK_SingleCandidate,
79
+ 0xff3d => :XK_MultipleCandidate,
80
+ 0xff3e => :XK_PreviousCandidate,
81
+ 0xff50 => :XK_Home,
82
+ 0xff51 => :XK_Left,
83
+ 0xff52 => :XK_Up,
84
+ 0xff53 => :XK_Right,
85
+ 0xff54 => :XK_Down,
86
+ 0xff55 => :XK_Page_Up,
87
+ 0xff56 => :XK_Page_Down,
88
+ 0xff57 => :XK_End,
89
+ 0xff58 => :XK_Begin,
90
+ 0xff60 => :XK_Select,
91
+ 0xff61 => :XK_Print,
92
+ 0xff62 => :XK_Execute,
93
+ 0xff63 => :XK_Insert,
94
+ 0xff65 => :XK_Undo,
95
+ 0xff66 => :XK_Redo,
96
+ 0xff67 => :XK_Menu,
97
+ 0xff68 => :XK_Find,
98
+ 0xff69 => :XK_Cancel,
99
+ 0xff6a => :XK_Help,
100
+ 0xff6b => :XK_Break,
101
+ 0xff7e => :XK_Mode_switch,
102
+ 0xff7f => :XK_Num_Lock,
103
+ 0xff80 => :XK_KP_Space,
104
+ 0xff89 => :XK_KP_Tab,
105
+ 0xff8d => :XK_KP_Enter,
106
+ 0xff95 => :XK_KP_Home,
107
+ 0xff96 => :XK_KP_Left,
108
+ 0xff97 => :XK_KP_Up,
109
+ 0xff98 => :XK_KP_Right,
110
+ 0xff99 => :XK_KP_Down,
111
+ 0xff9a => :XK_KP_Page_Up,
112
+ 0xff9b => :XK_KP_Page_Down,
113
+ 0xff9c => :XK_KP_End,
114
+ 0xff9d => :XK_KP_Begin,
115
+ 0xff9e => :XK_KP_Insert,
116
+ 0xff9f => :XK_KP_Delete,
117
+ 0xffbd => :XK_KP_Equal,
118
+ 0xffaa => :XK_KP_Multiply,
119
+ 0xffab => :XK_KP_Add,
120
+ 0xffac => :XK_KP_Separator,
121
+ 0xffad => :XK_KP_Subtract,
122
+ 0xffae => :XK_KP_Decimal,
123
+ 0xffaf => :XK_KP_Divide,
124
+
125
+ 0xffe1 => :XK_Shift_L,
126
+ 0xffe2 => :XK_Shift_R,
127
+ 0xffe3 => :XK_Control_L,
128
+ 0xffe4 => :XK_Control_R,
129
+ 0xffe5 => :XK_Caps_Lock,
130
+ 0xffe6 => :XK_Shift_Lock,
131
+ 0xffe7 => :XK_Meta_L,
132
+ 0xffe8 => :XK_Meta_R,
133
+ 0xffe9 => :XK_Alt_L,
134
+ 0xffea => :XK_Alt_R,
135
+ 0xffeb => :XK_Super_L,
136
+ 0xffec => :XK_Super_R,
137
+ 0xffed => :XK_Hyper_L,
138
+ 0xffee => :XK_Hyper_R,
139
+
140
+ 0x1005FF70 => :SunProps,
141
+ 0x1005FF71 => :SunFront,
142
+
143
+ 0x1008FF01 => :XF86XK_ModeLock,
144
+ 0x1008FF02 => :XF86XK_MonBrightnessUp,
145
+ 0x1008FF03 => :XF86XK_MonBrightnessDown,
146
+ 0x1008FF04 => :XF86XK_KbdLightOnOff,
147
+ 0x1008FF05 => :XF86XK_KbdBrightnessUp,
148
+ 0x1008FF06 => :XF86XK_KbdBrightnessDown,
149
+ 0x1008FF07 => :XF86XK_MonBrightnessCycle,
150
+ 0x1008FF10 => :XF86XK_Standby,
151
+ 0x1008FF11 => :XF86XK_AudioLowerVolume,
152
+ 0x1008FF12 => :XF86XK_AudioMute,
153
+ 0x1008FF13 => :XF86XK_AudioRaiseVolume,
154
+ 0x1008FF14 => :XF86XK_AudioPlay,
155
+ 0x1008FF15 => :XF86XK_AudioStop,
156
+ 0x1008FF16 => :XF86XK_AudioPrev,
157
+ 0x1008FF17 => :XF86XK_AudioNext,
158
+ 0x1008FF18 => :XF86XK_HomePage,
159
+ 0x1008FF19 => :XF86XK_Mail,
160
+ 0x1008FF1A => :XF86XK_Start,
161
+ 0x1008FF1B => :XF86XK_Search,
162
+ 0x1008FF1C => :XF86XK_AudioRecord,
163
+ 0x1008FF1D => :XF86XK_Calculator,
164
+ 0x1008FF1E => :XF86XK_Memo,
165
+ 0x1008FF1F => :XF86XK_ToDoList,
166
+ 0x1008FF20 => :XF86XK_Calendar,
167
+ 0x1008FF21 => :XF86XK_PowerDown,
168
+ 0x1008FF22 => :XF86XK_ContrastAdjust,
169
+ 0x1008FF23 => :XF86XK_RockerUp,
170
+ 0x1008FF24 => :XF86XK_RockerDown,
171
+ 0x1008FF25 => :XF86XK_RockerEnter,
172
+ 0x1008FF26 => :XF86XK_Back,
173
+ 0x1008FF27 => :XF86XK_Forward,
174
+ 0x1008FF28 => :XF86XK_Stop,
175
+ 0x1008FF29 => :XF86XK_Refresh,
176
+ 0x1008FF2A => :XF86XK_PowerOff,
177
+ 0x1008FF2B => :XF86XK_WakeUp,
178
+ 0x1008FF2C => :XF86XK_Eject,
179
+ 0x1008FF2D => :XF86XK_ScreenSaver,
180
+ 0x1008FF2E => :XF86XK_WWW,
181
+ 0x1008FF2F => :XF86XK_Sleep,
182
+ 0x1008FF30 => :XF86XK_Favorites,
183
+ 0x1008FF31 => :XF86XK_AudioPause,
184
+ 0x1008FF32 => :XF86XK_AudioMedia,
185
+ 0x1008FF33 => :XF86XK_MyComputer,
186
+ 0x1008FF34 => :XF86XK_VendorHome,
187
+ 0x1008FF35 => :XF86XK_LightBulb,
188
+ 0x1008FF36 => :XF86XK_Shop,
189
+ 0x1008FF37 => :XF86XK_History,
190
+ 0x1008FF38 => :XF86XK_OpenURL,
191
+ 0x1008FF39 => :XF86XK_AddFavorite,
192
+ 0x1008FF3A => :XF86XK_HotLinks,
193
+ 0x1008FF3B => :XF86XK_BrightnessAdjust,
194
+ 0x1008FF3C => :XF86XK_Finance,
195
+ 0x1008FF3D => :XF86XK_Community,
196
+ 0x1008FF3E => :XF86XK_AudioRewind,
197
+ 0x1008FF3F => :XF86XK_BackForward,
198
+ 0x1008FF40 => :XF86XK_Launch0,
199
+ 0x1008FF41 => :XF86XK_Launch1,
200
+ 0x1008FF42 => :XF86XK_Launch2,
201
+ 0x1008FF43 => :XF86XK_Launch3,
202
+ 0x1008FF44 => :XF86XK_Launch4,
203
+ 0x1008FF45 => :XF86XK_Launch5,
204
+ 0x1008FF46 => :XF86XK_Launch6,
205
+ 0x1008FF47 => :XF86XK_Launch7,
206
+ 0x1008FF48 => :XF86XK_Launch8,
207
+ 0x1008FF49 => :XF86XK_Launch9,
208
+ 0x1008FF4A => :XF86XK_LaunchA,
209
+ 0x1008FF4B => :XF86XK_LaunchB,
210
+ 0x1008FF4C => :XF86XK_LaunchC,
211
+ 0x1008FF4D => :XF86XK_LaunchD,
212
+ 0x1008FF4E => :XF86XK_LaunchE,
213
+ 0x1008FF4F => :XF86XK_LaunchF,
214
+ 0x1008FF50 => :XF86XK_ApplicationLeft,
215
+ 0x1008FF51 => :XF86XK_ApplicationRight,
216
+ 0x1008FF52 => :XF86XK_Book,
217
+ 0x1008FF53 => :XF86XK_CD,
218
+ 0x1008FF54 => :XF86XK_Calculater,
219
+ 0x1008FF55 => :XF86XK_Clear,
220
+ 0x1008FF56 => :XF86XK_Close,
221
+ 0x1008FF57 => :XF86XK_Copy,
222
+ 0x1008FF58 => :XF86XK_Cut,
223
+ 0x1008FF59 => :XF86XK_Display,
224
+ 0x1008FF5A => :XF86XK_DOS,
225
+ 0x1008FF5B => :XF86XK_Documents,
226
+ 0x1008FF5C => :XF86XK_Excel,
227
+ 0x1008FF5D => :XF86XK_Explorer,
228
+ 0x1008FF5E => :XF86XK_Game,
229
+ 0x1008FF5F => :XF86XK_Go,
230
+ 0x1008FF60 => :XF86XK_iTouch,
231
+ 0x1008FF61 => :XF86XK_LogOff,
232
+ 0x1008FF62 => :XF86XK_Market,
233
+ 0x1008FF63 => :XF86XK_Meeting,
234
+ 0x1008FF65 => :XF86XK_MenuKB,
235
+ 0x1008FF66 => :XF86XK_MenuPB,
236
+ 0x1008FF67 => :XF86XK_MySites,
237
+ 0x1008FF68 => :XF86XK_New,
238
+ 0x1008FF69 => :XF86XK_News,
239
+ 0x1008FF6A => :XF86XK_OfficeHome,
240
+ 0x1008FF6B => :XF86XK_Open,
241
+ 0x1008FF6C => :XF86XK_Option,
242
+ 0x1008FF6D => :XF86XK_Paste,
243
+ 0x1008FF6E => :XF86XK_Phone,
244
+ 0x1008FF70 => :XF86XK_Q,
245
+ 0x1008FF72 => :XF86XK_Reply,
246
+ 0x1008FF73 => :XF86XK_Reload,
247
+ 0x1008FF74 => :XF86XK_RotateWindows,
248
+ 0x1008FF75 => :XF86XK_RotationPB,
249
+ 0x1008FF76 => :XF86XK_RotationKB,
250
+ 0x1008FF77 => :XF86XK_Save,
251
+ 0x1008FF78 => :XF86XK_ScrollUp,
252
+ 0x1008FF79 => :XF86XK_ScrollDown,
253
+ 0x1008FF7A => :XF86XK_ScrollClick,
254
+ 0x1008FF7B => :XF86XK_Send,
255
+ 0x1008FF7C => :XF86XK_Spell,
256
+ 0x1008FF7D => :XF86XK_SplitScreen,
257
+ 0x1008FF7E => :XF86XK_Support,
258
+ 0x1008FF7F => :XF86XK_TaskPane,
259
+ 0x1008FF80 => :XF86XK_Terminal,
260
+ 0x1008FF81 => :XF86XK_Tools,
261
+ 0x1008FF82 => :XF86XK_Travel,
262
+ 0x1008FF84 => :XF86XK_UserPB,
263
+ 0x1008FF85 => :XF86XK_User1KB,
264
+ 0x1008FF86 => :XF86XK_User2KB,
265
+ 0x1008FF87 => :XF86XK_Video,
266
+ 0x1008FF88 => :XF86XK_WheelButton,
267
+ 0x1008FF89 => :XF86XK_Word,
268
+ 0x1008FF8A => :XF86XK_Xfer,
269
+ 0x1008FF8B => :XF86XK_ZoomIn,
270
+ 0x1008FF8C => :XF86XK_ZoomOut,
271
+ 0x1008FF8D => :XF86XK_Away,
272
+ 0x1008FF8E => :XF86XK_Messenger,
273
+ 0x1008FF8F => :XF86XK_WebCam,
274
+ 0x1008FF90 => :XF86XK_MailForward,
275
+ 0x1008FF91 => :XF86XK_Pictures,
276
+ 0x1008FF92 => :XF86XK_Music,
277
+ 0x1008FF93 => :XF86XK_Battery,
278
+ 0x1008FF94 => :XF86XK_Bluetooth,
279
+ 0x1008FF95 => :XF86XK_WLAN,
280
+ 0x1008FF96 => :XF86XK_UWB,
281
+ 0x1008FF97 => :XF86XK_AudioForward,
282
+ 0x1008FF98 => :XF86XK_AudioRepeat,
283
+ 0x1008FF99 => :XF86XK_AudioRandomPlay,
284
+ 0x1008FF9A => :XF86XK_Subtitle,
285
+ 0x1008FF9B => :XF86XK_AudioCycleTrack,
286
+ 0x1008FF9C => :XF86XK_CycleAngle,
287
+ 0x1008FF9D => :XF86XK_FrameBack,
288
+ 0x1008FF9E => :XF86XK_FrameForward,
289
+ 0x1008FF9F => :XF86XK_Time,
290
+ 0x1008FFA0 => :XF86XK_Select,
291
+ 0x1008FFA1 => :XF86XK_View,
292
+ 0x1008FFA2 => :XF86XK_TopMenu,
293
+ 0x1008FFA3 => :XF86XK_Red,
294
+ 0x1008FFA4 => :XF86XK_Green,
295
+ 0x1008FFA5 => :XF86XK_Yellow,
296
+ 0x1008FFA6 => :XF86XK_Blue,
297
+ 0x1008FFA7 => :XF86XK_Suspend,
298
+ 0x1008FFA8 => :XF86XK_Hibernate,
299
+ 0x1008FFA9 => :XF86XK_TouchpadToggle,
300
+ 0x1008FFB0 => :XF86XK_TouchpadOn,
301
+ 0x1008FFB1 => :XF86XK_TouchpadOff,
302
+ 0x1008FFB2 => :XF86XK_AudioMicMute,
303
+ 0x1008FFB3 => :XF86XK_Keyboard,
304
+ 0x1008FFB4 => :XF86XK_WWAN,
305
+ 0x1008FFB5 => :XF86XK_RFKill,
306
+ 0x1008FFB6 => :XF86XK_AudioPreset,
307
+ 0x1008FFB7 => :XF86XK_RotationLockToggle,
308
+ 0x1008FFB8 => :XF86XK_FullScreen,
309
+ 0x1008FE01 => :XF86XK_Switch_VT_1,
310
+ 0x1008FE02 => :XF86XK_Switch_VT_2,
311
+ 0x1008FE03 => :XF86XK_Switch_VT_3,
312
+ 0x1008FE04 => :XF86XK_Switch_VT_4,
313
+ 0x1008FE05 => :XF86XK_Switch_VT_5,
314
+ 0x1008FE06 => :XF86XK_Switch_VT_6,
315
+ 0x1008FE07 => :XF86XK_Switch_VT_7,
316
+ 0x1008FE08 => :XF86XK_Switch_VT_8,
317
+ 0x1008FE09 => :XF86XK_Switch_VT_9,
318
+ 0x1008FE0A => :XF86XK_Switch_VT_10,
319
+ 0x1008FE0B => :XF86XK_Switch_VT_11,
320
+ 0x1008FE0C => :XF86XK_Switch_VT_12,
321
+ 0x1008FE20 => :XF86XK_Ungrab,
322
+ 0x1008FE21 => :XF86XK_ClearGrab,
323
+ 0x1008FE22 => :XF86XK_Next_VMode,
324
+ 0x1008FE23 => :XF86XK_Prev_VMode,
325
+ 0x1008FE24 => :XF86XK_LogWindowTree,
326
+ 0x1008FE25 => :XF86XK_LogGrabInfo,
327
+ }
328
+ end
@@ -0,0 +1,16 @@
1
+ module X11
2
+ module Protocol
3
+ # endiness of your machine
4
+ BYTE_ORDER = case [1].pack("L")
5
+ when "\0\0\0\1"
6
+ "B".ord
7
+ when "\1\0\0\0"
8
+ "l".ord
9
+ else
10
+ raise ByteOrderError.new "Cannot determine byte order"
11
+ end
12
+
13
+ MAJOR = 11
14
+ MINOR = 0
15
+ end
16
+ end
data/lib/X11/screen.rb ADDED
@@ -0,0 +1,34 @@
1
+ module X11
2
+ class Screen
3
+ attr_reader :display
4
+
5
+ def initialize(display, data)
6
+ @display = display
7
+ @internal = data
8
+ end
9
+
10
+ def root
11
+ @internal.root
12
+ end
13
+
14
+ def root_depth
15
+ @internal.root_depth
16
+ end
17
+
18
+ def root_visual
19
+ @internal.root_visual
20
+ end
21
+
22
+ def width
23
+ @internal.width_in_pixels
24
+ end
25
+
26
+ def height
27
+ @internal.height_in_pixels
28
+ end
29
+
30
+ def to_s
31
+ "#<X11::Screen(#{id}) width=#{width} height=#{height}>"
32
+ end
33
+ end
34
+ end
data/lib/X11/type.rb ADDED
@@ -0,0 +1,116 @@
1
+ # This module is used for encoding Ruby Objects to binary
2
+ # data. The types Int8, Int16, etc. are data-types defined
3
+ # in the X11 protocol. We wrap each data-type in a lambda expression
4
+ # which gets evaluated when a packet is created.
5
+
6
+ module X11
7
+ module Type
8
+
9
+ def self.define(type, directive, bytesize)
10
+ eval %{
11
+ class X11::Type::#{type}
12
+ def self.pack(x)
13
+ [x].pack(\"#{directive}\")
14
+ end
15
+
16
+ def self.unpack(x)
17
+ x.unpack(\"#{directive}\").first
18
+ end
19
+
20
+ def self.size
21
+ #{bytesize}
22
+ end
23
+
24
+ def self.from_packet(sock)
25
+ r = sock.read(size)
26
+ r ? unpack(r) : nil
27
+ end
28
+ end
29
+ }
30
+ end
31
+
32
+ # Primitive Types
33
+ define "Int8", "c", 1
34
+ define "Int16", "s", 2
35
+ define "Int32", "l", 4
36
+ define "Uint8", "C", 1
37
+ define "Uint16", "S", 2
38
+ define "Uint32", "L", 4
39
+
40
+ class String8
41
+ def self.pack(x)
42
+ x.force_encoding("ASCII-8BIT") + "\x00"*(-x.length & 3)
43
+ end
44
+
45
+
46
+
47
+
48
+ def self.unpack(socket, size)
49
+ val = socket.read(size)
50
+ unused_padding = (4 - (size % 4)) % 4
51
+ socket.read(unused_padding)
52
+ val
53
+ end
54
+ end
55
+
56
+ class String16
57
+ def self.pack(x)
58
+ x.encode("UTF-16BE").force_encoding("ASCII-8BIT") + "\x00\x00"*(-x.length & 1)
59
+ end
60
+
61
+ def self.unpack(socket, size)
62
+ val = socket.read(size)
63
+ unused_padding = (4 - (size % 4)) % 4
64
+ socket.read(unused_padding)
65
+ val.force_encoding("UTF-16BE")
66
+ end
67
+ end
68
+
69
+
70
+ class String8Unpadded
71
+ def self.pack(x)
72
+ x
73
+ end
74
+
75
+
76
+ def self.unpack(socket, size)
77
+ val = socket.read(size)
78
+ end
79
+ end
80
+
81
+ class Bool
82
+ def self.pack(x)
83
+ x ? "\x01" : "\x00"
84
+ end
85
+
86
+ def self.unpack(str)
87
+ str[0] == "\x01"
88
+ end
89
+
90
+ def self.size
91
+ 1
92
+ end
93
+ end
94
+
95
+ KeyCode = Uint8
96
+ Signifigance = Uint8
97
+ BitGravity = Uint8
98
+ WinGravity = Uint8
99
+ BackingStore = Uint8
100
+ Bitmask = Uint32
101
+ Window = Uint32
102
+ Pixmap = Uint32
103
+ Cursor = Uint32
104
+ Colornum = Uint32
105
+ Font = Uint32
106
+ Gcontext = Uint32
107
+ Colormap = Uint32
108
+ Drawable = Uint32
109
+ Fontable = Uint32
110
+ Atom = Uint32
111
+ VisualID = Uint32
112
+ Mask = Uint32
113
+ Timestamp = Uint32
114
+ Keysym = Uint32
115
+ end
116
+ end
@@ -0,0 +1,3 @@
1
+ module X11
2
+ VERSION = "0.0.2"
3
+ end
data/lib/X11.rb ADDED
@@ -0,0 +1,12 @@
1
+ module X11
2
+ class X11Error < StandardError; end
3
+ end
4
+
5
+ require 'socket'
6
+ require_relative './X11/protocol'
7
+ require_relative './X11/auth'
8
+ require_relative './X11/display'
9
+ require_relative './X11/screen'
10
+ require_relative './X11/type'
11
+ require_relative './X11/form'
12
+ require_relative './X11/keysyms'
data/ruby-x11.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "X11/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pure-x11"
7
+ s.version = X11::VERSION
8
+ s.authors = ["Vidar Hokstad", "Richard Ramsden"]
9
+ s.email = ["vidar@hokstad.com"]
10
+ s.homepage = ""
11
+ s.summary = "Pure Ruby X11 bindings"
12
+ s.description = "Pure Ruby X11 bindings"
13
+
14
+ #s.rubyforge_project = "ruby-x11"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
data/test/core_test.rb ADDED
@@ -0,0 +1,15 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ describe X11 do
4
+ describe X11::Display do
5
+ before(:each) do
6
+ @display = X11::Display.new
7
+ end
8
+
9
+ it "should generate a unique id" do
10
+ collection = 1000.times.collect { @display.new_id }
11
+ expected = collection.size
12
+ collection.uniq.size.must_equal expected
13
+ end
14
+ end
15
+ end
data/test/form_test.rb ADDED
@@ -0,0 +1,66 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class MockSocket
4
+ def initialize(packet)
5
+ @packet = packet
6
+ end
7
+
8
+ def read(amount)
9
+ @packet.slice!(0..amount-1)
10
+ end
11
+ end
12
+
13
+ class Point < X11::Form::BaseForm
14
+ field :x, Int8
15
+ field :y, Int8
16
+ end
17
+
18
+ class Child < X11::Form::BaseForm
19
+ field :name, Uint16, :length
20
+ field :name, String8, :string
21
+ end
22
+
23
+ class Parent < X11::Form::BaseForm
24
+ field :value, Uint8
25
+ field :point, Point
26
+
27
+ field :name, Uint16, :length
28
+ field :name, String8, :string
29
+
30
+ field :children, Uint16, :length
31
+ field :children, Child, :list
32
+ end
33
+
34
+ describe X11::Form::BaseForm do
35
+ it "setters and getters on form should work" do
36
+
37
+ # we can create partial form objects
38
+ # without specifying all parameters.
39
+ parent = Parent.new(1337)
40
+
41
+ # To fill in the rest of the parameters
42
+ # we use attr_accessors
43
+ parent.name = "Parent Form"
44
+ parent.point = Point.new(0,0)
45
+
46
+ _(parent.point).must_be_instance_of Point
47
+ _(parent.name).must_equal "Parent Form"
48
+
49
+ parent.children = []
50
+ parent.children << Child.new
51
+ parent.children << Child.new
52
+
53
+ assert_equal parent.children.size, 2
54
+ end
55
+
56
+ it "should encode/decode a packet" do
57
+ parent = Parent.new(255,Point.new(23,17), "Parent Form", [])
58
+ socket = MockSocket.new(parent.to_packet)
59
+
60
+ decoded = Parent.from_packet(socket)
61
+ _(decoded.value).must_equal 255
62
+ _(decoded.name).must_equal "Parent Form"
63
+ _(decoded.point.x).must_equal 23
64
+ _(decoded.point.y).must_equal 17
65
+ end
66
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup(:default, :development)
4
+
5
+ require 'minitest/spec'
6
+ require 'minitest/autorun'
7
+
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+
11
+ require 'X11'
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pure-x11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Vidar Hokstad
8
+ - Richard Ramsden
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2023-09-25 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Pure Ruby X11 bindings
15
+ email:
16
+ - vidar@hokstad.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - docs/protocol.pdf
28
+ - example/genie.png
29
+ - example/test.rb
30
+ - lib/X11.rb
31
+ - lib/X11/auth.rb
32
+ - lib/X11/display.rb
33
+ - lib/X11/event.rb
34
+ - lib/X11/form.rb
35
+ - lib/X11/keysyms.rb
36
+ - lib/X11/protocol.rb
37
+ - lib/X11/screen.rb
38
+ - lib/X11/type.rb
39
+ - lib/X11/version.rb
40
+ - ruby-x11.gemspec
41
+ - test/core_test.rb
42
+ - test/form_test.rb
43
+ - test/helper.rb
44
+ homepage: ''
45
+ licenses: []
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.4.10
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Pure Ruby X11 bindings
66
+ test_files: []