Simplified the NetWM code a little bit, and it now operates on X11 Window
This commit is contained in:
parent
32c3816470
commit
e6a0c63fb7
3 changed files with 22 additions and 40 deletions
|
@ -485,7 +485,7 @@ X11_DispatchEvent(_THIS)
|
||||||
without ever mapping / unmapping them, so we handle that here,
|
without ever mapping / unmapping them, so we handle that here,
|
||||||
because they use the NETWM protocol to notify us of changes.
|
because they use the NETWM protocol to notify us of changes.
|
||||||
*/
|
*/
|
||||||
Uint32 flags = X11_GetNetWMState(_this, data->window);
|
Uint32 flags = X11_GetNetWMState(_this, xevent.xproperty.window);
|
||||||
if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) {
|
if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) {
|
||||||
if (flags & SDL_WINDOW_HIDDEN) {
|
if (flags & SDL_WINDOW_HIDDEN) {
|
||||||
X11_DispatchUnmapNotify(data);
|
X11_DispatchUnmapNotify(data);
|
||||||
|
|
|
@ -114,15 +114,18 @@ X11_IsActionAllowed(SDL_Window *window, Atom action)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
X11_GetWMStateProperty(_THIS, Uint32 flags, Atom atoms[5])
|
X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
|
||||||
{
|
{
|
||||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||||
|
Display *display = videodata->display;
|
||||||
|
Atom _NET_WM_STATE = videodata->_NET_WM_STATE;
|
||||||
/*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;*/
|
/*Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;*/
|
||||||
Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
|
Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
|
||||||
Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT;
|
Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT;
|
||||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
|
Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
|
||||||
Atom _NET_WM_STATE_FULLSCREEN = videodata->_NET_WM_STATE_FULLSCREEN;
|
Atom _NET_WM_STATE_FULLSCREEN = videodata->_NET_WM_STATE_FULLSCREEN;
|
||||||
|
Atom atoms[5];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
/* The window manager sets this property, we shouldn't set it.
|
/* The window manager sets this property, we shouldn't set it.
|
||||||
|
@ -143,14 +146,19 @@ X11_GetWMStateProperty(_THIS, Uint32 flags, Atom atoms[5])
|
||||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
atoms[count++] = _NET_WM_STATE_FULLSCREEN;
|
atoms[count++] = _NET_WM_STATE_FULLSCREEN;
|
||||||
}
|
}
|
||||||
return count;
|
if (count > 0) {
|
||||||
|
XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
|
||||||
|
PropModeReplace, (unsigned char *)atoms, count);
|
||||||
|
} else {
|
||||||
|
XDeleteProperty(display, xwindow, _NET_WM_STATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32
|
Uint32
|
||||||
X11_GetNetWMState(_THIS, SDL_Window * window)
|
X11_GetNetWMState(_THIS, Window xwindow)
|
||||||
{
|
{
|
||||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
|
||||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||||
|
Display *display = videodata->display;
|
||||||
Atom _NET_WM_STATE = videodata->_NET_WM_STATE;
|
Atom _NET_WM_STATE = videodata->_NET_WM_STATE;
|
||||||
Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;
|
Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;
|
||||||
Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
|
Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
|
||||||
|
@ -164,7 +172,7 @@ X11_GetNetWMState(_THIS, SDL_Window * window)
|
||||||
long maxLength = 1024;
|
long maxLength = 1024;
|
||||||
Uint32 flags = 0;
|
Uint32 flags = 0;
|
||||||
|
|
||||||
if (XGetWindowProperty(videodata->display, data->xwindow, _NET_WM_STATE,
|
if (XGetWindowProperty(display, xwindow, _NET_WM_STATE,
|
||||||
0l, maxLength, False, XA_ATOM, &actualType,
|
0l, maxLength, False, XA_ATOM, &actualType,
|
||||||
&actualFormat, &numItems, &bytesAfter,
|
&actualFormat, &numItems, &bytesAfter,
|
||||||
&propertyValue) == Success) {
|
&propertyValue) == Success) {
|
||||||
|
@ -214,8 +222,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
window->driverdata = data;
|
|
||||||
|
|
||||||
data->window = window;
|
data->window = window;
|
||||||
data->xwindow = w;
|
data->xwindow = w;
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
|
@ -269,7 +275,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||||
data->colormap = attrib.colormap;
|
data->colormap = attrib.colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->flags |= X11_GetNetWMState(_this, window);
|
window->flags |= X11_GetNetWMState(_this, w);
|
||||||
|
|
||||||
{
|
{
|
||||||
Window FocalWindow;
|
Window FocalWindow;
|
||||||
|
@ -290,6 +296,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All done! */
|
/* All done! */
|
||||||
|
window->driverdata = data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,8 +349,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
Atom _NET_WM_WINDOW_TYPE;
|
Atom _NET_WM_WINDOW_TYPE;
|
||||||
Atom _NET_WM_WINDOW_TYPE_NORMAL;
|
Atom _NET_WM_WINDOW_TYPE_NORMAL;
|
||||||
Atom _NET_WM_PID;
|
Atom _NET_WM_PID;
|
||||||
int wmstate_count;
|
|
||||||
Atom wmstate_atoms[5];
|
|
||||||
Uint32 fevent = 0;
|
Uint32 fevent = 0;
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
|
@ -528,14 +533,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the window manager state */
|
/* Set the window manager state */
|
||||||
wmstate_count = X11_GetWMStateProperty(_this, window->flags, wmstate_atoms);
|
X11_SetNetWMState(_this, w, window->flags);
|
||||||
if (wmstate_count > 0) {
|
|
||||||
XChangeProperty(display, w, data->_NET_WM_STATE, XA_ATOM, 32,
|
|
||||||
PropModeReplace,
|
|
||||||
(unsigned char *)wmstate_atoms, wmstate_count);
|
|
||||||
} else {
|
|
||||||
XDeleteProperty(display, w, data->_NET_WM_STATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Let the window manager know we're a "normal" window */
|
/* Let the window manager know we're a "normal" window */
|
||||||
_NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
_NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||||
|
@ -875,9 +873,7 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
|
||||||
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
||||||
} else {
|
} else {
|
||||||
int count;
|
|
||||||
Uint32 flags;
|
Uint32 flags;
|
||||||
Atom atoms[5];
|
|
||||||
|
|
||||||
flags = window->flags;
|
flags = window->flags;
|
||||||
if (maximized) {
|
if (maximized) {
|
||||||
|
@ -885,13 +881,7 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
|
||||||
} else {
|
} else {
|
||||||
flags &= ~SDL_WINDOW_MAXIMIZED;
|
flags &= ~SDL_WINDOW_MAXIMIZED;
|
||||||
}
|
}
|
||||||
count = X11_GetWMStateProperty(_this, flags, atoms);
|
X11_SetNetWMState(_this, data->xwindow, flags);
|
||||||
if (count > 0) {
|
|
||||||
XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32,
|
|
||||||
PropModeReplace, (unsigned char *)atoms, count);
|
|
||||||
} else {
|
|
||||||
XDeleteProperty(display, data->xwindow, _NET_WM_STATE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
@ -970,9 +960,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
|
||||||
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
||||||
} else {
|
} else {
|
||||||
int count;
|
|
||||||
Uint32 flags;
|
Uint32 flags;
|
||||||
Atom atoms[5];
|
|
||||||
|
|
||||||
flags = window->flags;
|
flags = window->flags;
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
@ -980,13 +968,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
|
||||||
} else {
|
} else {
|
||||||
flags &= ~SDL_WINDOW_FULLSCREEN;
|
flags &= ~SDL_WINDOW_FULLSCREEN;
|
||||||
}
|
}
|
||||||
count = X11_GetWMStateProperty(_this, flags, atoms);
|
X11_SetNetWMState(_this, data->xwindow, flags);
|
||||||
if (count > 0) {
|
|
||||||
XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32,
|
|
||||||
PropModeReplace, (unsigned char *)atoms, count);
|
|
||||||
} else {
|
|
||||||
XDeleteProperty(display, data->xwindow, _NET_WM_STATE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ typedef struct
|
||||||
struct SDL_VideoData *videodata;
|
struct SDL_VideoData *videodata;
|
||||||
} SDL_WindowData;
|
} SDL_WindowData;
|
||||||
|
|
||||||
extern int X11_GetWMStateProperty(_THIS, Uint32 flags, Atom atoms[5]);
|
extern void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags);
|
||||||
extern Uint32 X11_GetNetWMState(_THIS, SDL_Window * window);
|
extern Uint32 X11_GetNetWMState(_THIS, Window xwindow);
|
||||||
|
|
||||||
extern int X11_CreateWindow(_THIS, SDL_Window * window);
|
extern int X11_CreateWindow(_THIS, SDL_Window * window);
|
||||||
extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue