]> Dogcows Code - chaz/openbox/blobdiff - src/Window.cc
fix for changing window buttons order. destroy them properly when they no longer...
[chaz/openbox] / src / Window.cc
index ec042c305ae77e80cb253bdddbb40d7f9ed4afd7..fe13f4c1771fa05e37502b9dc8dfc51f6402e1d2 100644 (file)
@@ -538,24 +538,6 @@ void OpenboxWindow::associateClientWindow(void) {
   if (decorations.iconify) createIconifyButton();
   if (decorations.maximize) createMaximizeButton();
   if (decorations.close) createCloseButton();
-
-  if (frame.ubutton) {
-    if (frame.close_button)
-      XSetWindowBackgroundPixmap(display, frame.close_button, frame.ubutton);
-    if (frame.maximize_button)
-      XSetWindowBackgroundPixmap(display, frame.maximize_button,
-                                frame.ubutton);
-    if (frame.iconify_button)
-      XSetWindowBackgroundPixmap(display, frame.iconify_button, frame.ubutton);
-  } else {
-    if (frame.close_button)
-      XSetWindowBackground(display, frame.close_button, frame.ubutton_pixel);
-    if (frame.maximize_button)
-      XSetWindowBackground(display, frame.maximize_button,
-                          frame.ubutton_pixel);
-    if (frame.iconify_button)
-      XSetWindowBackground(display, frame.iconify_button, frame.ubutton_pixel);
-  }
 }
 
 
@@ -760,37 +742,40 @@ void OpenboxWindow::positionButtons(Bool redecorate_label) {
   for (int i = 0; format[i] != '\0' && i < 4; i++) {
     switch(format[i]) {
     case 'C':
-      if (decorations.close && frame.close_button != None) {
+      if (decorations.close) {
+        if (frame.close_button == None)
+          createCloseButton();
         XMoveResizeWindow(display, frame.close_button, bx, by,
                           frame.button_w, frame.button_h);
         XMapWindow(display, frame.close_button);
         XClearWindow(display, frame.close_button);
         bx += frame.button_w + bw;
         hasclose = true;
-      } else if (frame.close_button)
-        XUnmapWindow(display, frame.close_button);
+      }
       break;
     case 'I':
-      if (decorations.iconify && frame.iconify_button != None) {
+      if (decorations.iconify) {
+        if (frame.iconify_button == None)
+          createIconifyButton();
         XMoveResizeWindow(display, frame.iconify_button, bx, by,
                           frame.button_w, frame.button_h);
         XMapWindow(display, frame.iconify_button);
         XClearWindow(display, frame.iconify_button);
         bx += frame.button_w + bw;
         hasiconify = true;
-      } else if (frame.close_button)
-        XUnmapWindow(display, frame.close_button);
+      }
       break;
     case 'M':
-      if (decorations.maximize && frame.maximize_button != None) {
+      if (decorations.maximize) {
+        if (frame.maximize_button == None)
+          createMaximizeButton();
         XMoveResizeWindow(display, frame.maximize_button, bx, by,
                           frame.button_w, frame.button_h);
         XMapWindow(display, frame.maximize_button);
         XClearWindow(display, frame.maximize_button);
         bx += frame.button_w + bw;
         hasmaximize = true;
-      } else if (frame.close_button)
-        XUnmapWindow(display, frame.close_button);
+      }
       break;
     case 'L':
       XMoveResizeWindow(display, frame.label, bx, by - 1,
@@ -802,15 +787,18 @@ void OpenboxWindow::positionButtons(Bool redecorate_label) {
 
   if (!hasclose) {
       openbox.removeWindowSearch(frame.close_button);
-      XDestroyWindow(display, frame.close_button);     
+      XDestroyWindow(display, frame.close_button);
+      frame.close_button = None;
   }
   if (!hasiconify) {
       openbox.removeWindowSearch(frame.iconify_button);
       XDestroyWindow(display, frame.iconify_button);
+      frame.iconify_button = None;
   }
   if (!hasmaximize) {
       openbox.removeWindowSearch(frame.maximize_button);
       XDestroyWindow(display, frame.maximize_button);                 
+      frame.maximize_button = None;
   }
   if (redecorate_label)
     decorateLabel();
@@ -1353,7 +1341,7 @@ void OpenboxWindow::configure(int dx, int dy,
 }
 
 
-Bool OpenboxWindow::setInputFocus(void) {
+bool OpenboxWindow::setInputFocus(void) {
   if (((signed) (frame.x + frame.width)) < 0) {
     if (((signed) (frame.y + frame.y_border)) < 0)
       configure(frame.border_w, frame.border_w, frame.width, frame.height);
@@ -1378,39 +1366,36 @@ Bool OpenboxWindow::setInputFocus(void) {
   openbox.grab();
   if (! validateClient()) return False;
 
-  Bool ret = False;
+  bool ret = false;
 
   if (client.transient && flags.modal) {
     ret = client.transient->setInputFocus();
   } else if (! flags.focused) {
-    if (focus_mode == F_LocallyActive || focus_mode == F_Passive)
+    if (focus_mode == F_LocallyActive || focus_mode == F_Passive) {
       XSetInputFocus(display, client.window,
                       RevertToPointerRoot, CurrentTime);
-    else
-      XSetInputFocus(display, screen->getRootWindow(),
-                    RevertToNone, CurrentTime);
-
-    openbox.focusWindow(this);
-
-    if (flags.send_focus_message) {
-      XEvent ce;
-      ce.xclient.type = ClientMessage;
-      ce.xclient.message_type = openbox.getWMProtocolsAtom();
-      ce.xclient.display = display;
-      ce.xclient.window = client.window;
-      ce.xclient.format = 32;
-      ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
-      ce.xclient.data.l[1] = openbox.getLastTime();
-      ce.xclient.data.l[2] = 0l;
-      ce.xclient.data.l[3] = 0l;
-      ce.xclient.data.l[4] = 0l;
-      XSendEvent(display, client.window, False, NoEventMask, &ce);
-    }
+      openbox.focusWindow(this);
+
+      if (flags.send_focus_message) {
+        XEvent ce;
+        ce.xclient.type = ClientMessage;
+        ce.xclient.message_type = openbox.getWMProtocolsAtom();
+        ce.xclient.display = display;
+        ce.xclient.window = client.window;
+        ce.xclient.format = 32;
+        ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
+        ce.xclient.data.l[1] = openbox.getLastTime();
+        ce.xclient.data.l[2] = 0l;
+        ce.xclient.data.l[3] = 0l;
+        ce.xclient.data.l[4] = 0l;
+        XSendEvent(display, client.window, False, NoEventMask, &ce);
+      }
 
-    if (screen->sloppyFocus() && screen->autoRaise())
-      timer->start();
+      if (screen->sloppyFocus() && screen->autoRaise())
+        timer->start();
 
-    ret = True;
+      ret = true;
+    }
   }
 
   openbox.ungrab();
@@ -1629,6 +1614,7 @@ void OpenboxWindow::maximize(unsigned int button) {
 
 
 void OpenboxWindow::setWorkspace(int n) {
+  ASSERT(n < screen->getWorkspaceCount());
   workspace_number = n;
 
   openbox_attrib.flags |= AttribWorkspace;
@@ -3015,7 +3001,7 @@ void OpenboxWindow::shapeEvent(XShapeEvent *) {
 #endif // SHAPE
 
 
-Bool OpenboxWindow::validateClient(void) {
+bool OpenboxWindow::validateClient(void) {
   XSync(display, False);
 
   XEvent e;
@@ -3024,10 +3010,10 @@ Bool OpenboxWindow::validateClient(void) {
     XPutBackEvent(display, &e);
     openbox.ungrab();
 
-    return False;
+    return false;
   }
 
-  return True;
+  return true;
 }
 
 
This page took 0.024177 seconds and 4 git commands to generate.