GtkPlug: move public members to private structures

This commit is contained in:
Javier Jardón 2010-08-23 21:29:13 +02:00
parent af8efa0b46
commit e8184f2a46
4 changed files with 139 additions and 91 deletions

View File

@ -80,7 +80,9 @@ _gtk_plug_windowing_unmap_toplevel (GtkPlug *plug)
void void
_gtk_plug_windowing_set_focus (GtkPlug *plug) _gtk_plug_windowing_set_focus (GtkPlug *plug)
{ {
_gtk_xembed_send_message (plug->socket_window, GtkPlugPrivate *priv = plug->priv;
_gtk_xembed_send_message (priv->socket_window,
XEMBED_REQUEST_FOCUS, 0, 0, 0); XEMBED_REQUEST_FOCUS, 0, 0, 0);
} }
@ -89,7 +91,9 @@ _gtk_plug_windowing_add_grabbed_key (GtkPlug *plug,
guint accelerator_key, guint accelerator_key,
GdkModifierType accelerator_mods) GdkModifierType accelerator_mods)
{ {
_gtk_xembed_send_message (plug->socket_window, XEMBED_GTK_GRAB_KEY, 0, GtkPlugPrivate *priv = plug->priv;
_gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_GRAB_KEY, 0,
accelerator_key, accelerator_mods); accelerator_key, accelerator_mods);
} }
@ -98,7 +102,9 @@ _gtk_plug_windowing_remove_grabbed_key (GtkPlug *plug,
guint accelerator_key, guint accelerator_key,
GdkModifierType accelerator_mods) GdkModifierType accelerator_mods)
{ {
_gtk_xembed_send_message (plug->socket_window, XEMBED_GTK_UNGRAB_KEY, 0, GtkPlugPrivate *priv = plug->priv;
_gtk_xembed_send_message (priv->socket_window, XEMBED_GTK_UNGRAB_KEY, 0,
accelerator_key, accelerator_mods); accelerator_key, accelerator_mods);
} }
@ -106,6 +112,7 @@ void
_gtk_plug_windowing_focus_to_parent (GtkPlug *plug, _gtk_plug_windowing_focus_to_parent (GtkPlug *plug,
GtkDirectionType direction) GtkDirectionType direction)
{ {
GtkPlugPrivate *priv = plug->priv;
XEmbedMessageType message = XEMBED_FOCUS_PREV; /* Quiet GCC */ XEmbedMessageType message = XEMBED_FOCUS_PREV; /* Quiet GCC */
switch (direction) switch (direction)
@ -121,8 +128,8 @@ _gtk_plug_windowing_focus_to_parent (GtkPlug *plug,
message = XEMBED_FOCUS_NEXT; message = XEMBED_FOCUS_NEXT;
break; break;
} }
_gtk_xembed_send_focus_message (plug->socket_window, message, 0); _gtk_xembed_send_focus_message (priv->socket_window, message, 0);
} }
static void static void
@ -219,6 +226,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
GdkScreen *screen = gdk_drawable_get_screen (event->any.window); GdkScreen *screen = gdk_drawable_get_screen (event->any.window);
GdkDisplay *display = gdk_screen_get_display (screen); GdkDisplay *display = gdk_screen_get_display (screen);
GtkPlug *plug = GTK_PLUG (data); GtkPlug *plug = GTK_PLUG (data);
GtkPlugPrivate *priv = plug->priv;
XEvent *xevent = (XEvent *)gdk_xevent; XEvent *xevent = (XEvent *)gdk_xevent;
GdkFilterReturn return_val; GdkFilterReturn return_val;
@ -253,7 +261,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
case ReparentNotify: case ReparentNotify:
{ {
XReparentEvent *xre = &xevent->xreparent; XReparentEvent *xre = &xevent->xreparent;
gboolean was_embedded = plug->socket_window != NULL; gboolean was_embedded = priv->socket_window != NULL;
GTK_NOTE (PLUGSOCKET, g_message("GtkPlug: ReparentNotify received")); GTK_NOTE (PLUGSOCKET, g_message("GtkPlug: ReparentNotify received"));
@ -270,14 +278,14 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
* then add to a local window before we get notification * then add to a local window before we get notification
* Probably need check in _gtk_plug_add_to_socket * Probably need check in _gtk_plug_add_to_socket
*/ */
if (xre->parent != GDK_WINDOW_XWINDOW (plug->socket_window)) if (xre->parent != GDK_WINDOW_XWINDOW (priv->socket_window))
{ {
GtkWidget *widget = GTK_WIDGET (plug); GtkWidget *widget = GTK_WIDGET (plug);
gdk_window_set_user_data (plug->socket_window, NULL); gdk_window_set_user_data (priv->socket_window, NULL);
g_object_unref (plug->socket_window); g_object_unref (priv->socket_window);
plug->socket_window = NULL; priv->socket_window = NULL;
/* Emit a delete window, as if the user attempted /* Emit a delete window, as if the user attempted
* to close the toplevel. Simple as to how we * to close the toplevel. Simple as to how we
@ -305,25 +313,26 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
/* Start of embedding protocol */ /* Start of embedding protocol */
GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding")); GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding"));
plug->socket_window = gdk_window_lookup_for_display (display, xre->parent);
if (plug->socket_window) priv->socket_window = gdk_window_lookup_for_display (display, xre->parent);
if (priv->socket_window)
{ {
gpointer user_data = NULL; gpointer user_data = NULL;
gdk_window_get_user_data (plug->socket_window, &user_data); gdk_window_get_user_data (priv->socket_window, &user_data);
if (user_data) if (user_data)
{ {
g_warning (G_STRLOC "Plug reparented unexpectedly into window in the same process"); g_warning (G_STRLOC "Plug reparented unexpectedly into window in the same process");
plug->socket_window = NULL; priv->socket_window = NULL;
break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */
} }
g_object_ref (plug->socket_window); g_object_ref (priv->socket_window);
} }
else else
{ {
plug->socket_window = gdk_window_foreign_new_for_display (display, xre->parent); priv->socket_window = gdk_window_foreign_new_for_display (display, xre->parent);
if (!plug->socket_window) /* Already gone */ if (!priv->socket_window) /* Already gone */
break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */
} }

View File

@ -109,14 +109,15 @@ gtk_plug_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkPlug *plug = GTK_PLUG (object); GtkPlug *plug = GTK_PLUG (object);
GtkPlugPrivate *priv = plug->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_EMBEDDED: case PROP_EMBEDDED:
g_value_set_boolean (value, plug->socket_window != NULL); g_value_set_boolean (value, priv->socket_window != NULL);
break; break;
case PROP_SOCKET_WINDOW: case PROP_SOCKET_WINDOW:
g_value_set_object (value, plug->socket_window); g_value_set_object (value, priv->socket_window);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -200,14 +201,18 @@ gtk_plug_class_init (GtkPlugClass *class)
NULL, NULL, NULL, NULL,
_gtk_marshal_VOID__VOID, _gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
g_type_class_add_private (class, sizeof (GtkPlugPrivate));
} }
static void static void
gtk_plug_init (GtkPlug *plug) gtk_plug_init (GtkPlug *plug)
{ {
GtkWindow *window; GtkWindow *window = GTK_WINDOW (plug);
window = GTK_WINDOW (plug); plug->priv = G_TYPE_INSTANCE_GET_PRIVATE (plug,
GTK_TYPE_PLUG,
GtkPlugPrivate);
window->type = GTK_WINDOW_TOPLEVEL; window->type = GTK_WINDOW_TOPLEVEL;
} }
@ -216,20 +221,21 @@ static void
gtk_plug_set_is_child (GtkPlug *plug, gtk_plug_set_is_child (GtkPlug *plug,
gboolean is_child) gboolean is_child)
{ {
GtkPlugPrivate *priv = plug->priv;
GtkWidget *widget = GTK_WIDGET (plug); GtkWidget *widget = GTK_WIDGET (plug);
g_assert (!gtk_widget_get_parent (widget)); g_assert (!gtk_widget_get_parent (widget));
if (is_child) if (is_child)
{ {
if (plug->modality_window) if (priv->modality_window)
_gtk_plug_handle_modality_off (plug); _gtk_plug_handle_modality_off (plug);
if (plug->modality_group) if (priv->modality_group)
{ {
gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug)); gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug));
g_object_unref (plug->modality_group); g_object_unref (priv->modality_group);
plug->modality_group = NULL; priv->modality_group = NULL;
} }
/* As a toplevel, the MAPPED flag doesn't correspond /* As a toplevel, the MAPPED flag doesn't correspond
@ -251,10 +257,10 @@ gtk_plug_set_is_child (GtkPlug *plug,
gtk_window_set_focus (GTK_WINDOW (plug), NULL); gtk_window_set_focus (GTK_WINDOW (plug), NULL);
if (GTK_WINDOW (plug)->default_widget) if (GTK_WINDOW (plug)->default_widget)
gtk_window_set_default (GTK_WINDOW (plug), NULL); gtk_window_set_default (GTK_WINDOW (plug), NULL);
plug->modality_group = gtk_window_group_new (); priv->modality_group = gtk_window_group_new ();
gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug)); gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (plug));
_gtk_window_set_is_toplevel (GTK_WINDOW (plug), TRUE); _gtk_window_set_is_toplevel (GTK_WINDOW (plug), TRUE);
gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE); gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE);
@ -298,7 +304,7 @@ gtk_plug_get_embedded (GtkPlug *plug)
{ {
g_return_val_if_fail (GTK_IS_PLUG (plug), FALSE); g_return_val_if_fail (GTK_IS_PLUG (plug), FALSE);
return plug->socket_window != NULL; return plug->priv->socket_window != NULL;
} }
/** /**
@ -316,7 +322,7 @@ gtk_plug_get_socket_window (GtkPlug *plug)
{ {
g_return_val_if_fail (GTK_IS_PLUG (plug), NULL); g_return_val_if_fail (GTK_IS_PLUG (plug), NULL);
return plug->socket_window; return plug->priv->socket_window;
} }
/** /**
@ -330,6 +336,7 @@ void
_gtk_plug_add_to_socket (GtkPlug *plug, _gtk_plug_add_to_socket (GtkPlug *plug,
GtkSocket *socket_) GtkSocket *socket_)
{ {
GtkPlugPrivate *priv;
GtkWidget *widget; GtkWidget *widget;
gint w, h; gint w, h;
@ -337,15 +344,16 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
g_return_if_fail (GTK_IS_SOCKET (socket_)); g_return_if_fail (GTK_IS_SOCKET (socket_));
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (socket_))); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (socket_)));
priv = plug->priv;
widget = GTK_WIDGET (plug); widget = GTK_WIDGET (plug);
gtk_plug_set_is_child (plug, TRUE); gtk_plug_set_is_child (plug, TRUE);
plug->same_app = TRUE; priv->same_app = TRUE;
socket_->same_app = TRUE; socket_->same_app = TRUE;
socket_->plug_widget = widget; socket_->plug_widget = widget;
plug->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_)); priv->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_));
g_object_ref (plug->socket_window); g_object_ref (priv->socket_window);
g_signal_emit (plug, plug_signals[EMBEDDED], 0); g_signal_emit (plug, plug_signals[EMBEDDED], 0);
g_object_notify (G_OBJECT (plug), "embedded"); g_object_notify (G_OBJECT (plug), "embedded");
@ -355,7 +363,7 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h); gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h);
gdk_window_reparent (window, plug->socket_window, -w, -h); gdk_window_reparent (window, priv->socket_window, -w, -h);
} }
gtk_widget_set_parent (widget, GTK_WIDGET (socket_)); gtk_widget_set_parent (widget, GTK_WIDGET (socket_));
@ -400,6 +408,7 @@ void
_gtk_plug_remove_from_socket (GtkPlug *plug, _gtk_plug_remove_from_socket (GtkPlug *plug,
GtkSocket *socket_) GtkSocket *socket_)
{ {
GtkPlugPrivate *priv;
GtkWidget *widget; GtkWidget *widget;
GdkWindow *window; GdkWindow *window;
gboolean result; gboolean result;
@ -409,6 +418,7 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
g_return_if_fail (GTK_IS_SOCKET (socket_)); g_return_if_fail (GTK_IS_SOCKET (socket_));
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (plug))); g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (plug)));
priv = plug->priv;
widget = GTK_WIDGET (plug); widget = GTK_WIDGET (plug);
if (GTK_WIDGET_IN_REPARENT (widget)) if (GTK_WIDGET_IN_REPARENT (widget))
@ -437,11 +447,11 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
socket_->same_app = FALSE; socket_->same_app = FALSE;
plug->same_app = FALSE; priv->same_app = FALSE;
if (plug->socket_window != NULL) if (priv->socket_window != NULL)
{ {
g_object_unref (plug->socket_window); g_object_unref (priv->socket_window);
plug->socket_window = NULL; priv->socket_window = NULL;
} }
gtk_plug_set_is_child (plug, FALSE); gtk_plug_set_is_child (plug, FALSE);
@ -493,14 +503,21 @@ gtk_plug_construct_for_display (GtkPlug *plug,
GdkDisplay *display, GdkDisplay *display,
GdkNativeWindow socket_id) GdkNativeWindow socket_id)
{ {
GtkPlugPrivate *priv;
g_return_if_fail (GTK_IS_PLUG (plug));
g_return_if_fail (GDK_IS_DISPLAY (display));
priv = plug->priv;
if (socket_id) if (socket_id)
{ {
gpointer user_data = NULL; gpointer user_data = NULL;
plug->socket_window = gdk_window_lookup_for_display (display, socket_id); priv->socket_window = gdk_window_lookup_for_display (display, socket_id);
if (plug->socket_window) if (priv->socket_window)
{ {
gdk_window_get_user_data (plug->socket_window, &user_data); gdk_window_get_user_data (priv->socket_window, &user_data);
if (user_data) if (user_data)
{ {
@ -509,16 +526,16 @@ gtk_plug_construct_for_display (GtkPlug *plug,
else else
{ {
g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket"); g_warning (G_STRLOC "Can't create GtkPlug as child of non-GtkSocket");
plug->socket_window = NULL; priv->socket_window = NULL;
} }
} }
else else
g_object_ref (plug->socket_window); g_object_ref (priv->socket_window);
} }
else else
plug->socket_window = gdk_window_foreign_new_for_display (display, socket_id); priv->socket_window = gdk_window_foreign_new_for_display (display, socket_id);
if (plug->socket_window) { if (priv->socket_window) {
g_signal_emit (plug, plug_signals[EMBEDDED], 0); g_signal_emit (plug, plug_signals[EMBEDDED], 0);
g_object_notify (G_OBJECT (plug), "embedded"); g_object_notify (G_OBJECT (plug), "embedded");
@ -559,6 +576,8 @@ gtk_plug_new_for_display (GdkDisplay *display,
{ {
GtkPlug *plug; GtkPlug *plug;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
plug = g_object_new (GTK_TYPE_PLUG, NULL); plug = g_object_new (GTK_TYPE_PLUG, NULL);
gtk_plug_construct_for_display (plug, display, socket_id); gtk_plug_construct_for_display (plug, display, socket_id);
return GTK_WIDGET (plug); return GTK_WIDGET (plug);
@ -568,11 +587,12 @@ static void
gtk_plug_finalize (GObject *object) gtk_plug_finalize (GObject *object)
{ {
GtkPlug *plug = GTK_PLUG (object); GtkPlug *plug = GTK_PLUG (object);
GtkPlugPrivate *priv = plug->priv;
if (plug->grabbed_keys) if (priv->grabbed_keys)
{ {
g_hash_table_destroy (plug->grabbed_keys); g_hash_table_destroy (priv->grabbed_keys);
plug->grabbed_keys = NULL; priv->grabbed_keys = NULL;
} }
G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object);
@ -582,23 +602,24 @@ static void
gtk_plug_unrealize (GtkWidget *widget) gtk_plug_unrealize (GtkWidget *widget)
{ {
GtkPlug *plug = GTK_PLUG (widget); GtkPlug *plug = GTK_PLUG (widget);
GtkPlugPrivate *priv = plug->priv;
if (plug->socket_window != NULL) if (priv->socket_window != NULL)
{ {
gdk_window_set_user_data (plug->socket_window, NULL); gdk_window_set_user_data (priv->socket_window, NULL);
g_object_unref (plug->socket_window); g_object_unref (priv->socket_window);
plug->socket_window = NULL; priv->socket_window = NULL;
g_object_notify (G_OBJECT (widget), "embedded"); g_object_notify (G_OBJECT (widget), "embedded");
} }
if (!plug->same_app) if (!priv->same_app)
{ {
if (plug->modality_window) if (priv->modality_window)
_gtk_plug_handle_modality_off (plug); _gtk_plug_handle_modality_off (plug);
gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug)); gtk_window_group_remove_window (priv->modality_group, GTK_WINDOW (plug));
g_object_unref (plug->modality_group); g_object_unref (priv->modality_group);
} }
GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize (widget); GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize (widget);
@ -609,6 +630,7 @@ gtk_plug_realize (GtkWidget *widget)
{ {
GtkAllocation allocation; GtkAllocation allocation;
GtkPlug *plug = GTK_PLUG (widget); GtkPlug *plug = GTK_PLUG (widget);
GtkPlugPrivate *priv = plug->priv;
GtkWindow *window = GTK_WINDOW (widget); GtkWindow *window = GTK_WINDOW (widget);
GdkWindow *gdk_window; GdkWindow *gdk_window;
GdkWindowAttr attributes; GdkWindowAttr attributes;
@ -647,8 +669,8 @@ gtk_plug_realize (GtkWidget *widget)
attributes.window_type = GDK_WINDOW_TOPLEVEL; attributes.window_type = GDK_WINDOW_TOPLEVEL;
gdk_error_trap_push (); gdk_error_trap_push ();
if (plug->socket_window) if (priv->socket_window)
gdk_window = gdk_window_new (plug->socket_window, gdk_window = gdk_window_new (priv->socket_window,
&attributes, attributes_mask); &attributes, attributes_mask);
else /* If it's a passive plug, we use the root window */ else /* If it's a passive plug, we use the root window */
gdk_window = gdk_window_new (gtk_widget_get_root_window (widget), gdk_window = gdk_window_new (gtk_widget_get_root_window (widget),
@ -671,9 +693,9 @@ gtk_plug_realize (GtkWidget *widget)
_gtk_plug_windowing_filter_func, _gtk_plug_windowing_filter_func,
widget); widget);
plug->modality_group = gtk_window_group_new (); priv->modality_group = gtk_window_group_new ();
gtk_window_group_add_window (plug->modality_group, window); gtk_window_group_add_window (priv->modality_group, window);
_gtk_plug_windowing_realize_toplevel (plug); _gtk_plug_windowing_realize_toplevel (plug);
} }
else else
@ -867,9 +889,10 @@ add_grabbed_key (gpointer key, gpointer val, gpointer data)
{ {
GrabbedKey *grabbed_key = key; GrabbedKey *grabbed_key = key;
GtkPlug *plug = data; GtkPlug *plug = data;
GtkPlugPrivate *priv = plug->priv;
if (!plug->grabbed_keys || if (!priv->grabbed_keys ||
!g_hash_table_lookup (plug->grabbed_keys, grabbed_key)) !g_hash_table_lookup (priv->grabbed_keys, grabbed_key))
{ {
_gtk_plug_windowing_add_grabbed_key (plug, _gtk_plug_windowing_add_grabbed_key (plug,
grabbed_key->accelerator_key, grabbed_key->accelerator_key,
@ -901,8 +924,10 @@ add_grabbed_key_always (gpointer key,
void void
_gtk_plug_add_all_grabbed_keys (GtkPlug *plug) _gtk_plug_add_all_grabbed_keys (GtkPlug *plug)
{ {
if (plug->grabbed_keys) GtkPlugPrivate *priv = plug->priv;
g_hash_table_foreach (plug->grabbed_keys, add_grabbed_key_always, plug);
if (priv->grabbed_keys)
g_hash_table_foreach (priv->grabbed_keys, add_grabbed_key_always, plug);
} }
static void static void
@ -910,9 +935,10 @@ remove_grabbed_key (gpointer key, gpointer val, gpointer data)
{ {
GrabbedKey *grabbed_key = key; GrabbedKey *grabbed_key = key;
GtkPlug *plug = data; GtkPlug *plug = data;
GtkPlugPrivate *priv = plug->priv;
if (!plug->grabbed_keys || if (!priv->grabbed_keys ||
!g_hash_table_lookup (plug->grabbed_keys, grabbed_key)) !g_hash_table_lookup (priv->grabbed_keys, grabbed_key))
{ {
_gtk_plug_windowing_remove_grabbed_key (plug, _gtk_plug_windowing_remove_grabbed_key (plug,
grabbed_key->accelerator_key, grabbed_key->accelerator_key,
@ -947,19 +973,20 @@ gtk_plug_keys_changed (GtkWindow *window)
{ {
GHashTable *new_grabbed_keys, *old_grabbed_keys; GHashTable *new_grabbed_keys, *old_grabbed_keys;
GtkPlug *plug = GTK_PLUG (window); GtkPlug *plug = GTK_PLUG (window);
GtkPlugPrivate *priv = plug->priv;
new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)grabbed_key_free, NULL); new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)grabbed_key_free, NULL);
_gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys); _gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys);
if (plug->socket_window) if (priv->socket_window)
g_hash_table_foreach (new_grabbed_keys, add_grabbed_key, plug); g_hash_table_foreach (new_grabbed_keys, add_grabbed_key, plug);
old_grabbed_keys = plug->grabbed_keys; old_grabbed_keys = priv->grabbed_keys;
plug->grabbed_keys = new_grabbed_keys; priv->grabbed_keys = new_grabbed_keys;
if (old_grabbed_keys) if (old_grabbed_keys)
{ {
if (plug->socket_window) if (priv->socket_window)
g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug); g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug);
g_hash_table_destroy (old_grabbed_keys); g_hash_table_destroy (old_grabbed_keys);
} }
@ -1032,14 +1059,16 @@ gtk_plug_check_resize (GtkContainer *container)
void void
_gtk_plug_handle_modality_on (GtkPlug *plug) _gtk_plug_handle_modality_on (GtkPlug *plug)
{ {
if (!plug->modality_window) GtkPlugPrivate *priv = plug->priv;
if (!priv->modality_window)
{ {
plug->modality_window = gtk_window_new (GTK_WINDOW_POPUP); priv->modality_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (plug->modality_window), gtk_window_set_screen (GTK_WINDOW (priv->modality_window),
gtk_widget_get_screen (GTK_WIDGET (plug))); gtk_widget_get_screen (GTK_WIDGET (plug)));
gtk_widget_realize (plug->modality_window); gtk_widget_realize (priv->modality_window);
gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug->modality_window)); gtk_window_group_add_window (priv->modality_group, GTK_WINDOW (priv->modality_window));
gtk_grab_add (plug->modality_window); gtk_grab_add (priv->modality_window);
} }
} }
@ -1054,10 +1083,12 @@ _gtk_plug_handle_modality_on (GtkPlug *plug)
void void
_gtk_plug_handle_modality_off (GtkPlug *plug) _gtk_plug_handle_modality_off (GtkPlug *plug)
{ {
if (plug->modality_window) GtkPlugPrivate *priv = plug->priv;
if (priv->modality_window)
{ {
gtk_widget_destroy (plug->modality_window); gtk_widget_destroy (priv->modality_window);
plug->modality_window = NULL; priv->modality_window = NULL;
} }
} }

View File

@ -45,20 +45,16 @@ G_BEGIN_DECLS
#define GTK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLUG, GtkPlugClass)) #define GTK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLUG, GtkPlugClass))
typedef struct _GtkPlug GtkPlug; typedef struct _GtkPlug GtkPlug;
typedef struct _GtkPlugClass GtkPlugClass; typedef struct _GtkPlugPrivate GtkPlugPrivate;
typedef struct _GtkPlugClass GtkPlugClass;
struct _GtkPlug struct _GtkPlug
{ {
GtkWindow window; GtkWindow window;
GdkWindow *GSEAL (socket_window); GtkPlugPrivate *priv;
GtkWidget *GSEAL (modality_window);
GtkWindowGroup *GSEAL (modality_group);
GHashTable *GSEAL (grabbed_keys);
guint GSEAL (same_app) : 1;
}; };
struct _GtkPlugClass struct _GtkPlugClass

View File

@ -26,6 +26,18 @@
#ifndef __GTK_PLUG_PRIVATE_H__ #ifndef __GTK_PLUG_PRIVATE_H__
#define __GTK_PLUG_PRIVATE_H__ #define __GTK_PLUG_PRIVATE_H__
struct _GtkPlugPrivate
{
GtkWidget *modality_window;
GtkWindowGroup *modality_group;
GdkWindow *socket_window;
GHashTable *grabbed_keys;
guint same_app : 1;
};
/* In gtkplug.c: */ /* In gtkplug.c: */
void _gtk_plug_send_delete_event (GtkWidget *widget); void _gtk_plug_send_delete_event (GtkWidget *widget);
void _gtk_plug_add_all_grabbed_keys (GtkPlug *plug); void _gtk_plug_add_all_grabbed_keys (GtkPlug *plug);