[gtk+] Remove sealed members from GtkSocket
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Remove sealed members from GtkSocket
- Date: Sat, 18 Dec 2010 22:42:45 +0000 (UTC)
commit 5ee3a444152cc45c9fa921079de96e776bf53af3
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 18 00:45:13 2010 -0500
Remove sealed members from GtkSocket
gtk/gtkplug.c | 15 ++--
gtk/gtksocket-x11.c | 125 +++++++++++++------------
gtk/gtksocket.c | 239 ++++++++++++++++++++++++-----------------------
gtk/gtksocket.h | 20 +----
gtk/gtksocketprivate.h | 59 ++++++++----
5 files changed, 234 insertions(+), 224 deletions(-)
---
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index fc63c8c..65326d9 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -33,6 +33,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkplugprivate.h"
+#include "gtksocketprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
@@ -346,8 +347,8 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
gtk_plug_set_is_child (plug, TRUE);
priv->same_app = TRUE;
- socket_->same_app = TRUE;
- socket_->plug_widget = widget;
+ socket_->priv->same_app = TRUE;
+ socket_->priv->plug_widget = widget;
priv->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_));
g_object_ref (priv->socket_window);
@@ -436,14 +437,14 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
gtk_widget_unparent (GTK_WIDGET (plug));
_gtk_widget_set_in_reparent (widget, FALSE);
- socket_->plug_widget = NULL;
- if (socket_->plug_window != NULL)
+ socket_->priv->plug_widget = NULL;
+ if (socket_->priv->plug_window != NULL)
{
- g_object_unref (socket_->plug_window);
- socket_->plug_window = NULL;
+ g_object_unref (socket_->priv->plug_window);
+ socket_->priv->plug_window = NULL;
}
- socket_->same_app = FALSE;
+ socket_->priv->same_app = FALSE;
priv->same_app = FALSE;
if (priv->socket_window != NULL)
diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c
index 83cdc5c..692e083 100644
--- a/gtk/gtksocket-x11.c
+++ b/gtk/gtksocket-x11.c
@@ -91,36 +91,37 @@ void
_gtk_socket_windowing_end_embedding_toplevel (GtkSocket *socket)
{
gtk_window_remove_embedded_xid (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))),
- GDK_WINDOW_XID (socket->plug_window));
+ GDK_WINDOW_XID (socket->priv->plug_window));
}
void
_gtk_socket_windowing_size_request (GtkSocket *socket)
{
+ GtkSocketPrivate *private = socket->priv;
XSizeHints hints;
long supplied;
gdk_error_trap_push ();
- socket->request_width = 1;
- socket->request_height = 1;
+ private->request_width = 1;
+ private->request_height = 1;
- if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (socket->plug_window),
- GDK_WINDOW_XID (socket->plug_window),
+ if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (private->plug_window),
+ GDK_WINDOW_XID (private->plug_window),
&hints, &supplied))
{
if (hints.flags & PMinSize)
{
- socket->request_width = MAX (hints.min_width, 1);
- socket->request_height = MAX (hints.min_height, 1);
+ private->request_width = MAX (hints.min_width, 1);
+ private->request_height = MAX (hints.min_height, 1);
}
else if (hints.flags & PBaseSize)
{
- socket->request_width = MAX (hints.base_width, 1);
- socket->request_height = MAX (hints.base_height, 1);
+ private->request_width = MAX (hints.base_width, 1);
+ private->request_height = MAX (hints.base_height, 1);
}
}
- socket->have_size = TRUE;
+ private->have_size = TRUE;
gdk_error_trap_pop_ignored ();
}
@@ -131,11 +132,11 @@ _gtk_socket_windowing_send_key_event (GtkSocket *socket,
gboolean mask_key_presses)
{
XKeyEvent xkey;
- GdkScreen *screen = gdk_window_get_screen (socket->plug_window);
+ GdkScreen *screen = gdk_window_get_screen (socket->priv->plug_window);
memset (&xkey, 0, sizeof (xkey));
xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
- xkey.window = GDK_WINDOW_XID (socket->plug_window);
+ xkey.window = GDK_WINDOW_XID (socket->priv->plug_window);
xkey.root = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
xkey.subwindow = None;
xkey.time = gdk_event->key.time;
@@ -148,8 +149,8 @@ _gtk_socket_windowing_send_key_event (GtkSocket *socket,
xkey.same_screen = True;/* FIXME ? */
gdk_error_trap_push ();
- XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window),
- GDK_WINDOW_XID (socket->plug_window),
+ XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window),
+ GDK_WINDOW_XID (socket->priv->plug_window),
False,
(mask_key_presses ? KeyPressMask : NoEventMask),
(XEvent *)&xkey);
@@ -161,10 +162,10 @@ _gtk_socket_windowing_focus_change (GtkSocket *socket,
gboolean focus_in)
{
if (focus_in)
- _gtk_xembed_send_focus_message (socket->plug_window,
+ _gtk_xembed_send_focus_message (socket->priv->plug_window,
XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
else
- _gtk_xembed_send_message (socket->plug_window,
+ _gtk_xembed_send_message (socket->priv->plug_window,
XEMBED_FOCUS_OUT, 0, 0, 0);
}
@@ -172,7 +173,7 @@ void
_gtk_socket_windowing_update_active (GtkSocket *socket,
gboolean active)
{
- _gtk_xembed_send_message (socket->plug_window,
+ _gtk_xembed_send_message (socket->priv->plug_window,
active ? XEMBED_WINDOW_ACTIVATE : XEMBED_WINDOW_DEACTIVATE,
0, 0, 0);
}
@@ -181,7 +182,7 @@ void
_gtk_socket_windowing_update_modality (GtkSocket *socket,
gboolean modality)
{
- _gtk_xembed_send_message (socket->plug_window,
+ _gtk_xembed_send_message (socket->priv->plug_window,
modality ? XEMBED_MODALITY_ON : XEMBED_MODALITY_OFF,
0, 0, 0);
}
@@ -206,7 +207,7 @@ _gtk_socket_windowing_focus (GtkSocket *socket,
break;
}
- _gtk_xembed_send_focus_message (socket->plug_window, XEMBED_FOCUS_IN, detail);
+ _gtk_xembed_send_focus_message (socket->priv->plug_window, XEMBED_FOCUS_IN, detail);
}
void
@@ -216,20 +217,20 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket)
XConfigureEvent xconfigure;
gint x, y;
- g_return_if_fail (socket->plug_window != NULL);
+ g_return_if_fail (socket->priv->plug_window != NULL);
memset (&xconfigure, 0, sizeof (xconfigure));
xconfigure.type = ConfigureNotify;
- xconfigure.event = GDK_WINDOW_XID (socket->plug_window);
- xconfigure.window = GDK_WINDOW_XID (socket->plug_window);
+ xconfigure.event = GDK_WINDOW_XID (socket->priv->plug_window);
+ xconfigure.window = GDK_WINDOW_XID (socket->priv->plug_window);
/* The ICCCM says that synthetic events should have root relative
* coordinates. We still aren't really ICCCM compliant, since
* we don't send events when the real toplevel is moved.
*/
gdk_error_trap_push ();
- gdk_window_get_origin (socket->plug_window, &x, &y);
+ gdk_window_get_origin (socket->priv->plug_window, &x, &y);
gdk_error_trap_pop_ignored ();
gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation);
@@ -243,8 +244,8 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket)
xconfigure.override_redirect = False;
gdk_error_trap_push ();
- XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window),
- GDK_WINDOW_XID (socket->plug_window),
+ XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window),
+ GDK_WINDOW_XID (socket->priv->plug_window),
False, NoEventMask, (XEvent *)&xconfigure);
gdk_error_trap_pop_ignored ();
}
@@ -253,7 +254,7 @@ void
_gtk_socket_windowing_select_plug_window_input (GtkSocket *socket)
{
XSelectInput (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))),
- GDK_WINDOW_XID (socket->plug_window),
+ GDK_WINDOW_XID (socket->priv->plug_window),
StructureNotifyMask | PropertyChangeMask);
}
@@ -262,36 +263,38 @@ _gtk_socket_windowing_embed_get_info (GtkSocket *socket)
{
unsigned long version;
unsigned long flags;
+ GtkSocketPrivate *private = socket->priv;
- socket->xembed_version = -1;
- if (xembed_get_info (socket->plug_window, &version, &flags))
+ private->xembed_version = -1;
+ if (xembed_get_info (private->plug_window, &version, &flags))
{
- socket->xembed_version = MIN (GTK_XEMBED_PROTOCOL_VERSION, version);
- socket->is_mapped = (flags & XEMBED_MAPPED) != 0;
+ private->xembed_version = MIN (GTK_XEMBED_PROTOCOL_VERSION, version);
+ private->is_mapped = (flags & XEMBED_MAPPED) != 0;
}
else
{
/* FIXME, we should probably actually check the state before we started */
- socket->is_mapped = TRUE;
+ private->is_mapped = TRUE;
}
}
void
_gtk_socket_windowing_embed_notify (GtkSocket *socket)
{
+ GtkSocketPrivate *private = socket->priv;
#ifdef HAVE_XFIXES
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (socket));
gdk_error_trap_push ();
XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (display),
- GDK_WINDOW_XID (socket->plug_window),
+ GDK_WINDOW_XID (private->plug_window),
SetModeInsert, SaveSetRoot, SaveSetUnmap);
gdk_error_trap_pop_ignored ();
#endif
- _gtk_xembed_send_message (socket->plug_window,
+ _gtk_xembed_send_message (private->plug_window,
XEMBED_EMBEDDED_NOTIFY, 0,
GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))),
- socket->xembed_version);
+ private->xembed_version);
}
static gboolean
@@ -419,14 +422,16 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
GtkWidget *widget;
GdkDisplay *display;
XEvent *xevent;
+ GtkSocketPrivate *private;
GdkFilterReturn return_val;
-
+
socket = GTK_SOCKET (data);
+ private = socket->priv;
return_val = GDK_FILTER_CONTINUE;
- if (socket->plug_widget)
+ if (private->plug_widget)
return return_val;
widget = GTK_WIDGET (socket);
@@ -455,11 +460,11 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
{
XCreateWindowEvent *xcwe = &xevent->xcreatewindow;
- if (!socket->plug_window)
+ if (!private->plug_window)
{
_gtk_socket_add_window (socket, xcwe->window, FALSE);
- if (socket->plug_window)
+ if (private->plug_window)
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window created"));
}
@@ -474,19 +479,17 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
{
XConfigureRequestEvent *xcre = &xevent->xconfigurerequest;
- if (!socket->plug_window)
+ if (!private->plug_window)
_gtk_socket_add_window (socket, xcre->window, FALSE);
- if (socket->plug_window)
+ if (private->plug_window)
{
- GtkSocketPrivate *private = _gtk_socket_get_private (socket);
-
if (xcre->value_mask & (CWWidth | CWHeight))
{
GTK_NOTE (PLUGSOCKET,
g_message ("GtkSocket - configure request: %d %d",
- socket->request_width,
- socket->request_height));
+ private->request_width,
+ private->request_height));
private->resize_count++;
gtk_widget_queue_resize (widget);
@@ -509,13 +512,13 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
/* Note that we get destroy notifies both from SubstructureNotify on
* our window and StructureNotify on socket->plug_window
*/
- if (socket->plug_window && (xdwe->window == GDK_WINDOW_XID (socket->plug_window)))
+ if (private->plug_window && (xdwe->window == GDK_WINDOW_XID (private->plug_window)))
{
gboolean result;
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - destroy notify"));
- gdk_window_destroy_notify (socket->plug_window);
+ gdk_window_destroy_notify (private->plug_window);
_gtk_socket_end_embedding (socket);
g_object_ref (widget);
@@ -540,12 +543,12 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
return_val = GDK_FILTER_REMOVE;
break;
case MapRequest:
- if (!socket->plug_window)
+ if (!private->plug_window)
{
_gtk_socket_add_window (socket, xevent->xmaprequest.window, FALSE);
}
- if (socket->plug_window)
+ if (private->plug_window)
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Map Request"));
@@ -554,15 +557,15 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
}
break;
case PropertyNotify:
- if (socket->plug_window &&
- xevent->xproperty.window == GDK_WINDOW_XID (socket->plug_window))
+ if (private->plug_window &&
+ xevent->xproperty.window == GDK_WINDOW_XID (private->plug_window))
{
GdkDragProtocol protocol;
if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_NORMAL_HINTS"))
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - received PropertyNotify for plug's WM_NORMAL_HINTS"));
- socket->have_size = FALSE;
+ private->have_size = FALSE;
gtk_widget_queue_resize (widget);
return_val = GDK_FILTER_REMOVE;
}
@@ -574,7 +577,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
xevent->xproperty.window,
&protocol))
gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
- socket->plug_window,
+ private->plug_window,
protocol, TRUE);
gdk_error_trap_pop_ignored ();
@@ -584,9 +587,9 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
{
unsigned long flags;
- if (xembed_get_info (socket->plug_window, NULL, &flags))
+ if (xembed_get_info (private->plug_window, NULL, &flags))
{
- gboolean was_mapped = socket->is_mapped;
+ gboolean was_mapped = private->is_mapped;
gboolean is_mapped = (flags & XEMBED_MAPPED) != 0;
if (was_mapped != is_mapped)
@@ -596,7 +599,7 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
else
{
gdk_error_trap_push ();
- gdk_window_show (socket->plug_window);
+ gdk_window_show (private->plug_window);
gdk_error_trap_pop_ignored ();
_gtk_socket_unmap_notify (socket);
@@ -615,12 +618,12 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
window = gtk_widget_get_window (widget);
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received"));
- if (!socket->plug_window &&
+ if (!private->plug_window &&
xre->parent == GDK_WINDOW_XID (window))
{
_gtk_socket_add_window (socket, xre->window, FALSE);
- if (socket->plug_window)
+ if (private->plug_window)
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window reparented"));
}
@@ -629,8 +632,8 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
}
else
{
- if (socket->plug_window &&
- xre->window == GDK_WINDOW_XID (socket->plug_window) &&
+ if (private->plug_window &&
+ xre->window == GDK_WINDOW_XID (private->plug_window) &&
xre->parent != GDK_WINDOW_XID (window))
{
gboolean result;
@@ -650,8 +653,8 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
break;
}
case UnmapNotify:
- if (socket->plug_window &&
- xevent->xunmap.window == GDK_WINDOW_XID (socket->plug_window))
+ if (private->plug_window &&
+ xevent->xunmap.window == GDK_WINDOW_XID (private->plug_window))
{
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Unmap notify"));
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 86d72a1..c8a8c58 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -158,29 +158,15 @@ enum {
static guint socket_signals[LAST_SIGNAL] = { 0 };
-/*
- * _gtk_socket_get_private:
- *
- * @socket: a #GtkSocket
- *
- * Returns the private data associated with a GtkSocket, creating it
- * first if necessary.
- */
-GtkSocketPrivate *
-_gtk_socket_get_private (GtkSocket *socket)
-{
- return G_TYPE_INSTANCE_GET_PRIVATE (socket, GTK_TYPE_SOCKET, GtkSocketPrivate);
-}
-
G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER)
static void
gtk_socket_finalize (GObject *object)
{
GtkSocket *socket = GTK_SOCKET (object);
-
- g_object_unref (socket->accel_group);
- socket->accel_group = NULL;
+ GtkSocketPrivate *priv = socket->priv;
+
+ g_object_unref (priv->accel_group);
G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object);
}
@@ -213,7 +199,7 @@ gtk_socket_class_init (GtkSocketClass *class)
/* We don't want to show_all the in-process plug, if any.
*/
widget_class->show_all = gtk_widget_show;
-
+
container_class->remove = gtk_socket_remove;
container_class->forall = gtk_socket_forall;
@@ -258,20 +244,26 @@ gtk_socket_class_init (GtkSocketClass *class)
static void
gtk_socket_init (GtkSocket *socket)
{
- socket->request_width = 0;
- socket->request_height = 0;
- socket->current_width = 0;
- socket->current_height = 0;
-
- socket->plug_window = NULL;
- socket->plug_widget = NULL;
- socket->focus_in = FALSE;
- socket->have_size = FALSE;
- socket->need_map = FALSE;
- socket->active = FALSE;
-
- socket->accel_group = gtk_accel_group_new ();
- g_object_set_data (G_OBJECT (socket->accel_group), I_("gtk-socket"), socket);
+ GtkSocketPrivate *priv;
+
+ priv = G_TYPE_INSTANCE_GET_PRIVATE (socket,
+ GTK_TYPE_SOCKET,
+ GtkSocketPrivate);
+ socket->priv = priv;
+ priv->request_width = 0;
+ priv->request_height = 0;
+ priv->current_width = 0;
+ priv->current_height = 0;
+
+ priv->plug_window = NULL;
+ priv->plug_widget = NULL;
+ priv->focus_in = FALSE;
+ priv->have_size = FALSE;
+ priv->need_map = FALSE;
+ priv->active = FALSE;
+
+ priv->accel_group = gtk_accel_group_new ();
+ g_object_set_data (G_OBJECT (priv->accel_group), I_("gtk-socket"), socket);
}
/**
@@ -363,7 +355,7 @@ gtk_socket_get_plug_window (GtkSocket *socket)
{
g_return_val_if_fail (GTK_IS_SOCKET (socket), NULL);
- return socket->plug_window;
+ return socket->priv->plug_window;
}
static void
@@ -422,33 +414,34 @@ gtk_socket_realize (GtkWidget *widget)
void
_gtk_socket_end_embedding (GtkSocket *socket)
{
- GtkSocketPrivate *private = _gtk_socket_get_private (socket);
+ GtkSocketPrivate *private = socket->priv;
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
-
+
if (GTK_IS_WINDOW (toplevel))
_gtk_socket_windowing_end_embedding_toplevel (socket);
- g_object_unref (socket->plug_window);
- socket->plug_window = NULL;
- socket->current_width = 0;
- socket->current_height = 0;
+ g_object_unref (private->plug_window);
+ private->plug_window = NULL;
+ private->current_width = 0;
+ private->current_height = 0;
private->resize_count = 0;
- gtk_accel_group_disconnect (socket->accel_group, NULL);
+ gtk_accel_group_disconnect (private->accel_group, NULL);
}
static void
gtk_socket_unrealize (GtkWidget *widget)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
gtk_widget_set_realized (widget, FALSE);
- if (socket->plug_widget)
+ if (private->plug_widget)
{
- _gtk_plug_remove_from_socket (GTK_PLUG (socket->plug_widget), socket);
+ _gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket);
}
- else if (socket->plug_window)
+ else if (private->plug_window)
{
_gtk_socket_end_embedding (socket);
}
@@ -462,18 +455,19 @@ gtk_socket_get_preferred_width (GtkWidget *widget,
gint *natural)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
- if (socket->plug_widget)
+ if (private->plug_widget)
{
- gtk_widget_get_preferred_width (socket->plug_widget, minimum, natural);
+ gtk_widget_get_preferred_width (private->plug_widget, minimum, natural);
}
else
{
- if (socket->is_mapped && !socket->have_size && socket->plug_window)
+ if (private->is_mapped && !private->have_size && private->plug_window)
_gtk_socket_windowing_size_request (socket);
- if (socket->is_mapped && socket->have_size)
- *minimum = *natural = MAX (socket->request_width, 1);
+ if (private->is_mapped && private->have_size)
+ *minimum = *natural = MAX (private->request_width, 1);
else
*minimum = *natural = 1;
}
@@ -485,18 +479,19 @@ gtk_socket_get_preferred_height (GtkWidget *widget,
gint *natural)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
- if (socket->plug_widget)
+ if (private->plug_widget)
{
- gtk_widget_get_preferred_height (socket->plug_widget, minimum, natural);
+ gtk_widget_get_preferred_height (private->plug_widget, minimum, natural);
}
else
{
- if (socket->is_mapped && !socket->have_size && socket->plug_window)
+ if (private->is_mapped && !private->have_size && private->plug_window)
_gtk_socket_windowing_size_request (socket);
- if (socket->is_mapped && socket->have_size)
- *minimum = *natural = MAX (socket->request_height, 1);
+ if (private->is_mapped && private->have_size)
+ *minimum = *natural = MAX (private->request_height, 1);
else
*minimum = *natural = 1;
}
@@ -507,6 +502,7 @@ gtk_socket_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
@@ -515,7 +511,7 @@ gtk_socket_size_allocate (GtkWidget *widget,
allocation->x, allocation->y,
allocation->width, allocation->height);
- if (socket->plug_widget)
+ if (private->plug_widget)
{
GtkAllocation child_allocation;
@@ -524,18 +520,16 @@ gtk_socket_size_allocate (GtkWidget *widget,
child_allocation.width = allocation->width;
child_allocation.height = allocation->height;
- gtk_widget_size_allocate (socket->plug_widget, &child_allocation);
+ gtk_widget_size_allocate (private->plug_widget, &child_allocation);
}
- else if (socket->plug_window)
+ else if (private->plug_window)
{
- GtkSocketPrivate *private = _gtk_socket_get_private (socket);
-
gdk_error_trap_push ();
-
- if (allocation->width != socket->current_width ||
- allocation->height != socket->current_height)
+
+ if (allocation->width != private->current_width ||
+ allocation->height != private->current_height)
{
- gdk_window_move_resize (socket->plug_window,
+ gdk_window_move_resize (private->plug_window,
0, 0,
allocation->width, allocation->height);
if (private->resize_count)
@@ -544,14 +538,14 @@ gtk_socket_size_allocate (GtkWidget *widget,
GTK_NOTE (PLUGSOCKET,
g_message ("GtkSocket - allocated: %d %d",
allocation->width, allocation->height));
- socket->current_width = allocation->width;
- socket->current_height = allocation->height;
+ private->current_width = allocation->width;
+ private->current_height = allocation->height;
}
- if (socket->need_map)
+ if (private->need_map)
{
- gdk_window_show (socket->plug_window);
- socket->need_map = FALSE;
+ gdk_window_show (private->plug_window);
+ private->need_map = FALSE;
}
while (private->resize_count)
@@ -580,7 +574,7 @@ activate_key (GtkAccelGroup *accel_group,
GtkSocket *socket = g_object_get_data (G_OBJECT (accel_group), "gtk-socket");
gboolean retval = FALSE;
- if (gdk_event && gdk_event->type == GDK_KEY_PRESS && socket->plug_window)
+ if (gdk_event && gdk_event->type == GDK_KEY_PRESS && socket->priv->plug_window)
{
_gtk_socket_windowing_send_key_event (socket, gdk_event, FALSE);
retval = TRUE;
@@ -626,7 +620,7 @@ _gtk_socket_add_grabbed_key (GtkSocket *socket,
grabbed_key->accel_key = keyval;
grabbed_key->accel_mods = modifiers;
- if (gtk_accel_group_find (socket->accel_group,
+ if (gtk_accel_group_find (socket->priv->accel_group,
find_accel_key,
&grabbed_key))
{
@@ -638,7 +632,7 @@ _gtk_socket_add_grabbed_key (GtkSocket *socket,
closure = g_cclosure_new (G_CALLBACK (activate_key), grabbed_key, (GClosureNotify)g_free);
- gtk_accel_group_connect (socket->accel_group, keyval, modifiers, GTK_ACCEL_LOCKED,
+ gtk_accel_group_connect (socket->priv->accel_group, keyval, modifiers, GTK_ACCEL_LOCKED,
closure);
}
@@ -657,7 +651,7 @@ _gtk_socket_remove_grabbed_key (GtkSocket *socket,
guint keyval,
GdkModifierType modifiers)
{
- if (!gtk_accel_group_disconnect_key (socket->accel_group, keyval, modifiers))
+ if (!gtk_accel_group_disconnect_key (socket->priv->accel_group, keyval, modifiers))
g_warning ("GtkSocket: request to remove non-present grabbed key %u,%#x\n",
keyval, modifiers);
}
@@ -665,9 +659,10 @@ _gtk_socket_remove_grabbed_key (GtkSocket *socket,
static void
socket_update_focus_in (GtkSocket *socket)
{
+ GtkSocketPrivate *private = socket->priv;
gboolean focus_in = FALSE;
- if (socket->plug_window)
+ if (private->plug_window)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
@@ -677,9 +672,9 @@ socket_update_focus_in (GtkSocket *socket)
focus_in = TRUE;
}
- if (focus_in != socket->focus_in)
+ if (focus_in != private->focus_in)
{
- socket->focus_in = focus_in;
+ private->focus_in = focus_in;
_gtk_socket_windowing_focus_change (socket, focus_in);
}
@@ -688,9 +683,10 @@ socket_update_focus_in (GtkSocket *socket)
static void
socket_update_active (GtkSocket *socket)
{
+ GtkSocketPrivate *private = socket->priv;
gboolean active = FALSE;
- if (socket->plug_window)
+ if (private->plug_window)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
@@ -699,9 +695,9 @@ socket_update_active (GtkSocket *socket)
active = TRUE;
}
- if (active != socket->active)
+ if (active != private->active)
{
- socket->active = active;
+ private->active = active;
_gtk_socket_windowing_update_active (socket, active);
}
@@ -712,32 +708,33 @@ gtk_socket_hierarchy_changed (GtkWidget *widget,
GtkWidget *old_toplevel)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (toplevel && !GTK_IS_WINDOW (toplevel))
toplevel = NULL;
- if (toplevel != socket->toplevel)
+ if (toplevel != private->toplevel)
{
- if (socket->toplevel)
+ if (private->toplevel)
{
- gtk_window_remove_accel_group (GTK_WINDOW (socket->toplevel), socket->accel_group);
- g_signal_handlers_disconnect_by_func (socket->toplevel,
+ gtk_window_remove_accel_group (GTK_WINDOW (private->toplevel), private->accel_group);
+ g_signal_handlers_disconnect_by_func (private->toplevel,
socket_update_focus_in,
socket);
- g_signal_handlers_disconnect_by_func (socket->toplevel,
+ g_signal_handlers_disconnect_by_func (private->toplevel,
socket_update_active,
socket);
}
- socket->toplevel = toplevel;
+ private->toplevel = toplevel;
if (toplevel)
{
- gtk_window_add_accel_group (GTK_WINDOW (socket->toplevel), socket->accel_group);
- g_signal_connect_swapped (socket->toplevel, "notify::has-toplevel-focus",
+ gtk_window_add_accel_group (GTK_WINDOW (private->toplevel), private->accel_group);
+ g_signal_connect_swapped (private->toplevel, "notify::has-toplevel-focus",
G_CALLBACK (socket_update_focus_in), socket);
- g_signal_connect_swapped (socket->toplevel, "notify::is-active",
+ g_signal_connect_swapped (private->toplevel, "notify::is-active",
G_CALLBACK (socket_update_active), socket);
}
@@ -752,7 +749,7 @@ gtk_socket_grab_notify (GtkWidget *widget,
{
GtkSocket *socket = GTK_SOCKET (widget);
- if (!socket->same_app)
+ if (!socket->priv->same_app)
_gtk_socket_windowing_update_modality (socket, !was_grabbed);
}
@@ -761,8 +758,9 @@ gtk_socket_key_event (GtkWidget *widget,
GdkEventKey *event)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
- if (gtk_widget_has_focus (widget) && socket->plug_window && !socket->plug_widget)
+ if (gtk_widget_has_focus (widget) && private->plug_window && !private->plug_widget)
{
_gtk_socket_windowing_send_key_event (socket, (GdkEvent *) event, FALSE);
@@ -794,9 +792,10 @@ _gtk_socket_claim_focus (GtkSocket *socket,
gboolean send_event)
{
GtkWidget *widget = GTK_WIDGET (socket);
+ GtkSocketPrivate *private = socket->priv;
if (!send_event)
- socket->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */
+ private->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */
/* Oh, the trickery... */
@@ -810,9 +809,10 @@ gtk_socket_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkSocket *socket = GTK_SOCKET (widget);
+ GtkSocketPrivate *private = socket->priv;
- if (socket->plug_widget)
- return gtk_widget_child_focus (socket->plug_widget, direction);
+ if (private->plug_widget)
+ return gtk_widget_child_focus (private->plug_widget, direction);
if (!gtk_widget_is_focus (widget))
{
@@ -830,10 +830,11 @@ gtk_socket_remove (GtkContainer *container,
GtkWidget *child)
{
GtkSocket *socket = GTK_SOCKET (container);
+ GtkSocketPrivate *private = socket->priv;
- g_return_if_fail (child == socket->plug_widget);
+ g_return_if_fail (child == private->plug_widget);
- _gtk_plug_remove_from_socket (GTK_PLUG (socket->plug_widget), socket);
+ _gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket);
}
static void
@@ -843,9 +844,10 @@ gtk_socket_forall (GtkContainer *container,
gpointer callback_data)
{
GtkSocket *socket = GTK_SOCKET (container);
+ GtkSocketPrivate *private = socket->priv;
- if (socket->plug_widget)
- (* callback) (socket->plug_widget, callback_data);
+ if (private->plug_widget)
+ (* callback) (private->plug_widget, callback_data);
}
/**
@@ -866,13 +868,14 @@ _gtk_socket_add_window (GtkSocket *socket,
GtkWidget *widget = GTK_WIDGET (socket);
GdkDisplay *display = gtk_widget_get_display (widget);
gpointer user_data = NULL;
+ GtkSocketPrivate *private = socket->priv;
- socket->plug_window = gdk_window_lookup_for_display (display, xid);
+ private->plug_window = gdk_window_lookup_for_display (display, xid);
- if (socket->plug_window)
+ if (private->plug_window)
{
- g_object_ref (socket->plug_window);
- gdk_window_get_user_data (socket->plug_window, &user_data);
+ g_object_ref (private->plug_window);
+ gdk_window_get_user_data (private->plug_window, &user_data);
}
if (user_data) /* A widget's window in this process */
@@ -882,7 +885,7 @@ _gtk_socket_add_window (GtkSocket *socket,
if (!GTK_IS_PLUG (child_widget))
{
g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket");
- socket->plug_window = NULL;
+ private->plug_window = NULL;
gdk_error_trap_pop_ignored ();
return;
@@ -897,10 +900,10 @@ _gtk_socket_add_window (GtkSocket *socket,
gdk_error_trap_push ();
- if (!socket->plug_window)
+ if (!private->plug_window)
{
- socket->plug_window = gdk_window_foreign_new_for_display (display, xid);
- if (!socket->plug_window) /* was deleted before we could get it */
+ private->plug_window = gdk_window_foreign_new_for_display (display, xid);
+ if (!private->plug_window) /* was deleted before we could get it */
{
gdk_error_trap_pop_ignored ();
return;
@@ -911,8 +914,8 @@ _gtk_socket_add_window (GtkSocket *socket,
if (gdk_error_trap_pop ())
{
- g_object_unref (socket->plug_window);
- socket->plug_window = NULL;
+ g_object_unref (private->plug_window);
+ private->plug_window = NULL;
return;
}
@@ -922,25 +925,25 @@ _gtk_socket_add_window (GtkSocket *socket,
if (need_reparent)
{
- gdk_window_hide (socket->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */
- gdk_window_reparent (socket->plug_window,
+ gdk_window_hide (private->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */
+ gdk_window_reparent (private->plug_window,
gtk_widget_get_window (widget),
0, 0);
}
- socket->have_size = FALSE;
+ private->have_size = FALSE;
_gtk_socket_windowing_embed_get_info (socket);
- socket->need_map = socket->is_mapped;
+ private->need_map = private->is_mapped;
if (gdk_drag_get_protocol_for_display (display, xid, &protocol))
- gtk_drag_dest_set_proxy (GTK_WIDGET (socket), socket->plug_window,
+ gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window,
protocol, TRUE);
gdk_error_trap_pop_ignored ();
- gdk_window_add_filter (socket->plug_window,
+ gdk_window_add_filter (private->plug_window,
_gtk_socket_windowing_filter_func,
socket);
@@ -958,7 +961,7 @@ _gtk_socket_add_window (GtkSocket *socket,
gtk_widget_queue_resize (GTK_WIDGET (socket));
}
- if (socket->plug_window)
+ if (private->plug_window)
g_signal_emit (socket, socket_signals[PLUG_ADDED], 0);
}
@@ -972,10 +975,11 @@ _gtk_socket_add_window (GtkSocket *socket,
void
_gtk_socket_handle_map_request (GtkSocket *socket)
{
- if (!socket->is_mapped)
+ GtkSocketPrivate *private = socket->priv;
+ if (!private->is_mapped)
{
- socket->is_mapped = TRUE;
- socket->need_map = TRUE;
+ private->is_mapped = TRUE;
+ private->need_map = TRUE;
gtk_widget_queue_resize (GTK_WIDGET (socket));
}
@@ -991,9 +995,10 @@ _gtk_socket_handle_map_request (GtkSocket *socket)
void
_gtk_socket_unmap_notify (GtkSocket *socket)
{
- if (socket->is_mapped)
+ GtkSocketPrivate *private = socket->priv;
+ if (private->is_mapped)
{
- socket->is_mapped = FALSE;
+ private->is_mapped = FALSE;
gtk_widget_queue_resize (GTK_WIDGET (socket));
}
}
diff --git a/gtk/gtksocket.h b/gtk/gtksocket.h
index e3cd3a3..139d6a2 100644
--- a/gtk/gtksocket.h
+++ b/gtk/gtksocket.h
@@ -44,29 +44,13 @@ G_BEGIN_DECLS
typedef struct _GtkSocket GtkSocket;
typedef struct _GtkSocketClass GtkSocketClass;
+typedef struct _GtkSocketPrivate GtkSocketPrivate;
struct _GtkSocket
{
GtkContainer container;
- guint16 GSEAL (request_width);
- guint16 GSEAL (request_height);
- guint16 GSEAL (current_width);
- guint16 GSEAL (current_height);
-
- GdkWindow *GSEAL (plug_window);
- GtkWidget *GSEAL (plug_widget);
-
- gshort GSEAL (xembed_version); /* -1 == not xembed */
- guint GSEAL (same_app) : 1;
- guint GSEAL (focus_in) : 1;
- guint GSEAL (have_size) : 1;
- guint GSEAL (need_map) : 1;
- guint GSEAL (is_mapped) : 1;
- guint GSEAL (active) : 1;
-
- GtkAccelGroup *GSEAL (accel_group);
- GtkWidget *GSEAL (toplevel);
+ GtkSocketPrivate *priv;
};
struct _GtkSocketClass
diff --git a/gtk/gtksocketprivate.h b/gtk/gtksocketprivate.h
index 44a6c6b..282634a 100644
--- a/gtk/gtksocketprivate.h
+++ b/gtk/gtksocketprivate.h
@@ -26,33 +26,50 @@
#ifndef __GTK_SOCKET_PRIVATE_H__
#define __GTK_SOCKET_PRIVATE_H__
-typedef struct _GtkSocketPrivate GtkSocketPrivate;
+#include "gtksocket.h"
struct _GtkSocketPrivate
{
gint resize_count;
+
+ guint16 request_width;
+ guint16 request_height;
+ guint16 current_width;
+ guint16 current_height;
+
+ GdkWindow *plug_window;
+ GtkWidget *plug_widget;
+
+ gshort xembed_version; /* -1 == not xembed */
+ guint same_app : 1;
+ guint focus_in : 1;
+ guint have_size : 1;
+ guint need_map : 1;
+ guint is_mapped : 1;
+ guint active : 1;
+
+ GtkAccelGroup *GSEAL (accel_group);
+ GtkWidget *GSEAL (toplevel);
};
/* In gtksocket.c: */
-GtkSocketPrivate *_gtk_socket_get_private (GtkSocket *socket);
-
void _gtk_socket_add_grabbed_key (GtkSocket *socket,
- guint keyval,
- GdkModifierType modifiers);
+ guint keyval,
+ GdkModifierType modifiers);
void _gtk_socket_remove_grabbed_key (GtkSocket *socket,
- guint keyval,
- GdkModifierType modifiers);
-void _gtk_socket_claim_focus (GtkSocket *socket,
- gboolean send_event);
-void _gtk_socket_add_window (GtkSocket *socket,
- GdkNativeWindow xid,
- gboolean need_reparent);
+ guint keyval,
+ GdkModifierType modifiers);
+void _gtk_socket_claim_focus (GtkSocket *socket,
+ gboolean send_event);
+void _gtk_socket_add_window (GtkSocket *socket,
+ GdkNativeWindow xid,
+ gboolean need_reparent);
void _gtk_socket_end_embedding (GtkSocket *socket);
void _gtk_socket_handle_map_request (GtkSocket *socket);
void _gtk_socket_unmap_notify (GtkSocket *socket);
void _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
- GtkDirectionType direction);
+ GtkDirectionType direction);
/* In backend-specific file: */
@@ -88,36 +105,36 @@ void _gtk_socket_windowing_size_request (GtkSocket *socket);
*
*/
void _gtk_socket_windowing_send_key_event (GtkSocket *socket,
- GdkEvent *gdk_event,
- gboolean mask_key_presses);
+ GdkEvent *gdk_event,
+ gboolean mask_key_presses);
/*
* _gtk_socket_windowing_focus_change:
*
*/
void _gtk_socket_windowing_focus_change (GtkSocket *socket,
- gboolean focus_in);
+ gboolean focus_in);
/*
* _gtk_socket_windowing_update_active:
*
*/
void _gtk_socket_windowing_update_active (GtkSocket *socket,
- gboolean active);
+ gboolean active);
/*
* _gtk_socket_windowing_update_modality:
*
*/
void _gtk_socket_windowing_update_modality (GtkSocket *socket,
- gboolean modality);
+ gboolean modality);
/*
* _gtk_socket_windowing_focus:
*
*/
void _gtk_socket_windowing_focus (GtkSocket *socket,
- GtkDirectionType direction);
+ GtkDirectionType direction);
/*
* _gtk_socket_windowing_send_configure_event:
@@ -165,7 +182,7 @@ void _gtk_socket_windowing_embed_set_focus_wrapped (void);
*
*/
GdkFilterReturn _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data);
+ GdkEvent *event,
+ gpointer data);
#endif /* __GTK_SOCKET_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]