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) {
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;
395 #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL 398 XVisualInfo *vinfo =
NULL;
400 #if SDL_VIDEO_OPENGL_EGL 406 vinfo = X11_GLES_GetVisual(
_this, display, screen);
410 #if SDL_VIDEO_OPENGL_GLX 411 vinfo = X11_GL_GetVisual(
_this, display, screen);
418 visual = vinfo->visual;
419 depth = vinfo->depth;
424 visual = displaydata->visual;
425 depth = displaydata->depth;
429 xattr.background_pixmap = None;
430 xattr.border_pixel = 0;
432 if (visual->class == DirectColor) {
436 int rmax, gmax, bmax;
437 int rmask, gmask, bmask;
438 int rshift, gshift, bshift;
441 X11_XCreateColormap(display, RootWindow(display, screen),
445 if (!xattr.colormap) {
446 return SDL_SetError(
"Could not create writable colormap");
450 colorcells =
SDL_malloc(visual->map_entries *
sizeof(XColor));
454 ncolors = visual->map_entries;
460 rmask = visual->red_mask;
461 while (0 == (rmask & 1)) {
467 gmask = visual->green_mask;
468 while (0 == (gmask & 1)) {
474 bmask = visual->blue_mask;
475 while (0 == (bmask & 1)) {
481 for (i = 0; i < ncolors; i++) {
486 Uint32 rbits = (rmask *
i) / (ncolors - 1);
487 Uint32 gbits = (gmask *
i) / (ncolors - 1);
488 Uint32 bbits = (bmask *
i) / (ncolors - 1);
491 (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
493 colorcells[
i].pixel = pix;
495 colorcells[
i].red =
red;
496 colorcells[
i].green =
green;
497 colorcells[
i].blue =
blue;
499 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
502 X11_XStoreColors(display, xattr.colormap, colorcells, ncolors);
507 X11_XCreateColormap(display, RootWindow(display, screen),
511 w = X11_XCreateWindow(display, RootWindow(display, screen),
512 window->
x, window->
y, window->
w, window->
h,
513 0, depth, InputOutput, visual,
514 (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
515 CWColormap), &xattr);
520 SetWindowBordered(display, screen, w,
523 sizehints = X11_XAllocSizeHints();
525 sizehints->flags = 0;
527 sizehints->min_width = sizehints->max_width = window->
w;
528 sizehints->min_height = sizehints->max_height = window->
h;
529 sizehints->flags |= (PMaxSize | PMinSize);
531 sizehints->x = window->
x;
532 sizehints->y = window->
y;
533 sizehints->flags |= USPosition;
536 wmhints = X11_XAllocWMHints();
537 wmhints->input = True;
539 wmhints->flags = InputHint | WindowGroupHint;
542 classhints = X11_XAllocClassHint();
547 X11_XSetWMProperties(display, w,
NULL,
NULL,
NULL, 0, sizehints, wmhints, classhints);
549 X11_XFree(sizehints);
551 X11_XFree(classhints);
554 long pid = (long) data->
pid;
555 _NET_WM_PID = X11_XInternAtom(display,
"_NET_WM_PID", False);
556 X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
557 (
unsigned char *) &pid, 1);
566 wintype_name =
"_NET_WM_WINDOW_TYPE_UTILITY";
568 wintype_name =
"_NET_WM_WINDOW_TYPE_TOOLTIP";
570 wintype_name =
"_NET_WM_WINDOW_TYPE_POPUP_MENU";
572 wintype_name =
"_NET_WM_WINDOW_TYPE_NORMAL";
577 _NET_WM_WINDOW_TYPE = X11_XInternAtom(display,
"_NET_WM_WINDOW_TYPE", False);
578 wintype = X11_XInternAtom(display, wintype_name, False);
579 X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
580 PropModeReplace, (
unsigned char *)&wintype, 1);
582 _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display,
"_NET_WM_BYPASS_COMPOSITOR", False);
583 X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
585 (
unsigned char *)&compositor, 1);
600 SDL_assert(proto_count <=
sizeof(protocols) /
sizeof(protocols[0]));
602 X11_XSetWMProtocols(display, w, protocols, proto_count);
606 X11_XDestroyWindow(display, w);
614 #if SDL_VIDEO_OPENGL_GLX 618 #if SDL_VIDEO_OPENGL_EGL 619 if (!
_this->egl_data) {
620 X11_XDestroyWindow(display, w);
628 X11_XDestroyWindow(display, w);
629 return SDL_SetError(
"Could not create GLES window surface");
632 return SDL_SetError(
"Could not create GLES window surface (EGL support not configured)");
638 #ifdef X_HAVE_UTF8_STRING 639 if (SDL_X11_HAVE_UTF8 && windowdata->
ic) {
640 X11_XGetICValues(windowdata->
ic, XNFilterEvents, &fevent,
NULL);
646 X11_XSelectInput(display, w,
647 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
648 ExposureMask | ButtonPressMask | ButtonReleaseMask |
649 PointerMotionMask | KeyPressMask | KeyReleaseMask |
650 PropertyChangeMask | StructureNotifyMask |
651 KeymapStateMask | fevent));
661 Window w = (Window) data;
675 Display *display = data->
display;
676 int status, real_format;
678 unsigned long items_read, items_left;
679 unsigned char *propdata;
682 status = X11_XGetWindowProperty(display, xwindow, data->
_NET_WM_NAME,
683 0L, 8192L, False, data->
UTF8_STRING, &real_type, &real_format,
684 &items_read, &items_left, &propdata);
685 if (status == Success && propdata) {
689 status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME,
690 0L, 8192L, False, XA_STRING, &real_type, &real_format,
691 &items_read, &items_left, &propdata);
692 if (status == Success && propdata) {
707 XTextProperty titleprop;
709 const char *title = window->
title ? window->
title :
"";
710 char *title_locale =
NULL;
712 #ifdef X_HAVE_UTF8_STRING
722 status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
725 X11_XSetTextProperty(display, data->
xwindow, &titleprop, XA_WM_NAME);
726 X11_XFree(titleprop.value);
728 #ifdef X_HAVE_UTF8_STRING 729 if (SDL_X11_HAVE_UTF8) {
730 status = X11_Xutf8TextListToTextProperty(display, (
char **) &title, 1,
731 XUTF8StringStyle, &titleprop);
732 if (status == Success) {
733 X11_XSetTextProperty(display, data->
xwindow, &titleprop,
735 X11_XFree(titleprop.value);
756 propsize = 2 + (icon->
w * icon->
h);
757 propdata =
SDL_malloc(propsize *
sizeof(
long));
763 propdata[0] = icon->
w;
764 propdata[1] = icon->
h;
766 for (y = 0; y < icon->
h; ++
y) {
768 for (x = 0; x < icon->
w; ++
x) {
772 X11_XChangeProperty(display, data->
xwindow, _NET_WM_ICON, XA_CARDINAL,
773 32, PropModeReplace, (
unsigned char *) propdata,
778 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_ICON);
800 XSizeHints *sizehints = X11_XAllocSizeHints();
803 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
805 sizehints->min_width = window->
min_w;
806 sizehints->min_height = window->
min_h;
807 sizehints->flags |= PMinSize;
809 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
811 X11_XFree(sizehints);
814 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
816 X11_XRaiseWindow(display, data->
xwindow);
829 XSizeHints *sizehints = X11_XAllocSizeHints();
832 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
834 sizehints->max_width = window->
max_w;
835 sizehints->max_height = window->
max_h;
836 sizehints->flags |= PMaxSize;
838 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
840 X11_XFree(sizehints);
843 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
845 X11_XRaiseWindow(display, data->
xwindow);
863 XSizeHints *sizehints = X11_XAllocSizeHints();
866 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
868 sizehints->min_width = sizehints->max_width = window->
w;
869 sizehints->min_height = sizehints->max_height = window->
h;
870 sizehints->flags |= PMinSize | PMaxSize;
872 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
874 X11_XFree(sizehints);
892 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
894 X11_XRaiseWindow(display, data->
xwindow);
896 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
922 if (opacity == 1.0
f) {
923 X11_XDeleteProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY);
925 const Uint32 FullyOpaque = 0xFFFFFFFF;
926 const long alpha = (long) ((
double)opacity * (double)FullyOpaque);
927 X11_XChangeProperty(display, data->
xwindow, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
928 PropModeReplace, (
unsigned char *)&alpha, 1);
940 X11_XSetTransientForHint(display, data->
xwindow, parent_data->xwindow);
947 if (X11_IsWindowMapped(
_this, window)) {
950 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
968 SetWindowBordered(display, displaydata->screen, data->
xwindow, bordered);
972 XWindowAttributes attr;
974 X11_XSync(display, False);
975 X11_XGetWindowAttributes(display, data->
xwindow, &attr);
976 }
while (attr.map_state != IsViewable);
979 X11_XSetInputFocus(display, data->
xwindow, RevertToParent, CurrentTime);
984 X11_XSync(display, False);
985 X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
986 X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
995 XSizeHints *sizehints = X11_XAllocSizeHints();
998 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &userhints);
1002 const int maxsize = 0x7FFFFFFF;
1003 sizehints->min_width = window->
min_w;
1004 sizehints->min_height = window->
min_h;
1005 sizehints->max_width = (window->
max_w == 0) ? maxsize : window->
max_w;
1006 sizehints->max_height = (window->
max_h == 0) ? maxsize : window->
max_h;
1008 sizehints->min_width = window->
w;
1009 sizehints->min_height = window->
h;
1010 sizehints->max_width = window->
w;
1011 sizehints->max_height = window->
h;
1013 sizehints->flags |= PMinSize | PMaxSize;
1015 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1017 X11_XFree(sizehints);
1020 X11_XResizeWindow(display, data->
xwindow, window->
w, window->
h);
1022 X11_XRaiseWindow(display, data->
xwindow);
1024 X11_XFlush(display);
1034 if (!X11_IsWindowMapped(
_this, window)) {
1035 X11_XMapRaised(display, data->
xwindow);
1040 X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->
xwindow);
1041 X11_XFlush(display);
1046 X11_XSetInputFocus(display, data->
xwindow, RevertToNone, CurrentTime);
1047 X11_XFlush(display);
1059 if (X11_IsWindowMapped(
_this, window)) {
1060 X11_XWithdrawWindow(display, data->
xwindow, displaydata->screen);
1063 X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->
xwindow);
1064 X11_XFlush(display);
1077 if (X11_IsWindowMapped(
_this, window)) {
1083 e.xany.type = ClientMessage;
1084 e.xclient.message_type = _NET_ACTIVE_WINDOW;
1085 e.xclient.format = 32;
1086 e.xclient.window = data->
xwindow;
1087 e.xclient.data.l[0] = 1;
1089 e.xclient.data.l[2] = 0;
1091 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1092 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1094 X11_XFlush(display);
1104 X11_XRaiseWindow(display, data->
xwindow);
1105 SetWindowActive(
_this, window);
1106 X11_XFlush(display);
1123 window->
flags &= ~SDL_WINDOW_MAXIMIZED;
1126 if (X11_IsWindowMapped(
_this, window)) {
1130 e.xany.type = ClientMessage;
1131 e.xclient.message_type = _NET_WM_STATE;
1132 e.xclient.format = 32;
1133 e.xclient.window = data->
xwindow;
1134 e.xclient.data.l[0] =
1135 maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1136 e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
1137 e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
1138 e.xclient.data.l[3] = 0l;
1140 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1141 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1145 X11_XFlush(display);
1162 X11_XIconifyWindow(display, data->
xwindow, displaydata->screen);
1163 X11_XFlush(display);
1171 SetWindowActive(
_this, window);
1184 if (X11_IsWindowMapped(
_this, window)) {
1190 XSizeHints *sizehints = X11_XAllocSizeHints();
1192 X11_XGetWMNormalHints(display, data->
xwindow, sizehints, &flags);
1196 sizehints->flags &= ~(PMinSize | PMaxSize);
1199 sizehints->flags |= PMinSize | PMaxSize;
1200 sizehints->min_width = sizehints->max_width = window->
windowed.
w;
1201 sizehints->min_height = sizehints->max_height = window->
windowed.
h;
1203 X11_XSetWMNormalHints(display, data->
xwindow, sizehints);
1204 X11_XFree(sizehints);
1208 e.xany.type = ClientMessage;
1209 e.xclient.message_type = _NET_WM_STATE;
1210 e.xclient.format = 32;
1211 e.xclient.window = data->
xwindow;
1212 e.xclient.data.l[0] =
1213 fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1214 e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
1215 e.xclient.data.l[3] = 0l;
1217 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1218 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1222 if (!fullscreen && ((window->
flags & SDL_WINDOW_MAXIMIZED) == 0)) {
1224 e.xany.type = ClientMessage;
1225 e.xclient.message_type = _NET_WM_STATE;
1226 e.xclient.format = 32;
1227 e.xclient.window = data->
xwindow;
1228 e.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
1231 e.xclient.data.l[3] = 0l;
1232 X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1233 SubstructureNotifyMask | SubstructureRedirectMask, &e);
1238 flags = window->
flags;
1242 flags &= ~SDL_WINDOW_FULLSCREEN;
1247 if (data->
visual->class == DirectColor) {
1249 X11_XInstallColormap(display, data->
colormap);
1251 X11_XUninstallColormap(display, data->
colormap);
1255 X11_XFlush(display);
1264 Visual *visual = data->
visual;
1266 const int screen = displaydata->screen;
1267 Window root = RootWindow(display, screen);
1268 const int def_vis = (visual == DefaultVisual(display, screen));
1269 unsigned long xattrmask = 0;
1270 XSetWindowAttributes xattr;
1281 xattr.override_redirect = True;
1282 xattrmask |= CWOverrideRedirect;
1283 xattr.background_pixel = def_vis ? BlackPixel(display, screen) : 0;
1284 xattrmask |= CWBackPixel;
1285 xattr.border_pixel = 0;
1286 xattrmask |= CWBorderPixel;
1288 xattrmask |= CWColormap;
1290 data->
fswindow = X11_XCreateWindow(display, root,
1291 rect.
x, rect.
y, rect.
w, rect.
h, 0,
1292 displaydata->depth, InputOutput,
1293 visual, xattrmask, &xattr);
1295 X11_XSelectInput(display, data->
fswindow, StructureNotifyMask);
1296 X11_XSetWindowBackground(display, data->
fswindow, 0);
1297 X11_XInstallColormap(display, data->
colormap);
1298 X11_XClearWindow(display, data->
fswindow);
1299 X11_XMapRaised(display, data->
fswindow);
1302 X11_XUngrabPointer(display, CurrentTime);
1303 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1306 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
fswindow);
1307 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
fswindow);
1309 #if SDL_VIDEO_DRIVER_X11_XVIDMODE 1310 if ( displaydata->use_vidmode ) {
1311 X11_XF86VidModeLockModeSwitch(display, screen, True);
1319 (rect.
w - window->
w) / 2, (rect.
h - window->
h) / 2);
1322 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1325 rect.
x += (rect.
w / 2);
1326 rect.
y += (rect.
h / 2);
1327 X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.
x, rect.
y);
1330 X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1331 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1342 const int screen = displaydata->screen;
1343 Window root = RootWindow(display, screen);
1353 #if SDL_VIDEO_DRIVER_X11_VIDMODE 1354 if ( displaydata->use_vidmode ) {
1355 X11_XF86VidModeLockModeSwitch(display, screen, False);
1361 X11_XReparentWindow(display, data->
xwindow, root, window->
x, window->
y);
1364 X11_XSync(display, False);
1365 X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->
xwindow);
1366 X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->
xwindow);
1368 SetWindowBordered(display, screen, data->
xwindow,
1371 X11_XWithdrawWindow(display, fswindow, screen);
1374 X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
1375 X11_XDestroyWindow(display, fswindow);
1384 const char *env =
SDL_getenv(
"SDL_VIDEO_X11_LEGACY_FULLSCREEN");
1390 if ( displaydata->use_vidmode ) {
1392 }
else if ( !videodata->
net_wm ) {
1403 X11_BeginWindowFullscreenLegacy(
_this, window, _display);
1405 X11_EndWindowFullscreenLegacy(
_this, window, _display);
1408 X11_SetWindowFullscreenViaWM(
_this, window, _display, fullscreen);
1418 Visual *visual = data->
visual;
1419 Colormap colormap = data->
colormap;
1422 int rmask, gmask, bmask;
1423 int rshift, gshift, bshift;
1426 if (visual->class != DirectColor) {
1427 return SDL_SetError(
"Window doesn't have DirectColor visual");
1430 ncolors = visual->map_entries;
1431 colorcells =
SDL_malloc(ncolors *
sizeof(XColor));
1437 rmask = visual->red_mask;
1438 while (0 == (rmask & 1)) {
1444 gmask = visual->green_mask;
1445 while (0 == (gmask & 1)) {
1451 bmask = visual->blue_mask;
1452 while (0 == (bmask & 1)) {
1458 for (i = 0; i < ncolors; i++) {
1459 Uint32 rbits = (rmask *
i) / (ncolors - 1);
1460 Uint32 gbits = (gmask *
i) / (ncolors - 1);
1461 Uint32 bbits = (bmask *
i) / (ncolors - 1);
1462 Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
1464 colorcells[
i].pixel = pix;
1466 colorcells[
i].red = ramp[(0 * 256) + i];
1467 colorcells[
i].green = ramp[(1 * 256) + i];
1468 colorcells[
i].blue = ramp[(2 * 256) + i];
1470 colorcells[
i].flags = DoRed | DoGreen | DoBlue;
1473 X11_XStoreColors(display, colormap, colorcells, ncolors);
1474 X11_XFlush(display);
1492 oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(
_this, window);
1494 if (oldstyle_fullscreen || grabbed) {
1497 const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
1502 for (attempts = 0; attempts < 100; attempts++) {
1503 result = X11_XGrabPointer(display, data->
xwindow, True, mask, GrabModeAsync,
1504 GrabModeAsync, data->
xwindow, None, CurrentTime);
1505 if (result == GrabSuccess) {
1511 if (result != GrabSuccess) {
1518 X11_XRaiseWindow(display, data->
xwindow);
1527 grab_keyboard = oldstyle_fullscreen;
1529 if (grab_keyboard) {
1530 X11_XGrabKeyboard(display, data->
xwindow, True, GrabModeAsync,
1531 GrabModeAsync, CurrentTime);
1534 X11_XUngrabPointer(display, CurrentTime);
1535 X11_XUngrabKeyboard(display, CurrentTime);
1537 X11_XSync(display, False);
1547 Display *display = videodata->
display;
1553 for (i = 0; i < numwindows; ++
i) {
1554 if (windowlist[i] && (windowlist[i]->window == window)) {
1555 windowlist[
i] = windowlist[numwindows - 1];
1556 windowlist[numwindows - 1] =
NULL;
1562 #ifdef X_HAVE_UTF8_STRING 1564 X11_XDestroyIC(data->
ic);
1568 X11_XDestroyWindow(display, data->
xwindow);
1569 X11_XFlush(display);
1585 info->
info.
x11.display = display;
1589 SDL_SetError(
"Application not compiled with SDL %d.%d",
1606 Atom XdndAware = X11_XInternAtom(display,
"XdndAware", False);
1609 Atom xdnd_version = 5;
1610 X11_XChangeProperty(display, data->
xwindow, XdndAware, XA_ATOM, 32,
1611 PropModeReplace, (
unsigned char*)&xdnd_version, 1);
1613 X11_XDeleteProperty(display, data->
xwindow, XdndAware);
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.
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
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)
struct SDL_VideoDevice::@33 gl_config
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)
void X11_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
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
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if
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)
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)
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp if else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld, [WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld, [WK1]90:.else PF bic, WK0, base, #31 PF pld, [WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld, [WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X, [sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X, [sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld, [DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels DST endif subs bhs tst beq exit_label trailing_15bytes unaligned_mask endm macro narrow_case_inner_loop_and_trailing_pixels unaligned_mask tst conditional_process1 trailing_15bytes unaligned_mask endm macro switch_on_alignment action
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)