[mutter] bell: Flash whole window if the window had no frame



commit 99bba9e56c825037a92c425535f1a1aaf82b30b0
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Mar 8 12:10:21 2016 +0800

    bell: Flash whole window if the window had no frame
    
    CSD X11 clients and Wayland clients don't have a window frame drawn by
    the compositor to flash. So instead of flashing the whole screen when
    configured to just flash the window, flash just the window region.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763284

 src/compositor/compositor-private.h |    3 ++
 src/compositor/compositor.c         |   42 +++++++++++++++++++++++++++++++++++
 src/core/bell.c                     |    9 ++++++-
 3 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 9e3e73d..65fcec2 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -60,4 +60,7 @@ void     meta_end_modal_for_plugin   (MetaCompositor   *compositor,
 gint64 meta_compositor_monotonic_time_to_server_time (MetaDisplay *display,
                                                       gint64       monotonic_time);
 
+void meta_compositor_flash_window (MetaCompositor *compositor,
+                                   MetaWindow     *window);
+
 #endif /* META_COMPOSITOR_PRIVATE_H */
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index e445a72..30504ac 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1249,6 +1249,48 @@ meta_compositor_flash_screen (MetaCompositor *compositor,
   clutter_actor_restore_easing_state (flash);
 }
 
+static void
+window_flash_out_completed (ClutterTimeline *timeline,
+                            gboolean         is_finished,
+                            gpointer         user_data)
+{
+  ClutterActor *flash = CLUTTER_ACTOR (user_data);
+  clutter_actor_destroy (flash);
+}
+
+void
+meta_compositor_flash_window (MetaCompositor *compositor,
+                              MetaWindow     *window)
+{
+  ClutterActor *window_actor =
+    CLUTTER_ACTOR (meta_window_get_compositor_private (window));
+  ClutterActor *flash;
+  ClutterTransition *transition;
+
+  flash = clutter_actor_new ();
+  clutter_actor_set_background_color (flash, CLUTTER_COLOR_Black);
+  clutter_actor_set_size (flash, window->rect.width, window->rect.height);
+  clutter_actor_set_position (flash,
+                              window->custom_frame_extents.left,
+                              window->custom_frame_extents.top);
+  clutter_actor_set_opacity (flash, 0);
+  clutter_actor_add_child (window_actor, flash);
+
+  clutter_actor_save_easing_state (flash);
+  clutter_actor_set_easing_mode (flash, CLUTTER_EASE_IN_QUAD);
+  clutter_actor_set_easing_duration (flash, FLASH_TIME_MS);
+  clutter_actor_set_opacity (flash, 192);
+
+  transition = clutter_actor_get_transition (flash, "opacity");
+  clutter_timeline_set_auto_reverse (CLUTTER_TIMELINE (transition), TRUE);
+  clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (transition), 2);
+
+  g_signal_connect (transition, "stopped",
+                    G_CALLBACK (window_flash_out_completed), flash);
+
+  clutter_actor_restore_easing_state (flash);
+}
+
 /**
  * meta_compositor_monotonic_time_to_server_time:
  * @display: a #MetaDisplay
diff --git a/src/core/bell.c b/src/core/bell.c
index 4ac30dc..1afbf0a 100644
--- a/src/core/bell.c
+++ b/src/core/bell.c
@@ -52,6 +52,7 @@
 #include "screen-private.h"
 #include "window-private.h"
 #include "util-private.h"
+#include "compositor/compositor-private.h"
 #include <meta/prefs.h>
 #include <meta/compositor.h>
 #ifdef HAVE_LIBCANBERRA
@@ -131,6 +132,12 @@ bell_flash_window_frame (MetaWindow *window)
   g_source_set_name_by_id (id, "[mutter] bell_unflash_frame");
 }
 
+static void
+bell_flash_window (MetaWindow *window)
+{
+  meta_compositor_flash_window (window->display->compositor, window);
+}
+
 /**
  * bell_flash_frame:
  * @display:  The display the bell event came in on
@@ -146,7 +153,7 @@ bell_flash_frame (MetaDisplay *display,
   if (window && window->frame)
     bell_flash_window_frame (window);
   else
-    bell_flash_fullscreen (display);
+    bell_flash_window (window);
 }
 
 /**


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