Build fixes for OpenGL support in wxGTK with Wayland

Don't try using X-specific symbols when GDK_WINDOWING_X11 is off.

Closes https://github.com/wxWidgets/wxWidgets/pull/2191
This commit is contained in:
Hiroshi Takey F. (hiro2233)
2021-01-31 18:11:29 -04:00
committed by Vadim Zeitlin
parent 7856a385d1
commit 7e4865c7c1
4 changed files with 21 additions and 8 deletions

View File

@@ -50,6 +50,12 @@ GdkWindow* wxGetTopLevelGDK();
GtkWidget* wxGetTopLevelGTK();
#endif
#ifdef GTK_CHECK_VERSION
#if GTK_CHECK_VERSION(3,4,0)
#define wxHAS_GETKEYSTATE_GTK
#endif //GTK+ 3.4
#endif
// Only X11 backend is supported for wxGTK here (GTK < 2 has no others)
#if !defined(__WXGTK__) || \
(!defined(__WXGTK20__) || defined(GDK_WINDOWING_X11))
@@ -2544,6 +2550,7 @@ int wxUnicodeCharXToWX(WXKeySym keySym)
// check current state of a key
// ----------------------------------------------------------------------------
#ifndef wxHAS_GETKEYSTATE_GTK
static bool wxGetKeyStateX11(wxKeyCode key)
{
wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
@@ -2588,6 +2595,7 @@ static bool wxGetKeyStateX11(wxKeyCode key)
XQueryKeymap(pDisplay, key_vector);
return (key_vector[keyCode >> 3] & (1 << (keyCode & 7))) != 0;
}
#endif
#endif // !defined(__WXGTK__) || defined(GDK_WINDOWING_X11)
@@ -2596,9 +2604,8 @@ static bool wxGetKeyStateX11(wxKeyCode key)
#ifdef __WXGTK__
// gdk_keymap_get_modifier_state() is only available since 3.4
#if GTK_CHECK_VERSION(3,4,0)
#define wxHAS_GETKEYSTATE_GTK
#ifdef wxHAS_GETKEYSTATE_GTK
static bool wxGetKeyStateGTK(wxKeyCode key)
{
@@ -2629,22 +2636,24 @@ static bool wxGetKeyStateGTK(wxKeyCode key)
}
return (state & mask) != 0;
}
#endif // wxHAS_GETKEYSTATE_GTK
#endif // GTK+ 3.4
#endif // __WXGTK__
bool wxGetKeyState(wxKeyCode key)
{
#ifdef wxHAS_GETKEYSTATE_GTK
bool ret = false;
GdkDisplay* display = gdk_window_get_display(wxGetTopLevelGDK());
const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display));
if (strcmp(name, "GdkX11Display") != 0)
{
return wxGetKeyStateGTK(key);
ret = wxGetKeyStateGTK(key);
}
#endif // GTK+ 3.4+
return ret;
#else
return wxGetKeyStateX11(key);
#endif // GTK+ 3.4+
}
// ----------------------------------------------------------------------------