@@ -5,7 +5,6 @@ namespace ObsKit.NET.Platform.Linux.Interop;
55
66/// <summary>
77/// P/Invoke bindings for X11 functions.
8- /// Note: These are basic bindings. Full X11 support would require more comprehensive bindings.
98/// </summary>
109[ SupportedOSPlatform ( "linux" ) ]
1110internal static partial class X11
@@ -38,6 +37,58 @@ internal static partial class X11
3837
3938 #endregion
4039
40+ #region Window
41+
42+ [ LibraryImport ( LibX11 , EntryPoint = "XQueryTree" ) ]
43+ internal static partial int XQueryTree (
44+ nint display ,
45+ nint window ,
46+ out nint rootReturn ,
47+ out nint parentReturn ,
48+ out nint childrenReturn ,
49+ out uint nChildren ) ;
50+
51+ [ LibraryImport ( LibX11 , EntryPoint = "XFree" ) ]
52+ internal static partial int XFree ( nint data ) ;
53+
54+ [ LibraryImport ( LibX11 , EntryPoint = "XGetWindowAttributes" ) ]
55+ internal static partial int XGetWindowAttributes ( nint display , nint window , out XWindowAttributes attributes ) ;
56+
57+ [ LibraryImport ( LibX11 , EntryPoint = "XFetchName" ) ]
58+ internal static partial int XFetchName ( nint display , nint window , out nint windowName ) ;
59+
60+ [ LibraryImport ( LibX11 , EntryPoint = "XGetClassHint" ) ]
61+ internal static partial int XGetClassHint ( nint display , nint window , out XClassHint classHint ) ;
62+
63+ [ LibraryImport ( LibX11 , EntryPoint = "XInternAtom" , StringMarshalling = StringMarshalling . Utf8 ) ]
64+ internal static partial nint XInternAtom ( nint display , string atomName , [ MarshalAs ( UnmanagedType . Bool ) ] bool onlyIfExists ) ;
65+
66+ [ LibraryImport ( LibX11 , EntryPoint = "XGetWindowProperty" ) ]
67+ internal static partial int XGetWindowProperty (
68+ nint display ,
69+ nint window ,
70+ nint property ,
71+ long longOffset ,
72+ long longLength ,
73+ [ MarshalAs ( UnmanagedType . Bool ) ] bool delete ,
74+ nint reqType ,
75+ out nint actualTypeReturn ,
76+ out int actualFormatReturn ,
77+ out nuint nItemsReturn ,
78+ out nuint bytesAfterReturn ,
79+ out nint propReturn ) ;
80+
81+ [ LibraryImport ( LibX11 , EntryPoint = "XGetWMName" ) ]
82+ internal static partial int XGetWMName ( nint display , nint window , out XTextProperty textProp ) ;
83+
84+ [ LibraryImport ( LibX11 , EntryPoint = "XmbTextPropertyToTextList" ) ]
85+ internal static partial int XmbTextPropertyToTextList ( nint display , ref XTextProperty textProp , out nint listReturn , out int countReturn ) ;
86+
87+ [ LibraryImport ( LibX11 , EntryPoint = "XFreeStringList" ) ]
88+ internal static partial void XFreeStringList ( nint list ) ;
89+
90+ #endregion
91+
4192 #region XRandR
4293
4394 [ LibraryImport ( LibXrandr , EntryPoint = "XRRGetScreenResources" ) ]
@@ -112,5 +163,55 @@ internal struct XRRCrtcInfo
112163 public nint possible ;
113164 }
114165
166+ [ StructLayout ( LayoutKind . Sequential ) ]
167+ internal struct XWindowAttributes
168+ {
169+ public int x , y ;
170+ public int width , height ;
171+ public int border_width ;
172+ public int depth ;
173+ public nint visual ;
174+ public nint root ;
175+ public int c_class ;
176+ public int bit_gravity ;
177+ public int win_gravity ;
178+ public int backing_store ;
179+ public nuint backing_planes ;
180+ public nuint backing_pixel ;
181+ public int save_under ;
182+ public nint colormap ;
183+ public int map_installed ;
184+ public int map_state ;
185+ public nint all_event_masks ;
186+ public nint your_event_mask ;
187+ public nint do_not_propagate_mask ;
188+ public int override_redirect ;
189+ public nint screen ;
190+ }
191+
192+ [ StructLayout ( LayoutKind . Sequential ) ]
193+ internal struct XClassHint
194+ {
195+ public nint res_name ;
196+ public nint res_class ;
197+ }
198+
199+ [ StructLayout ( LayoutKind . Sequential ) ]
200+ internal struct XTextProperty
201+ {
202+ public nint value ;
203+ public nint encoding ;
204+ public int format ;
205+ public nuint nitems ;
206+ }
207+
208+ // Map state constants
209+ internal const int IsUnmapped = 0 ;
210+ internal const int IsUnviewable = 1 ;
211+ internal const int IsViewable = 2 ;
212+
213+ // Atom constants
214+ internal static readonly nint AnyPropertyType = 0 ;
215+
115216 #endregion
116217}
0 commit comments