From 4774676e2a6836d7f6c67bbfc851483f4063ac1a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 3 May 2021 21:09:01 -0400 Subject: [PATCH] Correct keypad symbols, push X11 into a namespace. --- OSBindings/Qt/mainwindow.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 5b20f52f3..b5957b852 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -884,7 +884,14 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) { #ifdef HAS_X11 #include -#include + +// X11 collides with my 'Time' namespace; that's probably my fault for lazy namespace +// selection, but this fixes the problem. +namespace X11 { +#include +#include +} + #endif std::optional MainWindow::keyForEvent(QKeyEvent *event) { @@ -893,10 +900,10 @@ std::optional MainWindow::keyForEvent(QKeyEvent *event) { #ifdef HAS_X11 if(QGuiApplication::platformName() == QLatin1String("xcb")) { // Convert from a machine-specific keycode to a more general keysym. - int keysyms = 0; - const KeySym *const keysyms = XGetKeyboardMapping(QX11Info::display(), event->nativeScanCode(), 1, &keysyms); - const KeySym keysym = keysyms[0]; - XFree(keysyms); + int keysym_count = 0; + KeySym *const keysyms = X11::XGetKeyboardMapping(QX11Info::display(), event->nativeScanCode(), 1, &keysym_count); + const auto keysym = keysyms[0]; + X11::XFree(keysyms); #define BIND(code, key) case code: return Inputs::Keyboard::Key::key; @@ -960,9 +967,9 @@ std::optional MainWindow::keyForEvent(QKeyEvent *event) { BIND(XK_KP_Divide, KeypadSlash); BIND(XK_KP_Multiply, KeypadAsterisk); BIND(XK_KP_Delete, KeypadDelete); - BIND(XP_KP_7, Keypad7); BIND(XP_KP_8, Keypad8); BIND(XP_KP_9, Keypad9); BIND(XK_KP_Add, KeypadPlus); - BIND(XP_KP_4, Keypad4); BIND(XP_KP_5, Keypad5); BIND(XP_KP_6, Keypad6); BIND(XK_KP_Subtract, KeypadMinus); - BIND(XP_KP_1, Keypad1); BIND(XP_KP_2, Keypad2); BIND(XP_KP_3, Keypad3); BIND(XK_KP_Enter, KeypadEnter); + BIND(XK_KP_7, Keypad7); BIND(XK_KP_8, Keypad8); BIND(XK_KP_9, Keypad9); BIND(XK_KP_Add, KeypadPlus); + BIND(XK_KP_4, Keypad4); BIND(XK_KP_5, Keypad5); BIND(XK_KP_6, Keypad6); BIND(XK_KP_Subtract, KeypadMinus); + BIND(XK_KP_1, Keypad1); BIND(XK_KP_2, Keypad2); BIND(XK_KP_3, Keypad3); BIND(XK_KP_Enter, KeypadEnter); BIND(XP_KP_0, Keypad0); BIND(XK_KP_Decimal, KeypadDecimalPoint); BIND(XK_KP_Equal, KeypadEquals);