zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_x11window.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22 
23 #if SDL_VIDEO_DRIVER_X11
24 
25 #include "SDL_assert.h"
26 #include "SDL_hints.h"
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"
31 
32 #include "SDL_x11video.h"
33 #include "SDL_x11mouse.h"
34 #include "SDL_x11shape.h"
35 #include "SDL_x11xinput2.h"
36 
37 #if SDL_VIDEO_OPENGL_EGL
38 #include "SDL_x11opengles.h"
39 #endif
40 
41 #include "SDL_timer.h"
42 #include "SDL_syswm.h"
43 #include "SDL_assert.h"
44 
45 #define _NET_WM_STATE_REMOVE 0l
46 #define _NET_WM_STATE_ADD 1l
47 #define _NET_WM_STATE_TOGGLE 2l
48 
49 static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win)
50 {
51  return ev->type == MapNotify && ev->xmap.window == *((Window*)win);
52 }
53 static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win)
54 {
55  return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
56 }
57 static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
58 {
59  return ev->type == ConfigureNotify && ev->xconfigure.window == *((Window*)win);
60 }
61 
62 /*
63 static Bool
64 XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS)
65 {
66  Uint32 start = SDL_GetTicks();
67 
68  while (!XCheckIfEvent(display, event_return, predicate, arg)) {
69  if ((SDL_GetTicks() - start) >= timeoutMS) {
70  return False;
71  }
72  }
73  return True;
74 }
75 */
76 
77 static SDL_bool
78 X11_IsWindowLegacyFullscreen(_THIS, SDL_Window * window)
79 {
81  return (data->fswindow != 0);
82 }
83 
84 static SDL_bool
85 X11_IsWindowMapped(_THIS, SDL_Window * window)
86 {
87  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
88  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
89  XWindowAttributes attr;
90 
91  XGetWindowAttributes(videodata->display, data->xwindow, &attr);
92  if (attr.map_state != IsUnmapped) {
93  return SDL_TRUE;
94  } else {
95  return SDL_FALSE;
96  }
97 }
98 
99 #if 0
100 static SDL_bool
101 X11_IsActionAllowed(SDL_Window *window, Atom action)
102 {
103  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
104  Atom _NET_WM_ALLOWED_ACTIONS = data->videodata->_NET_WM_ALLOWED_ACTIONS;
105  Atom type;
106  Display *display = data->videodata->display;
107  int form;
108  unsigned long remain;
109  unsigned long len, i;
110  Atom *list;
112 
113  if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success)
114  {
115  for (i=0; i<len; ++i)
116  {
117  if (list[i] == action) {
118  ret = SDL_TRUE;
119  break;
120  }
121  }
122  XFree(list);
123  }
124  return ret;
125 }
126 #endif /* 0 */
127 
128 void
129 X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
130 {
131  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
132  Display *display = videodata->display;
133  Atom _NET_WM_STATE = videodata->_NET_WM_STATE;
134  /* Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN; */
135  Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
136  Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT;
137  Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
138  Atom _NET_WM_STATE_FULLSCREEN = videodata->_NET_WM_STATE_FULLSCREEN;
139  Atom atoms[5];
140  int count = 0;
141 
142  /* The window manager sets this property, we shouldn't set it.
143  If we did, this would indicate to the window manager that we don't
144  actually want to be mapped during XMapRaised(), which would be bad.
145  *
146  if (flags & SDL_WINDOW_HIDDEN) {
147  atoms[count++] = _NET_WM_STATE_HIDDEN;
148  }
149  */
150  if (flags & SDL_WINDOW_INPUT_FOCUS) {
151  atoms[count++] = _NET_WM_STATE_FOCUSED;
152  }
153  if (flags & SDL_WINDOW_MAXIMIZED) {
154  atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT;
155  atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
156  }
157  if (flags & SDL_WINDOW_FULLSCREEN) {
158  atoms[count++] = _NET_WM_STATE_FULLSCREEN;
159  }
160  if (count > 0) {
161  XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
162  PropModeReplace, (unsigned char *)atoms, count);
163  } else {
164  XDeleteProperty(display, xwindow, _NET_WM_STATE);
165  }
166 }
167 
168 Uint32
169 X11_GetNetWMState(_THIS, Window xwindow)
170 {
171  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
172  Display *display = videodata->display;
173  Atom _NET_WM_STATE = videodata->_NET_WM_STATE;
174  Atom _NET_WM_STATE_HIDDEN = videodata->_NET_WM_STATE_HIDDEN;
175  Atom _NET_WM_STATE_FOCUSED = videodata->_NET_WM_STATE_FOCUSED;
176  Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->_NET_WM_STATE_MAXIMIZED_VERT;
177  Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
178  Atom _NET_WM_STATE_FULLSCREEN = videodata->_NET_WM_STATE_FULLSCREEN;
179  Atom actualType;
180  int actualFormat;
181  unsigned long i, numItems, bytesAfter;
182  unsigned char *propertyValue = NULL;
183  long maxLength = 1024;
184  Uint32 flags = 0;
185 
186  if (XGetWindowProperty(display, xwindow, _NET_WM_STATE,
187  0l, maxLength, False, XA_ATOM, &actualType,
188  &actualFormat, &numItems, &bytesAfter,
189  &propertyValue) == Success) {
190  Atom *atoms = (Atom *) propertyValue;
191  int maximized = 0;
192  int fullscreen = 0;
193 
194  for (i = 0; i < numItems; ++i) {
195  if (atoms[i] == _NET_WM_STATE_HIDDEN) {
196  flags |= SDL_WINDOW_HIDDEN;
197  } else if (atoms[i] == _NET_WM_STATE_FOCUSED) {
198  flags |= SDL_WINDOW_INPUT_FOCUS;
199  } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
200  maximized |= 1;
201  } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
202  maximized |= 2;
203  } else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) {
204  fullscreen = 1;
205  }
206  }
207  if (maximized == 3) {
208  flags |= SDL_WINDOW_MAXIMIZED;
209  } else if (fullscreen == 1) {
210  flags |= SDL_WINDOW_FULLSCREEN;
211  }
212  XFree(propertyValue);
213  }
214 
215  /* FIXME, check the size hints for resizable */
216  /* flags |= SDL_WINDOW_RESIZABLE; */
217 
218  return flags;
219 }
220 
221 static int
222 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
223 {
224  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
225  SDL_WindowData *data;
226  int numwindows = videodata->numwindows;
227  int windowlistlength = videodata->windowlistlength;
228  SDL_WindowData **windowlist = videodata->windowlist;
229 
230  /* Allocate the window data */
231  data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
232  if (!data) {
233  return SDL_OutOfMemory();
234  }
235  data->window = window;
236  data->xwindow = w;
237 #ifdef X_HAVE_UTF8_STRING
238  if (SDL_X11_HAVE_UTF8 && videodata->im) {
239  data->ic =
240  pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
241  XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
242  XNResourceName, videodata->classname, XNResourceClass,
243  videodata->classname, NULL);
244  }
245 #endif
246  data->created = created;
247  data->videodata = videodata;
248 
249  /* Associate the data with the window */
250 
251  if (numwindows < windowlistlength) {
252  windowlist[numwindows] = data;
253  videodata->numwindows++;
254  } else {
255  windowlist =
256  (SDL_WindowData **) SDL_realloc(windowlist,
257  (numwindows +
258  1) * sizeof(*windowlist));
259  if (!windowlist) {
260  SDL_free(data);
261  return SDL_OutOfMemory();
262  }
263  windowlist[numwindows] = data;
264  videodata->numwindows++;
265  videodata->windowlistlength++;
266  videodata->windowlist = windowlist;
267  }
268 
269  /* Fill in the SDL window with the window data */
270  {
271  XWindowAttributes attrib;
272 
273  XGetWindowAttributes(data->videodata->display, w, &attrib);
274  window->x = attrib.x;
275  window->y = attrib.y;
276  window->w = attrib.width;
277  window->h = attrib.height;
278  if (attrib.map_state != IsUnmapped) {
279  window->flags |= SDL_WINDOW_SHOWN;
280  } else {
281  window->flags &= ~SDL_WINDOW_SHOWN;
282  }
283  data->visual = attrib.visual;
284  data->colormap = attrib.colormap;
285  }
286 
287  window->flags |= X11_GetNetWMState(_this, w);
288 
289  {
290  Window FocalWindow;
291  int RevertTo=0;
292  XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo);
293  if (FocalWindow==w)
294  {
295  window->flags |= SDL_WINDOW_INPUT_FOCUS;
296  }
297 
298  if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
300  }
301 
302  if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
303  /* Tell x11 to clip mouse */
304  }
305  }
306 
307  /* All done! */
308  window->driverdata = data;
309  return 0;
310 }
311 
312 static void
313 SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
314 {
315  /*
316  * this code used to check for KWM_WIN_DECORATION, but KDE hasn't
317  * supported it for years and years. It now respects _MOTIF_WM_HINTS.
318  * Gnome is similar: just use the Motif atom.
319  */
320 
321  Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
322  if (WM_HINTS != None) {
323  /* Hints used by Motif compliant window managers */
324  struct
325  {
326  unsigned long flags;
327  unsigned long functions;
328  unsigned long decorations;
329  long input_mode;
330  unsigned long status;
331  } MWMHints = {
332  (1L << 1), 0, border ? 1 : 0, 0, 0
333  };
334 
335  XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
336  PropModeReplace, (unsigned char *) &MWMHints,
337  sizeof(MWMHints) / 4);
338  } else { /* set the transient hints instead, if necessary */
339  XSetTransientForHint(display, window, RootWindow(display, screen));
340  }
341 }
342 
343 int
345 {
347  SDL_DisplayData *displaydata =
349  SDL_WindowData *windowdata;
350  Display *display = data->display;
351  int screen = displaydata->screen;
352  Visual *visual;
353  int depth;
354  XSetWindowAttributes xattr;
355  Window w;
356  XSizeHints *sizehints;
357  XWMHints *wmhints;
358  XClassHint *classhints;
359  const long _NET_WM_BYPASS_COMPOSITOR_HINT_ON = 1;
360  Atom _NET_WM_BYPASS_COMPOSITOR;
361  Atom _NET_WM_WINDOW_TYPE;
362  Atom _NET_WM_WINDOW_TYPE_NORMAL;
363  Atom _NET_WM_PID;
364  Atom XdndAware, xdnd_version = 5;
365  Uint32 fevent = 0;
366 
367 #if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL
368  if ((window->flags & SDL_WINDOW_OPENGL) &&
369  !SDL_getenv("SDL_VIDEO_X11_VISUALID")) {
370  XVisualInfo *vinfo = NULL;
371 
372 #if SDL_VIDEO_OPENGL_EGL
374  ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile )) {
375  vinfo = X11_GLES_GetVisual(_this, display, screen);
376  } else
377 #endif
378  {
379 #if SDL_VIDEO_OPENGL_GLX
380  vinfo = X11_GL_GetVisual(_this, display, screen);
381 #endif
382  }
383 
384  if (!vinfo) {
385  return -1;
386  }
387  visual = vinfo->visual;
388  depth = vinfo->depth;
389  XFree(vinfo);
390  } else
391 #endif
392  {
393  visual = displaydata->visual;
394  depth = displaydata->depth;
395  }
396 
397  xattr.override_redirect = False;
398  xattr.background_pixmap = None;
399  xattr.border_pixel = 0;
400 
401  if (visual->class == DirectColor) {
402  XColor *colorcells;
403  int i;
404  int ncolors;
405  int rmax, gmax, bmax;
406  int rmask, gmask, bmask;
407  int rshift, gshift, bshift;
408 
409  xattr.colormap =
410  XCreateColormap(display, RootWindow(display, screen),
411  visual, AllocAll);
412 
413  /* If we can't create a colormap, then we must die */
414  if (!xattr.colormap) {
415  return SDL_SetError("Could not create writable colormap");
416  }
417 
418  /* OK, we got a colormap, now fill it in as best as we can */
419  colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
420  if (!colorcells) {
421  return SDL_OutOfMemory();
422  }
423  ncolors = visual->map_entries;
424  rmax = 0xffff;
425  gmax = 0xffff;
426  bmax = 0xffff;
427 
428  rshift = 0;
429  rmask = visual->red_mask;
430  while (0 == (rmask & 1)) {
431  rshift++;
432  rmask >>= 1;
433  }
434 
435  gshift = 0;
436  gmask = visual->green_mask;
437  while (0 == (gmask & 1)) {
438  gshift++;
439  gmask >>= 1;
440  }
441 
442  bshift = 0;
443  bmask = visual->blue_mask;
444  while (0 == (bmask & 1)) {
445  bshift++;
446  bmask >>= 1;
447  }
448 
449  /* build the color table pixel values */
450  for (i = 0; i < ncolors; i++) {
451  Uint32 red = (rmax * i) / (ncolors - 1);
452  Uint32 green = (gmax * i) / (ncolors - 1);
453  Uint32 blue = (bmax * i) / (ncolors - 1);
454 
455  Uint32 rbits = (rmask * i) / (ncolors - 1);
456  Uint32 gbits = (gmask * i) / (ncolors - 1);
457  Uint32 bbits = (bmask * i) / (ncolors - 1);
458 
459  Uint32 pix =
460  (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
461 
462  colorcells[i].pixel = pix;
463 
464  colorcells[i].red = red;
465  colorcells[i].green = green;
466  colorcells[i].blue = blue;
467 
468  colorcells[i].flags = DoRed | DoGreen | DoBlue;
469  }
470 
471  XStoreColors(display, xattr.colormap, colorcells, ncolors);
472 
473  SDL_free(colorcells);
474  } else {
475  xattr.colormap =
476  XCreateColormap(display, RootWindow(display, screen),
477  visual, AllocNone);
478  }
479 
480  w = XCreateWindow(display, RootWindow(display, screen),
481  window->x, window->y, window->w, window->h,
482  0, depth, InputOutput, visual,
483  (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
484  CWColormap), &xattr);
485  if (!w) {
486  return SDL_SetError("Couldn't create window");
487  }
488 
489  SetWindowBordered(display, screen, w,
490  (window->flags & SDL_WINDOW_BORDERLESS) == 0);
491 
492  sizehints = XAllocSizeHints();
493  /* Setup the normal size hints */
494  sizehints->flags = 0;
495  if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
496  sizehints->min_width = sizehints->max_width = window->w;
497  sizehints->min_height = sizehints->max_height = window->h;
498  sizehints->flags |= (PMaxSize | PMinSize);
499  }
500  sizehints->x = window->x;
501  sizehints->y = window->y;
502  sizehints->flags |= USPosition;
503 
504  /* Setup the input hints so we get keyboard input */
505  wmhints = XAllocWMHints();
506  wmhints->input = True;
507  wmhints->flags = InputHint;
508 
509  /* Setup the class hints so we can get an icon (AfterStep) */
510  classhints = XAllocClassHint();
511  classhints->res_name = data->classname;
512  classhints->res_class = data->classname;
513 
514  /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
515  XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
516 
517  XFree(sizehints);
518  XFree(wmhints);
519  XFree(classhints);
520  /* Set the PID related to the window for the given hostname, if possible */
521  if (data->pid > 0) {
522  _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);
523  XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
524  (unsigned char *)&data->pid, 1);
525  }
526 
527  /* Set the window manager state */
528  X11_SetNetWMState(_this, w, window->flags);
529 
530  /* Let the window manager know we're a "normal" window */
531  _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
532  _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
533  XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
534  PropModeReplace,
535  (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
536 
537  _NET_WM_BYPASS_COMPOSITOR = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False);
538  XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
539  PropModeReplace,
540  (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
541 
542  {
543  Atom protocols[] = {
544  data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
545  data->_NET_WM_PING, /* Respond so WM knows we're alive */
546  };
547  XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
548  }
549 
550  if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
551  XDestroyWindow(display, w);
552  return -1;
553  }
554  windowdata = (SDL_WindowData *) window->driverdata;
555 
556 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
557  if ((window->flags & SDL_WINDOW_OPENGL) &&
559  (!_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile) ) {
560  if (!_this->egl_data) {
561  XDestroyWindow(display, w);
562  return -1;
563  }
564 
565  /* Create the GLES window surface */
566  windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w);
567 
568  if (windowdata->egl_surface == EGL_NO_SURFACE) {
569  XDestroyWindow(display, w);
570  return SDL_SetError("Could not create GLES window surface");
571  }
572  }
573 #endif
574 
575 
576 #ifdef X_HAVE_UTF8_STRING
577  if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
578  pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
579  }
580 #endif
581 
582  X11_Xinput2SelectTouch(_this, window);
583 
584  XSelectInput(display, w,
585  (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
586  ExposureMask | ButtonPressMask | ButtonReleaseMask |
587  PointerMotionMask | KeyPressMask | KeyReleaseMask |
588  PropertyChangeMask | StructureNotifyMask |
589  KeymapStateMask | fevent));
590 
591  XdndAware = XInternAtom(display, "XdndAware", False);
592  XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
593  PropModeReplace,
594  (unsigned char*)&xdnd_version, 1);
595 
596  XFlush(display);
597 
598  return 0;
599 }
600 
601 int
602 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
603 {
604  Window w = (Window) data;
605 
606  window->title = X11_GetWindowTitle(_this, w);
607 
608  if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
609  return -1;
610  }
611  return 0;
612 }
613 
614 char *
615 X11_GetWindowTitle(_THIS, Window xwindow)
616 {
618  Display *display = data->display;
619  int status, real_format;
620  Atom real_type;
621  unsigned long items_read, items_left;
622  unsigned char *propdata;
623  char *title = NULL;
624 
625  status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
626  0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
627  &items_read, &items_left, &propdata);
628  if (status == Success && propdata) {
629  title = SDL_strdup(SDL_static_cast(char*, propdata));
630  XFree(propdata);
631  } else {
632  status = XGetWindowProperty(display, xwindow, XA_WM_NAME,
633  0L, 8192L, False, XA_STRING, &real_type, &real_format,
634  &items_read, &items_left, &propdata);
635  if (status == Success && propdata) {
636  title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1);
637  } else {
638  title = SDL_strdup("");
639  }
640  }
641  return title;
642 }
643 
644 void
646 {
647  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
648  Display *display = data->videodata->display;
649  XTextProperty titleprop, iconprop;
650  Status status;
651  const char *title = window->title;
652  const char *icon = NULL;
653 
654 #ifdef X_HAVE_UTF8_STRING
655  Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
656  Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
657 #endif
658 
659  if (title != NULL) {
660  char *title_locale = SDL_iconv_utf8_locale(title);
661  if (!title_locale) {
662  SDL_OutOfMemory();
663  return;
664  }
665  status = XStringListToTextProperty(&title_locale, 1, &titleprop);
666  SDL_free(title_locale);
667  if (status) {
668  XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
669  XFree(titleprop.value);
670  }
671 #ifdef X_HAVE_UTF8_STRING
672  if (SDL_X11_HAVE_UTF8) {
673  status =
674  Xutf8TextListToTextProperty(display, (char **) &title, 1,
675  XUTF8StringStyle, &titleprop);
676  if (status == Success) {
677  XSetTextProperty(display, data->xwindow, &titleprop,
678  _NET_WM_NAME);
679  XFree(titleprop.value);
680  }
681  }
682 #endif
683  }
684  if (icon != NULL) {
685  char *icon_locale = SDL_iconv_utf8_locale(icon);
686  if (!icon_locale) {
687  SDL_OutOfMemory();
688  return;
689  }
690  status = XStringListToTextProperty(&icon_locale, 1, &iconprop);
691  SDL_free(icon_locale);
692  if (status) {
693  XSetTextProperty(display, data->xwindow, &iconprop,
694  XA_WM_ICON_NAME);
695  XFree(iconprop.value);
696  }
697 #ifdef X_HAVE_UTF8_STRING
698  if (SDL_X11_HAVE_UTF8) {
699  status =
700  Xutf8TextListToTextProperty(display, (char **) &icon, 1,
701  XUTF8StringStyle, &iconprop);
702  if (status == Success) {
703  XSetTextProperty(display, data->xwindow, &iconprop,
704  _NET_WM_ICON_NAME);
705  XFree(iconprop.value);
706  }
707  }
708 #endif
709  }
710  XFlush(display);
711 }
712 
713 void
715 {
716  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
717  Display *display = data->videodata->display;
718  Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON;
719 
720  if (icon) {
721  int propsize;
722  long *propdata;
723 
724  /* Set the _NET_WM_ICON property */
726  propsize = 2 + (icon->w * icon->h);
727  propdata = SDL_malloc(propsize * sizeof(long));
728  if (propdata) {
729  int x, y;
730  Uint32 *src;
731  long *dst;
732 
733  propdata[0] = icon->w;
734  propdata[1] = icon->h;
735  dst = &propdata[2];
736  for (y = 0; y < icon->h; ++y) {
737  src = (Uint32*)((Uint8*)icon->pixels + y * icon->pitch);
738  for (x = 0; x < icon->w; ++x) {
739  *dst++ = *src++;
740  }
741  }
742  XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
743  32, PropModeReplace, (unsigned char *) propdata,
744  propsize);
745  }
746  SDL_free(propdata);
747  } else {
748  XDeleteProperty(display, data->xwindow, _NET_WM_ICON);
749  }
750  XFlush(display);
751 }
752 
753 void
755 {
756  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
757  Display *display = data->videodata->display;
758 
759  XMoveWindow(display, data->xwindow, window->x, window->y);
760  XFlush(display);
761 }
762 
763 void
765 {
766  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
767  Display *display = data->videodata->display;
768 
769  if (window->flags & SDL_WINDOW_RESIZABLE) {
770  XSizeHints *sizehints = XAllocSizeHints();
771  long userhints;
772 
773  XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
774 
775  sizehints->min_width = window->min_w;
776  sizehints->min_height = window->min_h;
777  sizehints->flags |= PMinSize;
778 
779  XSetWMNormalHints(display, data->xwindow, sizehints);
780 
781  XFree(sizehints);
782 
783  /* See comment in X11_SetWindowSize. */
784  XResizeWindow(display, data->xwindow, window->w, window->h);
785  XMoveWindow(display, data->xwindow, window->x, window->y);
786  XRaiseWindow(display, data->xwindow);
787  }
788 
789  XFlush(display);
790 }
791 
792 void
794 {
795  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
796  Display *display = data->videodata->display;
797 
798  if (window->flags & SDL_WINDOW_RESIZABLE) {
799  XSizeHints *sizehints = XAllocSizeHints();
800  long userhints;
801 
802  XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
803 
804  sizehints->max_width = window->max_w;
805  sizehints->max_height = window->max_h;
806  sizehints->flags |= PMaxSize;
807 
808  XSetWMNormalHints(display, data->xwindow, sizehints);
809 
810  XFree(sizehints);
811 
812  /* See comment in X11_SetWindowSize. */
813  XResizeWindow(display, data->xwindow, window->w, window->h);
814  XMoveWindow(display, data->xwindow, window->x, window->y);
815  XRaiseWindow(display, data->xwindow);
816  }
817 
818  XFlush(display);
819 }
820 
821 void
823 {
824  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
825  Display *display = data->videodata->display;
826 
827  if (SDL_IsShapedWindow(window)) {
828  X11_ResizeWindowShape(window);
829  }
830  if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
831  /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus
832  we must set the size hints to adjust the window size. */
833  XSizeHints *sizehints = XAllocSizeHints();
834  long userhints;
835 
836  XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
837 
838  sizehints->min_width = sizehints->max_width = window->w;
839  sizehints->min_height = sizehints->max_height = window->h;
840  sizehints->flags |= PMinSize | PMaxSize;
841 
842  XSetWMNormalHints(display, data->xwindow, sizehints);
843 
844  XFree(sizehints);
845 
846  /* From Pierre-Loup:
847  WMs each have their little quirks with that. When you change the
848  size hints, they get a ConfigureNotify event with the
849  WM_NORMAL_SIZE_HINTS Atom. They all save the hints then, but they
850  don't all resize the window right away to enforce the new hints.
851 
852  Some of them resize only after:
853  - A user-initiated move or resize
854  - A code-initiated move or resize
855  - Hiding & showing window (Unmap & map)
856 
857  The following move & resize seems to help a lot of WMs that didn't
858  properly update after the hints were changed. We don't do a
859  hide/show, because there are supposedly subtle problems with doing so
860  and transitioning from windowed to fullscreen in Unity.
861  */
862  XResizeWindow(display, data->xwindow, window->w, window->h);
863  XMoveWindow(display, data->xwindow, window->x, window->y);
864  XRaiseWindow(display, data->xwindow);
865  } else {
866  XResizeWindow(display, data->xwindow, window->w, window->h);
867  }
868 
869  XFlush(display);
870 }
871 
872 void
873 X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
874 {
875  const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0);
876  const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0);
877  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
878  SDL_DisplayData *displaydata =
880  Display *display = data->videodata->display;
881  XEvent event;
882 
883  SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
884  XFlush(display);
885  XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
886 
887  if (visible) {
888  XWindowAttributes attr;
889  do {
890  XSync(display, False);
891  XGetWindowAttributes(display, data->xwindow, &attr);
892  } while (attr.map_state != IsViewable);
893 
894  if (focused) {
895  XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
896  }
897  }
898 
899  /* make sure these don't make it to the real event queue if they fired here. */
900  XSync(display, False);
901  XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
902  XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
903 }
904 
905 void
907 {
908  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
909  Display *display = data->videodata->display;
910  XEvent event;
911 
912  if (!X11_IsWindowMapped(_this, window)) {
913  XMapRaised(display, data->xwindow);
914  /* Blocking wait for "MapNotify" event.
915  * We use XIfEvent because XWindowEvent takes a mask rather than a type,
916  * and XCheckTypedWindowEvent doesn't block */
917  XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
918  XFlush(display);
919  }
920 }
921 
922 void
924 {
925  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
927  Display *display = data->videodata->display;
928  XEvent event;
929 
930  if (X11_IsWindowMapped(_this, window)) {
931  XWithdrawWindow(display, data->xwindow, displaydata->screen);
932  /* Blocking wait for "UnmapNotify" event */
933  XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
934  XFlush(display);
935  }
936 }
937 
938 static void
939 SetWindowActive(_THIS, SDL_Window * window)
940 {
941  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
942  SDL_DisplayData *displaydata =
944  Display *display = data->videodata->display;
945  Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW;
946 
947  if (X11_IsWindowMapped(_this, window)) {
948  XEvent e;
949 
950  SDL_zero(e);
951  e.xany.type = ClientMessage;
952  e.xclient.message_type = _NET_ACTIVE_WINDOW;
953  e.xclient.format = 32;
954  e.xclient.window = data->xwindow;
955  e.xclient.data.l[0] = 1; /* source indication. 1 = application */
956  e.xclient.data.l[1] = CurrentTime;
957  e.xclient.data.l[2] = 0;
958 
959  XSendEvent(display, RootWindow(display, displaydata->screen), 0,
960  SubstructureNotifyMask | SubstructureRedirectMask, &e);
961 
962  XFlush(display);
963  }
964 }
965 
966 void
968 {
969  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
970  Display *display = data->videodata->display;
971 
972  XRaiseWindow(display, data->xwindow);
973  SetWindowActive(_this, window);
974  XFlush(display);
975 }
976 
977 static void
978 SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
979 {
980  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
981  SDL_DisplayData *displaydata =
983  Display *display = data->videodata->display;
984  Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
985  Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
986  Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
987 
988  if (maximized) {
989  window->flags |= SDL_WINDOW_MAXIMIZED;
990  } else {
991  window->flags &= ~SDL_WINDOW_MAXIMIZED;
992  }
993 
994  if (X11_IsWindowMapped(_this, window)) {
995  XEvent e;
996 
997  SDL_zero(e);
998  e.xany.type = ClientMessage;
999  e.xclient.message_type = _NET_WM_STATE;
1000  e.xclient.format = 32;
1001  e.xclient.window = data->xwindow;
1002  e.xclient.data.l[0] =
1003  maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1004  e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
1005  e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
1006  e.xclient.data.l[3] = 0l;
1007 
1008  XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1009  SubstructureNotifyMask | SubstructureRedirectMask, &e);
1010  } else {
1011  X11_SetNetWMState(_this, data->xwindow, window->flags);
1012  }
1013  XFlush(display);
1014 }
1015 
1016 void
1018 {
1019  SetWindowMaximized(_this, window, SDL_TRUE);
1020 }
1021 
1022 void
1024 {
1025  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1026  SDL_DisplayData *displaydata =
1028  Display *display = data->videodata->display;
1029 
1030  XIconifyWindow(display, data->xwindow, displaydata->screen);
1031  XFlush(display);
1032 }
1033 
1034 void
1036 {
1037  SetWindowMaximized(_this, window, SDL_FALSE);
1038  X11_ShowWindow(_this, window);
1039  SetWindowActive(_this, window);
1040 }
1041 
1042 /* This asks the Window Manager to handle fullscreen for us. Most don't do it right, though. */
1043 static void
1044 X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen)
1045 {
1046  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1047  SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
1048  Display *display = data->videodata->display;
1049  Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
1050  Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
1051 
1052  if (X11_IsWindowMapped(_this, window)) {
1053  XEvent e;
1054 
1055  if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
1056  /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we
1057  can be resized to the fullscreen resolution (or reset so we're not resizable again) */
1058  XSizeHints *sizehints = XAllocSizeHints();
1059  long flags = 0;
1060  XGetWMNormalHints(display, data->xwindow, sizehints, &flags);
1061  /* set the resize flags on */
1062  if (fullscreen) {
1063  /* we are going fullscreen so turn the flags off */
1064  sizehints->flags &= ~(PMinSize | PMaxSize);
1065  } else {
1066  /* Reset the min/max width height to make the window non-resizable again */
1067  sizehints->flags |= PMinSize | PMaxSize;
1068  sizehints->min_width = sizehints->max_width = window->windowed.w;
1069  sizehints->min_height = sizehints->max_height = window->windowed.h;
1070  }
1071  XSetWMNormalHints(display, data->xwindow, sizehints);
1072  XFree(sizehints);
1073  }
1074 
1075  SDL_zero(e);
1076  e.xany.type = ClientMessage;
1077  e.xclient.message_type = _NET_WM_STATE;
1078  e.xclient.format = 32;
1079  e.xclient.window = data->xwindow;
1080  e.xclient.data.l[0] =
1081  fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
1082  e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
1083  e.xclient.data.l[3] = 0l;
1084 
1085  XSendEvent(display, RootWindow(display, displaydata->screen), 0,
1086  SubstructureNotifyMask | SubstructureRedirectMask, &e);
1087  } else {
1088  Uint32 flags;
1089 
1090  flags = window->flags;
1091  if (fullscreen) {
1092  flags |= SDL_WINDOW_FULLSCREEN;
1093  } else {
1094  flags &= ~SDL_WINDOW_FULLSCREEN;
1095  }
1096  X11_SetNetWMState(_this, data->xwindow, flags);
1097  }
1098 
1099  if (data->visual->class == DirectColor) {
1100  if ( fullscreen ) {
1101  XInstallColormap(display, data->colormap);
1102  } else {
1103  XUninstallColormap(display, data->colormap);
1104  }
1105  }
1106 
1107  XFlush(display);
1108 }
1109 
1110 /* This handles fullscreen itself, outside the Window Manager. */
1111 static void
1112 X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _display)
1113 {
1114  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1115  SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
1116  Visual *visual = data->visual;
1117  Display *display = data->videodata->display;
1118  const int screen = displaydata->screen;
1119  Window root = RootWindow(display, screen);
1120  const int def_vis = (visual == DefaultVisual(display, screen));
1121  unsigned long xattrmask = 0;
1122  XSetWindowAttributes xattr;
1123  XEvent ev;
1124  SDL_Rect rect;
1125 
1126  if ( data->fswindow ) {
1127  return; /* already fullscreen, I hope. */
1128  }
1129 
1130  X11_GetDisplayBounds(_this, _display, &rect);
1131 
1132  SDL_zero(xattr);
1133  xattr.override_redirect = True;
1134  xattrmask |= CWOverrideRedirect;
1135  xattr.background_pixel = def_vis ? BlackPixel(display, screen) : 0;
1136  xattrmask |= CWBackPixel;
1137  xattr.border_pixel = 0;
1138  xattrmask |= CWBorderPixel;
1139  xattr.colormap = data->colormap;
1140  xattrmask |= CWColormap;
1141 
1142  data->fswindow = XCreateWindow(display, root,
1143  rect.x, rect.y, rect.w, rect.h, 0,
1144  displaydata->depth, InputOutput,
1145  visual, xattrmask, &xattr);
1146 
1147  XSelectInput(display, data->fswindow, StructureNotifyMask);
1148  XSetWindowBackground(display, data->fswindow, 0);
1149  XInstallColormap(display, data->colormap);
1150  XClearWindow(display, data->fswindow);
1151  XMapRaised(display, data->fswindow);
1152 
1153  /* Make sure the fswindow is in view by warping mouse to the corner */
1154  XUngrabPointer(display, CurrentTime);
1155  XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
1156 
1157  /* Wait to be mapped, filter Unmap event out if it arrives. */
1158  XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
1159  XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
1160 
1161 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
1162  if ( displaydata->use_vidmode ) {
1163  XF86VidModeLockModeSwitch(display, screen, True);
1164  }
1165 #endif
1166 
1167  SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
1168 
1169  /* Center actual window within our cover-the-screen window. */
1170  XReparentWindow(display, data->xwindow, data->fswindow,
1171  (rect.w - window->w) / 2, (rect.h - window->h) / 2);
1172 
1173  /* Move the mouse to the upper left to make sure it's on-screen */
1174  XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
1175 
1176  /* Center mouse in the fullscreen window. */
1177  rect.x += (rect.w / 2);
1178  rect.y += (rect.h / 2);
1179  XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
1180 
1181  /* Wait to be mapped, filter Unmap event out if it arrives. */
1182  XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
1183  XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
1184 
1185  SDL_UpdateWindowGrab(window);
1186 }
1187 
1188 static void
1189 X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _display)
1190 {
1191  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1192  SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
1193  Display *display = data->videodata->display;
1194  const int screen = displaydata->screen;
1195  Window root = RootWindow(display, screen);
1196  Window fswindow = data->fswindow;
1197  XEvent ev;
1198 
1199  if (!data->fswindow) {
1200  return; /* already not fullscreen, I hope. */
1201  }
1202 
1203  data->fswindow = None;
1204 
1205 #if SDL_VIDEO_DRIVER_X11_VIDMODE
1206  if ( displaydata->use_vidmode ) {
1207  XF86VidModeLockModeSwitch(display, screen, False);
1208  }
1209 #endif
1210 
1211  SDL_UpdateWindowGrab(window);
1212 
1213  XReparentWindow(display, data->xwindow, root, window->x, window->y);
1214 
1215  /* flush these events so they don't confuse normal event handling */
1216  XSync(display, False);
1217  XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
1218  XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
1219 
1220  SetWindowBordered(display, screen, data->xwindow,
1221  (window->flags & SDL_WINDOW_BORDERLESS) == 0);
1222 
1223  XWithdrawWindow(display, fswindow, screen);
1224 
1225  /* Wait to be unmapped. */
1226  XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
1227  XDestroyWindow(display, fswindow);
1228 }
1229 
1230 
1231 void
1232 X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen)
1233 {
1234  /* !!! FIXME: SDL_Hint? */
1235  SDL_bool legacy = SDL_FALSE;
1236  const char *env = SDL_getenv("SDL_VIDEO_X11_LEGACY_FULLSCREEN");
1237  if (env) {
1238  legacy = SDL_atoi(env);
1239  } else {
1240  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
1241  SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
1242  if ( displaydata->use_vidmode ) {
1243  legacy = SDL_TRUE; /* the new stuff only works with XRandR. */
1244  } else if ( !videodata->net_wm ) {
1245  legacy = SDL_TRUE; /* The window manager doesn't support it */
1246  } else {
1247  /* !!! FIXME: look at the window manager name, and blacklist certain ones? */
1248  /* http://stackoverflow.com/questions/758648/find-the-name-of-the-x-window-manager */
1249  legacy = SDL_FALSE; /* try the new way. */
1250  }
1251  }
1252 
1253  if (legacy) {
1254  if (fullscreen) {
1255  X11_BeginWindowFullscreenLegacy(_this, window, _display);
1256  } else {
1257  X11_EndWindowFullscreenLegacy(_this, window, _display);
1258  }
1259  } else {
1260  X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen);
1261  }
1262 }
1263 
1264 
1265 int
1266 X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
1267 {
1268  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1269  Display *display = data->videodata->display;
1270  Visual *visual = data->visual;
1271  Colormap colormap = data->colormap;
1272  XColor *colorcells;
1273  int ncolors;
1274  int rmask, gmask, bmask;
1275  int rshift, gshift, bshift;
1276  int i;
1277 
1278  if (visual->class != DirectColor) {
1279  return SDL_SetError("Window doesn't have DirectColor visual");
1280  }
1281 
1282  ncolors = visual->map_entries;
1283  colorcells = SDL_malloc(ncolors * sizeof(XColor));
1284  if (!colorcells) {
1285  return SDL_OutOfMemory();
1286  }
1287 
1288  rshift = 0;
1289  rmask = visual->red_mask;
1290  while (0 == (rmask & 1)) {
1291  rshift++;
1292  rmask >>= 1;
1293  }
1294 
1295  gshift = 0;
1296  gmask = visual->green_mask;
1297  while (0 == (gmask & 1)) {
1298  gshift++;
1299  gmask >>= 1;
1300  }
1301 
1302  bshift = 0;
1303  bmask = visual->blue_mask;
1304  while (0 == (bmask & 1)) {
1305  bshift++;
1306  bmask >>= 1;
1307  }
1308 
1309  /* build the color table pixel values */
1310  for (i = 0; i < ncolors; i++) {
1311  Uint32 rbits = (rmask * i) / (ncolors - 1);
1312  Uint32 gbits = (gmask * i) / (ncolors - 1);
1313  Uint32 bbits = (bmask * i) / (ncolors - 1);
1314  Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
1315 
1316  colorcells[i].pixel = pix;
1317 
1318  colorcells[i].red = ramp[(0 * 256) + i];
1319  colorcells[i].green = ramp[(1 * 256) + i];
1320  colorcells[i].blue = ramp[(2 * 256) + i];
1321 
1322  colorcells[i].flags = DoRed | DoGreen | DoBlue;
1323  }
1324 
1325  XStoreColors(display, colormap, colorcells, ncolors);
1326  XFlush(display);
1327  SDL_free(colorcells);
1328 
1329  return 0;
1330 }
1331 
1332 void
1333 X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
1334 {
1335  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1336  Display *display = data->videodata->display;
1337  SDL_bool oldstyle_fullscreen;
1338  SDL_bool grab_keyboard;
1339  const char *hint;
1340 
1341  /* ICCCM2.0-compliant window managers can handle fullscreen windows
1342  If we're using XVidMode to change resolution we need to confine
1343  the cursor so we don't pan around the virtual desktop.
1344  */
1345  oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(_this, window);
1346 
1347  if (oldstyle_fullscreen || grabbed) {
1348  /* Try to grab the mouse */
1349  for (;;) {
1350  int result =
1351  XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync,
1352  GrabModeAsync, data->xwindow, None, CurrentTime);
1353  if (result == GrabSuccess) {
1354  break;
1355  }
1356  SDL_Delay(50);
1357  }
1358 
1359  /* Raise the window if we grab the mouse */
1360  XRaiseWindow(display, data->xwindow);
1361 
1362  /* Now grab the keyboard */
1364  if (hint && SDL_atoi(hint)) {
1365  grab_keyboard = SDL_TRUE;
1366  } else {
1367  /* We need to do this with the old style override_redirect
1368  fullscreen window otherwise we won't get keyboard focus.
1369  */
1370  grab_keyboard = oldstyle_fullscreen;
1371  }
1372  if (grab_keyboard) {
1373  XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
1374  GrabModeAsync, CurrentTime);
1375  }
1376  } else {
1377  XUngrabPointer(display, CurrentTime);
1378  XUngrabKeyboard(display, CurrentTime);
1379  }
1380  XSync(display, False);
1381 }
1382 
1383 void
1385 {
1386  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1387  window->driverdata = NULL;
1388 
1389  if (data) {
1390  SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;
1391  Display *display = videodata->display;
1392  int numwindows = videodata->numwindows;
1393  SDL_WindowData **windowlist = videodata->windowlist;
1394  int i;
1395 
1396  if (windowlist) {
1397  for (i = 0; i < numwindows; ++i) {
1398  if (windowlist[i] && (windowlist[i]->window == window)) {
1399  windowlist[i] = windowlist[numwindows - 1];
1400  windowlist[numwindows - 1] = NULL;
1401  videodata->numwindows--;
1402  break;
1403  }
1404  }
1405  }
1406 #ifdef X_HAVE_UTF8_STRING
1407  if (data->ic) {
1408  XDestroyIC(data->ic);
1409  }
1410 #endif
1411  if (data->created) {
1412  XDestroyWindow(display, data->xwindow);
1413  XFlush(display);
1414  }
1415  SDL_free(data);
1416  }
1417 }
1418 
1419 SDL_bool
1421 {
1422  SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1423  Display *display = data->videodata->display;
1424 
1425  if (info->version.major == SDL_MAJOR_VERSION &&
1426  info->version.minor == SDL_MINOR_VERSION) {
1427  info->subsystem = SDL_SYSWM_X11;
1428  info->info.x11.display = display;
1429  info->info.x11.window = data->xwindow;
1430  return SDL_TRUE;
1431  } else {
1432  SDL_SetError("Application not compiled with SDL %d.%d\n",
1434  return SDL_FALSE;
1435  }
1436 }
1437 
1438 #endif /* SDL_VIDEO_DRIVER_X11 */
1439 
1440 /* vi: set ts=4 sw=4 expandtab: */
void SDL_UpdateWindowGrab(SDL_Window *window)
Definition: SDL_video.c:2006
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return cha XGetInputFocus)
Definition: SDL_x11sym.h:64
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window retur XIfEvent)
Definition: SDL_x11sym.h:74
#define SDL_MINOR_VERSION
Definition: SDL_version.h:61
Display * display
Definition: SDL_x11video.h:75
return
Definition: pngrutil.c:1266
Atom _NET_WM_STATE_FULLSCREEN
Definition: SDL_x11video.h:95
int X11_ResizeWindowShape(SDL_Window *window)
Atom _NET_WM_ALLOWED_ACTIONS
Definition: SDL_x11video.h:96
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap retur XWarpPointer)
Definition: SDL_x11sym.h:128
void X11_SetWindowTitle(_THIS, SDL_Window *window)
Visual * visual
Definition: SDL_x11window.h:49
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:611
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
Uint32 X11_GetNetWMState(_THIS, Window xwindow)
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
#define SDL_VIDEO_OPENGL_ES
#define NULL
Definition: ftobjs.h:61
#define EGL_NO_SURFACE
Definition: egl.h:71
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int retur XResizeWindow)
Definition: SDL_x11sym.h:102
Atom _NET_WM_STATE_MAXIMIZED_VERT
Definition: SDL_x11video.h:93
Colormap colormap
Definition: SDL_x11window.h:50
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int retur XFlush)
Definition: SDL_x11sym.h:54
#define SDL_MAJOR_VERSION
Definition: SDL_version.h:60
SDL_bool
Definition: SDL_stdinc.h:116
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer retur XGrabPointer)
Definition: SDL_x11sym.h:76
int windowlistlength
Definition: SDL_x11video.h:82
EGLSurface EGLint x
Definition: eglext.h:293
return Display return Display Bool Bool int int e
Definition: SDL_x11sym.h:30
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time retur XIconifyWindow)
Definition: SDL_x11sym.h:78
DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size)
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
DECLSPEC void SDLCALL SDL_free(void *mem)
SDL_version version
Definition: SDL_syswm.h:161
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHint XStoreColors)
Definition: SDL_x11sym.h:116
Uint8 major
Definition: SDL_version.h:53
SDL_WindowData ** windowlist
Definition: SDL_x11video.h:81
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window retur XSetWindowBackground)
Definition: SDL_x11sym.h:112
SDL_SYSWM_TYPE subsystem
Definition: SDL_syswm.h:162
void X11_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
GLclampf green
Definition: glew.h:1506
void X11_MinimizeWindow(_THIS, SDL_Window *window)
SDL_Window * window
GLenum GLsizei len
Definition: glew.h:7035
void X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
char * display
Definition: visualinfo.c:85
if(!yyg->yy_init)
#define SDL_X11_HAVE_UTF8
SDL_Rect windowed
Definition: SDL_sysvideo.h:84
ret
Definition: glew_str_glx.c:2
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int retur XSendEvent)
Definition: SDL_x11sym.h:104
void X11_MaximizeWindow(_THIS, SDL_Window *window)
struct SDL_GLDriverData * gl_data
Definition: SDL_sysvideo.h:315
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time retur XSetTransientForHint)
Definition: SDL_x11sym.h:110
#define SDL_HINT_GRAB_KEYBOARD
A variable controlling whether grabbing input grabs the keyboard.
Definition: SDL_hints.h:173
const GLubyte GLuint red
Definition: SDL_glfuncs.h:57
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
Atom _NET_WM_STATE
Definition: SDL_x11video.h:90
static SDL_VideoDevice * _this
Definition: SDL_video.c:92
EGLNativeWindowType NativeWindowType
Definition: eglplatform.h:117
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
char * classname
Definition: SDL_x11video.h:76
Atom _NET_WM_STATE_HIDDEN
Definition: SDL_x11video.h:91
return Display return Display Bool Bool int int int return XCheckIfEvent
Definition: SDL_x11sym.h:32
DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window)
Return whether the given window is a shaped window.
Definition: SDL_shape.c:57
Atom _NET_ACTIVE_WINDOW
Definition: SDL_x11video.h:102
Atom WM_DELETE_WINDOW
Definition: SDL_x11video.h:89
GLuint64EXT * result
Definition: glew.h:12708
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long retur XSetInputFocus)
Definition: SDL_x11sym.h:108
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym retur XInternAtom)
Definition: SDL_x11sym.h:82
GLenum GLenum dst
Definition: glew.h:2396
int X11_CreateWindow(_THIS, SDL_Window *window)
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time retur XUninstallColormap)
Definition: SDL_x11sym.h:126
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
void * pixels
Definition: SDL_surface.h:75
Atom _NET_WM_ICON_NAME
Definition: SDL_x11video.h:99
int X11_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
#define _THIS
struct SDL_VideoData * videodata
DECLSPEC char *SDLCALL SDL_strdup(const char *str)
Definition: SDL_string.c:511
GLuint GLsizei maxLength
Definition: glew.h:1811
GLint GLsizei count
Definition: gl2ext.h:1011
int X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
DECLSPEC void SDLCALL SDL_Delay(Uint32 ms)
Wait a specified number of milliseconds before returning.
Definition: SDL_systimer.c:70
void X11_RestoreWindow(_THIS, SDL_Window *window)
Uint8 minor
Definition: SDL_version.h:54
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: gl2ext.h:845
GLint GLenum GLsizei GLsizei GLsizei GLint border
Definition: gl2ext.h:845
char * title
Definition: SDL_sysvideo.h:75
int x
Definition: SDL_rect.h:65
void X11_ShowWindow(_THIS, SDL_Window *window)
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom retur XGetWindowAttributes)
Definition: SDL_x11sym.h:70
DECLSPEC const char *SDLCALL SDL_GetHint(const char *name)
Get a hint.
Definition: SDL_hints.c:104
void X11_DestroyWindow(_THIS, SDL_Window *window)
int w
Definition: SDL_rect.h:66
union SDL_SysWMinfo::@78 info
jmp_buf env
Definition: jumphack.c:12
#define SDL_assert(condition)
Definition: SDL_assert.h:159
void X11_SetWindowMinimumSize(_THIS, SDL_Window *window)
EGLSurface EGLint EGLint y
Definition: eglext.h:293
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
GLdouble l
Definition: glew.h:8383
SDL_PixelFormat * format
Definition: SDL_surface.h:72
Atom _NET_WM_STATE_MAXIMIZED_HORZ
Definition: SDL_x11video.h:94
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2767
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
Definition: SDL_video.c:996
int h
Definition: SDL_rect.h:66
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
DECLSPEC int SDLCALL SDL_atoi(const char *str)
Definition: SDL_string.c:774
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:99
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int retur XStringListToTextProperty)
Definition: SDL_x11sym.h:118
Atom _NET_WM_STATE_FOCUSED
Definition: SDL_x11video.h:92
void X11_RaiseWindow(_THIS, SDL_Window *window)
DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
Definition: SDL_iconv.c:855
SDL_bool net_wm
Definition: SDL_x11video.h:85
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int retur XWithdrawWindow)
Definition: SDL_x11sym.h:130
void X11_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
char * X11_GetWindowTitle(_THIS, Window xwindow)
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window retur XUngrabPointer)
Definition: SDL_x11sym.h:124
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long retur XSetWMNormalHints)
Definition: SDL_x11sym.h:114
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 int int return Display Window Cursor retur XDestroyWindow)
Definition: SDL_x11sym.h:46
XAllocWMHints
Definition: SDL_x11sym.h:26
GLint GLint GLint GLint GLint w
Definition: gl2ext.h:1215
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:137
DECLSPEC char *SDLCALL SDL_getenv(const char *name)
Definition: SDL_getenv.c:179
#define SDL_zero(x)
Definition: SDL_stdinc.h:254
void * driverdata
Definition: SDL_sysvideo.h:99
GLenum src
Definition: glew.h:2396
void X11_SetWindowSize(_THIS, SDL_Window *window)
int i
Definition: pngrutil.c:1377
int visual
Definition: visualinfo.c:86
char Bool
Definition: ftraster.c:307
Uint32 flags
Definition: SDL_sysvideo.h:81
GLclampf GLclampf blue
Definition: glew.h:1506
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int retur XReparentWindow)
Definition: SDL_x11sym.h:100
void X11_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void X11_HideWindow(_THIS, SDL_Window *window)
struct SDL_VideoDevice::@87 gl_config
void X11_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int y
Definition: SDL_rect.h:65
#define SDL_iconv_utf8_locale(S)
Definition: SDL_stdinc.h:380
EGLSurface egl_surface
A rectangle, with the origin at the upper left.
Definition: SDL_rect.h:63
SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void X11_SetWindowMaximumSize(_THIS, SDL_Window *window)
Display * dpy
cl_event event
Definition: glew.h:3556
void X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
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 int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo retur XMoveWindow)
Definition: SDL_x11sym.h:90
typedef BOOL(WINAPI *PFNWGLSETSTEREOEMITTERSTATE3DLPROC)(HDC hDC
void X11_SetWindowPosition(_THIS, SDL_Window *window)