From 2507c509f45ab6b48d693cfd118ef7f4f18e3541 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Fri, 12 Jun 2009 16:54:49 +0530 Subject: [PATCH] Add configure option to scale mutter background and scale background as a build time option. --- configure.ac | 11 ++++++++++ src/moblin-netbook.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index 68fc069..313ea04 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,17 @@ if test x"$enable_debug" = xyes; then CFLAGS="$CFLAGS -g -O0" fi +AC_ARG_ENABLE([scale-background], + AC_HELP_STRING([--scale-background], + [Scale the mutter-moblin background image]), + [scale_background="$enableval"], [scale_background=no]) + +if test x"$scale_background" = xyes; then + AC_DEFINE(ENABLE_MUTTER_SCALE, 1, [scale mutter background]) +else + AC_DEFINE(ENABLE_MUTTER_SCALE, 0, [don't scale mutter background]) +fi + # glib-genmarshal GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` AC_SUBST(GLIB_GENMARSHAL) diff --git a/src/moblin-netbook.c b/src/moblin-netbook.c index 8b84d2c..a5778cf 100644 --- a/src/moblin-netbook.c +++ b/src/moblin-netbook.c @@ -444,6 +444,57 @@ moblin_netbook_plugin_init (MoblinNetbookPlugin *self) textdomain (GETTEXT_PACKAGE); } +#if ENABLE_MUTTER_SCALE +static void +on_desktop_pre_paint (ClutterActor *actor, gpointer data) +{ + + MoblinNetbookPlugin *plugin = data; + MoblinNetbookPluginPrivate *priv = MOBLIN_NETBOOK_PLUGIN (plugin)->priv; + CoglHandle *tex; + float bw, bh, ah, bw; + float v; + float tx1, tx2, ty1, ty2; + ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; + gint screen_width, screen_height; + + tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (actor)); + + mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); + + bw = (float) cogl_texture_get_width (tex); /* base texture width */ + bh = (float) cogl_texture_get_height (tex); /* base texture height */ + + /* no comment */ + if (bw/bh < aw/ah) + { + /* fit width */ + v = ((ah * bw) / (aw * bh)) / 2; + tx1 = 0; + tx2 = 1; + ty1 = (0.5 - v); + ty2 = (0.5 + v); + } else { + /* fit height */ + v = ((aw * bh) / (ah * bw)) / 2; + tx1 = (0.5 - v); + tx2 = (0.5 + v); + ty1 = 0; + ty2 = 1; + } + + col.alpha = clutter_actor_get_paint_opacity (actor); + cogl_set_source_color4ub (col.red, col.green, col.blue, col.alpha); + cogl_rectangle (0, 0, aw, ah); + cogl_set_source_texture (tex); + cogl_rectangle_with_texture_coords (0, 0, + aw, ah, + tx1, ty1, + tx2, ty2); + + g_signal_stop_emission_by_name (actor, "paint"); +} +#else static void on_desktop_pre_paint (ClutterActor *actor, gpointer data) { @@ -486,6 +537,7 @@ on_desktop_pre_paint (ClutterActor *actor, gpointer data) g_signal_stop_emission_by_name (actor, "paint"); } +#endif struct parallax_data { -- 1.6.0.2