#include "config.h"
-#include "gtkintl.h"
+#include "gtkwindow.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
-#include "gdk/gdk.h"
-#include "gdk/gdkkeysyms.h"
#include "gtkprivate.h"
#include "gtkrc.h"
-#include "gtkwindow.h"
#include "gtkwindowprivate.h"
+#include "gtkaccelgroupprivate.h"
#include "gtkbindings.h"
#include "gtkkeyhash.h"
#include "gtkmain.h"
#include "gtkplug.h"
#include "gtkbuildable.h"
#include "gtkwidgetprivate.h"
+#include "gtkintl.h"
+#include "gtktypebuiltins.h"
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
static gint gtk_window_focus_out_event (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_window_style_updated (GtkWidget *widget);
-static gint gtk_window_client_event (GtkWidget *widget,
- GdkEventClient *event);
static gboolean gtk_window_state_event (GtkWidget *widget,
GdkEventWindowState *event);
static void gtk_window_check_resize (GtkContainer *container);
widget_class->focus_in_event = gtk_window_focus_in_event;
widget_class->button_press_event = gtk_window_button_press_event;
widget_class->focus_out_event = gtk_window_focus_out_event;
- widget_class->client_event = gtk_window_client_event;
widget_class->focus = gtk_window_focus;
widget_class->move_focus = gtk_window_move_focus;
widget_class->draw = gtk_window_draw;
GTK_PARAM_READWRITE));
/**
- * GtkWindow: resize-grip-visible:
+ * GtkWindow:resize-grip-visible:
*
* Whether a corner resize grip is currently shown.
*
0, G_MAXINT, 16, GTK_PARAM_READWRITE));
- /* Signals
- */
/**
* GtkWindow:application:
*
* The #GtkApplication associated with the window.
*
- * The application will be kept alive for at least as long as the
- * window is open.
+ * The application will be kept alive for at least as long as it
+ * has any windows associated with it (see g_application_hold()
+ * for a way to keep it alive without windows).
+ *
+ * Normally, the connection between the application and the window
+ * will remain until the window is destroyed, but you can explicitly
+ * remove it by setting the ::application property to %NULL.
*
* Since: 3.0
*/
priv->has_user_ref_count = TRUE;
toplevel_list = g_slist_prepend (toplevel_list, window);
- g_signal_connect (priv->screen, "composited-changed",
- G_CALLBACK (gtk_window_on_composited_changed), window);
+ if (priv->screen)
+ g_signal_connect (priv->screen, "composited-changed",
+ G_CALLBACK (gtk_window_on_composited_changed), window);
}
static void
return list;
}
-void
-gtk_window_add_embedded_xid (GtkWindow *window, GdkNativeWindow xid)
-{
- GList *embedded_windows;
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- embedded_windows = g_object_get_qdata (G_OBJECT (window), quark_gtk_embedded);
- if (embedded_windows)
- g_object_steal_qdata (G_OBJECT (window), quark_gtk_embedded);
- embedded_windows = g_list_prepend (embedded_windows,
- GUINT_TO_POINTER (xid));
-
- g_object_set_qdata_full (G_OBJECT (window), quark_gtk_embedded,
- embedded_windows,
- embedded_windows ?
- (GDestroyNotify) g_list_free : NULL);
-}
-
-void
-gtk_window_remove_embedded_xid (GtkWindow *window, GdkNativeWindow xid)
-{
- GList *embedded_windows;
- GList *node;
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- embedded_windows = g_object_get_qdata (G_OBJECT (window), quark_gtk_embedded);
- if (embedded_windows)
- g_object_steal_qdata (G_OBJECT (window), quark_gtk_embedded);
-
- node = g_list_find (embedded_windows, GUINT_TO_POINTER (xid));
- if (node)
- {
- embedded_windows = g_list_remove_link (embedded_windows, node);
- g_list_free_1 (node);
- }
-
- g_object_set_qdata_full (G_OBJECT (window), quark_gtk_embedded,
- embedded_windows,
- embedded_windows ?
- (GDestroyNotify) g_list_free : NULL);
-}
-
static void
gtk_window_dispose (GObject *object)
{
*
* Gets the #GtkApplication associated with the window (if any).
*
- * Return value: a #GtkApplication, or %NULL
+ * Return value: (transfer none): a #GtkApplication, or %NULL
*
* Since: 3.0
**/
/**
* gtk_window_set_application:
* @window: a #GtkWindow
- * @application: a #GtkApplication, or %NULL
+ * @application: (allow-none): a #GtkApplication, or %NULL
*
* Sets or unsets the #GtkApplication associated with the window.
*
/**
* gtk_window_set_icon_list:
* @window: a #GtkWindow
- * @list: (element-type GdkPixbuf) (transfer container): list of #GdkPixbuf
+ * @list: (element-type GdkPixbuf): list of #GdkPixbuf
*
* Sets up the icon representing a #GtkWindow. The icon is used when
* the window is minimized (also known as iconified). Some window
/**
* gtk_window_set_icon_from_file:
* @window: a #GtkWindow
- * @filename: location of icon file
+ * @filename: (type filename): location of icon file
* @err: (allow-none): location to store error, or %NULL.
*
* Sets the icon for @window.
/**
* gtk_window_set_default_icon_from_file:
- * @filename: location of icon file
+ * @filename: (type filename): location of icon file
* @err: (allow-none): location to store error, or %NULL.
*
* Sets an icon to be used as fallback for windows that haven't
* gdk_screen_height () - window_height)</literal> (note that this
* example does not take multi-head scenarios into account).
*
- * The Extended Window Manager Hints specification at <ulink
+ * The Extended Window Manager Hints specification at <ulink
* url="http://www.freedesktop.org/Standards/wm-spec">
- * http://www.freedesktop.org/Standards/wm-spec</ulink> has a
+ * http://www.freedesktop.org/Standards/wm-spec</ulink> has a
* nice table of gravities in the "implementation notes" section.
*
* The gtk_window_get_position() documentation may also be relevant.
gint x,
gint y)
{
- GtkWindowPrivate *priv;
GtkWindowGeometryInfo *info;
GtkWidget *widget;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
- priv = window->priv;
widget = GTK_WIDGET (window);
info = gtk_window_get_geometry_info (window, TRUE);
-
+
if (gtk_widget_get_mapped (widget))
{
GtkAllocation allocation;
gtk_window_constrain_position (window,
allocation.width, allocation.height,
&x, &y);
-
+
/* Note that this request doesn't go through our standard request
* framework, e.g. doesn't increment configure_request_count,
* doesn't set info->last, etc.; that's because
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
+ gtk_window_release_application (window);
+
toplevel_list = g_slist_remove (toplevel_list, window);
if (priv->transient_parent)
/* frees the icons */
gtk_window_set_icon_list (window, NULL);
-
+
if (priv->has_user_ref_count)
{
priv->has_user_ref_count = FALSE;
GtkWindowPrivate *priv = window->priv;
GtkContainer *container = GTK_CONTAINER (window);
gboolean need_resize;
+ gboolean is_plug;
+
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->show (widget);
+ return;
+ }
_gtk_widget_set_visible_flag (widget, TRUE);
/* Try to make sure that we have some focused widget
*/
- if (!priv->focus_widget && !GTK_IS_PLUG (window))
+#ifdef GDK_WINDOWING_X11
+ is_plug = GTK_IS_PLUG (window);
+#else
+ is_plug = FALSE;
+#endif
+ if (!priv->focus_widget && !is_plug)
gtk_window_move_focus (widget, GTK_DIR_TAB_FORWARD);
if (priv->modal)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->hide (widget);
+ return;
+ }
+
_gtk_widget_set_visible_flag (widget, FALSE);
gtk_widget_unmap (widget);
gdk_window = gtk_widget_get_window (widget);
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->map (widget);
+ return;
+ }
+
gtk_widget_set_mapped (widget, TRUE);
child = gtk_bin_get_child (&(window->bin));
GdkWindow *gdk_window;
GdkWindowState state;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->unmap (widget);
+ return;
+ }
+
gdk_window = gtk_widget_get_window (widget);
gtk_widget_set_mapped (widget, FALSE);
gtk_widget_get_allocation (widget, &allocation);
+ if (gtk_widget_get_parent_window (widget))
+ {
+ gtk_container_set_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT);
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes.window_type = GDK_WINDOW_CHILD;
+
+ attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK;
+
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.wclass = GDK_INPUT_OUTPUT;
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+
+ gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
+ gdk_window_set_user_data (gdk_window, widget);
+
+ gtk_style_context_set_background (gtk_widget_get_style_context (widget), gdk_window);
+
+ gdk_window_enable_synchronized_configure (gdk_window);
+ return;
+ }
+
+ gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
+
/* ensure widget tree is properly size allocated */
if (allocation.x == -1 &&
allocation.y == -1 &&
gdk_window_set_user_data (gdk_window, window);
- gtk_widget_style_attach (widget);
context = gtk_widget_get_style_context (widget);
-
gtk_style_context_set_background (context, gdk_window);
+
if (priv->transient_parent &&
gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)))
gdk_window_set_transient_for (gdk_window,
if (priv->wm_role)
gdk_window_set_role (gdk_window, priv->wm_role);
-
+
if (!priv->decorated)
gdk_window_set_decorations (gdk_window, 0);
-
+
if (!priv->deletable)
gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
-
+
if (gtk_window_get_skip_pager_hint (window))
gdk_window_set_skip_pager_hint (gdk_window, TRUE);
-
+
if (gtk_window_get_skip_taskbar_hint (window))
gdk_window_set_skip_taskbar_hint (gdk_window, TRUE);
-
+
if (gtk_window_get_accept_focus (window))
gdk_window_set_accept_focus (gdk_window, TRUE);
else
gdk_window_set_accept_focus (gdk_window, FALSE);
-
+
if (gtk_window_get_focus_on_map (window))
gdk_window_set_focus_on_map (gdk_window, TRUE);
else
gdk_window_set_focus_on_map (gdk_window, FALSE);
-
+
if (priv->modal)
gdk_window_set_modal_hint (gdk_window, TRUE);
else
gdk_window_set_modal_hint (gdk_window, FALSE);
-
+
if (priv->startup_id)
{
#ifdef GDK_WINDOWING_X11
guint32 timestamp = extract_time_from_startup_id (priv->startup_id);
if (timestamp != GDK_CURRENT_TIME)
- gdk_x11_window_set_user_time (gdk_window, timestamp);
+ gdk_x11_window_set_user_time (gdk_window, timestamp);
#endif
if (!startup_id_is_fake (priv->startup_id))
- gdk_window_set_startup_id (gdk_window, priv->startup_id);
+ gdk_window_set_startup_id (gdk_window, priv->startup_id);
}
-
+
/* Icons */
gtk_window_realize_icon (window);
-
+
if (priv->has_resize_grip)
resize_grip_create_window (window);
}
gtk_widget_set_allocation (widget, allocation);
+ if (gtk_widget_get_realized (widget))
+ {
+ /* If it's not a toplevel we're embedded, we need to resize the window's
+ * window and skip the grip.
+ */
+ if (!gtk_widget_is_toplevel (widget))
+ {
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+ }
+ else
+ {
+ update_grip_visibility (window);
+ set_grip_position (window);
+ }
+ }
+
child = gtk_bin_get_child (&(window->bin));
if (child && gtk_widget_get_visible (child))
{
gtk_widget_size_allocate (child, &child_allocation);
}
-
- if (gtk_widget_get_realized (widget))
- {
- update_grip_visibility (window);
- set_grip_position (window);
- }
}
static gint
GtkWindowPrivate *priv = window->priv;
gboolean expected_reply = priv->configure_request_count > 0;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ if (GTK_WIDGET_CLASS (gtk_window_parent_class)->configure_event)
+ return GTK_WIDGET_CLASS (gtk_window_parent_class)->configure_event (widget, event);
+
+ gdk_window_configure_finished (gtk_widget_get_window (widget));
+ return FALSE;
+ }
+
/* priv->configure_request_count incremented for each
* configure request, and decremented to a min of 0 for
* each configure notify.
GtkWindowPrivate *priv = window->priv;
GdkRectangle rect;
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->style_updated (widget);
+
if (priv->grip_window != NULL && gtk_window_get_resize_grip_area (window, &rect))
{
gdk_window_move_resize (priv->grip_window,
priv->has_resize_grip = value;
gtk_widget_queue_draw (widget);
- if (gtk_widget_get_realized (widget))
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_is_toplevel (GTK_WIDGET (widget)))
{
if (priv->has_resize_grip && priv->grip_window == NULL)
resize_grip_create_window (window);
*
* Determines whether a resize grip is visible for the specified window.
*
- * Returns %TRUE if a resize grip exists and is visible.
+ * Returns: %TRUE if a resize grip exists and is visible
*
* Since: 3.0
*/
if (!priv->resizable)
return FALSE;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ return FALSE;
+
if (gtk_widget_get_realized (widget))
{
GdkWindowState state;
*
* Determines whether the window may have a resize grip.
*
- * Returns: %TRUE if the window has a resize grip.
+ * Returns: %TRUE if the window has a resize grip
*
* Since: 3.0
*/
/**
* gtk_window_get_resize_grip_area:
* @window: a #GtkWindow
- * @rect: a pointer to a #GdkRectangle which we should store the
- * resize grip area.
+ * @rect: (out): a pointer to a #GdkRectangle which we should store
+ * the resize grip area
*
* If a window has a resize grip, this will retrieve the grip
* position, width and height into the specified #GdkRectangle.
*
- * Returns: %TRUE if the resize grip's area was retrieved.
+ * Returns: %TRUE if the resize grip's area was retrieved
*
* Since: 3.0
*/
return FALSE;
}
-static GdkAtom atom_rcfiles = GDK_NONE;
-static GdkAtom atom_iconthemes = GDK_NONE;
-
-static void
-send_client_message_to_embedded_windows (GtkWidget *widget,
- GdkAtom message_type)
-{
- GList *embedded_windows;
-
- embedded_windows = g_object_get_qdata (G_OBJECT (widget), quark_gtk_embedded);
- if (embedded_windows)
- {
- GdkEvent *send_event = gdk_event_new (GDK_CLIENT_EVENT);
- int i;
-
- for (i = 0; i < 5; i++)
- send_event->client.data.l[i] = 0;
- send_event->client.data_format = 32;
- send_event->client.message_type = message_type;
-
- while (embedded_windows)
- {
- GdkNativeWindow xid = GDK_GPOINTER_TO_NATIVE_WINDOW(embedded_windows->data);
- gdk_event_send_client_message_for_display (gtk_widget_get_display (widget), send_event, xid);
- embedded_windows = embedded_windows->next;
- }
-
- gdk_event_free (send_event);
- }
-}
-
-static gint
-gtk_window_client_event (GtkWidget *widget,
- GdkEventClient *event)
-{
- if (!atom_rcfiles)
- {
- atom_rcfiles = gdk_atom_intern_static_string ("_GTK_READ_RCFILES");
- atom_iconthemes = gdk_atom_intern_static_string ("_GTK_LOAD_ICONTHEMES");
- }
-
- if (event->message_type == atom_rcfiles)
- {
- send_client_message_to_embedded_windows (widget, atom_rcfiles);
- gtk_style_context_reset_widgets (gtk_widget_get_screen (widget));
- }
-
- if (event->message_type == atom_iconthemes)
- {
- send_client_message_to_embedded_windows (widget, atom_iconthemes);
- _gtk_icon_theme_check_reload (gtk_widget_get_display (widget));
- }
-
- return FALSE;
-}
-
static void
gtk_window_check_resize (GtkContainer *container)
{
- if (gtk_widget_get_visible (GTK_WIDGET (container)))
+ /* If the window is not toplevel anymore than it's embedded somewhere,
+ * so handle it like a normal window */
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (container)))
+ GTK_CONTAINER_CLASS (gtk_window_parent_class)->check_resize (container);
+ else if (gtk_widget_get_visible (GTK_WIDGET (container)))
gtk_window_move_resize (GTK_WINDOW (container));
}
GtkWidget *old_focus_child;
GtkWidget *parent;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ return GTK_WIDGET_CLASS (gtk_window_parent_class)->focus (widget, direction);
+
container = GTK_CONTAINER (widget);
window = GTK_WINDOW (widget);
priv = window->priv;
gtk_window_move_focus (GtkWidget *widget,
GtkDirectionType dir)
{
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->move_focus (widget, dir);
+ return;
+ }
+
gtk_widget_child_focus (widget, dir);
if (! gtk_container_get_focus_child (GTK_CONTAINER (widget)))
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
- gdk_display_get_device_state (display, pointer,
- &pointer_screen,
- &px, &py, NULL);
+ gdk_device_get_position (pointer,
+ &pointer_screen,
+ &px, &py);
if (pointer_screen == window_screen)
monitor_num = gdk_screen_get_monitor_at_point (pointer_screen, px, py);
GdkGeometry new_geometry;
guint new_flags;
int w, h;
- GtkWidget *widget;
GtkWindowPosition pos;
GtkWidget *parent_widget;
GtkWindowGeometryInfo *info;
GdkScreen *screen;
int x, y;
-
- widget = GTK_WIDGET (window);
screen = gtk_window_check_screen (window);
gtk_window_compute_hints (window, &new_geometry, &new_flags);
gtk_window_compute_configure_request_size (window,
- &new_geometry, new_flags,
- (guint *)&w, (guint *)&h);
+ &new_geometry, new_flags,
+ (guint *)&w, (guint *)&h);
gtk_window_constrain_size (window,
&new_geometry, new_flags,
&w, &h);
parent_widget = (GtkWidget*) priv->transient_parent;
-
+
pos = get_effective_position (window);
info = gtk_window_get_geometry_info (window, FALSE);
-
+
/* by default, don't change position requested */
if (info)
{
*
* Not sure how to go about that.
*/
-
switch (pos)
{
/* here we are only handling CENTER_ALWAYS
case GTK_WIN_POS_CENTER:
center_window_on_monitor (window, w, h, &x, &y);
break;
-
+
case GTK_WIN_POS_CENTER_ON_PARENT:
{
GtkAllocation allocation;
gint monitor_num;
GdkRectangle monitor;
gint ox, oy;
-
+
g_assert (gtk_widget_get_mapped (parent_widget)); /* established earlier */
gdk_window = gtk_widget_get_window (parent_widget);
{
gint screen_width = gdk_screen_get_width (screen);
gint screen_height = gdk_screen_get_height (screen);
- gint monitor_num;
- GdkRectangle monitor;
+ gint monitor_num;
+ GdkRectangle monitor;
GdkDisplay *display;
GdkDeviceManager *device_manager;
GdkDevice *pointer;
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
- gdk_display_get_device_state (display, pointer,
- &pointer_screen,
- &px, &py, NULL);
+ gdk_device_get_position (pointer,
+ &pointer_screen,
+ &px, &py);
if (pointer_screen == screen)
monitor_num = gdk_screen_get_monitor_at_point (screen, px, py);
else
monitor_num = -1;
-
+
x = px - w / 2;
y = py - h / 2;
x = CLAMP (x, 0, screen_width - w);
y = info->initial_y;
gtk_window_constrain_position (window, w, h, &x, &y);
}
-
+
request->x = x;
request->y = y;
request->width = w;
GtkWindowLastGeometryInfo saved_last_info;
widget = GTK_WIDGET (window);
+
gdk_window = gtk_widget_get_window (widget);
container = GTK_CONTAINER (widget);
info = gtk_window_get_geometry_info (window, TRUE);
gint root_y,
guint32 timestamp)
{
- GtkWindowPrivate *priv;
GtkWidget *widget;
GdkWindow *toplevel;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_visible (widget));
- priv = window->priv;
-
toplevel = gtk_widget_get_window (widget);
gdk_window_begin_resize_drag (toplevel,
gint root_y,
guint32 timestamp)
{
- GtkWindowPrivate *priv;
GtkWidget *widget;
GdkWindow *toplevel;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
widget = GTK_WIDGET (window);
g_return_if_fail (gtk_widget_get_visible (widget));
- priv = window->priv;
-
toplevel = gtk_widget_get_window (widget);
gdk_window_begin_move_drag (toplevel,
timestamp);
}
-/**
+/**
* gtk_window_set_screen:
* @window: a #GtkWindow.
* @screen: a #GdkScreen.
GtkWidget *widget;
GdkScreen *previous_screen;
gboolean was_mapped;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (GDK_IS_SCREEN (screen));
gtk_widget_unmap (widget);
if (gtk_widget_get_realized (widget))
gtk_widget_unrealize (widget);
-
+
gtk_window_free_key_hash (window);
priv->screen = screen;
gtk_widget_reset_rc_styles (widget);
if (screen != previous_screen)
{
- g_signal_handlers_disconnect_by_func (previous_screen,
- gtk_window_on_composited_changed, window);
- g_signal_connect (screen, "composited-changed",
- G_CALLBACK (gtk_window_on_composited_changed), window);
-
+ if (previous_screen)
+ g_signal_handlers_disconnect_by_func (previous_screen,
+ gtk_window_on_composited_changed, window);
+ g_signal_connect (screen, "composited-changed",
+ G_CALLBACK (gtk_window_on_composited_changed), window);
+
_gtk_widget_propagate_screen_changed (widget, previous_screen);
_gtk_widget_propagate_composited_changed (widget);
}
*
* Returns a list of the #GtkWindows that belong to @window_group.
*
- * Returns: (element-type GtkWidget) (transfer container): A newly-allocated list of
- * windows inside the group.
+ * Returns: (element-type GtkWindow) (transfer container): A
+ * newly-allocated list of windows inside the group.
*
* Since: 2.14
**/
group_windows = g_list_prepend (group_windows, window);
}
+ g_list_free (toplevels);
+
return g_list_reverse (group_windows);
}
* Gets the current grab widget of the given group,
* see gtk_grab_add().
*
- * Returns: the current grab widget of the group
+ * Returns: (transfer none): the current grab widget of the group
*
* Since: 2.22
*/
*
* Returns the current grab widget for @device, or %NULL if none.
*
- * Returns: The grab widget, or %NULL
+ * Returns: (transfer none): The grab widget, or %NULL
*
* Since: 3.0
*/
*/
void
_gtk_window_set_is_toplevel (GtkWindow *window,
- gboolean is_toplevel)
+ gboolean is_toplevel)
{
GtkWidget *widget;
+ GtkWidget *toplevel;
widget = GTK_WIDGET (window);
if (is_toplevel)
{
+ /* Pass through regular pathways of an embedded toplevel
+ * to go through unmapping and hiding the widget before
+ * becomming a toplevel again.
+ *
+ * We remain hidden after becomming toplevel in order to
+ * avoid problems during an embedded toplevel's dispose cycle
+ * (When a toplevel window is shown it tries to grab focus again,
+ * this causes problems while disposing).
+ */
+ gtk_widget_hide (widget);
+
+ /* Save the toplevel this widget was previously anchored into before
+ * propagating a hierarchy-changed.
+ *
+ * Usually this happens by way of gtk_widget_unparent() and we are
+ * already unanchored at this point, just adding this clause incase
+ * things happen differently.
+ */
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!gtk_widget_is_toplevel (toplevel))
+ toplevel = NULL;
+
_gtk_widget_set_is_toplevel (widget, TRUE);
+
+ /* When a window becomes toplevel after being embedded and anchored
+ * into another window we need to unset its anchored flag so that
+ * the hierarchy changed signal kicks in properly.
+ */
+ _gtk_widget_set_anchored (widget, FALSE);
+ _gtk_widget_propagate_hierarchy_changed (widget, toplevel);
+
toplevel_list = g_slist_prepend (toplevel_list, window);
}
else
{
_gtk_widget_set_is_toplevel (widget, FALSE);
toplevel_list = g_slist_remove (toplevel_list, window);
+
+ _gtk_widget_propagate_hierarchy_changed (widget, widget);
}
}
*wmclass_name = priv->wmclass_name;
*wmclass_class = priv->wmclass_class;
}
+
+/**
+ * gtk_window_set_has_user_ref_count:
+ * @window: a #GtkWindow
+ * @setting: the new value
+ *
+ * Tells GTK+ whether to drop its extra reference to the window
+ * when gtk_window_destroy() is called.
+ *
+ * This function is only exported for the benefit of language
+ * bindings which may need to keep the window alive until their
+ * wrapper object is garbage collected. There is no justification
+ * for ever calling this function in an application.
+ *
+ * Since: 3.0
+ */
+void
+gtk_window_set_has_user_ref_count (GtkWindow *window,
+ gboolean setting)
+{
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ window->priv->has_user_ref_count = setting;
+}