libx11 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -5
  3. data/.travis.yml +1 -1
  4. data/Rakefile +1 -9
  5. data/example/aliases.rb +2 -0
  6. data/example/create_window.rb +15 -13
  7. data/example/window_manager.rb +30 -22
  8. data/lib/libx11.rb +4 -2
  9. data/lib/libx11/keysymdef.rb +2272 -0
  10. data/lib/libx11/version.rb +1 -1
  11. data/lib/libx11/x.rb +148 -0
  12. data/lib/libx11/xlib.rb +42 -0
  13. data/lib/libx11/xlib/display.rb +52 -0
  14. data/lib/libx11/xlib/xany_event.rb +13 -0
  15. data/lib/libx11/xlib/xbutton_event.rb +23 -0
  16. data/lib/libx11/xlib/xcirculate_event.rb +15 -0
  17. data/lib/libx11/xlib/xcirculate_request_event.rb +15 -0
  18. data/lib/libx11/xlib/xclient_message_event.rb +24 -0
  19. data/lib/libx11/xlib/xcolormap_event.rb +16 -0
  20. data/lib/libx11/xlib/xconfigure_event.rb +21 -0
  21. data/lib/libx11/xlib/xconfigure_request_event.rb +22 -0
  22. data/lib/libx11/xlib/xcreate_window_event.rb +20 -0
  23. data/lib/libx11/xlib/xcrossing_event.rb +25 -0
  24. data/lib/libx11/xlib/xdestroy_window_event.rb +14 -0
  25. data/lib/libx11/xlib/xerror_event.rb +15 -0
  26. data/lib/libx11/xlib/xevent.rb +77 -0
  27. data/lib/libx11/xlib/xexpose_event.rb +18 -0
  28. data/lib/libx11/xlib/xfocus_change_event.rb +15 -0
  29. data/lib/libx11/xlib/xgeneric_event.rb +14 -0
  30. data/lib/libx11/xlib/xgeneric_event_cookie.rb +16 -0
  31. data/lib/libx11/xlib/xgraphics_expose_event.rb +21 -0
  32. data/lib/libx11/xlib/xgravity_event.rb +16 -0
  33. data/lib/libx11/xlib/xkey_event.rb +23 -0
  34. data/lib/libx11/xlib/xkeymap_event.rb +14 -0
  35. data/lib/libx11/xlib/xmap_event.rb +15 -0
  36. data/lib/libx11/xlib/xmap_request_event.rb +18 -0
  37. data/lib/libx11/xlib/xmapping_event.rb +16 -0
  38. data/lib/libx11/xlib/xmotion_event.rb +23 -0
  39. data/lib/libx11/xlib/xno_expose_event.rb +15 -0
  40. data/lib/libx11/xlib/xproperty_event.rb +16 -0
  41. data/lib/libx11/xlib/xreparent_event.rb +18 -0
  42. data/lib/libx11/xlib/xresize_request_event.rb +15 -0
  43. data/lib/libx11/xlib/xselection_clear_event.rb +15 -0
  44. data/lib/libx11/xlib/xselection_event.rb +17 -0
  45. data/lib/libx11/xlib/xselection_request_event.rb +18 -0
  46. data/lib/libx11/xlib/xunmap_event.rb +15 -0
  47. data/lib/libx11/xlib/xvisibility_event.rb +14 -0
  48. data/libx11.gemspec +1 -1
  49. metadata +56 -13
  50. data/HACKING.md +0 -14
  51. data/ext/libx11_ruby/constants.c +0 -182
  52. data/ext/libx11_ruby/display.c +0 -197
  53. data/ext/libx11_ruby/extconf.rb +0 -6
  54. data/ext/libx11_ruby/libx11_ruby.c +0 -13
  55. data/ext/libx11_ruby/libx11_ruby.h +0 -14
  56. data/ext/libx11_ruby/window.c +0 -33
  57. data/ext/libx11_ruby/xerror_event.c +0 -104
  58. data/ext/libx11_ruby/xevent.c +0 -134
@@ -1,3 +1,3 @@
1
1
  module LibX11
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,148 @@
1
+ module LibX11
2
+ module X
3
+ #****************************************************************
4
+ # RESERVED RESOURCE AND CONSTANT DEFINITIONS
5
+ #****************************************************************
6
+
7
+ None = 0 # universal null resource or null atom
8
+ ParentRelative = 1 # background pixmap in CreateWindow and ChangeWindowAttributes
9
+ CopyFromParent = 0 # border pixmap in CreateWindow and ChangeWindowAttributes special
10
+ # VisualID and special window class passed to CreateWindow
11
+ PointerWindow = 0 # destination window in SendEvent
12
+ InputFocus = 1 # destination window in SendEvent
13
+ PointerRoot = 1 # focus window in SetInputFocus
14
+ AnyPropertyType = 0 # special Atom, passed to GetProperty
15
+ AnyKey = 0 # special Key Code, passed to GrabKey
16
+ AnyButton = 0 # special Button Code, passed to GrabButton
17
+ AllTemporary = 0 # special Resource ID passed to KillClient
18
+ CurrentTime = 0 # special Time
19
+ NoSymbol = 0 # special KeySym
20
+
21
+ #***************************************************************
22
+ # EVENT DEFINITIONS
23
+ #***************************************************************
24
+
25
+ # Input Event Masks. Used as event-mask window attribute and as arguments
26
+ # to Grab requests. Not to be confused with event names.
27
+
28
+ NoEventMask = 0
29
+ KeyPressMask = (1<<0)
30
+ KeyReleaseMask = (1<<1)
31
+ ButtonPressMask = (1<<2)
32
+ ButtonReleaseMask = (1<<3)
33
+ EnterWindowMask = (1<<4)
34
+ LeaveWindowMask = (1<<5)
35
+ PointerMotionMask = (1<<6)
36
+ PointerMotionHintMask = (1<<7)
37
+ Button1MotionMask = (1<<8)
38
+ Button2MotionMask = (1<<9)
39
+ Button3MotionMask = (1<<10)
40
+ Button4MotionMask = (1<<11)
41
+ Button5MotionMask = (1<<12)
42
+ ButtonMotionMask = (1<<13)
43
+ KeymapStateMask = (1<<14)
44
+ ExposureMask = (1<<15)
45
+ VisibilityChangeMask = (1<<16)
46
+ StructureNotifyMask = (1<<17)
47
+ ResizeRedirectMask = (1<<18)
48
+ SubstructureNotifyMask = (1<<19)
49
+ SubstructureRedirectMask = (1<<20)
50
+ FocusChangeMask = (1<<21)
51
+ PropertyChangeMask = (1<<22)
52
+ ColormapChangeMask = (1<<23)
53
+ OwnerGrabButtonMask = (1<<24)
54
+
55
+ # Event names. Used in "type" field in XEvent structures. Not to be
56
+ # confused with event masks above. They start from 2 because 0 and 1
57
+ # are reserved in the protocol for errors and replies.
58
+
59
+ KeyPress = 2
60
+ KeyRelease = 3
61
+ ButtonPress = 4
62
+ ButtonRelease = 5
63
+ MotionNotify = 6
64
+ EnterNotify = 7
65
+ LeaveNotify = 8
66
+ FocusIn = 9
67
+ FocusOut = 10
68
+ KeymapNotify = 11
69
+ Expose = 12
70
+ GraphicsExpose = 13
71
+ NoExpose = 14
72
+ VisibilityNotify = 15
73
+ CreateNotify = 16
74
+ DestroyNotify = 17
75
+ UnmapNotify = 18
76
+ MapNotify = 19
77
+ MapRequest = 20
78
+ ReparentNotify = 21
79
+ ConfigureNotify = 22
80
+ ConfigureRequest = 23
81
+ GravityNotify = 24
82
+ ResizeRequest = 25
83
+ CirculateNotify = 26
84
+ CirculateRequest = 27
85
+ PropertyNotify = 28
86
+ SelectionClear = 29
87
+ SelectionRequest = 30
88
+ SelectionNotify = 31
89
+ ColormapNotify = 32
90
+ ClientMessage = 33
91
+ MappingNotify = 34
92
+ GenericEvent = 35
93
+ LASTEvent = 36
94
+
95
+ # Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
96
+ # state in various key-, mouse-, and button-related events.
97
+
98
+ ShiftMask = (1<<0)
99
+ LockMask = (1<<1)
100
+ ControlMask = (1<<2)
101
+ Mod1Mask = (1<<3)
102
+ Mod2Mask = (1<<4)
103
+ Mod3Mask = (1<<5)
104
+ Mod4Mask = (1<<6)
105
+ Mod5Mask = (1<<7)
106
+
107
+ # button masks. Used in same manner as Key masks above. Not to be confused
108
+ # with button names below.
109
+
110
+ Button1Mask = (1<<8)
111
+ Button2Mask = (1<<9)
112
+ Button3Mask = (1<<10)
113
+ Button4Mask = (1<<11)
114
+ Button5Mask = (1<<12)
115
+ AnyModifier = (1<<15)
116
+
117
+ # GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes
118
+
119
+ GrabModeSync = 0
120
+ GrabModeAsync = 1
121
+
122
+ #****************************************************************
123
+ # ERROR CODES
124
+ #****************************************************************
125
+
126
+ Success = 0
127
+ BadRequest = 1
128
+ BadValue = 2
129
+ BadWindow = 3
130
+ BadPixmap = 4
131
+ BadAtom = 5
132
+ BadCursor = 6
133
+ BadFont = 7
134
+ BadMatch = 8
135
+ BadDrawable = 9
136
+ BadAccess = 10
137
+ BadAlloc = 11
138
+ BadColor = 12
139
+ BadGC = 13
140
+ BadIDChoice = 14
141
+ BadName = 15
142
+ BadLength = 16
143
+ BadImplementation = 17
144
+
145
+ FirstExtensionError = 128
146
+ LastExtensionError = 255
147
+ end
148
+ end
@@ -0,0 +1,42 @@
1
+ module LibX11
2
+ module Xlib
3
+ extend FFI::Library
4
+
5
+ ffi_lib 'X11'
6
+
7
+ typedef :int, :Bool
8
+ typedef :uchar, :KeyCode
9
+ typedef :ulong, :Atom
10
+ typedef :ulong, :Time
11
+ typedef :ulong, :XID
12
+ typedef :XID, :Colormap
13
+ typedef :XID, :Drawable
14
+ typedef :XID, :KeySym
15
+ typedef :XID, :Window
16
+
17
+ require 'libx11/xlib/display'
18
+ require 'libx11/xlib/xevent'
19
+
20
+ callback :XErrorHandler, [Display.ptr, XErrorEvent.ptr], :int
21
+
22
+ attach_function :XOpenDisplay, [:string], Display.ptr
23
+ attach_function :XCreateSimpleWindow, [Display.ptr, :Window, :int, :int, :uint, :uint, :uint, :ulong, :ulong], :Window
24
+ attach_function :XLookupKeysym, [XKeyEvent.ptr, :int], :KeySym
25
+ attach_function :XDefaultRootWindow, [Display.ptr], :Window
26
+ attach_function :XBlackPixel, [Display.ptr, :int], :ulong
27
+ attach_function :XWhitePixel, [Display.ptr, :int], :ulong
28
+ attach_function :XDisplayString, [Display.ptr], :string
29
+ attach_function :XSetErrorHandler, [:XErrorHandler], :XErrorHandler
30
+ attach_function :XCloseDisplay, [Display.ptr], :int
31
+ attach_function :XConnectionNumber, [Display.ptr], :int
32
+ attach_function :XDefaultScreen, [Display.ptr], :int
33
+ attach_function :XDestroyWindow, [Display.ptr, :Window], :int
34
+ attach_function :XGrabKey, [Display.ptr, :int, :uint, :Window, :Bool, :int, :int], :int
35
+ attach_function :XKeysymToKeycode, [Display.ptr, :KeySym], :KeyCode
36
+ attach_function :XMapWindow, [Display.ptr, :Window], :int
37
+ attach_function :XNextEvent, [Display.ptr, XEvent.ptr], :int, blocking: true
38
+ attach_function :XSelectInput, [Display.ptr, :Window, :long], :int
39
+ attach_function :XSync, [Display.ptr, :Bool], :int, blocking: true
40
+ attach_function :XUngrabKey, [Display.ptr, :int, :uint, :Window], :int
41
+ end
42
+ end
@@ -0,0 +1,52 @@
1
+ module LibX11
2
+ module Xlib
3
+ class Display < FFI::Struct
4
+ layout(
5
+ :ext_data, :pointer,
6
+ :private1, :pointer,
7
+ :fd, :int,
8
+ :private2, :int,
9
+ :proto_major_version, :int,
10
+ :proto_minor_version, :int,
11
+ :vendor, :string,
12
+ :private3, :XID,
13
+ :private4, :XID,
14
+ :private5, :XID,
15
+ :private6, :int,
16
+ :resource_alloc, :pointer,
17
+ :byte_order, :int,
18
+ :bitmap_unit, :int,
19
+ :bitmap_pad, :int,
20
+ :bitmap_bit_order, :int,
21
+ :nformats, :int,
22
+ :pixmap_format, :pointer,
23
+ :private8, :int,
24
+ :release, :int,
25
+ :private9, :pointer,
26
+ :private10, :pointer,
27
+ :qlen, :int,
28
+ :last_request_read, :ulong,
29
+ :request, :ulong,
30
+ :private11, :pointer,
31
+ :private12, :pointer,
32
+ :private13, :pointer,
33
+ :private14, :pointer,
34
+ :max_request_size, :uint,
35
+ :db, :pointer,
36
+ :private15, :pointer,
37
+ :display_name, :string,
38
+ :default_screen, :int,
39
+ :nscreens, :int,
40
+ :screens, :pointer,
41
+ :motion_buffer, :ulong,
42
+ :private16, :ulong,
43
+ :min_keycode, :int,
44
+ :max_keycode, :int,
45
+ :private17, :pointer,
46
+ :private18, :pointer,
47
+ :private19, :int,
48
+ :xdefaults, :string,
49
+ )
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XAnyEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :window, :Window,
10
+ )
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XButtonEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :window, :Window,
10
+ :root, :Window,
11
+ :subwindow, :Window,
12
+ :time, :Time,
13
+ :x, :int,
14
+ :y, :int,
15
+ :x_root, :int,
16
+ :y_root, :int,
17
+ :state, :uint,
18
+ :button, :uint,
19
+ :same_screen, :Bool,
20
+ )
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XCirculateEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :event, :Window,
10
+ :window, :Window,
11
+ :place, :int,
12
+ )
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XCirculateRequestEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :event, :Window,
10
+ :window, :Window,
11
+ :place, :int,
12
+ )
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XClientMessageEvent < FFI::Struct
4
+ class Data < FFI::Union
5
+ layout(
6
+ :b, [:char, 20],
7
+ :s, [:short, 10],
8
+ :l, [:long, 5],
9
+ )
10
+ end
11
+
12
+ layout(
13
+ :type, :int,
14
+ :serial, :ulong,
15
+ :send_event, :Bool,
16
+ :display, :pointer,
17
+ :window, :Window,
18
+ :message_type, :Atom,
19
+ :format, :int,
20
+ :data, Data,
21
+ )
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XColormapEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :window, :Window,
10
+ :colormap, :Colormap,
11
+ :new, :Bool,
12
+ :state, :int,
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XConfigureEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :event, :Window,
10
+ :window, :Window,
11
+ :x, :int,
12
+ :y, :int,
13
+ :width, :int,
14
+ :height, :int,
15
+ :border_width, :int,
16
+ :above, :Window,
17
+ :override_redirect, :Bool,
18
+ )
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XConfigureRequestEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :event, :Window,
10
+ :window, :Window,
11
+ :x, :int,
12
+ :y, :int,
13
+ :width, :int,
14
+ :height, :int,
15
+ :border_width, :int,
16
+ :above, :Window,
17
+ :detail, :int,
18
+ :value_mask, :ulong,
19
+ )
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XCreateWindowEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :parent, :Window,
10
+ :window, :Window,
11
+ :x, :int,
12
+ :y, :int,
13
+ :width, :int,
14
+ :height, :int,
15
+ :border_width, :int,
16
+ :override_redirect, :Bool,
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module LibX11
2
+ module Xlib
3
+ class XCrossingEvent < FFI::Struct
4
+ layout(
5
+ :type, :int,
6
+ :serial, :ulong,
7
+ :send_event, :Bool,
8
+ :display, Display.ptr,
9
+ :window, :Window,
10
+ :root, :Window,
11
+ :subwindow, :Window,
12
+ :time, :Time,
13
+ :x, :int,
14
+ :y, :int,
15
+ :x_root, :int,
16
+ :y_root, :int,
17
+ :mode, :int,
18
+ :detail, :int,
19
+ :same_screen, :Bool,
20
+ :focus, :Bool,
21
+ :state, :uint
22
+ )
23
+ end
24
+ end
25
+ end