Applied patch from maemo-gtk that addresses many issues wrt display
2005-11-10 Michael Natterer <mitch@imendio.com> Applied patch from maemo-gtk that addresses many issues wrt display migration and display closing (bug #85715). * gdk/gdkdisplay.c (gdk_display_dispose): don't just set the default display to NULL when it's closed. Instead set the most recently opened display as new default (if one exists). * gdk/gdkpango.c (on_renderer_display_closed): fixed signature of this callback. * gdk/gdkscreen.c (gdk_screen_dispose): check if the GCs still exist before unrefing them. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): if the screen is closed, allow destruction of the root window. * gdk/x11/gdkdisplay-x11.c: moved some stuff from finalize() to dispose(), free stuff that was leaked before. * gdk/x11/gdkevents-x11.c (_gdk_x11_events_uninit_screen): check if the xsettings_client still exists before destroying it. * gdk/x11/gdkkeys-x11.c: added finalization and free the allocated X resources. * gdk/x11/gdkpixmap-x11.c: moved stuff from finalize() to new dispose() implementation. * gdk/x11/gdkscreen-x11.c: moved stuff from finalize() to dispose() and check if it still exists before unrefing it. Set their pointers to NULL/None *after* upchaining in dispose(), because X11 implementations of members of the parent class still need them for their own destruction. * gdk/x11/gdkvisual-x11.c: removed finalize() implementation which was g_error()ing when finalizing a visual. * gtk/gtkclipboard.c (gtk_clipboard_finalize): don't use get_clipboard_widget() because it would create the widget if it doesn't exist. Use g_object_get_data() directly instead. * gtk/gtktextdisplay.c (on_renderer_display_closed): fixed signature of this callback.
This commit is contained in:
committed by
Michael Natterer
parent
1571574ced
commit
8bdc0bf97c
@ -50,9 +50,9 @@
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
|
||||
static void gdk_display_x11_class_init (GdkDisplayX11Class *class);
|
||||
static void gdk_display_x11_dispose (GObject *object);
|
||||
static void gdk_display_x11_finalize (GObject *object);
|
||||
static void gdk_display_x11_class_init (GdkDisplayX11Class *class);
|
||||
static void gdk_display_x11_dispose (GObject *object);
|
||||
static void gdk_display_x11_finalize (GObject *object);
|
||||
|
||||
#ifdef HAVE_X11R6
|
||||
static void gdk_internal_connection_watch (Display *display,
|
||||
@ -717,18 +717,20 @@ gdk_x11_display_ungrab (GdkDisplay * display)
|
||||
static void
|
||||
gdk_display_x11_dispose (GObject *object)
|
||||
{
|
||||
GdkDisplayX11 *display_x11;
|
||||
gint i;
|
||||
|
||||
display_x11 = GDK_DISPLAY_X11 (object);
|
||||
|
||||
for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
|
||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
|
||||
gint n_screens;
|
||||
gint i;
|
||||
|
||||
n_screens = ScreenCount (display_x11->xdisplay);
|
||||
|
||||
for (i = 0; i < n_screens; i++)
|
||||
_gdk_screen_close (display_x11->screens[i]);
|
||||
|
||||
g_source_destroy (display_x11->event_source);
|
||||
|
||||
XCloseDisplay (display_x11->xdisplay);
|
||||
display_x11->xdisplay = NULL;
|
||||
if (display_x11->event_source)
|
||||
{
|
||||
g_source_destroy (display_x11->event_source);
|
||||
display_x11->event_source = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
@ -737,11 +739,13 @@ static void
|
||||
gdk_display_x11_finalize (GObject *object)
|
||||
{
|
||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
|
||||
int i;
|
||||
GList *tmp;
|
||||
/* FIXME need to write GdkKeymap finalize fct
|
||||
g_object_unref (display_x11->keymap);
|
||||
*/
|
||||
gint n_screens;
|
||||
gint i;
|
||||
|
||||
/* Keymap */
|
||||
if (display_x11->keymap)
|
||||
g_object_unref (display_x11->keymap);
|
||||
|
||||
/* Free motif Dnd */
|
||||
if (display_x11->motif_target_lists)
|
||||
{
|
||||
@ -753,30 +757,40 @@ gdk_display_x11_finalize (GObject *object)
|
||||
/* Atom Hashtable */
|
||||
g_hash_table_destroy (display_x11->atom_from_virtual);
|
||||
g_hash_table_destroy (display_x11->atom_to_virtual);
|
||||
|
||||
/* Leader Window */
|
||||
XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
|
||||
|
||||
/* list of filters for client messages */
|
||||
g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
|
||||
g_list_free (display_x11->client_filters);
|
||||
|
||||
/* List of event window extraction functions */
|
||||
g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
|
||||
g_slist_free (display_x11->event_types);
|
||||
|
||||
/* X ID hashtable */
|
||||
g_hash_table_destroy (display_x11->xid_ht);
|
||||
|
||||
/* input GdkDevice list */
|
||||
/* FIXME need to write finalize fct */
|
||||
for (tmp = display_x11->input_devices; tmp; tmp = tmp->next)
|
||||
g_object_unref (tmp->data);
|
||||
g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (display_x11->input_devices);
|
||||
|
||||
/* input GdkWindow list */
|
||||
for (tmp = display_x11->input_windows; tmp; tmp = tmp->next)
|
||||
g_object_unref (tmp->data);
|
||||
g_list_foreach (display_x11->input_windows, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (display_x11->input_windows);
|
||||
|
||||
/* Free all GdkScreens */
|
||||
n_screens = ScreenCount (display_x11->xdisplay);
|
||||
for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
|
||||
g_object_unref (display_x11->screens[i]);
|
||||
g_free (display_x11->screens);
|
||||
|
||||
g_free (display_x11->startup_notification_id);
|
||||
|
||||
|
||||
XCloseDisplay (display_x11->xdisplay);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -852,10 +866,13 @@ _gdk_windowing_set_default_display (GdkDisplay *display)
|
||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
|
||||
const gchar *startup_id;
|
||||
|
||||
if (display)
|
||||
gdk_display = GDK_DISPLAY_XDISPLAY (display);
|
||||
else
|
||||
gdk_display = NULL;
|
||||
if (!display)
|
||||
{
|
||||
gdk_display = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_display = GDK_DISPLAY_XDISPLAY (display);
|
||||
|
||||
g_free (display_x11->startup_notification_id);
|
||||
display_x11->startup_notification_id = NULL;
|
||||
|
||||
@ -193,8 +193,11 @@ _gdk_x11_events_uninit_screen (GdkScreen *screen)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
|
||||
|
||||
xsettings_client_destroy (screen_x11->xsettings_client);
|
||||
screen_x11->xsettings_client = NULL;
|
||||
if (screen_x11->xsettings_client)
|
||||
{
|
||||
xsettings_client_destroy (screen_x11->xsettings_client);
|
||||
screen_x11->xsettings_client = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -53,7 +53,8 @@
|
||||
# endif
|
||||
#endif /* HAVE_XKB */
|
||||
|
||||
typedef struct _GdkKeymapX11 GdkKeymapX11;
|
||||
typedef struct _GdkKeymapX11 GdkKeymapX11;
|
||||
typedef struct _GdkKeymapClass GdkKeymapX11Class;
|
||||
|
||||
#define GDK_TYPE_KEYMAP_X11 (gdk_keymap_x11_get_type ())
|
||||
#define GDK_KEYMAP_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_KEYMAP_X11, GdkKeymapX11))
|
||||
@ -103,8 +104,12 @@ struct _GdkKeymapX11
|
||||
#define KEYMAP_USE_XKB(keymap) GDK_DISPLAY_X11 ((keymap)->display)->use_xkb
|
||||
#define KEYMAP_XDISPLAY(keymap) GDK_DISPLAY_XDISPLAY ((keymap)->display)
|
||||
|
||||
static GType gdk_keymap_x11_get_type (void);
|
||||
static void gdk_keymap_x11_init (GdkKeymapX11 *keymap);
|
||||
static GType gdk_keymap_x11_get_type (void);
|
||||
static void gdk_keymap_x11_class_init (GdkKeymapX11Class *klass);
|
||||
static void gdk_keymap_x11_init (GdkKeymapX11 *keymap);
|
||||
static void gdk_keymap_x11_finalize (GObject *object);
|
||||
|
||||
static GdkKeymapClass *parent_class = NULL;
|
||||
|
||||
static GType
|
||||
gdk_keymap_x11_get_type (void)
|
||||
@ -118,7 +123,7 @@ gdk_keymap_x11_get_type (void)
|
||||
sizeof (GdkKeymapClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) NULL,
|
||||
(GClassInitFunc) gdk_keymap_x11_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GdkKeymapX11),
|
||||
@ -134,6 +139,16 @@ gdk_keymap_x11_get_type (void)
|
||||
return object_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_keymap_x11_class_init (GdkKeymapX11Class *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gdk_keymap_x11_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_keymap_x11_init (GdkKeymapX11 *keymap)
|
||||
{
|
||||
@ -159,6 +174,25 @@ gdk_keymap_x11_init (GdkKeymapX11 *keymap)
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_keymap_x11_finalize (GObject *object)
|
||||
{
|
||||
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (object);
|
||||
|
||||
if (keymap_x11->keymap)
|
||||
XFree (keymap_x11->keymap);
|
||||
|
||||
if (keymap_x11->mod_keymap)
|
||||
XFreeModifiermap (keymap_x11->mod_keymap);
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
if (keymap_x11->xkb_desc)
|
||||
XkbFreeClientMap (keymap_x11->xkb_desc, 0, True);
|
||||
#endif
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static inline void
|
||||
update_keyrange (GdkKeymapX11 *keymap_x11)
|
||||
{
|
||||
|
||||
@ -62,6 +62,7 @@ static void gdk_pixmap_impl_x11_get_size (GdkDrawable *drawable,
|
||||
|
||||
static void gdk_pixmap_impl_x11_init (GdkPixmapImplX11 *pixmap);
|
||||
static void gdk_pixmap_impl_x11_class_init (GdkPixmapImplX11Class *klass);
|
||||
static void gdk_pixmap_impl_x11_dispose (GObject *object);
|
||||
static void gdk_pixmap_impl_x11_finalize (GObject *object);
|
||||
|
||||
static gpointer parent_class = NULL;
|
||||
@ -116,11 +117,30 @@ gdk_pixmap_impl_x11_class_init (GdkPixmapImplX11Class *klass)
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->dispose = gdk_pixmap_impl_x11_dispose;
|
||||
object_class->finalize = gdk_pixmap_impl_x11_finalize;
|
||||
|
||||
drawable_class->get_size = gdk_pixmap_impl_x11_get_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_pixmap_impl_x11_dispose (GObject *object)
|
||||
{
|
||||
GdkPixmapImplX11 *impl = GDK_PIXMAP_IMPL_X11 (object);
|
||||
GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_X11 (impl)->wrapper);
|
||||
GdkDisplay *display = GDK_PIXMAP_DISPLAY (wrapper);
|
||||
|
||||
if (!display->closed)
|
||||
{
|
||||
if (!impl->is_foreign)
|
||||
XFreePixmap (GDK_DISPLAY_XDISPLAY (display), GDK_PIXMAP_XID (wrapper));
|
||||
}
|
||||
|
||||
_gdk_xid_table_remove (display, GDK_PIXMAP_XID (wrapper));
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_pixmap_impl_x11_finalize (GObject *object)
|
||||
{
|
||||
@ -131,16 +151,10 @@ gdk_pixmap_impl_x11_finalize (GObject *object)
|
||||
if (!display->closed)
|
||||
{
|
||||
GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (impl);
|
||||
|
||||
|
||||
_gdk_x11_drawable_finish (GDK_DRAWABLE (draw_impl));
|
||||
|
||||
if (!impl->is_foreign)
|
||||
XFreePixmap (GDK_DISPLAY_XDISPLAY (display), GDK_PIXMAP_XID (wrapper));
|
||||
}
|
||||
|
||||
_gdk_xid_table_remove (display, GDK_PIXMAP_XID (wrapper));
|
||||
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
#include "gdkx.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef HAVE_SOLARIS_XINERAMA
|
||||
#include <X11/extensions/xinerama.h>
|
||||
#endif
|
||||
@ -286,50 +288,60 @@ gdk_screen_x11_dispose (GObject *object)
|
||||
|
||||
_gdk_x11_events_uninit_screen (GDK_SCREEN (object));
|
||||
|
||||
g_object_unref (screen_x11->default_colormap);
|
||||
screen_x11->default_colormap = NULL;
|
||||
if (screen_x11->default_colormap)
|
||||
{
|
||||
g_object_unref (screen_x11->default_colormap);
|
||||
screen_x11->default_colormap = NULL;
|
||||
}
|
||||
|
||||
if (screen_x11->system_colormap)
|
||||
{
|
||||
g_object_unref (screen_x11->system_colormap);
|
||||
screen_x11->system_colormap = NULL;
|
||||
}
|
||||
|
||||
if (screen_x11->rgba_colormap)
|
||||
{
|
||||
g_object_unref (screen_x11->rgba_colormap);
|
||||
screen_x11->rgba_colormap = NULL;
|
||||
}
|
||||
|
||||
screen_x11->root_window = NULL;
|
||||
|
||||
if (screen_x11->root_window)
|
||||
_gdk_window_destroy (screen_x11->root_window, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
|
||||
screen_x11->xdisplay = NULL;
|
||||
screen_x11->xscreen = NULL;
|
||||
screen_x11->screen_num = -1;
|
||||
screen_x11->xroot_window = None;
|
||||
screen_x11->wmspec_check_window = None;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_screen_x11_finalize (GObject *object)
|
||||
{
|
||||
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (object);
|
||||
/* int i; */
|
||||
g_object_unref (screen_x11->root_window);
|
||||
gint i;
|
||||
|
||||
if (screen_x11->root_window)
|
||||
g_object_unref (screen_x11->root_window);
|
||||
|
||||
if (screen_x11->renderer)
|
||||
g_object_unref (screen_x11->renderer);
|
||||
|
||||
/* Visual Part (Need to implement finalize for Visuals for a clean
|
||||
* finalize) */
|
||||
/* for (i=0;i<screen_x11->nvisuals;i++)
|
||||
g_object_unref (screen_x11->visuals[i]);*/
|
||||
|
||||
/* Visual Part */
|
||||
for (i = 0; i < screen_x11->nvisuals; i++)
|
||||
g_object_unref (screen_x11->visuals[i]);
|
||||
g_free (screen_x11->visuals);
|
||||
g_hash_table_destroy (screen_x11->visual_hash);
|
||||
|
||||
g_free (screen_x11->window_manager_name);
|
||||
g_free (screen_x11->window_manager_name);
|
||||
|
||||
g_hash_table_destroy (screen_x11->colormap_hash);
|
||||
/* X settings */
|
||||
g_free (screen_x11->xsettings_client);
|
||||
|
||||
g_free (screen_x11->monitors);
|
||||
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
@ -63,19 +63,6 @@ static const gchar *const visual_names[] =
|
||||
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
static void
|
||||
gdk_visual_finalize (GObject *object)
|
||||
{
|
||||
g_error ("A GdkVisual object was finalized. This should not happen");
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_visual_class_init (GObjectClass *class)
|
||||
{
|
||||
class->finalize = gdk_visual_finalize;
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
gdk_visual_get_type (void)
|
||||
{
|
||||
@ -88,7 +75,7 @@ gdk_visual_get_type (void)
|
||||
sizeof (GdkVisualClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gdk_visual_class_init,
|
||||
(GClassInitFunc) NULL,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GdkVisualPrivate),
|
||||
@ -605,7 +592,7 @@ gdk_visual_add (GdkVisual *visual)
|
||||
|
||||
if (!screen_x11->visual_hash)
|
||||
screen_x11->visual_hash = g_hash_table_new ((GHashFunc) gdk_visual_hash,
|
||||
(GEqualFunc) gdk_visual_equal);
|
||||
(GEqualFunc) gdk_visual_equal);
|
||||
|
||||
g_hash_table_insert (screen_x11->visual_hash, private->xvisual, visual);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user