From c098a03e31e82d29d265a19fb4e79979034940be Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 2 Jan 2007 19:25:33 +0000 Subject: [PATCH] Try to fix #315732, reported by Luke Hutchinson: 2007-01-02 Matthias Clasen Try to fix #315732, reported by Luke Hutchinson: * gdk/x11/xsettings-client.[hc]: * gdk/x11/gdkdevents-x11.c: Don't assume that ref'ing a GdkWindow will guarantee that it can be looked up in the xid hash later. Also, use the nesting server grab function during the xsettings client initialization. Finally, make xsettings client not eat DestroyNotifys so that GDK can do its regular cleanup. svn path=/branches/gtk-2-10/; revision=17023 --- ChangeLog | 11 +++++++++++ gdk/x11/gdkevents-x11.c | 25 ++++++++++--------------- gdk/x11/xsettings-client.c | 23 +++++++++++++++++++---- gdk/x11/xsettings-client.h | 9 ++++++++- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f731587d6..2e7ff909e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-01-02 Matthias Clasen + + Try to fix #315732, reported by Luke Hutchinson: + + * gdk/x11/xsettings-client.[hc]: + * gdk/x11/gdkdevents-x11.c: Don't assume that ref'ing a GdkWindow + will guarantee that it can be looked up in the xid hash later. + Also, use the nesting server grab function during the xsettings + client initialization. Finally, make xsettings client not + eat DestroyNotifys so that GDK can do its regular cleanup. + 2007-01-02 Tor Lillqvist * gtk/gtkrecentchoosermenu.c (gtk_recent_chooser_menu_dispose): diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 52e4aca346..a83051c413 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -18,7 +18,7 @@ */ /* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2007. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. @@ -176,15 +176,13 @@ _gdk_x11_events_init_screen (GdkScreen *screen) /* Keep a flag to avoid extra notifies that we don't need */ screen_x11->xsettings_in_init = TRUE; - screen_x11->xsettings_client = xsettings_client_new (screen_x11->xdisplay, - screen_x11->screen_num, - gdk_xsettings_notify_cb, - gdk_xsettings_watch_cb, - screen); - xsettings_client_set_grab_func (screen_x11->xsettings_client, - refcounted_grab_server); - xsettings_client_set_ungrab_func (screen_x11->xsettings_client, - refcounted_ungrab_server); + screen_x11->xsettings_client = xsettings_client_new_with_grab_funcs (screen_x11->xdisplay, + screen_x11->screen_num, + gdk_xsettings_notify_cb, + gdk_xsettings_watch_cb, + screen, + refcounted_grab_server, + refcounted_ungrab_server); screen_x11->xsettings_in_init = FALSE; } @@ -3008,16 +3006,13 @@ gdk_xsettings_watch_cb (Window window, { if (!gdkwin) gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window); - else - g_object_ref (gdkwin); gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen); } else { - g_assert (gdkwin); - gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen); - g_object_unref (gdkwin); + if (gdkwin) + gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen); } } diff --git a/gdk/x11/xsettings-client.c b/gdk/x11/xsettings-client.c index d0ae1ec885..d17e4213a6 100644 --- a/gdk/x11/xsettings-client.c +++ b/gdk/x11/xsettings-client.c @@ -1,5 +1,5 @@ /* - * Copyright © 2001 Red Hat, Inc. + * Copyright © 2001, 2007 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -454,6 +454,19 @@ xsettings_client_new (Display *display, XSettingsNotifyFunc notify, XSettingsWatchFunc watch, void *cb_data) +{ + return xsettings_client_new_with_grab_funcs (display, screen, notify, watch, cb_data, + NULL, NULL); +} + +XSettingsClient * +xsettings_client_new_with_grab_funcs (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data, + XSettingsGrabFunc grab, + XSettingsGrabFunc ungrab) { XSettingsClient *client; char buffer[256]; @@ -469,8 +482,8 @@ xsettings_client_new (Display *display, client->notify = notify; client->watch = watch; client->cb_data = cb_data; - client->grab = NULL; - client->ungrab = NULL; + client->grab = grab; + client->ungrab = ungrab; client->manager_window = None; client->settings = NULL; @@ -505,6 +518,7 @@ xsettings_client_new (Display *display, return client; } + void xsettings_client_set_grab_func (XSettingsClient *client, XSettingsGrabFunc grab) @@ -571,7 +585,8 @@ xsettings_client_process_event (XSettingsClient *client, if (xev->xany.type == DestroyNotify) { check_manager_window (client); - return True; + /* let GDK do its cleanup */ + return False; } else if (xev->xany.type == PropertyNotify) { diff --git a/gdk/x11/xsettings-client.h b/gdk/x11/xsettings-client.h index b916eba1e0..ba34130107 100644 --- a/gdk/x11/xsettings-client.h +++ b/gdk/x11/xsettings-client.h @@ -1,5 +1,5 @@ /* - * Copyright © 2001 Red Hat, Inc. + * Copyright © 2001, 2007 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -54,6 +54,13 @@ XSettingsClient *xsettings_client_new (Display *display, XSettingsNotifyFunc notify, XSettingsWatchFunc watch, void *cb_data); +XSettingsClient *xsettings_client_new_with_grab_funcs (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data, + XSettingsGrabFunc grab, + XSettingsGrabFunc ungrab); void xsettings_client_set_grab_func (XSettingsClient *client, XSettingsGrabFunc grab); void xsettings_client_set_ungrab_func (XSettingsClient *client,