Add patch to resolve wxGetKeyState() crash on Wayland (#1266743)
- Add patch to fix wxFontEnumerator stop function - Add patch to fix wxNativeFontInfo::InitFromFont()epel8
parent
8b9de376d3
commit
e712f1cac9
@ -0,0 +1,47 @@
|
|||||||
|
From a19e512e80acdb2a777c3e44923ad0b1178db35a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Scott Talbert <swt@techie.net>
|
||||||
|
Date: Sun, 7 Aug 2016 23:15:41 -0400
|
||||||
|
Subject: [PATCH] Fix the stop function of wxFontEnumerator for wxGTK
|
||||||
|
|
||||||
|
In a wxFontEnumerator, if false is returned from OnFacename() or
|
||||||
|
OnFontEncoding(), the enumeration is supposed to stop. This was not happening
|
||||||
|
on wxGTK.
|
||||||
|
|
||||||
|
See https://github.com/wxWidgets/wxWidgets/pull/311
|
||||||
|
|
||||||
|
(cherry picked from commit 3572c2c6548bca2dbd439a3d25ed403fda99ebe9)
|
||||||
|
---
|
||||||
|
src/common/fontenumcmn.cpp | 3 ++-
|
||||||
|
src/unix/fontenum.cpp | 5 ++++-
|
||||||
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/common/fontenumcmn.cpp b/src/common/fontenumcmn.cpp
|
||||||
|
index 1185a86..f0d6f68 100644
|
||||||
|
--- a/src/common/fontenumcmn.cpp
|
||||||
|
+++ b/src/common/fontenumcmn.cpp
|
||||||
|
@@ -124,7 +124,8 @@ bool wxFontEnumerator::EnumerateEncodingsUTF8(const wxString& facename)
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
- OnFontEncoding(facenames[n], utf8);
|
||||||
|
+ if ( !OnFontEncoding(facenames[n], utf8) )
|
||||||
|
+ break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
diff --git a/src/unix/fontenum.cpp b/src/unix/fontenum.cpp
|
||||||
|
index cc7ee1d..e3739ed 100644
|
||||||
|
--- a/src/unix/fontenum.cpp
|
||||||
|
+++ b/src/unix/fontenum.cpp
|
||||||
|
@@ -89,7 +89,10 @@ bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
const gchar *name = pango_font_family_get_name(families[i]);
|
||||||
|
- OnFacename(wxString(name, wxConvUTF8));
|
||||||
|
+ if ( !OnFacename(wxString(name, wxConvUTF8)) )
|
||||||
|
+ {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_free(families);
|
@ -0,0 +1,48 @@
|
|||||||
|
From 2dd407609b8987634180c045e9a6d131db6f947e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Cornett <paulcor@users.noreply.github.com>
|
||||||
|
Date: Mon, 17 Aug 2015 21:54:41 -0700
|
||||||
|
Subject: [PATCH] use gtk_show_uri() in wxLaunchDefaultBrowser() implementation
|
||||||
|
for GTK+
|
||||||
|
|
||||||
|
(cherry picked from commit 22eec388068044b9ea3c9fd1539d6686574a32df)
|
||||||
|
---
|
||||||
|
src/unix/utilsx11.cpp | 16 +++++++++++++++-
|
||||||
|
1 file changed, 15 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp
|
||||||
|
index 12ff73e..7d5811a 100644
|
||||||
|
--- a/src/unix/utilsx11.cpp
|
||||||
|
+++ b/src/unix/utilsx11.cpp
|
||||||
|
@@ -36,10 +36,11 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
-#include <gdk/gdk.h>
|
||||||
|
+#include <gtk/gtk.h>
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#endif
|
||||||
|
+GdkWindow* wxGetTopLevelGDK();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Only X11 backend is supported for wxGTK here
|
||||||
|
@@ -887,6 +888,19 @@ bool wxDoLaunchDefaultBrowser(const wxString& url, int flags)
|
||||||
|
{
|
||||||
|
wxUnusedVar(flags);
|
||||||
|
|
||||||
|
+#ifdef __WXGTK__
|
||||||
|
+#if GTK_CHECK_VERSION(2,14,0)
|
||||||
|
+#ifndef __WXGTK3__
|
||||||
|
+ if (gtk_check_version(2,14,0) == NULL)
|
||||||
|
+#endif
|
||||||
|
+ {
|
||||||
|
+ GdkScreen* screen = gdk_window_get_screen(wxGetTopLevelGDK());
|
||||||
|
+ if (gtk_show_uri(screen, url.utf8_str(), GDK_CURRENT_TIME, NULL))
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+#endif // GTK_CHECK_VERSION(2,14,0)
|
||||||
|
+#endif // __WXGTK__
|
||||||
|
+
|
||||||
|
// Our best best is to use xdg-open from freedesktop.org cross-desktop
|
||||||
|
// compatibility suite xdg-utils
|
||||||
|
// (see http://portland.freedesktop.org/wiki/) -- this is installed on
|
@ -0,0 +1,39 @@
|
|||||||
|
From 238a948ed01f27e05e2c0e08932e8da207590648 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Scott Talbert <swt@techie.net>
|
||||||
|
Date: Tue, 9 Aug 2016 21:12:58 -0400
|
||||||
|
Subject: [PATCH] Fix wxNativeFontInfo::InitFromFont() when using Pango
|
||||||
|
|
||||||
|
Use pango_font_description_copy() to make a lossless copy of the original font
|
||||||
|
instead of doing it using wxWidgets API which is less direct and, in addition,
|
||||||
|
currently is completely broken as SetXXX() methods don't create the Pango font
|
||||||
|
description if it doesn't exist as they ought to.
|
||||||
|
|
||||||
|
See https://github.com/wxWidgets/wxWidgets/pull/312
|
||||||
|
|
||||||
|
(cherry picked from commit dbe2a1c2fdba53ad1d08ce36780267217933a876)
|
||||||
|
---
|
||||||
|
include/wx/fontutil.h | 4 ++++
|
||||||
|
1 file changed, 4 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h
|
||||||
|
index 60bb874..9e4d023 100644
|
||||||
|
--- a/include/wx/fontutil.h
|
||||||
|
+++ b/include/wx/fontutil.h
|
||||||
|
@@ -227,6 +227,9 @@ public :
|
||||||
|
// init with the parameters of the given font
|
||||||
|
void InitFromFont(const wxFont& font)
|
||||||
|
{
|
||||||
|
+#if wxUSE_PANGO
|
||||||
|
+ Init(*font.GetNativeFontInfo());
|
||||||
|
+#else
|
||||||
|
// translate all font parameters
|
||||||
|
SetStyle((wxFontStyle)font.GetStyle());
|
||||||
|
SetWeight((wxFontWeight)font.GetWeight());
|
||||||
|
@@ -252,6 +255,7 @@ public :
|
||||||
|
// deal with encoding now (it may override the font family and facename
|
||||||
|
// so do it after setting them)
|
||||||
|
SetEncoding(font.GetEncoding());
|
||||||
|
+#endif // !wxUSE_PANGO
|
||||||
|
}
|
||||||
|
|
||||||
|
// accessors and modifiers for the font elements
|
@ -0,0 +1,121 @@
|
|||||||
|
From 98065821bbf0178981b50515094f565b703fcaa8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Scott Talbert <swt@techie.net>
|
||||||
|
Date: Tue, 13 Sep 2016 13:24:12 +0200
|
||||||
|
Subject: [PATCH] Fix wxGetKeyState() on non-X11 wxGTK backends (e.g., Wayland)
|
||||||
|
|
||||||
|
wxGetKeyState() does not currently work on non-X11 GTK backends, and in some
|
||||||
|
cases it has been reported to crash. It seems that the most likely use case
|
||||||
|
for wxGetKeyState() is to query the modifier keys, so on non-X11 backends, use
|
||||||
|
GTK+ calls to retrieve the modifier key state.
|
||||||
|
|
||||||
|
Non-modifier keys are not currently implemented, update the documentation to
|
||||||
|
mention this.
|
||||||
|
|
||||||
|
Closes https://github.com/wxWidgets/wxWidgets/pull/322
|
||||||
|
|
||||||
|
(this is a combined backport of 1033fb048dec849906f76ece25f154e6a61fde4e,
|
||||||
|
9f9c09e24a7f9d86ea51997bd4c55c1ddb7c3159 and
|
||||||
|
a18fe083cc91bee442863c8ab7f97d6549f2b75c from master)
|
||||||
|
---
|
||||||
|
interface/wx/utils.h | 3 +++
|
||||||
|
src/unix/utilsx11.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
2 files changed, 63 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/interface/wx/utils.h b/interface/wx/utils.h
|
||||||
|
index 0bac1c0..f127a74 100644
|
||||||
|
--- a/interface/wx/utils.h
|
||||||
|
+++ b/interface/wx/utils.h
|
||||||
|
@@ -372,6 +372,9 @@ wxString wxGetDisplayName();
|
||||||
|
Even though there are virtual key codes defined for mouse buttons, they
|
||||||
|
cannot be used with this function currently.
|
||||||
|
|
||||||
|
+ In wxGTK, this function can be only used with modifier keys (@c WXK_ALT, @c
|
||||||
|
+ WXK_CONTROL and @c WXK_SHIFT) when not using X11 backend currently.
|
||||||
|
+
|
||||||
|
@header{wx/utils.h}
|
||||||
|
*/
|
||||||
|
bool wxGetKeyState(wxKeyCode key);
|
||||||
|
diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp
|
||||||
|
index 6b35551..efc0837 100644
|
||||||
|
--- a/src/unix/utilsx11.cpp
|
||||||
|
+++ b/src/unix/utilsx11.cpp
|
||||||
|
@@ -809,7 +809,7 @@ WXKeySym wxCharCodeWXToX(int id)
|
||||||
|
// check current state of a key
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-bool wxGetKeyState(wxKeyCode key)
|
||||||
|
+static bool wxGetKeyStateX11(wxKeyCode key)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
|
||||||
|
WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
|
||||||
|
@@ -851,11 +851,69 @@ bool wxGetKeyState(wxKeyCode key)
|
||||||
|
// with the least-significant bit in the byte representing key 8N.
|
||||||
|
char key_vector[32];
|
||||||
|
XQueryKeymap(pDisplay, key_vector);
|
||||||
|
- return key_vector[keyCode >> 3] & (1 << (keyCode & 7));
|
||||||
|
+ return (key_vector[keyCode >> 3] & (1 << (keyCode & 7))) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !defined(__WXGTK__) || defined(GDK_WINDOWING_X11)
|
||||||
|
|
||||||
|
+// We need to use GDK functions when using wxGTK with a non-X11 backend, the
|
||||||
|
+// X11 code above can't work in this case.
|
||||||
|
+#ifdef __WXGTK__
|
||||||
|
+
|
||||||
|
+// gdk_keymap_get_modifier_state() is only available since 3.4
|
||||||
|
+#if GTK_CHECK_VERSION(3,4,0)
|
||||||
|
+
|
||||||
|
+#define wxHAS_GETKEYSTATE_GTK
|
||||||
|
+
|
||||||
|
+extern GtkWidget *wxGetRootWindow();
|
||||||
|
+
|
||||||
|
+static bool wxGetKeyStateGTK(wxKeyCode key)
|
||||||
|
+{
|
||||||
|
+ if (gtk_check_version(3,4,0) != NULL)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ GdkDisplay* display = gtk_widget_get_display(wxGetRootWindow());
|
||||||
|
+ GdkKeymap* keymap = gdk_keymap_get_for_display(display);
|
||||||
|
+ guint state = gdk_keymap_get_modifier_state(keymap);
|
||||||
|
+ guint mask = 0;
|
||||||
|
+ switch (key)
|
||||||
|
+ {
|
||||||
|
+ case WXK_ALT:
|
||||||
|
+ mask = GDK_MOD1_MASK;
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ case WXK_CONTROL:
|
||||||
|
+ mask = GDK_CONTROL_MASK;
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ case WXK_SHIFT:
|
||||||
|
+ mask = GDK_SHIFT_MASK;
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ default:
|
||||||
|
+ wxFAIL_MSG(wxS("Unsupported key, only modifiers can be used"));
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ return (state & mask) != 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#endif // GTK+ 3.4
|
||||||
|
+#endif // __WXGTK__
|
||||||
|
+
|
||||||
|
+bool wxGetKeyState(wxKeyCode key)
|
||||||
|
+{
|
||||||
|
+#ifdef wxHAS_GETKEYSTATE_GTK
|
||||||
|
+ GdkDisplay* display = gtk_widget_get_display(wxGetRootWindow());
|
||||||
|
+ const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display));
|
||||||
|
+ if (strcmp(name, "GdkX11Display") != 0)
|
||||||
|
+ {
|
||||||
|
+ return wxGetKeyStateGTK(key);
|
||||||
|
+ }
|
||||||
|
+#endif // GTK+ 3.4+
|
||||||
|
+
|
||||||
|
+ return wxGetKeyStateX11(key);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Launch document with default app
|
||||||
|
// ----------------------------------------------------------------------------
|
Loading…
Reference in new issue