add ui_window_fullscreen (Motif)

Sun, 23 Nov 2025 14:52:41 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 23 Nov 2025 14:52:41 +0100
changeset 934
89118a9350da
parent 933
70e14fa98ab4
child 935
d95e8723545c

add ui_window_fullscreen (Motif)

ui/motif/window.c file | annotate | diff | comparison | revisions
ui/ui/window.h file | annotate | diff | comparison | revisions
--- a/ui/motif/window.c	Sun Nov 23 11:21:17 2025 +0100
+++ b/ui/motif/window.c	Sun Nov 23 14:52:41 2025 +0100
@@ -179,6 +179,32 @@
     }
 }
 
+static Atom net_wm_state;
+static Atom net_wm_state_fullscreen;
+static int net_wm_atoms_initialized = 0;
+
+void ui_window_fullscreen(UiObject *obj, UiBool fullscreen) {
+    Display *dpy = XtDisplay(obj->widget);
+    
+    // init net_wm_state atoms
+    if(!net_wm_atoms_initialized) {
+        net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
+        net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
+        net_wm_atoms_initialized = 1;
+    }
+    
+    XEvent ev;
+    memset(&ev, 0, sizeof(XEvent));
+    ev.type = ClientMessage;
+    ev.xclient.window = XtWindow(obj->widget);
+    ev.xclient.message_type = net_wm_state;
+    ev.xclient.format = 32;
+    ev.xclient.data.l[0] = fullscreen ? 1 : 0;
+    ev.xclient.data.l[1] = net_wm_state_fullscreen;
+    ev.xclient.data.l[2] = 0;
+    XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, &ev);
+}
+
 static void filedialog_event(UiEventData *event, int result, UiFileList flist) {
     UiEvent evt;
     evt.obj = event->obj;
--- a/ui/ui/window.h	Sun Nov 23 11:21:17 2025 +0100
+++ b/ui/ui/window.h	Sun Nov 23 14:52:41 2025 +0100
@@ -85,6 +85,8 @@
 UIEXPORT void ui_window_default_size(int width, int height);
 UIEXPORT void ui_window_menubar_set_visible(UiObject *obj, UiBool visible);
 
+UIEXPORT void ui_window_fullscreen(UiObject *obj, UiBool fullscreen);
+
 UIEXPORT void ui_splitview_window_set_pos(UiObject *obj, int pos);
 UIEXPORT int ui_splitview_window_get_pos(UiObject *obj);
 UIEXPORT void ui_splitview_window_set_default_pos(int pos);

mercurial