Openbox2 patches

Marc Wilson msw at cox.net
Mon Aug 11 05:53:34 EDT 2003


I may well be the only person still using openbox 2.x in the face of
openbox 3, but such is life.  What's a person to do?

Actually, I swap between them as the mood to fiddle strikes me.

Anyway, here are four patches to the current openbox 2 CVS:

00_ignore-rcs-suffix.patch :

Very simple... I keep my personal styles in RCS.  This stops ob2 from
trying to add them to a [stylesmenu].  I suppose if you were to do it
right, there should be a config option defining a list of extensions to
ignore.  Feel free, I'll be happy to use it instead of my own. :)

01_fix_iconv_string_def.patch :

The current ob 2 CVS has a broken Util.cc (at least on Debian unstable,
it's broken).  This reverts part of a prior change and makes it build
again.

02_xinerama_geom_display.patch :

Openbox 2 supports Xinerama, but imperfectly.  When moving or resizing a
window, the geometry display appears split between the two monitors.  This
makes the geometry display appear centered on the monitor containing the
window being operated on.

03_net_wm_fullscreen-xinerama.patch :

I don't remember who created the patch that gave ob 2 support for
_NET_WM_FULLSCREEN.  Whoever they were, they forgot about Xinerama.  The
unpatched behavior makes a FULLSCREEN window cover both monitors.  This
patch makes it follow the Options >> Xinerama Support >> Window Maximizing
toggle and only take over the monitor the window actually appears on.

Patch #2 adds a compile-time warning about an un-used variable.  The
compiler is right, it *is* unused.  It's there just for completeness...
feel free to delete the un-used Y coordinate or re-work it so that you
don't have to pass the X and Y coordinates of the origin of the window
being operated on into showGeometry().  I tried, my C++ isn't up to it.

Next step... getting menus to respect Xinerama screens.

-- 
 Marc Wilson |     To downgrade the human mind is bad theology.  -
 msw at cox.net |     C. K. Chesterton
-------------- next part --------------
*** src/Screen.cc.orig	2003-06-16 09:46:36.000000000 -0700
--- src/Screen.cc	2003-06-16 09:48:15.000000000 -0700
***************
*** 2336,2341 ****
--- 2336,2345 ----
          if (fname[fname.size()-1] == '~' || fname[0] == '.')
              continue;
  
+         //ignore RCS files
+         if (fname[fname.size()-1] == 'v' && fname[fname.size()-2] == ',')
+             continue;
+ 
          string style = stylesdir;
          style += '/';
          style += fname;
-------------- next part --------------
--- src/Util.cc.orig	2003-08-04 19:07:05.000000000 -0700
+++ src/Util.cc	2003-08-04 19:07:39.000000000 -0700
@@ -267,12 +267,12 @@
 }
 
 #define ICONV_BUFSIZE 2048
-string iconv_string(std::string s, char *to, char *from) {
+string iconv_string(const std::string s, const char *to, const char *from) {
   iconv_t ic;
   static char buf[ICONV_BUFSIZE];
   char *obuf = buf;
   size_t olen = ICONV_BUFSIZE - 1;
-  const char *ibuf = (char *) s.c_str();
+  char *ibuf = (char *) s.c_str();
   size_t ilen = strlen(ibuf);
 
   ic = iconv_open(to, from);
-------------- next part --------------
--- src/Screen.cc.orig	2003-08-04 19:24:27.000000000 -0700
+++ src/Screen.cc	2003-08-04 21:27:18.000000000 -0700
@@ -2413,9 +2417,17 @@
 
 void BScreen::showPosition(int x, int y) {
   if (! geom_visible) {
+#ifdef    XINERAMA
+    int t;
+    t = (getWidth() - geom_w) / 2;
+    XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
+                      (x>t) ? (t+(t/2)) : (t-(t/2)),
+                      (getHeight() - geom_h) / 2, geom_w, geom_h);
+#else
     XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
                       (getWidth() - geom_w) / 2,
                       (getHeight() - geom_h) / 2, geom_w, geom_h);
+#endif
     XMapWindow(blackbox->getXDisplay(), geom_window);
     XRaiseWindow(blackbox->getXDisplay(), geom_window);
 
@@ -2435,12 +2447,21 @@
                                    label, true);
 }
 
-
+#ifdef    XINERAMA
+void BScreen::showGeometry(unsigned int gx, unsigned int gy, int x, int y) {
+  if (! geom_visible) {
+    int t;
+    t = (getWidth() - geom_w) / 2;
+    XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
+                      (x>t) ? (t+(t/2)) : (t-(t/2)),
+                      (getHeight() - geom_h) / 2, geom_w, geom_h);
+#else
 void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
   if (! geom_visible) {
     XMoveResizeWindow(blackbox->getXDisplay(), geom_window,
                       (getWidth() - geom_w) / 2,
                       (getHeight() - geom_h) / 2, geom_w, geom_h);
+#endif
     XMapWindow(blackbox->getXDisplay(), geom_window);
     XRaiseWindow(blackbox->getXDisplay(), geom_window);
 
--- src/Screen.hh.orig	2003-08-04 21:34:17.000000000 -0700
+++ src/Screen.hh	2003-08-04 21:32:06.000000000 -0700
@@ -413,7 +413,11 @@
   void rereadMenu(void);
   void shutdown(void);
   void showPosition(int x, int y);
+#ifdef    XINERAMA
+  void showGeometry(unsigned int gx, unsigned int gy, int x, int y);
+#else
   void showGeometry(unsigned int gx, unsigned int gy);
+#endif
   void hideGeometry(void);
   bool parseMenuFile(FILE *file, Rootmenu *menu);
 
--- src/Window.cc.orig	2003-08-04 21:23:53.000000000 -0700
+++ src/Window.cc	2003-08-04 21:32:44.000000000 -0700
@@ -3843,8 +3843,12 @@
                  screen->getOpGC(), frame.changing.x(), frame.changing.y(),
                  frame.changing.width() - 1, frame.changing.height() - 1);
 
+#ifdef    XINERAMA
+  screen->showGeometry(gw, gh, frame.changing.x(), frame.changing.y());
+#else
   screen->showGeometry(gw, gh);
-  
+#endif
+
   frame.grab_x = x_root;
   frame.grab_y = y_root;
 }
@@ -3902,7 +3906,11 @@
                  screen->getOpGC(), frame.changing.x(), frame.changing.y(),
                  frame.changing.width() - 1, frame.changing.height() - 1);
 
+#ifdef    XINERAMA
+  screen->showGeometry(gw, gh, frame.changing.x(), frame.changing.y());
+#else
   screen->showGeometry(gw, gh);
+#endif
 }
 
 
-------------- next part --------------
--- src/Screen.hh.orig	2003-08-04 21:34:17.000000000 -0700
+++ src/Screen.hh	2003-08-10 19:58:32.000000000 -0700
@@ -154,6 +154,7 @@
   Rect usableArea;
 #ifdef    XINERAMA
   RectList xineramaUsableArea;
+  RectList xineramaUsableRect;
 #endif // XINERAMA
 
   typedef std::list<Strut*> StrutList;
@@ -375,6 +376,7 @@
   const Rect& availableArea(void) const;
 #ifdef    XINERAMA
   const RectList& allAvailableAreas(void) const;
+  const RectList& allAvailableRects(void) const;
 #endif // XINERAMA
   void updateAvailableArea(void);
   void addStrut(Strut *strut);
 
--- src/Screen.cc.orig	2003-08-04 19:24:27.000000000 -0700
+++ src/Screen.cc	2003-08-10 20:04:29.000000000 -0700
@@ -2495,6 +2516,15 @@
           xineramaUsableArea[0].width(), xineramaUsableArea[0].height());
   return xineramaUsableArea;
 }
+
+const RectList& BScreen::allAvailableRects(void) const {
+  assert(isXineramaActive());
+  assert(xineramaUsableRect.size() > 0);
+  fprintf(stderr, "1rect x %d y %d w %d h %d\n",
+          xineramaUsableRect[0].x(), xineramaUsableRect[0].y(),
+          xineramaUsableRect[0].width(), xineramaUsableRect[0].height());
+  return xineramaUsableRect;
+}
 #endif // XINERAMA
 
 
@@ -2506,6 +2536,7 @@
   // reset to the full areas
   if (isXineramaActive())
     xineramaUsableArea = getXineramaAreas();
+    xineramaUsableRect = getXineramaAreas();
 #endif // XINERAMA
 
   /* these values represent offsets from the screen edge
--- src/Window.cc.orig	2003-08-04 21:23:53.000000000 -0700
+++ src/Window.cc	2003-08-10 20:00:59.000000000 -0700
@@ -2101,8 +2101,27 @@
     blackbox_attrib.prefull_h =
       client.rect.height() + frame.margin.top + frame.margin.bottom;
     // go fullscreen
+#ifdef    XINERAMA
+    if (screen->isXineramaActive() && blackbox->doXineramaMaximizing()) {
+      // find the area to use
+      RectList availableAreas = screen->allAvailableRects();
+      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
+
+      client.rect = *it;
+      frame.rect = *it;
+    } else {
+        client.rect = screen->getRect();
+        frame.rect = screen->getRect();
+      }
+#else   
     client.rect = screen->getRect();
     frame.rect = screen->getRect();
+#endif // XINERAMA
     configure(frame.rect.x(), frame.rect.y(),
               frame.rect.width(), frame.rect.height());
     // disbale decorations
 


More information about the openbox mailing list