Openbox2 patch

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


This alters the menu display to make it Xinerama-aware.  It's a bit of a
hack... it assumes that the two monitors match in resolution.  Sorry, mine
do, and I'm lazy.

If they don't, it's non-fatal, the menu just doesn't appear where you think
it will.

-- 
 Marc Wilson |     "Why waste negative entropy on comments, when you
 msw at cox.net |     could use the same entropy to create bugs instead?"
             |     -- Steve Elias
-------------- next part --------------
--- src/Basemenu.cc.orig	2003-08-11 11:57:03.000000000 -0700
+++ src/Basemenu.cc	2003-08-11 12:04:25.000000000 -0700
@@ -494,9 +494,29 @@
       y = (((shifted) ? menu.y_shift : menu.y) +
            menu.height - submenu->menu.height);
 
+#ifdef     XINERAMA
+    if (screen->isXineramaActive()) {
+      int t = x;  // our original position
+      int w = screen->getWidth()/2;  // half of the screen
+    
+      if ( (x + submenu->getWidth()) > w && (x <= w) )
+        t = ((shifted) ? menu.x_shift : menu.x) -
+          submenu->getWidth() - screen->getBorderWidth();
+        
+      if ((x + submenu->getWidth()) > screen->getWidth())
+        t = ((shifted) ? menu.x_shift : menu.x) -
+          submenu->getWidth() - screen->getBorderWidth();
+
+      x = t;
+    } else
+        if ((x + submenu->getWidth()) > screen->getWidth())
+          x = ((shifted) ? menu.x_shift : menu.x) -
+            submenu->getWidth() - screen->getBorderWidth();
+#else
     if ((x + submenu->getWidth()) > screen->getWidth())
       x = ((shifted) ? menu.x_shift : menu.x) -
         submenu->getWidth() - screen->getBorderWidth();
+#endif
 
     if (x < 0) x = 0;
 
--- src/Screen.cc.orig	2003-08-04 19:24:27.000000000 -0700
+++ src/Screen.cc	2003-08-11 12:16:42.000000000 -0700
@@ -2614,8 +2645,25 @@
   if (mx < 0) mx = 0;
   if (my < 0) my = 0;
 
+#ifdef     XINERAMA
+  if (isXineramaActive()) {
+    int t = mx;  // our original position
+    int w = getWidth()/2;  // half of the screen
+  
+    if ( (mx + workspacemenu->getWidth() > w && (mx < w)) )
+      t = (getWidth()/2) - workspacemenu->getWidth() - getBorderWidth();
+
+    if (mx + workspacemenu->getWidth() > getWidth())
+      t = getWidth() - workspacemenu->getWidth() - getBorderWidth();
+
+    mx = t;
+  } else
+      if (mx + workspacemenu->getWidth() > getWidth())
+        mx = getWidth() - workspacemenu->getWidth() - getBorderWidth();
+#else
   if (mx + workspacemenu->getWidth() > getWidth())
     mx = getWidth() - workspacemenu->getWidth() - getBorderWidth();
+#endif
 
   if (my + workspacemenu->getHeight() > getHeight())
     my = getHeight() - workspacemenu->getHeight() - getBorderWidth();
@@ -2632,16 +2680,32 @@
 void BScreen::showRootMenu(int x, int y) {
   int mx = x - (rootmenu->getWidth() / 2);
   int my = y - (rootmenu->getTitleHeight() / 2);
-
+  
   if (mx < 0) mx = 0;
   if (my < 0) my = 0;
 
+#ifdef     XINERAMA
+  if (isXineramaActive()) {
+    int t = mx;  // our original position
+    int w = getWidth()/2;  // half of the screen
+  
+    if ( (mx + rootmenu->getWidth() > w && (mx < w)) )
+      t = (getWidth()/2) - rootmenu->getWidth() - getBorderWidth();
+
+    if (mx + rootmenu->getWidth() > getWidth())
+      t = getWidth() - rootmenu->getWidth() - getBorderWidth();
+
+    mx = t;
+  } else
+      if (mx + rootmenu->getWidth() > getWidth())
+        mx = getWidth() - rootmenu->getWidth() - getBorderWidth();
+#else
   if (mx + rootmenu->getWidth() > getWidth())
     mx = getWidth() - rootmenu->getWidth() - getBorderWidth();
+#endif
 
   if (my + rootmenu->getHeight() > getHeight())
     my = getHeight() - rootmenu->getHeight() - getBorderWidth();
-
   rootmenu->move(mx, my);
 
   if (! rootmenu->isVisible()) {


More information about the openbox mailing list