[gnome-applets/wip/segeiger/window-picker-in-process: 6/8] windowpicker/task-item.c: Reorder and cleanup code in draw function
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/segeiger/window-picker-in-process: 6/8] windowpicker/task-item.c: Reorder and cleanup code in draw function
- Date: Wed, 10 Jun 2015 17:24:55 +0000 (UTC)
commit 8baf5706a1e2e0d11e952f97f4ba6fbf51a22b4f
Author: Sebastian Geiger <sbastig gmx net>
Date: Mon Jun 8 21:13:43 2015 +0200
windowpicker/task-item.c: Reorder and cleanup code in draw function
windowpicker/src/task-item.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/windowpicker/src/task-item.c b/windowpicker/src/task-item.c
index babae4d..ef7d12c 100644
--- a/windowpicker/src/task-item.c
+++ b/windowpicker/src/task-item.c
@@ -251,26 +251,17 @@ static gboolean task_item_draw (
TaskItem *item = TASK_ITEM (widget);
TaskItemPrivate *priv = item->priv;
g_return_val_if_fail (WNCK_IS_WINDOW (priv->window), FALSE);
+
cr = gdk_cairo_create (gtk_widget_get_window(widget));
GdkRectangle area;
GdkPixbuf *pbuf;
area = priv->area;
- pbuf = priv->pixbuf;
- gint size = MIN (area.height, area.width);
gboolean active = wnck_window_is_active (priv->window);
- /* load the GSettings key for gray icons */
- gboolean icons_greyscale = window_picker_applet_get_icons_greyscale (priv->windowPickerApplet);
gboolean attention = wnck_window_or_transient_needs_attention (priv->window);
- if (GDK_IS_PIXBUF (pbuf) &&
- gdk_pixbuf_get_width (pbuf) != size &&
- gdk_pixbuf_get_height (pbuf) != size)
- {
- g_object_unref (pbuf);
- pbuf = NULL;
- }
+
if (active) { /* paint frame around the icon */
- /* We add -1 for x to make it bigger to the left
- * and +1 for width to make it bigger at the right */
+ /* We add +1 for x and y, and reduce the height and width by -2 to avoid drawing outside the visible
area.
+ * This effectively shrinks the rectangle by one pixel on each side. */
cairo_rectangle (cr, area.x + 1, area.y + 1, area.width - 2, area.height - 2);
cairo_set_source_rgba (cr, .8, .8, .8, .2);
cairo_fill_preserve (cr);
@@ -296,9 +287,20 @@ static gboolean task_item_draw (
cairo_set_source (cr, glow_pattern);
cairo_paint (cr);
}
+ gint size = MIN (area.height, area.width) - 1;
+ pbuf = priv->pixbuf;
+ if (GDK_IS_PIXBUF (pbuf) &&
+ gdk_pixbuf_get_width (pbuf) != size &&
+ gdk_pixbuf_get_height (pbuf) != size)
+ {
+ g_object_unref (pbuf);
+ pbuf = NULL;
+ }
if (!pbuf) {
pbuf = priv->pixbuf = task_item_sized_pixbuf_for_window (item, priv->window, size);
}
+
+ gboolean icons_greyscale = window_picker_applet_get_icons_greyscale (priv->windowPickerApplet);
if (active || priv->mouse_over || attention || !icons_greyscale) {
gdk_cairo_set_source_pixbuf (
cr,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]