summaryrefslogtreecommitdiff
path: root/gtk/gtkwindow.c
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2006-04-25 14:27:32 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2006-04-25 14:27:32 +0000
commitb9d1a034408647f5e4ac7c00ce3d9b3dae29c954 (patch)
treeeaaecbd294cc430b57fe07a90c06097e767cd8e3 /gtk/gtkwindow.c
parent33a8d113e1006250ebcb5744256f68dcbee80247 (diff)
downloadgtk+-b9d1a034408647f5e4ac7c00ce3d9b3dae29c954.tar.gz
Create 'composited' label.
Tue Apr 25 10:25:28 2006 Søren Sandmann <sandmann@redhat.com> * tests/testgtk.c (create_alpha_window): Create 'composited' label. * tests/testgtk.c (on_composited_changed): New function, change the label to say whether the screen is composited or not. * gtk/gtkwindow.c (gtk_window_on_composited_changed): When composited status change, invalidate the window and propagate the signal;. * gtk/gtkwindow.c (gtk_window_map): Set the appropriate type hint if reset_type_hint is TRUE. * gtk/gtkwindow.c (gtk_window_set_type_hint): If hint is one of the old hints, store a shadow copy in the public window->type_hint bitfield, otherwise set this field to normal. Set the private field to the type hint. * gtk/gtkwindow.c (gtk_window_init): Initialize priv->type_hint. * gtk/gtkwindow.c (struct _GtkWindowPrivate): New field "reset_type_hint" indicating whether the type hint needs to be reset. New field type_hint containing a GdkWindowTypeHint. * gtk/gtkwidget.c (propagate_composited_changed): New function to propagate changes in composited status. (gtk_widget_class_init): Add composited_changed signal. * gtk/gtkwidget.h (struct _GtkWidgetClass): New signal composited-changed. * gtk/gtkwidget.c (gtk_widget_is_composited): New function. * gtk/gtktooltips.c (gtk_tooltips_draw_tips): Set transient for. * gtk/gtktooltips.c (gtk_tooltips_force_window): Set the type hint * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Compute whether the item belongs to a menubar. Set the type_hint appropriately depending on the outcome. * gtk/gtkmenu.c (gtk_menu_position): Set the default type hint here. * gtk/gtkmenu.c (gtk_menu_attach_to_widget): connect to hierarchy changed on the attach widget. * gtk/gtkmenu.c (attach_widget_hierarchy_changed): New function to set the transient_for property for menus. * gtk/gtkdnd.c (set_icon_stock_pixbuf): Set the appropriate type hint. * gtk/gtkcombo.c (gtk_combo_popup_list): Make the popup window transient for the toplevel. * gtk/gtkcombobox.c (gtk_combo_box_set_popup_widget): Set transient-for, for the popup window. * gdk/x11/gdkwindow-x11.c (gdk_window_get_type_hint): Support for new window types. * gdk/x11/gdkwindow-x11.c (gdk_window_set_type_hint): Add support for new window types. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_process_owner_change): New function called whenever the compositing manager comes and goes. * gdk/x11/gdkscreen-x11.c (gdk_screen_is_composited): New function. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_request_cm_notification, make_cm_atom, check_is_composited): New functions * gdk/x11/gdkevents-x11.c (gdk_event_translate): Call _gdk_x11_screen_process_owner_change when an XFixesSelectionNotifyEvent is received. * gdk/x11/gdkdisplay-x11.c (gdk_display_open): Call _gdk_x11_screen_request_cm_notification() on all screens. * gdk/quartz/gdkscreen-quartz.c (gdk_screen_is_composited): Dummy implementation. * gdk/gdkscreen.c (gdk_screen_class_init): New signal, 'composited-changed'. * gdk/gdkwindow.h: Add new EWMH window types. * gdk/win32/gdkscreen-win32.c (gdk_screen_is_composited)
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r--gtk/gtkwindow.c74
1 files changed, 66 insertions, 8 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index d59ff6553f..82cc51dbe0 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -172,6 +172,9 @@ struct _GtkWindowPrivate
guint accept_focus : 1;
guint focus_on_map : 1;
guint deletable : 1;
+
+ guint reset_type_hint : 1;
+ GdkWindowTypeHint type_hint;
};
static void gtk_window_class_init (GtkWindowClass *klass);
@@ -279,6 +282,8 @@ static void gtk_window_unrealize_icon (GtkWindow *window);
static void gtk_window_notify_keys_changed (GtkWindow *window);
static GtkKeyHash *gtk_window_get_key_hash (GtkWindow *window);
static void gtk_window_free_key_hash (GtkWindow *window);
+static void gtk_window_on_composited_changed (GdkScreen *screen,
+ GtkWindow *window);
static GSList *toplevel_list = NULL;
static GtkBinClass *parent_class = NULL;
@@ -815,6 +820,7 @@ gtk_window_init (GtkWindow *window)
priv->accept_focus = TRUE;
priv->focus_on_map = TRUE;
priv->deletable = TRUE;
+ priv->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
colormap = _gtk_widget_peek_colormap ();
if (colormap)
@@ -826,6 +832,8 @@ gtk_window_init (GtkWindow *window)
gtk_decorated_window_init (window);
+ g_signal_connect (window->screen, "composited_changed",
+ G_CALLBACK (gtk_window_on_composited_changed), window);
}
static void
@@ -937,9 +945,11 @@ gtk_window_get_property (GObject *object,
GParamSpec *pspec)
{
GtkWindow *window;
+ GtkWindowPrivate *priv;
window = GTK_WINDOW (object);
-
+ priv = GTK_WINDOW_GET_PRIVATE (window);
+
switch (prop_id)
{
GtkWindowGeometryInfo *info;
@@ -1000,8 +1010,7 @@ gtk_window_get_property (GObject *object,
g_value_set_boolean (value, window->has_toplevel_focus);
break;
case PROP_TYPE_HINT:
- g_value_set_enum (value,
- window->type_hint);
+ g_value_set_enum (value, priv->type_hint);
break;
case PROP_SKIP_TASKBAR_HINT:
g_value_set_boolean (value,
@@ -1980,9 +1989,20 @@ void
gtk_window_set_type_hint (GtkWindow *window,
GdkWindowTypeHint hint)
{
+ GtkWindowPrivate *priv;
+
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
- window->type_hint = hint;
+
+ priv = GTK_WINDOW_GET_PRIVATE (window);
+
+ if (hint < GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU)
+ window->type_hint = hint;
+ else
+ window->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
+
+ priv->reset_type_hint = TRUE;
+ priv->type_hint = hint;
}
/**
@@ -1996,9 +2016,13 @@ gtk_window_set_type_hint (GtkWindow *window,
GdkWindowTypeHint
gtk_window_get_type_hint (GtkWindow *window)
{
+ GtkWindowPrivate *priv;
+
g_return_val_if_fail (GTK_IS_WINDOW (window), GDK_WINDOW_TYPE_HINT_NORMAL);
- return window->type_hint;
+ priv = GTK_WINDOW_GET_PRIVATE (window);
+
+ return priv->type_hint;
}
/**
@@ -3956,6 +3980,12 @@ gtk_window_finalize (GObject *object)
window->keys_changed_handler = 0;
}
+ if (window->screen)
+ {
+ g_signal_handlers_disconnect_by_func (window->screen,
+ gtk_window_on_composited_changed, window);
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -4101,6 +4131,17 @@ gtk_window_map (GtkWidget *widget)
window->need_default_size = FALSE;
window->need_default_position = FALSE;
+ if (priv->reset_type_hint)
+ {
+ /* We should only reset the type hint when the application
+ * used gtk_window_set_type_hint() to change the hint.
+ * Some applications use X directly to change the properties;
+ * in that case, we shouldn't overwrite what they did.
+ */
+ gdk_window_set_type_hint (widget->window, priv->type_hint);
+ priv->reset_type_hint = FALSE;
+ }
+
gdk_window_show (widget->window);
if (window->frame)
@@ -4312,8 +4353,8 @@ gtk_window_realize (GtkWidget *widget)
if (!priv->deletable)
gdk_window_set_functions (widget->window, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
- gdk_window_set_type_hint (widget->window, window->type_hint);
-
+ gdk_window_set_type_hint (widget->window, priv->type_hint);
+
if (gtk_window_get_skip_pager_hint (window))
gdk_window_set_skip_pager_hint (widget->window, TRUE);
@@ -6866,13 +6907,30 @@ gtk_window_set_screen (GtkWindow *window,
window->screen = screen;
gtk_widget_reset_rc_styles (widget);
if (screen != previous_screen)
- _gtk_widget_propagate_screen_changed (widget, 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);
+ }
g_object_notify (G_OBJECT (window), "screen");
if (was_mapped)
gtk_widget_map (widget);
}
+static void
+gtk_window_on_composited_changed (GdkScreen *screen,
+ GtkWindow *window)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (window));
+
+ _gtk_widget_propagate_composited_changed (GTK_WIDGET (window));
+}
+
static GdkScreen *
gtk_window_check_screen (GtkWindow *window)
{