]> Dogcows Code - chaz/openbox/blobdiff - src/Window.cc
no more segging when adding removing windows
[chaz/openbox] / src / Window.cc
index 722409f97ca7d0d1ea0fc183cc6638b53929c782..b13002d6ae2a86a19d49e1d85602a6efdbf6098f 100644 (file)
@@ -347,10 +347,6 @@ BlackboxWindow::~BlackboxWindow(void) {
   if (flags.moving)
     endMove();
 
-  delete timer;
-
-  delete windowmenu;
-
   if (client.window_group) {
     BWindowGroup *group = blackbox->searchGroup(client.window_group);
     if (group) group->removeWindow(this);
@@ -381,6 +377,10 @@ BlackboxWindow::~BlackboxWindow(void) {
     }
   }
 
+  delete timer;
+
+  delete windowmenu;
+
   if (frame.title)
     destroyTitlebar();
 
@@ -2962,6 +2962,59 @@ void BlackboxWindow::doMove(int x_root, int y_root) {
   dx -= frame.border_w;
   dy -= frame.border_w;
 
+  if (screen->doWorkspaceWarping()) {
+    // 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) {
+      endMove();
+      bool focus = flags.focused; // had focus while moving?
+      if (! flags.stuck)
+        screen->reassociateWindow(this, dest, False);
+      screen->changeWorkspaceID(dest);
+      if (focus)
+        setInputFocus();
+
+      /*
+         If the XWarpPointer is done after the configure, we can end up
+         grabbing another window, so made sure you do it first.
+         */
+      int dest_x;
+      if (x_root <= 0) {
+        dest_x = screen->getRect().right() - 1;
+        XWarpPointer(blackbox->getXDisplay(), None, 
+                     screen->getRootWindow(), 0, 0, 0, 0,
+                     dest_x, y_root);
+
+        configure(dx + (screen->getRect().width() - 1), dy,
+                  frame.rect.width(), frame.rect.height());
+      } else {
+        dest_x = 0;
+        XWarpPointer(blackbox->getXDisplay(), None, 
+                     screen->getRootWindow(), 0, 0, 0, 0,
+                     dest_x, y_root);
+
+        configure(dx - (screen->getRect().width() - 1), dy,
+                  frame.rect.width(), frame.rect.height());
+      }
+
+      beginMove(dest_x, y_root);
+      return;
+    }
+  }
+
   const int snap_distance = screen->getEdgeSnapThreshold();
 
   if (snap_distance) {
This page took 0.023964 seconds and 4 git commands to generate.