[gnome-shell] Implement distinct 2-window and multi-window highlights



commit 51db34d22341b5533e9129f50d29232269b7ab4e
Author: Dan Winship <danw gnome org>
Date:   Thu Aug 13 10:10:50 2009 -0400

    Implement distinct 2-window and multi-window highlights

 js/ui/appDisplay.js |    2 +-
 src/shell-drawing.c |   44 ++++++++++++++++++++++++++++----------------
 src/shell-drawing.h |    2 +-
 3 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index cbc873d..906c45f 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -488,7 +488,7 @@ WellDisplayItem.prototype = {
             let glow = new Shell.DrawingArea({});
             glow.connect('redraw', Lang.bind(this, function (e, tex) {
                 Shell.draw_app_highlight(tex,
-                                         this._windows.length > 1,
+                                         this._windows.length,
                                          GLOW_COLOR.red / 255,
                                          GLOW_COLOR.green / 255,
                                          GLOW_COLOR.blue / 255,
diff --git a/src/shell-drawing.c b/src/shell-drawing.c
index 9271790..44eafd4 100644
--- a/src/shell-drawing.c
+++ b/src/shell-drawing.c
@@ -168,7 +168,7 @@ draw_glow (cairo_t *cr, double red, double green, double blue, double alpha)
 
 void
 shell_draw_app_highlight (ClutterCairoTexture *texture,
-                          gboolean             multi,
+                          int                  num_windows,
                           double               red,
                           double               green,
                           double               blue,
@@ -177,6 +177,8 @@ shell_draw_app_highlight (ClutterCairoTexture *texture,
   cairo_t *cr;
   guint width, height;
 
+  g_return_if_fail (num_windows > 0);
+
   clutter_cairo_texture_get_surface_size (texture, &width, &height);
 
   clutter_cairo_texture_clear (texture);
@@ -185,28 +187,38 @@ shell_draw_app_highlight (ClutterCairoTexture *texture,
   cairo_save (cr);
   cairo_translate (cr, width / 2.0, height / 2.0);
 
-  if (multi)
+  if (num_windows == 1)
     {
-      double scale;
+      cairo_scale (cr, width / 2.0, height / 2.0);
+      draw_glow (cr, red, green, blue, alpha);
+    }
+  else
+    {
+      int num_circles;
+      double scale, highlight_width;
+
+      num_circles = num_windows == 2 ? 2 : 3;
 
-      /* We draw three circles of radius 1, at 0.0, -1.8, and +1.8.
-       * Total width is therefore 1 + 1.8 + 1.8 + 1 = 5.6.
+      /* The circles will have radius 1.0 (diameter 2.0) and overlap
+       * by 0.2, so the total width of the highlight is:
        */
-      scale = MIN (height / 2.0, width / 5.6);
-      cairo_scale (cr, scale, scale);
+      highlight_width = 2.0 * num_circles - 0.2 * (num_circles - 1);
 
-      draw_glow (cr, red, green, blue, alpha);
+      scale = MIN (height / 2.0, width / highlight_width);
+      cairo_scale (cr, scale, scale);
 
-      cairo_translate (cr, -1.8, 0.0);
+      /* Leftmost circle first; its left side is at
+       * -highlight_width/2, so its center is that plus 1.
+       */
+      cairo_translate (cr, -highlight_width / 2.0 + 1.0, 0.0);
       draw_glow (cr, red, green, blue, alpha);
 
-      cairo_translate (cr, 3.6, 0.0);
-      draw_glow (cr, red, green, blue, alpha);
-    }
-  else
-    {
-      cairo_scale (cr, width / 2.0, height / 2.0);
-      draw_glow (cr, red, green, blue, alpha);
+      /* Remaining circles */
+      while (--num_circles)
+        {
+          cairo_translate (cr, 1.8, 0.0);
+          draw_glow (cr, red, green, blue, alpha);
+        }
     }
 
   cairo_restore (cr);
diff --git a/src/shell-drawing.h b/src/shell-drawing.h
index 0d73786..d462d41 100644
--- a/src/shell-drawing.h
+++ b/src/shell-drawing.h
@@ -18,7 +18,7 @@ void shell_draw_clock (ClutterCairoTexture *texture,
 	               int                  minute);
 
 void shell_draw_app_highlight (ClutterCairoTexture *texture,
-                               gboolean             multi,
+                               int                  num_windows,
                                double               red,
                                double               blue,
                                double               green,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]