From 60a53113e05db443af4d520883ec3145680642a8 Mon Sep 17 00:00:00 2001
From: Peter Hercek <hercek@users.sourceforge.net>
Date: Sun, 29 Jul 2012 00:00:59 +0200
Subject: fix sanity check for transient and explicitly placed windows

When a screen has more heads and some part of the screen is not on any
head and some window is placed into this invisible area then the window
is invisible which sucks. This patch repositions such windows so that
they are visible.
Example:
* head 1 is at (0,120) (size 640x480)
* head 2 is at (480,0) (size 800x600)
* whole screen virtual size is 1440x600
* that means rectangle from (0,0) to (640,120) is not visible on any head
  and any windows placed there would not be visible; for example wireshark
  likes to place dialog boxes at (0,0)
---
 src/Window.cc | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/Window.cc b/src/Window.cc
index 747c909..597bc08 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -446,11 +446,15 @@ void FluxboxWindow::init() {
         int real_x = frame().x();
         int real_y = frame().y();
 
-        if (real_x >= 0 &&
-            real_y >= 0 &&
-            real_x <= (signed) screen().width() &&
-            real_y <= (signed) screen().height())
-            m_placed = true;
+        if (screen().hasXinerama()) { // xinerama available => use head info
+            if (0 != screen().getHead(real_x, real_y)) // if visible on some head
+                m_placed = true;
+        } else { // no xinerama available => use screen info
+            if (real_x >= 0 && real_y >= 0 &&
+                real_x <= (signed) screen().width() &&
+                real_y <= (signed) screen().height()) // if visible on the screen
+                m_placed = true;
+        }
 
     } else
         setOnHead(screen().getCurrHead());
-- 
cgit v0.11.2