[cheese] Track flash opacity explicitly
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Track flash opacity explicitly
- Date: Sun, 20 Jul 2014 18:30:06 +0000 (UTC)
commit 1c40135ddbd7f99ec8a7f1eafb91889d83b0108a
Author: Benjamin Herr <ben 0x539 de>
Date: Sun Jul 20 02:30:46 2014 +0200
Track flash opacity explicitly
Retrieving the opacity of the flash, reducing it by an exponentially
small step, and setting it again does not always actually decrease the
widget's opacity, and so the fading does not actually terminate.
Incidentally, also unset the flash timeout tags to avoid calling
g_source_remove() spuriously.
https://bugzilla.gnome.org/show_bug.cgi?id=733433
libcheese/cheese-flash.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/libcheese/cheese-flash.c b/libcheese/cheese-flash.c
index a87602d..cec97a2 100644
--- a/libcheese/cheese-flash.c
+++ b/libcheese/cheese-flash.c
@@ -70,6 +70,7 @@ struct _CheeseFlashPrivate
GtkWidget *parent;
guint flash_timeout_tag;
guint fade_timeout_tag;
+ gdouble opacity;
};
G_DEFINE_TYPE_WITH_PRIVATE (CheeseFlash, cheese_flash, GTK_TYPE_WINDOW)
@@ -84,6 +85,7 @@ cheese_flash_init (CheeseFlash *self)
priv->flash_timeout_tag = 0;
priv->fade_timeout_tag = 0;
+ priv->opacity = 1.0;
/* make it so it doesn't look like a window on the desktop (+fullscreen) */
gtk_window_set_decorated (window, FALSE);
@@ -186,18 +188,26 @@ cheese_flash_class_init (CheeseFlashClass *klass)
static gboolean
cheese_flash_opacity_fade (gpointer data)
{
- GtkWidget *flash_window = GTK_WIDGET (data);
- gdouble opacity = gtk_widget_get_opacity (flash_window);
+ CheeseFlashPrivate *priv;
+ GtkWidget *flash_window;
+
+ flash_window = GTK_WIDGET (data);
+ priv = cheese_flash_get_instance_private (CHEESE_FLASH (data));
/* exponentially decrease */
- gtk_widget_set_opacity (flash_window, opacity * FLASH_FADE_FACTOR);
+ priv->opacity *= FLASH_FADE_FACTOR;
- if (opacity <= FLASH_LOW_THRESHOLD)
+ if (priv->opacity <= FLASH_LOW_THRESHOLD)
{
/* the flasher has finished when we reach the quit value */
gtk_widget_hide (flash_window);
+ priv->fade_timeout_tag = 0;
return G_SOURCE_REMOVE;
}
+ else
+ {
+ gtk_widget_set_opacity (flash_window, priv->opacity);
+ }
return G_SOURCE_CONTINUE;
}
@@ -225,6 +235,7 @@ cheese_flash_start_fade (gpointer data)
}
flash_priv->fade_timeout_tag = g_timeout_add (1000.0 / FLASH_ANIMATION_RATE, cheese_flash_opacity_fade,
data);
+ flash_priv->flash_timeout_tag = 0;
return G_SOURCE_REMOVE;
}
@@ -253,9 +264,18 @@ cheese_flash_fire (CheeseFlash *flash)
flash_window = GTK_WINDOW (flash);
if (flash_priv->flash_timeout_tag > 0)
+ {
g_source_remove (flash_priv->flash_timeout_tag);
+ flash_priv->flash_timeout_tag = 0;
+ }
+
if (flash_priv->fade_timeout_tag > 0)
+ {
g_source_remove (flash_priv->fade_timeout_tag);
+ flash_priv->fade_timeout_tag = 0;
+ }
+
+ flash_priv->opacity = 1.0;
parent = gtk_widget_get_toplevel (flash_priv->parent);
screen = gtk_widget_get_screen (parent);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]