/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
-#include "gdk/gdkx.h"
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * 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/.
+ */
+
+#include "gdkx.h"
#include "gdk/gdkkeysyms.h"
#include "gtkwindow.h"
#include "gtksignal.h"
#include "gtksocket.h"
#include "gtkdnd.h"
+#ifdef GDK_WINDOWING_X11
+
/* Forward declararations */
static void gtk_socket_class_init (GtkSocketClass *klass);
GdkEvent *event,
gpointer data);
-#ifdef DEBUG_PLUGSOCKET
-#define DPRINTF(arg) g_print arg
-#else
-#define DPRINTF(arg)
-#endif
-
/* From Tk */
#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20
static GtkWidgetClass *parent_class = NULL;
-guint
+GtkType
gtk_socket_get_type ()
{
- static guint socket_type = 0;
+ static GtkType socket_type = 0;
if (!socket_type)
{
socket->plug_window = gdk_window_lookup (id);
+ gdk_error_trap_push ();
+
if (socket->plug_window && socket->plug_window->user_data)
{
/*
else
{
socket->plug_window = gdk_window_foreign_new (id);
+ if (!socket->plug_window) /* was deleted before we could get it */
+ {
+ gdk_error_trap_pop ();
+ return;
+ }
+
socket->same_app = FALSE;
socket->have_size = FALSE;
gdk_window_hide (socket->plug_window);
gdk_window_reparent (socket->plug_window, widget->window, 0, 0);
+
+ gdk_flush ();
+ gdk_error_trap_pop ();
+
socket->need_map = TRUE;
}
{
XSizeHints hints;
long supplied;
+
+ gdk_error_trap_push ();
if (XGetWMNormalHints (GDK_DISPLAY(),
GDK_WINDOW_XWINDOW (socket->plug_window),
}
}
socket->have_size = TRUE; /* don't check again? */
+
+ gdk_error_trap_pop ();
}
- requisition->width = socket->request_width;
- requisition->height = socket->request_height;
+ requisition->width = MAX (socket->request_width, 1);
+ requisition->height = MAX (socket->request_height, 1);
}
static void
if (socket->plug_window)
{
+ gdk_error_trap_push ();
+
if (!socket->need_map &&
(allocation->width == socket->current_width) &&
(allocation->height == socket->current_height))
{
gtk_socket_send_configure_event (socket);
- DPRINTF(( "No change: %d %d\n",
- allocation->width, allocation->height));
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - allocated no change: %d %d",
+ allocation->width, allocation->height));
}
else
{
gdk_window_move_resize (socket->plug_window,
0, 0,
allocation->width, allocation->height);
- DPRINTF(("configuring: %d %d\n",
- allocation->width, allocation->height));
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - allocated: %d %d",
+ allocation->width, allocation->height));
socket->current_width = allocation->width;
socket->current_height = allocation->height;
}
socket->need_map = FALSE;
}
+ gdk_flush ();
+ gdk_error_trap_pop ();
}
}
}
g_return_val_if_fail (GTK_IS_SOCKET (widget), FALSE);
socket = GTK_SOCKET (widget);
- DPRINTF (( "Got focus\n"));
-
if (socket->focus_in && socket->plug_window)
- XSetInputFocus (GDK_DISPLAY (),
- GDK_WINDOW_XWINDOW (socket->plug_window),
- RevertToParent, GDK_CURRENT_TIME);
+ {
+ gdk_error_trap_push ();
+ XSetInputFocus (GDK_DISPLAY (),
+ GDK_WINDOW_XWINDOW (socket->plug_window),
+ RevertToParent, GDK_CURRENT_TIME);
+ gdk_flush();
+ gdk_error_trap_pop ();
+ }
return TRUE;
}
/* FIXME: we might grab the focus even if we don't have
* it as an app... (and see _focus_in ()) */
if (socket->plug_window)
- XSetInputFocus (GDK_DISPLAY (),
- GDK_WINDOW_XWINDOW (socket->plug_window),
- RevertToParent, GDK_CURRENT_TIME);
+ {
+ gdk_error_trap_push ();
+ XSetInputFocus (GDK_DISPLAY (),
+ GDK_WINDOW_XWINDOW (socket->plug_window),
+ RevertToParent, GDK_CURRENT_TIME);
+ gdk_flush ();
+ gdk_error_trap_pop ();
+ }
}
static gint
break;
}
-
+
+ gdk_error_trap_push ();
XSendEvent (gdk_display,
GDK_WINDOW_XWINDOW (socket->plug_window),
False, NoEventMask, &xevent);
+ gdk_flush();
+ gdk_error_trap_pop ();
+
return TRUE;
}
else
event.xconfigure.border_width = 0;
event.xconfigure.above = None;
event.xconfigure.override_redirect = False;
-
+
+ gdk_error_trap_push ();
XSendEvent (gdk_display,
GDK_WINDOW_XWINDOW (socket->plug_window),
False, NoEventMask, &event);
+ gdk_flush ();
+ gdk_error_trap_pop ();
}
static void
{
GtkWidget *toplevel;
GdkDragProtocol protocol;
-
+
socket->plug_window = gdk_window_foreign_new (xid);
+ if (!socket->plug_window) /* Already gone */
+ return;
+
socket->same_app = FALSE;
-
+
+ gdk_error_trap_push ();
XSelectInput (GDK_DISPLAY (),
GDK_WINDOW_XWINDOW(socket->plug_window),
StructureNotifyMask | PropertyChangeMask);
-
+
if (gdk_drag_get_protocol (xid, &protocol))
gtk_drag_dest_set_proxy (GTK_WIDGET (socket), socket->plug_window,
protocol, TRUE);
+ gdk_flush ();
+ gdk_error_trap_pop ();
gdk_window_add_filter (socket->plug_window,
gtk_socket_filter_func, socket);
if (!socket->plug_window)
{
- g_print("Here!\n");
-
gtk_socket_add_window (socket, xcwe->window);
-
+
+ gdk_error_trap_push ();
gdk_window_move_resize(socket->plug_window,
0, 0,
widget->allocation.width,
widget->allocation.height);
+ gdk_flush ();
+ gdk_error_trap_pop ();
socket->request_width = xcwe->width;
socket->request_height = xcwe->height;
socket->have_size = TRUE;
-
- DPRINTF(("Window created with size: %d %d\n",
- socket->request_width,
- socket->request_height));
+
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - window created with size: %d %d",
+ socket->request_width,
+ socket->request_height));
gtk_widget_queue_resize (widget);
}
socket->request_height = xcre->height;
socket->have_size = TRUE;
- DPRINTF(("Configure request: %d %d\n",
- socket->request_width,
- socket->request_height));
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - configure request: %d %d",
+ socket->request_width,
+ socket->request_height));
gtk_widget_queue_resize (widget);
}
(xdwe->window == GDK_WINDOW_XWINDOW (socket->plug_window)))
{
GtkWidget *toplevel;
-
- DPRINTF(("Destroy Notify\n"));
+
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - destroy notify"));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
if (toplevel && GTK_IS_WINDOW (toplevel))
if (xevent->xmaprequest.window ==
GDK_WINDOW_XWINDOW (socket->plug_window))
{
- DPRINTF(("Map Request\n"));
-
+ GTK_NOTE(PLUGSOCKET,
+ g_message ("GtkSocket - Map Request"));
+
+ gdk_error_trap_push ();
gdk_window_show (socket->plug_window);
+ gdk_flush ();
+ gdk_error_trap_pop ();
return_val = GDK_FILTER_REMOVE;
}
if ((xevent->xproperty.atom == gdk_atom_intern ("XdndAware", FALSE)) ||
(xevent->xproperty.atom == gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE)))
{
+ gdk_error_trap_push ();
if (gdk_drag_get_protocol (xevent->xproperty.window, &protocol))
gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
socket->plug_window,
protocol, TRUE);
+ gdk_flush ();
+ gdk_error_trap_pop ();
}
return_val = GDK_FILTER_REMOVE;
}
return return_val;
}
+
+#elif defined (GDK_WINDOWING_WIN32)
+
+guint
+gtk_socket_get_type ()
+{
+ g_error ("GtkSocket not implemented");
+ return 42;
+}
+
+GtkWidget*
+gtk_socket_new ()
+{
+ g_error ("GtkSocket not implemented");
+ return NULL;
+}
+
+void
+gtk_socket_steal (GtkSocket *socket, guint32 id)
+{
+ g_error ("GtkSocket not implemented");
+}
+
+#endif /* GDK_WINDOWING */