[fusion-commits] compiz mirror: Changes to 'master' (239d7b32bac0ad79f25e013b0173c90991364a7a)
compiz at server.beryl-project.org
compiz at server.beryl-project.org
Wed Jul 11 09:15:05 CEST 2007
New commits:
commit 239d7b32bac0ad79f25e013b0173c90991364a7a
Author: Danny Baumann <dannybaumann at web.de>
Date: Wed Jul 11 09:13:39 2007 +0200
Trigger pointer based resize also if the resizing originally wasn't initiated by the mouse and determine the resize direction in that case by the pointer movement direction.
This also fixes window menu initiated resizing.
plugins/resize.c | 147 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 121 insertions(+), 26 deletions(-)
Modified: compiz/plugins/resize.c
===================================================================
--- compiz/plugins/resize.c
+++ compiz/plugins/resize.c
@@ -92,6 +92,7 @@ typedef struct _ResizeDisplay {
int mode;
XRectangle savedGeometry;
XRectangle geometry;
+
int releaseButton;
unsigned int mask;
int pointerDx;
@@ -209,6 +210,44 @@ resizeDamageRectangle (CompScreen *s,
damageScreenRegion (s, ®);
}
+static Cursor
+resizeCursorFromResizeMask (CompScreen *s,
+ unsigned int mask)
+{
+ Cursor cursor;
+
+ RESIZE_SCREEN (s);
+
+ if (mask & ResizeLeftMask)
+ {
+ if (mask & ResizeDownMask)
+ cursor = rs->downLeftCursor;
+ else if (mask & ResizeUpMask)
+ cursor = rs->upLeftCursor;
+ else
+ cursor = rs->leftCursor;
+ }
+ else if (mask & ResizeRightMask)
+ {
+ if (mask & ResizeDownMask)
+ cursor = rs->downRightCursor;
+ else if (mask & ResizeUpMask)
+ cursor = rs->upRightCursor;
+ else
+ cursor = rs->rightCursor;
+ }
+ else if (mask & ResizeUpMask)
+ {
+ cursor = rs->upCursor;
+ }
+ else
+ {
+ cursor = rs->downCursor;
+ }
+
+ return cursor;
+}
+
static void
resizeSendResizeNotify (CompDisplay *d)
{
@@ -387,31 +426,9 @@ resizeInitiate (CompDisplay *d,
{
cursor = rs->middleCursor;
}
- else if (mask & ResizeLeftMask)
- {
- if (mask & ResizeDownMask)
- cursor = rs->downLeftCursor;
- else if (mask & ResizeUpMask)
- cursor = rs->upLeftCursor;
- else
- cursor = rs->leftCursor;
- }
- else if (mask & ResizeRightMask)
- {
- if (mask & ResizeDownMask)
- cursor = rs->downRightCursor;
- else if (mask & ResizeUpMask)
- cursor = rs->upRightCursor;
- else
- cursor = rs->rightCursor;
- }
- else if (mask & ResizeUpMask)
- {
- cursor = rs->upCursor;
- }
else
{
- cursor = rs->downCursor;
+ cursor = resizeCursorFromResizeMask (w->screen, mask);
}
rs->grabIndex = pushScreenGrab (w->screen, cursor, "resize");
@@ -637,12 +654,90 @@ resizeHandleMotionEvent (CompScreen *s,
RESIZE_DISPLAY (s->display);
- rd->pointerDx += xRoot - lastPointerX;
- rd->pointerDy += yRoot - lastPointerY;
-
w = rd->savedGeometry.width;
h = rd->savedGeometry.height;
+ if (!rd->mask)
+ {
+ CompWindow *w = rd->w;
+ int xDist, yDist;
+ int minPointerOffsetX, minPointerOffsetY;
+
+ xDist = xRoot - (w->serverX + (w->serverWidth / 2));
+ yDist = yRoot - (w->serverY + (w->serverHeight / 2));
+
+ /* decision threshold is 10% of window size */
+ minPointerOffsetX = MIN (20, w->serverWidth / 10);
+ minPointerOffsetY = MIN (20, w->serverHeight / 10);
+
+ /* if we reached the threshold in one direction,
+ make the threshold in the other direction smaller
+ so there is a chance that this threshold also can
+ be reached (by diagonal movement) */
+ if (abs (xDist) > minPointerOffsetX)
+ minPointerOffsetY /= 2;
+ else if (abs (yDist) > minPointerOffsetY)
+ minPointerOffsetX /= 2;
+
+ if (abs (xDist) > minPointerOffsetX)
+ {
+ if (xDist > 0)
+ rd->mask |= ResizeRightMask;
+ else
+ rd->mask |= ResizeLeftMask;
+ }
+
+ if (abs (yDist) > minPointerOffsetY)
+ {
+ if (yDist > 0)
+ rd->mask |= ResizeDownMask;
+ else
+ rd->mask |= ResizeUpMask;
+ }
+
+ /* if the pointer movement was enough to determine a
+ direction, warp the pointer to the appropriate edge
+ and set the right cursor */
+ if (rd->mask)
+ {
+ Cursor cursor;
+ CompScreen *s = rd->w->screen;
+ CompAction *action;
+ int pointerAdjustX = 0;
+ int pointerAdjustY = 0;
+
+ RESIZE_SCREEN (s);
+
+ action = &rd->opt[RESIZE_DISPLAY_OPTION_INITIATE].value.action;
+ action->state |= CompActionStateTermButton;
+
+ if (rd->mask & ResizeRightMask)
+ pointerAdjustX = w->serverX + w->serverWidth +
+ w->input.right - xRoot;
+ else if (rd->mask & ResizeLeftMask)
+ pointerAdjustX = w->serverX - w->input.left - xRoot;
+
+ if (rd->mask & ResizeDownMask)
+ pointerAdjustY = w->serverY + w->serverHeight +
+ w->input.bottom - yRoot;
+ else if (rd->mask & ResizeUpMask)
+ pointerAdjustY = w->serverY - w->input.top - yRoot;
+
+ warpPointer (s, pointerAdjustX, pointerAdjustY);
+
+ cursor = resizeCursorFromResizeMask (s, rd->mask);
+ updateScreenGrab (s, rs->grabIndex, cursor);
+ }
+ }
+ else
+ {
+ /* only accumulate pointer movement if a mask is
+ already set as we don't have a use for the
+ difference information otherwise */
+ rd->pointerDx += xRoot - lastPointerX;
+ rd->pointerDy += yRoot - lastPointerY;
+ }
+
if (rd->mask & ResizeLeftMask)
w -= rd->pointerDx;
else if (rd->mask & ResizeRightMask)
More information about the commits
mailing list