From 46ae09156b61da418a3ffa9ced166a19a70ca488 Mon Sep 17 00:00:00 2001 From: Dom Lachowicz Date: Sat, 11 Mar 2006 18:06:19 +0000 Subject: [PATCH] Speed up the Windows theme considerably (#163724, John Ehresman) Be more 2006-03-11 Dom Lachowicz * modules/engines/ms-windows: Speed up the Windows theme considerably (#163724, John Ehresman) Be more careful about setting Pango font descriptions (#333372) --- ChangeLog | 6 +++++ ChangeLog.pre-2-10 | 6 +++++ modules/engines/ms-windows/msw_style.c | 8 +++--- modules/engines/ms-windows/msw_theme_main.c | 29 ++++++++++++++++++-- modules/engines/ms-windows/xp_theme.c | 30 ++++++++++++--------- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4c6ff8350..8ec3966934 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-11 Dom Lachowicz + + * modules/engines/ms-windows: Speed up the Windows theme + considerably (#163724, John Ehresman) + Be more careful about setting Pango font descriptions (#333372) + 2006-03-10 Federico Mena Quintero Merged from HEAD: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a4c6ff8350..8ec3966934 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2006-03-11 Dom Lachowicz + + * modules/engines/ms-windows: Speed up the Windows theme + considerably (#163724, John Ehresman) + Be more careful about setting Pango font descriptions (#333372) + 2006-03-10 Federico Mena Quintero Merged from HEAD: diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c index 10a9f18e12..93d7e998c9 100755 --- a/modules/engines/ms-windows/msw_style.c +++ b/modules/engines/ms-windows/msw_style.c @@ -39,8 +39,8 @@ #include "gtk/gtk.h" #include "gtk/gtk.h" -/* #include */ +/* #include */ #include "gdk/win32/gdkwin32.h" @@ -464,8 +464,10 @@ sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char *buf, pt_size = 10; font = get_family_name (&lf, hDC); - g_snprintf (buf, bufsiz, "%s %s %s %d", font, style, weight, - pt_size); + if(!(font && *font)) + return NULL; + + g_snprintf (buf, bufsiz, "%s %s %s %d", font, style, weight, pt_size); g_free (font); return buf; diff --git a/modules/engines/ms-windows/msw_theme_main.c b/modules/engines/ms-windows/msw_theme_main.c index 9301f4f8e2..4cabf54dcb 100755 --- a/modules/engines/ms-windows/msw_theme_main.c +++ b/modules/engines/ms-windows/msw_theme_main.c @@ -36,6 +36,28 @@ static GModule *this_module = NULL; static void (*msw_rc_reset_styles) (GtkSettings * settings) = NULL; +static GdkWindow* hidden_msg_window = NULL; + +static GdkWindow* +create_hidden_msg_window (void) +{ + GdkWindowAttr attributes; + gint attributes_mask; + + attributes.x = -100; + attributes.y = -100; + attributes.width = 10; + attributes.height = 10; + attributes.window_type = GDK_WINDOW_TEMP; + attributes.wclass = GDK_INPUT_ONLY; + attributes.override_redirect = TRUE; + attributes.event_mask = 0; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR; + + return gdk_window_new (gdk_get_default_root_window (), + &attributes, attributes_mask); +} static GdkFilterReturn global_filter_func (void *xevent, GdkEvent * event, gpointer data) @@ -88,13 +110,16 @@ theme_init (GTypeModule * module) } msw_style_init (); - gdk_window_add_filter (NULL, global_filter_func, NULL); + hidden_msg_window = create_hidden_msg_window (); + gdk_window_add_filter (hidden_msg_window, global_filter_func, NULL); } G_MODULE_EXPORT void theme_exit (void) { - gdk_window_remove_filter (NULL, global_filter_func, NULL); + gdk_window_remove_filter (hidden_msg_window, global_filter_func, NULL); + gdk_window_destroy (hidden_msg_window); + hidden_msg_window = NULL; if (this_module) { diff --git a/modules/engines/ms-windows/xp_theme.c b/modules/engines/ms-windows/xp_theme.c index 43d59c477f..b96467b6af 100755 --- a/modules/engines/ms-windows/xp_theme.c +++ b/modules/engines/ms-windows/xp_theme.c @@ -153,6 +153,7 @@ static const short element_part_map[] = { static HINSTANCE uxtheme_dll = NULL; static HTHEME open_themes[XP_THEME_CLASS__SIZEOF]; +static gboolean use_xp_theme = FALSE; typedef HRESULT (FAR PASCAL * GetThemeSysFontFunc) (HTHEME hTheme, int iFontID, OUT LOGFONT * plf); @@ -254,12 +255,26 @@ xp_theme_init (void) (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground"); } + + if (is_app_themed_func && is_theme_active_func) { + use_xp_theme = (is_app_themed_func () && is_theme_active_func ()); + } + else { + use_xp_theme = FALSE; + } } void xp_theme_reset (void) { xp_theme_close_open_handles (); + + if (is_app_themed_func && is_theme_active_func) { + use_xp_theme = (is_app_themed_func () && is_theme_active_func ()); + } + else { + use_xp_theme = FALSE; + } } void @@ -272,6 +287,7 @@ xp_theme_exit (void) FreeLibrary (uxtheme_dll); uxtheme_dll = NULL; + use_xp_theme = FALSE; is_app_themed_func = NULL; is_theme_active_func = NULL; @@ -838,19 +854,7 @@ xp_theme_draw (GdkWindow * win, XpThemeElement element, GtkStyle * style, gboolean xp_theme_is_active (void) { - gboolean active = FALSE; - - if (is_app_themed_func) - { - active = (*is_app_themed_func) (); - - if (active && is_theme_active_func) - { - active = (*is_theme_active_func) (); - } - } - - return active; + return use_xp_theme; } gboolean