Patch by: Iain Holmes <iain@gnome.org>
2007-10-26 Jens Granseuer <jensgr@gmx.net> Patch by: Iain Holmes <iain@gnome.org> * gsd-media-keys-window.c: (fade_timeout), (hide_timeout), (remove_hide_timeout), (add_hide_timeout), (on_expose_event), (gsd_media_keys_window_init): gradually fade out the OSD when composited (bug #490593) svn path=/trunk/; revision=8207
This commit is contained in:
parent
2c5faa6828
commit
c9c114f388
2 changed files with 71 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-10-26 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
Patch by: Iain Holmes <iain@gnome.org>
|
||||||
|
|
||||||
|
* gsd-media-keys-window.c: (fade_timeout), (hide_timeout),
|
||||||
|
(remove_hide_timeout), (add_hide_timeout), (on_expose_event),
|
||||||
|
(gsd_media_keys_window_init): gradually fade out the OSD when composited
|
||||||
|
(bug #490593)
|
||||||
|
|
||||||
2007-10-16 Sergey Udaltsov <svu@gnome.org>
|
2007-10-16 Sergey Udaltsov <svu@gnome.org>
|
||||||
|
|
||||||
* gnome-settings-keyboard-xkb.c: no more "configuration changed"
|
* gnome-settings-keyboard-xkb.c: no more "configuration changed"
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include "gsd-media-keys-window.h"
|
#include "gsd-media-keys-window.h"
|
||||||
|
|
||||||
#define DIALOG_TIMEOUT 2000 /* dialog timeout in ms */
|
#define DIALOG_TIMEOUT 2000 /* dialog timeout in ms */
|
||||||
|
#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
|
||||||
|
#define FADE_TIMEOUT 10 /* timeout in ms between each frame of the fade */
|
||||||
|
|
||||||
#define BG_ALPHA 0.50
|
#define BG_ALPHA 0.50
|
||||||
#define FG_ALPHA 1.00
|
#define FG_ALPHA 1.00
|
||||||
|
@ -46,6 +48,8 @@ struct GsdMediaKeysWindowPrivate
|
||||||
{
|
{
|
||||||
guint is_composited : 1;
|
guint is_composited : 1;
|
||||||
guint hide_timeout_id;
|
guint hide_timeout_id;
|
||||||
|
guint fade_timeout_id;
|
||||||
|
double fade_out_alpha;
|
||||||
GsdMediaKeysWindowAction action;
|
GsdMediaKeysWindowAction action;
|
||||||
|
|
||||||
guint volume_muted : 1;
|
guint volume_muted : 1;
|
||||||
|
@ -56,10 +60,45 @@ struct GsdMediaKeysWindowPrivate
|
||||||
|
|
||||||
G_DEFINE_TYPE (GsdMediaKeysWindow, gsd_media_keys_window, GTK_TYPE_WINDOW)
|
G_DEFINE_TYPE (GsdMediaKeysWindow, gsd_media_keys_window, GTK_TYPE_WINDOW)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fade_timeout (GsdMediaKeysWindow *window)
|
||||||
|
{
|
||||||
|
if (window->priv->fade_out_alpha <= 0.0) {
|
||||||
|
gtk_widget_hide (GTK_WIDGET (window));
|
||||||
|
|
||||||
|
/* Reset it for the next time */
|
||||||
|
window->priv->fade_out_alpha = 1.0;
|
||||||
|
window->priv->fade_timeout_id = 0;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
GdkRectangle rect;
|
||||||
|
GtkWidget *win = GTK_WIDGET (window);
|
||||||
|
|
||||||
|
window->priv->fade_out_alpha -= 0.10;
|
||||||
|
|
||||||
|
rect.x = 0;
|
||||||
|
rect.y = 0;
|
||||||
|
rect.width = win->allocation.width;
|
||||||
|
rect.height = win->allocation.height;
|
||||||
|
|
||||||
|
gdk_window_invalidate_rect (win->window, &rect, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
hide_timeout (GsdMediaKeysWindow *window)
|
hide_timeout (GsdMediaKeysWindow *window)
|
||||||
{
|
{
|
||||||
|
if (window->priv->is_composited) {
|
||||||
|
window->priv->hide_timeout_id = 0;
|
||||||
|
window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
|
||||||
|
(GSourceFunc) fade_timeout,
|
||||||
|
window);
|
||||||
|
} else {
|
||||||
gtk_widget_hide (GTK_WIDGET (window));
|
gtk_widget_hide (GTK_WIDGET (window));
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -71,13 +110,25 @@ remove_hide_timeout (GsdMediaKeysWindow *window)
|
||||||
g_source_remove (window->priv->hide_timeout_id);
|
g_source_remove (window->priv->hide_timeout_id);
|
||||||
window->priv->hide_timeout_id = 0;
|
window->priv->hide_timeout_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->priv->fade_timeout_id != 0) {
|
||||||
|
g_source_remove (window->priv->fade_timeout_id);
|
||||||
|
window->priv->fade_timeout_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_hide_timeout (GsdMediaKeysWindow *window)
|
add_hide_timeout (GsdMediaKeysWindow *window)
|
||||||
{
|
{
|
||||||
window->priv->hide_timeout_id = g_timeout_add (DIALOG_TIMEOUT,
|
int timeout;
|
||||||
(GSourceFunc)hide_timeout,
|
|
||||||
|
if (window->priv->is_composited) {
|
||||||
|
timeout = DIALOG_FADE_TIMEOUT;
|
||||||
|
} else {
|
||||||
|
timeout = DIALOG_TIMEOUT;
|
||||||
|
}
|
||||||
|
window->priv->hide_timeout_id = g_timeout_add (timeout,
|
||||||
|
(GSourceFunc) hide_timeout,
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,8 +808,13 @@ on_expose_event (GtkWidget *widget,
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
/* Make sure we have a transparent background */
|
||||||
|
cairo_rectangle (context, 0, 0, width, height);
|
||||||
|
cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
|
||||||
|
cairo_fill (context);
|
||||||
|
|
||||||
cairo_set_source_surface (context, surface, 0, 0);
|
cairo_set_source_surface (context, surface, 0, 0);
|
||||||
cairo_paint (context);
|
cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (surface != NULL) {
|
if (surface != NULL) {
|
||||||
|
@ -851,6 +907,8 @@ gsd_media_keys_window_init (GsdMediaKeysWindow *window)
|
||||||
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
||||||
g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event), window);
|
g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event), window);
|
||||||
|
|
||||||
|
window->priv->fade_out_alpha = 1.0;
|
||||||
} else {
|
} else {
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue