]> Dogcows Code - chaz/openbox/blobdiff - src/Window.cc
including wrong
[chaz/openbox] / src / Window.cc
index 316bbf1ae4127918743994b8e1d47f6e8c2632c2..722409f97ca7d0d1ea0fc183cc6638b53929c782 100644 (file)
@@ -59,6 +59,11 @@ extern "C" {
 
 using std::string;
 
+// change this to change what modifier keys openbox uses for mouse bindings
+// for example: Mod1Mask | ControlMask
+//          or: ControlMask| ShiftMask
+const unsigned int ModMask = Mod1Mask;
+
 /*
  * Initializes the class with default values/the window's set initial values.
  */
@@ -356,9 +361,18 @@ BlackboxWindow::~BlackboxWindow(void) {
     if (client.transient_for != (BlackboxWindow *) ~0ul) {
       client.transient_for->client.transientList.remove(this);
     }
-    client.transient_for = (BlackboxWindow*) 0;
+    // we save our transient_for though because the workspace will use it
+    // when determining the next window to get focus
   }
 
+  if (blackbox_attrib.workspace != BSENTINEL &&
+      window_number != BSENTINEL)
+    screen->getWorkspace(blackbox_attrib.workspace)->removeWindow(this);
+  else if (flags.iconic)
+    screen->removeIcon(this);
+
+  client.transient_for = (BlackboxWindow*) 0;
+
   if (client.transientList.size() > 0) {
     // reset transient_for for all transients
     BlackboxWindowList::iterator it, end = client.transientList.end();
@@ -826,17 +840,17 @@ void BlackboxWindow::grabButtons(void) {
                          screen->allowScrollLock());
   
   if (functions & Func_Move)
-    blackbox->grabButton(Button1, Mod1Mask, frame.window, True,
+    blackbox->grabButton(Button1, ModMask, frame.window, True,
                          ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
                          GrabModeAsync, frame.window, None,
                          screen->allowScrollLock());
   if (functions & Func_Resize)
-    blackbox->grabButton(Button3, Mod1Mask, frame.window, True,
+    blackbox->grabButton(Button3, ModMask, frame.window, True,
                          ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
                          GrabModeAsync, frame.window, None,
                          screen->allowScrollLock());
   // alt+middle lowers the window
-  blackbox->grabButton(Button2, Mod1Mask, frame.window, True,
+  blackbox->grabButton(Button2, ModMask, frame.window, True,
                        ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
                        frame.window, None,
                        screen->allowScrollLock());
@@ -847,9 +861,9 @@ void BlackboxWindow::ungrabButtons(void) {
   if ((! screen->isSloppyFocus()) || screen->doClickRaise())
     blackbox->ungrabButton(Button1, 0, frame.plate);
 
-  blackbox->ungrabButton(Button1, Mod1Mask, frame.window);
-  blackbox->ungrabButton(Button2, Mod1Mask, frame.window);
-  blackbox->ungrabButton(Button3, Mod1Mask, frame.window);
+  blackbox->ungrabButton(Button1, ModMask, frame.window);
+  blackbox->ungrabButton(Button2, ModMask, frame.window);
+  blackbox->ungrabButton(Button3, ModMask, frame.window);
 }
 
 
@@ -1792,8 +1806,21 @@ void BlackboxWindow::maximize(unsigned int button) {
   blackbox_attrib.premax_h =
     client.rect.height() + frame.margin.top + frame.margin.bottom;
 
-  const Rect &screen_area = screen->availableArea();
-  frame.changing = screen_area;
+#ifdef    XINERAMA
+  if (screen->isXineramaActive() && blackbox->doXineramaMaximizing()) {
+    // find the area to use
+    RectList availableAreas = screen->allAvailableAreas();
+    RectList::iterator it, end = availableAreas.end();
+
+    for (it = availableAreas.begin(); it != end; ++it)
+      if (it->intersects(frame.rect)) break;
+    if (it == end) // the window isn't inside an area
+      it = availableAreas.begin(); // so just default to the first one
+
+    frame.changing = *it;
+  } else
+#endif // XINERAMA
+  frame.changing = screen->availableArea();
 
   switch(button) {
   case 1:
@@ -2749,7 +2776,7 @@ void BlackboxWindow::buttonPressEvent(const XButtonEvent *be) {
 
   if (frame.maximize_button == be->window && be->button <= 3) {
     redrawMaximizeButton(True);
-  } else if (be->button == 1 || (be->button == 3 && be->state == Mod1Mask)) {
+  } else if (be->button == 1 || (be->button == 3 && be->state == ModMask)) {
     if (! flags.focused)
       setInputFocus();
 
@@ -2875,7 +2902,7 @@ void BlackboxWindow::buttonReleaseEvent(const XButtonEvent *re) {
   } else if (flags.resizing) {
     endResize();
   } else if (re->window == frame.window) {
-    if (re->button == 2 && re->state == Mod1Mask)
+    if (re->button == 2 && re->state == ModMask)
       XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
   }
 }
@@ -3022,48 +3049,58 @@ void BlackboxWindow::doMove(int x_root, int y_root) {
       }
     }
 
-    // try snap to the screen's available area
-    Rect srect = screen->availableArea();
-
-    int dleft = std::abs(wleft - srect.left()),
-       dright = std::abs(wright - srect.right()),
-         dtop = std::abs(wtop - srect.top()),
-      dbottom = std::abs(wbottom - srect.bottom());
-
-    // snap left?
-    if (dleft < snap_distance && dleft <= dright)
-      dx = srect.left();
-    // snap right?
-    else if (dright < snap_distance)
-      dx = srect.right() - frame.rect.width() + 1;
-
-    // snap top?
-    if (dtop < snap_distance && dtop <= dbottom)
-      dy = srect.top();
-    // snap bottom?
-    else if (dbottom < snap_distance)
-      dy = srect.bottom() - frame.rect.height() + 1;
-
-    srect = screen->getRect(); // now get the full screen
-
-    dleft = std::abs(wleft - srect.left()),
-      dright = std::abs(wright - srect.right()),
-      dtop = std::abs(wtop - srect.top()),
-      dbottom = std::abs(wbottom - srect.bottom());
-
-    // snap left?
-    if (dleft < snap_distance && dleft <= dright)
-      dx = srect.left();
-    // snap right?
-    else if (dright < snap_distance)
-      dx = srect.right() - frame.rect.width() + 1;
-
-    // snap top?
-    if (dtop < snap_distance && dtop <= dbottom)
-      dy = srect.top();
-    // snap bottom?
-    else if (dbottom < snap_distance)
-      dy = srect.bottom() - frame.rect.height() + 1;
+    RectList snaplist; // the list of rects we will try to snap to
+
+    // snap to the strut (and screen boundaries for xinerama)
+#ifdef    XINERAMA
+    if (screen->isXineramaActive() && blackbox->doXineramaSnapping()) {
+      if (! screen->doFullMax())
+        snaplist.insert(snaplist.begin(),
+                        screen->allAvailableAreas().begin(),
+                        screen->allAvailableAreas().end());
+
+      // always snap to the screen edges
+      snaplist.insert(snaplist.begin(),
+                      screen->getXineramaAreas().begin(),
+                      screen->getXineramaAreas().end());
+    } else
+#endif // XINERAMA
+    {
+      if (! screen->doFullMax())
+        snaplist.push_back(screen->availableArea());
+
+      // always snap to the screen edges
+      snaplist.push_back(screen->getRect());
+    }
+
+    RectList::const_iterator it, end = snaplist.end();
+    for (it = snaplist.begin(); it != end; ++it) {
+      const Rect &srect = *it;
+
+      // if we're not in the rectangle then don't snap to it.
+      if (! srect.intersects(Rect(wleft, wtop, frame.rect.width(),
+                                  frame.rect.height())))
+        continue;
+
+      int dleft = std::abs(wleft - srect.left()),
+         dright = std::abs(wright - srect.right()),
+           dtop = std::abs(wtop - srect.top()),
+        dbottom = std::abs(wbottom - srect.bottom());
+
+        // snap left?
+        if (dleft < snap_distance && dleft <= dright)
+          dx = srect.left();
+        // snap right?
+        else if (dright < snap_distance)
+          dx = srect.right() - frame.rect.width() + 1;
+
+        // snap top?
+        if (dtop < snap_distance && dtop <= dbottom)
+          dy = srect.top();
+        // snap bottom?
+        else if (dbottom < snap_distance)
+          dy = srect.bottom() - frame.rect.height() + 1;
+    }
   }
 
   if (screen->doOpaqueMove()) {
@@ -3292,7 +3329,7 @@ void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) {
     } else if ((functions & Func_Resize) &&
                (me->state & Button1Mask && (me->window == frame.right_grip ||
                                             me->window == frame.left_grip)) ||
-               (me->state & Button3Mask && me->state & Mod1Mask &&
+               (me->state & Button3Mask && me->state & ModMask &&
                 me->window == frame.window)) {
       unsigned int zones = screen->getResizeZones();
       Corner corner;
This page took 0.024789 seconds and 4 git commands to generate.