summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@src.gnome.org>2005-02-13 00:29:32 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2005-02-13 00:29:32 +0000
commita371607ca9b52336c1c1d2dcda8a20fbd489472e (patch)
tree2825fd7ad7bb5e813a95e5675e77eced9f697d66
parent6a8792e440e4c9f598e2549eed0d8ee2f93071a7 (diff)
downloadmetacity-a371607ca9b52336c1c1d2dcda8a20fbd489472e.tar.gz
Improve snow a little
-rw-r--r--src/compositor.c4
-rw-r--r--src/snow.c58
2 files changed, 42 insertions, 20 deletions
diff --git a/src/compositor.c b/src/compositor.c
index afd5c870..d0b93267 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -113,7 +113,7 @@ update_world (gpointer data)
meta_compositor_invalidate_region (compositor, screen, region);
XFixesDestroyRegion (compositor->display->xdisplay, region);
- time += 0.0005;
+ time += 0.001;
return TRUE;
}
@@ -511,7 +511,7 @@ ensure_repair_idle (MetaCompositor *compositor)
g_print ("screen %p\n", world_get_screen (compositor->world));
- g_timeout_add_full (G_PRIORITY_LOW, 25, update_world, compositor, NULL);
+ g_timeout_add_full (G_PRIORITY_HIGH, 50, update_world, compositor, NULL);
}
compositor->repair_idle = g_idle_add_full (META_PRIORITY_COMPOSITE,
diff --git a/src/snow.c b/src/snow.c
index b8ae68d5..5aa05fbf 100644
--- a/src/snow.c
+++ b/src/snow.c
@@ -8,18 +8,9 @@
typedef struct Flake Flake;
-/*
- * Diana:
- * Snowflakes are two concentric circles
- * outer radius: 8.2 * s
- * inner radius: 5.2 * s
- * alpha of both circles: 60 %
- *
- */
-
#define MAX_RADIUS 6.2
#define MIN_RADIUS 4.5
-#define MIN_ALPHA 40.0
+#define MIN_ALPHA 20.0
#define MAX_ALPHA 70.0
struct Flake
@@ -28,7 +19,7 @@ struct Flake
double x;
double y;
int alpha;
- int radius;
+ int radius;
double y_speed;
double increment;
double angle;
@@ -41,6 +32,7 @@ struct World
MetaScreen *screen;
GList *flakes;
gdouble time;
+ gint xmouse;
};
static void
@@ -94,15 +86,33 @@ static void
flake_move (Flake *flake,
gdouble delta)
{
+ gboolean mouse_enabled = TRUE;
+
flake->angle += delta * flake->increment;
- flake->x += flake->radius * 100000 * delta * sin (flake->angle);
- flake->y += delta * flake->y_speed;
+ if (mouse_enabled)
+ {
+ flake->x += (flake->world->screen->width / 2 - flake->world->xmouse) / 100;
+ flake->y += delta * 10 * flake->y_speed;
+
+ if ((flake->y > flake->world->screen->height || flake->y < 0))
+ {
+ flake_renew (flake, FALSE);
+ }
- if ((flake->x > flake->world->screen->width || flake->x < 0) ||
- (flake->y > flake->world->screen->height || flake->y < 0))
+ while (flake->x < 0)
+ flake->x += flake->world->screen->width;
+ }
+ else
{
- flake_renew (flake, FALSE);
+ flake->x += flake->radius * 25000 * delta * sin (flake->angle);
+ flake->y += delta * flake->y_speed;
+
+ if ((flake->x > flake->world->screen->width || flake->x < 0) ||
+ (flake->y > flake->world->screen->height || flake->y < 0))
+ {
+ flake_renew (flake, FALSE);
+ }
}
}
@@ -271,7 +281,7 @@ World *
world_new (Display *dpy,
MetaScreen *screen)
{
-#define N_FLAKES (screen->width / 40)
+#define N_FLAKES (screen->width / 20)
#if 0
#define N_FLAKES 10
#endif
@@ -298,7 +308,19 @@ world_set_time (World *world, double time)
GList *list;
gdouble delta = time - world->time;
world->time = time;
-
+ Window dummy;
+ int dummyint;
+
+ XQueryPointer (world->dpy,
+ world->screen->xroot,
+ &dummy, /* root_return */
+ &dummy, /* child return */
+ &world->xmouse, /* root x return */
+ &dummyint, /* root y return */
+ &dummyint, /* win x return */
+ &dummyint, /* win y return */
+ &dummyint /* mask return */);
+
for (list = world->flakes; list; list = list->next)
{
Flake *flake = list->data;