mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Unconditionally use some EWMH atoms
These window properties do no harm if they're declared even if the WM doesn't support them. This makes GLFW slightly more tolerant of WM changes as well as things like Ubuntu Unity reading _NET_WM_ICON without declaring support for it.
This commit is contained in:
parent
211bdab51f
commit
932a161d44
|
@ -445,16 +445,6 @@ static void detectEWMH(void)
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||||
_glfw.x11.NET_WM_FULLSCREEN_MONITORS =
|
_glfw.x11.NET_WM_FULLSCREEN_MONITORS =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
|
||||||
_glfw.x11.NET_WM_NAME =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME");
|
|
||||||
_glfw.x11.NET_WM_ICON_NAME =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON_NAME");
|
|
||||||
_glfw.x11.NET_WM_ICON =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON");
|
|
||||||
_glfw.x11.NET_WM_PID =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PID");
|
|
||||||
_glfw.x11.NET_WM_PING =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
|
|
||||||
_glfw.x11.NET_WM_WINDOW_TYPE =
|
_glfw.x11.NET_WM_WINDOW_TYPE =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
|
||||||
_glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
|
_glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
|
||||||
|
@ -465,8 +455,6 @@ static void detectEWMH(void)
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
|
||||||
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
||||||
_glfw.x11.NET_WM_BYPASS_COMPOSITOR =
|
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_BYPASS_COMPOSITOR");
|
|
||||||
|
|
||||||
XFree(supportedAtoms);
|
XFree(supportedAtoms);
|
||||||
}
|
}
|
||||||
|
@ -475,7 +463,8 @@ static void detectEWMH(void)
|
||||||
//
|
//
|
||||||
static GLFWbool initExtensions(void)
|
static GLFWbool initExtensions(void)
|
||||||
{
|
{
|
||||||
// Find or create window manager atoms
|
// ICCCM window property and protocol atoms
|
||||||
|
// Always intern these as they can be set safely even without WM support
|
||||||
_glfw.x11.WM_PROTOCOLS = XInternAtom(_glfw.x11.display,
|
_glfw.x11.WM_PROTOCOLS = XInternAtom(_glfw.x11.display,
|
||||||
"WM_PROTOCOLS",
|
"WM_PROTOCOLS",
|
||||||
False);
|
False);
|
||||||
|
@ -487,6 +476,21 @@ static GLFWbool initExtensions(void)
|
||||||
"_MOTIF_WM_HINTS",
|
"_MOTIF_WM_HINTS",
|
||||||
False);
|
False);
|
||||||
|
|
||||||
|
// EWMH window property and protocol atoms
|
||||||
|
// Always intern these as they can be set safely even without WM support
|
||||||
|
_glfw.x11.NET_WM_ICON =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
|
||||||
|
_glfw.x11.NET_WM_PING =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
|
||||||
|
_glfw.x11.NET_WM_PID =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
|
||||||
|
_glfw.x11.NET_WM_NAME =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
|
||||||
|
_glfw.x11.NET_WM_ICON_NAME =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
|
||||||
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XF86VM)
|
#if defined(_GLFW_HAS_XF86VM)
|
||||||
// Check for XF86VidMode extension
|
// Check for XF86VidMode extension
|
||||||
_glfw.x11.vidmode.available =
|
_glfw.x11.vidmode.available =
|
||||||
|
|
|
@ -295,7 +295,7 @@ static void updateWindowMode(_GLFWwindow* window)
|
||||||
window->x11.overrideRedirect = GLFW_TRUE;
|
window->x11.overrideRedirect = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)
|
// Enable compositor bypass
|
||||||
{
|
{
|
||||||
const unsigned long value = 1;
|
const unsigned long value = 1;
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ static void updateWindowMode(_GLFWwindow* window)
|
||||||
window->x11.overrideRedirect = GLFW_FALSE;
|
window->x11.overrideRedirect = GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)
|
// Disable compositor bypass
|
||||||
{
|
{
|
||||||
XDeleteProperty(_glfw.x11.display, window->x11.handle,
|
XDeleteProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.NET_WM_BYPASS_COMPOSITOR);
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR);
|
||||||
|
@ -495,28 +495,17 @@ static GLFWbool createWindow(_GLFWwindow* window,
|
||||||
|
|
||||||
// Declare the WM protocols supported by GLFW
|
// Declare the WM protocols supported by GLFW
|
||||||
{
|
{
|
||||||
int count = 0;
|
Atom protocols[] =
|
||||||
Atom protocols[2];
|
|
||||||
|
|
||||||
// The WM_DELETE_WINDOW ICCCM protocol
|
|
||||||
// Basic window close notification protocol
|
|
||||||
if (_glfw.x11.WM_DELETE_WINDOW)
|
|
||||||
protocols[count++] = _glfw.x11.WM_DELETE_WINDOW;
|
|
||||||
|
|
||||||
// The _NET_WM_PING EWMH protocol
|
|
||||||
// Tells the WM to ping the GLFW window and flag the application as
|
|
||||||
// unresponsive if the WM doesn't get a reply within a few seconds
|
|
||||||
if (_glfw.x11.NET_WM_PING)
|
|
||||||
protocols[count++] = _glfw.x11.NET_WM_PING;
|
|
||||||
|
|
||||||
if (count > 0)
|
|
||||||
{
|
{
|
||||||
XSetWMProtocols(_glfw.x11.display, window->x11.handle,
|
_glfw.x11.WM_DELETE_WINDOW,
|
||||||
protocols, count);
|
_glfw.x11.NET_WM_PING
|
||||||
}
|
};
|
||||||
|
|
||||||
|
XSetWMProtocols(_glfw.x11.display, window->x11.handle,
|
||||||
|
protocols, sizeof(protocols) / sizeof(Atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_PID)
|
// Declare our PID
|
||||||
{
|
{
|
||||||
const pid_t pid = getpid();
|
const pid_t pid = getpid();
|
||||||
|
|
||||||
|
@ -1591,21 +1580,15 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_NAME)
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
{
|
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
PropModeReplace,
|
||||||
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
|
(unsigned char*) title, strlen(title));
|
||||||
PropModeReplace,
|
|
||||||
(unsigned char*) title, strlen(title));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfw.x11.NET_WM_ICON_NAME)
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
{
|
_glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
PropModeReplace,
|
||||||
_glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
|
(unsigned char*) title, strlen(title));
|
||||||
PropModeReplace,
|
|
||||||
(unsigned char*) title, strlen(title));
|
|
||||||
}
|
|
||||||
|
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user