Change the XSettingsWatchFunc to return a Bool to indicate success. Update
2007-04-10 Matthias Clasen <mclasen@redhat.com> * gdk/x11/xsettings-client.[hc]: Change the XSettingsWatchFunc to return a Bool to indicate success. Update callers and implementors. Based on a patch by Owen Taylor. * gdk/x11/gdkevents-x11.c (gdk_xsettings_watch_cb): Don't leak a reference to gdkwin. svn path=/trunk/; revision=17592
This commit is contained in:
committed by
Matthias Clasen
parent
1b0bbc8773
commit
3b95bc271d
@ -1,3 +1,12 @@
|
|||||||
|
2007-04-10 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/x11/xsettings-client.[hc]: Change the XSettingsWatchFunc
|
||||||
|
to return a Bool to indicate success. Update callers and
|
||||||
|
implementors. Based on a patch by Owen Taylor.
|
||||||
|
|
||||||
|
* gdk/x11/gdkevents-x11.c (gdk_xsettings_watch_cb): Don't
|
||||||
|
leak a reference to gdkwin.
|
||||||
|
|
||||||
2007-04-07 Xan Lopez <xan@gnome.org>
|
2007-04-07 Xan Lopez <xan@gnome.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.c (gtk_notebook_class_init):
|
* gtk/gtknotebook.c (gtk_notebook_class_init):
|
||||||
|
|||||||
@ -111,7 +111,7 @@ static GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
|
|||||||
static GSource *gdk_display_source_new (GdkDisplay *display);
|
static GSource *gdk_display_source_new (GdkDisplay *display);
|
||||||
static gboolean gdk_check_xpending (GdkDisplay *display);
|
static gboolean gdk_check_xpending (GdkDisplay *display);
|
||||||
|
|
||||||
static void gdk_xsettings_watch_cb (Window window,
|
static Bool gdk_xsettings_watch_cb (Window window,
|
||||||
Bool is_start,
|
Bool is_start,
|
||||||
long mask,
|
long mask,
|
||||||
void *cb_data);
|
void *cb_data);
|
||||||
@ -2993,7 +2993,7 @@ gdk_xsettings_client_event_filter (GdkXEvent *xevent,
|
|||||||
return GDK_FILTER_CONTINUE;
|
return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Bool
|
||||||
gdk_xsettings_watch_cb (Window window,
|
gdk_xsettings_watch_cb (Window window,
|
||||||
Bool is_start,
|
Bool is_start,
|
||||||
long mask,
|
long mask,
|
||||||
@ -3006,16 +3006,39 @@ gdk_xsettings_watch_cb (Window window,
|
|||||||
|
|
||||||
if (is_start)
|
if (is_start)
|
||||||
{
|
{
|
||||||
if (!gdkwin)
|
if (gdkwin)
|
||||||
gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
|
g_object_ref (gdkwin);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window);
|
||||||
|
|
||||||
|
/* gdk_window_foreign_new_for_display() can fail and return NULL if the
|
||||||
|
* window has already been destroyed.
|
||||||
|
*/
|
||||||
|
if (!gdkwin)
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
|
gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gdkwin)
|
if (!gdkwin)
|
||||||
gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
|
{
|
||||||
|
/* gdkwin should not be NULL here, since if starting the watch succeeded
|
||||||
|
* we have a reference on the window. It might mean that the caller didn't
|
||||||
|
* remove the watch when it got a DestroyNotify event. Or maybe the
|
||||||
|
* caller ignored the return value when starting the watch failed.
|
||||||
|
*/
|
||||||
|
g_warning ("gdk_xsettings_watch_cb(): Couldn't find window to unwatch");
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_window_remove_filter (gdkwin, gdk_xsettings_client_event_filter, screen);
|
||||||
|
g_object_unref (gdkwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __GDK_EVENTS_X11_C__
|
#define __GDK_EVENTS_X11_C__
|
||||||
|
|||||||
@ -441,9 +441,19 @@ check_manager_window (XSettingsClient *client)
|
|||||||
XFlush (client->display);
|
XFlush (client->display);
|
||||||
|
|
||||||
if (client->manager_window && client->watch)
|
if (client->manager_window && client->watch)
|
||||||
client->watch (client->manager_window, True,
|
{
|
||||||
PropertyChangeMask | StructureNotifyMask,
|
if (!client->watch (client->manager_window, True,
|
||||||
client->cb_data);
|
PropertyChangeMask | StructureNotifyMask,
|
||||||
|
client->cb_data))
|
||||||
|
{
|
||||||
|
/* Inability to watch the window probably means that it was destroyed
|
||||||
|
* after we ungrabbed
|
||||||
|
*/
|
||||||
|
client->manager_window = None;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
read_settings (client);
|
read_settings (client);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ typedef void (*XSettingsNotifyFunc) (const char *name,
|
|||||||
XSettingsAction action,
|
XSettingsAction action,
|
||||||
XSettingsSetting *setting,
|
XSettingsSetting *setting,
|
||||||
void *cb_data);
|
void *cb_data);
|
||||||
typedef void (*XSettingsWatchFunc) (Window window,
|
typedef Bool (*XSettingsWatchFunc) (Window window,
|
||||||
Bool is_start,
|
Bool is_start,
|
||||||
long mask,
|
long mask,
|
||||||
void *cb_data);
|
void *cb_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user