[PATCH v2 2/2] shell-animation: add conf option in shell

juan.j.zhao at linux.intel.com juan.j.zhao at linux.intel.com
Wed Apr 25 04:09:52 PDT 2012


From: Juan Zhao <juan.j.zhao at intel.com>

Now we can choose zoom or fade in weston.ini
to fulfill and customize the user experence easier.

Signed-off-by: Juan Zhao <juan.j.zhao at intel.com>
---
 src/compositor.h |    8 ++++++++
 src/shell.c      |   38 +++++++++++++++++++++++++++++++++++++-
 weston.ini       |    2 ++
 3 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 5cf4285..3722d32 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -594,6 +594,14 @@ struct weston_zoom *
 weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
 		weston_zoom_done_func_t done, void *data);
 
+struct weston_fade;
+typedef	void (*weston_fade_done_func_t)(struct weston_fade *fade, void *data);
+
+struct weston_fade *
+weston_fade_run(struct weston_surface *surface,
+		weston_fade_done_func_t done, void *data);
+
+
 void
 weston_surface_set_color(struct weston_surface *surface,
 			 GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
diff --git a/src/shell.c b/src/shell.c
index fd66462..9c844b5 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -36,6 +36,13 @@
 #include "desktop-shell-server-protocol.h"
 #include "../shared/config-parser.h"
 
+enum animation_type {
+	ANIMATION_NONE,
+
+	ANIMATION_ZOOM,
+	ANIMATION_FADE
+};
+
 struct desktop_shell {
 	struct weston_compositor *compositor;
 
@@ -76,6 +83,7 @@ struct desktop_shell {
 	} screensaver;
 
 	uint32_t binding_modifier;
+	enum animation_type win_animation_type;
 	struct weston_surface *debug_repaint_surface;
 };
 
@@ -242,6 +250,20 @@ get_modifier(char *modifier)
 		return MODIFIER_SUPER;
 }
 
+static enum animation_type
+get_animation_type(char *animation)
+{
+	if (!animation)
+		return ANIMATION_NONE;
+
+	if (!strcmp("zoom", animation))
+		return ANIMATION_ZOOM;
+	else if (!strcmp("fade", animation))
+		return ANIMATION_FADE;
+	else
+		return ANIMATION_NONE;
+}
+
 static void
 shell_configuration(struct desktop_shell *shell)
 {
@@ -249,9 +271,11 @@ shell_configuration(struct desktop_shell *shell)
 	char *path = NULL;
 	int duration = 60;
 	char *modifier = NULL;
+	char *win_animation = NULL;
 
 	struct config_key shell_keys[] = {
 		{ "binding-modifier",   CONFIG_KEY_STRING, &modifier },
+		{ "animation",          CONFIG_KEY_STRING, &win_animation},
 	};
 
 	struct config_key saver_keys[] = {
@@ -271,6 +295,7 @@ shell_configuration(struct desktop_shell *shell)
 	shell->screensaver.path = path;
 	shell->screensaver.duration = duration;
 	shell->binding_modifier = get_modifier(modifier);
+	shell->win_animation_type = get_animation_type(win_animation);
 }
 
 static void
@@ -2020,7 +2045,18 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
 	}
 
 	if (surface_type == SHELL_SURFACE_TOPLEVEL)
-		weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);
+	{
+		switch (shell->win_animation_type) {
+		case ANIMATION_FADE:
+			weston_fade_run(surface, NULL, NULL);
+			break;
+		case ANIMATION_ZOOM:
+			weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);
+			break;
+		default:
+			break;
+		}
+	}
 }
 
 static void
diff --git a/weston.ini b/weston.ini
index 31d2e51..7693253 100644
--- a/weston.ini
+++ b/weston.ini
@@ -4,11 +4,13 @@ background-image=/usr/share/backgrounds/gnome/Aqua.jpg
 background-color=0xff002244
 panel-color=0x90ff0000
 locking=true
+animation=zoom
 
 #type=tablet-shell.so
 #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
 #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
 #homescreen=/usr/share/backgrounds/gnome/Blinds.jpg
+#animation=fade
 [launcher]
 icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png
 path=/usr/bin/gnome-terminal
-- 
1.7.5.4



More information about the wayland-devel mailing list