21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_X11 27 #include "../SDL_sysvideo.h" 28 #include "../SDL_pixels_c.h" 29 #include "../../events/SDL_keyboard_c.h" 30 #include "../../events/SDL_mouse_c.h" 37 #if SDL_VIDEO_OPENGL_EGL 45 #define _NET_WM_STATE_REMOVE 0l 46 #define _NET_WM_STATE_ADD 1l 48 static Bool isMapNotify(Display *
dpy, XEvent *ev, XPointer win)
50 return ev->type == MapNotify && ev->xmap.window == *((Window*)win);
52 static Bool isUnmapNotify(Display *
dpy, XEvent *ev, XPointer win)
54 return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
88 XWindowAttributes attr;
90 X11_XGetWindowAttributes(videodata->display, data->
xwindow, &attr);
91 if (attr.map_state != IsUnmapped) {
100 X11_IsActionAllowed(
SDL_Window *window, Atom action)
107 unsigned long remain;
108 unsigned long len,
i;
112 if (X11_XGetWindowProperty(display, data->
xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &
type, &form, &len, &remain, (
unsigned char **)&list) == Success)
116 if (list[
i] == action) {
131 Display *display = videodata->
display;
155 atoms[
count++] = _NET_WM_STATE_ABOVE;
158 atoms[
count++] = _NET_WM_STATE_SKIP_TASKBAR;
159 atoms[
count++] = _NET_WM_STATE_SKIP_PAGER;
162 atoms[
count++] = _NET_WM_STATE_FOCUSED;
165 atoms[
count++] = _NET_WM_STATE_MAXIMIZED_VERT;
166 atoms[
count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
169 atoms[
count++] = _NET_WM_STATE_FULLSCREEN;
175 X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
176 PropModeReplace, (
unsigned char *)atoms,
count);
178 X11_XDeleteProperty(display, xwindow, _NET_WM_STATE);
186 Display *display = videodata->
display;
195 unsigned long i, numItems, bytesAfter;
196 unsigned char *propertyValue =
NULL;
200 if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE,
201 0l,
maxLength, False, XA_ATOM, &actualType,
202 &actualFormat, &numItems, &bytesAfter,
203 &propertyValue) == Success) {
204 Atom *atoms = (Atom *) propertyValue;
208 for (i = 0; i < numItems; ++
i) {
209 if (atoms[i] == _NET_WM_STATE_HIDDEN) {
211 }
else if (atoms[i] == _NET_WM_STATE_FOCUSED) {
213 }
else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
215 }
else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
217 }
else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) {
221 if (maximized == 3) {
225 if (fullscreen == 1) {
234 XWindowAttributes attr;
236 X11_XGetWindowAttributes(videodata->
display, xwindow, &attr);
237 if (attr.map_state == IsUnmapped) {
241 X11_XFree(propertyValue);
266 #ifdef X_HAVE_UTF8_STRING 267 if (SDL_X11_HAVE_UTF8 && videodata->
im) {
269 X11_XCreateIC(videodata->
im, XNClientWindow, w, XNFocusWindow, w,
270 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
279 if (numwindows < windowlistlength) {
280 windowlist[numwindows] =
data;
286 1) *
sizeof(*windowlist));
291 windowlist[numwindows] =
data;
299 XWindowAttributes attrib;
302 window->
x = attrib.x;
303 window->
y = attrib.y;
304 window->
w = attrib.width;
305 window->
h = attrib.height;
306 if (attrib.map_state != IsUnmapped) {
311 data->
visual = attrib.visual;
326 if (window->
flags & SDL_WINDOW_INPUT_FOCUS) {
349 Atom WM_HINTS = X11_XInternAtom(display,
"_MOTIF_WM_HINTS", True);
350 if (WM_HINTS != None) {
355 unsigned long functions;
356 unsigned long decorations;
358 unsigned long status;
360 (1L << 1), 0, border ? 1 : 0, 0, 0
363 X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
364 PropModeReplace, (
unsigned char *) &MWMHints,
365 sizeof(MWMHints) /
sizeof(
long));
367 X11_XSetTransientForHint(display, window, RootWindow(display, screen));
378 Display *display = data->
display;
379 int screen = displaydata->screen;
382 XSetWindowAttributes xattr;
384 XSizeHints *sizehints;
386 XClassHint *classhints;
387 Atom _NET_WM_BYPASS_COMPOSITOR;
388 Atom _NET_WM_WINDOW_TYPE;
390 const char *wintype_name =
NULL;
393 Atom XdndAware, xdnd_version = 5;
396 #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL 399 XVisualInfo *vinfo =
NULL;
401 #if SDL_VIDEO_OPENGL_EGL 407 vinfo = X11_GLES_GetVisual(
_this, display, screen);
411 #if SDL_VIDEO_OPENGL_GLX 412 vinfo = X11_GL_GetVisual(
_this, display, screen);
419 visual = vinfo->visual;
420 depth = vinfo->depth;
425 visual = displaydata->visual;
426 depth = displaydata->depth;
430 xattr.background_pixmap = None;
431 xattr.border_pixel = 0;
433 if (visual->class == DirectColor) {
437 int rmax, gmax, bmax;
438 int rmask, gmask, bmask;
439 int rshift, gshift, bshift;
442 X11_XCreateColormap(display, RootWindow(display, screen),
446 if (!xattr.colormap) {
447 return SDL_SetError(
"Could not create writable colormap");
451 colorcells =
SDL_malloc(visual->map_entries *
sizeof(XColor));
455 ncolors = visual->map_entries;
461 rmask = visual->red_mask;
462 while (0 == (rmask & 1)) {
468 gmask = visual->green_mask;
469 while (0 == (gmask & 1)) {
475 bmask = visual->blue_mask;
476 while (0 == (bmask & 1)) {
482 for (i = 0; i < ncolors; i++) {
487 Uint32 rbits = (rmask *
i) / (ncolors - 1);
488 Uint32 gbits = (gmask *
i) / (ncolors - 1);
489 Uint32 bbits = (bmask *
i) / (ncolors - 1);
492 (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
494 colorcells[
i].pixel = pix;
496 colorcells[
i].red =
red;
497 colorcells[
i].green =
green;
498 colorcells[
i].blue =
blue;
500 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
503 X11_XStoreColors(display, xattr.colormap, colorcells, ncolors);
508 X11_XCreateColormap(display, RootWindow(display, screen),
512 w = X11_XCreateWindow(display, RootWindow(display, screen),
513 window->
x, window->
y, window->
w, window->
h,
514 0, depth, InputOutput, visual,
515 (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
516 CWColormap), &xattr);
521 SetWindowBordered(display, screen, w,
524 sizehints = X11_XAllocSizeHints();
526 sizehints->flags = 0;
528 sizehints->min_width = sizehints->max_width = window->
w;
529 sizehints->min_height = sizehints->max_height = window->
h;
530 sizehints->flags |= (PMaxSize | PMinSize);
532 sizehints->x = window->
x;
533 sizehints->y = window->
y;
534 sizehints->flags |= USPosition;
537 wmhints = X11_XAllocWMHints();
538 wmhints->input = True;
540 wmhints->flags = InputHint | WindowGroupHint;
543 classhints = X11_XAllocClassHint();
548 X11_XSetWMProperties(display, w,
NULL,
NULL,
NULL, 0, sizehints, wmhints, classhints);
550 X11_XFree(sizehints);
552 X11_XFree(classhints);
555 long pid = (long) data->
pid;
556 _NET_WM_PID = X11_XInternAtom(display,
"_NET_WM_PID", False);
557 X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
558 (
unsigned char *) &pid, 1);
567 wintype_name =
"_NET_WM_WINDOW_TYPE_UTILITY";
569 wintype_name =
"_NET_WM_WINDOW_TYPE_TOOLTIP";
571 wintype_name =
"_NET_WM_WINDOW_TYPE_POPUP_MENU";
573 wintype_name =
"_NET_WM_WINDOW_TYPE_NORMAL";
578 _NET_WM_WINDOW_TYPE = X11_XInternAtom(display,
"_NET_WM_WINDOW_TYPE", False);
579 wintype = X11_XInternAtom(display, wintype_name, False);
580 X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
581 PropModeReplace, (
unsigned char *)&wintype, 1);
583 _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display,
"_NET_WM_BYPASS_COMPOSITOR", False);
584 X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
586 (
unsigned char *)&compositor, 1);
601 SDL_assert(proto_count <=
sizeof(protocols) /
sizeof(protocols[0]));
603 X11_XSetWMProtocols(display, w, protocols, proto_count);
607 X11_XDestroyWindow(display, w);
615 #if SDL_VIDEO_OPENGL_GLX 619 #if SDL_VIDEO_OPENGL_EGL 620 if (!
_this->egl_data) {
621 X11_XDestroyWindow(display, w);
629 X11_XDestroyWindow(display, w);
630 return SDL_SetError(
"Could not create GLES window surface");
633 return SDL_SetError(
"Could not create GLES window surface (EGL support not configured)");
639 #ifdef X_HAVE_UTF8_STRING 640 if (SDL_X11_HAVE_UTF8 && windowdata->
ic) {
641 X11_XGetICValues(windowdata->
ic, XNFilterEvents, &fevent,
NULL);
647 X11_XSelectInput(display, w,
648 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
649 ExposureMask | ButtonPressMask | ButtonReleaseMask |
650 PointerMotionMask | KeyPressMask | KeyReleaseMask |
651 PropertyChangeMask | StructureNotifyMask |
652 KeymapStateMask | fevent));
654 XdndAware = X11_XInternAtom(display,
"XdndAware", False);
655 X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
657 (
unsigned char*)&xdnd_version, 1);
667 Window w = (Window) data;
681 Display *display = data->
display;
682 int status, real_format;
684 unsigned long items_read, items_left;
685 unsigned char *propdata;
688 status = X11_XGetWindowProperty(display, xwindow, data->
_NET_WM_NAME,
689 0L, 8192L, False, data->
UTF8_STRING, &real_type, &real_format,
690 &items_read, &items_left, &propdata);
691 if (status == Success && propdata) {
695 status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME,
696 0L, 8192L, False, XA_STRING, &real_type, &real_format,
697 &items_read, &items_left, &propdata);
698 if (status == Success && propdata) {
713 XTextProperty titleprop;
715 const char *title = window->
title ? window->
title :
"";
716 char *title_locale =
NULL;
718 #ifdef X_HAVE_UTF8_STRING
728 status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
731 X11_XSetTextProperty(display, data->
xwindow, &titleprop, XA_WM_NAME);
732 X11_XFree(titleprop.value);
734 #ifdef X_HAVE_UTF8_STRING 735 if (SDL_X11_HAVE_UTF8) {
736 status = X11_Xutf8TextListToTextProperty(display, (
char **) &title, 1,
737 XUTF8StringStyle, &titleprop);
738 if (status == Success) {
739 X11_XSetTextProperty(display, data->
xwindow, &titleprop,
741 X11_XFree(titleprop.value);
762 propsize = 2 + (icon->
w * icon->
h);
763 propdata =
SDL_malloc(propsize *
sizeof(
long));
769 propdata[0] = icon->
w;
770 propdata[1] = icon->
h;
772 for (y = 0; y < icon->
h; ++
y) {
774 for (x = 0; x < icon->
w; ++
x) {
778 X11_XChangeProperty(display, data->
xwindow, _NET_WM_ICON, XA_CARDINAL,
779 32, PropModeReplace, (
unsigned char *) propdata,
784 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_ICON);
806 XSizeHints *sizehints = X11_XAllocSizeHints();
809 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
811 sizehints->min_width = window->
min_w;
812 sizehints->min_height = window->
min_h;
813 sizehints->flags |= PMinSize;
815 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
817 X11_XFree(sizehints);
820 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
822 X11_XRaiseWindow(display, data->
xwindow);
835 XSizeHints *sizehints = X11_XAllocSizeHints();
838 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
840 sizehints->max_width = window->
max_w;
841 sizehints->max_height = window->
max_h;
842 sizehints->flags |= PMaxSize;
844 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
846 X11_XFree(sizehints);
849 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
851 X11_XRaiseWindow(display, data->
xwindow);
869 XSizeHints *sizehints = X11_XAllocSizeHints();
872 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
874 sizehints->min_width = sizehints->max_width = window->
w;
875 sizehints->min_height = sizehints->max_height = window->
h;
876 sizehints->flags |= PMinSize | PMaxSize;
878 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
880 X11_XFree(sizehints);
898 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
900 X11_XRaiseWindow(display, data->
xwindow);
902 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
928 if (opacity == 1.0
f) {
929 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY);
931 const Uint32 FullyOpaque = 0xFFFFFFFF;
932 const long alpha = (long) ((
double)opacity * (double)FullyOpaque);
933 X11_XChangeProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
934 PropModeReplace, (
unsigned char *)&alpha, 1);
946 X11_XSetTransientForHint(display, data->
xwindow, parent_data->xwindow);
953 if (X11_IsWindowMapped(
_this, window)) {
956 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
974 SetWindowBordered(display, displaydata->screen, data->
xwindow, bordered);
978 XWindowAttributes attr;
980 X11_XSync(display, False);
981 X11_XGetWindowAttributes(display, data->
xwindow, &attr);
982 }
while (attr.map_state != IsViewable);
985 X11_XSetInputFocus(display, data->
xwindow, RevertToParent, CurrentTime);
990 X11_XSync(display, False);
991 X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
992 X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
1001 XSizeHints *sizehints = X11_XAllocSizeHints();
1004 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
1008 const int maxsize = 0x7FFFFFFF;
1009 sizehints->min_width = window->
min_w;
1010 sizehints->min_height = window->
min_h;
1011 sizehints->max_width = (window->
max_w == 0) ? maxsize : window->
max_w;
1012 sizehints->max_height = (window->
max_h == 0) ? maxsize : window->
max_h;
1014 sizehints->min_width = window->
w;
1015 sizehints->min_height = window->
h;
1016 sizehints->max_width = window->
w;
1017 sizehints->max_height = window->
h;
1019 sizehints->flags |= PMinSize | PMaxSize;
1021 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1023 X11_XFree(sizehints);
1026 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
1028 X11_XRaiseWindow(display, data->
xwindow);
1030 X11_XFlush(display);
1040 if (!X11_IsWindowMapped(
_this, window)) {
1041 X11_XMapRaised(display, data->
xwindow);
1046 X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
1047 X11_XFlush(display);
1052 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
1053 X11_XFlush(display);
1065 if (X11_IsWindowMapped(
_this, window)) {
1066 X11_XWithdrawWindow(display, data->
xwindow, displaydata->screen);
1069 X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
1070 X11_XFlush(display);
1083 if (X11_IsWindowMapped(
_this, window)) {
1089 e.xany.type = ClientMessage;
1090 e.xclient.message_type = _NET_ACTIVE_WINDOW;
1091 e.xclient.format = 32;
1092 e.xclient.window = data->
xwindow;
1093 e.xclient.data.l[0] = 1;
1095 e.xclient.data.l[2] = 0;
1097 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1098 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1100 X11_XFlush(display);
1110 X11_XRaiseWindow(display, data->
xwindow);
1111 SetWindowActive(
_this, window);
1112 X11_XFlush(display);
1129 window->
flags &= ~SDL_WINDOW_MAXIMIZED;
1132 if (X11_IsWindowMapped(
_this, window)) {
1136 e.xany.type = ClientMessage;
1137 e.xclient.message_type = _NET_WM_STATE;
1138 e.xclient.format = 32;
1139 e.xclient.window = data->
xwindow;
1140 e.xclient.data.l[0] =
1141 maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1142 e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
1143 e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
1144 e.xclient.data.l[3] = 0l;
1146 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1147 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1151 X11_XFlush(display);
1168 X11_XIconifyWindow(display, data->
xwindow, displaydata->screen);
1169 X11_XFlush(display);
1177 SetWindowActive(
_this, window);
1190 if (X11_IsWindowMapped(
_this, window)) {
1196 XSizeHints *sizehints = X11_XAllocSizeHints();
1198 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &flags);
1202 sizehints->flags &= ~(PMinSize | PMaxSize);
1205 sizehints->flags |= PMinSize | PMaxSize;
1206 sizehints->min_width = sizehints->max_width = window->
windowed.
w;
1207 sizehints->min_height = sizehints->max_height = window->
windowed.
h;
1209 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1210 X11_XFree(sizehints);
1214 e.xany.type = ClientMessage;
1215 e.xclient.message_type = _NET_WM_STATE;
1216 e.xclient.format = 32;
1217 e.xclient.window = data->
xwindow;
1218 e.xclient.data.l[0] =
1219 fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1220 e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
1221 e.xclient.data.l[3] = 0l;
1223 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1224 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1228 if (!fullscreen && ((window->
flags & SDL_WINDOW_MAXIMIZED) == 0)) {
1230 e.xany.type = ClientMessage;
1231 e.xclient.message_type = _NET_WM_STATE;
1232 e.xclient.format = 32;
1233 e.xclient.window = data->
xwindow;
1234 e.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
1237 e.xclient.data.l[3] = 0l;
1238 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1239 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1244 flags = window->
flags;
1248 flags &= ~SDL_WINDOW_FULLSCREEN;
1253 if (data->
visual->class == DirectColor) {
1255 X11_XInstallColormap(display, data->
colormap);
1257 X11_XUninstallColormap(display, data->
colormap);
1261 X11_XFlush(display);
1270 Visual *visual = data->
visual;
1272 const int screen = displaydata->screen;
1273 Window root = RootWindow(display, screen);
1274 const int def_vis = (visual == DefaultVisual(display, screen));
1275 unsigned long xattrmask = 0;
1276 XSetWindowAttributes xattr;
1287 xattr.override_redirect = True;
1288 xattrmask |= CWOverrideRedirect;
1289 xattr.background_pixel = def_vis ? BlackPixel(display, screen) : 0;
1290 xattrmask |= CWBackPixel;
1291 xattr.border_pixel = 0;
1292 xattrmask |= CWBorderPixel;
1294 xattrmask |= CWColormap;
1296 data->
fswindow = X11_XCreateWindow(display, root,
1297 rect.
x, rect.
y, rect.
w, rect.
h, 0,
1298 displaydata->depth, InputOutput,
1299 visual, xattrmask, &xattr);
1301 X11_XSelectInput(display, data->
fswindow, StructureNotifyMask);
1302 X11_XSetWindowBackground(display, data->
fswindow, 0);
1303 X11_XInstallColormap(display, data->
colormap);
1304 X11_XClearWindow(display, data->
fswindow);
1305 X11_XMapRaised(display, data->
fswindow);
1308 X11_XUngrabPointer(display, CurrentTime);
1309 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1312 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
fswindow);
1313 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
fswindow);
1315 #if SDL_VIDEO_DRIVER_X11_XVIDMODE 1316 if ( displaydata->use_vidmode ) {
1317 X11_XF86VidModeLockModeSwitch(display, screen, True);
1325 (rect.
w - window->
w) / 2, (rect.
h - window->
h) / 2);
1328 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1331 rect.
x += (rect.
w / 2);
1332 rect.
y += (rect.
h / 2);
1333 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1336 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1337 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1348 const int screen = displaydata->screen;
1349 Window root = RootWindow(display, screen);
1359 #if SDL_VIDEO_DRIVER_X11_VIDMODE 1360 if ( displaydata->use_vidmode ) {
1361 X11_XF86VidModeLockModeSwitch(display, screen, False);
1367 X11_XReparentWindow(display, data->
xwindow, root, window->
x, window->
y);
1370 X11_XSync(display, False);
1371 X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1372 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1374 SetWindowBordered(display, screen, data->
xwindow,
1377 X11_XWithdrawWindow(display, fswindow, screen);
1380 X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
1381 X11_XDestroyWindow(display, fswindow);
1390 const char *env =
SDL_getenv(
"SDL_VIDEO_X11_LEGACY_FULLSCREEN");
1396 if ( displaydata->use_vidmode ) {
1398 }
else if ( !videodata->
net_wm ) {
1409 X11_BeginWindowFullscreenLegacy(
_this, window, _display);
1411 X11_EndWindowFullscreenLegacy(
_this, window, _display);
1414 X11_SetWindowFullscreenViaWM(
_this, window, _display, fullscreen);
1424 Visual *visual = data->
visual;
1425 Colormap colormap = data->
colormap;
1428 int rmask, gmask, bmask;
1429 int rshift, gshift, bshift;
1432 if (visual->class != DirectColor) {
1433 return SDL_SetError(
"Window doesn't have DirectColor visual");
1436 ncolors = visual->map_entries;
1437 colorcells =
SDL_malloc(ncolors *
sizeof(XColor));
1443 rmask = visual->red_mask;
1444 while (0 == (rmask & 1)) {
1450 gmask = visual->green_mask;
1451 while (0 == (gmask & 1)) {
1457 bmask = visual->blue_mask;
1458 while (0 == (bmask & 1)) {
1464 for (i = 0; i < ncolors; i++) {
1465 Uint32 rbits = (rmask *
i) / (ncolors - 1);
1466 Uint32 gbits = (gmask *
i) / (ncolors - 1);
1467 Uint32 bbits = (bmask *
i) / (ncolors - 1);
1468 Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
1470 colorcells[
i].pixel = pix;
1472 colorcells[
i].red = ramp[(0 * 256) + i];
1473 colorcells[
i].green = ramp[(1 * 256) + i];
1474 colorcells[
i].blue = ramp[(2 * 256) + i];
1476 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
1479 X11_XStoreColors(display, colormap, colorcells, ncolors);
1480 X11_XFlush(display);
1498 oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(
_this, window);
1500 if (oldstyle_fullscreen || grabbed) {
1503 const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
1508 for (attempts = 0; attempts < 100; attempts++) {
1509 result = X11_XGrabPointer(display, data->
xwindow, True, mask, GrabModeAsync,
1510 GrabModeAsync, data->
xwindow, None, CurrentTime);
1511 if (result == GrabSuccess) {
1517 if (result != GrabSuccess) {
1524 X11_XRaiseWindow(display, data->
xwindow);
1533 grab_keyboard = oldstyle_fullscreen;
1535 if (grab_keyboard) {
1536 X11_XGrabKeyboard(display, data->
xwindow, True, GrabModeAsync,
1537 GrabModeAsync, CurrentTime);
1540 X11_XUngrabPointer(display, CurrentTime);
1541 X11_XUngrabKeyboard(display, CurrentTime);
1543 X11_XSync(display, False);
1553 Display *display = videodata->
display;
1559 for (i = 0; i < numwindows; ++
i) {
1560 if (windowlist[i] && (windowlist[i]->window == window)) {
1561 windowlist[
i] = windowlist[numwindows - 1];
1562 windowlist[numwindows - 1] =
NULL;
1568 #ifdef X_HAVE_UTF8_STRING 1570 X11_XDestroyIC(data->
ic);
1574 X11_XDestroyWindow(display, data->
xwindow);
1575 X11_XFlush(display);
1591 info->
info.
x11.display = display;
1595 SDL_SetError(
"Application not compiled with SDL %d.%d",
void SDL_UpdateWindowGrab(SDL_Window *window)
#define SDL_MINOR_VERSION
int X11_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
Atom _NET_WM_STATE_FULLSCREEN
int X11_ResizeWindowShape(SDL_Window *window)
Atom _NET_WM_ALLOWED_ACTIONS
#define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used.
void X11_SetWindowTitle(_THIS, SDL_Window *window)
#define SDL_IsShapedWindow
void SDL_SetKeyboardFocus(SDL_Window *window)
Uint32 X11_GetNetWMState(_THIS, Window xwindow)
SDL_bool broken_pointer_grab
#define SDL_VIDEO_OPENGL_ES
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
GLint GLint GLint GLint GLint x
Atom _NET_WM_STATE_MAXIMIZED_VERT
#define SDL_MAJOR_VERSION
GLuint GLuint GLsizei count
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display dpy)
struct wl_display * display
A collection of pixels used in software blitting.
SDL_WindowData ** windowlist
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void X11_MinimizeWindow(_THIS, SDL_Window *window)
Atom _NET_WM_WINDOW_OPACITY
void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
GLdouble GLdouble GLdouble GLdouble top
#define SDL_VIDEO_OPENGL_ES2
GLfloat GLfloat GLfloat alpha
int X11_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
void X11_MaximizeWindow(_THIS, SDL_Window *window)
struct SDL_GLDriverData * gl_data
#define SDL_GetHintBoolean
#define SDL_HINT_GRAB_KEYBOARD
A variable controlling whether grabbing input grabs the keyboard.
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
static SDL_VideoDevice * _this
#define SDL_iconv_utf8_locale(S)
Atom _NET_WM_STATE_SKIP_TASKBAR
Atom _NET_WM_STATE_HIDDEN
#define SDL_HINT_VIDEO_X11_NET_WM_PING
A variable controlling whether the X11 _NET_WM_PING protocol should be supported. ...
int X11_CreateWindow(_THIS, SDL_Window *window)
Atom _NET_WM_STATE_SKIP_PAGER
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
struct SDL_VideoData * videodata
int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
#define SDL_static_cast(type, expression)
int X11_SetWindowInputFocus(_THIS, SDL_Window *window)
void X11_RestoreWindow(_THIS, SDL_Window *window)
GLubyte GLubyte GLubyte GLubyte w
int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
GLint GLint GLint GLint GLint GLint y
void X11_ShowWindow(_THIS, SDL_Window *window)
void X11_DestroyWindow(_THIS, SDL_Window *window)
#define SDL_VIDEO_OPENGL_GLX
struct SDL_SysWMinfo::@18::@19 x11
GLenum GLenum GLsizei const GLuint GLboolean enabled
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
void X11_SetWindowMinimumSize(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
int X11_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window)
GLint GLint GLsizei GLsizei GLsizei depth
Atom _NET_WM_STATE_MAXIMIZED_HORZ
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
Atom _NET_WM_STATE_FOCUSED
void X11_RaiseWindow(_THIS, SDL_Window *window)
void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
char * X11_GetWindowTitle(_THIS, Window xwindow)
GLint GLint GLsizei GLsizei GLsizei GLint border
GLuint GLuint GLsizei GLenum type
union SDL_SysWMinfo::@18 info
#define SDL_arraysize(array)
struct SDL_VideoDevice::@34 gl_config
void X11_SetWindowSize(_THIS, SDL_Window *window)
void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void X11_HideWindow(_THIS, SDL_Window *window)
void X11_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
void X11_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
A rectangle, with the origin at the upper left.
SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void X11_SetWindowMaximumSize(_THIS, SDL_Window *window)
void X11_SetWindowPosition(_THIS, SDL_Window *window)