From 17135e0a7704b55db39110c2d55b9beda00ef7ab Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Nov 2014 13:29:28 +0000 Subject: [PATCH] Don't use X11-only functions when not using X11 in wxGTK. See #16688. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78161 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 321d6816cb..49d0626adc 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -849,28 +849,31 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event, } #ifdef GDK_WINDOWING_X11 - // we want to always get the same key code when the same key is - // pressed regardless of the state of the modifiers, i.e. on a - // standard US keyboard pressing '5' or '%' ('5' key with - // Shift) should result in the same key code in OnKeyDown(): - // '5' (although OnChar() will get either '5' or '%'). - // - // to do it we first translate keysym to keycode (== scan code) - // and then back but always using the lower register - Display *dpy = (Display *)wxGetDisplay(); - KeyCode keycode = XKeysymToKeycode(dpy, keysym); + if (GDK_IS_X11_DISPLAY(gdk_window_get_display(gdk_event->window))) + { + // we want to always get the same key code when the same key is + // pressed regardless of the state of the modifiers, i.e. on a + // standard US keyboard pressing '5' or '%' ('5' key with + // Shift) should result in the same key code in OnKeyDown(): + // '5' (although OnChar() will get either '5' or '%'). + // + // to do it we first translate keysym to keycode (== scan code) + // and then back but always using the lower register + Display *dpy = (Display *)wxGetDisplay(); + KeyCode keycode = XKeysymToKeycode(dpy, keysym); - wxLogTrace(TRACE_KEYS, wxT("\t-> keycode %d"), keycode); + wxLogTrace(TRACE_KEYS, wxT("\t-> keycode %d"), keycode); #ifdef HAVE_X11_XKBLIB_H - KeySym keysymNormalized = XkbKeycodeToKeysym(dpy, keycode, 0, 0); + KeySym keysymNormalized = XkbKeycodeToKeysym(dpy, keycode, 0, 0); #else - KeySym keysymNormalized = XKeycodeToKeysym(dpy, keycode, 0); + KeySym keysymNormalized = XKeycodeToKeysym(dpy, keycode, 0); #endif - // use the normalized, i.e. lower register, keysym if we've - // got one - key_code = keysymNormalized ? keysymNormalized : keysym; + // use the normalized, i.e. lower register, keysym if we've + // got one + key_code = keysymNormalized ? keysymNormalized : keysym; + } #else key_code = keysym; #endif