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
GtkWindowPrivate *priv = window->priv;
GtkContainer *container = GTK_CONTAINER (window);
gboolean need_resize;
+ gboolean is_plug;
if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
{
/* 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)
gtk_widget_set_window (widget, gdk_window);
gdk_window_set_user_data (gdk_window, widget);
- gtk_widget_style_attach (widget);
- gtk_style_set_background (gtk_widget_get_style (widget), gdk_window, GTK_STATE_NORMAL);
+ gtk_style_context_set_background (gtk_widget_get_style_context (widget), gdk_window);
gdk_window_enable_synchronized_configure (gdk_window);
return;
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,
*
* 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
*/
*
* 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)
{
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;
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;
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;
- gboolean was_anchored;
widget = GTK_WIDGET (window);
if (is_toplevel == gtk_widget_is_toplevel (widget))
return;
- was_anchored = _gtk_widget_get_anchored (widget);
-
if (is_toplevel)
{
/* Pass through regular pathways of an embedded toplevel
gtk_widget_hide (widget);
/* Save the toplevel this widget was previously anchored into before
- * propagating a hierarchy-changed.
+ * 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 (widget))
- toplevel = NULL;
+ 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 it's anchored flag so that
- * the hierarchy changed signal kicks in properly.
+ * 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);
*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;
+}