Create EWMH and XDND atoms on demand

This commit is contained in:
Camilla Berglund 2016-05-01 22:54:02 +02:00
parent 3b0b5dacf5
commit 0b6a4313dd

View File

@ -356,16 +356,13 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
unsigned long atomCount, unsigned long atomCount,
const char* atomName) const char* atomName)
{ {
Atom atom = XInternAtom(_glfw.x11.display, atomName, True); unsigned long i;
if (atom != None) const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
{
unsigned long i;
for (i = 0; i < atomCount; i++) for (i = 0; i < atomCount; i++)
{ {
if (supportedAtoms[i] == atom) if (supportedAtoms[i] == atom)
return atom; return atom;
}
} }
return None; return None;
@ -378,13 +375,11 @@ static void detectEWMH(void)
Window* windowFromRoot = NULL; Window* windowFromRoot = NULL;
Window* windowFromChild = NULL; Window* windowFromChild = NULL;
// First we need a couple of atoms, which should already be there // First we need a couple of atoms
Atom supportingWmCheck = const Atom supportingWmCheck =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", True); XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
Atom wmSupported = const Atom wmSupported =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", True); XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
if (supportingWmCheck == None || wmSupported == None)
return;
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window // Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
if (_glfwGetWindowPropertyX11(_glfw.x11.root, if (_glfwGetWindowPropertyX11(_glfw.x11.root,
@ -611,15 +606,15 @@ static GLFWbool initExtensions(void)
XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False); XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
// Find Xdnd (drag and drop) atoms, if available // Find Xdnd (drag and drop) atoms, if available
_glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", True); _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
_glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", True); _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
_glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", True); _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
_glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", True); _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
_glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", True); _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
_glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", True); _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
_glfw.x11.XdndLeave = XInternAtom(_glfw.x11.display, "XdndLeave", True); _glfw.x11.XdndLeave = XInternAtom(_glfw.x11.display, "XdndLeave", False);
_glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", True); _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
_glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", True); _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
return GLFW_TRUE; return GLFW_TRUE;
} }