From bca90fc95f89409a8e013523cd8015a7dbb12faf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 17 Jul 2016 14:03:52 +0200 Subject: [PATCH 01/15] Recognize wxAUI_NB_MIDDLE_CLICK_CLOSE in wxAuiNotebook XRC handler This style was apparently just forgotten, so add it too. See #17597. (cherry picked from commit 63944ae9bd0218d7d649fb880fbf8f05d0f4dd72) --- src/xrc/xh_auinotbk.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xrc/xh_auinotbk.cpp b/src/xrc/xh_auinotbk.cpp index df7498394f..0a2c178f53 100644 --- a/src/xrc/xh_auinotbk.cpp +++ b/src/xrc/xh_auinotbk.cpp @@ -35,6 +35,7 @@ wxAuiNotebookXmlHandler::wxAuiNotebookXmlHandler() XRC_ADD_STYLE(wxAUI_NB_CLOSE_BUTTON); XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ACTIVE_TAB); XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ALL_TABS); + XRC_ADD_STYLE(wxAUI_NB_MIDDLE_CLICK_CLOSE); XRC_ADD_STYLE(wxAUI_NB_TOP); XRC_ADD_STYLE(wxAUI_NB_BOTTOM); From b4e2f93248fca0ba280424ca430799dbed7b6dc7 Mon Sep 17 00:00:00 2001 From: David Costanzo Date: Sun, 17 Jul 2016 14:15:40 +0200 Subject: [PATCH 02/15] Don't handle special keys as characters in wxSTC in non-Unicode build Correct the check for non-special keys when wxUSE_UNICODE==0. Closes #17598. (cherry picked from commit ab092c8d13312a7b519521bc839441f0c90e716a) --- docs/changes.txt | 1 + src/stc/stc.cpp | 2 +- src/stc/stc.cpp.in | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index abbadf529d..c9304a16d0 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -613,6 +613,7 @@ All (GUI): - Accept wxALIGN_CENTRE_HORIZONTAL in wxStaticText XRC handler (David Hart). - Fix appearance after updating a wxGrid with hidden rows/columns (iwbnwif). - Make wxAuiNotebookXmlHandler actually work. +- Fix key handling in wxStyledTextCtrl in non-Unicode build (David Costanzo). wxGTK: diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 38b9d52e30..e16eaad412 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -4749,7 +4749,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { } #else int key = evt.GetKeyCode(); - if (key <= WXK_START || key > WXK_COMMAND) { + if (key < WXK_START) { m_swx->DoAddChar(key); return; } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index cd4ee94e94..50c2dab618 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -887,7 +887,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { } #else int key = evt.GetKeyCode(); - if (key <= WXK_START || key > WXK_COMMAND) { + if (key < WXK_START) { m_swx->DoAddChar(key); return; } From a19e512e80acdb2a777c3e44923ad0b1178db35a Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Sun, 7 Aug 2016 23:15:41 -0400 Subject: [PATCH 03/15] 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 1185a864ab..f0d6f68d7e 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 cc7ee1dad4..e3739ed497 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); From 238a948ed01f27e05e2c0e08932e8da207590648 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 9 Aug 2016 21:12:58 -0400 Subject: [PATCH 04/15] 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 60bb874640..9e4d0235f9 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 From 3550b504611b2d9157dcb9750b1442dcefa60f75 Mon Sep 17 00:00:00 2001 From: Andy Robinson Date: Fri, 19 Aug 2016 22:44:23 +0200 Subject: [PATCH 05/15] Fix format specifiers used for size_t values in wxFileConfig Fix assert failures when reporting errors in config files under 64 bit systems where "%d" can't be used to output a "size_t" value. See #17630. (cherry picked from commit 75e254fce7f101098481b1628fbea8dbeeb7e773) --- src/common/fileconf.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index e626c3c0cc..4e77aa983d 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -571,7 +571,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) } if ( *pEnd != wxT(']') ) { - wxLogError(_("file '%s': unexpected character %c at line %d."), + wxLogError(_("file '%s': unexpected character %c at line %zu."), buffer.GetName(), *pEnd, n + 1); continue; // skip this line } @@ -607,7 +607,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) break; default: - wxLogWarning(_("file '%s', line %d: '%s' ignored after group header."), + wxLogWarning(_("file '%s', line %zu: '%s' ignored after group header."), buffer.GetName(), n + 1, pEnd); bCont = false; } @@ -636,7 +636,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) pEnd++; if ( *pEnd++ != wxT('=') ) { - wxLogError(_("file '%s', line %d: '=' expected."), + wxLogError(_("file '%s', line %zu: '=' expected."), buffer.GetName(), n + 1); } else { @@ -649,7 +649,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) else { if ( bLocal && pEntry->IsImmutable() ) { // immutable keys can't be changed by user - wxLogWarning(_("file '%s', line %d: value for immutable key '%s' ignored."), + wxLogWarning(_("file '%s', line %zu: value for immutable key '%s' ignored."), buffer.GetName(), n + 1, strKey.c_str()); continue; } @@ -659,8 +659,8 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) // (c) key from global file now found in local one // which is exactly what we want. else if ( !bLocal || pEntry->IsLocal() ) { - wxLogWarning(_("file '%s', line %d: key '%s' was first found at line %d."), - buffer.GetName(), (int)n + 1, strKey.c_str(), pEntry->Line()); + wxLogWarning(_("file '%s', line %zu: key '%s' was first found at line %d."), + buffer.GetName(), n + 1, strKey.c_str(), pEntry->Line()); } } From f252e56e8872b00b66305811acc30510c74991a2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Aug 2016 14:46:16 +0200 Subject: [PATCH 06/15] Fix wxBitmap ctor from XBM in wxGTK Width and height were exchanged in the loops, so the conversion code didn't work correctly and overflowed the pixel buffer (due to extra padding in the row stride) for non-square bitmaps. It also resulted in a completely wrong bitmap appearance, but somehow this managed to go unnoticed, unlike the memory errors. See #17633. (cherry picked from commit f9740e81805309fd44811108348dd6c04a1ac2d6) --- docs/changes.txt | 1 + src/gtk/bitmap.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c9304a16d0..fa28d309df 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -619,6 +619,7 @@ wxGTK: - Fix infinite sizing loop with GTK3 when using wxScrolled with a non-default target window. +- Fix wxBitmap ctor from XBM for non-square bitmaps. - Fix crashes in wxGTK3 when running with non-X11 backend (Marco Trevisan). - Fix coordinates of wxSetCursorEvent propagated to parent windows. - Fix GTK+ warnings when refreshing wxListCtrl items (Scott Talbert). diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index f81e7104a8..d3abc4c89b 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -428,17 +428,18 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) const char* src = bits; guchar* dst = gdk_pixbuf_get_pixels(pixbuf); const int stride_src = (width + 7) / 8; - const int rowinc_dst = gdk_pixbuf_get_rowstride(pixbuf) - 3 * width; - for (int j = 0; j < width; j++, src += stride_src, dst += rowinc_dst) + const int stride_dst = gdk_pixbuf_get_rowstride(pixbuf); + for (int j = 0; j < height; j++, src += stride_src, dst += stride_dst) { - for (int i = 0; i < height; i++) + guchar* d = dst; + for (int i = 0; i < width; i++) { guchar c = 0xff; if (src[i >> 3] & (1 << (i & 7))) c = 0; - *dst++ = c; - *dst++ = c; - *dst++ = c; + *d++ = c; + *d++ = c; + *d++ = c; } } #else From e1e94820050039b02da6e0c33297b73ec51e4dd7 Mon Sep 17 00:00:00 2001 From: samurajj Date: Mon, 22 Aug 2016 14:17:43 +0200 Subject: [PATCH 07/15] Fix error reporting for wxCopyFile() under Unix Check if copying file actually succeeded, any IO errors that could happen in it were previously just completely ignored. See #17638. (cherry picked from commit a93dcc531c94897b13944c779b185b42570511ac) --- src/common/filefn.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index f563a1a5ea..f6e368ee32 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1092,7 +1092,11 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) return false; } - wxDoCopyFile(fileIn, fbuf, file2, overwrite); + if ( !wxDoCopyFile(fileIn, fbuf, file2, overwrite) ) + { + wxLogError(_("Error copying the file '%s' to '%s'."), file1, file2); + return false; + } #if defined(__WXMAC__) || defined(__WXCOCOA__) // copy the resource fork of the file too if it's present From 817bd0076f61ed96694ec6cebba46ca5df495998 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 26 Jun 2014 13:38:22 +0000 Subject: [PATCH 08/15] Don't include QuickTime headers unnecessarily This should fix compilation under macOS Sierra (10.12). See #17639. (cherry picked from commit f6a2d1caef5c6d412c84aa900cb0d3990b350938) --- src/osx/carbon/dataobj.cpp | 4 ---- src/osx/core/bitmap.cpp | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 758e3a7928..5445aa6b14 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -29,10 +29,6 @@ #include "wx/osx/private.h" -#if wxOSX_USE_COCOA_OR_CARBON - #include -#endif - // ---------------------------------------------------------------------------- // wxDataFormat // ---------------------------------------------------------------------------- diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index c1bf6b7113..228b1d1842 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -35,10 +35,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) #include "wx/osx/private.h" #endif -#ifndef __WXOSX_IPHONE__ -#include -#endif - CGColorSpaceRef wxMacGetGenericRGBColorSpace(); CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); From ed54a746b0f740e707f135ba89b421944c031336 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 31 Aug 2016 09:39:25 -0700 Subject: [PATCH 09/15] Remove run-time dependencies on GTK3 backends for Wayland, Mir, Broadway This allows running with a GTK+ library that was built with different backends than the one wxWidgets was built with. Since GTK3 provides no way to determine the backends available at run-time, avoid referencing symbols in the backends by checking the type name of the GdkDisplay, on the assumption that they are unlikely to ever be changed. The X11 backend is still required at run-time if it was available at build-time, although this dependency could also be removed. (cherry picked from commit 1ba59a410f9658cfbbad7b4f24daada6d29bada6) --- src/gtk/toplevel.cpp | 60 ++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index acd3692d7e..d213cc8dc1 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -38,20 +38,6 @@ #include // XA_CARDINAL #include "wx/unix/utilsx11.h" #endif -#ifdef GDK_WINDOWING_WAYLAND - #include - #define HAS_CLIENT_DECOR -#endif -#ifdef GDK_WINDOWING_MIR - extern "C" { - #include - } - #define HAS_CLIENT_DECOR -#endif -#ifdef GDK_WINDOWING_BROADWAY - #include - #define HAS_CLIENT_DECOR -#endif #include "wx/gtk/private.h" #include "wx/gtk/private/gtk2-compat.h" @@ -93,25 +79,29 @@ static enum { static bool gs_decorCacheValid; #endif -#ifdef HAS_CLIENT_DECOR +#ifdef __WXGTK3__ static bool HasClientDecor(GtkWidget* widget) { - GdkDisplay* display = gtk_widget_get_display(widget); -#ifdef GDK_WINDOWING_WAYLAND - if (GDK_IS_WAYLAND_DISPLAY(display)) - return true; -#endif -#ifdef GDK_WINDOWING_MIR - if (GDK_IS_MIR_DISPLAY(display)) - return true; -#endif -#ifdef GDK_WINDOWING_BROADWAY - if (GDK_IS_BROADWAY_DISPLAY(display)) - return true; -#endif + static bool has; + static bool once; + if (!once) + { + once = true; + GdkDisplay* display = gtk_widget_get_display(widget); + const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display)); + has = + strcmp(name, "GdkWaylandDisplay") == 0 || + strcmp(name, "GdkMirDisplay") == 0 || + strcmp(name, "GdkBroadwayDisplay") == 0; + } + return has; +} +#else +static inline bool HasClientDecor(GtkWidget*) +{ return false; } -#endif // HAS_CLIENT_DECOR +#endif //----------------------------------------------------------------------------- // RequestUserAttention related functions @@ -266,7 +256,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) GtkAllocation a; gtk_widget_get_allocation(win->m_widget, &a); wxSize size(a.width, a.height); -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(win->m_widget)) { GtkAllocation a2; @@ -279,7 +268,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) win->GTKUpdateDecorSize(decorSize); } else -#endif { size.x += win->m_decorSize.left + win->m_decorSize.right; size.y += win->m_decorSize.top + win->m_decorSize.bottom; @@ -760,9 +748,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, if ( style & wxCAPTION ) m_gdkDecor |= GDK_DECOR_TITLE; -#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,10,0) +#if GTK_CHECK_VERSION(3,10,0) else if ( - GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(m_widget)) && + strcmp("GdkWaylandDisplay", g_type_name(G_TYPE_FROM_INSTANCE(gtk_widget_get_display(m_widget)))) == 0 && gtk_check_version(3,10,0) == NULL) { gtk_window_set_titlebar(GTK_WINDOW(m_widget), gtk_header_bar_new()); @@ -1109,9 +1097,7 @@ void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXU void wxTopLevelWindowGTK::GTKDoGetSize(int *width, int *height) const { wxSize size(m_width, m_height); -#ifdef HAS_CLIENT_DECOR if (!HasClientDecor(m_widget)) -#endif { size.x -= m_decorSize.left + m_decorSize.right; size.y -= m_decorSize.top + m_decorSize.bottom; @@ -1280,14 +1266,12 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, hints.max_height = INT_MAX / 16; int decorSize_x; int decorSize_y; -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(m_widget)) { decorSize_x = 0; decorSize_y = 0; } else -#endif { decorSize_x = m_decorSize.left + m_decorSize.right; decorSize_y = m_decorSize.top + m_decorSize.bottom; @@ -1323,13 +1307,11 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize) if (!IsMaximized() && !IsFullScreen()) GetCachedDecorSize() = decorSize; -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(m_widget)) { m_decorSize = decorSize; return; } -#endif #ifdef GDK_WINDOWING_X11 if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize))) { From 786f778b71849c755cce31eb08972d46770f10a8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 31 Aug 2016 10:39:57 -0700 Subject: [PATCH 10/15] Save and restore GtkStyleContext in a few places that were not doing it Does not fix any known problem, but seems prudent (backport of 5d04f41d47de8161c1653255666e3f4e7b508228) --- src/gtk/control.cpp | 2 ++ src/gtk/window.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index f11b6e80ed..c418af212c 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -250,6 +250,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, stateFlag = GTK_STATE_FLAG_ACTIVE; } GtkStyleContext* sc = gtk_widget_get_style_context(widget); + gtk_style_context_save(sc); GdkRGBA c; gtk_style_context_set_state(sc, stateFlag); gtk_style_context_get_color(sc, stateFlag, &c); @@ -260,6 +261,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, gtk_style_context_get( sc, stateFlag, GTK_STYLE_PROPERTY_FONT, &info.description, NULL); attr.font = wxFont(info); + gtk_style_context_restore(sc); #else GtkStyle* style; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8920d55a22..d27f889f59 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -304,8 +304,10 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) #ifdef __WXGTK3__ GtkStyleContext* sc = gtk_widget_get_style_context(win->m_wxwindow); GdkRGBA c; + gtk_style_context_save(sc); gtk_style_context_set_state(sc, GTK_STATE_FLAG_NORMAL); gtk_style_context_get_border_color(sc, GTK_STATE_FLAG_NORMAL, &c); + gtk_style_context_restore(sc); gdk_cairo_set_source_rgba(cr, &c); cairo_set_line_width(cr, 1); cairo_rectangle(cr, x + 0.5, y + 0.5, w - 1, h - 1); @@ -4444,9 +4446,11 @@ void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3( cairo_pattern_t* pattern = NULL; if (m_backgroundColour.IsOk()) { + gtk_style_context_save(context); gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL); gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, "background-image", &pattern, NULL); + gtk_style_context_restore(context); } if (pattern) { From 48841ad7036e1fb5a049d62e254b08a235af0688 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 31 Aug 2016 10:45:49 -0700 Subject: [PATCH 11/15] Remove incorrect g_object_ref on wxMenuBar Should probably have been removed as part of 9ff9d30 (r55288) (backport of 7986ccf03961b829b38048a0b9575ac29ea306f9) --- src/gtk/frame.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 50b536c44a..bf8a8940eb 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -280,8 +280,6 @@ void wxFrame::DetachMenuBar() #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 hildon_window_set_menu(HILDON_WINDOW(m_widget), NULL); #else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 - g_object_ref( m_frameMenuBar->m_widget ); - gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 } From d4ae8219d9bb3ebf8ef88006bee1c590615c66be Mon Sep 17 00:00:00 2001 From: Pete Bannister Date: Fri, 9 Sep 2016 23:39:20 +0200 Subject: [PATCH 12/15] Fix rendering of owner-drawn multi-column menus in wxMSW Compute the item rectangle bounds correctly for the items in non-first column. See #17072. (cherry picked from commit 61083f4871772b32b5b238342a0347e20522574b) --- docs/changes.txt | 1 + src/msw/menuitem.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index fa28d309df..918ff34326 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -629,6 +629,7 @@ wxGTK: wxMSW: - Fix compilation with g++ 4.9 in non-C++11 mode. +- Fix rendering of owner drawn multi-column menus (Pete Bannister). - Fix regression in accessibility support (Leland Lucius). - Fix regression in wxDC drawing with bottom-to-top y axis (Artur Wieczorek). - Fix compilation with C++Builder XE compiler (Nichka). diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index f845e3b3d3..2d53e1576d 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -873,7 +873,8 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, data->SeparatorMargin.ApplyTo(rcSeparator); RECT rcGutter = rcSelection; - rcGutter.right = data->ItemMargin.cxLeftWidth + rcGutter.right = rcGutter.left + + data->ItemMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth + imgWidth From fcb8497def66efafd5edb3814a7a8d20a2620b55 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Fri, 9 Sep 2016 00:15:55 -0400 Subject: [PATCH 13/15] Document wxHLB_XXX constants for wxHtmlListBox styles Add missing #define's to htmllbox interface header. Closes https://github.com/wxWidgets/wxWidgets/pull/323 (cherry picked from commit de1aff4117b2f0a354a618e35cde6ef97bbe3e50) --- interface/wx/htmllbox.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/wx/htmllbox.h b/interface/wx/htmllbox.h index 2f3cdaee16..651f193b8c 100644 --- a/interface/wx/htmllbox.h +++ b/interface/wx/htmllbox.h @@ -200,6 +200,9 @@ protected: @see wxSimpleHtmlListBox::Create */ +#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN +#define wxHLB_MULTIPLE wxLB_MULTIPLE + class wxSimpleHtmlListBox : public wxHtmlListBox, public wxItemContainer { From 98065821bbf0178981b50515094f565b703fcaa8 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Tue, 13 Sep 2016 13:24:12 +0200 Subject: [PATCH 14/15] 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 0bac1c07a0..f127a74084 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 6b35551647..efc0837431 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 // ---------------------------------------------------------------------------- From 59ef01d95cf3d6aaa1e3ea9f9dd999ebc70baf7d Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Mon, 19 Sep 2016 16:07:17 +0200 Subject: [PATCH 15/15] Do not return empty tokens when parsing XDG_DATA_HOME and XDG_DATA_DIRS. This fixes an assert where wxString::Last would have been called on an empty string. (cherry picked from commit 255b2adea2b5b865e08d83ed06cae3b8863f84a9) --- src/unix/mimetype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 265f86aae0..72c8d4850f 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -561,7 +561,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, } wxArrayString dirs; - wxStringTokenizer tokenizer(xdgDataDirs, ":"); + wxStringTokenizer tokenizer(xdgDataDirs, ":", wxTOKEN_STRTOK); while ( tokenizer.HasMoreTokens() ) { wxString p = tokenizer.GetNextToken();