]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
add frame.. wrapper changes.
[chaz/openbox] / src / client.cc
index f564786f24cc0d26b8a1c530151e7ac5d92c8065..1c411adb7893b58bb50a4a3eb688e478d8c160c3 100644 (file)
@@ -60,7 +60,8 @@ Client::Client(int screen, Window window)
   getShaped();
 
   updateProtocols();
-  updateNormalHints();
+  getGravity(); // get the attribute gravity
+  updateNormalHints(); // this may override the attribute gravity
   updateWMHints();
   updateTitle();
   updateIconTitle();
@@ -91,6 +92,17 @@ Client::~Client()
 }
 
 
+void Client::getGravity()
+{
+  XWindowAttributes wattrib;
+  Status ret;
+
+  ret = XGetWindowAttributes(**otk::display, _window, &wattrib);
+  assert(ret != BadWindow);
+  _gravity = wattrib.win_gravity;
+}
+
+
 void Client::getDesktop()
 {
   // defaults to the current desktop
@@ -339,7 +351,7 @@ void Client::calcLayer() {
         if we don't have a frame, then we aren't mapped yet (and this would
         SIGSEGV :)
       */
-      openbox->screen(_screen)->restack(true, this); // raise
+      openbox->screen(_screen)->raiseWindow(this);
     }
   }
 }
@@ -378,7 +390,6 @@ void Client::updateNormalHints()
   int oldgravity = _gravity;
 
   // defaults
-  _gravity = NorthWestGravity;
   _size_inc.setPoint(1, 1);
   _base_size.setPoint(0, 0);
   _min_size.setPoint(0, 0);
@@ -391,8 +402,18 @@ void Client::updateNormalHints()
   if (XGetWMNormalHints(**otk::display, _window, &size, &ret)) {
     _positioned = (size.flags & (PPosition|USPosition));
 
-    if (size.flags & PWinGravity)
+    if (size.flags & PWinGravity) {
       _gravity = size.win_gravity;
+      
+      // if the client has a frame, i.e. has already been mapped and is
+      // changing its gravity
+      if (frame && _gravity != oldgravity) {
+        // move our idea of the client's position based on its new gravity
+        int x, y;
+        frame->frameGravity(x, y);
+        _area.setPos(x, y);
+      }
+    }
 
     if (size.flags & PMinSize)
       _min_size.setPoint(size.min_width, size.min_height);
@@ -406,15 +427,6 @@ void Client::updateNormalHints()
     if (size.flags & PResizeInc)
       _size_inc.setPoint(size.width_inc, size.height_inc);
   }
-
-  // if the client has a frame, i.e. has already been mapped and is
-  // changing its gravity
-  if (frame && _gravity != oldgravity) {
-    // move our idea of the client's position based on its new gravity
-    int x, y;
-    frame->frameGravity(x, y);
-    _area.setPos(x, y);
-  }
 }
 
 
@@ -756,6 +768,7 @@ void Client::toggleClientBorder(bool addborder)
   // reversed.
   int x = _area.x(), y = _area.y();
   switch(_gravity) {
+  default:
   case NorthWestGravity:
   case WestGravity:
   case SouthWestGravity:
@@ -766,8 +779,17 @@ void Client::toggleClientBorder(bool addborder)
     if (addborder) x -= _border_width * 2;
     else           x += _border_width * 2;
     break;
+  case NorthGravity:
+  case SouthGravity:
+  case CenterGravity:
+  case ForgetGravity:
+  case StaticGravity:
+    if (addborder) x -= _border_width;
+    else           x += _border_width;
+    break;
   }
   switch(_gravity) {
+  default:
   case NorthWestGravity:
   case NorthGravity:
   case NorthEastGravity:
@@ -778,8 +800,13 @@ void Client::toggleClientBorder(bool addborder)
     if (addborder) y -= _border_width * 2;
     else           y += _border_width * 2;
     break;
-  default:
-    // no change for StaticGravity etc.
+  case WestGravity:
+  case EastGravity:
+  case CenterGravity:
+  case ForgetGravity:
+  case StaticGravity:
+    if (addborder) y -= _border_width;
+    else           y += _border_width;
     break;
   }
   _area.setPos(x, y);
@@ -856,7 +883,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
       shade(false);
     // XXX: deiconify
     focus();
-    openbox->screen(_screen)->restack(true, this); // raise
+    openbox->screen(_screen)->raiseWindow(this);
   }
 }
 
@@ -1165,13 +1192,13 @@ void Client::configureRequestHandler(const XConfigureRequestEvent &e)
     switch (e.detail) {
     case Below:
     case BottomIf:
-      openbox->screen(_screen)->restack(false, this); // lower
+      openbox->screen(_screen)->lowerWindow(this);
       break;
 
     case Above:
     case TopIf:
     default:
-      openbox->screen(_screen)->restack(true, this); // raise
+      openbox->screen(_screen)->raiseWindow(this);
       break;
     }
   }
This page took 0.024304 seconds and 4 git commands to generate.