Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
x11_init.c
Go to the documentation of this file.
1//========================================================================
2// GLFW 3.4 X11 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27// It is fine to use C99 in this file because it will not be built with VS
28//========================================================================
29
30#include "internal.h"
31
32#include <stdlib.h>
33#include <string.h>
34#include <limits.h>
35#include <stdio.h>
36#include <locale.h>
37#include <unistd.h>
38
39
40// Translate the X11 KeySyms for a key to a GLFW key code
41// NOTE: This is only used as a fallback, in case the XKB method fails
42// It is layout-dependent and will fail partially on most non-US layouts
43//
44static int translateKeySyms(const KeySym* keysyms, int width)
45{
46 if (width > 1)
47 {
48 switch (keysyms[1])
49 {
50 case XK_KP_0: return GLFW_KEY_KP_0;
51 case XK_KP_1: return GLFW_KEY_KP_1;
52 case XK_KP_2: return GLFW_KEY_KP_2;
53 case XK_KP_3: return GLFW_KEY_KP_3;
54 case XK_KP_4: return GLFW_KEY_KP_4;
55 case XK_KP_5: return GLFW_KEY_KP_5;
56 case XK_KP_6: return GLFW_KEY_KP_6;
57 case XK_KP_7: return GLFW_KEY_KP_7;
58 case XK_KP_8: return GLFW_KEY_KP_8;
59 case XK_KP_9: return GLFW_KEY_KP_9;
60 case XK_KP_Separator:
61 case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL;
62 case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
63 case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
64 default: break;
65 }
66 }
67
68 switch (keysyms[0])
69 {
70 case XK_Escape: return GLFW_KEY_ESCAPE;
71 case XK_Tab: return GLFW_KEY_TAB;
72 case XK_Shift_L: return GLFW_KEY_LEFT_SHIFT;
73 case XK_Shift_R: return GLFW_KEY_RIGHT_SHIFT;
74 case XK_Control_L: return GLFW_KEY_LEFT_CONTROL;
75 case XK_Control_R: return GLFW_KEY_RIGHT_CONTROL;
76 case XK_Meta_L:
77 case XK_Alt_L: return GLFW_KEY_LEFT_ALT;
78 case XK_Mode_switch: // Mapped to Alt_R on many keyboards
79 case XK_ISO_Level3_Shift: // AltGr on at least some machines
80 case XK_Meta_R:
81 case XK_Alt_R: return GLFW_KEY_RIGHT_ALT;
82 case XK_Super_L: return GLFW_KEY_LEFT_SUPER;
83 case XK_Super_R: return GLFW_KEY_RIGHT_SUPER;
84 case XK_Menu: return GLFW_KEY_MENU;
85 case XK_Num_Lock: return GLFW_KEY_NUM_LOCK;
86 case XK_Caps_Lock: return GLFW_KEY_CAPS_LOCK;
87 case XK_Print: return GLFW_KEY_PRINT_SCREEN;
88 case XK_Scroll_Lock: return GLFW_KEY_SCROLL_LOCK;
89 case XK_Pause: return GLFW_KEY_PAUSE;
90 case XK_Delete: return GLFW_KEY_DELETE;
91 case XK_BackSpace: return GLFW_KEY_BACKSPACE;
92 case XK_Return: return GLFW_KEY_ENTER;
93 case XK_Home: return GLFW_KEY_HOME;
94 case XK_End: return GLFW_KEY_END;
95 case XK_Page_Up: return GLFW_KEY_PAGE_UP;
96 case XK_Page_Down: return GLFW_KEY_PAGE_DOWN;
97 case XK_Insert: return GLFW_KEY_INSERT;
98 case XK_Left: return GLFW_KEY_LEFT;
99 case XK_Right: return GLFW_KEY_RIGHT;
100 case XK_Down: return GLFW_KEY_DOWN;
101 case XK_Up: return GLFW_KEY_UP;
102 case XK_F1: return GLFW_KEY_F1;
103 case XK_F2: return GLFW_KEY_F2;
104 case XK_F3: return GLFW_KEY_F3;
105 case XK_F4: return GLFW_KEY_F4;
106 case XK_F5: return GLFW_KEY_F5;
107 case XK_F6: return GLFW_KEY_F6;
108 case XK_F7: return GLFW_KEY_F7;
109 case XK_F8: return GLFW_KEY_F8;
110 case XK_F9: return GLFW_KEY_F9;
111 case XK_F10: return GLFW_KEY_F10;
112 case XK_F11: return GLFW_KEY_F11;
113 case XK_F12: return GLFW_KEY_F12;
114 case XK_F13: return GLFW_KEY_F13;
115 case XK_F14: return GLFW_KEY_F14;
116 case XK_F15: return GLFW_KEY_F15;
117 case XK_F16: return GLFW_KEY_F16;
118 case XK_F17: return GLFW_KEY_F17;
119 case XK_F18: return GLFW_KEY_F18;
120 case XK_F19: return GLFW_KEY_F19;
121 case XK_F20: return GLFW_KEY_F20;
122 case XK_F21: return GLFW_KEY_F21;
123 case XK_F22: return GLFW_KEY_F22;
124 case XK_F23: return GLFW_KEY_F23;
125 case XK_F24: return GLFW_KEY_F24;
126 case XK_F25: return GLFW_KEY_F25;
127
128 // Numeric keypad
129 case XK_KP_Divide: return GLFW_KEY_KP_DIVIDE;
130 case XK_KP_Multiply: return GLFW_KEY_KP_MULTIPLY;
131 case XK_KP_Subtract: return GLFW_KEY_KP_SUBTRACT;
132 case XK_KP_Add: return GLFW_KEY_KP_ADD;
133
134 // These should have been detected in secondary keysym test above!
135 case XK_KP_Insert: return GLFW_KEY_KP_0;
136 case XK_KP_End: return GLFW_KEY_KP_1;
137 case XK_KP_Down: return GLFW_KEY_KP_2;
138 case XK_KP_Page_Down: return GLFW_KEY_KP_3;
139 case XK_KP_Left: return GLFW_KEY_KP_4;
140 case XK_KP_Right: return GLFW_KEY_KP_6;
141 case XK_KP_Home: return GLFW_KEY_KP_7;
142 case XK_KP_Up: return GLFW_KEY_KP_8;
143 case XK_KP_Page_Up: return GLFW_KEY_KP_9;
144 case XK_KP_Delete: return GLFW_KEY_KP_DECIMAL;
145 case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
146 case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
147
148 // Last resort: Check for printable keys (should not happen if the XKB
149 // extension is available). This will give a layout dependent mapping
150 // (which is wrong, and we may miss some keys, especially on non-US
151 // keyboards), but it's better than nothing...
152 case XK_a: return GLFW_KEY_A;
153 case XK_b: return GLFW_KEY_B;
154 case XK_c: return GLFW_KEY_C;
155 case XK_d: return GLFW_KEY_D;
156 case XK_e: return GLFW_KEY_E;
157 case XK_f: return GLFW_KEY_F;
158 case XK_g: return GLFW_KEY_G;
159 case XK_h: return GLFW_KEY_H;
160 case XK_i: return GLFW_KEY_I;
161 case XK_j: return GLFW_KEY_J;
162 case XK_k: return GLFW_KEY_K;
163 case XK_l: return GLFW_KEY_L;
164 case XK_m: return GLFW_KEY_M;
165 case XK_n: return GLFW_KEY_N;
166 case XK_o: return GLFW_KEY_O;
167 case XK_p: return GLFW_KEY_P;
168 case XK_q: return GLFW_KEY_Q;
169 case XK_r: return GLFW_KEY_R;
170 case XK_s: return GLFW_KEY_S;
171 case XK_t: return GLFW_KEY_T;
172 case XK_u: return GLFW_KEY_U;
173 case XK_v: return GLFW_KEY_V;
174 case XK_w: return GLFW_KEY_W;
175 case XK_x: return GLFW_KEY_X;
176 case XK_y: return GLFW_KEY_Y;
177 case XK_z: return GLFW_KEY_Z;
178 case XK_1: return GLFW_KEY_1;
179 case XK_2: return GLFW_KEY_2;
180 case XK_3: return GLFW_KEY_3;
181 case XK_4: return GLFW_KEY_4;
182 case XK_5: return GLFW_KEY_5;
183 case XK_6: return GLFW_KEY_6;
184 case XK_7: return GLFW_KEY_7;
185 case XK_8: return GLFW_KEY_8;
186 case XK_9: return GLFW_KEY_9;
187 case XK_0: return GLFW_KEY_0;
188 case XK_space: return GLFW_KEY_SPACE;
189 case XK_minus: return GLFW_KEY_MINUS;
190 case XK_equal: return GLFW_KEY_EQUAL;
191 case XK_bracketleft: return GLFW_KEY_LEFT_BRACKET;
192 case XK_bracketright: return GLFW_KEY_RIGHT_BRACKET;
193 case XK_backslash: return GLFW_KEY_BACKSLASH;
194 case XK_semicolon: return GLFW_KEY_SEMICOLON;
195 case XK_apostrophe: return GLFW_KEY_APOSTROPHE;
196 case XK_grave: return GLFW_KEY_GRAVE_ACCENT;
197 case XK_comma: return GLFW_KEY_COMMA;
198 case XK_period: return GLFW_KEY_PERIOD;
199 case XK_slash: return GLFW_KEY_SLASH;
200 case XK_less: return GLFW_KEY_WORLD_1; // At least in some layouts...
201 default: break;
202 }
203
204 // No matching translation was found
205 return GLFW_KEY_UNKNOWN;
206}
207
208// Create key code translation tables
209//
210static void createKeyTables(void)
211{
212 int scancode, scancodeMin, scancodeMax;
213
214 memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
215 memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
216
217 if (_glfw.x11.xkb.available)
218 {
219 // Use XKB to determine physical key locations independently of the
220 // current keyboard layout
221
222 XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
223 XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc);
224
225 scancodeMin = desc->min_key_code;
226 scancodeMax = desc->max_key_code;
227
228 const struct
229 {
230 int key;
231 char* name;
232 } keymap[] =
233 {
234 { GLFW_KEY_GRAVE_ACCENT, "TLDE" },
235 { GLFW_KEY_1, "AE01" },
236 { GLFW_KEY_2, "AE02" },
237 { GLFW_KEY_3, "AE03" },
238 { GLFW_KEY_4, "AE04" },
239 { GLFW_KEY_5, "AE05" },
240 { GLFW_KEY_6, "AE06" },
241 { GLFW_KEY_7, "AE07" },
242 { GLFW_KEY_8, "AE08" },
243 { GLFW_KEY_9, "AE09" },
244 { GLFW_KEY_0, "AE10" },
245 { GLFW_KEY_MINUS, "AE11" },
246 { GLFW_KEY_EQUAL, "AE12" },
247 { GLFW_KEY_Q, "AD01" },
248 { GLFW_KEY_W, "AD02" },
249 { GLFW_KEY_E, "AD03" },
250 { GLFW_KEY_R, "AD04" },
251 { GLFW_KEY_T, "AD05" },
252 { GLFW_KEY_Y, "AD06" },
253 { GLFW_KEY_U, "AD07" },
254 { GLFW_KEY_I, "AD08" },
255 { GLFW_KEY_O, "AD09" },
256 { GLFW_KEY_P, "AD10" },
257 { GLFW_KEY_LEFT_BRACKET, "AD11" },
258 { GLFW_KEY_RIGHT_BRACKET, "AD12" },
259 { GLFW_KEY_A, "AC01" },
260 { GLFW_KEY_S, "AC02" },
261 { GLFW_KEY_D, "AC03" },
262 { GLFW_KEY_F, "AC04" },
263 { GLFW_KEY_G, "AC05" },
264 { GLFW_KEY_H, "AC06" },
265 { GLFW_KEY_J, "AC07" },
266 { GLFW_KEY_K, "AC08" },
267 { GLFW_KEY_L, "AC09" },
268 { GLFW_KEY_SEMICOLON, "AC10" },
269 { GLFW_KEY_APOSTROPHE, "AC11" },
270 { GLFW_KEY_Z, "AB01" },
271 { GLFW_KEY_X, "AB02" },
272 { GLFW_KEY_C, "AB03" },
273 { GLFW_KEY_V, "AB04" },
274 { GLFW_KEY_B, "AB05" },
275 { GLFW_KEY_N, "AB06" },
276 { GLFW_KEY_M, "AB07" },
277 { GLFW_KEY_COMMA, "AB08" },
278 { GLFW_KEY_PERIOD, "AB09" },
279 { GLFW_KEY_SLASH, "AB10" },
280 { GLFW_KEY_BACKSLASH, "BKSL" },
281 { GLFW_KEY_WORLD_1, "LSGT" },
282 { GLFW_KEY_SPACE, "SPCE" },
283 { GLFW_KEY_ESCAPE, "ESC" },
284 { GLFW_KEY_ENTER, "RTRN" },
285 { GLFW_KEY_TAB, "TAB" },
286 { GLFW_KEY_BACKSPACE, "BKSP" },
287 { GLFW_KEY_INSERT, "INS" },
288 { GLFW_KEY_DELETE, "DELE" },
289 { GLFW_KEY_RIGHT, "RGHT" },
290 { GLFW_KEY_LEFT, "LEFT" },
291 { GLFW_KEY_DOWN, "DOWN" },
292 { GLFW_KEY_UP, "UP" },
293 { GLFW_KEY_PAGE_UP, "PGUP" },
294 { GLFW_KEY_PAGE_DOWN, "PGDN" },
295 { GLFW_KEY_HOME, "HOME" },
296 { GLFW_KEY_END, "END" },
297 { GLFW_KEY_CAPS_LOCK, "CAPS" },
298 { GLFW_KEY_SCROLL_LOCK, "SCLK" },
299 { GLFW_KEY_NUM_LOCK, "NMLK" },
300 { GLFW_KEY_PRINT_SCREEN, "PRSC" },
301 { GLFW_KEY_PAUSE, "PAUS" },
302 { GLFW_KEY_F1, "FK01" },
303 { GLFW_KEY_F2, "FK02" },
304 { GLFW_KEY_F3, "FK03" },
305 { GLFW_KEY_F4, "FK04" },
306 { GLFW_KEY_F5, "FK05" },
307 { GLFW_KEY_F6, "FK06" },
308 { GLFW_KEY_F7, "FK07" },
309 { GLFW_KEY_F8, "FK08" },
310 { GLFW_KEY_F9, "FK09" },
311 { GLFW_KEY_F10, "FK10" },
312 { GLFW_KEY_F11, "FK11" },
313 { GLFW_KEY_F12, "FK12" },
314 { GLFW_KEY_F13, "FK13" },
315 { GLFW_KEY_F14, "FK14" },
316 { GLFW_KEY_F15, "FK15" },
317 { GLFW_KEY_F16, "FK16" },
318 { GLFW_KEY_F17, "FK17" },
319 { GLFW_KEY_F18, "FK18" },
320 { GLFW_KEY_F19, "FK19" },
321 { GLFW_KEY_F20, "FK20" },
322 { GLFW_KEY_F21, "FK21" },
323 { GLFW_KEY_F22, "FK22" },
324 { GLFW_KEY_F23, "FK23" },
325 { GLFW_KEY_F24, "FK24" },
326 { GLFW_KEY_F25, "FK25" },
327 { GLFW_KEY_KP_0, "KP0" },
328 { GLFW_KEY_KP_1, "KP1" },
329 { GLFW_KEY_KP_2, "KP2" },
330 { GLFW_KEY_KP_3, "KP3" },
331 { GLFW_KEY_KP_4, "KP4" },
332 { GLFW_KEY_KP_5, "KP5" },
333 { GLFW_KEY_KP_6, "KP6" },
334 { GLFW_KEY_KP_7, "KP7" },
335 { GLFW_KEY_KP_8, "KP8" },
336 { GLFW_KEY_KP_9, "KP9" },
337 { GLFW_KEY_KP_DECIMAL, "KPDL" },
338 { GLFW_KEY_KP_DIVIDE, "KPDV" },
339 { GLFW_KEY_KP_MULTIPLY, "KPMU" },
340 { GLFW_KEY_KP_SUBTRACT, "KPSU" },
341 { GLFW_KEY_KP_ADD, "KPAD" },
342 { GLFW_KEY_KP_ENTER, "KPEN" },
343 { GLFW_KEY_KP_EQUAL, "KPEQ" },
344 { GLFW_KEY_LEFT_SHIFT, "LFSH" },
345 { GLFW_KEY_LEFT_CONTROL, "LCTL" },
346 { GLFW_KEY_LEFT_ALT, "LALT" },
347 { GLFW_KEY_LEFT_SUPER, "LWIN" },
348 { GLFW_KEY_RIGHT_SHIFT, "RTSH" },
349 { GLFW_KEY_RIGHT_CONTROL, "RCTL" },
350 { GLFW_KEY_RIGHT_ALT, "RALT" },
351 { GLFW_KEY_RIGHT_ALT, "LVL3" },
352 { GLFW_KEY_RIGHT_ALT, "MDSW" },
353 { GLFW_KEY_RIGHT_SUPER, "RWIN" },
354 { GLFW_KEY_MENU, "MENU" }
355 };
356
357 // Find the X11 key code -> GLFW key code mapping
358 for (scancode = scancodeMin; scancode <= scancodeMax; scancode++)
359 {
360 int key = GLFW_KEY_UNKNOWN;
361
362 // Map the key name to a GLFW key code. Note: We use the US
363 // keyboard layout. Because function keys aren't mapped correctly
364 // when using traditional KeySym translations, they are mapped
365 // here instead.
366 for (int i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++)
367 {
368 if (strncmp(desc->names->keys[scancode].name,
369 keymap[i].name,
370 XkbKeyNameLength) == 0)
371 {
372 key = keymap[i].key;
373 break;
374 }
375 }
376
377 // Fall back to key aliases in case the key name did not match
378 for (int i = 0; i < desc->names->num_key_aliases; i++)
379 {
380 if (key != GLFW_KEY_UNKNOWN)
381 break;
382
383 if (strncmp(desc->names->key_aliases[i].real,
384 desc->names->keys[scancode].name,
385 XkbKeyNameLength) != 0)
386 {
387 continue;
388 }
389
390 for (int j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++)
391 {
392 if (strncmp(desc->names->key_aliases[i].alias,
393 keymap[j].name,
394 XkbKeyNameLength) == 0)
395 {
396 key = keymap[j].key;
397 break;
398 }
399 }
400 }
401
402 _glfw.x11.keycodes[scancode] = key;
403 }
404
405 XkbFreeNames(desc, XkbKeyNamesMask, True);
406 XkbFreeKeyboard(desc, 0, True);
407 }
408 else
409 XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax);
410
411 int width;
412 KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display,
413 scancodeMin,
414 scancodeMax - scancodeMin + 1,
415 &width);
416
417 for (scancode = scancodeMin; scancode <= scancodeMax; scancode++)
418 {
419 // Translate the un-translated key codes using traditional X11 KeySym
420 // lookups
421 if (_glfw.x11.keycodes[scancode] < 0)
422 {
423 const size_t base = (scancode - scancodeMin) * width;
424 _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width);
425 }
426
427 // Store the reverse translation for faster key name lookup
428 if (_glfw.x11.keycodes[scancode] > 0)
429 _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
430 }
431
432 XFree(keysyms);
433}
434
435// Check whether the IM has a usable style
436//
437static GLFWbool hasUsableInputMethodStyle(void)
438{
439 GLFWbool found = GLFW_FALSE;
440 XIMStyles* styles = NULL;
441
442 if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
443 return GLFW_FALSE;
444
445 for (unsigned int i = 0; i < styles->count_styles; i++)
446 {
447 if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
448 {
449 found = GLFW_TRUE;
450 break;
451 }
452 }
453
454 XFree(styles);
455 return found;
456}
457
458static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData)
459{
460 _glfw.x11.im = NULL;
461}
462
463static void inputMethodInstantiateCallback(Display* display,
464 XPointer clientData,
465 XPointer callData)
466{
467 if (_glfw.x11.im)
468 return;
469
470 _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
471 if (_glfw.x11.im)
472 {
473 if (!hasUsableInputMethodStyle())
474 {
475 XCloseIM(_glfw.x11.im);
476 _glfw.x11.im = NULL;
477 }
478 }
479
480 if (_glfw.x11.im)
481 {
482 XIMCallback callback;
483 callback.callback = (XIMProc) inputMethodDestroyCallback;
484 callback.client_data = NULL;
485 XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL);
486
487 for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
489 }
490}
491
492// Return the atom ID only if it is listed in the specified array
493//
494static Atom getAtomIfSupported(Atom* supportedAtoms,
495 unsigned long atomCount,
496 const char* atomName)
497{
498 const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
499
500 for (unsigned long i = 0; i < atomCount; i++)
501 {
502 if (supportedAtoms[i] == atom)
503 return atom;
504 }
505
506 return None;
507}
508
509// Check whether the running window manager is EWMH-compliant
510//
511static void detectEWMH(void)
512{
513 // First we read the _NET_SUPPORTING_WM_CHECK property on the root window
514
515 Window* windowFromRoot = NULL;
516 if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
517 _glfw.x11.NET_SUPPORTING_WM_CHECK,
518 XA_WINDOW,
519 (unsigned char**) &windowFromRoot))
520 {
521 return;
522 }
523
525
526 // If it exists, it should be the XID of a top-level window
527 // Then we look for the same property on that window
528
529 Window* windowFromChild = NULL;
530 if (!_glfwGetWindowPropertyX11(*windowFromRoot,
531 _glfw.x11.NET_SUPPORTING_WM_CHECK,
532 XA_WINDOW,
533 (unsigned char**) &windowFromChild))
534 {
535 XFree(windowFromRoot);
536 return;
537 }
538
540
541 // If the property exists, it should contain the XID of the window
542
543 if (*windowFromRoot != *windowFromChild)
544 {
545 XFree(windowFromRoot);
546 XFree(windowFromChild);
547 return;
548 }
549
550 XFree(windowFromRoot);
551 XFree(windowFromChild);
552
553 // We are now fairly sure that an EWMH-compliant WM is currently running
554 // We can now start querying the WM about what features it supports by
555 // looking in the _NET_SUPPORTED property on the root window
556 // It should contain a list of supported EWMH protocol and state atoms
557
558 Atom* supportedAtoms = NULL;
559 const unsigned long atomCount =
561 _glfw.x11.NET_SUPPORTED,
562 XA_ATOM,
563 (unsigned char**) &supportedAtoms);
564
565 // See which of the atoms we support that are supported by the WM
566
567 _glfw.x11.NET_WM_STATE =
568 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
569 _glfw.x11.NET_WM_STATE_ABOVE =
570 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
571 _glfw.x11.NET_WM_STATE_FULLSCREEN =
572 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
573 _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
574 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
575 _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
576 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
577 _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
578 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
579 _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
580 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
581 _glfw.x11.NET_WM_WINDOW_TYPE =
582 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
583 _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
584 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
585 _glfw.x11.NET_WORKAREA =
586 getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
587 _glfw.x11.NET_CURRENT_DESKTOP =
588 getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
589 _glfw.x11.NET_ACTIVE_WINDOW =
590 getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
591 _glfw.x11.NET_FRAME_EXTENTS =
592 getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
593 _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
594 getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
595
596 if (supportedAtoms)
597 XFree(supportedAtoms);
598}
599
600// Look for and initialize supported X11 extensions
601//
602static GLFWbool initExtensions(void)
603{
604 _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
605 if (_glfw.x11.vidmode.handle)
606 {
607 _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
608 _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
609 _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
610 _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
611 _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
612 _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
613 _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
614 _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
615
616 _glfw.x11.vidmode.available =
618 &_glfw.x11.vidmode.eventBase,
619 &_glfw.x11.vidmode.errorBase);
620 }
621
622#if defined(__CYGWIN__)
623 _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
624#else
625 _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
626#endif
627 if (_glfw.x11.xi.handle)
628 {
629 _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
630 _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion");
631 _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
632 _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents");
633
634 if (XQueryExtension(_glfw.x11.display,
635 "XInputExtension",
636 &_glfw.x11.xi.majorOpcode,
637 &_glfw.x11.xi.eventBase,
638 &_glfw.x11.xi.errorBase))
639 {
640 _glfw.x11.xi.major = 2;
641 _glfw.x11.xi.minor = 0;
642
643 if (XIQueryVersion(_glfw.x11.display,
644 &_glfw.x11.xi.major,
645 &_glfw.x11.xi.minor) == Success)
646 {
647 _glfw.x11.xi.available = GLFW_TRUE;
648 }
649 }
650 }
651
652#if defined(__CYGWIN__)
653 _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
654#else
655 _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
656#endif
657 if (_glfw.x11.randr.handle)
658 {
659 _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
660 _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma");
661 _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
662 _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
663 _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
664 _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
665 _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
666 _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
667 _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
668 _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
669 _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
670 _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources");
671 _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
672 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
673 _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
674 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
675 _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
676 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
677 _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
678 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo");
679 _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
680 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
681 _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
682 _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
683 _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
684 _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension");
685 _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
686 _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion");
687 _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
688 _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput");
689 _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
690 _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
691 _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
692 _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
693 _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
694 _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
695
696 if (XRRQueryExtension(_glfw.x11.display,
697 &_glfw.x11.randr.eventBase,
698 &_glfw.x11.randr.errorBase))
699 {
700 if (XRRQueryVersion(_glfw.x11.display,
701 &_glfw.x11.randr.major,
702 &_glfw.x11.randr.minor))
703 {
704 // The GLFW RandR path requires at least version 1.3
705 if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
706 _glfw.x11.randr.available = GLFW_TRUE;
707 }
708 else
709 {
711 "X11: Failed to query RandR version");
712 }
713 }
714 }
715
716 if (_glfw.x11.randr.available)
717 {
718 XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
719 _glfw.x11.root);
720
721 if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
722 {
723 // This is likely an older Nvidia driver with broken gamma support
724 // Flag it as useless and fall back to xf86vm gamma, if available
725 _glfw.x11.randr.gammaBroken = GLFW_TRUE;
726 }
727
728 if (!sr->ncrtc)
729 {
730 // A system without CRTCs is likely a system with broken RandR
731 // Disable the RandR monitor path and fall back to core functions
732 _glfw.x11.randr.monitorBroken = GLFW_TRUE;
733 }
734
736 }
737
738 if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
739 {
740 XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
741 RROutputChangeNotifyMask);
742 }
743
744#if defined(__CYGWIN__)
745 _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
746#else
747 _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
748#endif
749 if (_glfw.x11.xcursor.handle)
750 {
751 _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
752 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate");
753 _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
754 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
755 _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
756 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
757 _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
758 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme");
759 _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
760 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
761 _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
762 _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
763 }
764
765#if defined(__CYGWIN__)
766 _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
767#else
768 _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
769#endif
770 if (_glfw.x11.xinerama.handle)
771 {
772 _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
773 _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive");
774 _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
775 _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
776 _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
777 _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
778
779 if (XineramaQueryExtension(_glfw.x11.display,
780 &_glfw.x11.xinerama.major,
781 &_glfw.x11.xinerama.minor))
782 {
783 if (XineramaIsActive(_glfw.x11.display))
784 _glfw.x11.xinerama.available = GLFW_TRUE;
785 }
786 }
787
788 _glfw.x11.xkb.major = 1;
789 _glfw.x11.xkb.minor = 0;
790 _glfw.x11.xkb.available =
791 XkbQueryExtension(_glfw.x11.display,
792 &_glfw.x11.xkb.majorOpcode,
793 &_glfw.x11.xkb.eventBase,
794 &_glfw.x11.xkb.errorBase,
795 &_glfw.x11.xkb.major,
796 &_glfw.x11.xkb.minor);
797
798 if (_glfw.x11.xkb.available)
799 {
800 Bool supported;
801
802 if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
803 {
804 if (supported)
805 _glfw.x11.xkb.detectable = GLFW_TRUE;
806 }
807
808 XkbStateRec state;
809 if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
810 _glfw.x11.xkb.group = (unsigned int)state.group;
811
812 XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
813 XkbGroupStateMask, XkbGroupStateMask);
814 }
815
817 {
818#if defined(__CYGWIN__)
819 _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
820#else
821 _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
822#endif
823 }
824
825 if (_glfw.x11.x11xcb.handle)
826 {
827 _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
828 _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
829 }
830
831#if defined(__CYGWIN__)
832 _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
833#else
834 _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
835#endif
836 if (_glfw.x11.xrender.handle)
837 {
838 _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
839 _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension");
840 _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
841 _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion");
842 _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
843 _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
844
845 if (XRenderQueryExtension(_glfw.x11.display,
846 &_glfw.x11.xrender.errorBase,
847 &_glfw.x11.xrender.eventBase))
848 {
849 if (XRenderQueryVersion(_glfw.x11.display,
850 &_glfw.x11.xrender.major,
851 &_glfw.x11.xrender.minor))
852 {
853 _glfw.x11.xrender.available = GLFW_TRUE;
854 }
855 }
856 }
857
858#if defined(__CYGWIN__)
859 _glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so");
860#else
861 _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6");
862#endif
863 if (_glfw.x11.xshape.handle)
864 {
865 _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
866 _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension");
867 _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
868 _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion");
869 _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
870 _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion");
871 _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
872 _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask");
873
874 if (XShapeQueryExtension(_glfw.x11.display,
875 &_glfw.x11.xshape.errorBase,
876 &_glfw.x11.xshape.eventBase))
877 {
878 if (XShapeQueryVersion(_glfw.x11.display,
879 &_glfw.x11.xshape.major,
880 &_glfw.x11.xshape.minor))
881 {
882 _glfw.x11.xshape.available = GLFW_TRUE;
883 }
884 }
885 }
886
887 // Update the key code LUT
888 // FIXME: We should listen to XkbMapNotify events to track changes to
889 // the keyboard mapping.
890 createKeyTables();
891
892 // String format atoms
893 _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
894 _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
895 _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
896
897 // Custom selection property atom
898 _glfw.x11.GLFW_SELECTION =
899 XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
900
901 // ICCCM standard clipboard atoms
902 _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
903 _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
904 _glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
905 _glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
906 _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
907
908 // Clipboard manager atoms
909 _glfw.x11.CLIPBOARD_MANAGER =
910 XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
911 _glfw.x11.SAVE_TARGETS =
912 XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
913
914 // Xdnd (drag and drop) atoms
915 _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
916 _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
917 _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
918 _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
919 _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
920 _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
921 _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
922 _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
923 _glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
924 _glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
925
926 // ICCCM, EWMH and Motif window property atoms
927 // These can be set safely even without WM support
928 // The EWMH atoms that require WM support are handled in detectEWMH
929 _glfw.x11.WM_PROTOCOLS =
930 XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
931 _glfw.x11.WM_STATE =
932 XInternAtom(_glfw.x11.display, "WM_STATE", False);
933 _glfw.x11.WM_DELETE_WINDOW =
934 XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
935 _glfw.x11.NET_SUPPORTED =
936 XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
937 _glfw.x11.NET_SUPPORTING_WM_CHECK =
938 XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
939 _glfw.x11.NET_WM_ICON =
940 XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
941 _glfw.x11.NET_WM_PING =
942 XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
943 _glfw.x11.NET_WM_PID =
944 XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
945 _glfw.x11.NET_WM_NAME =
946 XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
947 _glfw.x11.NET_WM_ICON_NAME =
948 XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
949 _glfw.x11.NET_WM_BYPASS_COMPOSITOR =
950 XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
951 _glfw.x11.NET_WM_WINDOW_OPACITY =
952 XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
953 _glfw.x11.MOTIF_WM_HINTS =
954 XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
955
956 // The compositing manager selection name contains the screen number
957 {
958 char name[32];
959 snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
960 _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
961 }
962
963 // Detect whether an EWMH-conformant window manager is running
964 detectEWMH();
965
966 return GLFW_TRUE;
967}
968
969// Retrieve system content scale via folklore heuristics
970//
971static void getSystemContentScale(float* xscale, float* yscale)
972{
973 // Start by assuming the default X11 DPI
974 // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
975 // would be set to 96, so assume that is the case if we cannot find it
976 float xdpi = 96.f, ydpi = 96.f;
977
978 // NOTE: Basing the scale on Xft.dpi where available should provide the most
979 // consistent user experience (matches Qt, Gtk, etc), although not
980 // always the most accurate one
981 char* rms = XResourceManagerString(_glfw.x11.display);
982 if (rms)
983 {
984 XrmDatabase db = XrmGetStringDatabase(rms);
985 if (db)
986 {
987 XrmValue value;
988 char* type = NULL;
989
990 if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
991 {
992 if (type && strcmp(type, "String") == 0)
993 xdpi = ydpi = atof(value.addr);
994 }
995
997 }
998 }
999
1000 *xscale = xdpi / 96.f;
1001 *yscale = ydpi / 96.f;
1002}
1003
1004// Create a blank cursor for hidden and disabled cursor modes
1005//
1006static Cursor createHiddenCursor(void)
1007{
1008 unsigned char pixels[16 * 16 * 4] = { 0 };
1009 GLFWimage image = { 16, 16, pixels };
1010 return _glfwCreateCursorX11(&image, 0, 0);
1011}
1012
1013// Create a helper window for IPC
1014//
1015static Window createHelperWindow(void)
1016{
1017 XSetWindowAttributes wa;
1018 wa.event_mask = PropertyChangeMask;
1019
1020 return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
1021 0, 0, 1, 1, 0, 0,
1022 InputOnly,
1023 DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
1024 CWEventMask, &wa);
1025}
1026
1027// X error handler
1028//
1029static int errorHandler(Display *display, XErrorEvent* event)
1030{
1031 if (_glfw.x11.display != display)
1032 return 0;
1033
1034 _glfw.x11.errorCode = event->error_code;
1035 return 0;
1036}
1037
1038
1042
1043// Sets the X error handler callback
1044//
1046{
1047 _glfw.x11.errorCode = Success;
1048 XSetErrorHandler(errorHandler);
1049}
1050
1051// Clears the X error handler callback
1052//
1054{
1055 // Synchronize to make sure all commands are processed
1056 XSync(_glfw.x11.display, False);
1058}
1059
1060// Reports the specified error, appending information about the last X error
1061//
1062void _glfwInputErrorX11(int error, const char* message)
1063{
1064 char buffer[_GLFW_MESSAGE_SIZE];
1065 XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
1066 buffer, sizeof(buffer));
1067
1068 _glfwInputError(error, "%s: %s", message, buffer);
1069}
1070
1071// Creates a native cursor object from the specified image and hotspot
1072//
1073Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
1074{
1075 int i;
1076 Cursor cursor;
1077
1078 if (!_glfw.x11.xcursor.handle)
1079 return None;
1080
1081 XcursorImage* native = XcursorImageCreate(image->width, image->height);
1082 if (native == NULL)
1083 return None;
1084
1085 native->xhot = xhot;
1086 native->yhot = yhot;
1087
1088 unsigned char* source = (unsigned char*) image->pixels;
1089 XcursorPixel* target = native->pixels;
1090
1091 for (i = 0; i < image->width * image->height; i++, target++, source += 4)
1092 {
1093 unsigned int alpha = source[3];
1094
1095 *target = (alpha << 24) |
1096 ((unsigned char) ((source[0] * alpha) / 255) << 16) |
1097 ((unsigned char) ((source[1] * alpha) / 255) << 8) |
1098 ((unsigned char) ((source[2] * alpha) / 255) << 0);
1099 }
1100
1101 cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
1102 XcursorImageDestroy(native);
1103
1104 return cursor;
1105}
1106
1107
1111
1113{
1114 // HACK: If the application has left the locale as "C" then both wide
1115 // character text input and explicit UTF-8 input via XIM will break
1116 // This sets the CTYPE part of the current locale from the environment
1117 // in the hope that it is set to something more sane than "C"
1118 if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
1119 setlocale(LC_CTYPE, "");
1120
1121#if defined(__CYGWIN__)
1122 _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so");
1123#else
1124 _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6");
1125#endif
1126 if (!_glfw.x11.xlib.handle)
1127 {
1128 _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib");
1129 return GLFW_FALSE;
1130 }
1131
1132 _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
1133 _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint");
1134 _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
1135 _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints");
1136 _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints)
1137 _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints");
1138 _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty)
1139 _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty");
1140 _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes)
1141 _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes");
1142 _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent)
1143 _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent");
1144 _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent)
1145 _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent");
1146 _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay)
1147 _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay");
1148 _glfw.x11.xlib.CloseIM = (PFN_XCloseIM)
1149 _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM");
1150 _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection)
1151 _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection");
1152 _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap)
1153 _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap");
1154 _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor)
1155 _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor");
1156 _glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
1157 _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC");
1158 _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
1159 _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion");
1160 _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
1161 _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow");
1162 _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
1163 _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor");
1164 _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext)
1165 _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext");
1166 _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty)
1167 _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty");
1168 _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
1169 _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC");
1170 _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
1171 _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion");
1172 _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
1173 _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow");
1174 _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
1175 _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes");
1176 _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued)
1177 _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued");
1178 _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent)
1179 _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent");
1180 _glfw.x11.xlib.FindContext = (PFN_XFindContext)
1181 _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext");
1182 _glfw.x11.xlib.Flush = (PFN_XFlush)
1183 _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush");
1184 _glfw.x11.xlib.Free = (PFN_XFree)
1185 _glfw_dlsym(_glfw.x11.xlib.handle, "XFree");
1186 _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap)
1187 _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap");
1188 _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor)
1189 _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor");
1190 _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
1191 _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData");
1192 _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
1193 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText");
1194 _glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
1195 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData");
1196 _glfw.x11.xlib.GetICValues = (PFN_XGetICValues)
1197 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues");
1198 _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues)
1199 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues");
1200 _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus)
1201 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus");
1202 _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping)
1203 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping");
1204 _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver)
1205 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver");
1206 _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner)
1207 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner");
1208 _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo)
1209 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo");
1210 _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints)
1211 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints");
1212 _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes)
1213 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes");
1214 _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty)
1215 _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty");
1216 _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer)
1217 _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer");
1218 _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow)
1219 _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow");
1220 _glfw.x11.xlib.InitThreads = (PFN_XInitThreads)
1221 _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads");
1222 _glfw.x11.xlib.InternAtom = (PFN_XInternAtom)
1223 _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom");
1224 _glfw.x11.xlib.LookupString = (PFN_XLookupString)
1225 _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString");
1226 _glfw.x11.xlib.MapRaised = (PFN_XMapRaised)
1227 _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised");
1228 _glfw.x11.xlib.MapWindow = (PFN_XMapWindow)
1229 _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow");
1230 _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow)
1231 _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow");
1232 _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow)
1233 _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow");
1234 _glfw.x11.xlib.NextEvent = (PFN_XNextEvent)
1235 _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent");
1236 _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay)
1237 _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay");
1238 _glfw.x11.xlib.OpenIM = (PFN_XOpenIM)
1239 _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM");
1240 _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent)
1241 _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent");
1242 _glfw.x11.xlib.Pending = (PFN_XPending)
1243 _glfw_dlsym(_glfw.x11.xlib.handle, "XPending");
1244 _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension)
1245 _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension");
1246 _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer)
1247 _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer");
1248 _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow)
1249 _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow");
1250 _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback)
1251 _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback");
1252 _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow)
1253 _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow");
1254 _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString)
1255 _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString");
1256 _glfw.x11.xlib.SaveContext = (PFN_XSaveContext)
1257 _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext");
1258 _glfw.x11.xlib.SelectInput = (PFN_XSelectInput)
1259 _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput");
1260 _glfw.x11.xlib.SendEvent = (PFN_XSendEvent)
1261 _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent");
1262 _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint)
1263 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint");
1264 _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler)
1265 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler");
1266 _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus)
1267 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus");
1268 _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues)
1269 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues");
1270 _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus)
1271 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus");
1272 _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers)
1273 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers");
1274 _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver)
1275 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver");
1276 _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner)
1277 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner");
1278 _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints)
1279 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints");
1280 _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints)
1281 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints");
1282 _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols)
1283 _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols");
1284 _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale)
1285 _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale");
1286 _glfw.x11.xlib.Sync = (PFN_XSync)
1287 _glfw_dlsym(_glfw.x11.xlib.handle, "XSync");
1288 _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates)
1289 _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates");
1290 _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor)
1291 _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor");
1292 _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
1293 _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer");
1294 _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
1295 _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow");
1296 _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)
1297 _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus");
1298 _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual)
1299 _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
1300 _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
1301 _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer");
1302 _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
1303 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
1304 _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
1305 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames");
1306 _glfw.x11.xkb.GetMap = (PFN_XkbGetMap)
1307 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap");
1308 _glfw.x11.xkb.GetNames = (PFN_XkbGetNames)
1309 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames");
1310 _glfw.x11.xkb.GetState = (PFN_XkbGetState)
1311 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState");
1312 _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym)
1313 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym");
1314 _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension)
1315 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension");
1316 _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails)
1317 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails");
1318 _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat)
1319 _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat");
1320 _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase)
1321 _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase");
1322 _glfw.x11.xrm.GetResource = (PFN_XrmGetResource)
1323 _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource");
1324 _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase)
1325 _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase");
1326 _glfw.x11.xrm.Initialize = (PFN_XrmInitialize)
1327 _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize");
1328 _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark)
1329 _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark");
1330 _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback)
1331 _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback");
1332 _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString)
1333 _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString");
1334 _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
1335 _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
1336
1337 if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
1338 _glfw.x11.xlib.utf8 = GLFW_TRUE;
1339
1340 XInitThreads();
1341 XrmInitialize();
1342
1343 _glfw.x11.display = XOpenDisplay(NULL);
1344 if (!_glfw.x11.display)
1345 {
1346 const char* display = getenv("DISPLAY");
1347 if (display)
1348 {
1350 "X11: Failed to open display %s", display);
1351 }
1352 else
1353 {
1355 "X11: The DISPLAY environment variable is missing");
1356 }
1357
1358 return GLFW_FALSE;
1359 }
1360
1361 _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
1362 _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
1363 _glfw.x11.context = XUniqueContext();
1364
1365 getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
1366
1367 if (!initExtensions())
1368 return GLFW_FALSE;
1369
1370 _glfw.x11.helperWindowHandle = createHelperWindow();
1371 _glfw.x11.hiddenCursorHandle = createHiddenCursor();
1372
1373 if (XSupportsLocale() && _glfw.x11.xlib.utf8)
1374 {
1376
1377 // If an IM is already present our callback will be called right away
1379 NULL, NULL, NULL,
1380 inputMethodInstantiateCallback,
1381 NULL);
1382 }
1383
1385
1387 return GLFW_TRUE;
1388}
1389
1391{
1392 if (_glfw.x11.helperWindowHandle)
1393 {
1394 if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
1395 _glfw.x11.helperWindowHandle)
1396 {
1398 }
1399
1400 XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
1401 _glfw.x11.helperWindowHandle = None;
1402 }
1403
1404 if (_glfw.x11.hiddenCursorHandle)
1405 {
1406 XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
1407 _glfw.x11.hiddenCursorHandle = (Cursor) 0;
1408 }
1409
1410 free(_glfw.x11.primarySelectionString);
1411 free(_glfw.x11.clipboardString);
1412
1414 NULL, NULL, NULL,
1415 inputMethodInstantiateCallback,
1416 NULL);
1417
1418 if (_glfw.x11.im)
1419 {
1420 XCloseIM(_glfw.x11.im);
1421 _glfw.x11.im = NULL;
1422 }
1423
1424 if (_glfw.x11.display)
1425 {
1426 XCloseDisplay(_glfw.x11.display);
1427 _glfw.x11.display = NULL;
1428 }
1429
1430 if (_glfw.x11.x11xcb.handle)
1431 {
1432 _glfw_dlclose(_glfw.x11.x11xcb.handle);
1433 _glfw.x11.x11xcb.handle = NULL;
1434 }
1435
1436 if (_glfw.x11.xcursor.handle)
1437 {
1438 _glfw_dlclose(_glfw.x11.xcursor.handle);
1439 _glfw.x11.xcursor.handle = NULL;
1440 }
1441
1442 if (_glfw.x11.randr.handle)
1443 {
1444 _glfw_dlclose(_glfw.x11.randr.handle);
1445 _glfw.x11.randr.handle = NULL;
1446 }
1447
1448 if (_glfw.x11.xinerama.handle)
1449 {
1450 _glfw_dlclose(_glfw.x11.xinerama.handle);
1451 _glfw.x11.xinerama.handle = NULL;
1452 }
1453
1454 if (_glfw.x11.xrender.handle)
1455 {
1456 _glfw_dlclose(_glfw.x11.xrender.handle);
1457 _glfw.x11.xrender.handle = NULL;
1458 }
1459
1460 if (_glfw.x11.vidmode.handle)
1461 {
1462 _glfw_dlclose(_glfw.x11.vidmode.handle);
1463 _glfw.x11.vidmode.handle = NULL;
1464 }
1465
1466 if (_glfw.x11.xi.handle)
1467 {
1468 _glfw_dlclose(_glfw.x11.xi.handle);
1469 _glfw.x11.xi.handle = NULL;
1470 }
1471
1472 // NOTE: These need to be unloaded after XCloseDisplay, as they register
1473 // cleanup callbacks that get called by that function
1476
1477 if (_glfw.x11.xlib.handle)
1478 {
1479 _glfw_dlclose(_glfw.x11.xlib.handle);
1480 _glfw.x11.xlib.handle = NULL;
1481 }
1482}
1483
1485{
1486 return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa"
1487#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
1488 " clock_gettime"
1489#else
1490 " gettimeofday"
1491#endif
1492#if defined(__linux__)
1493 " evdev"
1494#endif
1495#if defined(_GLFW_BUILD_DLL)
1496 " shared"
1497#endif
1498 ;
1499}
1500
#define _glfw_dlopen(name)
#define _glfw_dlsym(handle, name)
#define _glfw_dlclose(handle)
void _glfwTerminateEGL(void)
Definition: egl_context.c:481
void _glfwTerminateGLX(void)
Definition: glx_context.c:425
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:758
#define GLFW_TRUE
One.
Definition: glfw3.h:310
#define GLFW_FALSE
Zero.
Definition: glfw3.h:319
#define GLFW_KEY_C
Definition: glfw3.h:412
#define GLFW_KEY_D
Definition: glfw3.h:413
#define GLFW_KEY_A
Definition: glfw3.h:410
#define GLFW_KEY_1
Definition: glfw3.h:399
#define GLFW_KEY_RIGHT
Definition: glfw3.h:450
#define GLFW_KEY_F2
Definition: glfw3.h:464
#define GLFW_KEY_F11
Definition: glfw3.h:473
#define GLFW_KEY_KP_0
Definition: glfw3.h:488
#define GLFW_KEY_S
Definition: glfw3.h:428
#define GLFW_KEY_V
Definition: glfw3.h:431
#define GLFW_KEY_I
Definition: glfw3.h:418
#define GLFW_KEY_9
Definition: glfw3.h:407
#define GLFW_KEY_UP
Definition: glfw3.h:453
#define GLFW_KEY_F21
Definition: glfw3.h:483
#define GLFW_KEY_INSERT
Definition: glfw3.h:448
#define GLFW_KEY_PERIOD
Definition: glfw3.h:396
#define GLFW_KEY_NUM_LOCK
Definition: glfw3.h:460
#define GLFW_KEY_PAGE_UP
Definition: glfw3.h:454
#define GLFW_KEY_HOME
Definition: glfw3.h:456
#define GLFW_KEY_F23
Definition: glfw3.h:485
#define GLFW_KEY_K
Definition: glfw3.h:420
#define GLFW_KEY_R
Definition: glfw3.h:427
#define GLFW_KEY_5
Definition: glfw3.h:403
#define GLFW_KEY_M
Definition: glfw3.h:422
#define GLFW_KEY_KP_DECIMAL
Definition: glfw3.h:498
#define GLFW_KEY_KP_ENTER
Definition: glfw3.h:503
#define GLFW_KEY_0
Definition: glfw3.h:398
#define GLFW_KEY_F
Definition: glfw3.h:415
#define GLFW_KEY_APOSTROPHE
Definition: glfw3.h:393
#define GLFW_KEY_J
Definition: glfw3.h:419
#define GLFW_KEY_RIGHT_ALT
Definition: glfw3.h:511
#define GLFW_KEY_TAB
Definition: glfw3.h:446
#define GLFW_KEY_BACKSPACE
Definition: glfw3.h:447
#define GLFW_KEY_F6
Definition: glfw3.h:468
#define GLFW_KEY_F10
Definition: glfw3.h:472
#define GLFW_KEY_GRAVE_ACCENT
Definition: glfw3.h:439
#define GLFW_KEY_KP_3
Definition: glfw3.h:491
#define GLFW_KEY_LEFT_ALT
Definition: glfw3.h:507
#define GLFW_KEY_F15
Definition: glfw3.h:477
#define GLFW_KEY_PAUSE
Definition: glfw3.h:462
#define GLFW_KEY_3
Definition: glfw3.h:401
#define GLFW_KEY_F24
Definition: glfw3.h:486
#define GLFW_KEY_F20
Definition: glfw3.h:482
#define GLFW_KEY_SEMICOLON
Definition: glfw3.h:408
#define GLFW_KEY_END
Definition: glfw3.h:457
#define GLFW_KEY_RIGHT_BRACKET
Definition: glfw3.h:438
#define GLFW_KEY_KP_7
Definition: glfw3.h:495
#define GLFW_KEY_LEFT_SHIFT
Definition: glfw3.h:505
#define GLFW_KEY_B
Definition: glfw3.h:411
#define GLFW_KEY_P
Definition: glfw3.h:425
#define GLFW_KEY_F22
Definition: glfw3.h:484
#define GLFW_KEY_T
Definition: glfw3.h:429
#define GLFW_KEY_CAPS_LOCK
Definition: glfw3.h:458
#define GLFW_KEY_ENTER
Definition: glfw3.h:445
#define GLFW_KEY_F17
Definition: glfw3.h:479
#define GLFW_KEY_MENU
Definition: glfw3.h:513
#define GLFW_KEY_UNKNOWN
Definition: glfw3.h:389
#define GLFW_KEY_KP_5
Definition: glfw3.h:493
#define GLFW_KEY_KP_MULTIPLY
Definition: glfw3.h:500
#define GLFW_KEY_F4
Definition: glfw3.h:466
#define GLFW_KEY_4
Definition: glfw3.h:402
#define GLFW_KEY_6
Definition: glfw3.h:404
#define GLFW_KEY_LEFT_CONTROL
Definition: glfw3.h:506
#define GLFW_KEY_W
Definition: glfw3.h:432
#define GLFW_KEY_KP_SUBTRACT
Definition: glfw3.h:501
#define GLFW_KEY_F25
Definition: glfw3.h:487
#define GLFW_KEY_F16
Definition: glfw3.h:478
#define GLFW_KEY_L
Definition: glfw3.h:421
#define GLFW_KEY_ESCAPE
Definition: glfw3.h:444
#define GLFW_KEY_KP_8
Definition: glfw3.h:496
#define GLFW_KEY_COMMA
Definition: glfw3.h:394
#define GLFW_KEY_7
Definition: glfw3.h:405
#define GLFW_KEY_BACKSLASH
Definition: glfw3.h:437
#define GLFW_KEY_KP_DIVIDE
Definition: glfw3.h:499
#define GLFW_KEY_E
Definition: glfw3.h:414
#define GLFW_KEY_X
Definition: glfw3.h:433
#define GLFW_KEY_Z
Definition: glfw3.h:435
#define GLFW_KEY_MINUS
Definition: glfw3.h:395
#define GLFW_KEY_F8
Definition: glfw3.h:470
#define GLFW_KEY_U
Definition: glfw3.h:430
#define GLFW_KEY_F7
Definition: glfw3.h:469
#define GLFW_KEY_KP_ADD
Definition: glfw3.h:502
#define GLFW_KEY_LEFT_BRACKET
Definition: glfw3.h:436
#define GLFW_KEY_RIGHT_CONTROL
Definition: glfw3.h:510
#define GLFW_KEY_RIGHT_SUPER
Definition: glfw3.h:512
#define GLFW_KEY_H
Definition: glfw3.h:417
#define GLFW_KEY_F13
Definition: glfw3.h:475
#define GLFW_KEY_KP_4
Definition: glfw3.h:492
#define GLFW_KEY_DELETE
Definition: glfw3.h:449
#define GLFW_KEY_WORLD_1
Definition: glfw3.h:440
#define GLFW_KEY_2
Definition: glfw3.h:400
#define GLFW_KEY_SPACE
Definition: glfw3.h:392
#define GLFW_KEY_8
Definition: glfw3.h:406
#define GLFW_KEY_SLASH
Definition: glfw3.h:397
#define GLFW_KEY_N
Definition: glfw3.h:423
#define GLFW_KEY_LEFT
Definition: glfw3.h:451
#define GLFW_KEY_EQUAL
Definition: glfw3.h:409
#define GLFW_KEY_DOWN
Definition: glfw3.h:452
#define GLFW_KEY_F9
Definition: glfw3.h:471
#define GLFW_KEY_G
Definition: glfw3.h:416
#define GLFW_KEY_KP_EQUAL
Definition: glfw3.h:504
#define GLFW_KEY_F18
Definition: glfw3.h:480
#define GLFW_KEY_F19
Definition: glfw3.h:481
#define GLFW_KEY_O
Definition: glfw3.h:424
#define GLFW_KEY_F3
Definition: glfw3.h:465
#define GLFW_KEY_PAGE_DOWN
Definition: glfw3.h:455
#define GLFW_KEY_F14
Definition: glfw3.h:476
#define GLFW_KEY_F5
Definition: glfw3.h:467
#define GLFW_KEY_KP_1
Definition: glfw3.h:489
#define GLFW_KEY_F12
Definition: glfw3.h:474
#define GLFW_KEY_SCROLL_LOCK
Definition: glfw3.h:459
#define GLFW_KEY_KP_2
Definition: glfw3.h:490
#define GLFW_KEY_PRINT_SCREEN
Definition: glfw3.h:461
#define GLFW_KEY_LEFT_SUPER
Definition: glfw3.h:508
#define GLFW_KEY_KP_9
Definition: glfw3.h:497
#define GLFW_KEY_F1
Definition: glfw3.h:463
#define GLFW_KEY_KP_6
Definition: glfw3.h:494
#define GLFW_KEY_Y
Definition: glfw3.h:434
#define GLFW_KEY_Q
Definition: glfw3.h:426
#define GLFW_KEY_RIGHT_SHIFT
Definition: glfw3.h:509
_GLFWlibrary _glfw
Definition: init.c:46
void _glfwInputError(int code, const char *format,...)
Definition: init.c:160
#define _GLFW_VERSION_NUMBER
Definition: internal.h:203
int GLFWbool
Definition: internal.h:61
#define _GLFW_MESSAGE_SIZE
Definition: internal.h:59
#define NULL
Definition: miniaudio.h:3718
void _glfwInitTimerPOSIX(void)
Definition: posix_time.c:45
GLFWbool xcbVulkanSurface
Definition: internal.h:252
struct _GLFWinitconfig::@17 x11
void * handle
Definition: internal.h:563
_GLFWctxconfig context
Definition: internal.h:535
_GLFWwindow * windowListHead
Definition: internal.h:541
GLFWbool available
Definition: internal.h:562
_GLFWinitconfig init
Definition: internal.h:532
struct _GLFWlibrary::@23 hints
struct _GLFWwindow * next
Definition: internal.h:379
Image data.
Definition: glfw3.h:1855
int height
Definition: glfw3.h:1861
unsigned char * pixels
Definition: glfw3.h:1864
int width
Definition: glfw3.h:1858
void _glfwInputErrorX11(int error, const char *message)
Definition: x11_init.c:1062
void _glfwReleaseErrorHandlerX11(void)
Definition: x11_init.c:1053
const char * _glfwPlatformGetVersionString(void)
Definition: x11_init.c:1484
void _glfwPlatformTerminate(void)
Definition: x11_init.c:1390
int _glfwPlatformInit(void)
Definition: x11_init.c:1112
void _glfwGrabErrorHandlerX11(void)
Definition: x11_init.c:1045
Cursor _glfwCreateCursorX11(const GLFWimage *image, int xhot, int yhot)
Definition: x11_init.c:1073
void _glfwPollMonitorsX11(void)
Definition: x11_monitor.c:101
XSizeHints *(* PFN_XAllocSizeHints)(void)
Definition: x11_platform.h:55
XClassHint *(* PFN_XAllocClassHint)(void)
Definition: x11_platform.h:54
int(* PFN_Xutf8LookupString)(XIC, XKeyPressedEvent *, char *, int, KeySym *, Status *)
Definition: x11_platform.h:154
int(* PFN_XMoveWindow)(Display *, Window, int, int)
Definition: x11_platform.h:104
int(* PFN_XCloseDisplay)(Display *)
Definition: x11_platform.h:61
int(* PFN_XNextEvent)(Display *, XEvent *)
Definition: x11_platform.h:105
XkbDescPtr(* PFN_XkbGetMap)(Display *, unsigned int, unsigned int)
Definition: x11_platform.h:141
int(* PFN_XUndefineCursor)(Display *, Window)
Definition: x11_platform.h:133
Status(* PFN_XkbGetNames)(Display *, unsigned int, XkbDescPtr)
Definition: x11_platform.h:142
int(* PFN_XRRUpdateConfiguration)(XEvent *)
Definition: x11_platform.h:275
int(* PFN_XSetSelectionOwner)(Display *, Atom, Window, Time)
Definition: x11_platform.h:126
int(* PFN_XGetErrorText)(Display *, int, char *, int)
Definition: x11_platform.h:84
#define XDisplayKeycodes
Definition: x11_platform.h:177
#define XkbSetDetectableAutoRepeat
Definition: x11_platform.h:249
#define XRRGetCrtcGammaSize
Definition: x11_platform.h:282
#define XSupportsLocale
Definition: x11_platform.h:232
int(* PFN_XFreeCursor)(Display *, Cursor)
Definition: x11_platform.h:82
Status(* PFN_XIQueryVersion)(Display *, int *, int *)
Definition: x11_platform.h:329
int(* PFN_XDefineCursor)(Display *, Window, Cursor)
Definition: x11_platform.h:69
int(* PFN_XResizeWindow)(Display *, Window, unsigned int, unsigned int)
Definition: x11_platform.h:114
int(* PFN_XSync)(Display *, Bool)
Definition: x11_platform.h:131
#define XGetErrorText
Definition: x11_platform.h:186
#define XCloseDisplay
Definition: x11_platform.h:163
#define XSetLocaleModifiers
Definition: x11_platform.h:226
int(* PFN_XGetScreenSaver)(Display *, int *, int *, int *, int *)
Definition: x11_platform.h:90
XRRCrtcGamma *(* PFN_XRRAllocGamma)(int)
Definition: x11_platform.h:259
Region(* PFN_XCreateRegion)(void)
Definition: x11_platform.h:67
int(* PFN_XGetInputFocus)(Display *, Window *, int *)
Definition: x11_platform.h:88
#define XRRFreeScreenResources
Definition: x11_platform.h:280
#define XResourceManagerString
Definition: x11_platform.h:217
Cursor(* PFN_XcursorImageLoadCursor)(Display *, const XcursorImage *)
Definition: x11_platform.h:296
char *(* PFN_XSetLocaleModifiers)(const char *)
Definition: x11_platform.h:124
int(* PFN_XcursorGetDefaultSize)(Display *)
Definition: x11_platform.h:298
void(* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo *)
Definition: x11_platform.h:260
int(* PFN_XRaiseWindow)(Display *, Window)
Definition: x11_platform.h:112
#define XFreeCursor
Definition: x11_platform.h:184
Bool(* PFN_XGetEventData)(Display *, XGenericEventCookie *)
Definition: x11_platform.h:85
#define XkbGetNames
Definition: x11_platform.h:244
#define XInternAtom
Definition: x11_platform.h:201
XcursorImage *(* PFN_XcursorLibraryLoadImage)(const char *, const char *, int)
Definition: x11_platform.h:299
Bool(* PFN_XRRQueryExtension)(Display *, int *, int *)
Definition: x11_platform.h:270
#define XUnregisterIMInstantiateCallback
Definition: x11_platform.h:255
char *(* PFN_XResourceManagerString)(Display *)
Definition: x11_platform.h:115
void(* PFN_XShapeCombineRegion)(Display *, Window, int, int, int, Region, int)
Definition: x11_platform.h:343
int(* PFN_XRRGetCrtcGammaSize)(Display *, RRCrtc)
Definition: x11_platform.h:265
Status(* PFN_XSetWMProtocols)(Display *, Window, Atom *, int)
Definition: x11_platform.h:129
#define XrmGetStringDatabase
Definition: x11_platform.h:252
void(* PFN_XRRFreeOutputInfo)(XRROutputInfo *)
Definition: x11_platform.h:262
Status(* PFN_XGetWMNormalHints)(Display *, Window, XSizeHints *, long *)
Definition: x11_platform.h:93
#define XkbQueryExtension
Definition: x11_platform.h:247
#define XkbFreeKeyboard
Definition: x11_platform.h:241
int(* PFN_XDisplayKeycodes)(Display *, int *, int *)
Definition: x11_platform.h:75
XRRCrtcInfo *(* PFN_XRRGetCrtcInfo)(Display *, XRRScreenResources *, RRCrtc)
Definition: x11_platform.h:266
#define XineramaQueryExtension
Definition: x11_platform.h:311
int(* PFN_XConvertSelection)(Display *, Atom, Atom, Atom, Window, Time)
Definition: x11_platform.h:63
Window(* PFN_XCreateWindow)(Display *, Window, int, int, unsigned int, unsigned int, unsigned int, int, unsigned int, Visual *, unsigned long, XSetWindowAttributes *)
Definition: x11_platform.h:68
Bool(* PFN_XRegisterIMInstantiateCallback)(Display *, void *, char *, char *, XIDProc, XPointer)
Definition: x11_platform.h:113
int(* PFN_XFree)(void *)
Definition: x11_platform.h:80
int(* PFN_XWarpPointer)(Display *, Window, Window, int, int, unsigned int, unsigned int, int, int)
Definition: x11_platform.h:138
void(* PFN_XRRSetCrtcGamma)(Display *, RRCrtc, XRRCrtcGamma *)
Definition: x11_platform.h:274
#define XRRQueryExtension
Definition: x11_platform.h:287
Bool(* PFN_XQueryExtension)(Display *, const char *, int *, int *, int *)
Definition: x11_platform.h:110
Bool(* PFN_XUnregisterIMInstantiateCallback)(Display *, void *, char *, char *, XIDProc, XPointer)
Definition: x11_platform.h:153
Bool(* PFN_XRenderQueryExtension)(Display *, int *, int *)
Definition: x11_platform.h:334
void(* PFN_XSetICFocus)(XIC)
Definition: x11_platform.h:121
XRenderPictFormat *(* PFN_XRenderFindVisualFormat)(Display *, Visual const *)
Definition: x11_platform.h:336
#define XineramaIsActive
Definition: x11_platform.h:310
void(* PFN_XUnsetICFocus)(XIC)
Definition: x11_platform.h:136
Bool(* PFN_XF86VidModeSetGammaRamp)(Display *, int, int, unsigned short *, unsigned short *, unsigned short *)
Definition: x11_platform.h:322
int(* PFN_XUnmapWindow)(Display *, Window)
Definition: x11_platform.h:135
Bool(* PFN_XFilterEvent)(XEvent *, Window)
Definition: x11_platform.h:77
void(* PFN_XRRFreeGamma)(XRRCrtcGamma *)
Definition: x11_platform.h:261
void(* PFN_XSetWMNormalHints)(Display *, Window, XSizeHints *)
Definition: x11_platform.h:128
int(* PFN_XUngrabPointer)(Display *, Time)
Definition: x11_platform.h:134
Window(* PFN_XGetSelectionOwner)(Display *, Atom)
Definition: x11_platform.h:91
Bool(* PFN_XrmGetResource)(XrmDatabase, const char *, const char *, char **, XrmValue *)
Definition: x11_platform.h:149
void(* PFN_XkbFreeNames)(XkbDescPtr, unsigned int, Bool)
Definition: x11_platform.h:140
RROutput(* PFN_XRRGetOutputPrimary)(Display *, Window)
Definition: x11_platform.h:268
xcb_connection_t *(* PFN_XGetXCBConnection)(Display *)
Definition: x11_platform.h:317
int(* PFN_XFindContext)(Display *, XID, XContext, XPointer *)
Definition: x11_platform.h:78
#define XRenderQueryExtension
Definition: x11_platform.h:337
XRRScreenResources *(* PFN_XRRGetScreenResourcesCurrent)(Display *, Window)
Definition: x11_platform.h:269
#define XrmInitialize
Definition: x11_platform.h:253
int(* PFN_XFreeColormap)(Display *, Colormap)
Definition: x11_platform.h:81
#define XGetIMValues
Definition: x11_platform.h:189
int(* PFN_XSetWMHints)(Display *, Window, XWMHints *)
Definition: x11_platform.h:127
#define XGetKeyboardMapping
Definition: x11_platform.h:191
#define XSetIMValues
Definition: x11_platform.h:224
Bool(* PFN_XCheckTypedWindowEvent)(Display *, Window, int, XEvent *)
Definition: x11_platform.h:60
#define XRRGetScreenResourcesCurrent
Definition: x11_platform.h:286
int(* PFN_XDestroyWindow)(Display *, Window)
Definition: x11_platform.h:74
int(* PFN_XDeleteContext)(Display *, XID, XContext)
Definition: x11_platform.h:70
int(* PFN_XGrabPointer)(Display *, Window, Bool, unsigned int, int, int, Window, Cursor, Time)
Definition: x11_platform.h:96
unsigned long _glfwGetWindowPropertyX11(Window window, Atom property, Atom type, unsigned char **value)
Definition: x11_window.c:1854
int(* PFN_XChangeWindowAttributes)(Display *, Window, unsigned long, XSetWindowAttributes *)
Definition: x11_platform.h:58
#define XCloseIM
Definition: x11_platform.h:164
void(* PFN_XRRFreeScreenResources)(XRRScreenResources *)
Definition: x11_platform.h:263
int(* PFN_XMoveResizeWindow)(Display *, Window, int, int, unsigned int, unsigned int)
Definition: x11_platform.h:103
Bool(* PFN_XSupportsLocale)(void)
Definition: x11_platform.h:130
XrmDatabase(* PFN_XrmGetStringDatabase)(const char *)
Definition: x11_platform.h:150
Status(* PFN_XRRSetCrtcConfig)(Display *, XRRScreenResources *, RRCrtc, Time, int, int, RRMode, Rotation, RROutput *, int)
Definition: x11_platform.h:273
#define XSetErrorHandler
Definition: x11_platform.h:222
XWMHints *(* PFN_XAllocWMHints)(void)
Definition: x11_platform.h:56
#define XDestroyWindow
Definition: x11_platform.h:176
int(* PFN_XGetWindowProperty)(Display *, Window, Atom, long, long, Bool, Atom, Atom *, int *, unsigned long *, unsigned long *, unsigned char **)
Definition: x11_platform.h:95
Cursor(* PFN_XCreateFontCursor)(Display *, unsigned int)
Definition: x11_platform.h:65
#define XShapeQueryExtension
Definition: x11_platform.h:346
int(* PFN_XDeleteProperty)(Display *, Window, Atom)
Definition: x11_platform.h:71
Bool(* PFN_XQueryPointer)(Display *, Window, Window *, Window *, int *, int *, int *, int *, unsigned int *)
Definition: x11_platform.h:111
void(* PFN_XDestroyIC)(XIC)
Definition: x11_platform.h:72
Status(* PFN_XShapeQueryVersion)(Display *dpy, int *, int *)
Definition: x11_platform.h:342
#define XcursorImageDestroy
Definition: x11_platform.h:301
int(* PFN_XChangeProperty)(Display *, Window, Atom, Atom, int, int, const unsigned char *, int)
Definition: x11_platform.h:57
char *(* PFN_XSetIMValues)(XIM,...)
Definition: x11_platform.h:122
int(* PFN_XFlush)(Display *)
Definition: x11_platform.h:79
void(* PFN_XShapeCombineMask)(Display *, Window, int, int, int, Pixmap, int)
Definition: x11_platform.h:344
Bool(* PFN_XF86VidModeGetGammaRampSize)(Display *, int, int *)
Definition: x11_platform.h:323
Status(* PFN_XCloseIM)(XIM)
Definition: x11_platform.h:62
#define XcursorImageLoadCursor
Definition: x11_platform.h:302
XVisualInfo *(* PFN_XGetVisualInfo)(Display *, long, XVisualInfo *, int *)
Definition: x11_platform.h:92
int(* PFN_XLookupString)(XKeyEvent *, char *, int, KeySym *, XComposeStatus *)
Definition: x11_platform.h:100
void(* PFN_XrmInitialize)(void)
Definition: x11_platform.h:151
Bool(* PFN_XineramaIsActive)(Display *)
Definition: x11_platform.h:307
#define XRenderQueryVersion
Definition: x11_platform.h:338
XrmQuark(* PFN_XrmUniqueQuark)(void)
Definition: x11_platform.h:152
VisualID(* PFN_XVisualIDFromVisual)(Visual *)
Definition: x11_platform.h:137
#define XQueryExtension
Definition: x11_platform.h:212
XRRCrtcGamma *(* PFN_XRRGetCrtcGamma)(Display *, RRCrtc)
Definition: x11_platform.h:264
Bool(* PFN_XkbSelectEventDetails)(Display *, unsigned int, unsigned int, unsigned long, unsigned long)
Definition: x11_platform.h:146
Status(* PFN_XInitThreads)(void)
Definition: x11_platform.h:98
void(* PFN_XRRSelectInput)(Display *, Window, int)
Definition: x11_platform.h:272
int(* PFN_XDestroyRegion)(Region)
Definition: x11_platform.h:73
#define XRRQueryVersion
Definition: x11_platform.h:288
#define XGetSelectionOwner
Definition: x11_platform.h:193
int(* PFN_XSetInputFocus)(Display *, Window, int, Time)
Definition: x11_platform.h:123
#define XrmDestroyDatabase
Definition: x11_platform.h:250
Bool(* PFN_XTranslateCoordinates)(Display *, Window, Window, int, int, int *, int *, Window *)
Definition: x11_platform.h:132
XcursorImage *(* PFN_XcursorImageCreate)(int, int)
Definition: x11_platform.h:294
#define XkbGetState
Definition: x11_platform.h:245
#define XOpenDisplay
Definition: x11_platform.h:208
Bool(* PFN_XF86VidModeGetGammaRamp)(Display *, int, int, unsigned short *, unsigned short *, unsigned short *)
Definition: x11_platform.h:321
Status(* PFN_XkbGetState)(Display *, unsigned int, XkbStatePtr)
Definition: x11_platform.h:143
Bool(* PFN_XineramaQueryExtension)(Display *, int *, int *)
Definition: x11_platform.h:308
KeySym *(* PFN_XGetKeyboardMapping)(Display *, KeyCode, int, int *)
Definition: x11_platform.h:89
int(* PFN_XMapWindow)(Display *, Window)
Definition: x11_platform.h:102
#define XShapeQueryVersion
Definition: x11_platform.h:347
#define XFree
Definition: x11_platform.h:182
#define XkbFreeNames
Definition: x11_platform.h:242
Bool(* PFN_XShapeQueryExtension)(Display *, int *, int *)
Definition: x11_platform.h:341
#define XF86VidModeQueryExtension
Definition: x11_platform.h:324
Bool(* PFN_XkbQueryExtension)(Display *, int *, int *, int *, int *, int *)
Definition: x11_platform.h:145
int(* PFN_XPending)(Display *)
Definition: x11_platform.h:109
#define XOpenIM
Definition: x11_platform.h:209
#define XkbGetMap
Definition: x11_platform.h:243
int(* PFN_XSetClassHint)(Display *, Window, XClassHint *)
Definition: x11_platform.h:119
#define XSync
Definition: x11_platform.h:233
XIC(* PFN_XCreateIC)(XIM,...)
Definition: x11_platform.h:66
char *(* PFN_XGetIMValues)(XIM,...)
Definition: x11_platform.h:87
#define XkbSelectEventDetails
Definition: x11_platform.h:248
Status(* PFN_XRRQueryVersion)(Display *, int *, int *)
Definition: x11_platform.h:271
KeySym(* PFN_XkbKeycodeToKeysym)(Display *, KeyCode, int, int)
Definition: x11_platform.h:144
#define XRRSelectInput
Definition: x11_platform.h:289
char *(* PFN_XGetICValues)(XIC,...)
Definition: x11_platform.h:86
void _glfwCreateInputContextX11(_GLFWwindow *window)
Definition: x11_window.c:1936
void(* PFN_XFreeEventData)(Display *, XGenericEventCookie *)
Definition: x11_platform.h:83
#define XInitThreads
Definition: x11_platform.h:200
Display *(* PFN_XOpenDisplay)(const char *)
Definition: x11_platform.h:106
void(* PFN_XrmDestroyDatabase)(XrmDatabase)
Definition: x11_platform.h:148
#define XrmGetResource
Definition: x11_platform.h:251
Bool(* PFN_XCheckIfEvent)(Display *, XEvent *, Bool(*)(Display *, XEvent *, XPointer), XPointer)
Definition: x11_platform.h:59
void(* PFN_Xutf8SetWMProperties)(Display *, Window, const char *, const char *, char **, int, XSizeHints *, XWMHints *, XClassHint *)
Definition: x11_platform.h:155
#define XIQueryVersion
Definition: x11_platform.h:331
Colormap(* PFN_XCreateColormap)(Display *, Window, Visual *, int)
Definition: x11_platform.h:64
XIM(* PFN_XOpenIM)(Display *, XrmDatabase *, char *, char *)
Definition: x11_platform.h:107
Status(* PFN_XSendEvent)(Display *, Window, Bool, long, XEvent *)
Definition: x11_platform.h:118
int(* PFN_XEventsQueued)(Display *, int)
Definition: x11_platform.h:76
int(* PFN_XPeekEvent)(Display *, XEvent *)
Definition: x11_platform.h:108
Status(* PFN_XIconifyWindow)(Display *, Window, int)
Definition: x11_platform.h:97
int(* PFN_XISelectEvents)(Display *, Window, XIEventMask *, int)
Definition: x11_platform.h:330
Bool(* PFN_XkbSetDetectableAutoRepeat)(Display *, Bool, Bool *)
Definition: x11_platform.h:147
XineramaScreenInfo *(* PFN_XineramaQueryScreens)(Display *, int *)
Definition: x11_platform.h:309
void _glfwPushSelectionToManagerX11(void)
Definition: x11_window.c:1890
XRROutputInfo *(* PFN_XRRGetOutputInfo)(Display *, XRRScreenResources *, RROutput)
Definition: x11_platform.h:267
#define XRegisterIMInstantiateCallback
Definition: x11_platform.h:215
int(* PFN_XSaveContext)(Display *, XID, XContext, const char *)
Definition: x11_platform.h:116
XErrorHandler(* PFN_XSetErrorHandler)(XErrorHandler)
Definition: x11_platform.h:120
void(* PFN_XkbFreeKeyboard)(XkbDescPtr, unsigned int, Bool)
Definition: x11_platform.h:139
char *(* PFN_XcursorGetTheme)(Display *)
Definition: x11_platform.h:297
Bool(* PFN_XF86VidModeQueryExtension)(Display *, int *, int *)
Definition: x11_platform.h:320
int(* PFN_XMapRaised)(Display *, Window)
Definition: x11_platform.h:101
#define XCreateWindow
Definition: x11_platform.h:170
int(* PFN_XSetScreenSaver)(Display *, int, int, int, int)
Definition: x11_platform.h:125
#define XcursorImageCreate
Definition: x11_platform.h:300
Status(* PFN_XGetWindowAttributes)(Display *, Window, XWindowAttributes *)
Definition: x11_platform.h:94
Atom(* PFN_XInternAtom)(Display *, const char *, Bool)
Definition: x11_platform.h:99
Status(* PFN_XRenderQueryVersion)(Display *dpy, int *, int *)
Definition: x11_platform.h:335
int(* PFN_XSelectInput)(Display *, Window, long)
Definition: x11_platform.h:117
void(* PFN_XcursorImageDestroy)(XcursorImage *)
Definition: x11_platform.h:295