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
This commit is contained in:
Peter Hercek 2013-02-26 19:28:50 +01:00 committed by Mathias Gumz
parent 5e3217441a
commit e00c2b784a

View file

@ -217,6 +217,19 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) {
win.oplock = false; 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<void> { class SetClientCmd:public FbTk::Command<void> {
public: public:
explicit SetClientCmd(WinClient &client):m_client(client) { explicit SetClientCmd(WinClient &client):m_client(client) {
@ -455,22 +468,16 @@ void FluxboxWindow::init() {
m_placed = true; m_placed = true;
else if (m_client->isTransient() || else if (m_client->isTransient() ||
m_client->normal_hint_flags & (PPosition|USPosition)) { m_client->normal_hint_flags & (PPosition|USPosition)) {
if (isWindowVisibleOnSomeHeadOrScreen(*this))
int real_x = frame().x(); m_placed = true;
int real_y = frame().y(); } else {
if (!isWindowVisibleOnSomeHeadOrScreen(*this)) {
if (screen().hasXinerama()) { // xinerama available => use head info int cur = screen().getHead(fbWindow());
if (0 != screen().getHead(real_x, real_y)) // if visible on some head move(screen().getHeadX(cur), screen().getHeadY(cur));
m_placed = true; m_placed = false; // allow placement strategy to fix position
} 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()); setOnHead(screen().getCurrHead());
}
// we must do this now, or else resizing may not work properly // we must do this now, or else resizing may not work properly
applyDecorations(); applyDecorations();