Make gtk_widget_set_extension_events() work on already realized widgets

2007-03-14  Michael Natterer  <mitch@imendio.com>

	Make gtk_widget_set_extension_events() work on already realized
	widgets (bug #379550, Tommi Komulainen)

	* gdk/x11/gdkinput.c (gdk_input_set_extension_events): allow to be
	called multiple times without leaking and work correctly when
	already realized (don't rely on a configure event following).

	* gtk/gtkwidget.c (gtk_widget_set_extension_events_internal): new
	internal function which walks the GdkWindow tree and sets the
	extension events on all windows that belong to the widget.

	(gtk_widget_realize)
	(gtk_widget_set_extension_events): use the new function.


svn path=/trunk/; revision=17515
This commit is contained in:
Michael Natterer
2007-03-14 13:55:12 +00:00
committed by Michael Natterer
parent 86ea351bd7
commit d953ce8775
3 changed files with 93 additions and 25 deletions

View File

@ -313,29 +313,42 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
iw = _gdk_input_window_find (window);
if (mask != 0)
{
iw = g_new(GdkInputWindow,1);
if (!iw)
{
iw = g_new(GdkInputWindow,1);
iw->window = window;
iw->mode = mode;
iw->window = window;
iw->mode = mode;
iw->obscuring = NULL;
iw->num_obscuring = 0;
iw->grabbed = FALSE;
iw->obscuring = NULL;
iw->num_obscuring = 0;
iw->grabbed = FALSE;
display_x11->input_windows = g_list_append(display_x11->input_windows,iw);
}
display_x11->input_windows = g_list_append(display_x11->input_windows,iw);
window_private->extension_events = mask;
#ifndef XINPUT_NONE
/* Add enter window events to the event mask */
/* FIXME, this is not needed for XINPUT_NONE */
/* this is not needed for XINPUT_NONE */
gdk_window_set_events (window,
gdk_window_get_events (window) |
GDK_ENTER_NOTIFY_MASK);
/* we might not receive ConfigureNotify so get the root_relative_geometry
* now, just in case */
_gdk_input_get_root_relative_geometry (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XWINDOW (window),
&iw->root_x, &iw->root_y, NULL, NULL);
#endif /* !XINPUT_NONE */
}
else
{
iw = _gdk_input_window_find (window);
if (iw)
{
display_x11->input_windows = g_list_remove(display_x11->input_windows,iw);