From e00c2b784a90d882689d61d042e26aa1caff0212 Mon Sep 17 00:00:00 2001 From: Peter Hercek Date: Tue, 26 Feb 2013 19:28:50 +0100 Subject: [PATCH] fix initial window placement to allow proper head detection and window placement based on apps file * a reasonable initial placement is important for later movements to different heads and correct head detection (required by apps file) * it did not work well in case when (0,0) was not near any head --- src/Window.cc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Window.cc b/src/Window.cc index 12b37c94..1c9c795e 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -217,6 +217,19 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) { win.oplock = false; } +bool isWindowVisibleOnSomeHeadOrScreen(FluxboxWindow const& w) { + int real_x = w.frame().x(); + int real_y = w.frame().y(); + + if (w.screen().hasXinerama()) { // xinerama available => use head info + return (0 != w.screen().getHead(real_x, real_y)); // if visible on some head + } else { // no xinerama available => use screen info + return (real_x >= 0 && real_y >= 0 && + real_x <= (signed) w.screen().width() && + real_y <= (signed) w.screen().height()); // if visible on the screen + } +} + class SetClientCmd:public FbTk::Command { public: explicit SetClientCmd(WinClient &client):m_client(client) { @@ -455,22 +468,16 @@ void FluxboxWindow::init() { m_placed = true; else if (m_client->isTransient() || m_client->normal_hint_flags & (PPosition|USPosition)) { - - int real_x = frame().x(); - int real_y = frame().y(); - - 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; + if (isWindowVisibleOnSomeHeadOrScreen(*this)) + m_placed = true; + } else { + if (!isWindowVisibleOnSomeHeadOrScreen(*this)) { + int cur = screen().getHead(fbWindow()); + move(screen().getHeadX(cur), screen().getHeadY(cur)); + m_placed = false; // allow placement strategy to fix position } - - } else setOnHead(screen().getCurrHead()); + } // we must do this now, or else resizing may not work properly applyDecorations();