Commit fdac60bd authored by Sam Lantinga's avatar Sam Lantinga

Let the window manager know we're a "normal" window

parent b60cbd56
...@@ -224,6 +224,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -224,6 +224,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *displaydata = SDL_DisplayData *displaydata =
(SDL_DisplayData *) window->display->driverdata; (SDL_DisplayData *) window->display->driverdata;
Display *display = data->display;
int screen = displaydata->screen;
Visual *visual; Visual *visual;
int depth; int depth;
XSetWindowAttributes xattr; XSetWindowAttributes xattr;
...@@ -233,6 +235,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -233,6 +235,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
XWMHints *wmhints; XWMHints *wmhints;
XClassHint *classhints; XClassHint *classhints;
SDL_bool oldstyle_fullscreen; SDL_bool oldstyle_fullscreen;
Atom _NET_WM_WINDOW_TYPE;
Atom _NET_WM_WINDOW_TYPE_NORMAL;
/* ICCCM2.0-compliant window managers can handle fullscreen windows */ /* ICCCM2.0-compliant window managers can handle fullscreen windows */
if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->net_wm) { if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->net_wm) {
...@@ -253,7 +257,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -253,7 +257,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
XVisualInfo *vinfo; XVisualInfo *vinfo;
vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); vinfo = X11_GL_GetVisual(_this, display, screen);
if (!vinfo) { if (!vinfo) {
return -1; return -1;
} }
...@@ -266,7 +270,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -266,7 +270,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
XVisualInfo *vinfo; XVisualInfo *vinfo;
vinfo = X11_GLES_GetVisual(_this, data->display, displaydata->screen); vinfo = X11_GLES_GetVisual(_this, display, screen);
if (!vinfo) { if (!vinfo) {
return -1; return -1;
} }
...@@ -305,15 +309,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -305,15 +309,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Is the colormap we need already registered in SDL? */ /* Is the colormap we need already registered in SDL? */
if ((colormap = if ((colormap =
X11_LookupColormap(data->display, X11_LookupColormap(display, screen, visual->visualid))) {
displaydata->screen, visual->visualid))) {
xattr.colormap = colormap; xattr.colormap = colormap;
/* printf("found existing colormap\n"); */ /* printf("found existing colormap\n"); */
} else { } else {
/* The colormap is not known to SDL so we will create it */ /* The colormap is not known to SDL so we will create it */
colormap = XCreateColormap(data->display, colormap = XCreateColormap(display, RootWindow(display, screen),
RootWindow(data->display,
displaydata->screen),
visual, AllocAll); visual, AllocAll);
/* printf("colormap = %x\n", colormap); */ /* printf("colormap = %x\n", colormap); */
...@@ -392,11 +393,10 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -392,11 +393,10 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
/* status = */ /* status = */
/* XStoreColors(data->display, colormap, colorcells, ncolors); */ /* XStoreColors(display, colormap, colorcells, ncolors); */
xattr.colormap = colormap; xattr.colormap = colormap;
X11_TrackColormap(data->display, displaydata->screen, X11_TrackColormap(display, screen, colormap, visual, NULL);
colormap, visual, NULL);
SDL_free(colorcells); SDL_free(colorcells);
} }
...@@ -412,15 +412,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -412,15 +412,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
/* Is the colormap we need already registered in SDL? */ /* Is the colormap we need already registered in SDL? */
if ((colormap = if ((colormap =
X11_LookupColormap(data->display, X11_LookupColormap(display, screen, visual->visualid))) {
displaydata->screen, visual->visualid))) {
xattr.colormap = colormap; xattr.colormap = colormap;
/* printf("found existing colormap\n"); */ /* printf("found existing colormap\n"); */
} else { } else {
/* The colormap is not known to SDL so we will create it */ /* The colormap is not known to SDL so we will create it */
colormap = XCreateColormap(data->display, colormap = XCreateColormap(display, RootWindow(display, screen),
RootWindow(data->display,
displaydata->screen),
visual, AllocAll); visual, AllocAll);
/* printf("colormap = %x\n", colormap); */ /* printf("colormap = %x\n", colormap); */
...@@ -493,18 +490,16 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -493,18 +490,16 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
status = status =
XStoreColors(data->display, colormap, colorcells, ncolors); XStoreColors(display, colormap, colorcells, ncolors);
xattr.colormap = colormap; xattr.colormap = colormap;
X11_TrackColormap(data->display, displaydata->screen, X11_TrackColormap(display, screen, colormap, visual, colorcells);
colormap, visual, colorcells);
SDL_free(colorcells); SDL_free(colorcells);
} }
} else { } else {
xattr.colormap = xattr.colormap =
XCreateColormap(data->display, XCreateColormap(display, RootWindow(display, screen),
RootWindow(data->display, displaydata->screen),
visual, AllocNone); visual, AllocNone);
} }
...@@ -527,8 +522,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -527,8 +522,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
y = window->y; y = window->y;
} }
w = XCreateWindow(data->display, w = XCreateWindow(display, RootWindow(display, screen), x, y,
RootWindow(data->display, displaydata->screen), x, y,
window->w, window->h, 0, depth, InputOutput, visual, window->w, window->h, 0, depth, InputOutput, visual,
(CWOverrideRedirect | CWBackPixel | CWBorderPixel | (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
CWColormap), &xattr); CWColormap), &xattr);
...@@ -565,7 +559,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -565,7 +559,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
sizehints->y = y; sizehints->y = y;
sizehints->flags |= USPosition; sizehints->flags |= USPosition;
} }
XSetWMNormalHints(data->display, w, sizehints); XSetWMNormalHints(display, w, sizehints);
XFree(sizehints); XFree(sizehints);
} }
...@@ -577,7 +571,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -577,7 +571,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
set = SDL_FALSE; set = SDL_FALSE;
/* First try to set MWM hints */ /* First try to set MWM hints */
WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
/* Hints used by Motif compliant window managers */ /* Hints used by Motif compliant window managers */
struct struct
...@@ -590,40 +584,36 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -590,40 +584,36 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} MWMHints = { } MWMHints = {
(1L << 1), 0, 0, 0, 0}; (1L << 1), 0, 0, 0, 0};
XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32, XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
PropModeReplace, (unsigned char *) &MWMHints, PropModeReplace, (unsigned char *) &MWMHints,
sizeof(MWMHints) / sizeof(long)); sizeof(MWMHints) / 4);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Now try to set KWM hints */ /* Now try to set KWM hints */
WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
long KWMHints = 0; long KWMHints = 0;
XChangeProperty(data->display, w, XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
WM_HINTS, WM_HINTS, 32,
PropModeReplace, PropModeReplace,
(unsigned char *) &KWMHints, (unsigned char *) &KWMHints,
sizeof(KWMHints) / sizeof(long)); sizeof(KWMHints) / 4);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Now try to set GNOME hints */ /* Now try to set GNOME hints */
WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
long GNOMEHints = 0; long GNOMEHints = 0;
XChangeProperty(data->display, w, XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
WM_HINTS, WM_HINTS, 32,
PropModeReplace, PropModeReplace,
(unsigned char *) &GNOMEHints, (unsigned char *) &GNOMEHints,
sizeof(GNOMEHints) / sizeof(long)); sizeof(GNOMEHints) / 4);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Finally set the transient hints if necessary */ /* Finally set the transient hints if necessary */
if (!set) { if (!set) {
XSetTransientForHint(data->display, w, XSetTransientForHint(display, w, RootWindow(display, screen));
RootWindow(data->display,
displaydata->screen));
} }
} else { } else {
SDL_bool set; SDL_bool set;
...@@ -633,27 +623,27 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -633,27 +623,27 @@ X11_CreateWindow(_THIS, SDL_Window * window)
set = SDL_FALSE; set = SDL_FALSE;
/* First try to unset MWM hints */ /* First try to unset MWM hints */
WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
XDeleteProperty(data->display, w, WM_HINTS); XDeleteProperty(display, w, WM_HINTS);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Now try to unset KWM hints */ /* Now try to unset KWM hints */
WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
XDeleteProperty(data->display, w, WM_HINTS); XDeleteProperty(display, w, WM_HINTS);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Now try to unset GNOME hints */ /* Now try to unset GNOME hints */
WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
if (WM_HINTS != None) { if (WM_HINTS != None) {
XDeleteProperty(data->display, w, WM_HINTS); XDeleteProperty(display, w, WM_HINTS);
set = SDL_TRUE; set = SDL_TRUE;
} }
/* Finally unset the transient hints if necessary */ /* Finally unset the transient hints if necessary */
if (!set) { if (!set) {
/* NOTE: Does this work? */ /* NOTE: Does this work? */
XSetTransientForHint(data->display, w, None); XSetTransientForHint(display, w, None);
} }
} }
...@@ -662,7 +652,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -662,7 +652,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if (wmhints) { if (wmhints) {
wmhints->input = True; wmhints->input = True;
wmhints->flags = InputHint; wmhints->flags = InputHint;
XSetWMHints(data->display, w, wmhints); XSetWMHints(display, w, wmhints);
XFree(wmhints); XFree(wmhints);
} }
...@@ -671,7 +661,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -671,7 +661,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
if (classhints != NULL) { if (classhints != NULL) {
classhints->res_name = data->classname; classhints->res_name = data->classname;
classhints->res_class = data->classname; classhints->res_class = data->classname;
XSetClassHint(data->display, w, classhints); XSetClassHint(display, w, classhints);
XFree(classhints); XFree(classhints);
} }
...@@ -688,16 +678,22 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -688,16 +678,22 @@ X11_CreateWindow(_THIS, SDL_Window * window)
e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
e.xclient.data.l[2] = 0l; e.xclient.data.l[2] = 0l;
XSendEvent(data->display, XSendEvent(display, RootWindow(display, screen), 0,
RootWindow(data->display, displaydata->screen), 0,
SubstructureNotifyMask | SubstructureRedirectMask, &e); SubstructureNotifyMask | SubstructureRedirectMask, &e);
} }
/* 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_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
PropModeReplace,
(unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
/* Allow the window to be deleted by the window manager */ /* Allow the window to be deleted by the window manager */
XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1);
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
XDestroyWindow(data->display, w); XDestroyWindow(display, w);
return -1; return -1;
} }
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
...@@ -705,7 +701,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -705,7 +701,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
Uint32 fevent = 0; Uint32 fevent = 0;
pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
XNFilterEvents, &fevent, NULL); XNFilterEvents, &fevent, NULL);
XSelectInput(data->display, w, XSelectInput(display, w,
(FocusChangeMask | EnterWindowMask | LeaveWindowMask | (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
ExposureMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask |
...@@ -714,7 +710,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -714,7 +710,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
#else #else
{ {
XSelectInput(data->display, w, XSelectInput(display, w,
(FocusChangeMask | EnterWindowMask | LeaveWindowMask | (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
ExposureMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment