forked from AuroraMiddleware/gtk
iconhelper: Get rid of _gtk_icon_helper_set_window()
Instead use the window of the owner widget.
This commit is contained in:
parent
c9d1a45d30
commit
e95e2d5048
@ -593,8 +593,6 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
|
||||
if (icon_helper == NULL)
|
||||
icon_helper = create_icon_helper (cellpixbuf, widget);
|
||||
|
||||
_gtk_icon_helper_set_window (icon_helper,
|
||||
gtk_widget_get_window (widget));
|
||||
_gtk_icon_helper_draw (icon_helper,
|
||||
context, cr,
|
||||
pix_rect.x, pix_rect.y);
|
||||
|
@ -3134,10 +3134,6 @@ realize_icon_info (GtkWidget *widget,
|
||||
gtk_widget_register_window (widget, icon_info->window);
|
||||
|
||||
gtk_widget_queue_resize (widget);
|
||||
|
||||
_gtk_icon_helper_set_window (icon_info->icon_helper,
|
||||
gtk_widget_get_window (widget));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3439,8 +3435,6 @@ gtk_entry_unrealize (GtkWidget *widget)
|
||||
{
|
||||
if ((icon_info = priv->icons[i]) != NULL)
|
||||
{
|
||||
_gtk_icon_helper_set_window (icon_info->icon_helper, NULL);
|
||||
|
||||
if (icon_info->window != NULL)
|
||||
{
|
||||
gtk_widget_unregister_window (widget, icon_info->window);
|
||||
|
@ -67,7 +67,6 @@ gtk_icon_helper_take_definition (GtkIconHelper *self,
|
||||
void
|
||||
_gtk_icon_helper_clear (GtkIconHelper *self)
|
||||
{
|
||||
g_clear_object (&self->priv->window);
|
||||
g_clear_pointer (&self->priv->rendered_surface, cairo_surface_destroy);
|
||||
|
||||
gtk_image_definition_unref (self->priv->def);
|
||||
@ -87,17 +86,6 @@ _gtk_icon_helper_invalidate (GtkIconHelper *self)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_helper_set_window (GtkIconHelper *self,
|
||||
GdkWindow *window)
|
||||
{
|
||||
if (window)
|
||||
g_object_ref (window);
|
||||
g_clear_object (&self->priv->window);
|
||||
self->priv->window = window;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_helper_finalize (GObject *object)
|
||||
{
|
||||
@ -223,30 +211,13 @@ get_surface_size (GtkIconHelper *self,
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static gint
|
||||
get_scale_factor (GtkIconHelper *self,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
|
||||
if (self->priv->window)
|
||||
return gdk_window_get_scale_factor (self->priv->window);
|
||||
|
||||
screen = gtk_style_context_get_screen (context);
|
||||
|
||||
/* else fall back to something that is more likely to be right than
|
||||
* just returning 1:
|
||||
*/
|
||||
return gdk_screen_get_monitor_scale_factor (screen, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_invalidate_surface (GtkIconHelper *self,
|
||||
GtkStyleContext *context)
|
||||
{
|
||||
int scale;
|
||||
|
||||
scale = get_scale_factor (self, context);
|
||||
scale = gtk_widget_get_scale_factor (self->priv->owner);
|
||||
|
||||
if ((self->priv->rendered_surface != NULL) &&
|
||||
(self->priv->last_surface_scale == scale))
|
||||
@ -341,7 +312,7 @@ ensure_surface_from_pixbuf (GtkIconHelper *self,
|
||||
else
|
||||
pixbuf = g_object_ref (orig_pixbuf);
|
||||
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, self->priv->window);
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window (self->priv->owner));
|
||||
icon_effect = _gtk_css_icon_effect_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_EFFECT));
|
||||
gtk_css_icon_effect_apply (icon_effect, surface);
|
||||
g_object_unref (pixbuf);
|
||||
@ -366,7 +337,7 @@ ensure_surface_for_icon_set (GtkIconHelper *self,
|
||||
scale);
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
|
||||
scale,
|
||||
self->priv->window);
|
||||
gtk_widget_get_window (self->priv->owner));
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return surface;
|
||||
@ -442,13 +413,13 @@ ensure_surface_for_gicon (GtkIconHelper *self,
|
||||
{
|
||||
GtkCssIconEffect icon_effect;
|
||||
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, self->priv->window);
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, gtk_widget_get_window (self->priv->owner));
|
||||
icon_effect = _gtk_css_icon_effect_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_EFFECT));
|
||||
gtk_css_icon_effect_apply (icon_effect, surface);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, self->priv->window);
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, gtk_widget_get_window (self->priv->owner));
|
||||
}
|
||||
g_object_unref (destination);
|
||||
|
||||
@ -546,7 +517,7 @@ gtk_icon_helper_ensure_surface (GtkIconHelper *self,
|
||||
if (!check_invalidate_surface (self, context))
|
||||
return;
|
||||
|
||||
scale = get_scale_factor (self, context);
|
||||
scale = gtk_widget_get_scale_factor (self->priv->owner);
|
||||
|
||||
self->priv->rendered_surface = gtk_icon_helper_load_surface (self, context, scale);
|
||||
}
|
||||
@ -575,7 +546,7 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||
|
||||
case GTK_IMAGE_PIXBUF:
|
||||
get_pixbuf_size (self,
|
||||
get_scale_factor (self, context),
|
||||
gtk_widget_get_scale_factor (self->priv->owner),
|
||||
gtk_image_definition_get_pixbuf (self->priv->def),
|
||||
gtk_image_definition_get_scale (self->priv->def),
|
||||
&width, &height, &scale);
|
||||
|
@ -71,8 +71,6 @@ GtkIconHelper *_gtk_icon_helper_new (GtkWidget *owner);
|
||||
|
||||
void _gtk_icon_helper_clear (GtkIconHelper *self);
|
||||
void _gtk_icon_helper_invalidate (GtkIconHelper *self);
|
||||
void _gtk_icon_helper_set_window (GtkIconHelper *self,
|
||||
GdkWindow *window);
|
||||
|
||||
gboolean _gtk_icon_helper_get_is_empty (GtkIconHelper *self);
|
||||
|
||||
|
@ -157,7 +157,6 @@ static gint gtk_image_draw (GtkWidget *widget,
|
||||
static void gtk_image_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation*allocation);
|
||||
static void gtk_image_unmap (GtkWidget *widget);
|
||||
static void gtk_image_realize (GtkWidget *widget);
|
||||
static void gtk_image_unrealize (GtkWidget *widget);
|
||||
static void gtk_image_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
@ -233,7 +232,6 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
widget_class->get_preferred_height_and_baseline_for_width = gtk_image_get_preferred_height_and_baseline_for_width;
|
||||
widget_class->size_allocate = gtk_image_size_allocate;
|
||||
widget_class->unmap = gtk_image_unmap;
|
||||
widget_class->realize = gtk_image_realize;
|
||||
widget_class->unrealize = gtk_image_unrealize;
|
||||
widget_class->style_updated = gtk_image_style_updated;
|
||||
widget_class->screen_changed = gtk_image_screen_changed;
|
||||
@ -1557,25 +1555,9 @@ gtk_image_unmap (GtkWidget *widget)
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = image->priv;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->realize (widget);
|
||||
|
||||
_gtk_icon_helper_set_window (priv->icon_helper,
|
||||
gtk_widget_get_window (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = image->priv;
|
||||
|
||||
_gtk_icon_helper_set_window (priv->icon_helper, NULL);
|
||||
gtk_image_reset_anim_iter (GTK_IMAGE (widget));
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget);
|
||||
|
@ -1100,7 +1100,6 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button,
|
||||
width = gdk_window_get_width (panel);
|
||||
|
||||
icon_helper = _gtk_icon_helper_new (widget);
|
||||
_gtk_icon_helper_set_window (icon_helper, panel);
|
||||
_gtk_icon_helper_set_use_fallback (icon_helper, TRUE);
|
||||
|
||||
if (panel == priv->down_panel)
|
||||
|
Loading…
Reference in New Issue
Block a user