From 8f89c86592a27a175f6a104730fa92a81388f4a8 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sun, 3 Jun 2007 23:51:11 +0000
Subject: update menu xinerama settings after moving

---
 ChangeLog        |  4 ++++
 src/FbMenu.cc    | 18 +++++++++++++++++-
 src/FbMenu.hh    |  1 +
 src/FbTk/Menu.hh |  3 ++-
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df0da3b..be50648 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
  (Format: Year/Month/Day)
 Changes for 1.0.0:
+*07/06/04:
+   * Fix submenu placement with xinerama after moving the menu between heads,
+     bug #1479517 (Mark)
+     FbMenu.cc/hh FbTk/Menu.hh
 *07/06/03:
    * Deiconify when automatically tabbing to a minimized window with focus new
      windows on, bug #1716899 (Mark)
diff --git a/src/FbMenu.cc b/src/FbMenu.cc
index bcef502..040a881 100644
--- a/src/FbMenu.cc
+++ b/src/FbMenu.cc
@@ -23,8 +23,10 @@
 
 
 #include "FbMenu.hh"
-#include "MenuTheme.hh"
 
+#include "fluxbox.hh"
+#include "MenuTheme.hh"
+#include "Screen.hh"
 #include "Shape.hh"
 
 FbMenu::FbMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
@@ -54,3 +56,17 @@ void FbMenu::reconfigure() {
     FbTk::Menu::reconfigure();
 }
 
+void FbMenu::buttonReleaseEvent(XButtonEvent &be) {
+    BScreen *screen = Fluxbox::instance()->findScreen(screenNumber());
+    if (be.window == titleWindow() && isMoving() && screen) {
+        // menu stopped moving, so update head
+        int head = screen->getHead(be.x_root, be.y_root);
+        setScreen(screen->getHeadX(head),
+                  screen->getHeadY(head),
+                  screen->getHeadWidth(head),
+                  screen->getHeadHeight(head));
+    }
+
+    // now get on with the show
+    FbTk::Menu::buttonReleaseEvent(be);
+}
diff --git a/src/FbMenu.hh b/src/FbMenu.hh
index cfd49d1..53266bf 100644
--- a/src/FbMenu.hh
+++ b/src/FbMenu.hh
@@ -41,6 +41,7 @@ public:
     void raise() { m_layeritem.raise(); }
     void lower() { m_layeritem.lower(); }
     void reconfigure();
+    void buttonReleaseEvent(XButtonEvent &be);
 private:
     FbTk::XLayerItem m_layeritem;
     std::auto_ptr<Shape> m_shape;
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index c77b0c0..e6c249d 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -104,7 +104,7 @@ public:
     //@{
     void handleEvent(XEvent &event);
     void buttonPressEvent(XButtonEvent &bp);
-    void buttonReleaseEvent(XButtonEvent &br);
+    virtual void buttonReleaseEvent(XButtonEvent &br);
     void motionNotifyEvent(XMotionEvent &mn);
     void exposeEvent(XExposeEvent &ee);
     void keyPressEvent(XKeyEvent &ke);
@@ -138,6 +138,7 @@ public:
 #endif
     inline bool isTorn() const { return m_torn; }
     inline bool isVisible() const { return m_visible; }
+    inline bool isMoving() const { return m_moving; }
     inline int screenNumber() const { return menu.window.screenNumber(); }
     inline Window window() const { return menu.window.window(); }
     inline FbWindow &fbwindow() { return menu.window; }
-- 
cgit v0.11.2