From 4d59497d7c601c5591ff5a313c5332e89131903c Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Wed, 27 Aug 2014 16:02:03 +0000 Subject: [PATCH] X11: implemented borderless and captionless window style using motif hints git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1703 7f0cb862-5218-0410-a997-914c9d46530a --- progs/demos/Resizer/Resizer.cpp | 2 +- src/x11/fg_window_x11.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/progs/demos/Resizer/Resizer.cpp b/progs/demos/Resizer/Resizer.cpp index 4828915..f56d826 100644 --- a/progs/demos/Resizer/Resizer.cpp +++ b/progs/demos/Resizer/Resizer.cpp @@ -380,4 +380,4 @@ int main(int argc, char* argv[]) printf("glutMainLoop returned\n"); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/src/x11/fg_window_x11.c b/src/x11/fg_window_x11.c index cea4ba2..a512b02 100644 --- a/src/x11/fg_window_x11.c +++ b/src/x11/fg_window_x11.c @@ -40,6 +40,18 @@ #include "x11/fg_window_x11_glx.h" #endif +/* Motif window hints, only define needed ones */ +typedef struct +{ + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} MotifWmHints; +#define MWM_HINTS_DECORATIONS (1L << 1) +#define MWM_DECOR_BORDER (1L << 1) + static int fghResizeFullscrToggle(void) { XWindowAttributes attributes; @@ -340,6 +352,26 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, XSetWMProtocols( fgDisplay.pDisplay.Display, window->Window.Handle, &fgDisplay.pDisplay.DeleteWindow, 1 ); + + if (!isSubWindow && !window->IsMenu && + ((fgState.DisplayMode & GLUT_BORDERLESS) || (fgState.DisplayMode & GLUT_CAPTIONLESS))) + { + /* _MOTIF_WM_HINTS is replaced by _NET_WM_WINDOW_TYPE, but that property does not allow precise + * control over the visual style of the window, which is what we are trying to achieve here. + * Stick with Motif and hope for the best... */ + MotifWmHints hints = {0}; + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = (fgState.DisplayMode & GLUT_CAPTIONLESS) ? MWM_DECOR_BORDER:0; + printf("%i\n",hints.decorations); + + XChangeProperty(fgDisplay.pDisplay.Display, window->Window.Handle, + XInternAtom( fgDisplay.pDisplay.Display, "_MOTIF_WM_HINTS", False ), + XInternAtom( fgDisplay.pDisplay.Display, "_MOTIF_WM_HINTS", False ), 32, + PropModeReplace, + (unsigned char*) &hints, + sizeof(MotifWmHints) / sizeof(long)); + } + if (fgDisplay.pDisplay.NetWMSupported && fgDisplay.pDisplay.NetWMPid != None -- 1.7.10.4