Moved to WM_STATE for iconify events.
This commit is contained in:
parent
e820284015
commit
b1ff42b7bb
@ -318,40 +318,6 @@ static void updateKeyCodeLUT(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Retrieve a single window property of the specified type
|
|
||||||
// Inspired by fghGetWindowProperty from freeglut
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static unsigned long getWindowProperty(Window window,
|
|
||||||
Atom property,
|
|
||||||
Atom type,
|
|
||||||
unsigned char** value)
|
|
||||||
{
|
|
||||||
Atom actualType;
|
|
||||||
int actualFormat;
|
|
||||||
unsigned long itemCount, bytesAfter;
|
|
||||||
|
|
||||||
XGetWindowProperty(_glfw.x11.display,
|
|
||||||
window,
|
|
||||||
property,
|
|
||||||
0,
|
|
||||||
LONG_MAX,
|
|
||||||
False,
|
|
||||||
type,
|
|
||||||
&actualType,
|
|
||||||
&actualFormat,
|
|
||||||
&itemCount,
|
|
||||||
&bytesAfter,
|
|
||||||
value);
|
|
||||||
|
|
||||||
if (actualType != type)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return itemCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Check whether the specified atom is supported
|
// Check whether the specified atom is supported
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -394,7 +360,7 @@ static void detectEWMH(void)
|
|||||||
return;
|
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 (getWindowProperty(_glfw.x11.root,
|
if (_glfwGetWindowProperty(_glfw.x11.root,
|
||||||
supportingWmCheck,
|
supportingWmCheck,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromRoot) != 1)
|
(unsigned char**) &windowFromRoot) != 1)
|
||||||
@ -405,7 +371,7 @@ static void detectEWMH(void)
|
|||||||
|
|
||||||
// It should be the ID of a child window (of the root)
|
// It should be the ID of a child window (of the root)
|
||||||
// Then we look for the same property on the child window
|
// Then we look for the same property on the child window
|
||||||
if (getWindowProperty(*windowFromRoot,
|
if (_glfwGetWindowProperty(*windowFromRoot,
|
||||||
supportingWmCheck,
|
supportingWmCheck,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromChild) != 1)
|
(unsigned char**) &windowFromChild) != 1)
|
||||||
@ -433,7 +399,7 @@ static void detectEWMH(void)
|
|||||||
|
|
||||||
// Now we need to check the _NET_SUPPORTED property of the root window
|
// Now we need to check the _NET_SUPPORTED property of the root window
|
||||||
// It should be a list of supported WM protocol and state atoms
|
// It should be a list of supported WM protocol and state atoms
|
||||||
atomCount = getWindowProperty(_glfw.x11.root,
|
atomCount = _glfwGetWindowProperty(_glfw.x11.root,
|
||||||
wmSupported,
|
wmSupported,
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
(unsigned char**) &supportedAtoms);
|
(unsigned char**) &supportedAtoms);
|
||||||
@ -484,7 +450,8 @@ static GLboolean initDisplay(void)
|
|||||||
_glfw.x11.screen = DefaultScreen(_glfw.x11.display);
|
_glfw.x11.screen = DefaultScreen(_glfw.x11.display);
|
||||||
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
|
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
|
||||||
|
|
||||||
// Find or create the protocol atom for window close notifications
|
// Find or create window manager atoms
|
||||||
|
_glfw.x11.WM_STATE = XInternAtom(_glfw.x11.display, "WM_STATE", False);
|
||||||
_glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display,
|
_glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display,
|
||||||
"WM_DELETE_WINDOW",
|
"WM_DELETE_WINDOW",
|
||||||
False);
|
False);
|
||||||
|
@ -123,6 +123,7 @@ typedef struct _GLFWlibraryX11
|
|||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
|
|
||||||
// Window manager atoms
|
// Window manager atoms
|
||||||
|
Atom WM_STATE;
|
||||||
Atom WM_DELETE_WINDOW;
|
Atom WM_DELETE_WINDOW;
|
||||||
Atom NET_WM_NAME;
|
Atom NET_WM_NAME;
|
||||||
Atom NET_WM_ICON_NAME;
|
Atom NET_WM_ICON_NAME;
|
||||||
@ -252,4 +253,10 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request);
|
|||||||
// Event processing
|
// Event processing
|
||||||
void _glfwProcessPendingEvents(void);
|
void _glfwProcessPendingEvents(void);
|
||||||
|
|
||||||
|
// Window support
|
||||||
|
unsigned long _glfwGetWindowProperty(Window window,
|
||||||
|
Atom property,
|
||||||
|
Atom type,
|
||||||
|
unsigned char** value);
|
||||||
|
|
||||||
#endif // _x11_platform_h_
|
#endif // _x11_platform_h_
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
// Action for EWMH client messages
|
// Action for EWMH client messages
|
||||||
#define _NET_WM_STATE_REMOVE 0
|
#define _NET_WM_STATE_REMOVE 0
|
||||||
@ -105,7 +106,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
||||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
||||||
EnterWindowMask | LeaveWindowMask;
|
EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
|
||||||
|
|
||||||
if (wndconfig->monitor == NULL)
|
if (wndconfig->monitor == NULL)
|
||||||
{
|
{
|
||||||
@ -666,7 +667,6 @@ static void processEvent(XEvent *event)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwInputWindowVisibility(window, GL_TRUE);
|
_glfwInputWindowVisibility(window, GL_TRUE);
|
||||||
_glfwInputWindowIconify(window, GL_FALSE);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,7 +677,6 @@ static void processEvent(XEvent *event)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwInputWindowVisibility(window, GL_FALSE);
|
_glfwInputWindowVisibility(window, GL_FALSE);
|
||||||
_glfwInputWindowIconify(window, GL_TRUE);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,6 +718,37 @@ static void processEvent(XEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PropertyNotify:
|
||||||
|
{
|
||||||
|
window = findWindow(event->xproperty.window);
|
||||||
|
if (window == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event->xproperty.atom == _glfw.x11.WM_STATE &&
|
||||||
|
event->xproperty.state == PropertyNewValue)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
CARD32 state;
|
||||||
|
Window icon;
|
||||||
|
} *state = NULL;
|
||||||
|
|
||||||
|
if (_glfwGetWindowProperty(window->x11.handle,
|
||||||
|
_glfw.x11.WM_STATE,
|
||||||
|
_glfw.x11.WM_STATE,
|
||||||
|
(unsigned char**) &state) >= 2)
|
||||||
|
{
|
||||||
|
if (state->state == IconicState)
|
||||||
|
_glfwInputWindowIconify(window, GL_TRUE);
|
||||||
|
else if (state->state == NormalState)
|
||||||
|
_glfwInputWindowIconify(window, GL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
{
|
{
|
||||||
// The ownership of the clipboard selection was lost
|
// The ownership of the clipboard selection was lost
|
||||||
@ -785,6 +815,45 @@ static void processEvent(XEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Retrieve a single window property of the specified type
|
||||||
|
// Inspired by fghGetWindowProperty from freeglut
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
unsigned long _glfwGetWindowProperty(Window window,
|
||||||
|
Atom property,
|
||||||
|
Atom type,
|
||||||
|
unsigned char** value)
|
||||||
|
{
|
||||||
|
Atom actualType;
|
||||||
|
int actualFormat;
|
||||||
|
unsigned long itemCount, bytesAfter;
|
||||||
|
|
||||||
|
XGetWindowProperty(_glfw.x11.display,
|
||||||
|
window,
|
||||||
|
property,
|
||||||
|
0,
|
||||||
|
LONG_MAX,
|
||||||
|
False,
|
||||||
|
type,
|
||||||
|
&actualType,
|
||||||
|
&actualFormat,
|
||||||
|
&itemCount,
|
||||||
|
&bytesAfter,
|
||||||
|
value);
|
||||||
|
|
||||||
|
if (actualType != type)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return itemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user