1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gdk/gdkkeysyms.h"
33 #include "gtkmarshalers.h"
34 #include "gtkwindow.h"
36 #include "gtkprivate.h"
37 #include "gtksocket.h"
38 #include "gtksocketprivate.h"
44 /* Forward declararations */
46 static void gtk_socket_finalize (GObject *object);
47 static void gtk_socket_notify (GObject *object,
49 static void gtk_socket_realize (GtkWidget *widget);
50 static void gtk_socket_unrealize (GtkWidget *widget);
51 static void gtk_socket_size_request (GtkWidget *widget,
52 GtkRequisition *requisition);
53 static void gtk_socket_size_allocate (GtkWidget *widget,
54 GtkAllocation *allocation);
55 static void gtk_socket_hierarchy_changed (GtkWidget *widget,
56 GtkWidget *old_toplevel);
57 static void gtk_socket_grab_notify (GtkWidget *widget,
58 gboolean was_grabbed);
59 static gboolean gtk_socket_key_event (GtkWidget *widget,
61 static gboolean gtk_socket_focus (GtkWidget *widget,
62 GtkDirectionType direction);
63 static void gtk_socket_remove (GtkContainer *container,
65 static void gtk_socket_forall (GtkContainer *container,
66 gboolean include_internals,
68 gpointer callback_data);
76 GdkModifierType accel_mods;
85 static guint socket_signals[LAST_SIGNAL] = { 0 };
88 * _gtk_socket_get_private:
90 * @socket: a #GtkSocket
92 * Returns the private data associated with a GtkSocket, creating it
96 _gtk_socket_get_private (GtkSocket *socket)
98 return G_TYPE_INSTANCE_GET_PRIVATE (socket, GTK_TYPE_SOCKET, GtkSocketPrivate);
101 G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER)
104 gtk_socket_finalize (GObject *object)
106 GtkSocket *socket = GTK_SOCKET (object);
108 g_object_unref (socket->accel_group);
109 socket->accel_group = NULL;
111 G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object);
115 gtk_socket_class_init (GtkSocketClass *class)
117 GtkWidgetClass *widget_class;
118 GtkContainerClass *container_class;
119 GObjectClass *gobject_class;
121 gobject_class = (GObjectClass *) class;
122 widget_class = (GtkWidgetClass*) class;
123 container_class = (GtkContainerClass*) class;
125 gobject_class->finalize = gtk_socket_finalize;
126 gobject_class->notify = gtk_socket_notify;
128 widget_class->realize = gtk_socket_realize;
129 widget_class->unrealize = gtk_socket_unrealize;
130 widget_class->size_request = gtk_socket_size_request;
131 widget_class->size_allocate = gtk_socket_size_allocate;
132 widget_class->hierarchy_changed = gtk_socket_hierarchy_changed;
133 widget_class->grab_notify = gtk_socket_grab_notify;
134 widget_class->key_press_event = gtk_socket_key_event;
135 widget_class->key_release_event = gtk_socket_key_event;
136 widget_class->focus = gtk_socket_focus;
138 /* We don't want to show_all/hide_all the in-process
141 widget_class->show_all = gtk_widget_show;
142 widget_class->hide_all = gtk_widget_hide;
144 container_class->remove = gtk_socket_remove;
145 container_class->forall = gtk_socket_forall;
147 socket_signals[PLUG_ADDED] =
148 g_signal_new (I_("plug_added"),
149 G_OBJECT_CLASS_TYPE (class),
151 G_STRUCT_OFFSET (GtkSocketClass, plug_added),
153 _gtk_marshal_VOID__VOID,
155 socket_signals[PLUG_REMOVED] =
156 g_signal_new (I_("plug_removed"),
157 G_OBJECT_CLASS_TYPE (class),
159 G_STRUCT_OFFSET (GtkSocketClass, plug_removed),
160 _gtk_boolean_handled_accumulator, NULL,
161 _gtk_marshal_BOOLEAN__VOID,
164 g_type_class_add_private (gobject_class, sizeof (GtkSocketPrivate));
168 gtk_socket_init (GtkSocket *socket)
170 socket->request_width = 0;
171 socket->request_height = 0;
172 socket->current_width = 0;
173 socket->current_height = 0;
175 socket->plug_window = NULL;
176 socket->plug_widget = NULL;
177 socket->focus_in = FALSE;
178 socket->have_size = FALSE;
179 socket->need_map = FALSE;
180 socket->active = FALSE;
182 socket->accel_group = gtk_accel_group_new ();
183 g_object_set_data (G_OBJECT (socket->accel_group), I_("gtk-socket"), socket);
189 * Create a new empty #GtkSocket.
191 * Return value: the new #GtkSocket.
194 gtk_socket_new (void)
198 socket = g_object_new (GTK_TYPE_SOCKET, NULL);
200 return GTK_WIDGET (socket);
205 * @socket_: a #GtkSocket
206 * @wid: the window ID of an existing toplevel window.
208 * Reparents a pre-existing toplevel window into a #GtkSocket. This is
209 * meant to embed clients that do not know about embedding into a
210 * #GtkSocket, however doing so is inherently unreliable, and using
211 * this function is not recommended.
213 * The #GtkSocket must have already be added into a toplevel window
214 * before you can make this call.
217 gtk_socket_steal (GtkSocket *socket,
220 g_return_if_fail (GTK_IS_SOCKET (socket));
221 g_return_if_fail (GTK_WIDGET_ANCHORED (socket));
223 if (!GTK_WIDGET_REALIZED (socket))
224 gtk_widget_realize (GTK_WIDGET (socket));
226 _gtk_socket_add_window (socket, wid, TRUE);
231 * @socket_: a #GtkSocket
232 * @window_id: the window ID of a client participating in the XEMBED protocol.
234 * Adds an XEMBED client, such as a #GtkPlug, to the #GtkSocket. The
235 * client may be in the same process or in a different process.
237 * To embed a #GtkPlug in a #GtkSocket, you can either create the
238 * #GtkPlug with <literal>gtk_plug_new (0)</literal>, call
239 * gtk_plug_get_id() to get the window ID of the plug, and then pass that to the
240 * gtk_socket_add_id(), or you can call gtk_socket_get_id() to get the
241 * window ID for the socket, and call gtk_plug_new() passing in that
244 * The #GtkSocket must have already be added into a toplevel window
245 * before you can make this call.
248 gtk_socket_add_id (GtkSocket *socket,
249 GdkNativeWindow window_id)
251 g_return_if_fail (GTK_IS_SOCKET (socket));
252 g_return_if_fail (GTK_WIDGET_ANCHORED (socket));
254 if (!GTK_WIDGET_REALIZED (socket))
255 gtk_widget_realize (GTK_WIDGET (socket));
257 _gtk_socket_add_window (socket, window_id, TRUE);
262 * @socket_: a #GtkSocket.
264 * Gets the window ID of a #GtkSocket widget, which can then
265 * be used to create a client embedded inside the socket, for
266 * instance with gtk_plug_new().
268 * The #GtkSocket must have already be added into a toplevel window
269 * before you can make this call.
271 * Return value: the window ID for the socket
274 gtk_socket_get_id (GtkSocket *socket)
276 g_return_val_if_fail (GTK_IS_SOCKET (socket), 0);
277 g_return_val_if_fail (GTK_WIDGET_ANCHORED (socket), 0);
279 if (!GTK_WIDGET_REALIZED (socket))
280 gtk_widget_realize (GTK_WIDGET (socket));
282 return _gtk_socket_windowing_get_id (socket);
286 gtk_socket_realize (GtkWidget *widget)
289 GdkWindowAttr attributes;
290 gint attributes_mask;
292 g_return_if_fail (GTK_IS_SOCKET (widget));
294 socket = GTK_SOCKET (widget);
295 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
297 attributes.window_type = GDK_WINDOW_CHILD;
298 attributes.x = widget->allocation.x;
299 attributes.y = widget->allocation.y;
300 attributes.width = widget->allocation.width;
301 attributes.height = widget->allocation.height;
302 attributes.wclass = GDK_INPUT_OUTPUT;
303 attributes.visual = gtk_widget_get_visual (widget);
304 attributes.colormap = gtk_widget_get_colormap (widget);
305 attributes.event_mask = GDK_FOCUS_CHANGE_MASK;
307 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
309 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
310 &attributes, attributes_mask);
311 gdk_window_set_user_data (widget->window, socket);
313 widget->style = gtk_style_attach (widget->style, widget->window);
314 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
316 _gtk_socket_windowing_realize_window (socket);
318 gdk_window_add_filter (widget->window,
319 _gtk_socket_windowing_filter_func,
322 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
324 /* We sync here so that we make sure that if the XID for
325 * our window is passed to another application, SubstructureRedirectMask
326 * will be set by the time the other app creates its window.
328 gdk_display_sync (gtk_widget_get_display (widget));
332 * _gtk_socket_end_embedding:
334 * @socket: a #GtkSocket
336 * Called to end the embedding of a plug in the socket.
339 _gtk_socket_end_embedding (GtkSocket *socket)
341 GtkSocketPrivate *private = _gtk_socket_get_private (socket);
342 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
345 if (toplevel && GTK_IS_WINDOW (toplevel))
346 _gtk_socket_windowing_end_embedding_toplevel (socket);
348 g_object_unref (socket->plug_window);
349 socket->plug_window = NULL;
350 socket->current_width = 0;
351 socket->current_height = 0;
352 private->resize_count = 0;
354 /* Remove from end to avoid indexes shifting. This is evil */
355 for (i = socket->accel_group->n_accels - 1; i >= 0; i--)
357 GtkAccelGroupEntry *accel_entry = &socket->accel_group->priv_accels[i];
358 gtk_accel_group_disconnect (socket->accel_group, accel_entry->closure);
363 gtk_socket_unrealize (GtkWidget *widget)
365 GtkSocket *socket = GTK_SOCKET (widget);
367 GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
369 if (socket->plug_widget)
371 _gtk_plug_remove_from_socket (GTK_PLUG (socket->plug_widget), socket);
373 else if (socket->plug_window)
375 _gtk_socket_end_embedding (socket);
378 if (GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize)
379 (* GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize) (widget);
383 gtk_socket_size_request (GtkWidget *widget,
384 GtkRequisition *requisition)
386 GtkSocket *socket = GTK_SOCKET (widget);
388 if (socket->plug_widget)
390 gtk_widget_size_request (socket->plug_widget, requisition);
394 if (socket->is_mapped && !socket->have_size && socket->plug_window)
395 _gtk_socket_windowing_size_request (socket);
397 if (socket->is_mapped && socket->have_size)
399 requisition->width = MAX (socket->request_width, 1);
400 requisition->height = MAX (socket->request_height, 1);
404 requisition->width = 1;
405 requisition->height = 1;
411 gtk_socket_size_allocate (GtkWidget *widget,
412 GtkAllocation *allocation)
416 g_return_if_fail (GTK_IS_SOCKET (widget));
417 g_return_if_fail (allocation != NULL);
419 socket = GTK_SOCKET (widget);
421 widget->allocation = *allocation;
422 if (GTK_WIDGET_REALIZED (widget))
424 gdk_window_move_resize (widget->window,
425 allocation->x, allocation->y,
426 allocation->width, allocation->height);
428 if (socket->plug_widget)
430 GtkAllocation child_allocation;
432 child_allocation.x = 0;
433 child_allocation.y = 0;
434 child_allocation.width = allocation->width;
435 child_allocation.height = allocation->height;
437 gtk_widget_size_allocate (socket->plug_widget, &child_allocation);
439 else if (socket->plug_window)
441 GtkSocketPrivate *private = _gtk_socket_get_private (socket);
443 gdk_error_trap_push ();
445 if (allocation->width != socket->current_width ||
446 allocation->height != socket->current_height)
448 gdk_window_move_resize (socket->plug_window,
450 allocation->width, allocation->height);
451 if (private->resize_count)
452 private->resize_count--;
454 GTK_NOTE (PLUGSOCKET,
455 g_message ("GtkSocket - allocated: %d %d",
456 allocation->width, allocation->height));
457 socket->current_width = allocation->width;
458 socket->current_height = allocation->height;
461 if (socket->need_map)
463 gdk_window_show (socket->plug_window);
464 socket->need_map = FALSE;
467 while (private->resize_count)
469 _gtk_socket_windowing_send_configure_event (socket);
470 private->resize_count--;
471 GTK_NOTE (PLUGSOCKET,
472 g_message ("GtkSocket - sending synthetic configure: %d %d",
473 allocation->width, allocation->height));
476 gdk_display_sync (gtk_widget_get_display (widget));
477 gdk_error_trap_pop ();
483 activate_key (GtkAccelGroup *accel_group,
484 GObject *acceleratable,
486 GdkModifierType accel_mods,
487 GrabbedKey *grabbed_key)
489 GdkEvent *gdk_event = gtk_get_current_event ();
491 GtkSocket *socket = g_object_get_data (G_OBJECT (accel_group), "gtk-socket");
492 gboolean retval = FALSE;
494 if (gdk_event && gdk_event->type == GDK_KEY_PRESS && socket->plug_window)
496 _gtk_socket_windowing_send_key_event (socket, gdk_event, TRUE);
501 gdk_event_free (gdk_event);
507 find_accel_key (GtkAccelKey *key,
511 GrabbedKey *grabbed_key = data;
513 return (key->accel_key == grabbed_key->accel_key &&
514 key->accel_mods == grabbed_key->accel_mods);
518 * _gtk_socket_add_grabbed_key:
520 * @socket: a #GtkSocket
522 * @modifiers: modifiers for the key
524 * Called from the GtkSocket platform-specific backend when the
525 * corresponding plug has told the socket to grab a key.
528 _gtk_socket_add_grabbed_key (GtkSocket *socket,
530 GdkModifierType modifiers)
533 GrabbedKey *grabbed_key;
535 grabbed_key = g_new (GrabbedKey, 1);
537 grabbed_key->accel_key = keyval;
538 grabbed_key->accel_mods = modifiers;
540 if (gtk_accel_group_find (socket->accel_group,
544 g_warning ("GtkSocket: request to add already present grabbed key %u,%#x\n",
546 g_free (grabbed_key);
550 closure = g_cclosure_new (G_CALLBACK (activate_key), grabbed_key, (GClosureNotify)g_free);
552 gtk_accel_group_connect (socket->accel_group, keyval, modifiers, GTK_ACCEL_LOCKED,
557 * _gtk_socket_remove_grabbed_key:
559 * @socket: a #GtkSocket
561 * @modifiers: modifiers for the key
563 * Called from the GtkSocket backend when the corresponding plug has
564 * told the socket to remove a key grab.
567 _gtk_socket_remove_grabbed_key (GtkSocket *socket,
569 GdkModifierType modifiers)
573 for (i = 0; i < socket->accel_group->n_accels; i++)
575 GtkAccelGroupEntry *accel_entry = &socket->accel_group->priv_accels[i];
576 if (accel_entry->key.accel_key == keyval &&
577 accel_entry->key.accel_mods == modifiers)
579 gtk_accel_group_disconnect (socket->accel_group,
580 accel_entry->closure);
585 g_warning ("GtkSocket: request to remove non-present grabbed key %u,%#x\n",
590 socket_update_focus_in (GtkSocket *socket)
592 gboolean focus_in = FALSE;
594 if (socket->plug_window)
596 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
598 if (GTK_WIDGET_TOPLEVEL (toplevel) &&
599 GTK_WINDOW (toplevel)->has_toplevel_focus &&
600 gtk_widget_is_focus (GTK_WIDGET (socket)))
604 if (focus_in != socket->focus_in)
606 socket->focus_in = focus_in;
608 _gtk_socket_windowing_focus_change (socket, focus_in);
613 socket_update_active (GtkSocket *socket)
615 gboolean active = FALSE;
617 if (socket->plug_window)
619 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
621 if (GTK_WIDGET_TOPLEVEL (toplevel) &&
622 GTK_WINDOW (toplevel)->is_active)
626 if (active != socket->active)
628 socket->active = active;
630 _gtk_socket_windowing_update_active (socket, active);
635 gtk_socket_hierarchy_changed (GtkWidget *widget,
636 GtkWidget *old_toplevel)
638 GtkSocket *socket = GTK_SOCKET (widget);
639 GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
641 if (toplevel && !GTK_IS_WINDOW (toplevel))
644 if (toplevel != socket->toplevel)
646 if (socket->toplevel)
648 gtk_window_remove_accel_group (GTK_WINDOW (socket->toplevel), socket->accel_group);
649 g_signal_handlers_disconnect_by_func (socket->toplevel,
650 socket_update_focus_in,
652 g_signal_handlers_disconnect_by_func (socket->toplevel,
653 socket_update_active,
657 socket->toplevel = toplevel;
661 gtk_window_add_accel_group (GTK_WINDOW (socket->toplevel), socket->accel_group);
662 g_signal_connect_swapped (socket->toplevel, "notify::has-toplevel-focus",
663 G_CALLBACK (socket_update_focus_in), socket);
664 g_signal_connect_swapped (socket->toplevel, "notify::is-active",
665 G_CALLBACK (socket_update_active), socket);
668 socket_update_focus_in (socket);
669 socket_update_active (socket);
674 gtk_socket_grab_notify (GtkWidget *widget,
675 gboolean was_grabbed)
677 GtkSocket *socket = GTK_SOCKET (widget);
679 if (!socket->same_app)
680 _gtk_socket_windowing_update_modality (socket, !was_grabbed);
684 gtk_socket_key_event (GtkWidget *widget,
687 GtkSocket *socket = GTK_SOCKET (widget);
689 if (GTK_WIDGET_HAS_FOCUS (socket) && socket->plug_window && !socket->plug_widget)
691 _gtk_socket_windowing_send_key_event (socket, (GdkEvent *) event, FALSE);
700 gtk_socket_notify (GObject *object,
703 if (!strcmp (pspec->name, "is-focus"))
705 socket_update_focus_in (GTK_SOCKET (object));
709 * _gtk_socket_claim_focus:
711 * @socket: a #GtkSocket
714 * Claims focus for the socket. XXX send_event?
717 _gtk_socket_claim_focus (GtkSocket *socket,
721 socket->focus_in = TRUE; /* Otherwise, our notify handler will send FOCUS_IN */
723 /* Oh, the trickery... */
725 GTK_WIDGET_SET_FLAGS (socket, GTK_CAN_FOCUS);
726 gtk_widget_grab_focus (GTK_WIDGET (socket));
727 GTK_WIDGET_UNSET_FLAGS (socket, GTK_CAN_FOCUS);
731 gtk_socket_focus (GtkWidget *widget,
732 GtkDirectionType direction)
736 g_return_val_if_fail (GTK_IS_SOCKET (widget), FALSE);
738 socket = GTK_SOCKET (widget);
740 if (socket->plug_widget)
741 return gtk_widget_child_focus (socket->plug_widget, direction);
743 if (!gtk_widget_is_focus (widget))
745 _gtk_socket_windowing_focus (socket, direction);
746 _gtk_socket_claim_focus (socket, FALSE);
755 gtk_socket_remove (GtkContainer *container,
758 GtkSocket *socket = GTK_SOCKET (container);
760 g_return_if_fail (child == socket->plug_widget);
762 _gtk_plug_remove_from_socket (GTK_PLUG (socket->plug_widget), socket);
766 gtk_socket_forall (GtkContainer *container,
767 gboolean include_internals,
768 GtkCallback callback,
769 gpointer callback_data)
771 GtkSocket *socket = GTK_SOCKET (container);
773 if (socket->plug_widget)
774 (* callback) (socket->plug_widget, callback_data);
778 * _gtk_socket_add_window:
780 * @socket: a #GtkSocket
781 * @xid: the native identifier for a window
782 * @need_reparent: whether the socket's plug's window needs to be
783 * reparented to the socket
785 * Adds a window to a GtkSocket.
788 _gtk_socket_add_window (GtkSocket *socket,
790 gboolean need_reparent)
792 GtkWidget *widget = GTK_WIDGET (socket);
793 GdkDisplay *display = gtk_widget_get_display (widget);
794 gpointer user_data = NULL;
796 socket->plug_window = gdk_window_lookup_for_display (display, xid);
798 if (socket->plug_window)
800 g_object_ref (socket->plug_window);
801 gdk_window_get_user_data (socket->plug_window, &user_data);
804 if (user_data) /* A widget's window in this process */
806 GtkWidget *child_widget = user_data;
808 if (!GTK_IS_PLUG (child_widget))
810 g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket");
811 socket->plug_window = NULL;
812 gdk_error_trap_pop ();
817 _gtk_plug_add_to_socket (GTK_PLUG (child_widget), socket);
819 else /* A foreign window */
822 GdkDragProtocol protocol;
824 gdk_error_trap_push ();
826 if (!socket->plug_window)
828 socket->plug_window = gdk_window_foreign_new_for_display (display, xid);
829 if (!socket->plug_window) /* was deleted before we could get it */
831 gdk_error_trap_pop ();
836 _gtk_socket_windowing_select_plug_window_input (socket);
838 if (gdk_error_trap_pop ())
840 g_object_unref (socket->plug_window);
841 socket->plug_window = NULL;
845 /* OK, we now will reliably get destroy notification on socket->plug_window */
847 gdk_error_trap_push ();
851 gdk_window_hide (socket->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */
852 gdk_window_reparent (socket->plug_window, widget->window, 0, 0);
855 socket->have_size = FALSE;
857 _gtk_socket_windowing_embed_get_info (socket);
859 socket->need_map = socket->is_mapped;
861 if (gdk_drag_get_protocol_for_display (display, xid, &protocol))
862 gtk_drag_dest_set_proxy (GTK_WIDGET (socket), socket->plug_window,
865 gdk_display_sync (display);
866 gdk_error_trap_pop ();
868 gdk_window_add_filter (socket->plug_window,
869 _gtk_socket_windowing_filter_func,
872 /* Add a pointer to the socket on our toplevel window */
874 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
875 if (toplevel && GTK_IS_WINDOW (toplevel))
876 gtk_window_add_embedded_xid (GTK_WINDOW (toplevel), xid);
878 _gtk_socket_windowing_embed_notify (socket);
880 socket_update_active (socket);
881 socket_update_focus_in (socket);
883 gtk_widget_queue_resize (GTK_WIDGET (socket));
886 if (socket->plug_window)
887 g_signal_emit (socket, socket_signals[PLUG_ADDED], 0);
891 * _gtk_socket_handle_map_request:
893 * @socket: a #GtkSocket
895 * Called from the GtkSocket backend when the plug has been mapped.
898 _gtk_socket_handle_map_request (GtkSocket *socket)
900 if (!socket->is_mapped)
902 socket->is_mapped = TRUE;
903 socket->need_map = TRUE;
905 gtk_widget_queue_resize (GTK_WIDGET (socket));
910 * _gtk_socket_unmap_notify:
912 * @socket: a #GtkSocket
914 * Called from the GtkSocket backend when the plug has been unmapped ???
917 _gtk_socket_unmap_notify (GtkSocket *socket)
919 if (socket->is_mapped)
921 socket->is_mapped = FALSE;
922 gtk_widget_queue_resize (GTK_WIDGET (socket));
927 * _gtk_socket_advance_toplevel_focus:
929 * @socket: a #GtkSocket
930 * @direction: a direction
932 * Called from the GtkSocket backend when the corresponding plug
933 * has told the socket to move the focus.
936 _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
937 GtkDirectionType direction)
941 GtkContainer *container;
943 GtkWidget *old_focus_child;
946 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
950 if (!GTK_WIDGET_TOPLEVEL (toplevel) || GTK_IS_PLUG (toplevel))
952 gtk_widget_child_focus (toplevel,direction);
956 container = GTK_CONTAINER (toplevel);
957 window = GTK_WINDOW (toplevel);
958 bin = GTK_BIN (toplevel);
960 /* This is a copy of gtk_window_focus(), modified so that we
961 * can detect wrap-around.
963 old_focus_child = container->focus_child;
967 if (gtk_widget_child_focus (old_focus_child, direction))
970 /* We are allowed exactly one wrap-around per sequence of focus
973 if (_gtk_socket_windowing_embed_get_focus_wrapped ())
976 _gtk_socket_windowing_embed_set_focus_wrapped ();
979 if (window->focus_widget)
981 /* Wrapped off the end, clear the focus setting for the toplevel */
982 parent = window->focus_widget->parent;
985 gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
986 parent = GTK_WIDGET (parent)->parent;
989 gtk_window_set_focus (GTK_WINDOW (container), NULL);
992 /* Now try to focus the first widget in the window */
995 if (gtk_widget_child_focus (bin->child, direction))
1000 #define __GTK_SOCKET_C__
1001 #include "gtkaliasdef.c"