Use "notify::gtk-theme-name" from GtkSettings to generate wxSysColourChangedEvent
"style-updated" occurs frequently for other reasons, such as switching focus between TLWs
(cherry picked from commit 61c8a7ca60
)
This commit is contained in:
@@ -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)
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,6 +854,9 @@ wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
|||||||
|
|
||||||
if (g_activeFrame == this)
|
if (g_activeFrame == this)
|
||||||
g_activeFrame = NULL;
|
g_activeFrame = NULL;
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func(
|
||||||
|
gtk_settings_get_default(), (void*)notify_gtk_theme_name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowGTK::EnableCloseButton( bool enable )
|
bool wxTopLevelWindowGTK::EnableCloseButton( bool enable )
|
||||||
|
@@ -2050,21 +2050,6 @@ gtk_window_grab_broken( GtkWidget*,
|
|||||||
}
|
}
|
||||||
#endif
|
#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"
|
// "unrealize"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -2167,21 +2152,6 @@ void wxWindowGTK::GTKHandleRealized()
|
|||||||
GTKProcessEvent( event );
|
GTKProcessEvent( event );
|
||||||
|
|
||||||
GTKUpdateCursor(false, true);
|
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()
|
void wxWindowGTK::GTKHandleUnrealize()
|
||||||
@@ -2190,12 +2160,6 @@ void wxWindowGTK::GTKHandleUnrealize()
|
|||||||
{
|
{
|
||||||
if (m_imContext)
|
if (m_imContext)
|
||||||
gtk_im_context_set_client_window(m_imContext, NULL);
|
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)
|
void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
|
||||||
{
|
{
|
||||||
GtkWidget* widget = m_wxwindow ? m_wxwindow : m_widget;
|
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);
|
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))
|
void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3(style))
|
||||||
|
Reference in New Issue
Block a user