summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/rotate.c
diff options
context:
space:
mode:
authorkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-11 17:06:46 +0000
committerkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-11 17:06:46 +0000
commit4b0d394ce874f72c0136867db12748be56c945e0 (patch)
tree0a764cb21aeacf6170b4bf5be49695b39b569990 /beryl-plugins/src/rotate.c
parent25c651b7bc41edae16d634927545e5d193d95805 (diff)
downloadmarex-dev-4b0d394ce874f72c0136867db12748be56c945e0.tar.gz
marex-dev-4b0d394ce874f72c0136867db12748be56c945e0.tar.bz2
addhelper: Only update when the active window actually changes.
rotate: Add option to rotate all screens. The option itself works fine, but screengrabs are a bit dangerous atm, so use with care. WIK. git-svn-id: file:///beryl/trunk@3961 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/rotate.c')
-rw-r--r--beryl-plugins/src/rotate.c278
1 files changed, 172 insertions, 106 deletions
diff --git a/beryl-plugins/src/rotate.c b/beryl-plugins/src/rotate.c
index 7312c5c..ad111e7 100644
--- a/beryl-plugins/src/rotate.c
+++ b/beryl-plugins/src/rotate.c
@@ -53,6 +53,9 @@
#define ROTATE_INITIATE_BUTTON_DEFAULT Button1
#define ROTATE_INITIATE_MODIFIERS_DEFAULT (ControlMask | CompAltMask)
+#define ROTATE_INITIATE_ALL_BUTTON_DEFAULT Button3
+#define ROTATE_INITIATE_ALL_MODIFIERS_DEFAULT (ControlMask | CompAltMask)
+
#define ROTATE_INITIATE_STICKY_BUTTON_DEFAULT Button2
#define ROTATE_INITIATE_STICKY_MODIFIERS_DEFAULT (ControlMask | CompAltMask)
@@ -138,7 +141,7 @@ static int displayPrivateIndex;
#define ROTATE_DISPLAY_OPTION_EDGEFLIP_POINTER 5
#define ROTATE_DISPLAY_OPTION_EDGEFLIP_WINDOW 6
#define ROTATE_DISPLAY_OPTION_EDGEFLIP_DND 7
-#define ROTATE_DISPLAY_OPTION_FLIPTIME 8
+#define ROTATE_DISPLAY_OPTION_FLIPTIME 44
#define ROTATE_DISPLAY_OPTION_TO_1 9
#define ROTATE_DISPLAY_OPTION_TO_2 10
#define ROTATE_DISPLAY_OPTION_TO_3 11
@@ -174,8 +177,9 @@ static int displayPrivateIndex;
#define ROTATE_DISPLAY_OPTION_STICKY_INITIATE 41
#define ROTATE_DISPLAY_OPTION_FLIP_LEFT 42
#define ROTATE_DISPLAY_OPTION_FLIP_RIGHT 43
+#define ROTATE_DISPLAY_OPTION_INITIATE_ALL 8
-#define ROTATE_DISPLAY_OPTION_NUM 44
+#define ROTATE_DISPLAY_OPTION_NUM 45
typedef struct _RotateDisplay
{
@@ -1006,86 +1010,105 @@ rotatePaintScreen(CompScreen * s,
return status;
}
-
-static Bool
-rotateInitiate(CompDisplay * d,
- CompAction * action,
- CompActionState state, CompOption * option, int nOption)
+static Bool rotateScreen(CompScreen * s, CompAction * action, CompActionState state, CompOption * option, int nOption)
{
- CompScreen *s;
- Window xid;
- xid = getIntOptionNamed(option, nOption, "root", 0);
+ ROTATE_SCREEN(s);
+ IPCS_SetBool(IPCS_OBJECT(s), rs->snapTopBottomAtom, FALSE);
- s = findScreenAtDisplay(d, xid);
- if (s)
- {
- ROTATE_SCREEN(s);
- IPCS_SetBool(IPCS_OBJECT(s), rs->snapTopBottomAtom, FALSE);
+ if (s->hsize < 2)
+ return FALSE;
- if (s->hsize < 2)
+ if (rs->rotateHandle && rs->grabWindow)
+ {
+ if (otherScreenGrabExist(s, "rotate", "move", 0))
return FALSE;
+ }
+ else
+ {
+ if (otherScreenGrabExist(s, "rotate", "switcher", "cube", 0))
+ return FALSE;
+ }
- if (rs->rotateHandle && rs->grabWindow)
- {
- if (otherScreenGrabExist(s, "rotate", "move", 0))
- return FALSE;
- }
- else
+ rs->moving = FALSE;
+ rs->slow = FALSE;
+ rs->movingVert = FALSE;
+ rs->moveTo = 0.0f;
+ rs->moveToY = 0.0f;
+
+ compDisplaySetRequestFlagForPlugin(s->display, "rotate", "ENABLE_3D");
+
+ rs->rotating = FALSE;
+ if ((state & CompActionStateInitButton))
+ {
+ IPCS_SetBool(IPCS_OBJECT(s), rs->manualAtom, TRUE);
+ }
+ else
+ {
+ IPCS_SetBool(IPCS_OBJECT(s), rs->manualAtom, FALSE);
+ }
+ if (!rs->grabIndex)
+ {
+ rs->grabIndex = pushScreenGrab(s, s->invisibleCursor, "rotate");
+ if (rs->grabIndex)
{
- if (otherScreenGrabExist(s, "rotate", "switcher", "cube", 0))
- return FALSE;
+ int x, y;
+
+ x = getIntOptionNamed(option, nOption, "x", 0);
+ y = getIntOptionNamed(option, nOption, "y", 0);
+
+ rs->savedPointer.x = x;
+ rs->savedPointer.y = y;
}
+ }
- rs->moving = FALSE;
- rs->slow = FALSE;
- rs->movingVert = FALSE;
+ if (rs->grabIndex)
+ {
rs->moveTo = 0.0f;
rs->moveToY = 0.0f;
- compDisplaySetRequestFlagForPlugin(s->display, "rotate", "ENABLE_3D");
+ rs->grabbed = TRUE;
+ rs->snapTop = rs->opt[ROTATE_SCREEN_OPTION_SNAP_TOP].value.b;
+ rs->snapBottom =
+ rs->opt[ROTATE_SCREEN_OPTION_SNAP_BOTTOM].value.b;
- rs->rotating = FALSE;
- if ((state & CompActionStateInitButton))
- {
- IPCS_SetBool(IPCS_OBJECT(s), rs->manualAtom, TRUE);
- }
- else
- {
- IPCS_SetBool(IPCS_OBJECT(s), rs->manualAtom, FALSE);
- }
- if (!rs->grabIndex)
- {
- rs->grabIndex = pushScreenGrab(s, s->invisibleCursor, "rotate");
- if (rs->grabIndex)
- {
- int x, y;
+ if (state & CompActionStateInitButton)
+ action->state |= CompActionStateTermButton;
- x = getIntOptionNamed(option, nOption, "x", 0);
- y = getIntOptionNamed(option, nOption, "y", 0);
+ if (state & CompActionStateInitKey)
+ action->state |= CompActionStateTermKey;
+ }
+ return True;
+}
- rs->savedPointer.x = x;
- rs->savedPointer.y = y;
- }
- }
+static Bool
+rotateInitiate(CompDisplay * d,
+ CompAction * action,
+ CompActionState state, CompOption * option, int nOption)
+{
+ CompScreen *s;
+ Window xid;
- if (rs->grabIndex)
- {
- rs->moveTo = 0.0f;
- rs->moveToY = 0.0f;
+ xid = getIntOptionNamed(option, nOption, "root", 0);
- rs->grabbed = TRUE;
- rs->snapTop = rs->opt[ROTATE_SCREEN_OPTION_SNAP_TOP].value.b;
- rs->snapBottom =
- rs->opt[ROTATE_SCREEN_OPTION_SNAP_BOTTOM].value.b;
+ s = findScreenAtDisplay(d, xid);
+ if (s)
+ if (!rotateScreen(s, action, state, option, nOption))
+ return FALSE;
- if (state & CompActionStateInitButton)
- action->state |= CompActionStateTermButton;
+ return TRUE;
+}
- if (state & CompActionStateInitKey)
- action->state |= CompActionStateTermKey;
- }
- }
+static Bool
+rotateInitiateAllScreen(CompDisplay * d,
+ CompAction * action,
+ CompActionState state, CompOption * option, int nOption)
+{
+ CompScreen *s;
+
+ for (s = d->screens; s; s = s->next)
+ if (!rotateScreen(s, action, state, option, nOption))
+ return FALSE;
return TRUE;
}
@@ -1126,8 +1149,8 @@ rotateTerminate(CompDisplay * d,
{
ROTATE_SCREEN(s);
- if (xid && s->root != xid)
- continue;
+// if (xid && s->root != xid)
+// continue;
rs->rotating = FALSE;
@@ -1980,59 +2003,79 @@ rotateToWithWindow(CompDisplay * d,
return FALSE;
}
-static void rotateHandleEvent(CompDisplay * d, XEvent * event)
+static void handleMotionNotify(CompDisplay * d, XEvent * event)
{
CompScreen *s;
-
+ RotateScreen *rs;
+ GLfloat pointerDx, pointerDy;
ROTATE_DISPLAY(d);
- switch (event->type)
+ for (s = d->screens; s; s = s->next)
{
- case MotionNotify:
- s = findScreenAtDisplay(d, event->xmotion.root);
- if (s)
- {
- ROTATE_SCREEN(s);
+ rs = GET_ROTATE_SCREEN(s, rd);
+ if (rs->grabIndex && rs->grabbed)
+ break;
+ }
+ if(!s)
+ return;
- if (rs->grabIndex)
- {
- if (rs->grabbed)
- {
- GLfloat pointerDx, pointerDy;
+ s = findScreenAtDisplay(d, event->xmotion.root);
+ if (!s)
+ return;
+ rs = GET_ROTATE_SCREEN(s,rd);
- pointerDx = d->pointerX - d->lastPointerX;
- pointerDy = d->pointerY - d->lastPointerY;
+ if (rs->grabbed)
+ {
- if (event->xmotion.x_root < 50 ||
- event->xmotion.y_root < 50 ||
- event->xmotion.x_root >
- s->width - 50
- || event->xmotion.y_root > s->height - 50)
- {
- warpPointer(s,
- (s->width /
- 2) -
- d->pointerX,
- (s->height / 2) - d->pointerY);
- }
+ pointerDx = d->pointerX - d->lastPointerX;
+ pointerDy = d->pointerY - d->lastPointerY;
- if (rs->
- opt[ROTATE_SCREEN_OPTION_POINTER_INVERT_Y].value.b)
- pointerDy = -pointerDy;
+ if (event->xmotion.x_root < 50 ||
+ event->xmotion.y_root < 50 ||
+ event->xmotion.x_root >
+ s->width - 50
+ || event->xmotion.y_root > s->height - 50)
+ {
+ warpPointer(s, (s->width / 2) - d->pointerX,
+ (s->height / 2) - d->pointerY);
+ }
- rs->xVelocity +=
- pointerDx * rs->pointerSensitivity * rs->invert;
- rs->yVelocity += pointerDy * rs->pointerSensitivity;
+ if (rs->
+ opt[ROTATE_SCREEN_OPTION_POINTER_INVERT_Y].value.b)
+ pointerDy = -pointerDy;
- damageScreen(s);
- }
- else
- {
- rs->savedPointer.x += d->pointerX - d->lastPointerX;
- rs->savedPointer.y += d->pointerY - d->lastPointerY;
- }
- }
+ damageScreen(s);
+ }
+ else
+ {
+ rs->savedPointer.x += d->pointerX - d->lastPointerX;
+ rs->savedPointer.y += d->pointerY - d->lastPointerY;
+ return;
+ }
+
+
+ for (s = d->screens; s; s = s->next)
+ {
+ rs = GET_ROTATE_SCREEN(s, rd);
+ if (rs->grabIndex && rs->grabbed)
+ {
+ rs->xVelocity +=
+ pointerDx * rs->pointerSensitivity * rs->invert;
+ rs->yVelocity += pointerDy * rs->pointerSensitivity;
+
+ damageScreen(s);
}
+ }
+}
+static void rotateHandleEvent(CompDisplay * d, XEvent * event)
+{
+ CompScreen *s;
+
+ ROTATE_DISPLAY(d);
+ switch (event->type)
+ {
+ case MotionNotify:
+ handleMotionNotify(d, event);
break;
case ClientMessage:
if (event->xclient.message_type == d->winActiveAtom)
@@ -2244,6 +2287,7 @@ rotateSetDisplayOption(CompDisplay * display,
switch (index)
{
case ROTATE_DISPLAY_OPTION_INITIATE:
+ case ROTATE_DISPLAY_OPTION_INITIATE_ALL:
case ROTATE_DISPLAY_OPTION_LEFT:
case ROTATE_DISPLAY_OPTION_RIGHT:
case ROTATE_DISPLAY_OPTION_UP:
@@ -2330,6 +2374,28 @@ static void rotateDisplayInitOptions(RotateDisplay * rd)
o->value.action.button.modifiers = ROTATE_INITIATE_MODIFIERS_DEFAULT;
o->value.action.button.button = ROTATE_INITIATE_BUTTON_DEFAULT;
+ o = &rd->opt[ROTATE_DISPLAY_OPTION_INITIATE_ALL];
+ o->advanced = False;
+ o->name = "initiate_all";
+ o->group = N_("Bindings");
+ o->subGroup = N_("Initiate");
+ o->displayHints = "";
+ o->shortDesc = N_("Initiate Display Rotation");
+ o->longDesc = N_("Start Rotation on all screens if working in a "
+ "multiscreen enviroment. IE: Not xinerama. This option "
+ "does not serve a purpose unless you have multiple "
+ "monitors and are not using xinerama.");
+ o->type = CompOptionTypeAction;
+ o->value.action.initiate = rotateInitiateAllScreen;
+ o->value.action.terminate = rotateTerminate;
+ o->value.action.bell = FALSE;
+ o->value.action.edgeMask = 0;
+ o->value.action.state = CompActionStateInitKey;
+ o->value.action.state |= CompActionStateInitButton;
+ o->value.action.type = CompBindingTypeButton;
+ //o->value.action.button.modifiers = ROTATE_INITIATE_ALL_MODIFIERS_DEFAULT;
+ //o->value.action.button.button = ROTATE_INITIATE_ALL_BUTTON_DEFAULT;
+
o = &rd->opt[ROTATE_DISPLAY_OPTION_STICKY_INITIATE];
o->advanced = False;
o->name = "initiate_sticky";