2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
2019-04-16 12:43:29 +00:00
|
|
|
// GLFW 3.4 X11 - www.glfw.org
|
2010-09-07 15:34:51 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
2019-04-15 18:50:00 +00:00
|
|
|
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
2010-09-07 15:34:51 +00:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
// be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
//========================================================================
|
2019-05-20 13:24:14 +00:00
|
|
|
// It is fine to use C99 in this file because it will not be built with VS
|
|
|
|
//========================================================================
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
2010-10-13 02:04:43 +00:00
|
|
|
#include <stdlib.h>
|
2011-09-22 12:10:03 +00:00
|
|
|
#include <string.h>
|
2012-04-05 15:29:08 +00:00
|
|
|
#include <limits.h>
|
2013-07-10 09:42:14 +00:00
|
|
|
#include <stdio.h>
|
2014-12-18 01:52:06 +00:00
|
|
|
#include <locale.h>
|
2019-12-15 16:24:26 +00:00
|
|
|
#include <unistd.h>
|
2010-09-08 15:01:39 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2020-04-23 19:27:28 +00:00
|
|
|
// Translate the X11 KeySyms for a key to a GLFW key code
|
|
|
|
// NOTE: This is only used as a fallback, in case the XKB method fails
|
|
|
|
// It is layout-dependent and will fail partially on most non-US layouts
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2020-04-23 19:27:28 +00:00
|
|
|
static int translateKeySyms(const KeySym* keysyms, int width)
|
2011-01-04 22:07:34 +00:00
|
|
|
{
|
2020-04-23 19:27:28 +00:00
|
|
|
if (width > 1)
|
2014-04-24 05:10:58 +00:00
|
|
|
{
|
2020-04-23 19:27:28 +00:00
|
|
|
switch (keysyms[1])
|
|
|
|
{
|
|
|
|
case XK_KP_0: return GLFW_KEY_KP_0;
|
|
|
|
case XK_KP_1: return GLFW_KEY_KP_1;
|
|
|
|
case XK_KP_2: return GLFW_KEY_KP_2;
|
|
|
|
case XK_KP_3: return GLFW_KEY_KP_3;
|
|
|
|
case XK_KP_4: return GLFW_KEY_KP_4;
|
|
|
|
case XK_KP_5: return GLFW_KEY_KP_5;
|
|
|
|
case XK_KP_6: return GLFW_KEY_KP_6;
|
|
|
|
case XK_KP_7: return GLFW_KEY_KP_7;
|
|
|
|
case XK_KP_8: return GLFW_KEY_KP_8;
|
|
|
|
case XK_KP_9: return GLFW_KEY_KP_9;
|
|
|
|
case XK_KP_Separator:
|
|
|
|
case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL;
|
|
|
|
case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
|
|
|
|
case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
|
|
|
|
default: break;
|
|
|
|
}
|
2011-01-04 22:07:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-23 19:27:28 +00:00
|
|
|
switch (keysyms[0])
|
2011-01-04 22:07:34 +00:00
|
|
|
{
|
|
|
|
case XK_Escape: return GLFW_KEY_ESCAPE;
|
|
|
|
case XK_Tab: return GLFW_KEY_TAB;
|
|
|
|
case XK_Shift_L: return GLFW_KEY_LEFT_SHIFT;
|
|
|
|
case XK_Shift_R: return GLFW_KEY_RIGHT_SHIFT;
|
|
|
|
case XK_Control_L: return GLFW_KEY_LEFT_CONTROL;
|
|
|
|
case XK_Control_R: return GLFW_KEY_RIGHT_CONTROL;
|
|
|
|
case XK_Meta_L:
|
|
|
|
case XK_Alt_L: return GLFW_KEY_LEFT_ALT;
|
|
|
|
case XK_Mode_switch: // Mapped to Alt_R on many keyboards
|
|
|
|
case XK_ISO_Level3_Shift: // AltGr on at least some machines
|
|
|
|
case XK_Meta_R:
|
|
|
|
case XK_Alt_R: return GLFW_KEY_RIGHT_ALT;
|
|
|
|
case XK_Super_L: return GLFW_KEY_LEFT_SUPER;
|
|
|
|
case XK_Super_R: return GLFW_KEY_RIGHT_SUPER;
|
|
|
|
case XK_Menu: return GLFW_KEY_MENU;
|
|
|
|
case XK_Num_Lock: return GLFW_KEY_NUM_LOCK;
|
|
|
|
case XK_Caps_Lock: return GLFW_KEY_CAPS_LOCK;
|
2013-02-21 17:39:22 +00:00
|
|
|
case XK_Print: return GLFW_KEY_PRINT_SCREEN;
|
2011-01-04 22:07:34 +00:00
|
|
|
case XK_Scroll_Lock: return GLFW_KEY_SCROLL_LOCK;
|
|
|
|
case XK_Pause: return GLFW_KEY_PAUSE;
|
|
|
|
case XK_Delete: return GLFW_KEY_DELETE;
|
|
|
|
case XK_BackSpace: return GLFW_KEY_BACKSPACE;
|
|
|
|
case XK_Return: return GLFW_KEY_ENTER;
|
|
|
|
case XK_Home: return GLFW_KEY_HOME;
|
|
|
|
case XK_End: return GLFW_KEY_END;
|
|
|
|
case XK_Page_Up: return GLFW_KEY_PAGE_UP;
|
|
|
|
case XK_Page_Down: return GLFW_KEY_PAGE_DOWN;
|
|
|
|
case XK_Insert: return GLFW_KEY_INSERT;
|
|
|
|
case XK_Left: return GLFW_KEY_LEFT;
|
|
|
|
case XK_Right: return GLFW_KEY_RIGHT;
|
|
|
|
case XK_Down: return GLFW_KEY_DOWN;
|
|
|
|
case XK_Up: return GLFW_KEY_UP;
|
|
|
|
case XK_F1: return GLFW_KEY_F1;
|
|
|
|
case XK_F2: return GLFW_KEY_F2;
|
|
|
|
case XK_F3: return GLFW_KEY_F3;
|
|
|
|
case XK_F4: return GLFW_KEY_F4;
|
|
|
|
case XK_F5: return GLFW_KEY_F5;
|
|
|
|
case XK_F6: return GLFW_KEY_F6;
|
|
|
|
case XK_F7: return GLFW_KEY_F7;
|
|
|
|
case XK_F8: return GLFW_KEY_F8;
|
|
|
|
case XK_F9: return GLFW_KEY_F9;
|
|
|
|
case XK_F10: return GLFW_KEY_F10;
|
|
|
|
case XK_F11: return GLFW_KEY_F11;
|
|
|
|
case XK_F12: return GLFW_KEY_F12;
|
|
|
|
case XK_F13: return GLFW_KEY_F13;
|
|
|
|
case XK_F14: return GLFW_KEY_F14;
|
|
|
|
case XK_F15: return GLFW_KEY_F15;
|
|
|
|
case XK_F16: return GLFW_KEY_F16;
|
|
|
|
case XK_F17: return GLFW_KEY_F17;
|
|
|
|
case XK_F18: return GLFW_KEY_F18;
|
|
|
|
case XK_F19: return GLFW_KEY_F19;
|
|
|
|
case XK_F20: return GLFW_KEY_F20;
|
|
|
|
case XK_F21: return GLFW_KEY_F21;
|
|
|
|
case XK_F22: return GLFW_KEY_F22;
|
|
|
|
case XK_F23: return GLFW_KEY_F23;
|
|
|
|
case XK_F24: return GLFW_KEY_F24;
|
|
|
|
case XK_F25: return GLFW_KEY_F25;
|
|
|
|
|
|
|
|
// Numeric keypad
|
|
|
|
case XK_KP_Divide: return GLFW_KEY_KP_DIVIDE;
|
|
|
|
case XK_KP_Multiply: return GLFW_KEY_KP_MULTIPLY;
|
|
|
|
case XK_KP_Subtract: return GLFW_KEY_KP_SUBTRACT;
|
|
|
|
case XK_KP_Add: return GLFW_KEY_KP_ADD;
|
|
|
|
|
|
|
|
// These should have been detected in secondary keysym test above!
|
|
|
|
case XK_KP_Insert: return GLFW_KEY_KP_0;
|
|
|
|
case XK_KP_End: return GLFW_KEY_KP_1;
|
|
|
|
case XK_KP_Down: return GLFW_KEY_KP_2;
|
|
|
|
case XK_KP_Page_Down: return GLFW_KEY_KP_3;
|
|
|
|
case XK_KP_Left: return GLFW_KEY_KP_4;
|
|
|
|
case XK_KP_Right: return GLFW_KEY_KP_6;
|
|
|
|
case XK_KP_Home: return GLFW_KEY_KP_7;
|
|
|
|
case XK_KP_Up: return GLFW_KEY_KP_8;
|
|
|
|
case XK_KP_Page_Up: return GLFW_KEY_KP_9;
|
|
|
|
case XK_KP_Delete: return GLFW_KEY_KP_DECIMAL;
|
|
|
|
case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
|
|
|
|
case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
|
|
|
|
|
|
|
|
// Last resort: Check for printable keys (should not happen if the XKB
|
|
|
|
// extension is available). This will give a layout dependent mapping
|
|
|
|
// (which is wrong, and we may miss some keys, especially on non-US
|
|
|
|
// keyboards), but it's better than nothing...
|
|
|
|
case XK_a: return GLFW_KEY_A;
|
|
|
|
case XK_b: return GLFW_KEY_B;
|
|
|
|
case XK_c: return GLFW_KEY_C;
|
|
|
|
case XK_d: return GLFW_KEY_D;
|
|
|
|
case XK_e: return GLFW_KEY_E;
|
|
|
|
case XK_f: return GLFW_KEY_F;
|
|
|
|
case XK_g: return GLFW_KEY_G;
|
|
|
|
case XK_h: return GLFW_KEY_H;
|
|
|
|
case XK_i: return GLFW_KEY_I;
|
|
|
|
case XK_j: return GLFW_KEY_J;
|
|
|
|
case XK_k: return GLFW_KEY_K;
|
|
|
|
case XK_l: return GLFW_KEY_L;
|
|
|
|
case XK_m: return GLFW_KEY_M;
|
|
|
|
case XK_n: return GLFW_KEY_N;
|
|
|
|
case XK_o: return GLFW_KEY_O;
|
|
|
|
case XK_p: return GLFW_KEY_P;
|
|
|
|
case XK_q: return GLFW_KEY_Q;
|
|
|
|
case XK_r: return GLFW_KEY_R;
|
|
|
|
case XK_s: return GLFW_KEY_S;
|
|
|
|
case XK_t: return GLFW_KEY_T;
|
|
|
|
case XK_u: return GLFW_KEY_U;
|
|
|
|
case XK_v: return GLFW_KEY_V;
|
|
|
|
case XK_w: return GLFW_KEY_W;
|
|
|
|
case XK_x: return GLFW_KEY_X;
|
|
|
|
case XK_y: return GLFW_KEY_Y;
|
|
|
|
case XK_z: return GLFW_KEY_Z;
|
|
|
|
case XK_1: return GLFW_KEY_1;
|
|
|
|
case XK_2: return GLFW_KEY_2;
|
|
|
|
case XK_3: return GLFW_KEY_3;
|
|
|
|
case XK_4: return GLFW_KEY_4;
|
|
|
|
case XK_5: return GLFW_KEY_5;
|
|
|
|
case XK_6: return GLFW_KEY_6;
|
|
|
|
case XK_7: return GLFW_KEY_7;
|
|
|
|
case XK_8: return GLFW_KEY_8;
|
|
|
|
case XK_9: return GLFW_KEY_9;
|
|
|
|
case XK_0: return GLFW_KEY_0;
|
|
|
|
case XK_space: return GLFW_KEY_SPACE;
|
|
|
|
case XK_minus: return GLFW_KEY_MINUS;
|
|
|
|
case XK_equal: return GLFW_KEY_EQUAL;
|
|
|
|
case XK_bracketleft: return GLFW_KEY_LEFT_BRACKET;
|
|
|
|
case XK_bracketright: return GLFW_KEY_RIGHT_BRACKET;
|
|
|
|
case XK_backslash: return GLFW_KEY_BACKSLASH;
|
|
|
|
case XK_semicolon: return GLFW_KEY_SEMICOLON;
|
|
|
|
case XK_apostrophe: return GLFW_KEY_APOSTROPHE;
|
|
|
|
case XK_grave: return GLFW_KEY_GRAVE_ACCENT;
|
|
|
|
case XK_comma: return GLFW_KEY_COMMA;
|
|
|
|
case XK_period: return GLFW_KEY_PERIOD;
|
|
|
|
case XK_slash: return GLFW_KEY_SLASH;
|
|
|
|
case XK_less: return GLFW_KEY_WORLD_1; // At least in some layouts...
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2013-05-30 15:19:12 +00:00
|
|
|
// No matching translation was found
|
|
|
|
return GLFW_KEY_UNKNOWN;
|
2011-01-04 22:07:34 +00:00
|
|
|
}
|
|
|
|
|
2014-03-30 14:23:22 +00:00
|
|
|
// Create key code translation tables
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2014-03-30 14:23:22 +00:00
|
|
|
static void createKeyTables(void)
|
2011-01-02 10:18:14 +00:00
|
|
|
{
|
2021-02-16 19:12:19 +00:00
|
|
|
int scancodeMin, scancodeMax;
|
2011-01-02 10:18:14 +00:00
|
|
|
|
2016-09-07 13:43:39 +00:00
|
|
|
memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
|
|
|
|
memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
|
2011-01-02 10:18:14 +00:00
|
|
|
|
2014-05-18 10:24:29 +00:00
|
|
|
if (_glfw.x11.xkb.available)
|
2014-04-24 05:10:58 +00:00
|
|
|
{
|
2017-09-17 12:39:17 +00:00
|
|
|
// Use XKB to determine physical key locations independently of the
|
|
|
|
// current keyboard layout
|
2011-01-02 10:18:14 +00:00
|
|
|
|
2015-08-14 15:54:24 +00:00
|
|
|
XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
|
2020-03-25 17:16:15 +00:00
|
|
|
XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc);
|
2011-01-04 22:07:34 +00:00
|
|
|
|
2020-03-16 23:04:48 +00:00
|
|
|
scancodeMin = desc->min_key_code;
|
|
|
|
scancodeMax = desc->max_key_code;
|
|
|
|
|
2020-03-25 17:16:15 +00:00
|
|
|
const struct
|
|
|
|
{
|
|
|
|
int key;
|
|
|
|
char* name;
|
|
|
|
} keymap[] =
|
|
|
|
{
|
|
|
|
{ GLFW_KEY_GRAVE_ACCENT, "TLDE" },
|
|
|
|
{ GLFW_KEY_1, "AE01" },
|
|
|
|
{ GLFW_KEY_2, "AE02" },
|
|
|
|
{ GLFW_KEY_3, "AE03" },
|
|
|
|
{ GLFW_KEY_4, "AE04" },
|
|
|
|
{ GLFW_KEY_5, "AE05" },
|
|
|
|
{ GLFW_KEY_6, "AE06" },
|
|
|
|
{ GLFW_KEY_7, "AE07" },
|
|
|
|
{ GLFW_KEY_8, "AE08" },
|
|
|
|
{ GLFW_KEY_9, "AE09" },
|
|
|
|
{ GLFW_KEY_0, "AE10" },
|
|
|
|
{ GLFW_KEY_MINUS, "AE11" },
|
|
|
|
{ GLFW_KEY_EQUAL, "AE12" },
|
|
|
|
{ GLFW_KEY_Q, "AD01" },
|
|
|
|
{ GLFW_KEY_W, "AD02" },
|
|
|
|
{ GLFW_KEY_E, "AD03" },
|
|
|
|
{ GLFW_KEY_R, "AD04" },
|
|
|
|
{ GLFW_KEY_T, "AD05" },
|
|
|
|
{ GLFW_KEY_Y, "AD06" },
|
|
|
|
{ GLFW_KEY_U, "AD07" },
|
|
|
|
{ GLFW_KEY_I, "AD08" },
|
|
|
|
{ GLFW_KEY_O, "AD09" },
|
|
|
|
{ GLFW_KEY_P, "AD10" },
|
|
|
|
{ GLFW_KEY_LEFT_BRACKET, "AD11" },
|
|
|
|
{ GLFW_KEY_RIGHT_BRACKET, "AD12" },
|
|
|
|
{ GLFW_KEY_A, "AC01" },
|
|
|
|
{ GLFW_KEY_S, "AC02" },
|
|
|
|
{ GLFW_KEY_D, "AC03" },
|
|
|
|
{ GLFW_KEY_F, "AC04" },
|
|
|
|
{ GLFW_KEY_G, "AC05" },
|
|
|
|
{ GLFW_KEY_H, "AC06" },
|
|
|
|
{ GLFW_KEY_J, "AC07" },
|
|
|
|
{ GLFW_KEY_K, "AC08" },
|
|
|
|
{ GLFW_KEY_L, "AC09" },
|
|
|
|
{ GLFW_KEY_SEMICOLON, "AC10" },
|
|
|
|
{ GLFW_KEY_APOSTROPHE, "AC11" },
|
|
|
|
{ GLFW_KEY_Z, "AB01" },
|
|
|
|
{ GLFW_KEY_X, "AB02" },
|
|
|
|
{ GLFW_KEY_C, "AB03" },
|
|
|
|
{ GLFW_KEY_V, "AB04" },
|
|
|
|
{ GLFW_KEY_B, "AB05" },
|
|
|
|
{ GLFW_KEY_N, "AB06" },
|
|
|
|
{ GLFW_KEY_M, "AB07" },
|
|
|
|
{ GLFW_KEY_COMMA, "AB08" },
|
|
|
|
{ GLFW_KEY_PERIOD, "AB09" },
|
|
|
|
{ GLFW_KEY_SLASH, "AB10" },
|
|
|
|
{ GLFW_KEY_BACKSLASH, "BKSL" },
|
|
|
|
{ GLFW_KEY_WORLD_1, "LSGT" },
|
|
|
|
{ GLFW_KEY_SPACE, "SPCE" },
|
|
|
|
{ GLFW_KEY_ESCAPE, "ESC" },
|
|
|
|
{ GLFW_KEY_ENTER, "RTRN" },
|
|
|
|
{ GLFW_KEY_TAB, "TAB" },
|
|
|
|
{ GLFW_KEY_BACKSPACE, "BKSP" },
|
|
|
|
{ GLFW_KEY_INSERT, "INS" },
|
|
|
|
{ GLFW_KEY_DELETE, "DELE" },
|
|
|
|
{ GLFW_KEY_RIGHT, "RGHT" },
|
|
|
|
{ GLFW_KEY_LEFT, "LEFT" },
|
|
|
|
{ GLFW_KEY_DOWN, "DOWN" },
|
|
|
|
{ GLFW_KEY_UP, "UP" },
|
|
|
|
{ GLFW_KEY_PAGE_UP, "PGUP" },
|
|
|
|
{ GLFW_KEY_PAGE_DOWN, "PGDN" },
|
|
|
|
{ GLFW_KEY_HOME, "HOME" },
|
|
|
|
{ GLFW_KEY_END, "END" },
|
|
|
|
{ GLFW_KEY_CAPS_LOCK, "CAPS" },
|
|
|
|
{ GLFW_KEY_SCROLL_LOCK, "SCLK" },
|
|
|
|
{ GLFW_KEY_NUM_LOCK, "NMLK" },
|
|
|
|
{ GLFW_KEY_PRINT_SCREEN, "PRSC" },
|
|
|
|
{ GLFW_KEY_PAUSE, "PAUS" },
|
|
|
|
{ GLFW_KEY_F1, "FK01" },
|
|
|
|
{ GLFW_KEY_F2, "FK02" },
|
|
|
|
{ GLFW_KEY_F3, "FK03" },
|
|
|
|
{ GLFW_KEY_F4, "FK04" },
|
|
|
|
{ GLFW_KEY_F5, "FK05" },
|
|
|
|
{ GLFW_KEY_F6, "FK06" },
|
|
|
|
{ GLFW_KEY_F7, "FK07" },
|
|
|
|
{ GLFW_KEY_F8, "FK08" },
|
|
|
|
{ GLFW_KEY_F9, "FK09" },
|
|
|
|
{ GLFW_KEY_F10, "FK10" },
|
|
|
|
{ GLFW_KEY_F11, "FK11" },
|
|
|
|
{ GLFW_KEY_F12, "FK12" },
|
|
|
|
{ GLFW_KEY_F13, "FK13" },
|
|
|
|
{ GLFW_KEY_F14, "FK14" },
|
|
|
|
{ GLFW_KEY_F15, "FK15" },
|
|
|
|
{ GLFW_KEY_F16, "FK16" },
|
|
|
|
{ GLFW_KEY_F17, "FK17" },
|
|
|
|
{ GLFW_KEY_F18, "FK18" },
|
|
|
|
{ GLFW_KEY_F19, "FK19" },
|
|
|
|
{ GLFW_KEY_F20, "FK20" },
|
|
|
|
{ GLFW_KEY_F21, "FK21" },
|
|
|
|
{ GLFW_KEY_F22, "FK22" },
|
|
|
|
{ GLFW_KEY_F23, "FK23" },
|
|
|
|
{ GLFW_KEY_F24, "FK24" },
|
|
|
|
{ GLFW_KEY_F25, "FK25" },
|
|
|
|
{ GLFW_KEY_KP_0, "KP0" },
|
|
|
|
{ GLFW_KEY_KP_1, "KP1" },
|
|
|
|
{ GLFW_KEY_KP_2, "KP2" },
|
|
|
|
{ GLFW_KEY_KP_3, "KP3" },
|
|
|
|
{ GLFW_KEY_KP_4, "KP4" },
|
|
|
|
{ GLFW_KEY_KP_5, "KP5" },
|
|
|
|
{ GLFW_KEY_KP_6, "KP6" },
|
|
|
|
{ GLFW_KEY_KP_7, "KP7" },
|
|
|
|
{ GLFW_KEY_KP_8, "KP8" },
|
|
|
|
{ GLFW_KEY_KP_9, "KP9" },
|
|
|
|
{ GLFW_KEY_KP_DECIMAL, "KPDL" },
|
|
|
|
{ GLFW_KEY_KP_DIVIDE, "KPDV" },
|
|
|
|
{ GLFW_KEY_KP_MULTIPLY, "KPMU" },
|
|
|
|
{ GLFW_KEY_KP_SUBTRACT, "KPSU" },
|
|
|
|
{ GLFW_KEY_KP_ADD, "KPAD" },
|
|
|
|
{ GLFW_KEY_KP_ENTER, "KPEN" },
|
|
|
|
{ GLFW_KEY_KP_EQUAL, "KPEQ" },
|
|
|
|
{ GLFW_KEY_LEFT_SHIFT, "LFSH" },
|
|
|
|
{ GLFW_KEY_LEFT_CONTROL, "LCTL" },
|
|
|
|
{ GLFW_KEY_LEFT_ALT, "LALT" },
|
|
|
|
{ GLFW_KEY_LEFT_SUPER, "LWIN" },
|
|
|
|
{ GLFW_KEY_RIGHT_SHIFT, "RTSH" },
|
|
|
|
{ GLFW_KEY_RIGHT_CONTROL, "RCTL" },
|
|
|
|
{ GLFW_KEY_RIGHT_ALT, "RALT" },
|
2020-04-23 15:42:36 +00:00
|
|
|
{ GLFW_KEY_RIGHT_ALT, "LVL3" },
|
|
|
|
{ GLFW_KEY_RIGHT_ALT, "MDSW" },
|
2020-03-25 17:16:15 +00:00
|
|
|
{ GLFW_KEY_RIGHT_SUPER, "RWIN" },
|
2020-03-31 15:00:43 +00:00
|
|
|
{ GLFW_KEY_MENU, "MENU" }
|
2020-03-25 17:16:15 +00:00
|
|
|
};
|
|
|
|
|
2014-04-24 05:10:58 +00:00
|
|
|
// Find the X11 key code -> GLFW key code mapping
|
2021-02-16 19:12:19 +00:00
|
|
|
for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
2014-04-24 05:10:58 +00:00
|
|
|
{
|
2020-03-25 17:16:15 +00:00
|
|
|
int key = GLFW_KEY_UNKNOWN;
|
2014-04-24 05:10:58 +00:00
|
|
|
|
2019-11-21 14:49:44 +00:00
|
|
|
// Map the key name to a GLFW key code. Note: We use the US
|
|
|
|
// keyboard layout. Because function keys aren't mapped correctly
|
|
|
|
// when using traditional KeySym translations, they are mapped
|
|
|
|
// here instead.
|
2020-03-25 17:16:15 +00:00
|
|
|
for (int i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++)
|
|
|
|
{
|
|
|
|
if (strncmp(desc->names->keys[scancode].name,
|
|
|
|
keymap[i].name,
|
|
|
|
XkbKeyNameLength) == 0)
|
|
|
|
{
|
|
|
|
key = keymap[i].key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fall back to key aliases in case the key name did not match
|
|
|
|
for (int i = 0; i < desc->names->num_key_aliases; i++)
|
|
|
|
{
|
|
|
|
if (key != GLFW_KEY_UNKNOWN)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strncmp(desc->names->key_aliases[i].real,
|
|
|
|
desc->names->keys[scancode].name,
|
|
|
|
XkbKeyNameLength) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++)
|
|
|
|
{
|
|
|
|
if (strncmp(desc->names->key_aliases[i].alias,
|
|
|
|
keymap[j].name,
|
|
|
|
XkbKeyNameLength) == 0)
|
|
|
|
{
|
|
|
|
key = keymap[j].key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-30 14:23:22 +00:00
|
|
|
|
2020-03-16 23:04:48 +00:00
|
|
|
_glfw.x11.keycodes[scancode] = key;
|
2014-04-24 05:10:58 +00:00
|
|
|
}
|
2013-01-07 17:08:07 +00:00
|
|
|
|
2015-08-14 15:54:24 +00:00
|
|
|
XkbFreeNames(desc, XkbKeyNamesMask, True);
|
2015-12-17 11:38:53 +00:00
|
|
|
XkbFreeKeyboard(desc, 0, True);
|
2014-04-24 05:10:58 +00:00
|
|
|
}
|
2020-03-16 23:04:48 +00:00
|
|
|
else
|
|
|
|
XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax);
|
2011-01-04 22:07:34 +00:00
|
|
|
|
2020-04-23 19:27:28 +00:00
|
|
|
int width;
|
|
|
|
KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display,
|
|
|
|
scancodeMin,
|
|
|
|
scancodeMax - scancodeMin + 1,
|
|
|
|
&width);
|
|
|
|
|
2021-02-16 19:12:19 +00:00
|
|
|
for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++)
|
2011-01-04 22:07:34 +00:00
|
|
|
{
|
2015-07-02 12:24:50 +00:00
|
|
|
// Translate the un-translated key codes using traditional X11 KeySym
|
|
|
|
// lookups
|
2016-09-07 13:43:39 +00:00
|
|
|
if (_glfw.x11.keycodes[scancode] < 0)
|
2020-04-23 19:27:28 +00:00
|
|
|
{
|
|
|
|
const size_t base = (scancode - scancodeMin) * width;
|
|
|
|
_glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width);
|
|
|
|
}
|
2015-07-02 12:24:50 +00:00
|
|
|
|
|
|
|
// Store the reverse translation for faster key name lookup
|
2016-09-07 13:43:39 +00:00
|
|
|
if (_glfw.x11.keycodes[scancode] > 0)
|
|
|
|
_glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
|
2011-01-02 10:18:14 +00:00
|
|
|
}
|
2020-04-23 19:27:28 +00:00
|
|
|
|
|
|
|
XFree(keysyms);
|
2011-01-02 10:18:14 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 00:13:41 +00:00
|
|
|
// Check whether the IM has a usable style
|
|
|
|
//
|
2015-08-23 17:30:04 +00:00
|
|
|
static GLFWbool hasUsableInputMethodStyle(void)
|
2014-09-21 00:13:41 +00:00
|
|
|
{
|
2015-08-23 17:30:04 +00:00
|
|
|
GLFWbool found = GLFW_FALSE;
|
2014-09-21 00:13:41 +00:00
|
|
|
XIMStyles* styles = NULL;
|
|
|
|
|
|
|
|
if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
|
2015-08-23 17:30:04 +00:00
|
|
|
return GLFW_FALSE;
|
2014-09-21 00:13:41 +00:00
|
|
|
|
2019-06-04 14:51:31 +00:00
|
|
|
for (unsigned int i = 0; i < styles->count_styles; i++)
|
2014-09-21 00:13:41 +00:00
|
|
|
{
|
|
|
|
if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
|
|
|
|
{
|
2015-08-23 17:30:04 +00:00
|
|
|
found = GLFW_TRUE;
|
2014-09-21 00:13:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(styles);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2020-01-22 19:12:36 +00:00
|
|
|
static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData)
|
|
|
|
{
|
|
|
|
_glfw.x11.im = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void inputMethodInstantiateCallback(Display* display,
|
|
|
|
XPointer clientData,
|
|
|
|
XPointer callData)
|
|
|
|
{
|
|
|
|
if (_glfw.x11.im)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
|
|
|
|
if (_glfw.x11.im)
|
|
|
|
{
|
|
|
|
if (!hasUsableInputMethodStyle())
|
|
|
|
{
|
|
|
|
XCloseIM(_glfw.x11.im);
|
|
|
|
_glfw.x11.im = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.im)
|
|
|
|
{
|
|
|
|
XIMCallback callback;
|
|
|
|
callback.callback = (XIMProc) inputMethodDestroyCallback;
|
|
|
|
callback.client_data = NULL;
|
|
|
|
XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL);
|
|
|
|
|
|
|
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
|
|
|
_glfwCreateInputContextX11(window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 17:03:02 +00:00
|
|
|
// Return the atom ID only if it is listed in the specified array
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2020-05-19 17:03:02 +00:00
|
|
|
static Atom getAtomIfSupported(Atom* supportedAtoms,
|
|
|
|
unsigned long atomCount,
|
|
|
|
const char* atomName)
|
2012-04-05 15:29:08 +00:00
|
|
|
{
|
2016-05-01 20:54:02 +00:00
|
|
|
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
|
2012-04-05 15:29:08 +00:00
|
|
|
|
2020-05-25 13:03:23 +00:00
|
|
|
for (unsigned long i = 0; i < atomCount; i++)
|
2016-05-01 20:54:02 +00:00
|
|
|
{
|
|
|
|
if (supportedAtoms[i] == atom)
|
|
|
|
return atom;
|
2012-04-05 15:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the running window manager is EWMH-compliant
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2013-01-04 06:11:30 +00:00
|
|
|
static void detectEWMH(void)
|
2012-04-05 15:29:08 +00:00
|
|
|
{
|
2019-06-04 14:52:40 +00:00
|
|
|
// First we read the _NET_SUPPORTING_WM_CHECK property on the root window
|
2012-04-05 15:29:08 +00:00
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
Window* windowFromRoot = NULL;
|
2017-01-16 00:36:14 +00:00
|
|
|
if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
|
2019-06-04 14:52:40 +00:00
|
|
|
_glfw.x11.NET_SUPPORTING_WM_CHECK,
|
2017-01-16 00:36:14 +00:00
|
|
|
XA_WINDOW,
|
|
|
|
(unsigned char**) &windowFromRoot))
|
2012-04-05 15:29:08 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-03 17:16:46 +00:00
|
|
|
_glfwGrabErrorHandlerX11();
|
2014-02-11 14:46:54 +00:00
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
// If it exists, it should be the XID of a top-level window
|
|
|
|
// Then we look for the same property on that window
|
|
|
|
|
|
|
|
Window* windowFromChild = NULL;
|
2017-01-16 00:36:14 +00:00
|
|
|
if (!_glfwGetWindowPropertyX11(*windowFromRoot,
|
2019-06-04 14:52:40 +00:00
|
|
|
_glfw.x11.NET_SUPPORTING_WM_CHECK,
|
2017-01-16 00:36:14 +00:00
|
|
|
XA_WINDOW,
|
|
|
|
(unsigned char**) &windowFromChild))
|
2012-04-05 15:29:08 +00:00
|
|
|
{
|
|
|
|
XFree(windowFromRoot);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-03 17:16:46 +00:00
|
|
|
_glfwReleaseErrorHandlerX11();
|
2014-02-11 14:46:54 +00:00
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
// If the property exists, it should contain the XID of the window
|
|
|
|
|
2012-04-05 15:29:08 +00:00
|
|
|
if (*windowFromRoot != *windowFromChild)
|
|
|
|
{
|
|
|
|
XFree(windowFromRoot);
|
|
|
|
XFree(windowFromChild);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(windowFromRoot);
|
|
|
|
XFree(windowFromChild);
|
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
// We are now fairly sure that an EWMH-compliant WM is currently running
|
|
|
|
// We can now start querying the WM about what features it supports by
|
|
|
|
// looking in the _NET_SUPPORTED property on the root window
|
|
|
|
// It should contain a list of supported EWMH protocol and state atoms
|
2012-04-05 15:29:08 +00:00
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
Atom* supportedAtoms = NULL;
|
|
|
|
const unsigned long atomCount =
|
|
|
|
_glfwGetWindowPropertyX11(_glfw.x11.root,
|
|
|
|
_glfw.x11.NET_SUPPORTED,
|
|
|
|
XA_ATOM,
|
|
|
|
(unsigned char**) &supportedAtoms);
|
2012-04-05 15:29:08 +00:00
|
|
|
|
|
|
|
// See which of the atoms we support that are supported by the WM
|
2019-06-04 14:52:40 +00:00
|
|
|
|
2013-01-21 17:03:47 +00:00
|
|
|
_glfw.x11.NET_WM_STATE =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
|
2014-05-23 12:01:02 +00:00
|
|
|
_glfw.x11.NET_WM_STATE_ABOVE =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
|
2013-01-21 17:03:47 +00:00
|
|
|
_glfw.x11.NET_WM_STATE_FULLSCREEN =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
|
2015-10-13 10:50:59 +00:00
|
|
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
|
2015-10-13 10:50:59 +00:00
|
|
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
2017-03-21 13:02:57 +00:00
|
|
|
_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
|
2014-09-22 10:49:03 +00:00
|
|
|
_glfw.x11.NET_WM_FULLSCREEN_MONITORS =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
|
2016-03-14 19:47:48 +00:00
|
|
|
_glfw.x11.NET_WM_WINDOW_TYPE =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
|
2016-03-14 19:47:48 +00:00
|
|
|
_glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
|
2017-04-06 19:48:08 +00:00
|
|
|
_glfw.x11.NET_WORKAREA =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
|
2019-02-25 13:10:45 +00:00
|
|
|
_glfw.x11.NET_CURRENT_DESKTOP =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
|
2013-01-21 17:03:47 +00:00
|
|
|
_glfw.x11.NET_ACTIVE_WINDOW =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
|
2014-03-25 20:30:13 +00:00
|
|
|
_glfw.x11.NET_FRAME_EXTENTS =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
|
2014-03-30 10:24:18 +00:00
|
|
|
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
2020-05-19 17:03:02 +00:00
|
|
|
getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
2012-04-05 15:29:08 +00:00
|
|
|
|
2017-01-16 00:36:14 +00:00
|
|
|
if (supportedAtoms)
|
|
|
|
XFree(supportedAtoms);
|
2012-04-05 15:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-20 16:48:45 +00:00
|
|
|
// Look for and initialize supported X11 extensions
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2015-08-23 17:30:04 +00:00
|
|
|
static GLFWbool initExtensions(void)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2021-12-22 21:19:25 +00:00
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
_glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so");
|
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1");
|
2021-12-22 21:19:25 +00:00
|
|
|
#endif
|
2016-12-10 22:41:19 +00:00
|
|
|
if (_glfw.x11.vidmode.handle)
|
|
|
|
{
|
|
|
|
_glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
|
2016-12-10 22:41:19 +00:00
|
|
|
_glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
|
2016-12-10 22:41:19 +00:00
|
|
|
_glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
|
2016-12-10 22:41:19 +00:00
|
|
|
_glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
|
2016-12-10 22:41:19 +00:00
|
|
|
|
|
|
|
_glfw.x11.vidmode.available =
|
|
|
|
XF86VidModeQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.vidmode.eventBase,
|
|
|
|
&_glfw.x11.vidmode.errorBase);
|
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2017-01-12 19:31:59 +00:00
|
|
|
if (_glfw.x11.xi.handle)
|
|
|
|
{
|
|
|
|
_glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XIQueryVersion");
|
2017-01-12 19:31:59 +00:00
|
|
|
_glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XISelectEvents");
|
2017-01-12 19:31:59 +00:00
|
|
|
|
|
|
|
if (XQueryExtension(_glfw.x11.display,
|
|
|
|
"XInputExtension",
|
|
|
|
&_glfw.x11.xi.majorOpcode,
|
|
|
|
&_glfw.x11.xi.eventBase,
|
|
|
|
&_glfw.x11.xi.errorBase))
|
|
|
|
{
|
|
|
|
_glfw.x11.xi.major = 2;
|
|
|
|
_glfw.x11.xi.minor = 0;
|
|
|
|
|
|
|
|
if (XIQueryVersion(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xi.major,
|
|
|
|
&_glfw.x11.xi.minor) == Success)
|
|
|
|
{
|
|
|
|
_glfw.x11.xi.available = GLFW_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2017-08-16 17:46:09 +00:00
|
|
|
if (_glfw.x11.randr.handle)
|
2010-10-13 02:04:43 +00:00
|
|
|
{
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRAllocGamma");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeScreenResources");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputInfo");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryExtension");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryVersion");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSelectInput");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
|
2017-08-16 17:46:09 +00:00
|
|
|
_glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
|
2017-08-16 17:46:09 +00:00
|
|
|
|
|
|
|
if (XRRQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.randr.eventBase,
|
|
|
|
&_glfw.x11.randr.errorBase))
|
2015-06-14 19:05:42 +00:00
|
|
|
{
|
2017-08-16 17:46:09 +00:00
|
|
|
if (XRRQueryVersion(_glfw.x11.display,
|
|
|
|
&_glfw.x11.randr.major,
|
|
|
|
&_glfw.x11.randr.minor))
|
|
|
|
{
|
|
|
|
// The GLFW RandR path requires at least version 1.3
|
|
|
|
if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
|
|
|
|
_glfw.x11.randr.available = GLFW_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
"X11: Failed to query RandR version");
|
|
|
|
}
|
2010-11-23 16:45:23 +00:00
|
|
|
}
|
2015-06-14 19:05:42 +00:00
|
|
|
}
|
2013-01-12 17:10:18 +00:00
|
|
|
|
2015-06-14 19:05:42 +00:00
|
|
|
if (_glfw.x11.randr.available)
|
|
|
|
{
|
2016-12-18 14:00:55 +00:00
|
|
|
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
|
|
|
|
_glfw.x11.root);
|
2014-08-18 10:58:02 +00:00
|
|
|
|
|
|
|
if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
|
|
|
|
{
|
2017-03-19 04:30:27 +00:00
|
|
|
// This is likely an older Nvidia driver with broken gamma support
|
|
|
|
// Flag it as useless and fall back to xf86vm gamma, if available
|
2015-08-23 17:30:04 +00:00
|
|
|
_glfw.x11.randr.gammaBroken = GLFW_TRUE;
|
2014-08-18 10:58:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-19 04:30:27 +00:00
|
|
|
if (!sr->ncrtc)
|
2017-01-16 16:44:31 +00:00
|
|
|
{
|
2017-03-19 04:30:27 +00:00
|
|
|
// A system without CRTCs is likely a system with broken RandR
|
|
|
|
// Disable the RandR monitor path and fall back to core functions
|
2017-01-16 16:44:31 +00:00
|
|
|
_glfw.x11.randr.monitorBroken = GLFW_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-08-18 10:58:02 +00:00
|
|
|
XRRFreeScreenResources(sr);
|
2017-03-19 04:30:27 +00:00
|
|
|
}
|
2015-06-14 19:05:42 +00:00
|
|
|
|
2017-03-19 04:30:27 +00:00
|
|
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
|
|
|
{
|
2015-06-14 19:05:42 +00:00
|
|
|
XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
|
|
|
|
RROutputChangeNotifyMask);
|
2010-10-13 02:04:43 +00:00
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2017-08-16 18:54:14 +00:00
|
|
|
if (_glfw.x11.xcursor.handle)
|
|
|
|
{
|
|
|
|
_glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageCreate");
|
2017-08-16 18:54:14 +00:00
|
|
|
_glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
|
2017-08-16 18:54:14 +00:00
|
|
|
_glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
|
2019-05-07 18:40:37 +00:00
|
|
|
_glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetTheme");
|
2019-05-07 18:40:37 +00:00
|
|
|
_glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
|
2019-05-07 18:40:37 +00:00
|
|
|
_glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
|
2017-08-16 18:54:14 +00:00
|
|
|
}
|
|
|
|
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2017-08-16 17:55:32 +00:00
|
|
|
if (_glfw.x11.xinerama.handle)
|
2014-09-22 10:49:03 +00:00
|
|
|
{
|
2017-08-16 17:55:32 +00:00
|
|
|
_glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaIsActive");
|
2017-08-16 17:55:32 +00:00
|
|
|
_glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
|
2017-08-16 17:55:32 +00:00
|
|
|
_glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
|
2017-08-16 17:55:32 +00:00
|
|
|
|
|
|
|
if (XineramaQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xinerama.major,
|
|
|
|
&_glfw.x11.xinerama.minor))
|
|
|
|
{
|
|
|
|
if (XineramaIsActive(_glfw.x11.display))
|
|
|
|
_glfw.x11.xinerama.available = GLFW_TRUE;
|
|
|
|
}
|
2014-09-22 10:49:03 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 12:35:31 +00:00
|
|
|
_glfw.x11.xkb.major = 1;
|
|
|
|
_glfw.x11.xkb.minor = 0;
|
2014-04-24 05:10:58 +00:00
|
|
|
_glfw.x11.xkb.available =
|
|
|
|
XkbQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xkb.majorOpcode,
|
|
|
|
&_glfw.x11.xkb.eventBase,
|
|
|
|
&_glfw.x11.xkb.errorBase,
|
2015-05-27 12:35:31 +00:00
|
|
|
&_glfw.x11.xkb.major,
|
|
|
|
&_glfw.x11.xkb.minor);
|
2014-04-24 05:10:58 +00:00
|
|
|
|
2014-05-18 10:24:29 +00:00
|
|
|
if (_glfw.x11.xkb.available)
|
2013-01-12 16:06:35 +00:00
|
|
|
{
|
2014-05-18 10:24:29 +00:00
|
|
|
Bool supported;
|
2013-01-12 16:06:35 +00:00
|
|
|
|
2014-05-18 10:24:29 +00:00
|
|
|
if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
|
2014-04-24 05:10:58 +00:00
|
|
|
{
|
2014-05-18 10:24:29 +00:00
|
|
|
if (supported)
|
2015-08-23 17:30:04 +00:00
|
|
|
_glfw.x11.xkb.detectable = GLFW_TRUE;
|
2014-04-24 05:10:58 +00:00
|
|
|
}
|
2019-05-29 22:37:26 +00:00
|
|
|
|
|
|
|
XkbStateRec state;
|
|
|
|
if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
|
|
|
|
_glfw.x11.xkb.group = (unsigned int)state.group;
|
2020-05-19 15:44:59 +00:00
|
|
|
|
2020-05-19 15:49:02 +00:00
|
|
|
XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
|
|
|
|
XkbGroupStateMask, XkbGroupStateMask);
|
2013-01-12 20:01:44 +00:00
|
|
|
}
|
|
|
|
|
2020-10-23 16:55:37 +00:00
|
|
|
if (_glfw.hints.init.x11.xcbVulkanSurface)
|
|
|
|
{
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2020-10-23 16:55:37 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 18:19:04 +00:00
|
|
|
if (_glfw.x11.x11xcb.handle)
|
|
|
|
{
|
2017-08-16 19:03:10 +00:00
|
|
|
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
|
2015-08-10 18:19:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-24 13:37:23 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so");
|
2018-04-24 13:37:23 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1");
|
2018-04-24 13:37:23 +00:00
|
|
|
#endif
|
2017-09-18 16:10:57 +00:00
|
|
|
if (_glfw.x11.xrender.handle)
|
|
|
|
{
|
|
|
|
_glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryExtension");
|
2017-09-18 16:10:57 +00:00
|
|
|
_glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryVersion");
|
2017-09-18 16:10:57 +00:00
|
|
|
_glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
|
2017-09-18 16:10:57 +00:00
|
|
|
|
|
|
|
if (XRenderQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xrender.errorBase,
|
|
|
|
&_glfw.x11.xrender.eventBase))
|
|
|
|
{
|
|
|
|
if (XRenderQueryVersion(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xrender.major,
|
|
|
|
&_glfw.x11.xrender.minor))
|
|
|
|
{
|
|
|
|
_glfw.x11.xrender.available = GLFW_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 12:44:43 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so");
|
2019-09-30 12:44:43 +00:00
|
|
|
#else
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6");
|
2019-09-30 12:44:43 +00:00
|
|
|
#endif
|
|
|
|
if (_glfw.x11.xshape.handle)
|
|
|
|
{
|
|
|
|
_glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryExtension");
|
2019-09-30 12:44:43 +00:00
|
|
|
_glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineRegion");
|
2019-09-30 12:44:43 +00:00
|
|
|
_glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryVersion");
|
2020-07-06 21:09:28 +00:00
|
|
|
_glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineMask");
|
2019-09-30 12:44:43 +00:00
|
|
|
|
|
|
|
if (XShapeQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xshape.errorBase,
|
|
|
|
&_glfw.x11.xshape.eventBase))
|
|
|
|
{
|
|
|
|
if (XShapeQueryVersion(_glfw.x11.display,
|
|
|
|
&_glfw.x11.xshape.major,
|
|
|
|
&_glfw.x11.xshape.minor))
|
|
|
|
{
|
|
|
|
_glfw.x11.xshape.available = GLFW_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 10:18:14 +00:00
|
|
|
// Update the key code LUT
|
|
|
|
// FIXME: We should listen to XkbMapNotify events to track changes to
|
|
|
|
// the keyboard mapping.
|
2014-03-30 14:23:22 +00:00
|
|
|
createKeyTables();
|
2011-01-02 10:18:14 +00:00
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// String format atoms
|
2015-01-27 23:04:59 +00:00
|
|
|
_glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
|
2017-08-08 12:04:51 +00:00
|
|
|
_glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
|
2013-04-29 11:16:56 +00:00
|
|
|
_glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
|
2013-01-29 01:45:08 +00:00
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// Custom selection property atom
|
2013-04-29 10:45:18 +00:00
|
|
|
_glfw.x11.GLFW_SELECTION =
|
2013-01-02 00:40:42 +00:00
|
|
|
XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
|
2012-04-11 21:32:50 +00:00
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// ICCCM standard clipboard atoms
|
2013-01-29 01:45:08 +00:00
|
|
|
_glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
|
2013-04-29 10:26:25 +00:00
|
|
|
_glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
|
2017-08-02 14:10:13 +00:00
|
|
|
_glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
|
2017-08-07 21:23:37 +00:00
|
|
|
_glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
|
2013-01-29 01:45:08 +00:00
|
|
|
_glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
|
2011-09-22 11:03:45 +00:00
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// Clipboard manager atoms
|
2013-04-29 11:16:56 +00:00
|
|
|
_glfw.x11.CLIPBOARD_MANAGER =
|
|
|
|
XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
|
|
|
|
_glfw.x11.SAVE_TARGETS =
|
|
|
|
XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
|
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// Xdnd (drag and drop) atoms
|
2016-05-01 20:54:02 +00:00
|
|
|
_glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
|
|
|
|
_glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
|
|
|
|
_glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
|
|
|
|
_glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
|
|
|
|
_glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
|
|
|
|
_glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
|
|
|
|
_glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
|
|
|
|
_glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
|
2017-03-16 22:07:59 +00:00
|
|
|
_glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
|
|
|
|
_glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
|
2013-07-10 09:42:14 +00:00
|
|
|
|
2016-05-03 10:00:16 +00:00
|
|
|
// ICCCM, EWMH and Motif window property atoms
|
|
|
|
// These can be set safely even without WM support
|
|
|
|
// The EWMH atoms that require WM support are handled in detectEWMH
|
|
|
|
_glfw.x11.WM_PROTOCOLS =
|
|
|
|
XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
|
|
|
|
_glfw.x11.WM_STATE =
|
|
|
|
XInternAtom(_glfw.x11.display, "WM_STATE", False);
|
|
|
|
_glfw.x11.WM_DELETE_WINDOW =
|
|
|
|
XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
|
2019-06-04 14:52:40 +00:00
|
|
|
_glfw.x11.NET_SUPPORTED =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
|
|
|
|
_glfw.x11.NET_SUPPORTING_WM_CHECK =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
|
2016-05-03 10:00:16 +00:00
|
|
|
_glfw.x11.NET_WM_ICON =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
|
|
|
|
_glfw.x11.NET_WM_PING =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
|
|
|
|
_glfw.x11.NET_WM_PID =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
|
|
|
|
_glfw.x11.NET_WM_NAME =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
|
|
|
|
_glfw.x11.NET_WM_ICON_NAME =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
|
|
|
|
_glfw.x11.NET_WM_BYPASS_COMPOSITOR =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
|
2017-09-25 21:14:45 +00:00
|
|
|
_glfw.x11.NET_WM_WINDOW_OPACITY =
|
|
|
|
XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
|
2016-05-03 10:00:16 +00:00
|
|
|
_glfw.x11.MOTIF_WM_HINTS =
|
|
|
|
XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
|
|
|
|
|
2017-09-25 21:14:45 +00:00
|
|
|
// The compositing manager selection name contains the screen number
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
|
|
|
|
_glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
|
|
|
|
}
|
|
|
|
|
2019-06-04 14:52:40 +00:00
|
|
|
// Detect whether an EWMH-conformant window manager is running
|
|
|
|
detectEWMH();
|
|
|
|
|
2015-08-23 17:30:04 +00:00
|
|
|
return GLFW_TRUE;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 17:19:00 +00:00
|
|
|
// Retrieve system content scale via folklore heuristics
|
|
|
|
//
|
|
|
|
static void getSystemContentScale(float* xscale, float* yscale)
|
|
|
|
{
|
2019-10-28 18:18:19 +00:00
|
|
|
// Start by assuming the default X11 DPI
|
|
|
|
// NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
|
|
|
|
// would be set to 96, so assume that is the case if we cannot find it
|
|
|
|
float xdpi = 96.f, ydpi = 96.f;
|
2017-08-29 17:19:00 +00:00
|
|
|
|
|
|
|
// NOTE: Basing the scale on Xft.dpi where available should provide the most
|
|
|
|
// consistent user experience (matches Qt, Gtk, etc), although not
|
|
|
|
// always the most accurate one
|
|
|
|
char* rms = XResourceManagerString(_glfw.x11.display);
|
|
|
|
if (rms)
|
|
|
|
{
|
|
|
|
XrmDatabase db = XrmGetStringDatabase(rms);
|
|
|
|
if (db)
|
|
|
|
{
|
|
|
|
XrmValue value;
|
|
|
|
char* type = NULL;
|
|
|
|
|
|
|
|
if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
|
|
|
|
{
|
|
|
|
if (type && strcmp(type, "String") == 0)
|
|
|
|
xdpi = ydpi = atof(value.addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrmDestroyDatabase(db);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*xscale = xdpi / 96.f;
|
|
|
|
*yscale = ydpi / 96.f;
|
|
|
|
}
|
|
|
|
|
2014-06-22 11:13:53 +00:00
|
|
|
// Create a blank cursor for hidden and disabled cursor modes
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2016-02-22 11:29:52 +00:00
|
|
|
static Cursor createHiddenCursor(void)
|
2010-09-11 13:39:21 +00:00
|
|
|
{
|
2017-03-20 16:51:03 +00:00
|
|
|
unsigned char pixels[16 * 16 * 4] = { 0 };
|
2014-06-22 11:13:53 +00:00
|
|
|
GLFWimage image = { 16, 16, pixels };
|
2021-07-13 19:50:09 +00:00
|
|
|
return _glfwCreateNativeCursorX11(&image, 0, 0);
|
2010-09-11 13:39:21 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 20:46:56 +00:00
|
|
|
// Create a helper window for IPC
|
|
|
|
//
|
|
|
|
static Window createHelperWindow(void)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes wa;
|
|
|
|
wa.event_mask = PropertyChangeMask;
|
|
|
|
|
|
|
|
return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
|
|
|
|
0, 0, 1, 1, 0, 0,
|
|
|
|
InputOnly,
|
|
|
|
DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
|
|
|
|
CWEventMask, &wa);
|
|
|
|
}
|
|
|
|
|
2013-07-10 23:23:26 +00:00
|
|
|
// X error handler
|
|
|
|
//
|
|
|
|
static int errorHandler(Display *display, XErrorEvent* event)
|
|
|
|
{
|
2020-03-16 16:13:59 +00:00
|
|
|
if (_glfw.x11.display != display)
|
|
|
|
return 0;
|
|
|
|
|
2013-07-10 23:23:26 +00:00
|
|
|
_glfw.x11.errorCode = event->error_code;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW internal API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Sets the X error handler callback
|
2013-07-10 23:23:26 +00:00
|
|
|
//
|
2015-12-03 17:16:46 +00:00
|
|
|
void _glfwGrabErrorHandlerX11(void)
|
2013-07-10 23:23:26 +00:00
|
|
|
{
|
|
|
|
_glfw.x11.errorCode = Success;
|
|
|
|
XSetErrorHandler(errorHandler);
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Clears the X error handler callback
|
2013-07-10 23:23:26 +00:00
|
|
|
//
|
2015-12-03 17:16:46 +00:00
|
|
|
void _glfwReleaseErrorHandlerX11(void)
|
2013-07-10 23:23:26 +00:00
|
|
|
{
|
|
|
|
// Synchronize to make sure all commands are processed
|
|
|
|
XSync(_glfw.x11.display, False);
|
|
|
|
XSetErrorHandler(NULL);
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Reports the specified error, appending information about the last X error
|
2013-07-10 23:23:26 +00:00
|
|
|
//
|
2015-12-03 17:16:46 +00:00
|
|
|
void _glfwInputErrorX11(int error, const char* message)
|
2013-07-10 23:23:26 +00:00
|
|
|
{
|
2017-08-17 12:25:10 +00:00
|
|
|
char buffer[_GLFW_MESSAGE_SIZE];
|
2013-07-10 23:23:26 +00:00
|
|
|
XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
|
|
|
|
buffer, sizeof(buffer));
|
|
|
|
|
|
|
|
_glfwInputError(error, "%s: %s", message, buffer);
|
|
|
|
}
|
|
|
|
|
2014-09-02 17:42:43 +00:00
|
|
|
// Creates a native cursor object from the specified image and hotspot
|
2014-06-22 11:13:53 +00:00
|
|
|
//
|
2021-07-13 19:50:09 +00:00
|
|
|
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot)
|
2014-06-22 11:13:53 +00:00
|
|
|
{
|
|
|
|
Cursor cursor;
|
|
|
|
|
2017-08-16 18:54:14 +00:00
|
|
|
if (!_glfw.x11.xcursor.handle)
|
|
|
|
return None;
|
|
|
|
|
2014-06-22 11:13:53 +00:00
|
|
|
XcursorImage* native = XcursorImageCreate(image->width, image->height);
|
|
|
|
if (native == NULL)
|
|
|
|
return None;
|
|
|
|
|
|
|
|
native->xhot = xhot;
|
|
|
|
native->yhot = yhot;
|
|
|
|
|
|
|
|
unsigned char* source = (unsigned char*) image->pixels;
|
|
|
|
XcursorPixel* target = native->pixels;
|
|
|
|
|
2021-02-16 19:12:19 +00:00
|
|
|
for (int i = 0; i < image->width * image->height; i++, target++, source += 4)
|
2014-06-22 11:13:53 +00:00
|
|
|
{
|
2016-02-23 10:47:14 +00:00
|
|
|
unsigned int alpha = source[3];
|
2016-02-17 05:53:57 +00:00
|
|
|
|
|
|
|
*target = (alpha << 24) |
|
2016-02-23 10:47:14 +00:00
|
|
|
((unsigned char) ((source[0] * alpha) / 255) << 16) |
|
|
|
|
((unsigned char) ((source[1] * alpha) / 255) << 8) |
|
|
|
|
((unsigned char) ((source[2] * alpha) / 255) << 0);
|
2014-06-22 11:13:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
|
|
|
|
XcursorImageDestroy(native);
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2010-09-15 14:44:43 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW platform API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2021-07-13 19:50:09 +00:00
|
|
|
const _GLFWplatform x11 =
|
|
|
|
{
|
|
|
|
GLFW_PLATFORM_X11,
|
|
|
|
_glfwInitX11,
|
|
|
|
_glfwTerminateX11,
|
|
|
|
_glfwGetCursorPosX11,
|
|
|
|
_glfwSetCursorPosX11,
|
|
|
|
_glfwSetCursorModeX11,
|
|
|
|
_glfwSetRawMouseMotionX11,
|
|
|
|
_glfwRawMouseMotionSupportedX11,
|
|
|
|
_glfwCreateCursorX11,
|
|
|
|
_glfwCreateStandardCursorX11,
|
|
|
|
_glfwDestroyCursorX11,
|
|
|
|
_glfwSetCursorX11,
|
|
|
|
_glfwGetScancodeNameX11,
|
|
|
|
_glfwGetKeyScancodeX11,
|
|
|
|
_glfwSetClipboardStringX11,
|
|
|
|
_glfwGetClipboardStringX11,
|
|
|
|
#if defined(__linux__)
|
|
|
|
_glfwInitJoysticksLinux,
|
|
|
|
_glfwTerminateJoysticksLinux,
|
|
|
|
_glfwPollJoystickLinux,
|
|
|
|
_glfwGetMappingNameLinux,
|
|
|
|
_glfwUpdateGamepadGUIDLinux,
|
|
|
|
#else
|
|
|
|
_glfwInitJoysticksNull,
|
|
|
|
_glfwTerminateJoysticksNull,
|
|
|
|
_glfwPollJoystickNull,
|
|
|
|
_glfwGetMappingNameNull,
|
|
|
|
_glfwUpdateGamepadGUIDNull,
|
|
|
|
#endif
|
|
|
|
_glfwFreeMonitorX11,
|
|
|
|
_glfwGetMonitorPosX11,
|
|
|
|
_glfwGetMonitorContentScaleX11,
|
|
|
|
_glfwGetMonitorWorkareaX11,
|
|
|
|
_glfwGetVideoModesX11,
|
|
|
|
_glfwGetVideoModeX11,
|
|
|
|
_glfwGetGammaRampX11,
|
|
|
|
_glfwSetGammaRampX11,
|
|
|
|
_glfwCreateWindowX11,
|
|
|
|
_glfwDestroyWindowX11,
|
|
|
|
_glfwSetWindowTitleX11,
|
|
|
|
_glfwSetWindowIconX11,
|
|
|
|
_glfwGetWindowPosX11,
|
|
|
|
_glfwSetWindowPosX11,
|
|
|
|
_glfwGetWindowSizeX11,
|
|
|
|
_glfwSetWindowSizeX11,
|
|
|
|
_glfwSetWindowSizeLimitsX11,
|
|
|
|
_glfwSetWindowAspectRatioX11,
|
|
|
|
_glfwGetFramebufferSizeX11,
|
|
|
|
_glfwGetWindowFrameSizeX11,
|
|
|
|
_glfwGetWindowContentScaleX11,
|
|
|
|
_glfwIconifyWindowX11,
|
|
|
|
_glfwRestoreWindowX11,
|
|
|
|
_glfwMaximizeWindowX11,
|
|
|
|
_glfwShowWindowX11,
|
|
|
|
_glfwHideWindowX11,
|
|
|
|
_glfwRequestWindowAttentionX11,
|
|
|
|
_glfwFocusWindowX11,
|
|
|
|
_glfwSetWindowMonitorX11,
|
|
|
|
_glfwWindowFocusedX11,
|
|
|
|
_glfwWindowIconifiedX11,
|
|
|
|
_glfwWindowVisibleX11,
|
|
|
|
_glfwWindowMaximizedX11,
|
|
|
|
_glfwWindowHoveredX11,
|
|
|
|
_glfwFramebufferTransparentX11,
|
|
|
|
_glfwGetWindowOpacityX11,
|
|
|
|
_glfwSetWindowResizableX11,
|
|
|
|
_glfwSetWindowDecoratedX11,
|
|
|
|
_glfwSetWindowFloatingX11,
|
|
|
|
_glfwSetWindowOpacityX11,
|
|
|
|
_glfwSetWindowMousePassthroughX11,
|
|
|
|
_glfwPollEventsX11,
|
|
|
|
_glfwWaitEventsX11,
|
|
|
|
_glfwWaitEventsTimeoutX11,
|
|
|
|
_glfwPostEmptyEventX11,
|
|
|
|
_glfwGetEGLPlatformX11,
|
|
|
|
_glfwGetEGLNativeDisplayX11,
|
|
|
|
_glfwGetEGLNativeWindowX11,
|
|
|
|
_glfwGetRequiredInstanceExtensionsX11,
|
|
|
|
_glfwGetPhysicalDevicePresentationSupportX11,
|
|
|
|
_glfwCreateWindowSurfaceX11,
|
|
|
|
};
|
|
|
|
|
2020-02-06 14:46:37 +00:00
|
|
|
// HACK: If the application has left the locale as "C" then both wide
|
|
|
|
// character text input and explicit UTF-8 input via XIM will break
|
|
|
|
// This sets the CTYPE part of the current locale from the environment
|
|
|
|
// in the hope that it is set to something more sane than "C"
|
2014-12-18 01:52:06 +00:00
|
|
|
if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
|
|
|
|
setlocale(LC_CTYPE, "");
|
|
|
|
|
2019-12-16 12:19:37 +00:00
|
|
|
#if defined(__CYGWIN__)
|
2021-07-13 19:50:09 +00:00
|
|
|
void* module = _glfwPlatformLoadModule("libX11-6.so");
|
2021-12-22 21:19:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
void* module = _glfwPlatformLoadModule("libX11.so");
|
2019-12-16 12:19:37 +00:00
|
|
|
#else
|
2021-07-13 19:50:09 +00:00
|
|
|
void* module = _glfwPlatformLoadModule("libX11.so.6");
|
2019-12-16 12:19:37 +00:00
|
|
|
#endif
|
2021-07-13 19:50:09 +00:00
|
|
|
if (!module)
|
2019-12-16 12:19:37 +00:00
|
|
|
{
|
2021-07-13 19:50:09 +00:00
|
|
|
if (platformID == GLFW_PLATFORM_X11)
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib");
|
|
|
|
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PFN_XInitThreads XInitThreads = (PFN_XInitThreads)
|
|
|
|
_glfwPlatformGetModuleSymbol(module, "XInitThreads");
|
|
|
|
PFN_XrmInitialize XrmInitialize = (PFN_XrmInitialize)
|
|
|
|
_glfwPlatformGetModuleSymbol(module, "XrmInitialize");
|
|
|
|
PFN_XOpenDisplay XOpenDisplay = (PFN_XOpenDisplay)
|
|
|
|
_glfwPlatformGetModuleSymbol(module, "XOpenDisplay");
|
|
|
|
if (!XInitThreads || !XrmInitialize || !XOpenDisplay)
|
|
|
|
{
|
|
|
|
if (platformID == GLFW_PLATFORM_X11)
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib entry point");
|
|
|
|
|
|
|
|
_glfwPlatformFreeModule(module);
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
XInitThreads();
|
|
|
|
XrmInitialize();
|
|
|
|
|
|
|
|
Display* display = XOpenDisplay(NULL);
|
|
|
|
if (!display)
|
|
|
|
{
|
|
|
|
if (platformID == GLFW_PLATFORM_X11)
|
|
|
|
{
|
|
|
|
const char* name = getenv("DISPLAY");
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
|
|
|
"X11: Failed to open display %s", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
|
|
|
"X11: The DISPLAY environment variable is missing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_glfwPlatformFreeModule(module);
|
2019-12-16 12:19:37 +00:00
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
_glfw.x11.display = display;
|
|
|
|
_glfw.x11.xlib.handle = module;
|
|
|
|
|
|
|
|
*platform = x11;
|
|
|
|
return GLFW_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int _glfwInitX11(void)
|
|
|
|
{
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocSizeHints");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocWMHints");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeProperty");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeWindowAttributes");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckIfEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseDisplay");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CloseIM = (PFN_XCloseIM)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseIM");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XConvertSelection");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateColormap");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateFontCursor");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateIC");
|
2019-09-30 12:44:43 +00:00
|
|
|
_glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateRegion");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDefineCursor");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteContext");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteProperty");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyIC");
|
2019-09-30 12:44:43 +00:00
|
|
|
_glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyRegion");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyWindow");
|
2020-03-16 23:04:48 +00:00
|
|
|
_glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDisplayKeycodes");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XEventsQueued");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFilterEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.FindContext = (PFN_XFindContext)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFindContext");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.Flush = (PFN_XFlush)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFlush");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.Free = (PFN_XFree)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFree");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeColormap");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeCursor");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeEventData");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetErrorText");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetEventData");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetICValues = (PFN_XGetICValues)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetICValues");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetIMValues");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetInputFocus");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetKeyboardMapping");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetScreenSaver");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetSelectionOwner");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetVisualInfo");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWMNormalHints");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowAttributes");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowProperty");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGrabPointer");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XIconifyWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.InternAtom = (PFN_XInternAtom)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInternAtom");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.LookupString = (PFN_XLookupString)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XLookupString");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.MapRaised = (PFN_XMapRaised)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapRaised");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.MapWindow = (PFN_XMapWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveResizeWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.NextEvent = (PFN_XNextEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XNextEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.OpenIM = (PFN_XOpenIM)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenIM");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPeekEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.Pending = (PFN_XPending)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPending");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryExtension");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryPointer");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRaiseWindow");
|
2020-01-22 19:12:36 +00:00
|
|
|
_glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResizeWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResourceManagerString");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SaveContext = (PFN_XSaveContext)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSaveContext");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SelectInput = (PFN_XSelectInput)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSelectInput");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SendEvent = (PFN_XSendEvent)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSendEvent");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetClassHint");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetErrorHandler");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetICFocus");
|
2020-01-22 19:12:36 +00:00
|
|
|
_glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetIMValues");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetInputFocus");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetLocaleModifiers");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetScreenSaver");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetSelectionOwner");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMHints");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMNormalHints");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMProtocols");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSupportsLocale");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.Sync = (PFN_XSync)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSync");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XTranslateCoordinates");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUndefineCursor");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUngrabPointer");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnmapWindow");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnsetICFocus");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XWarpPointer");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeNames");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.GetMap = (PFN_XkbGetMap)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetMap");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.GetNames = (PFN_XkbGetNames)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetNames");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.GetState = (PFN_XkbGetState)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetState");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbQueryExtension");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSelectEventDetails");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmDestroyDatabase");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xrm.GetResource = (PFN_XrmGetResource)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetResource");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetStringDatabase");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmUniqueQuark");
|
2020-01-22 19:12:36 +00:00
|
|
|
_glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8LookupString");
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
|
2019-12-16 12:19:37 +00:00
|
|
|
|
2020-07-02 16:53:26 +00:00
|
|
|
if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
|
|
|
|
_glfw.x11.xlib.utf8 = GLFW_TRUE;
|
|
|
|
|
2013-06-24 12:38:00 +00:00
|
|
|
_glfw.x11.screen = DefaultScreen(_glfw.x11.display);
|
|
|
|
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
|
|
|
|
_glfw.x11.context = XUniqueContext();
|
2010-10-13 02:04:43 +00:00
|
|
|
|
2017-08-29 17:19:00 +00:00
|
|
|
getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
|
|
|
|
|
2013-06-24 12:38:00 +00:00
|
|
|
if (!initExtensions())
|
2015-08-23 17:30:04 +00:00
|
|
|
return GLFW_FALSE;
|
2012-04-23 11:00:49 +00:00
|
|
|
|
2017-09-17 14:06:02 +00:00
|
|
|
_glfw.x11.helperWindowHandle = createHelperWindow();
|
|
|
|
_glfw.x11.hiddenCursorHandle = createHiddenCursor();
|
|
|
|
|
2020-07-02 16:53:26 +00:00
|
|
|
if (XSupportsLocale() && _glfw.x11.xlib.utf8)
|
2014-09-21 00:13:41 +00:00
|
|
|
{
|
|
|
|
XSetLocaleModifiers("");
|
|
|
|
|
2020-01-22 19:12:36 +00:00
|
|
|
// If an IM is already present our callback will be called right away
|
|
|
|
XRegisterIMInstantiateCallback(_glfw.x11.display,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
inputMethodInstantiateCallback,
|
|
|
|
NULL);
|
2014-09-21 00:13:41 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 00:19:48 +00:00
|
|
|
_glfwPollMonitorsX11();
|
2015-08-23 17:30:04 +00:00
|
|
|
return GLFW_TRUE;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 19:50:09 +00:00
|
|
|
void _glfwTerminateX11(void)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2015-10-24 20:46:56 +00:00
|
|
|
if (_glfw.x11.helperWindowHandle)
|
|
|
|
{
|
2015-10-24 20:54:30 +00:00
|
|
|
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
|
|
|
|
_glfw.x11.helperWindowHandle)
|
|
|
|
{
|
|
|
|
_glfwPushSelectionToManagerX11();
|
|
|
|
}
|
|
|
|
|
2015-10-24 20:46:56 +00:00
|
|
|
XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
|
|
|
|
_glfw.x11.helperWindowHandle = None;
|
|
|
|
}
|
|
|
|
|
2016-09-06 14:21:15 +00:00
|
|
|
if (_glfw.x11.hiddenCursorHandle)
|
2010-09-11 13:42:32 +00:00
|
|
|
{
|
2016-09-06 14:21:15 +00:00
|
|
|
XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
|
|
|
|
_glfw.x11.hiddenCursorHandle = (Cursor) 0;
|
2010-09-11 13:42:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-03 18:53:48 +00:00
|
|
|
_glfw_free(_glfw.x11.primarySelectionString);
|
|
|
|
_glfw_free(_glfw.x11.clipboardString);
|
2013-06-24 12:08:50 +00:00
|
|
|
|
2020-01-22 19:12:36 +00:00
|
|
|
XUnregisterIMInstantiateCallback(_glfw.x11.display,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
inputMethodInstantiateCallback,
|
|
|
|
NULL);
|
|
|
|
|
2013-10-06 19:19:38 +00:00
|
|
|
if (_glfw.x11.im)
|
|
|
|
{
|
|
|
|
XCloseIM(_glfw.x11.im);
|
|
|
|
_glfw.x11.im = NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-21 19:18:02 +00:00
|
|
|
if (_glfw.x11.display)
|
|
|
|
{
|
|
|
|
XCloseDisplay(_glfw.x11.display);
|
|
|
|
_glfw.x11.display = NULL;
|
|
|
|
}
|
2015-08-12 22:21:33 +00:00
|
|
|
|
2017-08-16 19:12:48 +00:00
|
|
|
if (_glfw.x11.x11xcb.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.x11xcb.handle);
|
2017-08-16 19:12:48 +00:00
|
|
|
_glfw.x11.x11xcb.handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.xcursor.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.xcursor.handle);
|
2017-08-16 19:12:48 +00:00
|
|
|
_glfw.x11.xcursor.handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.randr.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.randr.handle);
|
2017-08-16 19:12:48 +00:00
|
|
|
_glfw.x11.randr.handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.xinerama.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.xinerama.handle);
|
2017-08-16 19:12:48 +00:00
|
|
|
_glfw.x11.xinerama.handle = NULL;
|
|
|
|
}
|
|
|
|
|
2018-04-25 19:49:41 +00:00
|
|
|
if (_glfw.x11.xrender.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.xrender.handle);
|
2018-04-25 19:49:41 +00:00
|
|
|
_glfw.x11.xrender.handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.vidmode.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.vidmode.handle);
|
2018-04-25 19:49:41 +00:00
|
|
|
_glfw.x11.vidmode.handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_glfw.x11.xi.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.xi.handle);
|
2018-04-25 19:49:41 +00:00
|
|
|
_glfw.x11.xi.handle = NULL;
|
|
|
|
}
|
|
|
|
|
2017-11-27 14:54:33 +00:00
|
|
|
// NOTE: These need to be unloaded after XCloseDisplay, as they register
|
|
|
|
// cleanup callbacks that get called by that function
|
|
|
|
_glfwTerminateEGL();
|
2015-12-03 17:16:46 +00:00
|
|
|
_glfwTerminateGLX();
|
|
|
|
|
2019-12-16 12:19:37 +00:00
|
|
|
if (_glfw.x11.xlib.handle)
|
|
|
|
{
|
2021-07-16 12:57:22 +00:00
|
|
|
_glfwPlatformFreeModule(_glfw.x11.xlib.handle);
|
2019-12-16 12:19:37 +00:00
|
|
|
_glfw.x11.xlib.handle = NULL;
|
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|