From 49fe8f03990133cbbaef9033ed25cb52936886f9 Mon Sep 17 00:00:00 2001 From: Jayaraj Rajappan Date: Fri, 24 May 2002 02:55:54 +0000 Subject: [PATCH] fix for bugzilla bug #72314, filter out LeaveNotify caused by grabs when 2002-05-23 Jayaraj Rajappan * src/display.c (event_callback): fix for bugzilla bug #72314, filter out LeaveNotify caused by grabs when in mouse focus mode. --- ChangeLog | 5 +++ src/display.c | 4 ++- src/frames.c | 60 ++++++++++++++++++++--------------- src/metacity.schemas | 27 +++------------- src/prefs.c | 75 +++++++------------------------------------- src/prefs.h | 3 -- src/preview-widget.c | 2 +- src/theme.c | 6 +++- src/theme.h | 3 +- 9 files changed, 67 insertions(+), 118 deletions(-) diff --git a/ChangeLog b/ChangeLog index 977b963a2..13a5fb452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-05-23 Jayaraj Rajappan + + * src/display.c (event_callback): fix for bugzilla bug #72314, + filter out LeaveNotify caused by grabs when in mouse focus mode. + 2002-05-23 Havoc Pennington * src/metacity.schemas: clean up the font preference diff --git a/src/display.c b/src/display.c index 739a54500..605f39a21 100644 --- a/src/display.c +++ b/src/display.c @@ -1158,7 +1158,9 @@ event_callback (XEvent *event, * is probably right. Anyway, unfocus the * focused window. */ - if (window->has_focus) + if (window->has_focus && + event->xcrossing.mode != NotifyGrab && + event->xcrossing.mode != NotifyUngrab) { meta_verbose ("Unsetting focus from %s due to LeaveNotify\n", window->desc); diff --git a/src/frames.c b/src/frames.c index 7ab338060..d699d81f4 100644 --- a/src/frames.c +++ b/src/frames.c @@ -26,6 +26,7 @@ #include "menu.h" #include "fixedtip.h" #include "theme.h" +#include "prefs.h" #define DEFAULT_INNER_BUTTON_BORDER 3 @@ -68,6 +69,7 @@ static void meta_frames_ensure_layout (MetaFrames *frames, static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames, Window xwindow); +static void meta_frames_font_changed (MetaFrames *frames); static GdkRectangle* control_rect (MetaFrameControl control, MetaFrameGeometry *fgeom); @@ -154,6 +156,16 @@ unsigned_long_hash (gconstpointer v) #endif } +static void +font_changed_callback (MetaPreference pref, + void *data) +{ + if (pref == META_PREF_TITLEBAR_FONT) + { + meta_frames_font_changed (META_FRAMES (data)); + } +} + static void meta_frames_init (MetaFrames *frames) { @@ -168,6 +180,8 @@ meta_frames_init (MetaFrames *frames) frames->expose_delay_count = 0; gtk_widget_set_double_buffered (GTK_WIDGET (frames), FALSE); + + meta_prefs_add_listener (font_changed_callback, frames); } static void @@ -188,6 +202,8 @@ meta_frames_destroy (GtkObject *object) frames = META_FRAMES (object); + meta_prefs_remove_listener (font_changed_callback, frames); + clear_tip (frames); winlist = NULL; @@ -258,13 +274,8 @@ queue_recalc_func (gpointer key, gpointer value, gpointer data) } static void -meta_frames_style_set (GtkWidget *widget, - GtkStyle *prev_style) +meta_frames_font_changed (MetaFrames *frames) { - MetaFrames *frames; - - frames = META_FRAMES (widget); - if (g_hash_table_size (frames->text_heights) > 0) { g_hash_table_destroy (frames->text_heights); @@ -275,6 +286,18 @@ meta_frames_style_set (GtkWidget *widget, g_hash_table_foreach (frames->frames, queue_recalc_func, frames); +} + +static void +meta_frames_style_set (GtkWidget *widget, + GtkStyle *prev_style) +{ + MetaFrames *frames; + + frames = META_FRAMES (widget); + + meta_frames_font_changed (frames); + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); } @@ -326,7 +349,8 @@ meta_frames_ensure_layout (MetaFrames *frames, frame->layout = gtk_widget_create_pango_layout (widget, frame->title); - font_desc = meta_gtk_widget_get_font_desc (widget, scale); + font_desc = meta_gtk_widget_get_font_desc (widget, scale, + meta_prefs_get_titlebar_font ()); size = pango_font_description_get_size (font_desc); @@ -346,25 +370,9 @@ meta_frames_ensure_layout (MetaFrames *frames, &size, GINT_TO_POINTER (frame->text_height)); } - - if (pango_font_description_get_size (font_desc) != - pango_font_description_get_size (widget->style->font_desc)) - { - PangoAttrList *attrs; - PangoAttribute *attr; - - attrs = pango_attr_list_new (); - - attr = pango_attr_size_new (pango_font_description_get_size (font_desc)); - attr->start_index = 0; - attr->end_index = G_MAXINT; - - pango_attr_list_insert (attrs, attr); - - pango_layout_set_attributes (frame->layout, attrs); - - pango_attr_list_unref (attrs); - } + + pango_layout_set_font_description (frame->layout, + font_desc); pango_font_description_free (font_desc); diff --git a/src/metacity.schemas b/src/metacity.schemas index 04660ee52..6f6439433 100644 --- a/src/metacity.schemas +++ b/src/metacity.schemas @@ -69,16 +69,16 @@ - /schemas/apps/metacity/general/titlebar_uses_desktop_font - /apps/metacity/general/titlebar_uses_desktop_font + /schemas/apps/metacity/general/titlebar_uses_system_font + /apps/metacity/general/titlebar_uses_system_font metacity bool true - Use standard desktop font in window titles + Use standard system font in window titles - If true, ignore the titlebar_font and titlebar_font_size - options, and use the standard application font for window + If true, ignore the titlebar_font + option, and use the standard application font for window titles. @@ -105,23 +105,6 @@ - - /schemas/apps/metacity/general/titlebar_font_size - /apps/metacity/general/titlebar_font_size - metacity - int - 0 - - Window title font size - - The size of the font used in window titlebars, in points. - If set to 0, the size comes from the titlebar_font option - or from the desktop-wide default. If set to nonzero, - overrides those sizes. - - - - /schemas/apps/metacity/general/num_workspaces /apps/metacity/general/num_workspaces diff --git a/src/prefs.c b/src/prefs.c index 49071eb22..bb7a0d969 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -33,9 +33,8 @@ #define KEY_AUTO_RAISE "/apps/metacity/general/auto_raise" #define KEY_AUTO_RAISE_DELAY "/apps/metacity/general/auto_raise_delay" #define KEY_THEME "/apps/metacity/general/theme" -#define KEY_USE_DESKTOP_FONT "/apps/metacity/general/titlebar_uses_desktop_font" +#define KEY_USE_SYSTEM_FONT "/apps/metacity/general/titlebar_uses_system_font" #define KEY_TITLEBAR_FONT "/apps/metacity/general/titlebar_font" -#define KEY_TITLEBAR_FONT_SIZE "/apps/metacity/general/titlebar_font_size" #define KEY_NUM_WORKSPACES "/apps/metacity/general/num_workspaces" #define KEY_APPLICATION_BASED "/apps/metacity/general/application_based" #define KEY_DISABLE_WORKAROUNDS "/apps/metacity/general/disable_workarounds" @@ -47,9 +46,8 @@ static GConfClient *default_client = NULL; static GList *listeners = NULL; static GList *changes = NULL; static guint changed_idle; -static gboolean use_desktop_font = TRUE; +static gboolean use_system_font = TRUE; static PangoFontDescription *titlebar_font = NULL; -static int titlebar_font_size = 0; static MetaFocusMode focus_mode = META_FOCUS_MODE_CLICK; static char* current_theme = NULL; static int num_workspaces = 4; @@ -58,9 +56,8 @@ static gboolean disable_workarounds = FALSE; static gboolean auto_raise = FALSE; static gboolean auto_raise_delay = 500; -static gboolean update_use_desktop_font (gboolean value); +static gboolean update_use_system_font (gboolean value); static gboolean update_titlebar_font (const char *value); -static gboolean update_titlebar_font_size (int value); static gboolean update_focus_mode (const char *value); static gboolean update_theme (const char *value); static gboolean update_num_workspaces (int value); @@ -259,15 +256,10 @@ meta_prefs_init (void) * just lazy. But they keys ought to be set, anyhow. */ - bool_val = gconf_client_get_bool (default_client, KEY_USE_DESKTOP_FONT, + bool_val = gconf_client_get_bool (default_client, KEY_USE_SYSTEM_FONT, &err); cleanup_error (&err); - update_use_desktop_font (bool_val); - - int_val = gconf_client_get_int (default_client, KEY_TITLEBAR_FONT_SIZE, - &err); - cleanup_error (&err); - update_titlebar_font_size (int_val); + update_use_system_font (bool_val); str_val = gconf_client_get_string (default_client, KEY_TITLEBAR_FONT, &err); @@ -382,30 +374,14 @@ change_notify (GConfClient *client, if (update_titlebar_font (str)) queue_changed (META_PREF_TITLEBAR_FONT); } - else if (strcmp (key, KEY_TITLEBAR_FONT_SIZE) == 0) - { - int d; - - if (value && value->type != GCONF_VALUE_INT) - { - meta_warning (_("GConf key \"%s\" is set to an invalid type\n"), - KEY_TITLEBAR_FONT_SIZE); - goto out; - } - - d = value ? gconf_value_get_int (value) : 0; - - if (update_titlebar_font_size (d)) - queue_changed (META_PREF_TITLEBAR_FONT_SIZE); - } - else if (strcmp (key, KEY_USE_DESKTOP_FONT) == 0) + else if (strcmp (key, KEY_USE_SYSTEM_FONT) == 0) { gboolean b; if (value && value->type != GCONF_VALUE_BOOL) { meta_warning (_("GConf key \"%s\" is set to an invalid type\n"), - KEY_USE_DESKTOP_FONT); + KEY_USE_SYSTEM_FONT); goto out; } @@ -415,7 +391,7 @@ change_notify (GConfClient *client, * get_titlebar_font returns NULL, so that's what we queue * the change on */ - if (update_use_desktop_font (b)) + if (update_use_system_font (b)) queue_changed (META_PREF_TITLEBAR_FONT); } else if (strcmp (key, KEY_NUM_WORKSPACES) == 0) @@ -606,11 +582,11 @@ meta_prefs_get_theme (void) } static gboolean -update_use_desktop_font (gboolean value) +update_use_system_font (gboolean value) { - gboolean old = use_desktop_font; + gboolean old = use_system_font; - use_desktop_font = value; + use_system_font = value; return old != value; } @@ -650,36 +626,12 @@ update_titlebar_font (const char *value) const PangoFontDescription* meta_prefs_get_titlebar_font (void) { - if (use_desktop_font) + if (use_system_font) return NULL; else return titlebar_font; } -static gboolean -update_titlebar_font_size (int value) -{ - int old = titlebar_font_size; - - if (value < 0) - { - meta_warning (_("%d stored in GConf key %s is not a valid font size\n"), - value, KEY_TITLEBAR_FONT_SIZE); - value = 0; - } - - titlebar_font_size = value; - - return old != titlebar_font_size; -} - -int -meta_prefs_get_titlebar_font_size (void) -{ - return titlebar_font_size; -} - - #define MAX_REASONABLE_WORKSPACES 32 static gboolean @@ -795,9 +747,6 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_TITLEBAR_FONT: return "TITLEBAR_FONT"; - case META_PREF_TITLEBAR_FONT_SIZE: - return "TITLEBAR_FONT_SIZE"; - case META_PREF_NUM_WORKSPACES: return "NUM_WORKSPACES"; diff --git a/src/prefs.h b/src/prefs.h index 6226e25de..bcd369b6e 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -33,7 +33,6 @@ typedef enum META_PREF_AUTO_RAISE_DELAY, META_PREF_THEME, META_PREF_TITLEBAR_FONT, - META_PREF_TITLEBAR_FONT_SIZE, META_PREF_NUM_WORKSPACES, META_PREF_APPLICATION_BASED, META_PREF_WINDOW_KEYBINDINGS, @@ -56,8 +55,6 @@ MetaFocusMode meta_prefs_get_focus_mode (void); const char* meta_prefs_get_theme (void); /* returns NULL if GTK default should be used */ const PangoFontDescription* meta_prefs_get_titlebar_font (void); -/* returns 0 if default should be used */ -int meta_prefs_get_titlebar_font_size (void); int meta_prefs_get_num_workspaces (void); gboolean meta_prefs_get_application_based (void); gboolean meta_prefs_get_disable_workarounds (void); diff --git a/src/preview-widget.c b/src/preview-widget.c index a6809ef95..6acac0bba 100644 --- a/src/preview-widget.c +++ b/src/preview-widget.c @@ -143,7 +143,7 @@ ensure_info (MetaPreview *preview) preview->layout = gtk_widget_create_pango_layout (widget, preview->title); - font_desc = meta_gtk_widget_get_font_desc (widget, scale); + font_desc = meta_gtk_widget_get_font_desc (widget, scale, NULL); preview->text_height = meta_pango_font_desc_get_text_height (font_desc, diff --git a/src/theme.c b/src/theme.c index d9ae527f3..1c106cffb 100644 --- a/src/theme.c +++ b/src/theme.c @@ -4671,7 +4671,8 @@ meta_theme_lookup_float_constant (MetaTheme *theme, PangoFontDescription* meta_gtk_widget_get_font_desc (GtkWidget *widget, - double scale) + double scale, + const PangoFontDescription *override) { PangoFontDescription *font_desc; @@ -4679,6 +4680,9 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget, font_desc = pango_font_description_copy (widget->style->font_desc); + if (override) + pango_font_description_merge (font_desc, override, TRUE); + pango_font_description_set_size (font_desc, MAX (pango_font_description_get_size (font_desc) * scale, 1)); diff --git a/src/theme.h b/src/theme.h index 79f9ca4df..eb54d74d8 100644 --- a/src/theme.h +++ b/src/theme.h @@ -742,7 +742,8 @@ char* meta_theme_replace_constants (MetaTheme *theme, /* random stuff */ PangoFontDescription* meta_gtk_widget_get_font_desc (GtkWidget *widget, - double scale); + double scale, + const PangoFontDescription *override); int meta_pango_font_desc_get_text_height (PangoFontDescription *font_desc, PangoContext *context);