summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2008-11-15 13:47:10 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2008-11-15 13:47:10 +0900
commit435a4bc0a455d736e2914bd2bf608a05c8760951 (patch)
tree88044039a4b59c9886a291dfd0ef446699d7b660
parentcab0499a42e1cc3047cc0317cab1e84bad03dc5b (diff)
downloadthrow-435a4bc0a455d736e2914bd2bf608a05c8760951.tar.gz
throw-435a4bc0a455d736e2914bd2bf608a05c8760951.tar.bz2
* Options support, constrain X, Y etc
-rw-r--r--throw.c30
-rw-r--r--throw.xml.in14
2 files changed, 39 insertions, 5 deletions
diff --git a/throw.c b/throw.c
index 21d384a..a02adc2 100644
--- a/throw.c
+++ b/throw.c
@@ -85,6 +85,12 @@ typedef struct _ThrowWindow
GET_THROW_SCREEN (w->screen, \
GET_THROW_DISPLAY (w->screen->display)))
+#define WIN_REAL_X(w) (w->attrib.x - w->input.left)
+#define WIN_REAL_Y(w) (w->attrib.y - w->input.top)
+
+#define WIN_REAL_W(w) (w->width + w->input.left + w->input.right)
+#define WIN_REAL_H(w) (w->height + w->input.top + w->input.bottom)
+
/* Handle the velocity */
static void
throwPreparePaintScreen (CompScreen *s,
@@ -100,14 +106,32 @@ throwPreparePaintScreen (CompScreen *s,
if (tw->moving)
tw->time += ms;
- tw->xVelocity /= 1.25;
- tw->yVelocity /= 1.25;
+ tw->xVelocity /= (1.0 + (throwGetFrictionConstant (s) / 100));
+ tw->yVelocity /= (1.0 + (throwGetFrictionConstant (s) / 100));
if (!tw->moving && (
(tw->xVelocity < 0.0f || tw->xVelocity > 0.0f) ||
(tw->yVelocity < 0.0f || tw->yVelocity > 0.0)))
{
- moveWindow (w, roundf(tw->xVelocity * (ms / 10)), roundf (tw->yVelocity * (ms / 10)), TRUE, FALSE);
+ int dx = roundf(tw->xVelocity * (ms / 10) * (throwGetVelocityX (s) / 10));
+ int dy = roundf (tw->yVelocity * (ms / 10) * (throwGetVelocityY (s) / 10));
+
+ if (throwGetConstrainX (s))
+ {
+ if ((WIN_REAL_X (w) + dx) < 0)
+ dx = 0;
+ else if ((WIN_REAL_X (w) + WIN_REAL_W (w) + dx) > w->screen->width)
+ dx = 0;
+ }
+ if (throwGetConstrainY (s))
+ {
+ if ((WIN_REAL_Y (w) + dy) < 0)
+ dy = 0;
+ else if ((WIN_REAL_Y (w) + WIN_REAL_H (w) + dy) > w->screen->height)
+ dy = 0;
+ }
+
+ moveWindow (w, dx, dy, TRUE, FALSE);
syncWindowPosition (w);
}
diff --git a/throw.xml.in b/throw.xml.in
index 0370b6d..520e18c 100644
--- a/throw.xml.in
+++ b/throw.xml.in
@@ -9,7 +9,7 @@
<plugin>resize</plugin>
</relation>
</deps>
- <display>
+ <screen>
<group>
<option type="float" name="velocity_x">
<_short>X Velocity Multiplier</_short>
@@ -32,7 +32,17 @@
<max>100.0</max>
<default>10.0</default>
</option>
+ <option type="bool" name="constrain_x">
+ <_short>Constrain X</_short>
+ <_long>Constrain window in display width</_long>
+ <default>false</default>
+ </option>
+ <option type="bool" name="constrain_y">
+ <_short>Constrain Y</_short>
+ <_long>Constrain window in display height</_long>
+ <default>true</default>
+ </option>
</group>
- </display>
+ </screen>
</plugin>
</compiz>