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 47 #define _NET_WM_STATE_TOGGLE 2l 49 static Bool isMapNotify(Display *
dpy, XEvent *ev, XPointer win)
51 return ev->type == MapNotify && ev->xmap.window == *((Window*)win);
53 static Bool isUnmapNotify(Display *
dpy, XEvent *ev, XPointer win)
55 return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
89 XWindowAttributes attr;
91 X11_XGetWindowAttributes(videodata->display, data->
xwindow, &attr);
92 if (attr.map_state != IsUnmapped) {
101 X11_IsActionAllowed(
SDL_Window *window, Atom action)
108 unsigned long remain;
109 unsigned long len,
i;
113 if (X11_XGetWindowProperty(display, data->
xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &
type, &form, &len, &remain, (
unsigned char **)&list) == Success)
117 if (list[
i] == action) {
132 Display *display = videodata->
display;
156 atoms[
count++] = _NET_WM_STATE_ABOVE;
159 atoms[
count++] = _NET_WM_STATE_SKIP_TASKBAR;
160 atoms[
count++] = _NET_WM_STATE_SKIP_PAGER;
163 atoms[
count++] = _NET_WM_STATE_FOCUSED;
166 atoms[
count++] = _NET_WM_STATE_MAXIMIZED_VERT;
167 atoms[
count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
170 atoms[
count++] = _NET_WM_STATE_FULLSCREEN;
176 X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
177 PropModeReplace, (
unsigned char *)atoms,
count);
179 X11_XDeleteProperty(display, xwindow, _NET_WM_STATE);
187 Display *display = videodata->
display;
196 unsigned long i, numItems, bytesAfter;
197 unsigned char *propertyValue =
NULL;
201 if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE,
202 0l,
maxLength, False, XA_ATOM, &actualType,
203 &actualFormat, &numItems, &bytesAfter,
204 &propertyValue) == Success) {
205 Atom *atoms = (Atom *) propertyValue;
209 for (i = 0; i < numItems; ++
i) {
210 if (atoms[i] == _NET_WM_STATE_HIDDEN) {
212 }
else if (atoms[i] == _NET_WM_STATE_FOCUSED) {
214 }
else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
216 }
else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
218 }
else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) {
222 if (maximized == 3) {
226 if (fullscreen == 1) {
229 X11_XFree(propertyValue);
254 #ifdef X_HAVE_UTF8_STRING 255 if (SDL_X11_HAVE_UTF8 && videodata->
im) {
257 X11_XCreateIC(videodata->
im, XNClientWindow, w, XNFocusWindow, w,
258 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
267 if (numwindows < windowlistlength) {
268 windowlist[numwindows] =
data;
274 1) *
sizeof(*windowlist));
279 windowlist[numwindows] =
data;
287 XWindowAttributes attrib;
290 window->
x = attrib.x;
291 window->
y = attrib.y;
292 window->
w = attrib.width;
293 window->
h = attrib.height;
294 if (attrib.map_state != IsUnmapped) {
299 data->
visual = attrib.visual;
314 if (window->
flags & SDL_WINDOW_INPUT_FOCUS) {
337 Atom WM_HINTS = X11_XInternAtom(display,
"_MOTIF_WM_HINTS", True);
338 if (WM_HINTS != None) {
343 unsigned long functions;
344 unsigned long decorations;
346 unsigned long status;
348 (1L << 1), 0, border ? 1 : 0, 0, 0
351 X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
352 PropModeReplace, (
unsigned char *) &MWMHints,
353 sizeof(MWMHints) /
sizeof(
long));
355 X11_XSetTransientForHint(display, window, RootWindow(display, screen));
366 Display *display = data->
display;
367 int screen = displaydata->screen;
370 XSetWindowAttributes xattr;
372 XSizeHints *sizehints;
374 XClassHint *classhints;
375 Atom _NET_WM_BYPASS_COMPOSITOR;
376 Atom _NET_WM_WINDOW_TYPE;
378 const char *wintype_name =
NULL;
381 Atom XdndAware, xdnd_version = 5;
384 #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL 387 XVisualInfo *vinfo =
NULL;
389 #if SDL_VIDEO_OPENGL_EGL 395 vinfo = X11_GLES_GetVisual(
_this, display, screen);
399 #if SDL_VIDEO_OPENGL_GLX 400 vinfo = X11_GL_GetVisual(
_this, display, screen);
407 visual = vinfo->visual;
408 depth = vinfo->depth;
413 visual = displaydata->visual;
414 depth = displaydata->depth;
418 xattr.background_pixmap = None;
419 xattr.border_pixel = 0;
421 if (visual->class == DirectColor) {
425 int rmax, gmax, bmax;
426 int rmask, gmask, bmask;
427 int rshift, gshift, bshift;
430 X11_XCreateColormap(display, RootWindow(display, screen),
434 if (!xattr.colormap) {
435 return SDL_SetError(
"Could not create writable colormap");
439 colorcells =
SDL_malloc(visual->map_entries *
sizeof(XColor));
443 ncolors = visual->map_entries;
449 rmask = visual->red_mask;
450 while (0 == (rmask & 1)) {
456 gmask = visual->green_mask;
457 while (0 == (gmask & 1)) {
463 bmask = visual->blue_mask;
464 while (0 == (bmask & 1)) {
470 for (i = 0; i < ncolors; i++) {
475 Uint32 rbits = (rmask *
i) / (ncolors - 1);
476 Uint32 gbits = (gmask *
i) / (ncolors - 1);
477 Uint32 bbits = (bmask *
i) / (ncolors - 1);
480 (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
482 colorcells[
i].pixel = pix;
484 colorcells[
i].red =
red;
485 colorcells[
i].green =
green;
486 colorcells[
i].blue =
blue;
488 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
491 X11_XStoreColors(display, xattr.colormap, colorcells, ncolors);
496 X11_XCreateColormap(display, RootWindow(display, screen),
500 w = X11_XCreateWindow(display, RootWindow(display, screen),
501 window->
x, window->
y, window->
w, window->
h,
502 0, depth, InputOutput, visual,
503 (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
504 CWColormap), &xattr);
509 SetWindowBordered(display, screen, w,
512 sizehints = X11_XAllocSizeHints();
514 sizehints->flags = 0;
516 sizehints->min_width = sizehints->max_width = window->
w;
517 sizehints->min_height = sizehints->max_height = window->
h;
518 sizehints->flags |= (PMaxSize | PMinSize);
520 sizehints->x = window->
x;
521 sizehints->y = window->
y;
522 sizehints->flags |= USPosition;
525 wmhints = X11_XAllocWMHints();
526 wmhints->input = True;
528 wmhints->flags = InputHint | WindowGroupHint;
531 classhints = X11_XAllocClassHint();
536 X11_XSetWMProperties(display, w,
NULL,
NULL,
NULL, 0, sizehints, wmhints, classhints);
538 X11_XFree(sizehints);
540 X11_XFree(classhints);
543 long pid = (long) data->
pid;
544 _NET_WM_PID = X11_XInternAtom(display,
"_NET_WM_PID", False);
545 X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
546 (
unsigned char *) &pid, 1);
555 wintype_name =
"_NET_WM_WINDOW_TYPE_UTILITY";
557 wintype_name =
"_NET_WM_WINDOW_TYPE_TOOLTIP";
559 wintype_name =
"_NET_WM_WINDOW_TYPE_POPUP_MENU";
561 wintype_name =
"_NET_WM_WINDOW_TYPE_NORMAL";
566 _NET_WM_WINDOW_TYPE = X11_XInternAtom(display,
"_NET_WM_WINDOW_TYPE", False);
567 wintype = X11_XInternAtom(display, wintype_name, False);
568 X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
569 PropModeReplace, (
unsigned char *)&wintype, 1);
571 _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display,
"_NET_WM_BYPASS_COMPOSITOR", False);
572 X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
574 (
unsigned char *)&compositor, 1);
588 SDL_assert(proto_count <=
sizeof(protocols) /
sizeof(protocols[0]));
590 X11_XSetWMProtocols(display, w, protocols, proto_count);
594 X11_XDestroyWindow(display, w);
602 #if SDL_VIDEO_OPENGL_GLX 606 #if SDL_VIDEO_OPENGL_EGL 607 if (!
_this->egl_data) {
608 X11_XDestroyWindow(display, w);
613 windowdata->
egl_surface = SDL_EGL_CreateSurface(
_this, (NativeWindowType) w);
616 X11_XDestroyWindow(display, w);
617 return SDL_SetError(
"Could not create GLES window surface");
620 return SDL_SetError(
"Could not create GLES window surface (no EGL support available)");
626 #ifdef X_HAVE_UTF8_STRING 627 if (SDL_X11_HAVE_UTF8 && windowdata->
ic) {
628 X11_XGetICValues(windowdata->
ic, XNFilterEvents, &fevent,
NULL);
634 X11_XSelectInput(display, w,
635 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
636 ExposureMask | ButtonPressMask | ButtonReleaseMask |
637 PointerMotionMask | KeyPressMask | KeyReleaseMask |
638 PropertyChangeMask | StructureNotifyMask |
639 KeymapStateMask | fevent));
641 XdndAware = X11_XInternAtom(display,
"XdndAware", False);
642 X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
644 (
unsigned char*)&xdnd_version, 1);
654 Window w = (Window) data;
668 Display *display = data->
display;
669 int status, real_format;
671 unsigned long items_read, items_left;
672 unsigned char *propdata;
675 status = X11_XGetWindowProperty(display, xwindow, data->
_NET_WM_NAME,
676 0L, 8192L, False, data->
UTF8_STRING, &real_type, &real_format,
677 &items_read, &items_left, &propdata);
678 if (status == Success && propdata) {
682 status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME,
683 0L, 8192L, False, XA_STRING, &real_type, &real_format,
684 &items_read, &items_left, &propdata);
685 if (status == Success && propdata) {
700 XTextProperty titleprop;
702 const char *title = window->
title ? window->
title :
"";
703 char *title_locale =
NULL;
705 #ifdef X_HAVE_UTF8_STRING
715 status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
718 X11_XSetTextProperty(display, data->
xwindow, &titleprop, XA_WM_NAME);
719 X11_XFree(titleprop.value);
721 #ifdef X_HAVE_UTF8_STRING 722 if (SDL_X11_HAVE_UTF8) {
723 status = X11_Xutf8TextListToTextProperty(display, (
char **) &title, 1,
724 XUTF8StringStyle, &titleprop);
725 if (status == Success) {
726 X11_XSetTextProperty(display, data->
xwindow, &titleprop,
728 X11_XFree(titleprop.value);
749 propsize = 2 + (icon->
w * icon->
h);
750 propdata =
SDL_malloc(propsize *
sizeof(
long));
756 propdata[0] = icon->
w;
757 propdata[1] = icon->
h;
759 for (y = 0; y < icon->
h; ++
y) {
761 for (x = 0; x < icon->
w; ++
x) {
765 X11_XChangeProperty(display, data->
xwindow, _NET_WM_ICON, XA_CARDINAL,
766 32, PropModeReplace, (
unsigned char *) propdata,
771 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_ICON);
793 XSizeHints *sizehints = X11_XAllocSizeHints();
796 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
798 sizehints->min_width = window->
min_w;
799 sizehints->min_height = window->
min_h;
800 sizehints->flags |= PMinSize;
802 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
804 X11_XFree(sizehints);
807 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
809 X11_XRaiseWindow(display, data->
xwindow);
822 XSizeHints *sizehints = X11_XAllocSizeHints();
825 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
827 sizehints->max_width = window->
max_w;
828 sizehints->max_height = window->
max_h;
829 sizehints->flags |= PMaxSize;
831 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
833 X11_XFree(sizehints);
836 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
838 X11_XRaiseWindow(display, data->
xwindow);
856 XSizeHints *sizehints = X11_XAllocSizeHints();
859 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
861 sizehints->min_width = sizehints->max_width = window->
w;
862 sizehints->min_height = sizehints->max_height = window->
h;
863 sizehints->flags |= PMinSize | PMaxSize;
865 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
867 X11_XFree(sizehints);
885 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
887 X11_XRaiseWindow(display, data->
xwindow);
889 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
915 if (opacity == 1.0
f) {
916 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY);
918 const Uint32 FullyOpaque = 0xFFFFFFFF;
919 const long alpha = (long) ((
double)opacity * (double)FullyOpaque);
920 X11_XChangeProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
921 PropModeReplace, (
unsigned char *)&alpha, 1);
933 X11_XSetTransientForHint(display, data->
xwindow, parent_data->xwindow);
940 if (X11_IsWindowMapped(
_this, window)) {
943 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
961 SetWindowBordered(display, displaydata->screen, data->
xwindow, bordered);
965 XWindowAttributes attr;
967 X11_XSync(display, False);
968 X11_XGetWindowAttributes(display, data->
xwindow, &attr);
969 }
while (attr.map_state != IsViewable);
972 X11_XSetInputFocus(display, data->
xwindow, RevertToParent, CurrentTime);
977 X11_XSync(display, False);
978 X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
979 X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
988 XSizeHints *sizehints = X11_XAllocSizeHints();
991 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
995 const int maxsize = 0x7FFFFFFF;
996 sizehints->min_width = window->
min_w;
997 sizehints->min_height = window->
min_h;
998 sizehints->max_width = (window->
max_w == 0) ? maxsize : window->
max_w;
999 sizehints->max_height = (window->
max_h == 0) ? maxsize : window->
max_h;
1001 sizehints->min_width = window->
w;
1002 sizehints->min_height = window->
h;
1003 sizehints->max_width = window->
w;
1004 sizehints->max_height = window->
h;
1006 sizehints->flags |= PMinSize | PMaxSize;
1008 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1010 X11_XFree(sizehints);
1013 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
1015 X11_XRaiseWindow(display, data->
xwindow);
1017 X11_XFlush(display);
1027 if (!X11_IsWindowMapped(
_this, window)) {
1028 X11_XMapRaised(display, data->
xwindow);
1032 X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
1033 X11_XFlush(display);
1038 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
1039 X11_XFlush(display);
1051 if (X11_IsWindowMapped(
_this, window)) {
1052 X11_XWithdrawWindow(display, data->
xwindow, displaydata->screen);
1054 X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
1055 X11_XFlush(display);
1068 if (X11_IsWindowMapped(
_this, window)) {
1074 e.xany.type = ClientMessage;
1075 e.xclient.message_type = _NET_ACTIVE_WINDOW;
1076 e.xclient.format = 32;
1077 e.xclient.window = data->
xwindow;
1078 e.xclient.data.l[0] = 1;
1080 e.xclient.data.l[2] = 0;
1082 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1083 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1085 X11_XFlush(display);
1095 X11_XRaiseWindow(display, data->
xwindow);
1096 SetWindowActive(
_this, window);
1097 X11_XFlush(display);
1114 window->
flags &= ~SDL_WINDOW_MAXIMIZED;
1117 if (X11_IsWindowMapped(
_this, window)) {
1121 e.xany.type = ClientMessage;
1122 e.xclient.message_type = _NET_WM_STATE;
1123 e.xclient.format = 32;
1124 e.xclient.window = data->
xwindow;
1125 e.xclient.data.l[0] =
1126 maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1127 e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
1128 e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
1129 e.xclient.data.l[3] = 0l;
1131 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1132 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1136 X11_XFlush(display);
1153 X11_XIconifyWindow(display, data->
xwindow, displaydata->screen);
1154 X11_XFlush(display);
1162 SetWindowActive(
_this, window);
1175 if (X11_IsWindowMapped(
_this, window)) {
1181 XSizeHints *sizehints = X11_XAllocSizeHints();
1183 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &flags);
1187 sizehints->flags &= ~(PMinSize | PMaxSize);
1190 sizehints->flags |= PMinSize | PMaxSize;
1191 sizehints->min_width = sizehints->max_width = window->
windowed.
w;
1192 sizehints->min_height = sizehints->max_height = window->
windowed.
h;
1194 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1195 X11_XFree(sizehints);
1199 e.xany.type = ClientMessage;
1200 e.xclient.message_type = _NET_WM_STATE;
1201 e.xclient.format = 32;
1202 e.xclient.window = data->
xwindow;
1203 e.xclient.data.l[0] =
1204 fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1205 e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
1206 e.xclient.data.l[3] = 0l;
1208 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1209 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1213 if (!fullscreen && ((window->
flags & SDL_WINDOW_MAXIMIZED) == 0)) {
1215 e.xany.type = ClientMessage;
1216 e.xclient.message_type = _NET_WM_STATE;
1217 e.xclient.format = 32;
1218 e.xclient.window = data->
xwindow;
1219 e.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
1222 e.xclient.data.l[3] = 0l;
1223 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1224 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1229 flags = window->
flags;
1233 flags &= ~SDL_WINDOW_FULLSCREEN;
1238 if (data->
visual->class == DirectColor) {
1240 X11_XInstallColormap(display, data->
colormap);
1242 X11_XUninstallColormap(display, data->
colormap);
1246 X11_XFlush(display);
1255 Visual *visual = data->
visual;
1257 const int screen = displaydata->screen;
1258 Window root = RootWindow(display, screen);
1259 const int def_vis = (visual == DefaultVisual(display, screen));
1260 unsigned long xattrmask = 0;
1261 XSetWindowAttributes xattr;
1272 xattr.override_redirect = True;
1273 xattrmask |= CWOverrideRedirect;
1274 xattr.background_pixel = def_vis ? BlackPixel(display, screen) : 0;
1275 xattrmask |= CWBackPixel;
1276 xattr.border_pixel = 0;
1277 xattrmask |= CWBorderPixel;
1279 xattrmask |= CWColormap;
1281 data->
fswindow = X11_XCreateWindow(display, root,
1282 rect.
x, rect.
y, rect.
w, rect.
h, 0,
1283 displaydata->depth, InputOutput,
1284 visual, xattrmask, &xattr);
1286 X11_XSelectInput(display, data->
fswindow, StructureNotifyMask);
1287 X11_XSetWindowBackground(display, data->
fswindow, 0);
1288 X11_XInstallColormap(display, data->
colormap);
1289 X11_XClearWindow(display, data->
fswindow);
1290 X11_XMapRaised(display, data->
fswindow);
1293 X11_XUngrabPointer(display, CurrentTime);
1294 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1297 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
fswindow);
1298 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
fswindow);
1300 #if SDL_VIDEO_DRIVER_X11_XVIDMODE 1301 if ( displaydata->use_vidmode ) {
1302 X11_XF86VidModeLockModeSwitch(display, screen, True);
1310 (rect.
w - window->
w) / 2, (rect.
h - window->
h) / 2);
1313 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1316 rect.
x += (rect.
w / 2);
1317 rect.
y += (rect.
h / 2);
1318 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1321 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1322 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1333 const int screen = displaydata->screen;
1334 Window root = RootWindow(display, screen);
1344 #if SDL_VIDEO_DRIVER_X11_VIDMODE 1345 if ( displaydata->use_vidmode ) {
1346 X11_XF86VidModeLockModeSwitch(display, screen, False);
1352 X11_XReparentWindow(display, data->
xwindow, root, window->
x, window->
y);
1355 X11_XSync(display, False);
1356 X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1357 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1359 SetWindowBordered(display, screen, data->
xwindow,
1362 X11_XWithdrawWindow(display, fswindow, screen);
1365 X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
1366 X11_XDestroyWindow(display, fswindow);
1375 const char *env =
SDL_getenv(
"SDL_VIDEO_X11_LEGACY_FULLSCREEN");
1381 if ( displaydata->use_vidmode ) {
1383 }
else if ( !videodata->
net_wm ) {
1394 X11_BeginWindowFullscreenLegacy(
_this, window, _display);
1396 X11_EndWindowFullscreenLegacy(
_this, window, _display);
1399 X11_SetWindowFullscreenViaWM(
_this, window, _display, fullscreen);
1409 Visual *visual = data->
visual;
1410 Colormap colormap = data->
colormap;
1413 int rmask, gmask, bmask;
1414 int rshift, gshift, bshift;
1417 if (visual->class != DirectColor) {
1418 return SDL_SetError(
"Window doesn't have DirectColor visual");
1421 ncolors = visual->map_entries;
1422 colorcells =
SDL_malloc(ncolors *
sizeof(XColor));
1428 rmask = visual->red_mask;
1429 while (0 == (rmask & 1)) {
1435 gmask = visual->green_mask;
1436 while (0 == (gmask & 1)) {
1442 bmask = visual->blue_mask;
1443 while (0 == (bmask & 1)) {
1449 for (i = 0; i < ncolors; i++) {
1450 Uint32 rbits = (rmask *
i) / (ncolors - 1);
1451 Uint32 gbits = (gmask *
i) / (ncolors - 1);
1452 Uint32 bbits = (bmask *
i) / (ncolors - 1);
1453 Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
1455 colorcells[
i].pixel = pix;
1457 colorcells[
i].red = ramp[(0 * 256) + i];
1458 colorcells[
i].green = ramp[(1 * 256) + i];
1459 colorcells[
i].blue = ramp[(2 * 256) + i];
1461 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
1464 X11_XStoreColors(display, colormap, colorcells, ncolors);
1465 X11_XFlush(display);
1483 oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(
_this, window);
1485 if (oldstyle_fullscreen || grabbed) {
1489 X11_XGrabPointer(display, data->
xwindow, True, 0, GrabModeAsync,
1490 GrabModeAsync, data->
xwindow, None, CurrentTime);
1491 if (result == GrabSuccess) {
1498 X11_XRaiseWindow(display, data->
xwindow);
1507 grab_keyboard = oldstyle_fullscreen;
1509 if (grab_keyboard) {
1510 X11_XGrabKeyboard(display, data->
xwindow, True, GrabModeAsync,
1511 GrabModeAsync, CurrentTime);
1514 X11_XUngrabPointer(display, CurrentTime);
1515 X11_XUngrabKeyboard(display, CurrentTime);
1517 X11_XSync(display, False);
1527 Display *display = videodata->
display;
1533 for (i = 0; i < numwindows; ++
i) {
1534 if (windowlist[i] && (windowlist[i]->window == window)) {
1535 windowlist[
i] = windowlist[numwindows - 1];
1536 windowlist[numwindows - 1] =
NULL;
1542 #ifdef X_HAVE_UTF8_STRING 1544 X11_XDestroyIC(data->
ic);
1548 X11_XDestroyWindow(display, data->
xwindow);
1549 X11_XFlush(display);
1565 info->
info.
x11.display = display;
1569 SDL_SetError(
"Application not compiled with SDL %d.%d\n",
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
void X11_SetWindowTitle(_THIS, SDL_Window *window)
#define SDL_IsShapedWindow
void SDL_SetKeyboardFocus(SDL_Window *window)
Uint32 X11_GetNetWMState(_THIS, Window xwindow)
#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
Atom _NET_WM_STATE_MAXIMIZED_VERT
GLint GLint GLint GLint GLint x
#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
static SDL_Window * window
A collection of pixels used in software blitting.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
SDL_WindowData ** windowlist
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)
uint32_t Uint32
An unsigned 32-bit integer type.
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. ...
GLuint GLuint GLsizei GLenum type
void * SDL_calloc(size_t nmemb, size_t size)
int X11_CreateWindow(_THIS, SDL_Window *window)
GLint GLint GLint GLint GLint GLint y
Atom _NET_WM_STATE_SKIP_PAGER
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
struct SDL_VideoData * videodata
uint8_t Uint8
An unsigned 8-bit integer type.
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)
int X11_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
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)
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)
struct SDL_VideoDevice::@28 gl_config
GLint GLint GLsizei GLsizei GLsizei GLint border
uint16_t Uint16
An unsigned 16-bit integer type.
union SDL_SysWMinfo::@18 info
#define SDL_arraysize(array)
GLubyte GLubyte GLubyte GLubyte w
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)