diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 113b5bb7d5..1990a731d2 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -451,6 +451,19 @@ gtk_frame_window_state_callback( GtkWidget* WXUNUSED(widget), } } +//----------------------------------------------------------------------------- +// "notify::gtk-theme-name" from GtkSettings +//----------------------------------------------------------------------------- + +extern "C" { +static void notify_gtk_theme_name(GObject*, GParamSpec*, wxTopLevelWindowGTK* win) +{ + wxSysColourChangedEvent event; + event.SetEventObject(win); + win->HandleWindowEvent(event); +} +} + //----------------------------------------------------------------------------- bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom) @@ -801,6 +814,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, gtk_widget_set_size_request(m_widget, w, h); } + g_signal_connect(gtk_settings_get_default(), "notify::gtk-theme-name", + G_CALLBACK(notify_gtk_theme_name), this); + return true; } @@ -838,6 +854,9 @@ wxTopLevelWindowGTK::~wxTopLevelWindowGTK() if (g_activeFrame == this) g_activeFrame = NULL; + + g_signal_handlers_disconnect_by_func( + gtk_settings_get_default(), (void*)notify_gtk_theme_name, this); } bool wxTopLevelWindowGTK::EnableCloseButton( bool enable ) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 30fcf6e099..79cdcfa490 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2050,21 +2050,6 @@ gtk_window_grab_broken( GtkWidget*, } #endif -//----------------------------------------------------------------------------- -// "style_set"/"style_updated" -//----------------------------------------------------------------------------- - -#ifdef __WXGTK3__ -static void style_updated(GtkWidget*, wxWindow* win) -#else -static void style_updated(GtkWidget*, GtkStyle*, wxWindow* win) -#endif -{ - wxSysColourChangedEvent event; - event.SetEventObject(win); - win->GTKProcessEvent(event); -} - //----------------------------------------------------------------------------- // "unrealize" //----------------------------------------------------------------------------- @@ -2167,21 +2152,6 @@ void wxWindowGTK::GTKHandleRealized() GTKProcessEvent( event ); GTKUpdateCursor(false, true); - - if (m_wxwindow && isTopLevel) - { - // attaching to style changed signal after realization avoids initial - // changes we don't care about - const gchar *detailed_signal = -#ifdef __WXGTK3__ - "style_updated"; -#else - "style_set"; -#endif - g_signal_connect(m_wxwindow, - detailed_signal, - G_CALLBACK(style_updated), this); - } } void wxWindowGTK::GTKHandleUnrealize() @@ -2190,12 +2160,6 @@ void wxWindowGTK::GTKHandleUnrealize() { if (m_imContext) gtk_im_context_set_client_window(m_imContext, NULL); - - if (IsTopLevel()) - { - g_signal_handlers_disconnect_by_func( - m_wxwindow, (void*)style_updated, this); - } } } @@ -4480,24 +4444,7 @@ void wxWindowGTK::GTKApplyWidgetStyle(bool forceStyle) void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style) { GtkWidget* widget = m_wxwindow ? m_wxwindow : m_widget; - - // block the signal temporarily to avoid sending - // wxSysColourChangedEvents when we change the colours ourselves - bool unblock = false; - if (m_wxwindow && IsTopLevel()) - { - unblock = true; - g_signal_handlers_block_by_func( - m_wxwindow, (void*)style_updated, this); - } - GTKApplyStyle(widget, style); - - if (unblock) - { - g_signal_handlers_unblock_by_func( - m_wxwindow, (void*)style_updated, this); - } } void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3(style))