[mutter] bell: add a composited flash-screen function



commit 3597035f679953596d966363d7fff95c41da3e0f
Author: Dan Winship <danw gnome org>
Date:   Fri Mar 18 09:36:28 2011 -0400

    bell: add a composited flash-screen function
    
    The old bell_flash_screen() has no effect when compositing. Add
    meta_compositor_flash_screen(), and use that instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=639765

 src/compositor/compositor.c |   44 +++++++++++++++++++++++++++++++++++++++++++
 src/core/bell.c             |   14 ++++++++++--
 src/meta/compositor.h       |    3 ++
 3 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 4617ed8..7498990 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1187,3 +1187,47 @@ meta_get_overlay_window (MetaScreen *screen)
 
   return info->output;
 }
+
+#define FLASH_TIME_MS 50
+
+static void
+flash_out_completed (ClutterAnimation *animation,
+                     ClutterActor     *flash)
+{
+  clutter_actor_destroy (flash);
+}
+
+static void
+flash_in_completed (ClutterAnimation *animation,
+                    ClutterActor     *flash)
+{
+  clutter_actor_animate (flash, CLUTTER_EASE_IN_QUAD,
+                         FLASH_TIME_MS,
+                         "opacity", 0,
+                         "signal-after::completed", flash_out_completed, flash,
+                         NULL);
+}
+
+void
+meta_compositor_flash_screen (MetaCompositor *compositor,
+                              MetaScreen     *screen)
+{
+  ClutterActor *stage;
+  ClutterActor *flash;
+  ClutterColor black = { 0, 0, 0, 255 };
+  gfloat width, height;
+
+  stage = meta_get_stage_for_screen (screen);
+  clutter_actor_get_size (stage, &width, &height);
+
+  flash = clutter_rectangle_new_with_color (&black);
+  clutter_actor_set_size (flash, width, height);
+  clutter_actor_set_opacity (flash, 0);
+  clutter_container_add_actor (CLUTTER_CONTAINER (stage), flash);
+
+  clutter_actor_animate (flash, CLUTTER_EASE_OUT_QUAD,
+                         FLASH_TIME_MS,
+                         "opacity", 192,
+                         "signal-after::completed", flash_in_completed, flash,
+                         NULL);
+}
diff --git a/src/core/bell.c b/src/core/bell.c
index 81103a4..8c7da04 100644
--- a/src/core/bell.c
+++ b/src/core/bell.c
@@ -149,7 +149,7 @@ bell_flash_screen (MetaDisplay *display,
 #ifdef HAVE_XKB
 static void
 bell_flash_fullscreen (MetaDisplay *display, 
-			    XkbAnyEvent *xkb_ev)
+                       XkbAnyEvent *xkb_ev)
 {
   XkbBellNotifyEvent *xkb_bell_ev = (XkbBellNotifyEvent *) xkb_ev;
   MetaScreen *screen;
@@ -159,7 +159,12 @@ bell_flash_fullscreen (MetaDisplay *display,
     {
       screen = meta_display_screen_for_xwindow (display, xkb_bell_ev->window);
       if (screen)
-	bell_flash_screen (display, screen);
+        {
+          if (display->compositor)
+            meta_compositor_flash_screen (display->compositor, screen);
+          else
+            bell_flash_screen (display, screen);
+        }
     }
   else 
     {
@@ -167,7 +172,10 @@ bell_flash_fullscreen (MetaDisplay *display,
       while (screen_list) 
 	{
 	  screen = (MetaScreen *) screen_list->data;
-	  bell_flash_screen (display, screen);
+          if (display->compositor)
+            meta_compositor_flash_screen (display->compositor, screen);
+          else
+            bell_flash_screen (display, screen);
 	  screen_list = screen_list->next;
 	}
     }
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index c36546b..f9a42b2 100644
--- a/src/meta/compositor.h
+++ b/src/meta/compositor.h
@@ -160,4 +160,7 @@ void meta_compositor_sync_screen_size          (MetaCompositor *compositor,
                                                 guint           width,
                                                 guint           height);
 
+void meta_compositor_flash_screen              (MetaCompositor *compositor,
+                                                MetaScreen     *screen);
+
 #endif /* META_COMPOSITOR_H */



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