bool RotateScreen::rotateTo (CompAction *action, CompAction::State state, CompOption::Vector &options, int face, bool withWindow) { CompOption::Vector o (0); if (face < 0) face = CompOption::getIntOptionNamed (options, "face", screen->vp ().x ()); if (face > screen->vpSize ().width ()) return false; o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (CompOption::getIntOptionNamed (options, "x", pointerX)); o[2].value ().set (CompOption::getIntOptionNamed (options, "y", pointerY)); if (withWindow) { o.push_back (CompOption ("window", CompOption::TypeInt)); o[3].value ().set (CompOption::getIntOptionNamed (options, "window", 0)); rotateWithWindow (NULL, 0, o, rotateToDirection (face)); } else rotate (NULL, 0, o, rotateToDirection (face)); return false; }
bool RotateScreen::rotateFlip (int direction) { if (screen->otherGrabExist ("rotate", "move", "group-drag", NULL)) return false; CompOption::Vector o (0); mMoveTo = 0.0f; mSlow = false; int warpX = pointerX - (screen->width () * direction); if (direction == -1) screen->warpPointer (screen->width () - 10, 0); else screen->warpPointer (10 - screen->width (), 0); lastPointerX = warpX; o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (0); o[2].value ().set (pointerY); rotate (NULL, 0, o, direction); XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, direction, 0); mSavedPointer.setX (lastPointerX + (9 * direction)); return false; }
static void saveYourselfCallback (SmcConn connection, SmPointer client_data, int saveType, Bool shutdown, int interact_Style, Bool fast) { CompOption::Vector args; args.push_back (CompOption ("save_type", CompOption::TypeInt)); args.push_back (CompOption ("shutdown", CompOption::TypeBool)); args.push_back (CompOption ("interact_style", CompOption::TypeInt)); args.push_back (CompOption ("fast", CompOption::TypeBool)); args[0].value ().set (saveType); args[1].value ().set ((bool) shutdown); args[2].value ().set (interact_Style); args[3].value ().set ((bool) fast); screen->sessionEvent (CompSession::EventSaveYourself, args); setCloneRestartCommands (connection); setRestartStyle (connection, SmRestartImmediately); setProgramInfo (connection, getpid (), getuid ()); SmcSaveYourselfDone (connection, 1); }
bool RotateScreen::rotateWithWindow (CompAction *action, CompAction::State state, CompOption::Vector &options, int direction) { if (screen->vpSize ().width () < 2 || !direction) return false; Window xid = CompOption::getIntOptionNamed (options, "window"); if (mMoveWindow != xid) { releaseMoveWindow (); if (!mGrabIndex && !mMoving) { CompWindow *w = screen->findWindow (xid); if (w && !(w->type () & (CompWindowTypeDesktopMask | CompWindowTypeDockMask)) && !(w->state () & CompWindowStateStickyMask)) { mMoveWindow = w->id (); mMoveWindowX = w->x (); if (optionGetRaiseOnRotate ()) w->raise (); } } } if (!mGrabIndex) { CompOption::Vector o (0); o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (CompOption::getIntOptionNamed (options, "x", 0)); o[2].value ().set (CompOption::getIntOptionNamed (options, "y", 0)); initiate (NULL, 0, o); } if (mGrabIndex) { mMoving = true; mMoveTo += 360.0f / screen->vpSize ().width () * direction; mGrabbed = false; cScreen->damageScreen (); } return false; }
void PrivateScaleScreen::activateEvent (bool activating) { CompOption::Vector o (0); o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("active", CompOption::TypeBool)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (activating); screen->handleCompizEvent ("scale", "activate", o); }
void RotateWindow::activate () { if (window->placed () && !screen->otherGrabExist ("rotate", "switcher", "cube", NULL)) { /* reset movement */ rScreen->mMoveTo = 0.0f; int dx = window->defaultViewport ().x (); dx -= screen->vp ().x (); if (dx) { Window win; int i, x, y; unsigned int ui; CompOption::Vector o (0); XQueryPointer (screen->dpy (), screen->root (), &win, &win, &x, &y, &i, &i, &ui); if (dx * 2 > screen->vpSize ().width ()) dx -= screen->vpSize ().width (); else if (dx * 2 < -screen->vpSize ().width ()) dx += screen->vpSize ().width (); o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (x); o[2].value ().set (y); rScreen->rotate (NULL, 0, o, dx); } } window->activate (); }
bool RotateScreen::rotate (CompAction *action, CompAction::State state, CompOption::Vector &options, int direction) { if (screen->vpSize ().width () < 2 || !direction || screen->otherGrabExist ("rotate", "move", "switcher", "group-drag", "cube", NULL)) return false; if (mMoveWindow) releaseMoveWindow (); /* we allow the grab to fail here so that we can rotate on drag-and-drop */ if (!mGrabIndex) { CompOption::Vector o (0); o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (CompOption::getIntOptionNamed (options, "x", 0)); o[2].value ().set (CompOption::getIntOptionNamed (options, "y", 0)); initiate (NULL, 0, o); } mMoving = true; mMoveTo += 360.0f / screen->vpSize ().width () * direction; mGrabbed = false; cScreen->damageScreen (); return false; }
void RotateScreen::handleEvent (XEvent *event) { switch (event->type) { case MotionNotify: if (screen->root () == event->xmotion.root && mGrabIndex) { if (mGrabbed) { GLfloat pointerDx = pointerX - lastPointerX; GLfloat pointerDy = pointerY - lastPointerY; // TODO: Eliminate magic numbers here if (event->xmotion.x_root < 50 || event->xmotion.y_root < 50 || event->xmotion.x_root > screen->width () - 50 || event->xmotion.y_root > screen->height () - 50) screen->warpPointer ((screen->width () / 2) - pointerX, (screen->height () / 2) - pointerY); if (optionGetInvertY ()) pointerDy = -pointerDy; mXVelocity += pointerDx * mPointerSensitivity * cubeScreen->invert (); mYVelocity += pointerDy * mPointerSensitivity; cScreen->damageScreen (); } else { mSavedPointer.setX (mSavedPointer.x () + pointerX - lastPointerX); mSavedPointer.setY (mSavedPointer.y () + pointerY - lastPointerY); } } break; case ClientMessage: if (event->xclient.message_type == Atoms::desktopViewport) { if (screen->root () == event->xclient.window) { if (screen->otherGrabExist ("rotate", "switcher", "cube", NULL)) break; /* reset movement */ mMoveTo = 0.0f; int dx = (event->xclient.data.l[0] / screen->width ()) - screen->vp ().x (); if (dx) { Window win; int i, x, y; unsigned int ui; CompOption::Vector o (0); XQueryPointer (screen->dpy (), screen->root (), &win, &win, &x, &y, &i, &i, &ui); if (dx * 2 > screen->vpSize ().width ()) dx -= screen->vpSize ().width (); else if (dx * 2 < -screen->vpSize ().width ()) dx += screen->vpSize ().width (); o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (x); o[2].value ().set (y); rotate (NULL, 0, o, dx); } } } break; default: break; } screen->handleEvent (event); }
bool RotateScreen::rotateEdgeFlip (CompAction *action, CompAction::State state, CompOption::Vector &options, int direction) { CompOption::Vector o (0); if (screen->vpSize ().width () < 2 || screen->otherGrabExist ("rotate", "move", "group-drag", NULL)) return false; if (state & CompAction::StateInitEdgeDnd) { if (!optionGetEdgeFlipDnd ()) return false; } else if (screen->otherGrabExist ("rotate", "group-drag", NULL)) { if (!optionGetEdgeFlipWindow () || !mGrabWindow || /* bail out if window is horizontally maximized, fullscreen * or sticky */ mGrabWindow->state () & (CompWindowStateMaximizedHorzMask | CompWindowStateFullscreenMask | CompWindowStateStickyMask)) return false; } else if (screen->otherGrabExist ("rotate", NULL)) { /* in that case, 'group-drag' must be the active screen grab */ if (!optionGetEdgeFlipWindow ()) return false; } else if (!optionGetEdgeFlipPointer ()) return false; o.push_back (CompOption ("root", CompOption::TypeInt)); o.push_back (CompOption ("x", CompOption::TypeInt)); o.push_back (CompOption ("y", CompOption::TypeInt)); o[0].value ().set ((int) screen->root ()); o[1].value ().set (CompOption::getIntOptionNamed (options, "x", 0)); o[2].value ().set (CompOption::getIntOptionNamed (options, "y", 0)); if (optionGetFlipTime () == 0 || (mMoving && !mSlow)) { int pointerDx = pointerX - lastPointerX; int warpX; /* TODO: Eliminate those magic numbers here */ if (direction == -1) { warpX = pointerX + screen->width (); screen->warpPointer (screen->width () - 10, 0); lastPointerX = warpX - pointerDx; rotate (NULL, 0, o, direction); XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, -1, 0); mSavedPointer.setX (lastPointerX - 9); } else { warpX = pointerX - screen->width (); screen->warpPointer (10 - screen->width (), 0); lastPointerX = warpX - pointerDx; rotate (NULL, 0, o, direction); XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, 1, 0); mSavedPointer.setX (lastPointerX + 9); } } else { if (!mRotateTimer.active ()) mRotateTimer.start (boost::bind (&RotateScreen::rotateFlip, this, direction), optionGetFlipTime (), (float) optionGetFlipTime () * 1.2); mMoving = true; mMoveTo += 360.0f / screen->vpSize ().width () * direction; mSlow = true; if (state & CompAction::StateInitEdge) action->setState (action->state () | CompAction::StateTermEdge); if (state & CompAction::StateInitEdgeDnd) action->setState (action->state () | CompAction::StateTermEdgeDnd); cScreen->damageScreen (); } return false; }