Parcourir la source

Merge branch 'bullno1-resize'

Andre Weissflog il y a 5 mois
Parent
commit
4018189c9a
2 fichiers modifiés avec 34 ajouts et 0 suppressions
  1. 3 0
      CHANGELOG.md
  2. 31 0
      sokol_app.h

+ 3 - 0
CHANGELOG.md

@@ -5,6 +5,9 @@
 - sokol_app.h linux: fix a drag-n-drop related memory leak
   (see PR https://github.com/floooh/sokol/pull/1238).
   Many thanks to @bullno1 for catching and fixing that issue!
+- sokol_app.h linux: two new functions to obtain the X11 window and
+  display handles: `sapp_x11_get_window()` and `sapp_x11_get_display()`.
+  Again, many thanks to @bullno1 for the PR (https://github.com/floooh/sokol/pull/1237)!
 
 ### 29-Mar-2025
 

+ 31 - 0
sokol_app.h

@@ -310,6 +310,16 @@
             HWND has been cast to a void pointer in order to be tunneled
             through code which doesn't include Windows.h.
 
+        const void* sapp_x11_get_window(void)
+            On Linux, get the X11 Window, otherwise a null pointer. The
+            Window has been cast to a void pointer in order to be tunneled
+            through code which doesn't include X11/Xlib.h.
+
+        const void* sapp_x11_get_display(void)
+            On Linux, get the X11 Display, otherwise a null pointer. The
+            Display has been cast to a void pointer in order to be tunneled
+            through code which doesn't include X11/Xlib.h.
+
         const void* sapp_wgpu_get_device(void)
         const void* sapp_wgpu_get_render_view(void)
         const void* sapp_wgpu_get_resolve_view(void)
@@ -2005,6 +2015,11 @@ SOKOL_APP_API_DECL int sapp_gl_get_major_version(void);
 /* GL: get minor version (only valid for desktop GL) */
 SOKOL_APP_API_DECL int sapp_gl_get_minor_version(void);
 
+/* X11: get Window */
+SOKOL_APP_API_DECL const void* sapp_x11_get_window(void);
+/* X11: get Display */
+SOKOL_APP_API_DECL const void* sapp_x11_get_display(void);
+
 /* Android: get native activity handle */
 SOKOL_APP_API_DECL const void* sapp_android_get_native_activity(void);
 
@@ -12375,6 +12390,22 @@ SOKOL_API_IMPL int sapp_gl_get_minor_version(void) {
     #endif
 }
 
+SOKOL_API_IMPL const void* sapp_x11_get_window(void) {
+    #if defined(_SAPP_LINUX)
+        return (void*)_sapp.x11.window;
+    #else
+        return 0;
+    #endif
+}
+
+SOKOL_API_IMPL const void* sapp_x11_get_display(void) {
+    #if defined(_SAPP_LINUX)
+        return (void*)_sapp.x11.display;
+    #else
+        return 0;
+    #endif
+}
+
 SOKOL_API_IMPL const void* sapp_android_get_native_activity(void) {
     // NOTE: _sapp.valid is not asserted here because sapp_android_get_native_activity()
     // needs to be callable from within sokol_main() (see: https://github.com/floooh/sokol/issues/708)