v2 / vlib / x / x11 / x11.v
136 lines · 119 sloc · 2.84 KB · 5d6de17f708abcf79877f70e677d60a4e23bb727
Raw
1// X11 type definitions - shared across all V modules
2// Import this module instead of defining X11 types yourself
3module x11
4
5// Basic X11 types
6pub type Window = u64
7pub type Atom = u64
8pub type VisualID = usize
9pub type Time = u64
10pub type Colormap = u64
11
12// Forward declarations
13pub struct C.Display {}
14
15// X11 event types
16@[typedef]
17pub struct C.XSelectionRequestEvent {
18pub mut:
19 display &C.Display = unsafe { nil }
20 owner Window
21 requestor Window
22 selection Atom
23 target Atom
24 property Atom
25 time int
26}
27
28@[typedef]
29pub struct C.XSelectionEvent {
30pub mut:
31 type int
32 display &C.Display = unsafe { nil }
33 requestor Window
34 selection Atom
35 target Atom
36 property Atom
37 time int
38}
39
40@[typedef]
41pub struct C.XSelectionClearEvent {
42pub mut:
43 window Window
44 selection Atom
45}
46
47@[typedef]
48pub struct C.XDestroyWindowEvent {
49pub mut:
50 window Window
51}
52
53@[typedef]
54pub struct C.XPropertyEvent {
55pub mut:
56 state int
57 atom Atom
58}
59
60@[typedef]
61pub struct C.XClientMessageEvent {
62pub mut:
63 window Window
64 format int
65 message_type Atom
66 data C.XClientMessageData
67}
68
69@[typedef]
70pub union C.XClientMessageData {
71pub mut:
72 b [20]u8
73 s [10]i16
74 l [5]i64
75}
76
77@[typedef]
78pub struct C.XGenericEventCookie {
79pub mut:
80 extension int
81 evtype int
82 data voidptr
83}
84
85@[typedef]
86pub struct C.XKeyEvent {
87pub mut:
88 keycode u32
89 state u32
90}
91
92@[typedef]
93pub struct C.XButtonEvent {
94pub mut:
95 button u32
96 state u32
97 x int
98 y int
99}
100
101@[typedef]
102pub struct C.XMotionEvent {
103pub mut:
104 x int
105 y int
106 state u32
107}
108
109@[typedef]
110pub struct C.XCrossingEvent {
111pub mut:
112 x int
113 y int
114 state u32
115}
116
117@[typedef]
118pub struct C.XFocusChangeEvent {
119pub mut:
120 mode int
121}
122
123// Main XEvent union - each module should define this themselves based on their needs
124// pub union C.XEvent { ... }
125
126// X11 function declarations
127pub fn C.XNextEvent(display &C.Display, event &C.XEvent) int
128pub fn C.XCheckTypedWindowEvent(display &C.Display, window Window, event_type int, event &C.XEvent) int
129pub fn C.XSendEvent(display &C.Display, window Window, propagate int, event_mask i64, event &C.XEvent) int
130pub fn C.XFilterEvent(event &C.XEvent, window Window) int
131pub fn C.XChangeProperty(display &C.Display, window Window, property Atom, type_ Atom, format int, mode int, data &u8, nitems int) int
132pub fn C.XConvertSelection(display &C.Display, selection Atom, target Atom, property Atom, requestor Window, time Time) int
133pub fn C.XSetSelectionOwner(display &C.Display, selection Atom, window Window, time Time) Window
134pub fn C.XGetSelectionOwner(display &C.Display, selection Atom) Window
135pub fn C.XDeleteProperty(display &C.Display, window Window, property Atom) int
136pub fn C.XGetWindowProperty(display &C.Display, window Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type &Atom, actual_format &int, nitems &u64, bytes_after &u64, data &&u8) int
137