aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-08-13 14:00:08 +0100
committerGitHub <noreply@github.com>2024-08-13 14:00:08 +0100
commitd93364ce52d0e75b3984affe446fdd988ca3f7a8 (patch)
tree0d9e6020f28c9615db414d1549f1a2276cc3ef63
parent4c4f24b5f445a7f2c190d09935476406a1dba06a (diff)
parent554b0e5bf7e8e88e80b63f9bdcb0026423b99c45 (diff)
Merge pull request #4049 from IllusionMan1212/xrandr-xinput-xfixes
vendor/x11: added a few procedures for xrandr, xinput, and xfixes
-rw-r--r--vendor/x11/xlib/xlib_const.odin5
-rw-r--r--vendor/x11/xlib/xlib_procs.odin46
-rw-r--r--vendor/x11/xlib/xlib_types.odin188
3 files changed, 234 insertions, 5 deletions
diff --git a/vendor/x11/xlib/xlib_const.odin b/vendor/x11/xlib/xlib_const.odin
index ce31a4e76..0466df76d 100644
--- a/vendor/x11/xlib/xlib_const.odin
+++ b/vendor/x11/xlib/xlib_const.odin
@@ -72,6 +72,11 @@ XkbAllEventsMask :: XkbEventMask {
.ExtensionDeviceNotify,
}
+/* ---- X11/extensions/XI2.h ---------------------------------------------------------*/
+
+XIAllDevices :: 0
+XIAllMasterDevices :: 1
+
/* ---- X11/Xlib.h ---------------------------------------------------------*/
diff --git a/vendor/x11/xlib/xlib_procs.odin b/vendor/x11/xlib/xlib_procs.odin
index 207b3f6bc..b5365e73d 100644
--- a/vendor/x11/xlib/xlib_procs.odin
+++ b/vendor/x11/xlib/xlib_procs.odin
@@ -9,13 +9,49 @@ foreign xlib {
foreign import xcursor "system:Xcursor"
@(default_calling_convention="c", link_prefix="X")
foreign xcursor {
- cursorGetTheme :: proc(display: ^Display) -> cstring ---
- cursorGetDefaultSize :: proc(display: ^Display) -> i32 ---
- cursorLibraryLoadImage :: proc(name: cstring, theme: cstring, size: i32) -> rawptr ---
- cursorImageLoadCursor :: proc(display: ^Display, img: rawptr) -> Cursor ---
- cursorImageDestroy :: proc(img: rawptr) ---
+ cursorGetTheme :: proc(display: ^Display) -> cstring ---
+ cursorGetDefaultSize :: proc(display: ^Display) -> i32 ---
+ cursorLibraryLoadCursor :: proc(display: ^Display, name: cstring) -> Cursor ---
+ cursorLibraryLoadImage :: proc(name: cstring, theme: cstring, size: i32) -> rawptr ---
+ cursorImageLoadCursor :: proc(display: ^Display, img: rawptr) -> Cursor ---
+ cursorImageDestroy :: proc(img: rawptr) ---
}
+foreign import xfixes "system:Xfixes"
+@(default_calling_convention="c", link_prefix="XFixes")
+foreign xfixes {
+ HideCursor :: proc(display: ^Display, window: Window) ---
+ ShowCursor :: proc(display: ^Display, window: Window) ---
+}
+
+foreign import xrandr "system:Xrandr"
+@(default_calling_convention="c")
+foreign xrandr {
+ XRRSizes :: proc(display: ^Display, screen: i32, nsizes: ^i32) -> [^]XRRScreenSize ---
+ XRRGetScreenResources :: proc(display: ^Display, window: Window) -> ^XRRScreenResources ---
+ XRRFreeScreenResources :: proc(resources: ^XRRScreenResources) ---
+ XRRGetOutputInfo :: proc(display: ^Display, resources: ^XRRScreenResources, output: RROutput) -> ^XRROutputInfo ---
+ XRRFreeOutputInfo :: proc(output_info: ^XRROutputInfo) ---
+ XRRGetCrtcInfo :: proc(display: ^Display, resources: ^XRRScreenResources, crtc: RRCrtc) -> ^XRRCrtcInfo ---
+ XRRFreeCrtcInfo :: proc(crtc_info: ^XRRCrtcInfo) ---
+ XRRGetMonitors :: proc(dpy: ^Display, window: Window, get_active: b32, nmonitors: ^i32) -> [^]XRRMonitorInfo ---
+}
+
+foreign import xinput "system:Xi"
+foreign xinput {
+ XISelectEvents :: proc(display: ^Display, window: Window, masks: [^]XIEventMask, num_masks: i32) -> i32 ---
+ XIQueryVersion :: proc(display: ^Display, major: ^i32, minor: ^i32) -> Status ---
+}
+
+XISetMask :: proc(ptr: [^]u8, event: XIEventType) {
+ ptr[cast(i32)event >> 3] |= (1 << cast(uint)((cast(i32)event) & 7))
+}
+
+XIMaskIsSet :: proc(ptr: [^]u8, event: i32) -> bool {
+ return (ptr[event >> 3] & (1 << cast(uint)((event) & 7))) != 0
+}
+
+
/* ---- X11/Xlib.h ---------------------------------------------------------*/
@(default_calling_convention="c", link_prefix="X")
diff --git a/vendor/x11/xlib/xlib_types.odin b/vendor/x11/xlib/xlib_types.odin
index d2bd2c5a3..b5de824e9 100644
--- a/vendor/x11/xlib/xlib_types.odin
+++ b/vendor/x11/xlib/xlib_types.odin
@@ -26,6 +26,7 @@ GContext :: XID
RRCrtc :: XID
RROutput :: XID
+RRMode :: XID
KeyCode :: u8
@@ -2069,3 +2070,190 @@ XrmOptionDescRec :: struct {
}
XrmOptionDescList :: [^]XrmOptionDescRec
+
+/* ---- X11/extensions/Xrandr.h ---------------------------------------------------------*/
+
+XRRModeFlags :: bit_set[XRRModeBits;u64]
+XRRModeBits :: enum u8 {
+ RR_HSyncPositive = 0,
+ RR_HSyncNegative = 1,
+ RR_VSyncPositive = 2,
+ RR_VSyncNegative = 3,
+ RR_Interlace = 4,
+ RR_DoubleScan = 5,
+ RR_CSync = 6,
+ RR_CSyncPositive = 7,
+ RR_CSyncNegative = 8,
+ RR_HSkewPresent = 9,
+ RR_BCast = 10,
+ RR_PixelMultiplex = 11,
+ RR_DoubleClock = 12,
+ RR_ClockDivideBy2 = 13,
+}
+
+Rotation :: enum u16 {
+ Rotate_0 = 1,
+ Rotate_90 = 2,
+ Rotate_180 = 4,
+ Rotate_270 = 8,
+}
+
+Connection :: enum u16 {
+ RR_Connected = 0,
+ RR_Disconnected = 1,
+ RR_UnknownConnection = 2,
+}
+
+SubpixelOrder :: enum u16 {
+ Unknown = 0,
+ HorizontalRGB = 1,
+ HorizontalBGR = 2,
+ VerticalRGB = 3,
+ VerticalBGR = 4,
+ None = 5,
+}
+
+XRRModeInfo :: struct {
+ id: RRMode,
+ width: u32,
+ height: u32,
+ dotClock: u64,
+ hSyncStart: u32,
+ hSyncEnd: u32,
+ hTotal: u32,
+ hSkew: u32,
+ vSyncStart: u32,
+ vSyncEnd: u32,
+ vTotal: u32,
+ name: cstring,
+ nameLength: u32,
+ modeFlags: XRRModeFlags,
+}
+
+XRRScreenSize :: struct {
+ width, height: i32,
+ mwidth, mheight: i32,
+}
+
+XRRScreenResources :: struct {
+ timestamp: Time,
+ configTimestamp: Time,
+ ncrtc: i32,
+ crtcs: [^]RRCrtc,
+ noutput: i32,
+ outputs: [^]RROutput,
+ nmode: i32,
+ modes: [^]XRRModeInfo,
+}
+
+XRROutputInfo :: struct {
+ timestamp: Time,
+ crtc: RRCrtc,
+ name: cstring,
+ nameLen: i32,
+ mm_width: u64,
+ mm_height: u64,
+ connection: Connection,
+ subpixel_order: SubpixelOrder,
+ ncrtc: i32,
+ crtcs: [^]RRCrtc,
+ nclone: i32,
+ clones: [^]RROutput,
+ nmode: i32,
+ npreferred: i32,
+ modes: [^]RRMode,
+}
+
+XRRCrtcInfo :: struct {
+ timestamp: Time,
+ x, y: i32,
+ width, height: u32,
+ mode: RRMode,
+ rotation: Rotation,
+ noutput: i32,
+ outputs: [^]RROutput,
+ rotations: Rotation,
+ npossible: i32,
+ possible: [^]RROutput,
+}
+
+XRRMonitorInfo :: struct {
+ name: Atom,
+ primary: b32,
+ automatic: b32,
+ noutput: i32,
+ x: i32,
+ y: i32,
+ width: i32,
+ height: i32,
+ mwidth: i32,
+ mheight: i32,
+ outputs: [^]RROutput,
+}
+
+/* ---- X11/extensions/XInput2.h ---------------------------------------------------------*/
+
+XIEventType :: enum i32 {
+ DeviceChanged = 1,
+ KeyPress,
+ KeyRelease,
+ ButtonPress,
+ ButtonRelease,
+ Motion,
+ Enter,
+ Leave,
+ FocusIn,
+ FocusOut,
+ HierarchyChanged,
+ Property,
+ RawKeyPress,
+ RawKeyRelease,
+ RawButtonPress,
+ RawButtonRelease,
+ RawMotion,
+ TouchBegin,
+ TouchUpdate,
+ TouchEnd,
+ TouchOwnership,
+ RawTouchBegin,
+ RawTouchUpdate,
+ RawTouchEnd,
+ BarrierHit,
+ BarrierLeave,
+ GesturePinchBegin,
+ GesturePinchUpdate,
+ GesturePinchEnd,
+ GestureSwipeBegin,
+ GestureSwipeUpdate,
+ GestureSwipeEnd,
+ LastEvent = GestureSwipeEnd,
+}
+
+XIEventMask :: struct {
+ deviceid: i32,
+ mask_len: i32,
+ mask: [^]u8,
+}
+
+XIValuatorState :: struct {
+ mask_len: i32,
+ mask: [^]u8,
+ values: [^]f64,
+}
+
+XIRawEvent :: struct {
+ type: EventType,
+ serial: u64,
+ send_event: b32,
+ display: ^Display,
+ extension: i32,
+ evtype: XIEventType,
+ time: Time,
+ deviceid: i32,
+ sourceid: i32,
+ detail: i32,
+ flags: i32,
+ valuators: XIValuatorState,
+ raw_values: [^]f64,
+}
+