* 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 <http://www.gnu.org/licenses/>.Free
*/
/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
#include <string.h>
-#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 <gdk/gdkx.h>
* SECTION:gtksocket
* @Short_description: Container for widgets from other processes
* @Title: GtkSocket
+ * @include: gtk/gtkx.h
* @See_also: #GtkPlug, <ulink url="http://www.freedesktop.org/Standards/xembed-spec">XEmbed</ulink>
*
- * 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.
*
* <example>
* <title>Obtaining the window ID of a socket.</title>
* 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));
* </example>
*
* 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
* <ulink url="http://www.freedesktop.org/Standards/xembed-spec">XEmbed</ulink>
- * protocol. This protocol has also been implemented in other toolkits, e.g.
- * <application>Qt</application>, allowing the same level of integration
- * when embedding a <application>Qt</application> widget in GTK or vice versa.
+ * protocol. This protocol has also been implemented in other toolkits,
+ * e.g. <application>Qt</application>, allowing the same level of
+ * integration when embedding a <application>Qt</application> widget
+ * in GTK or vice versa.
*
* <note>
- * 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 <filename>gtk/gtkx.h</filename>
+ * header.
* </note>
*/
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,
/**
* 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.
**/
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)));
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);
}
/**
*
* 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);
gtk_socket_realize (GtkWidget *widget)
{
GtkAllocation allocation;
- GtkSocket *socket = GTK_SOCKET (widget);
GdkWindow *window;
GdkWindowAttr attributes;
XWindowAttributes xattrs;
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);
/**
* gtk_socket_end_embedding:
- *
* @socket: a #GtkSocket
*
* Called to end the embedding of a plug in the socket.
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;
/**
* gtk_socket_add_grabbed_key:
- *
* @socket: a #GtkSocket
* @keyval: a key
* @modifiers: modifiers for the key
/**
* gtk_socket_remove_grabbed_key:
- *
* @socket: a #GtkSocket
* @keyval: a key
* @modifiers: modifiers for the key
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?
*
/**
* 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);
}
else /* A foreign window */
{
- GtkWidget *toplevel;
GdkDragProtocol protocol;
gdk_error_trap_push ();
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);
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))),
/**
* gtk_socket_handle_map_request:
- *
* @socket: a #GtkSocket
*
* Called from the GtkSocket backend when the plug has been mapped.
/**
* gtk_socket_unmap_notify:
- *
* @socket: a #GtkSocket
*
* Called from the GtkSocket backend when the plug has been unmapped ???
/**
* gtk_socket_advance_toplevel_focus:
- *
* @socket: a #GtkSocket
* @direction: a direction
*
(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);