2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1998-11-24 04:45:29 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-11-24 04:45:29 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1998-11-24 04:45:29 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-11-24 04:45:29 +00:00
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
#include "gtksocketprivate.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-01-04 22:32:12 +00:00
|
|
|
#include "gtkmainprivate.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
#include "gtkmarshalers.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
#include "gtksizerequest.h"
|
2001-07-03 14:14:30 +00:00
|
|
|
#include "gtkplug.h"
|
2001-07-05 02:58:34 +00:00
|
|
|
#include "gtkprivate.h"
|
1998-11-24 04:45:29 +00:00
|
|
|
#include "gtkdnd.h"
|
2010-09-18 23:57:32 +00:00
|
|
|
#include "gtkdebug.h"
|
2005-09-01 05:11:46 +00:00
|
|
|
#include "gtkintl.h"
|
2010-10-21 12:08:45 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2011-01-28 10:13:06 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2011-01-28 12:02:52 +00:00
|
|
|
#include <gdk/gdkprivate.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_XFIXES
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gtkxembed.h"
|
2010-12-15 06:39:30 +00:00
|
|
|
|
This might seem like a large patch, but it isn't that bad, and nothing
should break on Unix/X11.
Win32 merge and general portability stuff:
* acconfig.h,configure.in: Check for <sys/time.h>.
* gdk/win32: New directory (actually, been there for a while).
* gtk/fnmatch.c: Include <glib.h> for G_DIR_SEPARATOR, WIN32 and
NATIVE_WIN32, and use these. Always case fold on Win32. No
backslashed escapes on native Win32.
* gtk/{gtk.def,makefile.msc}: New files.
* gtk/Makefile.am: Add above new files.
* gtk/{gtkaccelgroup,gtkbindings}.c: Include <string.h>
instead of <strings.h>.
* gtk/{gtkcalendar,gtkitemfactory,gtkpreview,gtkrc}.c: Include
config.h. Protect inclusion of <sys/param.h>, <sys/time.h>, and
<unistd.h> appropriately.
* gtk/gtkdnd.c: Merge in Win32 version (which doesn't do much).
Use ABS() (from <glib.h>) instead of abs().
* gtk/gtkfilesel.c: Moved Win32-specific includes after inclusion
of gtk (and thus glib) headers, so that WIN32 will be
defined. With MS C, include <direct.h> for mkdir prototype.
* gtk/gtkitemfactory.c (gtk_item_factory_callback_marshal): Add
some casts, needed by MS C.
* gtk/{gtklayout,gtkplug}.c: Merge in Win32 version (which isn't
implemented).
* gtk/gtkmain.c: Include gdk/gdkx.h for GDK_WINDOWING. Include
<X11/Xlocale.h> only on X11 platform, otherwise <locale.h>. Use
G_SEARCHPATH_SEPARATOR_S and g_module_build_path.
* gtk/gtkmain.h: Mark variables for export/import on Win32.
* gtk/gtkrange.c (gtk_range_motion_notify): Set mods also in case
the event is not a hint, or its window is not the slider. Needed
on Win32, at least.
* gtk/gtkrc.c: Include config.h and gdk/gdkx.h. Use <locale.h>
unless on X11. Skip \r chars, too. Use G_DIR_SEPARATOR and
G_SEARCHPATH_SEPARATOR(_S). Use g_path_is_absolute. On Win32, use
a subdirectory of the Windows directory as gtk system
configuration directory.
* gtk/gtkselection.c: No chunks on Win32.
* gtk/gtksocket.c: Not implemented on Win32.
* gtk/gtkthemes.c (gtk_theme_engine_get): Use g_module_build_path.
* gtk/makeenums.h: Include gdkprivate.h after gdk.h.
* gtk/testrgb.c: Use dynamically allocated buffer. Use GTimers.
1999-03-15 00:03:37 +00:00
|
|
|
|
2010-03-05 21:58:13 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtksocket
|
|
|
|
* @Short_description: Container for widgets from other processes
|
|
|
|
* @Title: GtkSocket
|
2011-01-29 19:16:47 +00:00
|
|
|
* @include: gtk/gtkx.h
|
2010-03-05 21:58:13 +00:00
|
|
|
* @See_also: #GtkPlug, <ulink url="http://www.freedesktop.org/Standards/xembed-spec">XEmbed</ulink>
|
|
|
|
*
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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.
|
2010-03-05 21:58:13 +00:00
|
|
|
*
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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.
|
2010-03-05 21:58:13 +00:00
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>Obtaining the window ID of a socket.</title>
|
|
|
|
* <programlisting>
|
|
|
|
* GtkWidget *socket = gtk_socket_new (<!-- -->);
|
|
|
|
* gtk_widget_show (socket);
|
|
|
|
* gtk_container_add (GTK_CONTAINER (parent), socket);
|
|
|
|
*
|
2011-01-29 19:16:47 +00:00
|
|
|
* /* The following call is only necessary if one of
|
2010-03-05 21:58:13 +00:00
|
|
|
* * the ancestors of the socket is not yet visible.
|
2011-01-29 19:16:47 +00:00
|
|
|
* */
|
2010-03-05 21:58:13 +00:00
|
|
|
* gtk_widget_realize (socket);
|
|
|
|
* g_print ("The ID of the sockets window is %#x\n",
|
|
|
|
* gtk_socket_get_id (socket));
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
|
|
|
*
|
|
|
|
* Note that if you pass the window ID of the socket to another
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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
|
2010-03-05 21:58:13 +00:00
|
|
|
* successfully created inside of the socket.
|
|
|
|
*
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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.
|
2010-03-05 21:58:13 +00:00
|
|
|
*
|
|
|
|
* The communication between a #GtkSocket and a #GtkPlug follows the
|
|
|
|
* <ulink url="http://www.freedesktop.org/Standards/xembed-spec">XEmbed</ulink>
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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.
|
2010-03-05 21:58:13 +00:00
|
|
|
*
|
|
|
|
* <note>
|
2011-01-29 19:16:47 +00:00
|
|
|
* 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.
|
2010-03-05 21:58:13 +00:00
|
|
|
* </note>
|
|
|
|
*/
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
/* Forward declararations */
|
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
static void gtk_socket_finalize (GObject *object);
|
2002-06-06 15:38:39 +00:00
|
|
|
static void gtk_socket_notify (GObject *object,
|
|
|
|
GParamSpec *pspec);
|
2001-07-03 14:14:30 +00:00
|
|
|
static void gtk_socket_realize (GtkWidget *widget);
|
|
|
|
static void gtk_socket_unrealize (GtkWidget *widget);
|
2010-10-27 15:17:40 +00:00
|
|
|
static void gtk_socket_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
|
|
|
static void gtk_socket_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
2001-07-03 14:14:30 +00:00
|
|
|
static void gtk_socket_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void gtk_socket_hierarchy_changed (GtkWidget *widget,
|
|
|
|
GtkWidget *old_toplevel);
|
|
|
|
static void gtk_socket_grab_notify (GtkWidget *widget,
|
|
|
|
gboolean was_grabbed);
|
2003-08-01 19:51:05 +00:00
|
|
|
static gboolean gtk_socket_key_event (GtkWidget *widget,
|
2001-07-03 14:14:30 +00:00
|
|
|
GdkEventKey *event);
|
|
|
|
static gboolean gtk_socket_focus (GtkWidget *widget,
|
|
|
|
GtkDirectionType direction);
|
|
|
|
static void gtk_socket_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void gtk_socket_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
2011-01-28 12:02:52 +00:00
|
|
|
static void gtk_socket_add_window (GtkSocket *socket,
|
2011-01-28 14:20:54 +00:00
|
|
|
Window xid,
|
2011-01-28 12:02:52 +00:00
|
|
|
gboolean need_reparent);
|
|
|
|
static GdkFilterReturn gtk_socket_filter_func (GdkXEvent *gdk_xevent,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static gboolean xembed_get_info (GdkWindow *gdk_window,
|
|
|
|
unsigned long *version,
|
|
|
|
unsigned long *flags);
|
|
|
|
|
|
|
|
/* From Tk */
|
|
|
|
#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20
|
2001-07-03 14:14:30 +00:00
|
|
|
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
/* Local data */
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint accel_key;
|
|
|
|
GdkModifierType accel_mods;
|
|
|
|
} GrabbedKey;
|
|
|
|
|
2001-07-05 02:58:34 +00:00
|
|
|
enum {
|
|
|
|
PLUG_ADDED,
|
|
|
|
PLUG_REMOVED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint socket_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER)
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (object);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *priv = socket->priv;
|
|
|
|
|
|
|
|
g_object_unref (priv->accel_group);
|
2002-02-24 01:52:14 +00:00
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object);
|
2002-02-24 01:52:14 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_class_init (GtkSocketClass *class)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkContainerClass *container_class;
|
2002-02-24 01:52:14 +00:00
|
|
|
GObjectClass *gobject_class;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
gobject_class = (GObjectClass *) class;
|
1998-11-24 04:45:29 +00:00
|
|
|
widget_class = (GtkWidgetClass*) class;
|
|
|
|
container_class = (GtkContainerClass*) class;
|
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
gobject_class->finalize = gtk_socket_finalize;
|
2002-06-06 15:38:39 +00:00
|
|
|
gobject_class->notify = gtk_socket_notify;
|
2002-02-24 01:52:14 +00:00
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
widget_class->realize = gtk_socket_realize;
|
|
|
|
widget_class->unrealize = gtk_socket_unrealize;
|
2010-10-27 15:17:40 +00:00
|
|
|
widget_class->get_preferred_width = gtk_socket_get_preferred_width;
|
|
|
|
widget_class->get_preferred_height = gtk_socket_get_preferred_height;
|
1998-11-24 04:45:29 +00:00
|
|
|
widget_class->size_allocate = gtk_socket_size_allocate;
|
2001-04-19 20:36:46 +00:00
|
|
|
widget_class->hierarchy_changed = gtk_socket_hierarchy_changed;
|
|
|
|
widget_class->grab_notify = gtk_socket_grab_notify;
|
2003-08-01 19:51:05 +00:00
|
|
|
widget_class->key_press_event = gtk_socket_key_event;
|
|
|
|
widget_class->key_release_event = gtk_socket_key_event;
|
2001-06-08 18:09:34 +00:00
|
|
|
widget_class->focus = gtk_socket_focus;
|
2004-03-04 21:58:26 +00:00
|
|
|
|
2010-10-19 17:31:38 +00:00
|
|
|
/* We don't want to show_all the in-process plug, if any.
|
2004-03-04 21:58:26 +00:00
|
|
|
*/
|
|
|
|
widget_class->show_all = gtk_widget_show;
|
2010-12-18 05:45:13 +00:00
|
|
|
|
2001-07-03 14:14:30 +00:00
|
|
|
container_class->remove = gtk_socket_remove;
|
|
|
|
container_class->forall = gtk_socket_forall;
|
2001-07-05 02:58:34 +00:00
|
|
|
|
2007-07-11 22:21:06 +00:00
|
|
|
/**
|
|
|
|
* GtkSocket::plug-added:
|
|
|
|
* @socket_: the object which received the signal
|
|
|
|
*
|
|
|
|
* This signal is emitted when a client is successfully
|
|
|
|
* added to the socket.
|
|
|
|
*/
|
2001-07-05 02:58:34 +00:00
|
|
|
socket_signals[PLUG_ADDED] =
|
2008-08-08 14:36:41 +00:00
|
|
|
g_signal_new (I_("plug-added"),
|
2001-07-05 02:58:34 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkSocketClass, plug_added),
|
|
|
|
NULL, NULL,
|
2001-11-17 23:28:51 +00:00
|
|
|
_gtk_marshal_VOID__VOID,
|
2002-10-13 19:34:42 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2007-07-11 22:21:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkSocket::plug-removed:
|
|
|
|
* @socket_: the object which received the signal
|
|
|
|
*
|
|
|
|
* This signal is emitted when a client is removed from the socket.
|
|
|
|
* The default action is to destroy the #GtkSocket widget, so if you
|
|
|
|
* want to reuse it you must add a signal handler that returns %TRUE.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE to stop other handlers from being invoked.
|
|
|
|
*/
|
2001-07-05 02:58:34 +00:00
|
|
|
socket_signals[PLUG_REMOVED] =
|
2008-08-08 14:36:41 +00:00
|
|
|
g_signal_new (I_("plug-removed"),
|
2001-07-05 02:58:34 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkSocketClass, plug_removed),
|
|
|
|
_gtk_boolean_handled_accumulator, NULL,
|
2001-11-17 23:28:51 +00:00
|
|
|
_gtk_marshal_BOOLEAN__VOID,
|
2001-07-05 02:58:34 +00:00
|
|
|
G_TYPE_BOOLEAN, 0);
|
2005-11-21 16:24:59 +00:00
|
|
|
|
|
|
|
g_type_class_add_private (gobject_class, sizeof (GtkSocketPrivate));
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_socket_init (GtkSocket *socket)
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
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);
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2001-07-05 02:58:34 +00:00
|
|
|
/**
|
|
|
|
* gtk_socket_new:
|
|
|
|
*
|
|
|
|
* Create a new empty #GtkSocket.
|
|
|
|
*
|
|
|
|
* Return value: the new #GtkSocket.
|
|
|
|
**/
|
1998-11-24 04:45:29 +00:00
|
|
|
GtkWidget*
|
2000-02-13 08:16:48 +00:00
|
|
|
gtk_socket_new (void)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
|
|
|
GtkSocket *socket;
|
|
|
|
|
2001-04-19 20:36:46 +00:00
|
|
|
socket = g_object_new (GTK_TYPE_SOCKET, NULL);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
|
|
|
return GTK_WIDGET (socket);
|
|
|
|
}
|
|
|
|
|
2001-07-05 02:58:34 +00:00
|
|
|
/**
|
|
|
|
* gtk_socket_add_id:
|
2002-11-08 19:41:50 +00:00
|
|
|
* @socket_: a #GtkSocket
|
2011-01-28 14:20:54 +00:00
|
|
|
* @window: the Window of a client participating in the XEMBED protocol.
|
2001-07-05 02:58:34 +00:00
|
|
|
*
|
|
|
|
* Adds an XEMBED client, such as a #GtkPlug, to the #GtkSocket. The
|
|
|
|
* client may be in the same process or in a different process.
|
|
|
|
*
|
|
|
|
* To embed a #GtkPlug in a #GtkSocket, you can either create the
|
2002-01-09 00:02:30 +00:00
|
|
|
* #GtkPlug with <literal>gtk_plug_new (0)</literal>, call
|
|
|
|
* gtk_plug_get_id() to get the window ID of the plug, and then pass that to the
|
2001-07-05 02:58:34 +00:00
|
|
|
* gtk_socket_add_id(), or you can call gtk_socket_get_id() to get the
|
|
|
|
* window ID for the socket, and call gtk_plug_new() passing in that
|
|
|
|
* ID.
|
|
|
|
*
|
|
|
|
* The #GtkSocket must have already be added into a toplevel window
|
|
|
|
* before you can make this call.
|
|
|
|
**/
|
|
|
|
void
|
2005-07-21 13:31:03 +00:00
|
|
|
gtk_socket_add_id (GtkSocket *socket,
|
2011-01-28 14:20:54 +00:00
|
|
|
Window window)
|
2001-07-05 02:58:34 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_SOCKET (socket));
|
2010-09-18 23:57:32 +00:00
|
|
|
g_return_if_fail (_gtk_widget_get_anchored (GTK_WIDGET (socket)));
|
2001-07-05 02:58:34 +00:00
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (socket)))
|
2001-07-05 02:58:34 +00:00
|
|
|
gtk_widget_realize (GTK_WIDGET (socket));
|
|
|
|
|
2011-01-28 14:20:54 +00:00
|
|
|
gtk_socket_add_window (socket, window, TRUE);
|
2001-07-05 02:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_socket_get_id:
|
2002-11-08 19:41:50 +00:00
|
|
|
* @socket_: a #GtkSocket.
|
2001-07-05 02:58:34 +00:00
|
|
|
*
|
|
|
|
* Gets the window ID of a #GtkSocket widget, which can then
|
|
|
|
* be used to create a client embedded inside the socket, for
|
2002-01-09 00:02:30 +00:00
|
|
|
* instance with gtk_plug_new().
|
Doc typo fix. (#68172)
* gtk/gtksocket.c (gtk_socket_get_id): Doc typo fix. (#68172)
* gtk/gtktreemodel.c (gtk_tree_path_is_descendant): Fix docs.
* gtk/gtktreemodel.c (gtk_tree_model_rows_reordered): Document.
* gtk/gtkwindow.c (gtk_window_remove_accel_group): Fix docs.
* gtk/gtkrc.c (gtk_rc_get_style_by_paths),
gtk/gtkwidget.c (gtk_widget_get_toplevel,
gtk_widget_push_composite_child), gtk/gtkdialog.c
(gtk_dialog_new_with_buttons, gtk_dialog_run): Keep gtk-doc
from messing up the indentation of inline examples.
* gtk/gtkmain.c, gtk/gtkrc.c: Consistently call g_getenv()
instead of getenv().
* gtk/gtktreemodel.c, gtk/gtkaccelgroup.c, gtk/gtkclipboard.c,
gtk/gtkdnd.c, gtk/gtkiconfactory.c, gtk/gtkrc.c,
gtk/gtkstyle.c, gtk/gtkselection.c: Doc fixes.
* gtk/gtkaccelmap.c (gtk_accel_map_add_filter,
gtk_accel_map_foreach_unfiltered, gtk_accel_map_load_scanner):
Document.
* gtk/tmpl/gtksocket.sgml: Mention gtk_socket_get_id()
instead of GTK_WINDOW_XWINDOW(). (#68172)
* gtk/gtk-sections.txt: Move functions which are documented
as "private" or "internal" into Private subsections.
* gtk/tmpl/gtkdnd.sgml, gtk/tmpl/gtkobject.sgml,
gtk/tmpl/gtkrc.sgml, gtk/tmpl/gtktooltips.sgml,
gtk/tmpl/gtkwidget.sgml, gtk/tmpl/gtkclipboard.sgml,
gtk/tmpl/gtkstyle.sgml, gtk/tmpl/gtkselection.sgml,
gtk/tmpl/gtkfeatures.sgml: Minor markup fixes.
* gtk/tmpl/gtksignal.sgml: Add link to GLib signal docs.
* gtk/tmpl/gtkpreview.sgml, gtk/tmpl/gtktext.sgml,
gtk/tmpl/gtktree.sgml: Remove "deprecated" from short desc.
* gtk/tmpl/gtkrc.sgml: Correct names of default RC files.
2002-01-08 00:04:57 +00:00
|
|
|
*
|
|
|
|
* The #GtkSocket must have already be added into a toplevel window
|
|
|
|
* before you can make this call.
|
2001-07-05 02:58:34 +00:00
|
|
|
*
|
|
|
|
* Return value: the window ID for the socket
|
|
|
|
**/
|
2011-01-28 14:20:54 +00:00
|
|
|
Window
|
2001-07-05 02:58:34 +00:00
|
|
|
gtk_socket_get_id (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_SOCKET (socket), 0);
|
2010-09-18 23:57:32 +00:00
|
|
|
g_return_val_if_fail (_gtk_widget_get_anchored (GTK_WIDGET (socket)), 0);
|
2001-07-05 02:58:34 +00:00
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (!gtk_widget_get_realized (GTK_WIDGET (socket)))
|
2001-07-05 02:58:34 +00:00
|
|
|
gtk_widget_realize (GTK_WIDGET (socket));
|
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket)));
|
2001-07-05 02:58:34 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 11:08:13 +00:00
|
|
|
/**
|
|
|
|
* gtk_socket_get_plug_window:
|
|
|
|
* @socket_: a #GtkSocket.
|
|
|
|
*
|
|
|
|
* Retrieves the window of the plug. Use this to check if the plug has
|
|
|
|
* been created inside of the socket.
|
|
|
|
*
|
2010-09-21 04:18:11 +00:00
|
|
|
* Return value: (transfer none): the window of the plug if available, or %NULL
|
2008-06-20 11:08:13 +00:00
|
|
|
*
|
2008-06-20 13:54:31 +00:00
|
|
|
* Since: 2.14
|
2008-06-20 11:08:13 +00:00
|
|
|
**/
|
|
|
|
GdkWindow*
|
|
|
|
gtk_socket_get_plug_window (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_SOCKET (socket), NULL);
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
return socket->priv->plug_window;
|
2008-06-20 11:08:13 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_realize (GtkWidget *widget)
|
|
|
|
{
|
2010-08-11 21:00:34 +00:00
|
|
|
GtkAllocation allocation;
|
2008-02-07 16:59:42 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-08-11 21:00:34 +00:00
|
|
|
GdkWindow *window;
|
1998-11-24 04:45:29 +00:00
|
|
|
GdkWindowAttr attributes;
|
2011-01-28 12:02:52 +00:00
|
|
|
XWindowAttributes xattrs;
|
1998-11-24 04:45:29 +00:00
|
|
|
gint attributes_mask;
|
|
|
|
|
2010-03-06 10:51:33 +00:00
|
|
|
gtk_widget_set_realized (widget, TRUE);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-08-11 21:00:34 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
2010-08-11 21:00:34 +00:00
|
|
|
attributes.x = allocation.x;
|
|
|
|
attributes.y = allocation.y;
|
|
|
|
attributes.width = allocation.width;
|
|
|
|
attributes.height = allocation.height;
|
1998-11-24 04:45:29 +00:00
|
|
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
attributes.visual = gtk_widget_get_visual (widget);
|
|
|
|
attributes.event_mask = GDK_FOCUS_CHANGE_MASK;
|
|
|
|
|
2010-08-28 16:04:08 +00:00
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-08-11 21:00:34 +00:00
|
|
|
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);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2011-01-04 01:09:11 +00:00
|
|
|
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
|
|
|
|
window);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
GDK_WINDOW_XID (window),
|
|
|
|
&xattrs);
|
|
|
|
|
|
|
|
/* Sooooo, it turns out that mozilla, as per the gtk2xt code selects
|
|
|
|
for input on the socket with a mask of 0x0fffff (for god knows why)
|
|
|
|
which includes ButtonPressMask causing a BadAccess if someone else
|
|
|
|
also selects for this. As per the client-side windows merge we always
|
|
|
|
normally selects for button press so we can emulate it on client
|
|
|
|
side children that selects for button press. However, we don't need
|
|
|
|
this for GtkSocket, so we unselect it here, fixing the crashes in
|
|
|
|
firefox. */
|
|
|
|
XSelectInput (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
GDK_WINDOW_XID (window),
|
|
|
|
(xattrs.your_event_mask & ~ButtonPressMask) |
|
|
|
|
SubstructureNotifyMask | SubstructureRedirectMask);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-08-11 21:00:34 +00:00
|
|
|
gdk_window_add_filter (window,
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_filter_func,
|
2005-07-21 13:31:03 +00:00
|
|
|
widget);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
|
|
|
/* We sync here so that we make sure that if the XID for
|
|
|
|
* our window is passed to another application, SubstructureRedirectMask
|
|
|
|
* will be set by the time the other app creates its window.
|
|
|
|
*/
|
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com>
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
* gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(),
make internals multihead aware.
* gtk/gtkcolorsel.[ch]: Add
gtk_color_selection_set_change_palette_with_screen_hook () [ugh!]
make up for non-multihead safety of
gtk_color_selection_set_change_palette_hook()
* gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add
gtk_{invisible,menu,window}_set_screen(); add "screen" properties
for GtkWindow and GtkMenu.
* gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(),
gtk_plug_new_for_display(). Multihead fixes.
* gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(),
make internals multihead aware.
* gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get
rid of now-useless gtk_settings_constructor().
* gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix
check/radio button indicators bitmap handling to be multihead
safe.
* gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(),
gtk_widget_get_display(), gtk_widget_get_clipboard(),
gtk_widget_get_root_window().
* gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c
gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c
gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c
gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c
gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c
gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c
gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c
gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c:
misc mechanical multihead-safety fixes.
* gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for
the dropper, look up the color palette only at realization time,
other multihead fixes.
* gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when
unrealizing.
* gtk/gtkentry.c: Only claim ownership of the primary selection
when realized, misc multihead fixes.
* gtk/gtkfontsel.c: Only fill in fonts when attached to a screen,
fix gtk_font_selection_get_font() for multihead.
* gtk/gtkgc.c: make the depth => drawable hash per-screen.
* gtk/gtkinvisible.c: Add a constructor that realizes the
widget, so we get a realized widget with g_object_new() as
well gtk_invisible_new() as before.
* gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap
variables.
* gtk/gtktextdisplay.c: Add warnings if stipple bitmaps
are used on the wrong screen.
* gtk/gtktoolbar.c: Make handling of GtkSettings-based layout
read properties and connect to settings when the screen is changed,
rather than on init/finalize.
* gtk/gtkwindow.c: Fix icon handing to be multihead safe ...
default icon pixmaps/mask are only shared between windows on the
same screen. Misc multihead fixes.
Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.c (gtk_clipboard_get_for_display):
Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE.
2002-04-29 Alex Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkproperty-fb.c (gdk_property_get):
Fix silly bug, noticed by Sven Neumann.
Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix
so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
|
|
|
gdk_display_sync (gtk_widget_get_display (widget));
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_end_embedding:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
*
|
|
|
|
* Called to end the embedding of a plug in the socket.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_end_embedding (GtkSocket *socket)
|
2002-02-24 01:52:14 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2002-02-24 01:52:14 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
g_object_unref (private->plug_window);
|
|
|
|
private->plug_window = NULL;
|
|
|
|
private->current_width = 0;
|
|
|
|
private->current_height = 0;
|
2002-05-16 23:38:01 +00:00
|
|
|
private->resize_count = 0;
|
2002-02-24 01:52:14 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_accel_group_disconnect (private->accel_group, NULL);
|
2002-02-24 01:52:14 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_unrealize (GtkWidget *widget)
|
|
|
|
{
|
2001-07-05 02:58:34 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-03-06 10:51:33 +00:00
|
|
|
gtk_widget_set_realized (widget, FALSE);
|
2001-10-31 23:58:31 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
2001-07-05 02:58:34 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
_gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket);
|
2001-07-05 02:58:34 +00:00
|
|
|
}
|
2010-12-18 05:45:13 +00:00
|
|
|
else if (private->plug_window)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_end_embedding (socket);
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 09:44:32 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize (widget);
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
2008-08-12 09:06:34 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_size_request (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
GtkSocketPrivate *private = socket->priv;
|
|
|
|
XSizeHints hints;
|
|
|
|
long supplied;
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
|
|
|
|
private->request_width = 1;
|
|
|
|
private->request_height = 1;
|
|
|
|
|
|
|
|
if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (private->plug_window),
|
|
|
|
GDK_WINDOW_XID (private->plug_window),
|
|
|
|
&hints, &supplied))
|
|
|
|
{
|
|
|
|
if (hints.flags & PMinSize)
|
|
|
|
{
|
|
|
|
private->request_width = MAX (hints.min_width, 1);
|
|
|
|
private->request_height = MAX (hints.min_height, 1);
|
|
|
|
}
|
|
|
|
else if (hints.flags & PBaseSize)
|
|
|
|
{
|
|
|
|
private->request_width = MAX (hints.base_width, 1);
|
|
|
|
private->request_height = MAX (hints.base_height, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private->have_size = TRUE;
|
|
|
|
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
}
|
|
|
|
|
2008-08-12 09:06:34 +00:00
|
|
|
static void
|
2010-10-27 15:17:40 +00:00
|
|
|
gtk_socket_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2001-07-05 02:58:34 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_widget_get_preferred_width (private->plug_widget, minimum, natural);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->is_mapped && !private->have_size && private->plug_window)
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_size_request (socket);
|
1999-02-21 19:25:53 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->is_mapped && private->have_size)
|
|
|
|
*minimum = *natural = MAX (private->request_width, 1);
|
2001-07-03 14:14:30 +00:00
|
|
|
else
|
2010-10-27 15:17:40 +00:00
|
|
|
*minimum = *natural = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_socket_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2010-10-27 15:17:40 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
2010-10-27 15:17:40 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_widget_get_preferred_height (private->plug_widget, minimum, natural);
|
2010-10-27 15:17:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->is_mapped && !private->have_size && private->plug_window)
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_size_request (socket);
|
2010-10-27 15:17:40 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->is_mapped && private->have_size)
|
|
|
|
*minimum = *natural = MAX (private->request_height, 1);
|
2010-10-27 15:17:40 +00:00
|
|
|
else
|
|
|
|
*minimum = *natural = 1;
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_send_configure_event (GtkSocket *socket)
|
|
|
|
{
|
|
|
|
GtkAllocation allocation;
|
|
|
|
XConfigureEvent xconfigure;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
g_return_if_fail (socket->priv->plug_window != NULL);
|
|
|
|
|
|
|
|
memset (&xconfigure, 0, sizeof (xconfigure));
|
|
|
|
xconfigure.type = ConfigureNotify;
|
|
|
|
|
|
|
|
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->priv->plug_window, &x, &y);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation);
|
|
|
|
xconfigure.x = x;
|
|
|
|
xconfigure.y = y;
|
|
|
|
xconfigure.width = allocation.width;
|
|
|
|
xconfigure.height = allocation.height;
|
|
|
|
|
|
|
|
xconfigure.border_width = 0;
|
|
|
|
xconfigure.above = None;
|
|
|
|
xconfigure.override_redirect = False;
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window),
|
|
|
|
GDK_WINDOW_XID (socket->priv->plug_window),
|
|
|
|
False, NoEventMask, (XEvent *)&xconfigure);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
}
|
|
|
|
|
1998-11-24 04:45:29 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
2008-02-07 16:59:42 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-08-11 21:00:34 +00:00
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
2010-03-02 06:16:02 +00:00
|
|
|
if (gtk_widget_get_realized (widget))
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2010-08-11 21:00:34 +00:00
|
|
|
gdk_window_move_resize (gtk_widget_get_window (widget),
|
1998-11-24 04:45:29 +00:00
|
|
|
allocation->x, allocation->y,
|
|
|
|
allocation->width, allocation->height);
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
|
|
|
GtkAllocation child_allocation;
|
|
|
|
|
|
|
|
child_allocation.x = 0;
|
|
|
|
child_allocation.y = 0;
|
|
|
|
child_allocation.width = allocation->width;
|
|
|
|
child_allocation.height = allocation->height;
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_widget_size_allocate (private->plug_widget, &child_allocation);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
2010-12-18 05:45:13 +00:00
|
|
|
else if (private->plug_window)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
1999-02-21 19:25:53 +00:00
|
|
|
gdk_error_trap_push ();
|
2010-12-18 05:45:13 +00:00
|
|
|
|
|
|
|
if (allocation->width != private->current_width ||
|
|
|
|
allocation->height != private->current_height)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gdk_window_move_resize (private->plug_window,
|
1998-11-24 04:45:29 +00:00
|
|
|
0, 0,
|
|
|
|
allocation->width, allocation->height);
|
2002-05-16 23:38:01 +00:00
|
|
|
if (private->resize_count)
|
|
|
|
private->resize_count--;
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket - allocated: %d %d",
|
|
|
|
allocation->width, allocation->height));
|
2010-12-18 05:45:13 +00:00
|
|
|
private->current_width = allocation->width;
|
|
|
|
private->current_height = allocation->height;
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->need_map)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gdk_window_show (private->plug_window);
|
|
|
|
private->need_map = FALSE;
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2002-05-16 23:38:01 +00:00
|
|
|
while (private->resize_count)
|
|
|
|
{
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_send_configure_event (socket);
|
2002-05-16 23:38:01 +00:00
|
|
|
private->resize_count--;
|
2005-07-21 13:31:03 +00:00
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket - sending synthetic configure: %d %d",
|
|
|
|
allocation->width, allocation->height));
|
2002-05-16 23:38:01 +00:00
|
|
|
}
|
2010-09-20 20:38:48 +00:00
|
|
|
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_send_key_event (GtkSocket *socket,
|
|
|
|
GdkEvent *gdk_event,
|
|
|
|
gboolean mask_key_presses)
|
|
|
|
{
|
|
|
|
XKeyEvent xkey;
|
|
|
|
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->priv->plug_window);
|
|
|
|
xkey.root = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
|
|
|
|
xkey.subwindow = None;
|
|
|
|
xkey.time = gdk_event->key.time;
|
|
|
|
xkey.x = 0;
|
|
|
|
xkey.y = 0;
|
|
|
|
xkey.x_root = 0;
|
|
|
|
xkey.y_root = 0;
|
|
|
|
xkey.state = gdk_event->key.state;
|
|
|
|
xkey.keycode = gdk_event->key.hardware_keycode;
|
|
|
|
xkey.same_screen = True;/* FIXME ? */
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XSendEvent (GDK_WINDOW_XDISPLAY (socket->priv->plug_window),
|
|
|
|
GDK_WINDOW_XID (socket->priv->plug_window),
|
|
|
|
False,
|
|
|
|
(mask_key_presses ? KeyPressMask : NoEventMask),
|
|
|
|
(XEvent *)&xkey);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
}
|
|
|
|
|
2003-04-22 18:33:45 +00:00
|
|
|
static gboolean
|
|
|
|
activate_key (GtkAccelGroup *accel_group,
|
|
|
|
GObject *acceleratable,
|
|
|
|
guint accel_key,
|
|
|
|
GdkModifierType accel_mods,
|
|
|
|
GrabbedKey *grabbed_key)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2002-02-24 01:52:14 +00:00
|
|
|
GdkEvent *gdk_event = gtk_get_current_event ();
|
2001-04-19 20:36:46 +00:00
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
GtkSocket *socket = g_object_get_data (G_OBJECT (accel_group), "gtk-socket");
|
2003-04-22 18:33:45 +00:00
|
|
|
gboolean retval = FALSE;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (gdk_event && gdk_event->type == GDK_KEY_PRESS && socket->priv->plug_window)
|
2002-02-24 01:52:14 +00:00
|
|
|
{
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_send_key_event (socket, gdk_event, FALSE);
|
2003-04-22 18:33:45 +00:00
|
|
|
retval = TRUE;
|
2002-02-24 01:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gdk_event)
|
|
|
|
gdk_event_free (gdk_event);
|
2003-04-22 18:33:45 +00:00
|
|
|
|
|
|
|
return retval;
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2002-02-24 01:52:14 +00:00
|
|
|
find_accel_key (GtkAccelKey *key,
|
|
|
|
GClosure *closure,
|
|
|
|
gpointer data)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2002-02-24 01:52:14 +00:00
|
|
|
GrabbedKey *grabbed_key = data;
|
|
|
|
|
|
|
|
return (key->accel_key == grabbed_key->accel_key &&
|
|
|
|
key->accel_mods == grabbed_key->accel_mods);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_add_grabbed_key:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
* @keyval: a key
|
|
|
|
* @modifiers: modifiers for the key
|
|
|
|
*
|
|
|
|
* Called from the GtkSocket platform-specific backend when the
|
|
|
|
* corresponding plug has told the socket to grab a key.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_add_grabbed_key (GtkSocket *socket,
|
|
|
|
guint keyval,
|
|
|
|
GdkModifierType modifiers)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2002-02-24 01:52:14 +00:00
|
|
|
GClosure *closure;
|
|
|
|
GrabbedKey *grabbed_key;
|
2001-04-19 20:36:46 +00:00
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
grabbed_key = g_new (GrabbedKey, 1);
|
|
|
|
|
|
|
|
grabbed_key->accel_key = keyval;
|
|
|
|
grabbed_key->accel_mods = modifiers;
|
2001-04-19 20:36:46 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (gtk_accel_group_find (socket->priv->accel_group,
|
2002-02-24 01:52:14 +00:00
|
|
|
find_accel_key,
|
|
|
|
&grabbed_key))
|
|
|
|
{
|
|
|
|
g_warning ("GtkSocket: request to add already present grabbed key %u,%#x\n",
|
|
|
|
keyval, modifiers);
|
|
|
|
g_free (grabbed_key);
|
|
|
|
return;
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 01:52:14 +00:00
|
|
|
closure = g_cclosure_new (G_CALLBACK (activate_key), grabbed_key, (GClosureNotify)g_free);
|
2001-04-19 20:36:46 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_accel_group_connect (socket->priv->accel_group, keyval, modifiers, GTK_ACCEL_LOCKED,
|
2002-02-24 01:52:14 +00:00
|
|
|
closure);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_remove_grabbed_key:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
* @keyval: a key
|
|
|
|
* @modifiers: modifiers for the key
|
|
|
|
*
|
|
|
|
* Called from the GtkSocket backend when the corresponding plug has
|
|
|
|
* told the socket to remove a key grab.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_remove_grabbed_key (GtkSocket *socket,
|
|
|
|
guint keyval,
|
|
|
|
GdkModifierType modifiers)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
if (!gtk_accel_group_disconnect_key (socket->priv->accel_group, keyval, modifiers))
|
2009-10-27 20:27:28 +00:00
|
|
|
g_warning ("GtkSocket: request to remove non-present grabbed key %u,%#x\n",
|
|
|
|
keyval, modifiers);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
static void
|
|
|
|
socket_update_focus_in (GtkSocket *socket)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2002-06-06 15:38:39 +00:00
|
|
|
gboolean focus_in = FALSE;
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_window)
|
2002-06-06 15:38:39 +00:00
|
|
|
{
|
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2010-01-04 06:49:26 +00:00
|
|
|
if (gtk_widget_is_toplevel (toplevel) &&
|
2010-08-17 13:14:58 +00:00
|
|
|
gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)) &&
|
2002-06-06 15:38:39 +00:00
|
|
|
gtk_widget_is_focus (GTK_WIDGET (socket)))
|
|
|
|
focus_in = TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (focus_in != private->focus_in)
|
2002-06-06 15:38:39 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
private->focus_in = focus_in;
|
2002-01-29 19:58:43 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
if (focus_in)
|
|
|
|
_gtk_xembed_send_focus_message (private->plug_window,
|
|
|
|
XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
|
|
|
else
|
|
|
|
_gtk_xembed_send_message (private->plug_window,
|
|
|
|
XEMBED_FOCUS_OUT, 0, 0, 0);
|
2002-06-06 15:38:39 +00:00
|
|
|
}
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
static void
|
|
|
|
socket_update_active (GtkSocket *socket)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2002-06-06 15:38:39 +00:00
|
|
|
gboolean active = FALSE;
|
2002-01-29 19:58:43 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_window)
|
2002-06-06 15:38:39 +00:00
|
|
|
{
|
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2010-01-04 06:49:26 +00:00
|
|
|
if (gtk_widget_is_toplevel (toplevel) &&
|
2010-08-17 13:14:58 +00:00
|
|
|
gtk_window_is_active (GTK_WINDOW (toplevel)))
|
2002-06-06 15:38:39 +00:00
|
|
|
active = TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (active != private->active)
|
2002-06-06 15:38:39 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
private->active = active;
|
2002-06-06 15:38:39 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
_gtk_xembed_send_message (private->plug_window,
|
|
|
|
active ? XEMBED_WINDOW_ACTIVATE : XEMBED_WINDOW_DEACTIVATE,
|
|
|
|
0, 0, 0);
|
2002-06-06 15:38:39 +00:00
|
|
|
}
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-01 00:57:21 +00:00
|
|
|
gtk_socket_hierarchy_changed (GtkWidget *widget,
|
|
|
|
GtkWidget *old_toplevel)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2001-04-19 20:36:46 +00:00
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
|
|
|
|
|
|
|
if (toplevel && !GTK_IS_WINDOW (toplevel))
|
|
|
|
toplevel = NULL;
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (toplevel != private->toplevel)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->toplevel)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_window_remove_accel_group (GTK_WINDOW (private->toplevel), private->accel_group);
|
|
|
|
g_signal_handlers_disconnect_by_func (private->toplevel,
|
2002-10-13 19:34:42 +00:00
|
|
|
socket_update_focus_in,
|
|
|
|
socket);
|
2010-12-18 05:45:13 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (private->toplevel,
|
2002-10-13 19:34:42 +00:00
|
|
|
socket_update_active,
|
|
|
|
socket);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
private->toplevel = toplevel;
|
2001-04-19 20:36:46 +00:00
|
|
|
|
|
|
|
if (toplevel)
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (private->toplevel), private->accel_group);
|
|
|
|
g_signal_connect_swapped (private->toplevel, "notify::has-toplevel-focus",
|
2002-06-06 15:38:39 +00:00
|
|
|
G_CALLBACK (socket_update_focus_in), socket);
|
2010-12-18 05:45:13 +00:00
|
|
|
g_signal_connect_swapped (private->toplevel, "notify::is-active",
|
2002-06-06 15:38:39 +00:00
|
|
|
G_CALLBACK (socket_update_active), socket);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
2002-06-06 15:38:39 +00:00
|
|
|
|
|
|
|
socket_update_focus_in (socket);
|
|
|
|
socket_update_active (socket);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_socket_grab_notify (GtkWidget *widget,
|
|
|
|
gboolean was_grabbed)
|
|
|
|
{
|
2002-01-27 00:36:38 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (!socket->priv->same_app)
|
2011-01-28 12:02:52 +00:00
|
|
|
_gtk_xembed_send_message (socket->priv->plug_window,
|
|
|
|
was_grabbed ? XEMBED_MODALITY_OFF : XEMBED_MODALITY_ON,
|
|
|
|
0, 0, 0);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-08-01 19:51:05 +00:00
|
|
|
gtk_socket_key_event (GtkWidget *widget,
|
|
|
|
GdkEventKey *event)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2001-04-19 20:36:46 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (gtk_widget_has_focus (widget) && private->plug_window && !private->plug_widget)
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_send_key_event (socket, (GdkEvent *) event, FALSE);
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2001-04-19 20:36:46 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_notify (GObject *object,
|
|
|
|
GParamSpec *pspec)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2011-02-20 21:44:26 +00:00
|
|
|
if (strcmp (pspec->name, "is-focus") == 0)
|
|
|
|
socket_update_focus_in (GTK_SOCKET (object));
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_claim_focus:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
* @send_event: huh?
|
|
|
|
*
|
|
|
|
* Claims focus for the socket. XXX send_event?
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_claim_focus (GtkSocket *socket,
|
|
|
|
gboolean send_event)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2010-03-02 03:40:38 +00:00
|
|
|
GtkWidget *widget = GTK_WIDGET (socket);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2010-03-02 03:40:38 +00:00
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
if (!send_event)
|
2010-12-18 05:45:13 +00:00
|
|
|
private->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */
|
1998-11-24 04:45:29 +00:00
|
|
|
|
|
|
|
/* Oh, the trickery... */
|
|
|
|
|
2010-03-02 03:40:38 +00:00
|
|
|
gtk_widget_set_can_focus (widget, TRUE);
|
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
gtk_widget_set_can_focus (widget, FALSE);
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2001-04-19 20:36:46 +00:00
|
|
|
static gboolean
|
2005-07-21 13:31:03 +00:00
|
|
|
gtk_socket_focus (GtkWidget *widget,
|
|
|
|
GtkDirectionType direction)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2008-02-07 16:59:42 +00:00
|
|
|
GtkSocket *socket = GTK_SOCKET (widget);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
|
|
|
return gtk_widget_child_focus (private->plug_widget, direction);
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2003-11-20 15:03:27 +00:00
|
|
|
if (!gtk_widget_is_focus (widget))
|
2001-04-19 20:36:46 +00:00
|
|
|
{
|
2011-01-28 12:02:52 +00:00
|
|
|
gint detail = -1;
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GTK_DIR_UP:
|
|
|
|
case GTK_DIR_LEFT:
|
|
|
|
case GTK_DIR_TAB_BACKWARD:
|
|
|
|
detail = XEMBED_FOCUS_LAST;
|
|
|
|
break;
|
|
|
|
case GTK_DIR_DOWN:
|
|
|
|
case GTK_DIR_RIGHT:
|
|
|
|
case GTK_DIR_TAB_FORWARD:
|
|
|
|
detail = XEMBED_FOCUS_FIRST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gtk_xembed_send_focus_message (private->plug_window, XEMBED_FOCUS_IN, detail);
|
|
|
|
gtk_socket_claim_focus (socket, FALSE);
|
2001-04-19 20:36:46 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
1998-11-24 04:45:29 +00:00
|
|
|
}
|
|
|
|
|
2001-07-03 14:14:30 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_remove (GtkContainer *container,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (container);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
g_return_if_fail (child == private->plug_widget);
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
_gtk_plug_remove_from_socket (GTK_PLUG (private->plug_widget), socket);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_socket_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
GtkSocket *socket = GTK_SOCKET (container);
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_widget)
|
|
|
|
(* callback) (private->plug_widget, callback_data);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_add_window:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* Adds a window to a GtkSocket.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_add_window (GtkSocket *socket,
|
2011-01-28 14:20:54 +00:00
|
|
|
Window xid,
|
2011-01-28 12:02:52 +00:00
|
|
|
gboolean need_reparent)
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
2001-07-03 14:14:30 +00:00
|
|
|
GtkWidget *widget = GTK_WIDGET (socket);
|
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com>
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
* gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(),
make internals multihead aware.
* gtk/gtkcolorsel.[ch]: Add
gtk_color_selection_set_change_palette_with_screen_hook () [ugh!]
make up for non-multihead safety of
gtk_color_selection_set_change_palette_hook()
* gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add
gtk_{invisible,menu,window}_set_screen(); add "screen" properties
for GtkWindow and GtkMenu.
* gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(),
gtk_plug_new_for_display(). Multihead fixes.
* gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(),
make internals multihead aware.
* gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get
rid of now-useless gtk_settings_constructor().
* gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix
check/radio button indicators bitmap handling to be multihead
safe.
* gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(),
gtk_widget_get_display(), gtk_widget_get_clipboard(),
gtk_widget_get_root_window().
* gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c
gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c
gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c
gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c
gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c
gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c
gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c
gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c:
misc mechanical multihead-safety fixes.
* gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for
the dropper, look up the color palette only at realization time,
other multihead fixes.
* gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when
unrealizing.
* gtk/gtkentry.c: Only claim ownership of the primary selection
when realized, misc multihead fixes.
* gtk/gtkfontsel.c: Only fill in fonts when attached to a screen,
fix gtk_font_selection_get_font() for multihead.
* gtk/gtkgc.c: make the depth => drawable hash per-screen.
* gtk/gtkinvisible.c: Add a constructor that realizes the
widget, so we get a realized widget with g_object_new() as
well gtk_invisible_new() as before.
* gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap
variables.
* gtk/gtktextdisplay.c: Add warnings if stipple bitmaps
are used on the wrong screen.
* gtk/gtktoolbar.c: Make handling of GtkSettings-based layout
read properties and connect to settings when the screen is changed,
rather than on init/finalize.
* gtk/gtkwindow.c: Fix icon handing to be multihead safe ...
default icon pixmaps/mask are only shared between windows on the
same screen. Misc multihead fixes.
Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.c (gtk_clipboard_get_for_display):
Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE.
2002-04-29 Alex Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkproperty-fb.c (gdk_property_get):
Fix silly bug, noticed by Sven Neumann.
Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix
so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
|
|
|
GdkDisplay *display = gtk_widget_get_display (widget);
|
2001-07-03 14:14:30 +00:00
|
|
|
gpointer user_data = NULL;
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
2011-01-28 12:02:52 +00:00
|
|
|
unsigned long version;
|
|
|
|
unsigned long flags;
|
2010-12-15 06:39:30 +00:00
|
|
|
|
2010-12-20 18:20:10 +00:00
|
|
|
if (GDK_IS_X11_DISPLAY (display))
|
2010-12-15 06:39:30 +00:00
|
|
|
private->plug_window = gdk_x11_window_lookup_for_display (display, xid);
|
|
|
|
else
|
|
|
|
private->plug_window = NULL;
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_window)
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
g_object_ref (private->plug_window);
|
|
|
|
gdk_window_get_user_data (private->plug_window, &user_data);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 06:39:30 +00:00
|
|
|
if (user_data) /* A widget's window in this process */
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
|
|
|
GtkWidget *child_widget = user_data;
|
|
|
|
|
|
|
|
if (!GTK_IS_PLUG (child_widget))
|
2010-12-15 06:39:30 +00:00
|
|
|
{
|
|
|
|
g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket");
|
|
|
|
private->plug_window = NULL;
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2001-07-03 14:14:30 +00:00
|
|
|
|
|
|
|
_gtk_plug_add_to_socket (GTK_PLUG (child_widget), socket);
|
|
|
|
}
|
2010-12-15 06:39:30 +00:00
|
|
|
else /* A foreign window */
|
1998-11-24 04:45:29 +00:00
|
|
|
{
|
|
|
|
GdkDragProtocol protocol;
|
1999-02-21 19:25:53 +00:00
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (!private->plug_window)
|
2010-12-15 06:39:30 +00:00
|
|
|
{
|
2010-12-20 18:20:10 +00:00
|
|
|
if (GDK_IS_X11_DISPLAY (display))
|
2010-12-15 06:39:30 +00:00
|
|
|
private->plug_window = gdk_x11_window_foreign_new_for_display (display, xid);
|
|
|
|
if (!private->plug_window) /* was deleted before we could get it */
|
|
|
|
{
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
XSelectInput (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))),
|
|
|
|
GDK_WINDOW_XID (private->plug_window),
|
|
|
|
StructureNotifyMask | PropertyChangeMask);
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2001-07-03 14:14:30 +00:00
|
|
|
if (gdk_error_trap_pop ())
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
g_object_unref (private->plug_window);
|
|
|
|
private->plug_window = NULL;
|
2001-07-03 14:14:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OK, we now will reliably get destroy notification on socket->plug_window */
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
|
|
|
|
if (need_reparent)
|
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
gdk_window_hide (private->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */
|
|
|
|
gdk_window_reparent (private->plug_window,
|
2010-08-11 21:00:34 +00:00
|
|
|
gtk_widget_get_window (widget),
|
|
|
|
0, 0);
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
private->have_size = FALSE;
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
private->xembed_version = -1;
|
|
|
|
if (xembed_get_info (private->plug_window, &version, &flags))
|
|
|
|
{
|
|
|
|
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 */
|
|
|
|
private->is_mapped = TRUE;
|
|
|
|
}
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
private->need_map = private->is_mapped;
|
2001-07-03 14:14:30 +00:00
|
|
|
|
2011-02-01 17:11:35 +00:00
|
|
|
protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
|
|
|
|
if (protocol)
|
2010-12-18 05:45:13 +00:00
|
|
|
gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window,
|
1998-11-24 04:45:29 +00:00
|
|
|
protocol, TRUE);
|
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com>
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
* gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(),
make internals multihead aware.
* gtk/gtkcolorsel.[ch]: Add
gtk_color_selection_set_change_palette_with_screen_hook () [ugh!]
make up for non-multihead safety of
gtk_color_selection_set_change_palette_hook()
* gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add
gtk_{invisible,menu,window}_set_screen(); add "screen" properties
for GtkWindow and GtkMenu.
* gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(),
gtk_plug_new_for_display(). Multihead fixes.
* gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(),
make internals multihead aware.
* gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get
rid of now-useless gtk_settings_constructor().
* gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix
check/radio button indicators bitmap handling to be multihead
safe.
* gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(),
gtk_widget_get_display(), gtk_widget_get_clipboard(),
gtk_widget_get_root_window().
* gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c
gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c
gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c
gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c
gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c
gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c
gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c
gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c:
misc mechanical multihead-safety fixes.
* gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for
the dropper, look up the color palette only at realization time,
other multihead fixes.
* gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when
unrealizing.
* gtk/gtkentry.c: Only claim ownership of the primary selection
when realized, misc multihead fixes.
* gtk/gtkfontsel.c: Only fill in fonts when attached to a screen,
fix gtk_font_selection_get_font() for multihead.
* gtk/gtkgc.c: make the depth => drawable hash per-screen.
* gtk/gtkinvisible.c: Add a constructor that realizes the
widget, so we get a realized widget with g_object_new() as
well gtk_invisible_new() as before.
* gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap
variables.
* gtk/gtktextdisplay.c: Add warnings if stipple bitmaps
are used on the wrong screen.
* gtk/gtktoolbar.c: Make handling of GtkSettings-based layout
read properties and connect to settings when the screen is changed,
rather than on init/finalize.
* gtk/gtkwindow.c: Fix icon handing to be multihead safe ...
default icon pixmaps/mask are only shared between windows on the
same screen. Misc multihead fixes.
Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.c (gtk_clipboard_get_for_display):
Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE.
2002-04-29 Alex Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkproperty-fb.c (gdk_property_get):
Fix silly bug, noticed by Sven Neumann.
Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix
so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
|
|
|
|
2010-09-19 03:17:31 +00:00
|
|
|
gdk_error_trap_pop_ignored ();
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
gdk_window_add_filter (private->plug_window,
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_socket_filter_func,
|
2005-07-21 13:31:03 +00:00
|
|
|
socket);
|
1998-11-24 04:45:29 +00:00
|
|
|
|
2011-01-28 12:02:52 +00:00
|
|
|
#ifdef HAVE_XFIXES
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XFixesChangeSaveSet (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (socket))),
|
|
|
|
GDK_WINDOW_XID (private->plug_window),
|
|
|
|
SetModeInsert, SaveSetRoot, SaveSetUnmap);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
#endif
|
|
|
|
_gtk_xembed_send_message (private->plug_window,
|
|
|
|
XEMBED_EMBEDDED_NOTIFY, 0,
|
|
|
|
GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (socket))),
|
|
|
|
private->xembed_version);
|
2005-07-21 13:31:03 +00:00
|
|
|
|
2002-06-06 15:38:39 +00:00
|
|
|
socket_update_active (socket);
|
|
|
|
socket_update_focus_in (socket);
|
|
|
|
|
2001-04-19 20:36:46 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (socket));
|
|
|
|
}
|
2001-07-05 02:58:34 +00:00
|
|
|
|
2010-12-18 05:45:13 +00:00
|
|
|
if (private->plug_window)
|
2002-10-13 19:34:42 +00:00
|
|
|
g_signal_emit (socket, socket_signals[PLUG_ADDED], 0);
|
2001-04-19 20:36:46 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_handle_map_request:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
*
|
|
|
|
* Called from the GtkSocket backend when the plug has been mapped.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_handle_map_request (GtkSocket *socket)
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
|
|
|
if (!private->is_mapped)
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
private->is_mapped = TRUE;
|
|
|
|
private->need_map = TRUE;
|
2005-07-21 13:31:03 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (socket));
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
2005-07-21 13:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_unmap_notify:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
*
|
|
|
|
* Called from the GtkSocket backend when the plug has been unmapped ???
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_unmap_notify (GtkSocket *socket)
|
2005-07-21 13:31:03 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
GtkSocketPrivate *private = socket->priv;
|
|
|
|
if (private->is_mapped)
|
2001-07-03 14:14:30 +00:00
|
|
|
{
|
2010-12-18 05:45:13 +00:00
|
|
|
private->is_mapped = FALSE;
|
2005-07-21 13:31:03 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (socket));
|
2001-07-03 14:14:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-21 13:31:03 +00:00
|
|
|
/**
|
2011-01-28 12:02:52 +00:00
|
|
|
* gtk_socket_advance_toplevel_focus:
|
2005-07-21 13:31:03 +00:00
|
|
|
*
|
|
|
|
* @socket: a #GtkSocket
|
|
|
|
* @direction: a direction
|
|
|
|
*
|
|
|
|
* Called from the GtkSocket backend when the corresponding plug
|
|
|
|
* has told the socket to move the focus.
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
static void
|
|
|
|
gtk_socket_advance_toplevel_focus (GtkSocket *socket,
|
|
|
|
GtkDirectionType direction)
|
2003-08-25 21:46:57 +00:00
|
|
|
{
|
|
|
|
GtkBin *bin;
|
|
|
|
GtkWindow *window;
|
|
|
|
GtkContainer *container;
|
2010-05-24 20:31:36 +00:00
|
|
|
GtkWidget *child;
|
2010-08-17 13:14:58 +00:00
|
|
|
GtkWidget *focus_widget;
|
2003-08-25 21:46:57 +00:00
|
|
|
GtkWidget *toplevel;
|
|
|
|
GtkWidget *old_focus_child;
|
|
|
|
GtkWidget *parent;
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
|
|
|
|
if (!toplevel)
|
|
|
|
return;
|
|
|
|
|
2010-01-04 06:49:26 +00:00
|
|
|
if (!gtk_widget_is_toplevel (toplevel) || GTK_IS_PLUG (toplevel))
|
2003-08-25 21:46:57 +00:00
|
|
|
{
|
|
|
|
gtk_widget_child_focus (toplevel,direction);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
container = GTK_CONTAINER (toplevel);
|
|
|
|
window = GTK_WINDOW (toplevel);
|
|
|
|
bin = GTK_BIN (toplevel);
|
|
|
|
|
|
|
|
/* This is a copy of gtk_window_focus(), modified so that we
|
|
|
|
* can detect wrap-around.
|
|
|
|
*/
|
2010-06-02 04:28:22 +00:00
|
|
|
old_focus_child = gtk_container_get_focus_child (container);
|
2003-08-25 21:46:57 +00:00
|
|
|
|
|
|
|
if (old_focus_child)
|
|
|
|
{
|
|
|
|
if (gtk_widget_child_focus (old_focus_child, direction))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* We are allowed exactly one wrap-around per sequence of focus
|
|
|
|
* events
|
|
|
|
*/
|
2011-01-28 12:02:52 +00:00
|
|
|
if (_gtk_xembed_get_focus_wrapped ())
|
2003-08-25 21:46:57 +00:00
|
|
|
return;
|
|
|
|
else
|
2011-01-28 12:02:52 +00:00
|
|
|
_gtk_xembed_set_focus_wrapped ();
|
2003-08-25 21:46:57 +00:00
|
|
|
}
|
|
|
|
|
2010-08-17 13:14:58 +00:00
|
|
|
focus_widget = gtk_window_get_focus (window);
|
|
|
|
if (window)
|
2003-08-25 21:46:57 +00:00
|
|
|
{
|
|
|
|
/* Wrapped off the end, clear the focus setting for the toplevel */
|
2010-08-17 13:14:58 +00:00
|
|
|
parent = gtk_widget_get_parent (focus_widget);
|
2003-08-25 21:46:57 +00:00
|
|
|
while (parent)
|
|
|
|
{
|
|
|
|
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
|
2010-08-11 21:00:34 +00:00
|
|
|
parent = gtk_widget_get_parent (parent);
|
2003-08-25 21:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (container), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now try to focus the first widget in the window */
|
2010-05-24 20:31:36 +00:00
|
|
|
child = gtk_bin_get_child (bin);
|
|
|
|
if (child)
|
2003-08-25 21:46:57 +00:00
|
|
|
{
|
2010-05-24 20:31:36 +00:00
|
|
|
if (gtk_widget_child_focus (child, direction))
|
2003-08-25 21:46:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-28 12:02:52 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
xembed_get_info (GdkWindow *window,
|
|
|
|
unsigned long *version,
|
|
|
|
unsigned long *flags)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_window_get_display (window);
|
|
|
|
Atom xembed_info_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO");
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, bytes_after;
|
|
|
|
unsigned char *data;
|
|
|
|
unsigned long *data_long;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
|
|
|
|
GDK_WINDOW_XID (window),
|
|
|
|
xembed_info_atom,
|
|
|
|
0, 2, False,
|
|
|
|
xembed_info_atom, &type, &format,
|
|
|
|
&nitems, &bytes_after, &data);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
|
|
|
|
if (status != Success)
|
|
|
|
return FALSE; /* Window vanished? */
|
|
|
|
|
|
|
|
if (type == None) /* No info property */
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (type != xembed_info_atom)
|
|
|
|
{
|
|
|
|
g_warning ("_XEMBED_INFO property has wrong type\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nitems < 2)
|
|
|
|
{
|
|
|
|
g_warning ("_XEMBED_INFO too short\n");
|
|
|
|
XFree (data);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_long = (unsigned long *)data;
|
|
|
|
if (version)
|
|
|
|
*version = data_long[0];
|
|
|
|
if (flags)
|
|
|
|
*flags = data_long[1] & XEMBED_MAPPED;
|
|
|
|
|
|
|
|
XFree (data);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_xembed_message (GtkSocket *socket,
|
|
|
|
XEmbedMessageType message,
|
|
|
|
glong detail,
|
|
|
|
glong data1,
|
|
|
|
glong data2,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket: %s received", _gtk_xembed_message_name (message)));
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case XEMBED_EMBEDDED_NOTIFY:
|
|
|
|
case XEMBED_WINDOW_ACTIVATE:
|
|
|
|
case XEMBED_WINDOW_DEACTIVATE:
|
|
|
|
case XEMBED_MODALITY_ON:
|
|
|
|
case XEMBED_MODALITY_OFF:
|
|
|
|
case XEMBED_FOCUS_IN:
|
|
|
|
case XEMBED_FOCUS_OUT:
|
|
|
|
g_warning ("GtkSocket: Invalid _XEMBED message %s received", _gtk_xembed_message_name (message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_REQUEST_FOCUS:
|
|
|
|
gtk_socket_claim_focus (socket, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_FOCUS_NEXT:
|
|
|
|
case XEMBED_FOCUS_PREV:
|
|
|
|
gtk_socket_advance_toplevel_focus (socket,
|
|
|
|
(message == XEMBED_FOCUS_NEXT ?
|
|
|
|
GTK_DIR_TAB_FORWARD : GTK_DIR_TAB_BACKWARD));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_GTK_GRAB_KEY:
|
|
|
|
gtk_socket_add_grabbed_key (socket, data1, data2);
|
|
|
|
break;
|
|
|
|
case XEMBED_GTK_UNGRAB_KEY:
|
|
|
|
gtk_socket_remove_grabbed_key (socket, data1, data2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_GRAB_KEY:
|
|
|
|
case XEMBED_UNGRAB_KEY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket: Ignoring unknown _XEMBED message of type %d", message));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkFilterReturn
|
|
|
|
gtk_socket_filter_func (GdkXEvent *gdk_xevent,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkSocket *socket;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GdkDisplay *display;
|
|
|
|
XEvent *xevent;
|
|
|
|
GtkSocketPrivate *private;
|
|
|
|
|
|
|
|
GdkFilterReturn return_val;
|
|
|
|
|
|
|
|
socket = GTK_SOCKET (data);
|
|
|
|
private = socket->priv;
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_CONTINUE;
|
|
|
|
|
|
|
|
if (private->plug_widget)
|
|
|
|
return return_val;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (socket);
|
|
|
|
xevent = (XEvent *)gdk_xevent;
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
switch (xevent->type)
|
|
|
|
{
|
|
|
|
case ClientMessage:
|
|
|
|
if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"))
|
|
|
|
{
|
|
|
|
_gtk_xembed_push_message (xevent);
|
|
|
|
handle_xembed_message (socket,
|
|
|
|
xevent->xclient.data.l[1],
|
|
|
|
xevent->xclient.data.l[2],
|
|
|
|
xevent->xclient.data.l[3],
|
|
|
|
xevent->xclient.data.l[4],
|
|
|
|
xevent->xclient.data.l[0]);
|
|
|
|
_gtk_xembed_pop_message ();
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CreateNotify:
|
|
|
|
{
|
|
|
|
XCreateWindowEvent *xcwe = &xevent->xcreatewindow;
|
|
|
|
|
|
|
|
if (!private->plug_window)
|
|
|
|
{
|
|
|
|
gtk_socket_add_window (socket, xcwe->window, FALSE);
|
|
|
|
|
|
|
|
if (private->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window created"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ConfigureRequest:
|
|
|
|
{
|
|
|
|
XConfigureRequestEvent *xcre = &xevent->xconfigurerequest;
|
|
|
|
|
|
|
|
if (!private->plug_window)
|
|
|
|
gtk_socket_add_window (socket, xcre->window, FALSE);
|
|
|
|
|
|
|
|
if (private->plug_window)
|
|
|
|
{
|
|
|
|
if (xcre->value_mask & (CWWidth | CWHeight))
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET,
|
|
|
|
g_message ("GtkSocket - configure request: %d %d",
|
|
|
|
private->request_width,
|
|
|
|
private->request_height));
|
|
|
|
|
|
|
|
private->resize_count++;
|
|
|
|
gtk_widget_queue_resize (widget);
|
|
|
|
}
|
|
|
|
else if (xcre->value_mask & (CWX | CWY))
|
|
|
|
{
|
|
|
|
gtk_socket_send_configure_event (socket);
|
|
|
|
}
|
|
|
|
/* Ignore stacking requests. */
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DestroyNotify:
|
|
|
|
{
|
|
|
|
XDestroyWindowEvent *xdwe = &xevent->xdestroywindow;
|
|
|
|
|
|
|
|
/* Note that we get destroy notifies both from SubstructureNotify on
|
|
|
|
* our window and StructureNotify on 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 (private->plug_window);
|
|
|
|
gtk_socket_end_embedding (socket);
|
|
|
|
|
|
|
|
g_object_ref (widget);
|
|
|
|
g_signal_emit_by_name (widget, "plug-removed", &result);
|
|
|
|
if (!result)
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
g_object_unref (widget);
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FocusIn:
|
|
|
|
if (xevent->xfocus.mode == EMBEDDED_APP_WANTS_FOCUS)
|
|
|
|
{
|
|
|
|
gtk_socket_claim_focus (socket, TRUE);
|
|
|
|
}
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
break;
|
|
|
|
case MapRequest:
|
|
|
|
if (!private->plug_window)
|
|
|
|
{
|
|
|
|
gtk_socket_add_window (socket, xevent->xmaprequest.window, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (private->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Map Request"));
|
|
|
|
|
|
|
|
gtk_socket_handle_map_request (socket);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
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"));
|
|
|
|
private->have_size = FALSE;
|
|
|
|
gtk_widget_queue_resize (widget);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
else if ((xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "XdndAware")) ||
|
|
|
|
(xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO")))
|
|
|
|
{
|
|
|
|
gdk_error_trap_push ();
|
2011-02-01 17:11:35 +00:00
|
|
|
protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
|
|
|
|
if (protocol)
|
2011-01-28 12:02:52 +00:00
|
|
|
gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
|
|
|
|
private->plug_window,
|
|
|
|
protocol, TRUE);
|
|
|
|
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED_INFO"))
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (xembed_get_info (private->plug_window, NULL, &flags))
|
|
|
|
{
|
|
|
|
gboolean was_mapped = private->is_mapped;
|
|
|
|
gboolean is_mapped = (flags & XEMBED_MAPPED) != 0;
|
|
|
|
|
|
|
|
if (was_mapped != is_mapped)
|
|
|
|
{
|
|
|
|
if (is_mapped)
|
|
|
|
gtk_socket_handle_map_request (socket);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
gdk_window_show (private->plug_window);
|
|
|
|
gdk_error_trap_pop_ignored ();
|
|
|
|
|
|
|
|
gtk_socket_unmap_notify (socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ReparentNotify:
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
XReparentEvent *xre = &xevent->xreparent;
|
|
|
|
|
|
|
|
window = gtk_widget_get_window (widget);
|
|
|
|
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - ReparentNotify received"));
|
|
|
|
if (!private->plug_window &&
|
|
|
|
xre->parent == GDK_WINDOW_XID (window))
|
|
|
|
{
|
|
|
|
gtk_socket_add_window (socket, xre->window, FALSE);
|
|
|
|
|
|
|
|
if (private->plug_window)
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - window reparented"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (private->plug_window &&
|
|
|
|
xre->window == GDK_WINDOW_XID (private->plug_window) &&
|
|
|
|
xre->parent != GDK_WINDOW_XID (window))
|
|
|
|
{
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
gtk_socket_end_embedding (socket);
|
|
|
|
|
|
|
|
g_object_ref (widget);
|
|
|
|
g_signal_emit_by_name (widget, "plug-removed", &result);
|
|
|
|
if (!result)
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
g_object_unref (widget);
|
|
|
|
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UnmapNotify:
|
|
|
|
if (private->plug_window &&
|
|
|
|
xevent->xunmap.window == GDK_WINDOW_XID (private->plug_window))
|
|
|
|
{
|
|
|
|
GTK_NOTE (PLUGSOCKET, g_message ("GtkSocket - Unmap notify"));
|
|
|
|
|
|
|
|
gtk_socket_unmap_notify (socket);
|
|
|
|
return_val = GDK_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_val;
|
|
|
|
}
|