Ok, here's another one that shaleh says is never gonna make it into
blackbox...

I like being able to rearrange the buttons, or for that matter, delete
them.  So I re-did this one for 0.62.1.  It's not pretty, it doesn't
particularly follow shaleh's idea of proper coding (he's bracket happy), it
just works.

It adds a resource to your .blackboxrc like so:

session.titlebarLayout: LIMC

where:  L == window label
        I == iconify button
        M == maximize button
        C == close button

If you don't have it already there, it defaults it to the standard blackbox
arrangement (that being 'ILMC') and adds it for you.  If you want to leave
a button out, you can edit .blackboxrc yourself and do so. ^_^

Please note that I did *NOT* create the patch, nor am I claiming credit for
it.  I merely want to use it. ^_^

(ok, now I get to work on taskbar_menu, which is the OTHER one I want to
use, and which makes mouse_wheel unnecessary...)

-- 
Marc Wilson
[EMAIL PROTECTED]
http://members.cox.net/msw

diff -urN blackbox-0.62.1.orig/configure blackbox-0.62.1/configure
--- blackbox-0.62.1.orig/configure      Fri Jan 25 02:50:25 2002
+++ blackbox-0.62.1/configure   Sat Mar  2 20:11:11 2002
@@ -714,7 +714,7 @@
 
 PACKAGE=blackbox
 
-VERSION=0.62.1pre0
+VERSION=0.62.1
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { echo "configure: error: source directory already configured; run "make distclean" 
there first" 1>&2; exit 1; }
diff -urN blackbox-0.62.1.orig/configure.in blackbox-0.62.1/configure.in
--- blackbox-0.62.1.orig/configure.in   Fri Jan 25 02:50:18 2002
+++ blackbox-0.62.1/configure.in        Sat Mar  2 20:11:39 2002
@@ -1,7 +1,7 @@
 dnl configure.in for Blackbox - an X11 Window manager
 dnl Initialize autoconf and automake
 AC_INIT(src/blackbox.cc)
-AM_INIT_AUTOMAKE(blackbox,0.62.1pre0,no-define)
+AM_INIT_AUTOMAKE(blackbox,0.62.1,no-define)
 
 dnl Determine default prefix
 test x$prefix = "xNONE" && prefix="$ac_default_prefix"
diff -urN blackbox-0.62.1.orig/src/Window.cc blackbox-0.62.1/src/Window.cc
--- blackbox-0.62.1.orig/src/Window.cc  Sat Jan 19 08:06:30 2002
+++ blackbox-0.62.1/src/Window.cc       Sat Mar  2 20:05:25 2002
@@ -741,50 +741,103 @@
 
 
 void BlackboxWindow::positionButtons(Bool redecorate_label) {
-  unsigned int bw = frame.button_w + frame.bevel_w + 1,
-    by = frame.bevel_w + 1, lx = by, lw = frame.width - by;
+  char *format = (char *) blackbox->getTitleBarLayout();
 
-  if (decorations.iconify && frame.iconify_button != None) {
-    XMoveResizeWindow(display, frame.iconify_button, by, by,
-                     frame.button_w, frame.button_h);
-    XMapWindow(display, frame.iconify_button);
-    XClearWindow(display, frame.iconify_button);
-
-    lx += bw;
-    lw -= bw;
-  } else if (frame.iconify_button) {
-    XUnmapWindow(display, frame.iconify_button);
+  unsigned int x = 0;
+  unsigned int ty = frame.bevel_w + 1;
+  unsigned int tx = frame.bevel_w + 1;
+  unsigned int bw = frame.button_w + frame.bevel_w + 1;
+  unsigned int bc = strlen(format) - 1;
+
+  if (!decorations.close) bc -= 1;
+  if (!decorations.iconify) bc -= 1;
+  if (!decorations.maximize) bc -= 1;
+
+  frame.label_w = frame.width - (bc * bw) - (2 * frame.bevel_w) - 1;
+
+  while (&format[x] != "" && x <= 3) {
+    switch(format[x++]){
+      case 'C':
+       {
+         tx += BlackboxWindow::positionCloseButton(tx,ty);
+         break;
+       }
+      case 'I':
+       {
+         tx += BlackboxWindow::positionIconifyButton(tx,ty);
+         break;
+       }   
+      case 'M':
+       {
+         tx += BlackboxWindow::positionMaximizeButton(tx,ty);
+         break;
+       }
+      case 'L':
+       {
+         tx += BlackboxWindow::positionLabel(tx,ty);
+         break;
+       } 
+    }
   }
-  int bx = frame.width - bw;
+
+  if (redecorate_label) decorateLabel();
+  redrawLabel();
+  redrawAllButtons();
+
+
+}
+
+
+unsigned int BlackboxWindow::positionCloseButton(unsigned int tx, unsigned int ty) {
 
   if (decorations.close && frame.close_button != None) {
-    XMoveResizeWindow(display, frame.close_button, bx, by,
-                     frame.button_w, frame.button_h);
+    XMoveResizeWindow(display, frame.close_button, tx, ty, frame.button_w, 
+frame.button_h);
     XMapWindow(display, frame.close_button);
     XClearWindow(display, frame.close_button);
+    return frame.button_w + frame.bevel_w + 1;
 
-    bx -= bw;
-    lw -= bw;
   } else if (frame.close_button) {
     XUnmapWindow(display, frame.close_button);
+    return 0;
+  }    
+    
+}  
+
+unsigned int BlackboxWindow::positionIconifyButton(unsigned int tx, unsigned int ty) {
+  
+  if (decorations.iconify && frame.iconify_button != None) {
+    XMoveResizeWindow(display, frame.iconify_button, tx, ty, frame.button_w, 
+frame.button_h);
+    XMapWindow(display, frame.iconify_button);
+    XClearWindow(display, frame.iconify_button);
+    return frame.button_w + frame.bevel_w + 1;
+
+  } else if (frame.iconify_button) {
+    XUnmapWindow(display, frame.iconify_button);
+    return 0;
   }
+
+}
+
+unsigned int BlackboxWindow::positionMaximizeButton(unsigned int tx, unsigned int ty) 
+{
+  
   if (decorations.maximize && frame.maximize_button != None) {
-    XMoveResizeWindow(display, frame.maximize_button, bx, by,
-                     frame.button_w, frame.button_h);
+    XMoveResizeWindow(display, frame.maximize_button, tx, ty, frame.button_w, 
+frame.button_h);
     XMapWindow(display, frame.maximize_button);
     XClearWindow(display, frame.maximize_button);
+    return frame.button_w + frame.bevel_w + 1;
 
-    lw -= bw;
   } else if (frame.maximize_button) {
     XUnmapWindow(display, frame.maximize_button);
-  }
-  frame.label_w = lw - by;
-  XMoveResizeWindow(display, frame.label, lx, frame.bevel_w,
-                    frame.label_w, frame.label_h);
-  if (redecorate_label) decorateLabel();
+    return 0;
+  }   
+   
+} 
+
+unsigned int BlackboxWindow::positionLabel(unsigned int tx, unsigned int ty) {
+
+  XMoveResizeWindow(display, frame.label, tx, ty - 1, frame.label_w, frame.label_h);
+  return frame.label_w + frame.bevel_w + 1;
 
-  redrawLabel();
-  redrawAllButtons();
 }
 
 
diff -urN blackbox-0.62.1.orig/src/Window.hh blackbox-0.62.1/src/Window.hh
--- blackbox-0.62.1.orig/src/Window.hh  Sat Dec 29 23:00:19 2001
+++ blackbox-0.62.1/src/Window.hh       Sat Mar  2 19:46:37 2002
@@ -210,7 +210,14 @@
   void associateClientWindow(void);
   void decorate(void);
   void decorateLabel(void);
+
   void positionButtons(Bool redecorate_label = False);
+  unsigned int BlackboxWindow::positionCloseButton(unsigned int tx, unsigned int ty);
+  unsigned int BlackboxWindow::positionMaximizeButton(unsigned int tx, unsigned int 
+ty);
+  unsigned int BlackboxWindow::positionIconifyButton(unsigned int tx, unsigned int 
+ty);
+  unsigned int BlackboxWindow::positionLabel(unsigned int tx, unsigned int ty);
+
+
   void positionWindows(void);
   void createCloseButton(void);
   void createIconifyButton(void);
diff -urN blackbox-0.62.1.orig/src/blackbox.cc blackbox-0.62.1/src/blackbox.cc
--- blackbox-0.62.1.orig/src/blackbox.cc        Sat Jan 12 03:17:26 2002
+++ blackbox-0.62.1/src/blackbox.cc     Sat Mar  2 20:10:05 2002
@@ -161,7 +161,7 @@
 
   no_focus = False;
 
-  resource.menu_file = resource.style_file = (char *) 0;
+  resource.menu_file = resource.style_file = resource.titlebar_layout = (char *) 0;
   resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
 
   focused_window = masked_window = (BlackboxWindow *) 0;
@@ -1161,6 +1161,10 @@
     delete [] save_string;
   }
 
+  sprintf(rc_string, "session.titlebarLayout:  %s",
+          resource.titlebar_layout);
+  XrmPutLineResource(&new_blackboxrc, rc_string);
+
   XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile);
 
   XrmMergeDatabases(new_blackboxrc, &old_blackboxrc);
@@ -1259,6 +1263,12 @@
       resource.cache_max = 200;
   } else {
     resource.cache_max = 200;
+  }
+  if (XrmGetResource(database, "session.titlebarLayout", "Session.TitlebarLayout",
+                     &value_type, &value)) {
+    resource.titlebar_layout = bstrdup(value.addr);
+  } else {
+    resource.titlebar_layout = bstrdup("ILMC");
   }
 }
 
diff -urN blackbox-0.62.1.orig/src/blackbox.hh blackbox-0.62.1/src/blackbox.hh
--- blackbox-0.62.1.orig/src/blackbox.hh        Sat Dec 29 23:11:38 2001
+++ blackbox-0.62.1/src/blackbox.hh     Sat Mar  2 19:46:12 2002
@@ -81,7 +81,7 @@
   struct resource {
     Time double_click_interval;
 
-    char *menu_file, *style_file;
+    char *menu_file, *style_file, *titlebar_layout;
     int colors_per_channel;
     timeval auto_raise_delay;
     unsigned long cache_life, cache_max;
@@ -159,6 +159,9 @@
 
   inline const timeval &getAutoRaiseDelay(void) const
     { return resource.auto_raise_delay; }
+
+  inline const char *getTitleBarLayout(void) const
+    { return resource.titlebar_layout; }
 
   inline const unsigned long &getCacheLife(void) const
     { return resource.cache_life; }

Reply via email to