+ if (screen->doOpaqueMove()) {
+ configure(dx, dy, frame.rect.width(), frame.rect.height());
+ } else {
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(),
+ frame.changing.x(),
+ frame.changing.y(),
+ frame.changing.width() - 1,
+ frame.changing.height() - 1);
+
+ frame.changing.setPos(dx, dy);
+
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(),
+ frame.changing.x(),
+ frame.changing.y(),
+ frame.changing.width() - 1,
+ frame.changing.height() - 1);
+ }
+
+ screen->showPosition(dx, dy);
+}
+
+
+bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root,
+ int dx, int dy) {
+ // workspace warping
+ bool warp = False;
+ unsigned int dest = screen->getCurrentWorkspaceID();
+ if (x_root <= 0) {
+ warp = True;
+
+ if (dest > 0) dest--;
+ else dest = screen->getNumberOfWorkspaces() - 1;
+
+ } else if (x_root >= screen->getRect().right()) {
+ warp = True;
+
+ if (dest < screen->getNumberOfWorkspaces() - 1) dest++;
+ else dest = 0;
+ }
+ if (! warp)
+ return false;
+
+ endMove();
+ bool focus = flags.focused; // had focus while moving?
+ if (! flags.stuck)
+ screen->reassociateWindow(this, dest, False);
+ screen->changeWorkspaceID(dest);
+ if (focus)
+ setInputFocus();
+
+ /*
+ We grab the X server here because we are moving the window and then the
+ mouse cursor. When one moves, it could end up putting the mouse cursor
+ over another window for a moment. This can cause the warp to iniate a
+ move on another window.
+ */
+ XGrabServer(blackbox->getXDisplay());
+ int dest_x;
+ if (x_root <= 0) {
+ dest_x = screen->getRect().right() - 1;
+ configure(dx + (screen->getRect().width() - 1), dy,
+ frame.rect.width(), frame.rect.height());
+ } else {
+ dest_x = 0;
+ configure(dx - (screen->getRect().width() - 1), dy,
+ frame.rect.width(), frame.rect.height());
+ }
+ XWarpPointer(blackbox->getXDisplay(), None,
+ screen->getRootWindow(), 0, 0, 0, 0,
+ dest_x, y_root);
+ XUngrabServer(blackbox->getXDisplay());
+
+ beginMove(dest_x, y_root);
+ return true;
+}
+
+
+void BlackboxWindow::doWindowSnapping(int &dx, int &dy) {
+ // how much resistance to edges to provide
+ const int resistance_size = screen->getResistanceSize();
+
+ // how far away to snap
+ const int snap_distance = screen->getSnapThreshold();
+
+ // how to snap windows
+ const int snap_to_windows = screen->getWindowToWindowSnap();
+ const int snap_to_edges = screen->getWindowToEdgeSnap();
+ // the amount of space away from the edge to provide resistance/snap
+ const int snap_offset = screen->getSnapOffset();
+
+ // find the geomeetery where the moving window currently is
+ const Rect &moving = screen->doOpaqueMove() ? frame.rect : frame.changing;
+
+ // window corners
+ const int wleft = dx,
+ wright = dx + frame.rect.width() - 1,
+ wtop = dy,
+ wbottom = dy + frame.rect.height() - 1;
+
+ if (snap_to_windows) {
+ RectList rectlist;
+
+ Workspace *w = screen->getWorkspace(getWorkspaceNumber());
+ assert(w);
+
+ // add windows on the workspace to the rect list
+ const BlackboxWindowList& stack_list = w->getStackingList();
+ BlackboxWindowList::const_iterator st_it, st_end = stack_list.end();
+ for (st_it = stack_list.begin(); st_it != st_end; ++st_it)
+ if (*st_it != this) // don't snap to ourself
+ rectlist.push_back( (*st_it)->frameRect() );
+
+ // add the toolbar and the slit to the rect list.
+ // (only if they are not hidden)
+ Toolbar *tbar = screen->getToolbar();
+ Slit *slit = screen->getSlit();
+ Rect tbar_rect, slit_rect;
+ unsigned int bwidth = screen->getBorderWidth() * 2;
+
+ if (! (screen->doHideToolbar() || tbar->isHidden())) {
+ tbar_rect.setRect(tbar->getX(), tbar->getY(), tbar->getWidth() + bwidth,
+ tbar->getHeight() + bwidth);
+ rectlist.push_back(tbar_rect);
+ }
+
+ if (! slit->isHidden()) {
+ slit_rect.setRect(slit->getX(), slit->getY(), slit->getWidth() + bwidth,
+ slit->getHeight() + bwidth);
+ rectlist.push_back(slit_rect);
+ }