X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtksocket.c;h=c497f5065eaf7936323909bccb456f485ad4f570;hb=32825a66ac8e65bf98cafed26a339fa1f31eddd4;hp=6a76b5e557b1ece746565ae2e5bd1049743afb83;hpb=b8895cf91036915c8e053dafd6228f19353ceec3;p=~andy%2Fgtk diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 6a76b5e55..c497f5065 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -12,8 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library. If not, see .Free */ /* By Owen Taylor 98/4/4 */ @@ -31,15 +30,14 @@ #include -#include "gtkmainprivate.h" #include "gtkmarshalers.h" #include "gtksizerequest.h" -#include "gtkwindowprivate.h" #include "gtkplug.h" #include "gtkprivate.h" #include "gtkdnd.h" #include "gtkdebug.h" #include "gtkintl.h" +#include "gtkmain.h" #include "gtkwidgetprivate.h" #include @@ -56,21 +54,19 @@ * SECTION:gtksocket * @Short_description: Container for widgets from other processes * @Title: GtkSocket + * @include: gtk/gtkx.h * @See_also: #GtkPlug, XEmbed * - * Together with #GtkPlug, #GtkSocket provides the ability - * to embed widgets from one process into another process - * in a fashion that is transparent to the user. One - * process creates a #GtkSocket widget and passes - * that widget's window ID to the other process, - * which then creates a #GtkPlug with that window ID. - * Any widgets contained in the #GtkPlug then will appear - * inside the first application's window. + * Together with #GtkPlug, #GtkSocket provides the ability to embed + * widgets from one process into another process in a fashion that + * is transparent to the user. One process creates a #GtkSocket widget + * and passes that widget's window ID to the other process, which then + * creates a #GtkPlug with that window ID. Any widgets contained in the + * #GtkPlug then will appear inside the first application's window. * - * The socket's window ID is obtained by using - * gtk_socket_get_id(). Before using this function, - * the socket must have been realized, and for hence, - * have been added to its parent. + * The socket's window ID is obtained by using gtk_socket_get_id(). + * Before using this function, the socket must have been realized, + * and for hence, have been added to its parent. * * * Obtaining the window ID of a socket. @@ -79,9 +75,9 @@ * gtk_widget_show (socket); * gtk_container_add (GTK_CONTAINER (parent), socket); * - * /* The following call is only necessary if one of + * /* The following call is only necessary if one of * * the ancestors of the socket is not yet visible. - * */ + * */ * gtk_widget_realize (socket); * g_print ("The ID of the sockets window is %#x\n", * gtk_socket_get_id (socket)); @@ -89,33 +85,34 @@ * * * Note that if you pass the window ID of the socket to another - * process that will create a plug in the socket, you - * must make sure that the socket widget is not destroyed - * until that plug is created. Violating this rule will - * cause unpredictable consequences, the most likely - * consequence being that the plug will appear as a - * separate toplevel window. You can check if the plug - * has been created by using gtk_socket_get_plug_window(). If - * it returns a non-%NULL value, then the plug has been + * process that will create a plug in the socket, you must make + * sure that the socket widget is not destroyed until that plug + * is created. Violating this rule will cause unpredictable + * consequences, the most likely consequence being that the plug + * will appear as a separate toplevel window. You can check if + * the plug has been created by using gtk_socket_get_plug_window(). + * If it returns a non-%NULL value, then the plug has been * successfully created inside of the socket. * - * When GTK+ is notified that the embedded window has been - * destroyed, then it will destroy the socket as well. You - * should always, therefore, be prepared for your sockets - * to be destroyed at any time when the main event loop - * is running. To prevent this from happening, you can - * connect to the #GtkSocket::plug-removed signal. + * When GTK+ is notified that the embedded window has been destroyed, + * then it will destroy the socket as well. You should always, + * therefore, be prepared for your sockets to be destroyed at any + * time when the main event loop is running. To prevent this from + * happening, you can connect to the #GtkSocket::plug-removed signal. * * The communication between a #GtkSocket and a #GtkPlug follows the * XEmbed - * protocol. This protocol has also been implemented in other toolkits, e.g. - * Qt, allowing the same level of integration - * when embedding a Qt widget in GTK or vice versa. + * protocol. This protocol has also been implemented in other toolkits, + * e.g. Qt, allowing the same level of + * integration when embedding a Qt widget + * in GTK or vice versa. * * - * The #GtkPlug and #GtkSocket widgets are only available when GTK is - * compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. - * They can only be used on a #GdkX11Display. + * The #GtkPlug and #GtkSocket widgets are only available when GTK+ + * is compiled for the X11 platform and %GDK_WINDOWING_X11 is defined. + * They can only be used on a #GdkX11Display. To use #GtkPlug and + * #GtkSocket, you need to include the gtk/gtkx.h + * header. * */ @@ -149,7 +146,7 @@ static void gtk_socket_forall (GtkContainer *container, GtkCallback callback, gpointer callback_data); static void gtk_socket_add_window (GtkSocket *socket, - GdkNativeWindow xid, + Window xid, gboolean need_reparent); static GdkFilterReturn gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, @@ -307,7 +304,7 @@ gtk_socket_new (void) /** * gtk_socket_add_id: * @socket_: a #GtkSocket - * @window_id: the window ID of a client participating in the XEMBED protocol. + * @window: the Window of a client participating in the XEMBED protocol. * * Adds an XEMBED client, such as a #GtkPlug, to the #GtkSocket. The * client may be in the same process or in a different process. @@ -324,7 +321,7 @@ gtk_socket_new (void) **/ void gtk_socket_add_id (GtkSocket *socket, - GdkNativeWindow window_id) + Window window) { g_return_if_fail (GTK_IS_SOCKET (socket)); g_return_if_fail (_gtk_widget_get_anchored (GTK_WIDGET (socket))); @@ -332,7 +329,7 @@ gtk_socket_add_id (GtkSocket *socket, if (!gtk_widget_get_realized (GTK_WIDGET (socket))) gtk_widget_realize (GTK_WIDGET (socket)); - gtk_socket_add_window (socket, window_id, TRUE); + gtk_socket_add_window (socket, window, TRUE); } /** @@ -348,7 +345,7 @@ gtk_socket_add_id (GtkSocket *socket, * * Return value: the window ID for the socket **/ -GdkNativeWindow +Window gtk_socket_get_id (GtkSocket *socket) { g_return_val_if_fail (GTK_IS_SOCKET (socket), 0); @@ -383,7 +380,6 @@ static void gtk_socket_realize (GtkWidget *widget) { GtkAllocation allocation; - GtkSocket *socket = GTK_SOCKET (widget); GdkWindow *window; GdkWindowAttr attributes; XWindowAttributes xattrs; @@ -407,7 +403,7 @@ gtk_socket_realize (GtkWidget *widget) window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, socket); + gtk_widget_register_window (widget, window); gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); @@ -442,7 +438,6 @@ gtk_socket_realize (GtkWidget *widget) /** * gtk_socket_end_embedding: - * * @socket: a #GtkSocket * * Called to end the embedding of a plug in the socket. @@ -451,11 +446,6 @@ static void gtk_socket_end_embedding (GtkSocket *socket) { GtkSocketPrivate *private = socket->priv; - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); - - if (GTK_IS_WINDOW (toplevel)) - gtk_window_remove_embedded_xid (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))), - GDK_WINDOW_XID (socket->priv->plug_window)); g_object_unref (private->plug_window); private->plug_window = NULL; @@ -739,7 +729,6 @@ find_accel_key (GtkAccelKey *key, /** * gtk_socket_add_grabbed_key: - * * @socket: a #GtkSocket * @keyval: a key * @modifiers: modifiers for the key @@ -778,7 +767,6 @@ gtk_socket_add_grabbed_key (GtkSocket *socket, /** * gtk_socket_remove_grabbed_key: - * * @socket: a #GtkSocket * @keyval: a key * @modifiers: modifiers for the key @@ -923,14 +911,15 @@ static void gtk_socket_notify (GObject *object, GParamSpec *pspec) { - if (!strcmp (pspec->name, "is-focus")) - return; - socket_update_focus_in (GTK_SOCKET (object)); + if (strcmp (pspec->name, "is-focus") == 0) + socket_update_focus_in (GTK_SOCKET (object)); + + if (G_OBJECT_CLASS (gtk_socket_parent_class)->notify) + G_OBJECT_CLASS (gtk_socket_parent_class)->notify (object, pspec); } /** * gtk_socket_claim_focus: - * * @socket: a #GtkSocket * @send_event: huh? * @@ -1017,17 +1006,16 @@ gtk_socket_forall (GtkContainer *container, /** * gtk_socket_add_window: - * * @socket: a #GtkSocket * @xid: the native identifier for a window * @need_reparent: whether the socket's plug's window needs to be - * reparented to the socket + * reparented to the socket * * Adds a window to a GtkSocket. */ static void gtk_socket_add_window (GtkSocket *socket, - GdkNativeWindow xid, + Window xid, gboolean need_reparent) { GtkWidget *widget = GTK_WIDGET (socket); @@ -1065,7 +1053,6 @@ gtk_socket_add_window (GtkSocket *socket, } else /* A foreign window */ { - GtkWidget *toplevel; GdkDragProtocol protocol; gdk_error_trap_push (); @@ -1120,7 +1107,8 @@ gtk_socket_add_window (GtkSocket *socket, private->need_map = private->is_mapped; - if (gdk_drag_get_protocol_for_display (display, xid, &protocol)) + protocol = gdk_window_get_drag_protocol (private->plug_window, NULL); + if (protocol) gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window, protocol, TRUE); @@ -1130,12 +1118,6 @@ gtk_socket_add_window (GtkSocket *socket, gtk_socket_filter_func, socket); - /* Add a pointer to the socket on our toplevel window */ - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket)); - if (GTK_IS_WINDOW (toplevel)) - gtk_window_add_embedded_xid (GTK_WINDOW (toplevel), xid); - #ifdef HAVE_XFIXES gdk_error_trap_push (); XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))), @@ -1160,7 +1142,6 @@ gtk_socket_add_window (GtkSocket *socket, /** * gtk_socket_handle_map_request: - * * @socket: a #GtkSocket * * Called from the GtkSocket backend when the plug has been mapped. @@ -1180,7 +1161,6 @@ gtk_socket_handle_map_request (GtkSocket *socket) /** * gtk_socket_unmap_notify: - * * @socket: a #GtkSocket * * Called from the GtkSocket backend when the plug has been unmapped ??? @@ -1198,7 +1178,6 @@ gtk_socket_unmap_notify (GtkSocket *socket) /** * gtk_socket_advance_toplevel_focus: - * * @socket: a #GtkSocket * @direction: a direction * @@ -1538,9 +1517,8 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO"))) { gdk_error_trap_push (); - if (gdk_drag_get_protocol_for_display (display, - xevent->xproperty.window, - &protocol)) + protocol = gdk_window_get_drag_protocol (private->plug_window, NULL); + if (protocol) gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window, protocol, TRUE);