Commit 8bdc0bf9 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

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.
parent 1571574c
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.
2005-11-10 Simos Xenitellis <simos@gnome.org>
* configure.in: Added Tatar (tt) to ALL_LINGUAS.
......
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.
2005-11-10 Simos Xenitellis <simos@gnome.org>
* configure.in: Added Tatar (tt) to ALL_LINGUAS.
......
......@@ -175,7 +175,14 @@ gdk_display_dispose (GObject *object)
_gdk_displays = g_slist_remove (_gdk_displays, object);
if (gdk_display_get_default() == display)
gdk_display_manager_set_default_display (gdk_display_manager_get(), NULL);
{
if (_gdk_displays)
gdk_display_manager_set_default_display (gdk_display_manager_get(),
_gdk_displays->data);
else
gdk_display_manager_set_default_display (gdk_display_manager_get(),
NULL);
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
......
......@@ -541,6 +541,7 @@ gdk_pango_renderer_new (GdkScreen *screen)
static void
on_renderer_display_closed (GdkDisplay *display,
gboolean is_error,
GdkPangoRenderer *renderer)
{
g_signal_handlers_disconnect_by_func (renderer->priv->screen,
......
......@@ -152,10 +152,16 @@ gdk_screen_dispose (GObject *object)
for (i = 0; i < 32; ++i)
{
if (screen->exposure_gcs[i])
g_object_unref (screen->exposure_gcs[i]);
{
g_object_unref (screen->exposure_gcs[i]);
screen->exposure_gcs[i] = NULL;
}
if (screen->normal_gcs[i])
g_object_unref (screen->normal_gcs[i]);
{
g_object_unref (screen->normal_gcs[i]);
screen->normal_gcs[i] = NULL;
}
}
G_OBJECT_CLASS (parent_class)->dispose (object);
......
......@@ -339,6 +339,7 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
GdkWindowObject *private;
GdkWindowObject *temp_private;
GdkWindow *temp_window;
GdkScreen *screen;
GList *children;
GList *tmp;
......@@ -351,6 +352,14 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
switch (GDK_WINDOW_TYPE (window))
{
case GDK_WINDOW_ROOT:
screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
if (!screen->closed)
{
g_error ("attempted to destroy root window");
break;
}
/* else fall thru */
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_CHILD:
case GDK_WINDOW_DIALOG:
......@@ -426,10 +435,6 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
gdk_drawable_set_colormap (GDK_DRAWABLE (window), NULL);
}
break;
case GDK_WINDOW_ROOT:
g_error ("attempted to destroy root window");
break;
}
}
......
......@@ -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++)
_gdk_screen_close (display_x11->screens[i]);
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (object);
gint n_screens;
gint i;
g_source_destroy (display_x11->event_source);
n_screens = ScreenCount (display_x11->xdisplay);
XCloseDisplay (display_x11->xdisplay);
display_x11->xdisplay = NULL;
for (i = 0; i < n_screens; i++)
_gdk_screen_close (display_x11->screens[i]);
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);
}
......
......@@ -203,20 +203,21 @@ gtk_clipboard_finalize (GObject *object)
if (g_slist_index (clipboards, clipboard) >= 0)
g_warning ("GtkClipboard prematurely finalized");
clipboard_widget = get_clipboard_widget (clipboard->display);
/* don't use get_clipboard_widget() here because it would create the
* widget if it doesn't exist.
*/
clipboard_widget = g_object_get_data (G_OBJECT (clipboard->display),
"gtk-clipboard-widget");
clipboard_unset (clipboard);
clipboards = g_object_get_data (G_OBJECT (clipboard->display), "gtk-clipboard-list");
clipboards = g_slist_remove (clipboards, clipboard);
g_object_set_data (G_OBJECT (clipboard->display), I_("gtk-clipboard-list"), clipboards);
if (g_main_loop_is_running (clipboard->store_loop))
{
g_main_loop_quit (clipboard->store_loop);
g_main_loop_unref (clipboard->store_loop);
}
if (clipboard->store_loop && g_main_loop_is_running (clipboard->store_loop))
g_main_loop_quit (clipboard->store_loop);
if (clipboard->store_timeout != 0)
g_source_remove (clipboard->store_timeout);
......
......@@ -647,6 +647,7 @@ render_para (GtkTextRenderer *text_renderer,
static void
on_renderer_display_closed (GdkDisplay *display,
gboolean is_error,
GtkTextRenderer *text_renderer)
{
g_signal_handlers_disconnect_by_func (text_renderer->screen,
......@@ -671,8 +672,9 @@ get_text_renderer (GdkScreen *screen)
g_object_set_data_full (G_OBJECT (screen), I_("gtk-text-renderer"), text_renderer,
(GDestroyNotify)g_object_unref);
g_signal_connect (gdk_screen_get_display (screen), "closed",
G_CALLBACK (on_renderer_display_closed), text_renderer);
g_signal_connect_object (gdk_screen_get_display (screen), "closed",
G_CALLBACK (on_renderer_display_closed),
text_renderer, 0);
}
return text_renderer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment