| 1 | // X11 type definitions - shared across all V modules |
| 2 | // Import this module instead of defining X11 types yourself |
| 3 | module x11 |
| 4 | |
| 5 | // Basic X11 types |
| 6 | pub type Window = u64 |
| 7 | pub type Atom = u64 |
| 8 | pub type VisualID = usize |
| 9 | pub type Time = u64 |
| 10 | pub type Colormap = u64 |
| 11 | |
| 12 | // Forward declarations |
| 13 | pub struct C.Display {} |
| 14 | |
| 15 | // X11 event types |
| 16 | @[typedef] |
| 17 | pub struct C.XSelectionRequestEvent { |
| 18 | pub 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] |
| 29 | pub struct C.XSelectionEvent { |
| 30 | pub 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] |
| 41 | pub struct C.XSelectionClearEvent { |
| 42 | pub mut: |
| 43 | window Window |
| 44 | selection Atom |
| 45 | } |
| 46 | |
| 47 | @[typedef] |
| 48 | pub struct C.XDestroyWindowEvent { |
| 49 | pub mut: |
| 50 | window Window |
| 51 | } |
| 52 | |
| 53 | @[typedef] |
| 54 | pub struct C.XPropertyEvent { |
| 55 | pub mut: |
| 56 | state int |
| 57 | atom Atom |
| 58 | } |
| 59 | |
| 60 | @[typedef] |
| 61 | pub struct C.XClientMessageEvent { |
| 62 | pub mut: |
| 63 | window Window |
| 64 | format int |
| 65 | message_type Atom |
| 66 | data C.XClientMessageData |
| 67 | } |
| 68 | |
| 69 | @[typedef] |
| 70 | pub union C.XClientMessageData { |
| 71 | pub mut: |
| 72 | b [20]u8 |
| 73 | s [10]i16 |
| 74 | l [5]i64 |
| 75 | } |
| 76 | |
| 77 | @[typedef] |
| 78 | pub struct C.XGenericEventCookie { |
| 79 | pub mut: |
| 80 | extension int |
| 81 | evtype int |
| 82 | data voidptr |
| 83 | } |
| 84 | |
| 85 | @[typedef] |
| 86 | pub struct C.XKeyEvent { |
| 87 | pub mut: |
| 88 | keycode u32 |
| 89 | state u32 |
| 90 | } |
| 91 | |
| 92 | @[typedef] |
| 93 | pub struct C.XButtonEvent { |
| 94 | pub mut: |
| 95 | button u32 |
| 96 | state u32 |
| 97 | x int |
| 98 | y int |
| 99 | } |
| 100 | |
| 101 | @[typedef] |
| 102 | pub struct C.XMotionEvent { |
| 103 | pub mut: |
| 104 | x int |
| 105 | y int |
| 106 | state u32 |
| 107 | } |
| 108 | |
| 109 | @[typedef] |
| 110 | pub struct C.XCrossingEvent { |
| 111 | pub mut: |
| 112 | x int |
| 113 | y int |
| 114 | state u32 |
| 115 | } |
| 116 | |
| 117 | @[typedef] |
| 118 | pub struct C.XFocusChangeEvent { |
| 119 | pub 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 |
| 127 | pub fn C.XNextEvent(display &C.Display, event &C.XEvent) int |
| 128 | pub fn C.XCheckTypedWindowEvent(display &C.Display, window Window, event_type int, event &C.XEvent) int |
| 129 | pub fn C.XSendEvent(display &C.Display, window Window, propagate int, event_mask i64, event &C.XEvent) int |
| 130 | pub fn C.XFilterEvent(event &C.XEvent, window Window) int |
| 131 | pub fn C.XChangeProperty(display &C.Display, window Window, property Atom, type_ Atom, format int, mode int, data &u8, nitems int) int |
| 132 | pub fn C.XConvertSelection(display &C.Display, selection Atom, target Atom, property Atom, requestor Window, time Time) int |
| 133 | pub fn C.XSetSelectionOwner(display &C.Display, selection Atom, window Window, time Time) Window |
| 134 | pub fn C.XGetSelectionOwner(display &C.Display, selection Atom) Window |
| 135 | pub fn C.XDeleteProperty(display &C.Display, window Window, property Atom) int |
| 136 | pub 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 | |