From 662001b60adc6171ff8351e2146c6fa1ba383f75 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 6 Oct 2016 16:02:39 +0200 Subject: [PATCH] API: Remove ability to set visuals on windows And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are gone. We now always use the RGBA visual (if available) and otherwise fall back to the system visual. --- demos/gtk-demo/offscreen_window.c | 3 +- demos/gtk-demo/offscreen_window2.c | 3 +- gdk/gdkwindow.c | 10 +- gdk/gdkwindow.h | 7 +- gdk/wayland/gdkdevice-wayland.c | 3 +- gdk/wayland/gdkdnd-wayland.c | 3 +- gdk/win32/gdkwindow-win32.c | 9 +- gdk/x11/gdkdnd-x11.c | 5 +- gtk/deprecated/Makefile.inc | 2 - gtk/deprecated/gtkhandlebox.c | 1627 ---------------------------- gtk/deprecated/gtkhandlebox.h | 111 -- gtk/deprecated/gtkmisc.c | 3 +- gtk/gtk.h | 1 - gtk/gtkdnd.c | 19 +- gtk/gtkdrawingarea.c | 3 +- gtk/gtkeventbox.c | 3 +- gtk/gtkfixed.c | 3 +- gtk/gtkiconview.c | 3 +- gtk/gtklayout.c | 3 +- gtk/gtkmenu.c | 3 +- gtk/gtkmenushell.c | 3 +- gtk/gtknotebook.c | 3 +- gtk/gtkoffscreenwindow.c | 3 +- gtk/gtkoverlay.c | 3 +- gtk/gtkpaned.c | 5 +- gtk/gtkpopover.c | 3 +- gtk/gtkrevealer.c | 3 +- gtk/gtkscrolledwindow.c | 6 +- gtk/gtkseparatortoolitem.c | 1 - gtk/gtkspinbutton.c | 3 +- gtk/gtkstack.c | 3 +- gtk/gtktextview.c | 6 +- gtk/gtktoolitemgroup.c | 3 +- gtk/gtktoolpalette.c | 3 +- gtk/gtktreeview.c | 15 +- gtk/gtktreeviewcolumn.c | 1 - gtk/gtkviewport.c | 3 +- gtk/gtkwidget.c | 77 +- gtk/gtkwidget.h | 5 - gtk/gtkwindow.c | 32 +- gtk/inspector/inspect-button.c | 6 +- tests/gtkoffscreenbox.c | 3 +- tests/subsurface.c | 3 +- tests/testgtk.c | 27 +- 44 files changed, 54 insertions(+), 1990 deletions(-) delete mode 100644 gtk/deprecated/gtkhandlebox.c delete mode 100644 gtk/deprecated/gtkhandlebox.h diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c index acd4c41901..20f0b6c4f3 100644 --- a/demos/gtk-demo/offscreen_window.c +++ b/demos/gtk-demo/offscreen_window.c @@ -255,10 +255,9 @@ gtk_rotated_bin_realize (GtkWidget *widget) | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c index a9d1687087..9d96500613 100644 --- a/demos/gtk-demo/offscreen_window2.c +++ b/demos/gtk-demo/offscreen_window2.c @@ -194,10 +194,9 @@ gtk_mirror_bin_realize (GtkWidget *widget) | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index a7201816c6..ba64a65f43 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1340,11 +1340,6 @@ gdk_window_new (GdkWindow *parent, return NULL; } - if (attributes_mask & GDK_WA_VISUAL) - { - g_return_val_if_fail (gdk_visual_get_screen (attributes->visual) == screen, NULL); - } - display = gdk_screen_get_display (screen); window = _gdk_display_create_window (display); @@ -1418,9 +1413,8 @@ gdk_window_new (GdkWindow *parent, return NULL; } - if (attributes_mask & GDK_WA_VISUAL) - window->visual = attributes->visual; - else + window->visual = gdk_screen_get_rgba_visual (screen); + if (window->visual == NULL) window->visual = gdk_screen_get_system_visual (screen); window->event_mask = attributes->event_mask; diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 319d8367c2..d3b3240dff 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -91,7 +91,6 @@ typedef enum * @GDK_WA_TITLE: Honor the title field * @GDK_WA_X: Honor the X coordinate field * @GDK_WA_Y: Honor the Y coordinate field - * @GDK_WA_VISUAL: Honor the visual field * @GDK_WA_NOREDIR: Honor the override_redirect field * @GDK_WA_TYPE_HINT: Honor the type_hint field * @@ -107,9 +106,8 @@ typedef enum GDK_WA_TITLE = 1 << 1, GDK_WA_X = 1 << 2, GDK_WA_Y = 1 << 3, - GDK_WA_VISUAL = 1 << 4, - GDK_WA_NOREDIR = 1 << 5, - GDK_WA_TYPE_HINT = 1 << 6 + GDK_WA_NOREDIR = 1 << 4, + GDK_WA_TYPE_HINT = 1 << 5 } GdkWindowAttributesType; /* Size restriction enumeration. @@ -352,7 +350,6 @@ struct _GdkWindowAttr gint width; gint height; GdkWindowWindowClass wclass; - GdkVisual *visual; GdkWindowType window_type; gboolean override_redirect; GdkWindowTypeHint type_hint; diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index fd39676740..f453df5b4d 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -4512,9 +4512,8 @@ create_foreign_dnd_window (GdkDisplay *display) attrs.width = attrs.height = 1; attrs.wclass = GDK_INPUT_OUTPUT; attrs.window_type = GDK_WINDOW_TEMP; - attrs.visual = gdk_screen_get_system_visual (screen); - mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + mask = GDK_WA_X | GDK_WA_Y; return gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask); } diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index adc33a4bc2..817b72e15f 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -508,9 +508,8 @@ create_dnd_window (GdkScreen *screen) attrs.wclass = GDK_INPUT_OUTPUT; attrs.window_type = GDK_WINDOW_TEMP; attrs.type_hint = GDK_WINDOW_TYPE_HINT_DND; - attrs.visual = gdk_screen_get_system_visual (screen); - mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_TYPE_HINT; + mask = GDK_WA_X | GDK_WA_Y | GDK_WA_TYPE_HINT; return gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask); } diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 6a5a7dca68..0adb9074b1 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -672,7 +672,6 @@ RegisterGdkClass (GdkWindowType wtype, GdkWindowTypeHint wtype_hint) * except for toplevel window where OS/Window Manager placement * is used. * - * The visual parameter, is based on GDK_WA_VISUAL if set already. * From attributes the only things used is: colormap, title, * wmclass and type_hint. [1]. We are checking redundant information * and complain if that changes, which would break this implementation @@ -734,9 +733,9 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display, remaining_mask &= ~GDK_WA_NOREDIR; } - if ((remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0) + if ((remaining_mask & ~(GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0) g_warning ("_gdk_window_impl_new: uexpected attribute 0x%X", - remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_TITLE|GDK_WA_TYPE_HINT)); + remaining_mask & ~(GDK_WA_TITLE|GDK_WA_TYPE_HINT)); hparent = GDK_WINDOW_HWND (real_parent); @@ -744,10 +743,6 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display, impl->wrapper = GDK_WINDOW (window); window->impl = GDK_WINDOW_IMPL (impl); - if (attributes_mask & GDK_WA_VISUAL) - g_assert ((gdk_screen_get_system_visual (screen) == attributes->visual) || - (gdk_screen_get_rgba_visual (screen) == attributes->visual)); - impl->override_redirect = override_redirect; impl->layered = FALSE; impl->layered_opacity = 1.0; diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index bb322c4c10..16685510fd 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -2001,11 +2001,8 @@ create_drag_window (GdkScreen *screen) attrs.wclass = GDK_INPUT_OUTPUT; attrs.window_type = GDK_WINDOW_TEMP; attrs.type_hint = GDK_WINDOW_TYPE_HINT_DND; - attrs.visual = gdk_screen_get_rgba_visual (screen); - if (!attrs.visual) - attrs.visual = gdk_screen_get_system_visual (screen); - mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_TYPE_HINT; + mask = GDK_WA_X | GDK_WA_Y | GDK_WA_TYPE_HINT; return gdk_window_new (gdk_screen_get_root_window (screen), &attrs, mask); } diff --git a/gtk/deprecated/Makefile.inc b/gtk/deprecated/Makefile.inc index 45039387f4..e93bd66a58 100644 --- a/gtk/deprecated/Makefile.inc +++ b/gtk/deprecated/Makefile.inc @@ -8,7 +8,6 @@ deprecated_h_sources = \ deprecated/gtkcolorseldialog.h \ deprecated/gtkfontsel.h \ deprecated/gtkgradient.h \ - deprecated/gtkhandlebox.h \ deprecated/gtkhbbox.h \ deprecated/gtkhpaned.h \ deprecated/gtkhscale.h \ @@ -52,7 +51,6 @@ deprecated_c_sources = \ deprecated/gtkcolorseldialog.c \ deprecated/gtkfontsel.c \ deprecated/gtkgradient.c \ - deprecated/gtkhandlebox.c \ deprecated/gtkhbbox.c \ deprecated/gtkhpaned.c \ deprecated/gtkhscale.c \ diff --git a/gtk/deprecated/gtkhandlebox.c b/gtk/deprecated/gtkhandlebox.c deleted file mode 100644 index cb1d12ca2b..0000000000 --- a/gtk/deprecated/gtkhandlebox.c +++ /dev/null @@ -1,1627 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * Copyright (C) 1998 Elliot Lee - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include - -#define GDK_DISABLE_DEPRECATION_WARNINGS - -#include "gtkhandlebox.h" -#include "gtkinvisible.h" -#include "gtkmain.h" -#include "gtkmarshalers.h" -#include "gtkrender.h" -#include "gtkwindow.h" -#include "gtktypebuiltins.h" -#include "gtkprivate.h" -#include "gtkintl.h" - - -/** - * SECTION:gtkhandlebox - * @Short_description: a widget for detachable window portions - * @Title: GtkHandleBox - * - * The #GtkHandleBox widget allows a portion of a window to be "torn - * off". It is a bin widget which displays its child and a handle that - * the user can drag to tear off a separate window (the “float - * window”) containing the child widget. A thin - * “ghost” is drawn in the original location of the - * handlebox. By dragging the separate window back to its original - * location, it can be reattached. - * - * When reattaching, the ghost and float window, must be aligned - * along one of the edges, the “snap edge”. - * This either can be specified by the application programmer - * explicitly, or GTK+ will pick a reasonable default based - * on the handle position. - * - * To make detaching and reattaching the handlebox as minimally confusing - * as possible to the user, it is important to set the snap edge so that - * the snap edge does not move when the handlebox is deattached. For - * instance, if the handlebox is packed at the bottom of a VBox, then - * when the handlebox is detached, the bottom edge of the handlebox's - * allocation will remain fixed as the height of the handlebox shrinks, - * so the snap edge should be set to %GTK_POS_BOTTOM. - * - * > #GtkHandleBox has been deprecated. It is very specialized, lacks features - * > to make it useful and most importantly does not fit well into modern - * > application design. Do not use it. There is no replacement. - */ - - -struct _GtkHandleBoxPrivate -{ - /* Properties */ - GtkPositionType handle_position; - gint snap_edge; - GtkShadowType shadow_type; - gboolean child_detached; - /* Properties */ - - GtkAllocation attach_allocation; - GtkAllocation float_allocation; - - GdkDevice *grab_device; - - GdkWindow *bin_window; /* parent window for children */ - GdkWindow *float_window; - - /* Variables used during a drag - */ - gint orig_x; - gint orig_y; - - guint float_window_mapped : 1; - guint in_drag : 1; - guint shrink_on_detach : 1; -}; - -enum { - PROP_0, - PROP_SHADOW_TYPE, - PROP_HANDLE_POSITION, - PROP_SNAP_EDGE, - PROP_SNAP_EDGE_SET, - PROP_CHILD_DETACHED -}; - -#define DRAG_HANDLE_SIZE 10 -#define CHILDLESS_SIZE 25 -#define GHOST_HEIGHT 3 -#define TOLERANCE 5 - -enum { - SIGNAL_CHILD_ATTACHED, - SIGNAL_CHILD_DETACHED, - SIGNAL_LAST -}; - -/* The algorithm for docking and redocking implemented here - * has a couple of nice properties: - * - * 1) During a single drag, docking always occurs at the - * the same cursor position. This means that the users - * motions are reversible, and that you won't - * undock/dock oscillations. - * - * 2) Docking generally occurs at user-visible features. - * The user, once they figure out to redock, will - * have useful information about doing it again in - * the future. - * - * Please try to preserve these properties if you - * change the algorithm. (And the current algorithm - * is far from ideal). Briefly, the current algorithm - * for deciding whether the handlebox is docked or not: - * - * 1) The decision is done by comparing two rectangles - the - * allocation if the widget at the start of the drag, - * and the boundary of hb->bin_window at the start of - * of the drag offset by the distance that the cursor - * has moved. - * - * 2) These rectangles must have one edge, the “snap_edge” - * of the handlebox, aligned within TOLERANCE. - * - * 3) On the other dimension, the extents of one rectangle - * must be contained in the extents of the other, - * extended by tolerance. That is, either we can have: - * - * <-TOLERANCE-|--------bin_window--------------|-TOLERANCE-> - * <--------float_window--------------------> - * - * or we can have: - * - * <-TOLERANCE-|------float_window--------------|-TOLERANCE-> - * <--------bin_window--------------------> - */ - -static void gtk_handle_box_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_handle_box_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void gtk_handle_box_map (GtkWidget *widget); -static void gtk_handle_box_unmap (GtkWidget *widget); -static void gtk_handle_box_realize (GtkWidget *widget); -static void gtk_handle_box_unrealize (GtkWidget *widget); -static void gtk_handle_box_style_updated (GtkWidget *widget); -static void gtk_handle_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_handle_box_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_handle_box_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_handle_box_size_allocate (GtkWidget *widget, - GtkAllocation *real_allocation); -static void gtk_handle_box_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_handle_box_remove (GtkContainer *container, - GtkWidget *widget); -static gboolean gtk_handle_box_draw (GtkWidget *widget, - cairo_t *cr); -static gboolean gtk_handle_box_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean gtk_handle_box_motion (GtkWidget *widget, - GdkEventMotion *event); -static gboolean gtk_handle_box_delete_event (GtkWidget *widget, - GdkEventAny *event); -static void gtk_handle_box_reattach (GtkHandleBox *hb); -static void gtk_handle_box_end_drag (GtkHandleBox *hb, - guint32 time); - -static guint handle_box_signals[SIGNAL_LAST] = { 0 }; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkHandleBox, gtk_handle_box, GTK_TYPE_BIN) - -static void -gtk_handle_box_class_init (GtkHandleBoxClass *class) -{ - GObjectClass *gobject_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - gobject_class = (GObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - container_class = (GtkContainerClass *) class; - - gobject_class->set_property = gtk_handle_box_set_property; - gobject_class->get_property = gtk_handle_box_get_property; - - g_object_class_install_property (gobject_class, - PROP_SHADOW_TYPE, - g_param_spec_enum ("shadow-type", - P_("Shadow type"), - P_("Appearance of the shadow that surrounds the container"), - GTK_TYPE_SHADOW_TYPE, - GTK_SHADOW_OUT, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_HANDLE_POSITION, - g_param_spec_enum ("handle-position", - P_("Handle position"), - P_("Position of the handle relative to the child widget"), - GTK_TYPE_POSITION_TYPE, - GTK_POS_LEFT, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_SNAP_EDGE, - g_param_spec_enum ("snap-edge", - P_("Snap edge"), - P_("Side of the handlebox that's lined up with the docking point to dock the handlebox"), - GTK_TYPE_POSITION_TYPE, - GTK_POS_TOP, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_SNAP_EDGE_SET, - g_param_spec_boolean ("snap-edge-set", - P_("Snap edge set"), - P_("Whether to use the value from the snap_edge property or a value derived from handle_position"), - FALSE, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_CHILD_DETACHED, - g_param_spec_boolean ("child-detached", - P_("Child Detached"), - P_("A boolean value indicating whether the handlebox's child is attached or detached."), - FALSE, - GTK_PARAM_READABLE)); - - widget_class->map = gtk_handle_box_map; - widget_class->unmap = gtk_handle_box_unmap; - widget_class->realize = gtk_handle_box_realize; - widget_class->unrealize = gtk_handle_box_unrealize; - widget_class->style_updated = gtk_handle_box_style_updated; - widget_class->get_preferred_width = gtk_handle_box_get_preferred_width; - widget_class->get_preferred_height = gtk_handle_box_get_preferred_height; - widget_class->size_allocate = gtk_handle_box_size_allocate; - widget_class->draw = gtk_handle_box_draw; - widget_class->button_press_event = gtk_handle_box_button_press; - widget_class->delete_event = gtk_handle_box_delete_event; - - container_class->add = gtk_handle_box_add; - container_class->remove = gtk_handle_box_remove; - - class->child_attached = NULL; - class->child_detached = NULL; - - /** - * GtkHandleBox::child-attached: - * @handlebox: the object which received the signal. - * @widget: the child widget of the handlebox. - * (this argument provides no extra information - * and is here only for backwards-compatibility) - * - * This signal is emitted when the contents of the - * handlebox are reattached to the main window. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ - handle_box_signals[SIGNAL_CHILD_ATTACHED] = - g_signal_new (I_("child-attached"), - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GtkHandleBoxClass, child_attached), - NULL, NULL, - NULL, - G_TYPE_NONE, 1, - GTK_TYPE_WIDGET); - - /** - * GtkHandleBox::child-detached: - * @handlebox: the object which received the signal. - * @widget: the child widget of the handlebox. - * (this argument provides no extra information - * and is here only for backwards-compatibility) - * - * This signal is emitted when the contents of the - * handlebox are detached from the main window. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ - handle_box_signals[SIGNAL_CHILD_DETACHED] = - g_signal_new (I_("child-detached"), - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GtkHandleBoxClass, child_detached), - NULL, NULL, - NULL, - G_TYPE_NONE, 1, - GTK_TYPE_WIDGET); -} - -static void -gtk_handle_box_init (GtkHandleBox *handle_box) -{ - GtkHandleBoxPrivate *priv; - GtkStyleContext *context; - - handle_box->priv = gtk_handle_box_get_instance_private (handle_box); - priv = handle_box->priv; - - gtk_widget_set_has_window (GTK_WIDGET (handle_box), TRUE); - - priv->bin_window = NULL; - priv->float_window = NULL; - priv->shadow_type = GTK_SHADOW_OUT; - priv->handle_position = GTK_POS_LEFT; - priv->float_window_mapped = FALSE; - priv->child_detached = FALSE; - priv->in_drag = FALSE; - priv->shrink_on_detach = TRUE; - priv->snap_edge = -1; - - context = gtk_widget_get_style_context (GTK_WIDGET (handle_box)); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_DOCK); -} - -static void -gtk_handle_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkHandleBox *handle_box = GTK_HANDLE_BOX (object); - - switch (prop_id) - { - case PROP_SHADOW_TYPE: - gtk_handle_box_set_shadow_type (handle_box, g_value_get_enum (value)); - break; - case PROP_HANDLE_POSITION: - gtk_handle_box_set_handle_position (handle_box, g_value_get_enum (value)); - break; - case PROP_SNAP_EDGE: - gtk_handle_box_set_snap_edge (handle_box, g_value_get_enum (value)); - break; - case PROP_SNAP_EDGE_SET: - if (!g_value_get_boolean (value)) - gtk_handle_box_set_snap_edge (handle_box, (GtkPositionType)-1); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_handle_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkHandleBox *handle_box = GTK_HANDLE_BOX (object); - GtkHandleBoxPrivate *priv = handle_box->priv; - - switch (prop_id) - { - case PROP_SHADOW_TYPE: - g_value_set_enum (value, priv->shadow_type); - break; - case PROP_HANDLE_POSITION: - g_value_set_enum (value, priv->handle_position); - break; - case PROP_SNAP_EDGE: - g_value_set_enum (value, - (priv->snap_edge == -1 ? - GTK_POS_TOP : priv->snap_edge)); - break; - case PROP_SNAP_EDGE_SET: - g_value_set_boolean (value, priv->snap_edge != -1); - break; - case PROP_CHILD_DETACHED: - g_value_set_boolean (value, priv->child_detached); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * gtk_handle_box_new: - * - * Create a new handle box. - * - * Returns: a new #GtkHandleBox. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ -GtkWidget* -gtk_handle_box_new (void) -{ - return g_object_new (GTK_TYPE_HANDLE_BOX, NULL); -} - -static void -gtk_handle_box_map (GtkWidget *widget) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child; - - gtk_widget_set_mapped (widget, TRUE); - - child = gtk_bin_get_child (bin); - if (child != NULL && - gtk_widget_get_visible (child) && - !gtk_widget_get_mapped (child)) - gtk_widget_map (child); - - if (priv->child_detached && !priv->float_window_mapped) - { - gdk_window_show (priv->float_window); - priv->float_window_mapped = TRUE; - } - - gdk_window_show (priv->bin_window); - gdk_window_show (gtk_widget_get_window (widget)); -} - -static void -gtk_handle_box_unmap (GtkWidget *widget) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - - gtk_widget_set_mapped (widget, FALSE); - - gdk_window_hide (gtk_widget_get_window (widget)); - if (priv->float_window_mapped) - { - gdk_window_hide (priv->float_window); - priv->float_window_mapped = FALSE; - } - - GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->unmap (widget); -} - -static void -gtk_handle_box_realize (GtkWidget *widget) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkAllocation allocation; - GtkRequisition requisition; - GtkStyleContext *context; - GtkWidget *child; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - - gtk_widget_set_realized (widget, TRUE); - - gtk_widget_get_allocation (widget, &allocation); - - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; - - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, widget); - - attributes.x = 0; - attributes.y = 0; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = (gtk_widget_get_events (widget) - | GDK_BUTTON1_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; - - priv->bin_window = gdk_window_new (window, - &attributes, attributes_mask); - gdk_window_set_user_data (priv->bin_window, widget); - - child = gtk_bin_get_child (GTK_BIN (hb)); - if (child) - gtk_widget_set_parent_window (child, priv->bin_window); - - gtk_widget_get_preferred_size (widget, &requisition, NULL); - - attributes.x = 0; - attributes.y = 0; - attributes.width = requisition.width; - attributes.height = requisition.height; - attributes.window_type = GDK_WINDOW_TOPLEVEL; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.event_mask = (gtk_widget_get_events (widget) - | GDK_KEY_PRESS_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_FOCUS_CHANGE_MASK - | GDK_STRUCTURE_MASK); - attributes.type_hint = GDK_WINDOW_TYPE_HINT_TOOLBAR; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_TYPE_HINT; - priv->float_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), - &attributes, attributes_mask); - gdk_window_set_user_data (priv->float_window, widget); - gdk_window_set_decorations (priv->float_window, 0); - gdk_window_set_type_hint (priv->float_window, GDK_WINDOW_TYPE_HINT_TOOLBAR); - - context = gtk_widget_get_style_context (widget); - gtk_style_context_set_background (context, window); - gtk_style_context_set_background (context, priv->bin_window); - gtk_style_context_set_background (context, priv->float_window); -} - -static void -gtk_handle_box_unrealize (GtkWidget *widget) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - - gdk_window_set_user_data (priv->bin_window, NULL); - gdk_window_destroy (priv->bin_window); - priv->bin_window = NULL; - gdk_window_set_user_data (priv->float_window, NULL); - gdk_window_destroy (priv->float_window); - priv->float_window = NULL; - - GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->unrealize (widget); -} - -static void -gtk_handle_box_style_updated (GtkWidget *widget) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - - GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->style_updated (widget); - - if (gtk_widget_get_realized (widget) && - gtk_widget_get_has_window (widget)) - { - GtkStateFlags state; - GtkStyleContext *context; - - context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - - gtk_style_context_save (context); - gtk_style_context_set_state (context, state); - - gtk_style_context_set_background (context, gtk_widget_get_window (widget)); - gtk_style_context_set_background (context, priv->bin_window); - gtk_style_context_set_background (context, priv->float_window); - - gtk_style_context_restore (context); - } -} - -static int -effective_handle_position (GtkHandleBox *hb) -{ - GtkHandleBoxPrivate *priv = hb->priv; - int handle_position; - - if (gtk_widget_get_direction (GTK_WIDGET (hb)) == GTK_TEXT_DIR_LTR) - handle_position = priv->handle_position; - else - { - switch (priv->handle_position) - { - case GTK_POS_LEFT: - handle_position = GTK_POS_RIGHT; - break; - case GTK_POS_RIGHT: - handle_position = GTK_POS_LEFT; - break; - default: - handle_position = priv->handle_position; - break; - } - } - - return handle_position; -} - -static void -gtk_handle_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin = GTK_BIN (widget); - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkRequisition child_requisition; - GtkWidget *child; - gint handle_position; - - handle_position = effective_handle_position (hb); - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - { - requisition->width = DRAG_HANDLE_SIZE; - requisition->height = 0; - } - else - { - requisition->width = 0; - requisition->height = DRAG_HANDLE_SIZE; - } - - child = gtk_bin_get_child (bin); - /* if our child is not visible, we still request its size, since we - * won't have any useful hint for our size otherwise. - */ - if (child) - { - gtk_widget_get_preferred_size (child, &child_requisition, NULL); - } - else - { - child_requisition.width = 0; - child_requisition.height = 0; - } - - if (priv->child_detached) - { - /* FIXME: This doesn't work currently */ - if (!priv->shrink_on_detach) - { - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - requisition->height += child_requisition.height; - else - requisition->width += child_requisition.width; - } - else - { - GtkStyleContext *context; - GtkStateFlags state; - GtkBorder padding; - - context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - gtk_style_context_get_padding (context, state, &padding); - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - requisition->height += padding.top; - else - requisition->width += padding.left; - } - } - else - { - guint border_width; - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - requisition->width += border_width * 2; - requisition->height += border_width * 2; - - if (child) - { - requisition->width += child_requisition.width; - requisition->height += child_requisition.height; - } - else - { - requisition->width += CHILDLESS_SIZE; - requisition->height += CHILDLESS_SIZE; - } - } -} - -static void -gtk_handle_box_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkRequisition requisition; - - gtk_handle_box_size_request (widget, &requisition); - - *minimum = *natural = requisition.width; -} - -static void -gtk_handle_box_get_preferred_height (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - GtkRequisition requisition; - - gtk_handle_box_size_request (widget, &requisition); - - *minimum = *natural = requisition.height; -} - - -static void -gtk_handle_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin = GTK_BIN (widget); - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkRequisition child_requisition; - GtkWidget *child; - gint handle_position; - - handle_position = effective_handle_position (hb); - - child = gtk_bin_get_child (bin); - - if (child) - { - gtk_widget_get_preferred_size (child, &child_requisition, NULL); - } - else - { - child_requisition.width = 0; - child_requisition.height = 0; - } - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, allocation->y, - allocation->width, allocation->height); - - if (child != NULL && gtk_widget_get_visible (child)) - { - GtkAllocation child_allocation; - guint border_width; - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - child_allocation.x = border_width; - child_allocation.y = border_width; - if (handle_position == GTK_POS_LEFT) - child_allocation.x += DRAG_HANDLE_SIZE; - else if (handle_position == GTK_POS_TOP) - child_allocation.y += DRAG_HANDLE_SIZE; - - if (priv->child_detached) - { - guint float_width; - guint float_height; - - child_allocation.width = child_requisition.width; - child_allocation.height = child_requisition.height; - - float_width = child_allocation.width + 2 * border_width; - float_height = child_allocation.height + 2 * border_width; - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - float_width += DRAG_HANDLE_SIZE; - else - float_height += DRAG_HANDLE_SIZE; - - if (gtk_widget_get_realized (widget)) - { - gdk_window_resize (priv->float_window, - float_width, - float_height); - gdk_window_move_resize (priv->bin_window, - 0, - 0, - float_width, - float_height); - } - } - else - { - child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width); - child_allocation.height = MAX (1, (gint) allocation->height - 2 * border_width); - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - child_allocation.width -= DRAG_HANDLE_SIZE; - else - child_allocation.height -= DRAG_HANDLE_SIZE; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (priv->bin_window, - 0, - 0, - allocation->width, - allocation->height); - } - - gtk_widget_size_allocate (child, &child_allocation); - } -} - -static void -gtk_handle_box_draw_ghost (GtkHandleBox *hb, - cairo_t *cr) -{ - GtkWidget *widget = GTK_WIDGET (hb); - GtkStateFlags state; - GtkStyleContext *context; - guint x; - guint y; - guint width; - guint height; - gint allocation_width; - gint allocation_height; - gint handle_position; - - handle_position = effective_handle_position (hb); - allocation_width = gtk_widget_get_allocated_width (widget); - allocation_height = gtk_widget_get_allocated_height (widget); - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - { - x = handle_position == GTK_POS_LEFT ? 0 : allocation_width - DRAG_HANDLE_SIZE; - y = 0; - width = DRAG_HANDLE_SIZE; - height = allocation_height; - } - else - { - x = 0; - y = handle_position == GTK_POS_TOP ? 0 : allocation_height - DRAG_HANDLE_SIZE; - width = allocation_width; - height = DRAG_HANDLE_SIZE; - } - - context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - - gtk_style_context_save (context); - gtk_style_context_set_state (context, state); - - gtk_render_background (context, cr, x, y, width, height); - gtk_render_frame (context, cr, x, y, width, height); - - if (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) - gtk_render_line (context, cr, - handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0, - allocation_height / 2, - handle_position == GTK_POS_LEFT ? allocation_width : allocation_width - DRAG_HANDLE_SIZE, - allocation_height / 2); - else - gtk_render_line (context, cr, - allocation_width / 2, - handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0, - allocation_width / 2, - handle_position == GTK_POS_TOP ? allocation_height : allocation_height - DRAG_HANDLE_SIZE); - - gtk_style_context_restore (context); -} - -/** - * gtk_handle_box_set_shadow_type: - * @handle_box: a #GtkHandleBox - * @type: the shadow type. - * - * Sets the type of shadow to be drawn around the border - * of the handle box. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ -void -gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box, - GtkShadowType type) -{ - GtkHandleBoxPrivate *priv; - - g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); - - priv = handle_box->priv; - - if ((GtkShadowType) priv->shadow_type != type) - { - priv->shadow_type = type; - g_object_notify (G_OBJECT (handle_box), "shadow-type"); - gtk_widget_queue_resize (GTK_WIDGET (handle_box)); - } -} - -/** - * gtk_handle_box_get_shadow_type: - * @handle_box: a #GtkHandleBox - * - * Gets the type of shadow drawn around the handle box. See - * gtk_handle_box_set_shadow_type(). - * - * Returns: the type of shadow currently drawn around the handle box. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - **/ -GtkShadowType -gtk_handle_box_get_shadow_type (GtkHandleBox *handle_box) -{ - g_return_val_if_fail (GTK_IS_HANDLE_BOX (handle_box), GTK_SHADOW_ETCHED_OUT); - - return handle_box->priv->shadow_type; -} - -/** - * gtk_handle_box_set_handle_position: - * @handle_box: a #GtkHandleBox - * @position: the side of the handlebox where the handle should be drawn. - * - * Sets the side of the handlebox where the handle is drawn. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ -void -gtk_handle_box_set_handle_position (GtkHandleBox *handle_box, - GtkPositionType position) -{ - GtkHandleBoxPrivate *priv; - - g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); - - priv = handle_box->priv; - - if ((GtkPositionType) priv->handle_position != position) - { - priv->handle_position = position; - g_object_notify (G_OBJECT (handle_box), "handle-position"); - gtk_widget_queue_resize (GTK_WIDGET (handle_box)); - } -} - -/** - * gtk_handle_box_get_handle_position: - * @handle_box: a #GtkHandleBox - * - * Gets the handle position of the handle box. See - * gtk_handle_box_set_handle_position(). - * - * Returns: the current handle position. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - **/ -GtkPositionType -gtk_handle_box_get_handle_position (GtkHandleBox *handle_box) -{ - g_return_val_if_fail (GTK_IS_HANDLE_BOX (handle_box), GTK_POS_LEFT); - - return handle_box->priv->handle_position; -} - -/** - * gtk_handle_box_set_snap_edge: - * @handle_box: a #GtkHandleBox - * @edge: the snap edge, or -1 to unset the value; in which - * case GTK+ will try to guess an appropriate value - * in the future. - * - * Sets the snap edge of a handlebox. The snap edge is - * the edge of the detached child that must be aligned - * with the corresponding edge of the “ghost” left - * behind when the child was detached to reattach - * the torn-off window. Usually, the snap edge should - * be chosen so that it stays in the same place on - * the screen when the handlebox is torn off. - * - * If the snap edge is not set, then an appropriate value - * will be guessed from the handle position. If the - * handle position is %GTK_POS_RIGHT or %GTK_POS_LEFT, - * then the snap edge will be %GTK_POS_TOP, otherwise - * it will be %GTK_POS_LEFT. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - */ -void -gtk_handle_box_set_snap_edge (GtkHandleBox *handle_box, - GtkPositionType edge) -{ - GtkHandleBoxPrivate *priv; - - g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box)); - - priv = handle_box->priv; - - if (priv->snap_edge != edge) - { - priv->snap_edge = edge; - - g_object_freeze_notify (G_OBJECT (handle_box)); - g_object_notify (G_OBJECT (handle_box), "snap-edge"); - g_object_notify (G_OBJECT (handle_box), "snap-edge-set"); - g_object_thaw_notify (G_OBJECT (handle_box)); - } -} - -/** - * gtk_handle_box_get_snap_edge: - * @handle_box: a #GtkHandleBox - * - * Gets the edge used for determining reattachment of the handle box. - * See gtk_handle_box_set_snap_edge(). - * - * Returns: the edge used for determining reattachment, or - * (GtkPositionType)-1 if this is determined (as per default) - * from the handle position. - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - **/ -GtkPositionType -gtk_handle_box_get_snap_edge (GtkHandleBox *handle_box) -{ - g_return_val_if_fail (GTK_IS_HANDLE_BOX (handle_box), (GtkPositionType)-1); - - return (GtkPositionType)handle_box->priv->snap_edge; -} - -/** - * gtk_handle_box_get_child_detached: - * @handle_box: a #GtkHandleBox - * - * Whether the handlebox’s child is currently detached. - * - * Returns: %TRUE if the child is currently detached, otherwise %FALSE - * - * Since: 2.14 - * - * Deprecated: 3.4: #GtkHandleBox has been deprecated. - **/ -gboolean -gtk_handle_box_get_child_detached (GtkHandleBox *handle_box) -{ - g_return_val_if_fail (GTK_IS_HANDLE_BOX (handle_box), FALSE); - - return handle_box->priv->child_detached; -} - -static void -gtk_handle_box_paint (GtkWidget *widget, - cairo_t *cr) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkBin *bin = GTK_BIN (widget); - GtkStyleContext *context; - GtkStateFlags state; - GtkWidget *child; - gint width, height; - GdkRectangle rect; - gint handle_position; - - handle_position = effective_handle_position (hb); - - width = gdk_window_get_width (priv->bin_window); - height = gdk_window_get_height (priv->bin_window); - - context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - - gtk_style_context_save (context); - gtk_style_context_set_state (context, state); - - gtk_render_background (context, cr, 0, 0, width, height); - gtk_render_frame (context, cr, 0, 0, width, height); - - switch (handle_position) - { - case GTK_POS_LEFT: - rect.x = 0; - rect.y = 0; - rect.width = DRAG_HANDLE_SIZE; - rect.height = height; - break; - case GTK_POS_RIGHT: - rect.x = width - DRAG_HANDLE_SIZE; - rect.y = 0; - rect.width = DRAG_HANDLE_SIZE; - rect.height = height; - break; - case GTK_POS_TOP: - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = DRAG_HANDLE_SIZE; - break; - case GTK_POS_BOTTOM: - rect.x = 0; - rect.y = height - DRAG_HANDLE_SIZE; - rect.width = width; - rect.height = DRAG_HANDLE_SIZE; - break; - default: - g_assert_not_reached (); - break; - } - - gtk_render_handle (context, cr, - rect.x, rect.y, rect.width, rect.height); - - child = gtk_bin_get_child (bin); - if (child != NULL && gtk_widget_get_visible (child)) - GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->draw (widget, cr); - - gtk_style_context_restore (context); -} - -static gboolean -gtk_handle_box_draw (GtkWidget *widget, - cairo_t *cr) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - - if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) - { - if (priv->child_detached) - gtk_handle_box_draw_ghost (hb, cr); - } - else if (gtk_cairo_should_draw_window (cr, priv->bin_window)) - gtk_handle_box_paint (widget, cr); - - return FALSE; -} - -static GtkWidget * -gtk_handle_box_get_invisible (void) -{ - static GtkWidget *handle_box_invisible = NULL; - - if (!handle_box_invisible) - { - handle_box_invisible = gtk_invisible_new (); - gtk_widget_show (handle_box_invisible); - } - - return handle_box_invisible; -} - -static gboolean -gtk_handle_box_grab_event (GtkWidget *widget, - GdkEvent *event, - GtkHandleBox *hb) -{ - GtkHandleBoxPrivate *priv = hb->priv; - - switch (event->type) - { - case GDK_BUTTON_RELEASE: - if (priv->in_drag) /* sanity check */ - { - gtk_handle_box_end_drag (hb, event->button.time); - return TRUE; - } - break; - - case GDK_MOTION_NOTIFY: - return gtk_handle_box_motion (GTK_WIDGET (hb), (GdkEventMotion *)event); - break; - - default: - break; - } - - return FALSE; -} - -static gboolean -gtk_handle_box_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - gboolean event_handled; - GdkCursor *fleur; - gint handle_position; - - handle_position = effective_handle_position (hb); - - event_handled = FALSE; - if ((event->button == GDK_BUTTON_PRIMARY) && - (event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS)) - { - GtkWidget *child; - gboolean in_handle; - - if (event->window != priv->bin_window) - return FALSE; - - child = gtk_bin_get_child (GTK_BIN (hb)); - - if (child) - { - GtkAllocation child_allocation; - guint border_width; - - gtk_widget_get_allocation (child, &child_allocation); - border_width = gtk_container_get_border_width (GTK_CONTAINER (hb)); - - switch (handle_position) - { - case GTK_POS_LEFT: - in_handle = event->x < DRAG_HANDLE_SIZE; - break; - case GTK_POS_TOP: - in_handle = event->y < DRAG_HANDLE_SIZE; - break; - case GTK_POS_RIGHT: - in_handle = event->x > 2 * border_width + child_allocation.width; - break; - case GTK_POS_BOTTOM: - in_handle = event->y > 2 * border_width + child_allocation.height; - break; - default: - in_handle = FALSE; - break; - } - } - else - { - in_handle = FALSE; - event_handled = TRUE; - } - - if (in_handle) - { - if (event->type == GDK_BUTTON_PRESS) /* Start a drag */ - { - GtkWidget *invisible = gtk_handle_box_get_invisible (); - GdkWindow *window; - gint root_x, root_y; - - gtk_invisible_set_screen (GTK_INVISIBLE (invisible), - gtk_widget_get_screen (GTK_WIDGET (hb))); - gdk_window_get_origin (priv->bin_window, &root_x, &root_y); - - priv->orig_x = event->x_root; - priv->orig_y = event->y_root; - - priv->float_allocation.x = root_x - event->x_root; - priv->float_allocation.y = root_y - event->y_root; - priv->float_allocation.width = gdk_window_get_width (priv->bin_window); - priv->float_allocation.height = gdk_window_get_height (priv->bin_window); - - window = gtk_widget_get_window (widget); - if (gdk_window_is_viewable (window)) - { - gdk_window_get_origin (window, &root_x, &root_y); - - priv->attach_allocation.x = root_x; - priv->attach_allocation.y = root_y; - priv->attach_allocation.width = gdk_window_get_width (window); - priv->attach_allocation.height = gdk_window_get_height (window); - } - else - { - priv->attach_allocation.x = -1; - priv->attach_allocation.y = -1; - priv->attach_allocation.width = 0; - priv->attach_allocation.height = 0; - } - priv->in_drag = TRUE; - priv->grab_device = event->device; - fleur = gdk_cursor_new_for_display (gtk_widget_get_display (widget), - GDK_FLEUR); - if (gdk_device_grab (event->device, - gtk_widget_get_window (invisible), - GDK_OWNERSHIP_WINDOW, - FALSE, - (GDK_BUTTON1_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_RELEASE_MASK), - fleur, - event->time) != GDK_GRAB_SUCCESS) - { - priv->in_drag = FALSE; - priv->grab_device = NULL; - } - else - { - gtk_device_grab_add (invisible, priv->grab_device, TRUE); - g_signal_connect (invisible, "event", - G_CALLBACK (gtk_handle_box_grab_event), hb); - } - - g_object_unref (fleur); - event_handled = TRUE; - } - else if (priv->child_detached) /* Double click */ - { - gtk_handle_box_reattach (hb); - } - } - } - - return event_handled; -} - -static gboolean -gtk_handle_box_motion (GtkWidget *widget, - GdkEventMotion *event) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - GtkWidget *child; - gint new_x, new_y; - gint snap_edge; - gboolean is_snapped = FALSE; - gint handle_position; - GdkGeometry geometry; - GdkScreen *screen, *pointer_screen; - - if (!priv->in_drag) - return FALSE; - handle_position = effective_handle_position (hb); - - /* Calculate the attachment point on the float, if the float - * were detached - */ - new_x = 0; - new_y = 0; - screen = gtk_widget_get_screen (widget); - gdk_device_get_position (event->device, - &pointer_screen, - &new_x, &new_y); - if (pointer_screen != screen) - { - new_x = priv->orig_x; - new_y = priv->orig_y; - } - - new_x += priv->float_allocation.x; - new_y += priv->float_allocation.y; - - snap_edge = priv->snap_edge; - if (snap_edge == -1) - snap_edge = (handle_position == GTK_POS_LEFT || - handle_position == GTK_POS_RIGHT) ? - GTK_POS_TOP : GTK_POS_LEFT; - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - switch (snap_edge) - { - case GTK_POS_LEFT: - snap_edge = GTK_POS_RIGHT; - break; - case GTK_POS_RIGHT: - snap_edge = GTK_POS_LEFT; - break; - default: - break; - } - - /* First, check if the snapped edge is aligned - */ - switch (snap_edge) - { - case GTK_POS_TOP: - is_snapped = abs (priv->attach_allocation.y - new_y) < TOLERANCE; - break; - case GTK_POS_BOTTOM: - is_snapped = abs (priv->attach_allocation.y + (gint)priv->attach_allocation.height - - new_y - (gint)priv->float_allocation.height) < TOLERANCE; - break; - case GTK_POS_LEFT: - is_snapped = abs (priv->attach_allocation.x - new_x) < TOLERANCE; - break; - case GTK_POS_RIGHT: - is_snapped = abs (priv->attach_allocation.x + (gint)priv->attach_allocation.width - - new_x - (gint)priv->float_allocation.width) < TOLERANCE; - break; - } - - /* Next, check if coordinates in the other direction are sufficiently - * aligned - */ - if (is_snapped) - { - gint float_pos1 = 0; /* Initialize to suppress warnings */ - gint float_pos2 = 0; - gint attach_pos1 = 0; - gint attach_pos2 = 0; - - switch (snap_edge) - { - case GTK_POS_TOP: - case GTK_POS_BOTTOM: - attach_pos1 = priv->attach_allocation.x; - attach_pos2 = priv->attach_allocation.x + priv->attach_allocation.width; - float_pos1 = new_x; - float_pos2 = new_x + priv->float_allocation.width; - break; - case GTK_POS_LEFT: - case GTK_POS_RIGHT: - attach_pos1 = priv->attach_allocation.y; - attach_pos2 = priv->attach_allocation.y + priv->attach_allocation.height; - float_pos1 = new_y; - float_pos2 = new_y + priv->float_allocation.height; - break; - } - - is_snapped = ((attach_pos1 - TOLERANCE < float_pos1) && - (attach_pos2 + TOLERANCE > float_pos2)) || - ((float_pos1 - TOLERANCE < attach_pos1) && - (float_pos2 + TOLERANCE > attach_pos2)); - } - - child = gtk_bin_get_child (GTK_BIN (hb)); - - if (is_snapped) - { - if (priv->child_detached) - { - priv->child_detached = FALSE; - gdk_window_hide (priv->float_window); - gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget), 0, 0); - priv->float_window_mapped = FALSE; - g_signal_emit (hb, - handle_box_signals[SIGNAL_CHILD_ATTACHED], - 0, - child); - - gtk_widget_queue_resize (widget); - } - } - else - { - gint width, height; - - width = gdk_window_get_width (priv->float_window); - height = gdk_window_get_height (priv->float_window); - - switch (handle_position) - { - case GTK_POS_LEFT: - new_y += ((gint)priv->float_allocation.height - height) / 2; - break; - case GTK_POS_RIGHT: - new_x += (gint)priv->float_allocation.width - width; - new_y += ((gint)priv->float_allocation.height - height) / 2; - break; - case GTK_POS_TOP: - new_x += ((gint)priv->float_allocation.width - width) / 2; - break; - case GTK_POS_BOTTOM: - new_x += ((gint)priv->float_allocation.width - width) / 2; - new_y += (gint)priv->float_allocation.height - height; - break; - } - - if (priv->child_detached) - { - gdk_window_move (priv->float_window, new_x, new_y); - gdk_window_raise (priv->float_window); - } - else - { - guint border_width; - GtkRequisition child_requisition; - - priv->child_detached = TRUE; - - if (child) - { - gtk_widget_get_preferred_size (child, &child_requisition, NULL); - } - else - { - child_requisition.width = 0; - child_requisition.height = 0; - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (hb)); - width = child_requisition.width + 2 * border_width; - height = child_requisition.height + 2 * border_width; - - if (handle_position == GTK_POS_LEFT || handle_position == GTK_POS_RIGHT) - width += DRAG_HANDLE_SIZE; - else - height += DRAG_HANDLE_SIZE; - - gdk_window_move_resize (priv->float_window, new_x, new_y, width, height); - gdk_window_reparent (priv->bin_window, priv->float_window, 0, 0); - gdk_window_set_geometry_hints (priv->float_window, &geometry, GDK_HINT_POS); - gdk_window_show (priv->float_window); - priv->float_window_mapped = TRUE; -#if 0 - /* this extra move is necessary if we use decorations, or our - * window manager insists on decorations. - */ - gdk_display_sync (gtk_widget_get_display (widget)); - gdk_window_move (priv->float_window, new_x, new_y); - gdk_display_sync (gtk_widget_get_display (widget)); -#endif /* 0 */ - g_signal_emit (hb, - handle_box_signals[SIGNAL_CHILD_DETACHED], - 0, - child); - - gtk_widget_queue_resize (widget); - } - } - - return TRUE; -} - -static void -gtk_handle_box_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkHandleBoxPrivate *priv = GTK_HANDLE_BOX (container)->priv; - - gtk_widget_set_parent_window (widget, priv->bin_window); - GTK_CONTAINER_CLASS (gtk_handle_box_parent_class)->add (container, widget); -} - -static void -gtk_handle_box_remove (GtkContainer *container, - GtkWidget *widget) -{ - GTK_CONTAINER_CLASS (gtk_handle_box_parent_class)->remove (container, widget); - - gtk_handle_box_reattach (GTK_HANDLE_BOX (container)); -} - -static gint -gtk_handle_box_delete_event (GtkWidget *widget, - GdkEventAny *event) -{ - GtkHandleBox *hb = GTK_HANDLE_BOX (widget); - GtkHandleBoxPrivate *priv = hb->priv; - - if (event->window == priv->float_window) - { - gtk_handle_box_reattach (hb); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_handle_box_reattach (GtkHandleBox *hb) -{ - GtkHandleBoxPrivate *priv = hb->priv; - GtkWidget *child; - GtkWidget *widget = GTK_WIDGET (hb); - - if (priv->child_detached) - { - priv->child_detached = FALSE; - if (gtk_widget_get_realized (widget)) - { - gdk_window_hide (priv->float_window); - gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget), - 0, 0); - - child = gtk_bin_get_child (GTK_BIN (hb)); - if (child) - g_signal_emit (hb, - handle_box_signals[SIGNAL_CHILD_ATTACHED], - 0, - child); - - } - priv->float_window_mapped = FALSE; - } - if (priv->in_drag) - gtk_handle_box_end_drag (hb, GDK_CURRENT_TIME); - - gtk_widget_queue_resize (GTK_WIDGET (hb)); -} - -static void -gtk_handle_box_end_drag (GtkHandleBox *hb, - guint32 time) -{ - GtkHandleBoxPrivate *priv = hb->priv; - GtkWidget *invisible = gtk_handle_box_get_invisible (); - - priv->in_drag = FALSE; - - gtk_device_grab_remove (invisible, priv->grab_device); - gdk_device_ungrab (priv->grab_device, time); - g_signal_handlers_disconnect_by_func (invisible, - G_CALLBACK (gtk_handle_box_grab_event), - hb); - - priv->grab_device = NULL; -} diff --git a/gtk/deprecated/gtkhandlebox.h b/gtk/deprecated/gtkhandlebox.h deleted file mode 100644 index b63476ef9d..0000000000 --- a/gtk/deprecated/gtkhandlebox.h +++ /dev/null @@ -1,111 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * Copyright (C) 1998 Elliot Lee - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* The GtkHandleBox is to allow widgets to be dragged in and out of - * their parents. - */ - -#ifndef __GTK_HANDLE_BOX_H__ -#define __GTK_HANDLE_BOX_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_HANDLE_BOX (gtk_handle_box_get_type ()) -#define GTK_HANDLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HANDLE_BOX, GtkHandleBox)) -#define GTK_HANDLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HANDLE_BOX, GtkHandleBoxClass)) -#define GTK_IS_HANDLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HANDLE_BOX)) -#define GTK_IS_HANDLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HANDLE_BOX)) -#define GTK_HANDLE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HANDLE_BOX, GtkHandleBoxClass)) - -typedef struct _GtkHandleBox GtkHandleBox; -typedef struct _GtkHandleBoxPrivate GtkHandleBoxPrivate; -typedef struct _GtkHandleBoxClass GtkHandleBoxClass; - -struct _GtkHandleBox -{ - GtkBin bin; - - /*< private >*/ - GtkHandleBoxPrivate *priv; -}; - -/** - * GtkHandleBoxClass: - * @parent_class: The parent class. - * @child_attached: Signal emitted when the contents of the handlebox - * are reattached to the main window. Deprecated: 3.4. - * @child_detached: Signal emitted when the contents of the handlebox - * are detached from the main window. Deprecated: 3.4. - */ -struct _GtkHandleBoxClass -{ - GtkBinClass parent_class; - - void (*child_attached) (GtkHandleBox *handle_box, - GtkWidget *child); - void (*child_detached) (GtkHandleBox *handle_box, - GtkWidget *child); - - /*< private >*/ - - /* Padding for future expansion */ - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); - void (*_gtk_reserved4) (void); -}; - - -GDK_DEPRECATED_IN_3_4 -GType gtk_handle_box_get_type (void) G_GNUC_CONST; -GDK_DEPRECATED_IN_3_4 -GtkWidget* gtk_handle_box_new (void); -GDK_DEPRECATED_IN_3_4 -void gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box, - GtkShadowType type); -GDK_DEPRECATED_IN_3_4 -GtkShadowType gtk_handle_box_get_shadow_type (GtkHandleBox *handle_box); -GDK_DEPRECATED_IN_3_4 -void gtk_handle_box_set_handle_position (GtkHandleBox *handle_box, - GtkPositionType position); -GDK_DEPRECATED_IN_3_4 -GtkPositionType gtk_handle_box_get_handle_position(GtkHandleBox *handle_box); -GDK_DEPRECATED_IN_3_4 -void gtk_handle_box_set_snap_edge (GtkHandleBox *handle_box, - GtkPositionType edge); -GDK_DEPRECATED_IN_3_4 -GtkPositionType gtk_handle_box_get_snap_edge (GtkHandleBox *handle_box); -GDK_DEPRECATED_IN_3_4 -gboolean gtk_handle_box_get_child_detached (GtkHandleBox *handle_box); - -G_END_DECLS - -#endif /* __GTK_HANDLE_BOX_H__ */ diff --git a/gtk/deprecated/gtkmisc.c b/gtk/deprecated/gtkmisc.c index 8ad92f09ab..2cab744fff 100644 --- a/gtk/deprecated/gtkmisc.c +++ b/gtk/deprecated/gtkmisc.c @@ -439,9 +439,8 @@ gtk_misc_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); diff --git a/gtk/gtk.h b/gtk/gtk.h index a858454038..7cc03bfc2f 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -253,7 +253,6 @@ #include #include #include -#include #include #include #include diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index e08907cd3a..b90cadca84 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1840,22 +1840,16 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, if (!info->icon_window) { GdkScreen *screen; - GdkVisual *visual; - gboolean has_rgba; screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); - visual = gdk_screen_get_rgba_visual (screen); - has_rgba = visual != NULL && gdk_screen_is_composited (screen); info->icon_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_WINDOW_TYPE_HINT_DND); gtk_window_set_screen (GTK_WINDOW (info->icon_window), screen); gtk_widget_set_size_request (info->icon_window, 24, 24); - if (visual) - gtk_widget_set_visual (info->icon_window, visual); gtk_widget_set_events (info->icon_window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - if (has_rgba) + if (gdk_screen_is_composited (screen)) gtk_widget_set_app_paintable (info->icon_window, TRUE); gtk_window_set_hardcoded_window (GTK_WINDOW (info->icon_window), @@ -2077,8 +2071,6 @@ gtk_drag_set_icon_surface (GdkDragContext *context, GdkScreen *screen; GdkRectangle extents; cairo_pattern_t *pattern; - GdkVisual *rgba_visual; - gboolean has_rgba; cairo_matrix_t matrix; g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); @@ -2087,16 +2079,11 @@ gtk_drag_set_icon_surface (GdkDragContext *context, _gtk_cairo_surface_extents (surface, &extents); screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); - rgba_visual = gdk_screen_get_rgba_visual (screen); window = gtk_window_new (GTK_WINDOW_POPUP); - has_rgba = rgba_visual != NULL && gdk_screen_is_composited (screen); gtk_window_set_screen (GTK_WINDOW (window), screen); - if (has_rgba) - gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual); - gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND); gtk_widget_set_events (window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); @@ -2111,8 +2098,8 @@ gtk_drag_set_icon_surface (GdkDragContext *context, g_signal_connect_data (window, "draw", - has_rgba ? G_CALLBACK (gtk_drag_draw_icon_pattern) - : G_CALLBACK (gtk_drag_draw_icon_pattern_and_background), + gdk_screen_is_composited (screen) ? G_CALLBACK (gtk_drag_draw_icon_pattern) + : G_CALLBACK (gtk_drag_draw_icon_pattern_and_background), pattern, (GClosureNotify) cairo_pattern_destroy, G_CONNECT_AFTER); diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c index 261bf34479..16f8f3befd 100644 --- a/gtk/gtkdrawingarea.c +++ b/gtk/gtkdrawingarea.c @@ -208,10 +208,9 @@ gtk_drawing_area_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 288b5fffb3..dc06847ac9 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -418,10 +418,9 @@ gtk_event_box_realize (GtkWidget *widget) visible_window = gtk_widget_get_has_window (widget); if (visible_window) { - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 79d00cdfa6..097676d14e 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -393,11 +393,10 @@ gtk_fixed_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 091c9a6bd2..54d89824a6 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -1314,10 +1314,9 @@ gtk_icon_view_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 26b74f2981..7402651b26 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -899,10 +899,9 @@ gtk_layout_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 3e10e760a8..0143b3b2af 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -2733,12 +2733,11 @@ gtk_menu_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index e15102ac32..c284c6ad7b 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -598,7 +598,6 @@ gtk_menu_shell_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -607,7 +606,7 @@ gtk_menu_shell_realize (GtkWidget *widget) GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 29e5b315ed..64509438ac 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2952,9 +2952,8 @@ show_drag_window (GtkNotebook *notebook, attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c index a07c7f67f2..ec2594c7fb 100644 --- a/gtk/gtkoffscreenwindow.c +++ b/gtk/gtkoffscreenwindow.c @@ -175,10 +175,9 @@ gtk_offscreen_window_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_OFFSCREEN; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index 0af10a5c34..29fc355cba 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -149,8 +149,7 @@ gtk_overlay_create_child_window (GtkOverlay *overlay, attributes.height = allocation.height; attributes.x = allocation.x; attributes.y = allocation.y; - attributes.visual = gtk_widget_get_visual (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; attributes.event_mask = gtk_widget_get_events (widget); window = gdk_window_new (gtk_widget_get_window (widget), diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index cbe65e9e7c..c6aafd2db0 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -1614,7 +1614,6 @@ gtk_paned_create_child_window (GtkPaned *paned, attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events (widget); - attributes.visual = gtk_widget_get_visual (widget); if (child) { GtkAllocation allocation; @@ -1643,13 +1642,13 @@ gtk_paned_create_child_window (GtkPaned *paned, gtk_widget_get_allocation (child, &allocation); attributes.width = allocation.width; attributes.height = allocation.height; - attributes_mask = GDK_WA_X | GDK_WA_Y| GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; } else { attributes.width = 1; attributes.height = 1; - attributes_mask = GDK_WA_VISUAL; + attributes_mask = 0; } window = gdk_window_new (gtk_widget_get_window (widget), diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index abfb90f0b2..5570931277 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -399,7 +399,6 @@ gtk_popover_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = gtk_widget_get_events (widget) | @@ -410,7 +409,7 @@ gtk_popover_realize (GtkWidget *widget) GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c index b23f66a7e1..2e3d34fc6b 100644 --- a/gtk/gtkrevealer.c +++ b/gtk/gtkrevealer.c @@ -365,10 +365,9 @@ gtk_revealer_real_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); - attributes_mask = (GDK_WA_X | GDK_WA_Y) | GDK_WA_VISUAL; + attributes_mask = (GDK_WA_X | GDK_WA_Y); priv->view_window = gdk_window_new (gtk_widget_get_parent_window ((GtkWidget*) revealer), diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 3392475448..a44d4fa091 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -4170,8 +4170,7 @@ create_indicator_window (GtkScrolledWindow *scrolled_window, attributes.height = allocation.height; attributes.x = allocation.x; attributes.y = allocation.y; - attributes.visual = gtk_widget_get_visual (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; attributes.event_mask = gtk_widget_get_events (widget); window = gdk_window_new (gtk_widget_get_window (widget), @@ -4443,8 +4442,7 @@ gtk_scrolled_window_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.x = allocation.x; attributes.y = allocation.y; - attributes.visual = gtk_widget_get_visual (widget); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; attributes.event_mask = gtk_widget_get_events (widget) | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c index 211143954b..228d90fb0a 100644 --- a/gtk/gtkseparatortoolitem.c +++ b/gtk/gtkseparatortoolitem.c @@ -295,7 +295,6 @@ gtk_separator_tool_item_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_ONLY; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 9e5e4c7849..a3caec71be 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -977,13 +977,12 @@ gtk_spin_button_realize (GtkWidget *widget) attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_ONLY; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; gtk_css_gadget_get_border_allocation (priv->up_button, &up_allocation, NULL); gtk_css_gadget_get_border_allocation (priv->down_button, &down_allocation, NULL); diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index 22e19a6bfa..ca3e4e43e1 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -351,10 +351,9 @@ gtk_stack_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget); - attributes_mask = (GDK_WA_X | GDK_WA_Y) | GDK_WA_VISUAL; + attributes_mask = (GDK_WA_X | GDK_WA_Y); priv->view_window = gdk_window_new (gtk_widget_get_window (GTK_WIDGET (stack)), diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 01b60e5245..f6be78bfe8 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -4686,10 +4686,9 @@ gtk_text_view_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); @@ -9944,10 +9943,9 @@ text_window_realize (GtkTextWindow *win, attributes.width = win->allocation.width; attributes.height = win->allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (win->widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gtk_widget_get_window (widget); diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c index c4dbbcbbe5..38fedeb4d2 100644 --- a/gtk/gtktoolitemgroup.c +++ b/gtk/gtktoolitemgroup.c @@ -1255,12 +1255,11 @@ gtk_tool_item_group_realize (GtkWidget *widget) attributes.width = allocation.width - border_width * 2; attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_VISIBILITY_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index 83f8e489de..a5258233c5 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -730,14 +730,13 @@ gtk_tool_palette_realize (GtkWidget *widget) attributes.width = allocation.width - border_width * 2; attributes.height = allocation.height - border_width * 2; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_VISIBILITY_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 73d355798e..fa82973ef9 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -2434,10 +2434,9 @@ gtk_tree_view_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); @@ -4046,9 +4045,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) gtk_widget_get_allocation (button, &drag_allocation); width = attributes.width = drag_allocation.width; height = attributes.height = drag_allocation.height; - attributes.visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; tree_view->priv->drag_highlight_window = gdk_window_new (tree_view->priv->header_window, &attributes, attributes_mask); gtk_widget_register_window (GTK_WIDGET (tree_view), tree_view->priv->drag_highlight_window); @@ -4092,9 +4090,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) attributes.window_type = GDK_WINDOW_TEMP; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view)); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; attributes.x = x; attributes.y = y; attributes.width = width; @@ -4173,9 +4170,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) attributes.window_type = GDK_WINDOW_TEMP; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view)); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; attributes.x = x; attributes.y = y; attributes.width = width; @@ -10068,9 +10064,8 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view, attributes.y = 0; attributes.width = button_allocation.width; attributes.height = button_allocation.height; - attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view)); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_POINTER_MOTION_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; tree_view->priv->drag_window = gdk_window_new (tree_view->priv->header_window, &attributes, diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index fff7ce7ef6..e61e392073 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -1329,7 +1329,6 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column) attr.window_type = GDK_WINDOW_CHILD; attr.wclass = GDK_INPUT_ONLY; - attr.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view)); attr.event_mask = gtk_widget_get_events (GTK_WIDGET (tree_view)) | (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index a5487ffc70..1f7b4949e8 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -850,13 +850,12 @@ gtk_viewport_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); event_mask = gtk_widget_get_events (widget); attributes.event_mask = event_mask | GDK_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SMOOTH_SCROLL_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 932bea4484..d50a77c581 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -828,7 +828,6 @@ static GQuark quark_pango_context = 0; static GQuark quark_mnemonic_labels = 0; static GQuark quark_tooltip_markup = 0; static GQuark quark_tooltip_window = 0; -static GQuark quark_visual = 0; static GQuark quark_modifier_style = 0; static GQuark quark_enabled_devices = 0; static GQuark quark_size_groups = 0; @@ -997,7 +996,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels"); quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup"); quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window"); - quark_visual = g_quark_from_static_string ("gtk-widget-visual"); quark_modifier_style = g_quark_from_static_string ("gtk-widget-modifier-style"); quark_enabled_devices = g_quark_from_static_string ("gtk-widget-enabled-devices"); quark_size_groups = g_quark_from_static_string ("gtk-widget-size-groups"); @@ -6990,9 +6988,7 @@ gtk_widget_draw_internal (GtkWidget *widget, } push_group = - widget->priv->alpha != 255 && - (!_gtk_widget_is_toplevel (widget) || - gtk_widget_get_visual (widget) == gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget))); + widget->priv->alpha != 255 && !_gtk_widget_is_toplevel (widget); if (push_group) cairo_push_group (cr); @@ -11512,74 +11508,6 @@ gtk_widget_get_ancestor (GtkWidget *widget, return widget; } -/** - * gtk_widget_set_visual: - * @widget: a #GtkWidget - * @visual: (allow-none): visual to be used or %NULL to unset a previous one - * - * Sets the visual that should be used for by widget and its children for - * creating #GdkWindows. The visual must be on the same #GdkScreen as - * returned by gtk_widget_get_screen(), so handling the - * #GtkWidget::screen-changed signal is necessary. - * - * Setting a new @visual will not cause @widget to recreate its windows, - * so you should call this function before @widget is realized. - **/ -void -gtk_widget_set_visual (GtkWidget *widget, - GdkVisual *visual) -{ - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (visual == NULL || GDK_IS_VISUAL (visual)); - - if (visual) - g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual)); - - g_object_set_qdata_full (G_OBJECT (widget), - quark_visual, - visual ? g_object_ref (visual) : NULL, - g_object_unref); -} - -/** - * gtk_widget_get_visual: - * @widget: a #GtkWidget - * - * Gets the visual that will be used to render @widget. - * - * Returns: (transfer none): the visual for @widget - **/ -GdkVisual* -gtk_widget_get_visual (GtkWidget *widget) -{ - GtkWidget *w; - GdkVisual *visual; - GdkScreen *screen; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - if (!_gtk_widget_get_has_window (widget) && - widget->priv->window) - return gdk_window_get_visual (widget->priv->window); - - screen = gtk_widget_get_screen (widget); - - for (w = widget; w != NULL; w = w->priv->parent) - { - visual = g_object_get_qdata (G_OBJECT (w), quark_visual); - if (visual) - { - if (gdk_visual_get_screen (visual) == screen) - return visual; - - g_warning ("Ignoring visual set on widget '%s' that is not on the correct screen.", - gtk_widget_get_name (widget)); - } - } - - return gdk_screen_get_system_visual (screen); -} - /** * gtk_widget_get_settings: * @widget: a #GtkWidget @@ -15959,8 +15887,7 @@ gtk_widget_update_alpha (GtkWidget *widget) if (_gtk_widget_get_realized (widget)) { - if (_gtk_widget_is_toplevel (widget) && - gtk_widget_get_visual (widget) != gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget))) + if (_gtk_widget_is_toplevel (widget)) gdk_window_set_opacity (priv->window, priv->alpha / 255.0); gtk_widget_queue_draw (widget); diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index aacfc94bb0..65a832d858 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -998,11 +998,6 @@ GtkWidget* gtk_widget_get_toplevel (GtkWidget *widget); GDK_AVAILABLE_IN_ALL GtkWidget* gtk_widget_get_ancestor (GtkWidget *widget, GType widget_type); -GDK_AVAILABLE_IN_ALL -GdkVisual* gtk_widget_get_visual (GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_widget_set_visual (GtkWidget *widget, - GdkVisual *visual); GDK_AVAILABLE_IN_ALL GdkScreen * gtk_widget_get_screen (GtkWidget *widget); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 600951b3aa..a943b4ac5d 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4017,15 +4017,10 @@ gtk_window_enable_csd (GtkWindow *window) { GtkWindowPrivate *priv = window->priv; GtkWidget *widget = GTK_WIDGET (window); - GdkVisual *visual; /* We need a visual with alpha for client shadows */ if (priv->use_client_shadow) { - visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)); - if (visual != NULL) - gtk_widget_set_visual (widget, visual); - gtk_style_context_add_class (gtk_widget_get_style_context (widget), GTK_STYLE_CLASS_CSD); } else @@ -6483,10 +6478,9 @@ popover_realize (GtkWidget *widget, attributes.y = rect.y; attributes.width = rect.width; attributes.height = rect.height; - attributes.visual = gtk_widget_get_visual (GTK_WIDGET (window)); attributes.event_mask = gtk_widget_get_events (popover->widget) | GDK_EXPOSURE_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; popover->window = gdk_window_new (parent_window, &attributes, attributes_mask); gtk_widget_register_window (GTK_WIDGET (window), popover->window); @@ -7005,10 +6999,9 @@ gtk_window_realize (GtkWidget *widget) 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; + attributes_mask = GDK_WA_X | GDK_WA_Y; gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); @@ -7080,7 +7073,6 @@ gtk_window_realize (GtkWidget *widget) attributes.title = priv->title; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes_mask = 0; parent_window = gdk_screen_get_root_window (_gtk_window_get_screen (window)); @@ -7105,7 +7097,7 @@ gtk_window_realize (GtkWidget *widget) attributes.type_hint = priv->type_hint; - attributes_mask |= GDK_WA_VISUAL | GDK_WA_TYPE_HINT; + attributes_mask |= GDK_WA_TYPE_HINT; attributes_mask |= (priv->title ? GDK_WA_TITLE : 0); gdk_window = gdk_window_new (parent_window, &attributes, attributes_mask); @@ -7123,10 +7115,9 @@ gtk_window_realize (GtkWidget *widget) 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; + attributes_mask = GDK_WA_X | GDK_WA_Y; if (priv->client_decorated && priv->type == GTK_WINDOW_TOPLEVEL) { @@ -10595,7 +10586,6 @@ gtk_window_set_screen (GtkWindow *window, GtkWindowPrivate *priv; GtkWidget *widget; GdkScreen *previous_screen; - gboolean was_rgba; gboolean was_mapped; g_return_if_fail (GTK_IS_WINDOW (window)); @@ -10613,11 +10603,6 @@ gtk_window_set_screen (GtkWindow *window, previous_screen = priv->screen; - if (gdk_screen_get_rgba_visual (previous_screen) == gtk_widget_get_visual (widget)) - was_rgba = TRUE; - else - was_rgba = FALSE; - was_mapped = _gtk_widget_get_mapped (widget); if (was_mapped) @@ -10651,15 +10636,6 @@ gtk_window_set_screen (GtkWindow *window, } g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_SCREEN]); - if (was_rgba && priv->use_client_shadow) - { - GdkVisual *visual; - - visual = gdk_screen_get_rgba_visual (screen); - if (visual) - gtk_widget_set_visual (widget, visual); - } - if (was_mapped) gtk_widget_map (widget); diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c index 3a1eb03815..e8c55909fe 100644 --- a/gtk/inspector/inspect-button.c +++ b/gtk/inspector/inspect-button.c @@ -278,8 +278,7 @@ deemphasize_window (GtkWidget *window) GdkScreen *screen; screen = gtk_widget_get_screen (window); - if (gdk_screen_is_composited (screen) && - gtk_widget_get_visual (window) == gdk_screen_get_rgba_visual (screen)) + if (gdk_screen_is_composited (screen)) { cairo_rectangle_int_t rect; cairo_region_t *region; @@ -300,8 +299,7 @@ reemphasize_window (GtkWidget *window) GdkScreen *screen; screen = gtk_widget_get_screen (window); - if (gdk_screen_is_composited (screen) && - gtk_widget_get_visual (window) == gdk_screen_get_rgba_visual (screen)) + if (gdk_screen_is_composited (screen)) { gtk_widget_set_opacity (window, 1.0); gtk_widget_input_shape_combine_region (window, NULL); diff --git a/tests/gtkoffscreenbox.c b/tests/gtkoffscreenbox.c index 5f474ace7f..610ddd850c 100644 --- a/tests/gtkoffscreenbox.c +++ b/tests/gtkoffscreenbox.c @@ -279,10 +279,9 @@ gtk_offscreen_box_realize (GtkWidget *widget) | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; - attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/tests/subsurface.c b/tests/subsurface.c index 9f8f9c41ea..ce467ea46c 100644 --- a/tests/subsurface.c +++ b/tests/subsurface.c @@ -52,10 +52,9 @@ da_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; + attributes_mask = GDK_WA_X | GDK_WA_Y; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); diff --git a/tests/testgtk.c b/tests/testgtk.c index 9b8149a4a5..7becaae833 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -226,27 +226,6 @@ build_alpha_widgets (void) return grid; } -static void -on_alpha_screen_changed (GtkWindow *window, - GdkScreen *old_screen, - GtkWidget *label) -{ - GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window)); - GdkVisual *visual = gdk_screen_get_rgba_visual (screen); - - if (!visual) - { - visual = gdk_screen_get_system_visual (screen); - gtk_label_set_markup (GTK_LABEL (label), "Screen doesn't support alpha"); - } - else - { - gtk_label_set_markup (GTK_LABEL (label), "Screen supports alpha"); - } - - gtk_widget_set_visual (GTK_WIDGET (window), visual); -} - static void on_composited_changed (GtkWidget *window, GtkLabel *label) @@ -288,9 +267,6 @@ create_alpha_window (GtkWidget *widget) label = gtk_label_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - on_alpha_screen_changed (GTK_WINDOW (window), NULL, label); - g_signal_connect (window, "screen-changed", - G_CALLBACK (on_alpha_screen_changed), label); label = gtk_label_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); @@ -366,10 +342,9 @@ create_pattern (GtkWidget *widget, attributes.height = h; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = GDK_EXPOSURE_MASK; - attributes.visual = gtk_widget_get_visual (widget); child = gdk_window_new (parent, &attributes, - GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL); + GDK_WA_X | GDK_WA_Y); pattern_set_bg (widget, child, level);