From 295e763b4da13726b7beb8e9c905a5af30b0e251 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sun, 21 Feb 1999 19:25:53 +0000 Subject: [PATCH] removed debugging statements about embedded XID's. They could have been Sun Feb 21 14:21:46 1999 Owen Taylor * gtk/gtkwindow.c: removed debugging statements about embedded XID's. They could have been moved to the new PLUGSOCKET debug key, but they weren't really useful anyways. * gdk/gdk.h: Added gdk_error_trap_push/pop to provide a clean interface to the gdk_error_code functionality of trapping X errors. * gtk/gtkplug.c gtk/gtksocket.c: Add error traps around accesses to foreign windows. --- ChangeLog | 14 +++++++ ChangeLog.pre-2-0 | 14 +++++++ ChangeLog.pre-2-10 | 14 +++++++ ChangeLog.pre-2-2 | 14 +++++++ ChangeLog.pre-2-4 | 14 +++++++ ChangeLog.pre-2-6 | 14 +++++++ ChangeLog.pre-2-8 | 14 +++++++ gdk/gdk.c | 84 ++++++++++++++++++++++++++++++++++++++++- gdk/gdk.h | 6 +++ gdk/gdkwindow.c | 27 ++++++++----- gdk/x11/gdkmain-x11.c | 84 ++++++++++++++++++++++++++++++++++++++++- gdk/x11/gdkwindow-x11.c | 27 ++++++++----- gtk/gtkplug.c | 24 +++++++++++- gtk/gtksocket.c | 82 ++++++++++++++++++++++++++++++++-------- gtk/gtkwindow.c | 8 ---- 15 files changed, 390 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbea393043..7ccbb7706e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index bbea393043..7ccbb7706e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +Sun Feb 21 14:21:46 1999 Owen Taylor + + * gtk/gtkwindow.c: removed debugging statements + about embedded XID's. They could have been + moved to the new PLUGSOCKET debug key, but they weren't + really useful anyways. + + * gdk/gdk.h: Added gdk_error_trap_push/pop to provide + a clean interface to the gdk_error_code functionality + of trapping X errors. + + * gtk/gtkplug.c gtk/gtksocket.c: Add error + traps around accesses to foreign windows. + Sun Feb 21 15:37:25 1999 Tim Janik * gtk/gtkwindow.h: marked gtk_window_set_focus, gtk_window_set_default, diff --git a/gdk/gdk.c b/gdk/gdk.c index ea2a65aa24..f4d5f7b808 100644 --- a/gdk/gdk.c +++ b/gdk/gdk.c @@ -47,6 +47,7 @@ typedef struct _GdkPredicate GdkPredicate; +typedef struct _GdkErrorTrap GdkErrorTrap; struct _GdkPredicate { @@ -54,6 +55,12 @@ struct _GdkPredicate gpointer data; }; +struct _GdkErrorTrap +{ + gint error_warnings; + gint error_code; +}; + /* * Private function declarations */ @@ -97,9 +104,11 @@ static struct timeval *timerp; /* The actual timer passed to "select" static guint32 timer_val; /* The timeout length as specified by * the user in milliseconds. */ - static gint autorepeat; +static GSList *gdk_error_traps = NULL; /* List of error traps */ +static GSList *gdk_error_trap_free_list = NULL; /* Free list */ + #ifdef G_ENABLE_DEBUG static const GDebugKey gdk_debug_keys[] = { {"events", GDK_DEBUG_EVENTS}, @@ -1049,11 +1058,82 @@ gdk_x_io_error (Display *display) } gchar * -gdk_get_display(void) +gdk_get_display (void) { return (gchar *)XDisplayName (gdk_display_name); } +/************************************************************* + * gdk_error_trap_push: + * Push an error trap. X errors will be trapped until + * the corresponding gdk_error_pop(), which will return + * the error code, if any. + * arguments: + * + * results: + *************************************************************/ + +void +gdk_error_trap_push (void) +{ + GSList *node; + GdkErrorTrap *trap; + + if (gdk_error_trap_free_list) + { + node = gdk_error_trap_free_list; + gdk_error_trap_free_list = gdk_error_trap_free_list->next; + } + else + { + node = g_slist_alloc(); + node->data = g_new (GdkErrorTrap, 1); + } + + node->next = gdk_error_traps; + gdk_error_traps = node; + + trap = node->data; + trap->error_code = gdk_error_code; + trap->error_warnings = gdk_error_warnings; + + gdk_error_code = 0; + gdk_error_warnings = 0; +} + +/************************************************************* + * gdk_error_trap_pop: + * Pop an error trap added with gdk_error_push() + * arguments: + * + * results: + * 0, if no error occured, otherwise the error code. + *************************************************************/ + +gint +gdk_error_trap_pop (void) +{ + GSList *node; + GdkErrorTrap *trap; + gint result; + + g_return_val_if_fail (gdk_error_traps != NULL, 0); + + node = gdk_error_traps; + gdk_error_traps = gdk_error_traps->next; + + node->next = gdk_error_trap_free_list; + gdk_error_trap_free_list = node; + + result = gdk_error_code; + + trap = node->data; + gdk_error_code = trap->error_code; + gdk_error_warnings = trap->error_warnings; + + return result; +} + gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask, XEvent *event_send) diff --git a/gdk/gdk.h b/gdk/gdk.h index 34accf87c1..b8b84a099b 100644 --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -35,6 +35,12 @@ void gdk_init (gint *argc, void gdk_exit (gint error_code); gchar* gdk_set_locale (void); +/* Push and pop error handlers for X errors + */ +void gdk_error_trap_push (void); +gint gdk_error_trap_pop (void); + + gboolean gdk_events_pending (void); GdkEvent* gdk_event_get (void); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 076d763789..c2b8944535 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -503,19 +503,23 @@ gdk_window_foreign_new (guint32 anid) Window root, parent; Window *children = NULL; guint nchildren; - - if (!XGetWindowAttributes (gdk_display, anid, &attrs)) { - g_warning ("XGetWindowAttributes failed on window ID %d\n", anid); + gboolean result; + + gdk_error_trap_push (); + result = XGetWindowAttributes (gdk_display, anid, &attrs); + if (gdk_error_trap_pop () || !result) + return NULL; + + /* FIXME: This is pretty expensive. Maybe the caller should supply + * the parent */ + gdk_error_trap_push (); + result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren); + if (gdk_error_trap_pop () || !result) return NULL; - } private = g_new (GdkWindowPrivate, 1); window = (GdkWindow*) private; - /* FIXME: This is pretty expensive. Maybe the caller should supply - * the parent */ - XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren); - if (children) XFree (children); private->parent = gdk_xid_table_lookup (parent); @@ -634,7 +638,8 @@ gdk_window_internal_destroy (GdkWindow *window, * it a delete event, as if we were a WM */ XClientMessageEvent xevent; - + + gdk_error_trap_push (); gdk_window_hide (window); gdk_window_reparent (window, NULL, 0, 0); @@ -644,9 +649,11 @@ gdk_window_internal_destroy (GdkWindow *window, xevent.format = 32; xevent.data.l[0] = gdk_wm_delete_window; xevent.data.l[1] = CurrentTime; - + XSendEvent (private->xdisplay, private->xwindow, False, 0, (XEvent *)&xevent); + gdk_flush (); + gdk_error_trap_pop (); } } else if (xdestroy) diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index ea2a65aa24..f4d5f7b808 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -47,6 +47,7 @@ typedef struct _GdkPredicate GdkPredicate; +typedef struct _GdkErrorTrap GdkErrorTrap; struct _GdkPredicate { @@ -54,6 +55,12 @@ struct _GdkPredicate gpointer data; }; +struct _GdkErrorTrap +{ + gint error_warnings; + gint error_code; +}; + /* * Private function declarations */ @@ -97,9 +104,11 @@ static struct timeval *timerp; /* The actual timer passed to "select" static guint32 timer_val; /* The timeout length as specified by * the user in milliseconds. */ - static gint autorepeat; +static GSList *gdk_error_traps = NULL; /* List of error traps */ +static GSList *gdk_error_trap_free_list = NULL; /* Free list */ + #ifdef G_ENABLE_DEBUG static const GDebugKey gdk_debug_keys[] = { {"events", GDK_DEBUG_EVENTS}, @@ -1049,11 +1058,82 @@ gdk_x_io_error (Display *display) } gchar * -gdk_get_display(void) +gdk_get_display (void) { return (gchar *)XDisplayName (gdk_display_name); } +/************************************************************* + * gdk_error_trap_push: + * Push an error trap. X errors will be trapped until + * the corresponding gdk_error_pop(), which will return + * the error code, if any. + * arguments: + * + * results: + *************************************************************/ + +void +gdk_error_trap_push (void) +{ + GSList *node; + GdkErrorTrap *trap; + + if (gdk_error_trap_free_list) + { + node = gdk_error_trap_free_list; + gdk_error_trap_free_list = gdk_error_trap_free_list->next; + } + else + { + node = g_slist_alloc(); + node->data = g_new (GdkErrorTrap, 1); + } + + node->next = gdk_error_traps; + gdk_error_traps = node; + + trap = node->data; + trap->error_code = gdk_error_code; + trap->error_warnings = gdk_error_warnings; + + gdk_error_code = 0; + gdk_error_warnings = 0; +} + +/************************************************************* + * gdk_error_trap_pop: + * Pop an error trap added with gdk_error_push() + * arguments: + * + * results: + * 0, if no error occured, otherwise the error code. + *************************************************************/ + +gint +gdk_error_trap_pop (void) +{ + GSList *node; + GdkErrorTrap *trap; + gint result; + + g_return_val_if_fail (gdk_error_traps != NULL, 0); + + node = gdk_error_traps; + gdk_error_traps = gdk_error_traps->next; + + node->next = gdk_error_trap_free_list; + gdk_error_trap_free_list = node; + + result = gdk_error_code; + + trap = node->data; + gdk_error_code = trap->error_code; + gdk_error_warnings = trap->error_warnings; + + return result; +} + gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask, XEvent *event_send) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 076d763789..c2b8944535 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -503,19 +503,23 @@ gdk_window_foreign_new (guint32 anid) Window root, parent; Window *children = NULL; guint nchildren; - - if (!XGetWindowAttributes (gdk_display, anid, &attrs)) { - g_warning ("XGetWindowAttributes failed on window ID %d\n", anid); + gboolean result; + + gdk_error_trap_push (); + result = XGetWindowAttributes (gdk_display, anid, &attrs); + if (gdk_error_trap_pop () || !result) + return NULL; + + /* FIXME: This is pretty expensive. Maybe the caller should supply + * the parent */ + gdk_error_trap_push (); + result = XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren); + if (gdk_error_trap_pop () || !result) return NULL; - } private = g_new (GdkWindowPrivate, 1); window = (GdkWindow*) private; - /* FIXME: This is pretty expensive. Maybe the caller should supply - * the parent */ - XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren); - if (children) XFree (children); private->parent = gdk_xid_table_lookup (parent); @@ -634,7 +638,8 @@ gdk_window_internal_destroy (GdkWindow *window, * it a delete event, as if we were a WM */ XClientMessageEvent xevent; - + + gdk_error_trap_push (); gdk_window_hide (window); gdk_window_reparent (window, NULL, 0, 0); @@ -644,9 +649,11 @@ gdk_window_internal_destroy (GdkWindow *window, xevent.format = 32; xevent.data.l[0] = gdk_wm_delete_window; xevent.data.l[1] = CurrentTime; - + XSendEvent (private->xdisplay, private->xwindow, False, 0, (XEvent *)&xevent); + gdk_flush (); + gdk_error_trap_pop (); } } else if (xdestroy) diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 3e6a564d20..878ecfb66f 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -151,8 +151,19 @@ gtk_plug_realize (GtkWidget *widget) attributes_mask |= (window->title ? GDK_WA_TITLE : 0); attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0); + gdk_error_trap_push (); widget->window = gdk_window_new (plug->socket_window, &attributes, attributes_mask); + gdk_flush (); + if (gdk_error_trap_pop ()) /* Uh-oh */ + { + gdk_error_trap_push (); + gdk_window_destroy (widget->window); + gdk_flush (); + gdk_error_trap_pop (); + widget->window = gdk_window_new (NULL, &attributes, attributes_mask); + } + ((GdkWindowPrivate *)widget->window)->window_type = GDK_WINDOW_TOPLEVEL; gdk_window_set_user_data (widget->window, window); @@ -251,10 +262,13 @@ gtk_plug_key_press_event (GtkWidget *widget, if (!GTK_CONTAINER (window)->focus_child) { gtk_window_set_focus (GTK_WINDOW (widget), NULL); - + + gdk_error_trap_push (); XSetInputFocus (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (plug->socket_window), RevertToParent, event->time); + gdk_flush (); + gdk_error_trap_pop (); gtk_plug_forward_key_press (plug, event); } @@ -288,10 +302,13 @@ gtk_plug_forward_key_press (GtkPlug *plug, GdkEventKey *event) xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), event->keyval); xevent.xkey.same_screen = TRUE; /* FIXME ? */ - + + gdk_error_trap_push (); XSendEvent (gdk_display, GDK_WINDOW_XWINDOW (plug->socket_window), False, NoEventMask, &xevent); + gdk_flush (); + gdk_error_trap_pop (); } /* Copied from Window, Ughh */ @@ -406,8 +423,11 @@ gtk_plug_set_focus (GtkWindow *window, xevent.xfocus.mode = EMBEDDED_APP_WANTS_FOCUS; xevent.xfocus.detail = FALSE; /* Don't force */ + gdk_error_trap_push (); XSendEvent (gdk_display, GDK_WINDOW_XWINDOW (plug->socket_window), False, NoEventMask, &xevent); + gdk_flush (); + gdk_error_trap_pop (); } } diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 11fb450252..b1f6d019df 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -135,6 +135,8 @@ gtk_socket_steal (GtkSocket *socket, guint32 id) socket->plug_window = gdk_window_lookup (id); + gdk_error_trap_push (); + if (socket->plug_window && socket->plug_window->user_data) { /* @@ -150,6 +152,12 @@ gtk_socket_steal (GtkSocket *socket, guint32 id) 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; @@ -162,6 +170,10 @@ gtk_socket_steal (GtkSocket *socket, guint32 id) 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; } @@ -256,6 +268,8 @@ gtk_socket_size_request (GtkWidget *widget, { XSizeHints hints; long supplied; + + gdk_error_trap_push (); if (XGetWMNormalHints (GDK_DISPLAY(), GDK_WINDOW_XWINDOW (socket->plug_window), @@ -280,6 +294,8 @@ gtk_socket_size_request (GtkWidget *widget, } } socket->have_size = TRUE; /* don't check again? */ + + gdk_error_trap_pop (); } requisition->width = socket->request_width; @@ -307,6 +323,8 @@ gtk_socket_size_allocate (GtkWidget *widget, if (socket->plug_window) { + gdk_error_trap_push (); + if (!socket->need_map && (allocation->width == socket->current_width) && (allocation->height == socket->current_height)) @@ -334,6 +352,8 @@ gtk_socket_size_allocate (GtkWidget *widget, socket->need_map = FALSE; } + gdk_flush (); + gdk_error_trap_pop (); } } } @@ -346,9 +366,14 @@ gtk_socket_focus_in_event (GtkWidget *widget, GdkEventFocus *event) socket = GTK_SOCKET (widget); 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; } @@ -391,9 +416,14 @@ gtk_socket_claim_focus (GtkSocket *socket) /* 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 @@ -448,10 +478,14 @@ gtk_socket_focus (GtkContainer *container, GtkDirectionType direction) 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 @@ -481,10 +515,13 @@ gtk_socket_send_configure_event (GtkSocket *socket) 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 @@ -497,17 +534,23 @@ gtk_socket_add_window (GtkSocket *socket, guint32 xid) { GtkWidget *toplevel; GdkDragProtocol protocol; - - socket->plug_window = gdk_window_foreign_new (xid); - socket->same_app = FALSE; + 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); @@ -545,14 +588,15 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) 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; @@ -662,8 +706,11 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { 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; } @@ -677,10 +724,13 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) 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; } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index ce562e108c..2f1a625ad1 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -501,10 +501,6 @@ gtk_window_add_embedded_xid (GtkWindow *window, guint xid) g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); -#ifdef G_ENABLE_DEBUG - g_message ("add embedded xid %#x\n", xid); -#endif - embedded_windows = gtk_object_get_data (GTK_OBJECT (window), "gtk-embedded"); if (embedded_windows) gtk_object_remove_no_notify_by_id (GTK_OBJECT (window), @@ -527,10 +523,6 @@ gtk_window_remove_embedded_xid (GtkWindow *window, guint xid) g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); -#ifdef G_ENABLE_DEBUG - g_message ("remove embedded xid %#x\n", xid); -#endif - embedded_windows = gtk_object_get_data (GTK_OBJECT (window), "gtk-embedded"); if (embedded_windows) gtk_object_remove_no_notify_by_id (GTK_OBJECT (window),