diff options
author | Peter Hercek <hercek@users.sourceforge.net> | 2013-02-26 18:28:50 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-05-23 06:27:18 (GMT) |
commit | e00c2b784a90d882689d61d042e26aa1caff0212 (patch) | |
tree | 6673033c5eea616d987605fe6ad619103e1a6ebd /src | |
parent | 5e3217441ad0f97bff1e946fb93a9673ac806052 (diff) | |
download | fluxbox-e00c2b784a90d882689d61d042e26aa1caff0212.zip fluxbox-e00c2b784a90d882689d61d042e26aa1caff0212.tar.bz2 |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/Window.cc | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/Window.cc b/src/Window.cc index 12b37c9..1c9c795 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -217,6 +217,19 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) { | |||
217 | win.oplock = false; | 217 | win.oplock = false; |
218 | } | 218 | } |
219 | 219 | ||
220 | bool isWindowVisibleOnSomeHeadOrScreen(FluxboxWindow const& w) { | ||
221 | int real_x = w.frame().x(); | ||
222 | int real_y = w.frame().y(); | ||
223 | |||
224 | if (w.screen().hasXinerama()) { // xinerama available => use head info | ||
225 | return (0 != w.screen().getHead(real_x, real_y)); // if visible on some head | ||
226 | } else { // no xinerama available => use screen info | ||
227 | return (real_x >= 0 && real_y >= 0 && | ||
228 | real_x <= (signed) w.screen().width() && | ||
229 | real_y <= (signed) w.screen().height()); // if visible on the screen | ||
230 | } | ||
231 | } | ||
232 | |||
220 | class SetClientCmd:public FbTk::Command<void> { | 233 | class SetClientCmd:public FbTk::Command<void> { |
221 | public: | 234 | public: |
222 | explicit SetClientCmd(WinClient &client):m_client(client) { | 235 | explicit SetClientCmd(WinClient &client):m_client(client) { |
@@ -455,22 +468,16 @@ void FluxboxWindow::init() { | |||
455 | m_placed = true; | 468 | m_placed = true; |
456 | else if (m_client->isTransient() || | 469 | else if (m_client->isTransient() || |
457 | m_client->normal_hint_flags & (PPosition|USPosition)) { | 470 | m_client->normal_hint_flags & (PPosition|USPosition)) { |
458 | 471 | if (isWindowVisibleOnSomeHeadOrScreen(*this)) | |
459 | int real_x = frame().x(); | 472 | m_placed = true; |
460 | int real_y = frame().y(); | 473 | } else { |
461 | 474 | if (!isWindowVisibleOnSomeHeadOrScreen(*this)) { | |
462 | if (screen().hasXinerama()) { // xinerama available => use head info | 475 | int cur = screen().getHead(fbWindow()); |
463 | if (0 != screen().getHead(real_x, real_y)) // if visible on some head | 476 | move(screen().getHeadX(cur), screen().getHeadY(cur)); |
464 | m_placed = true; | 477 | m_placed = false; // allow placement strategy to fix position |
465 | } else { // no xinerama available => use screen info | ||
466 | if (real_x >= 0 && real_y >= 0 && | ||
467 | real_x <= (signed) screen().width() && | ||
468 | real_y <= (signed) screen().height()) // if visible on the screen | ||
469 | m_placed = true; | ||
470 | } | 478 | } |
471 | |||
472 | } else | ||
473 | setOnHead(screen().getCurrHead()); | 479 | setOnHead(screen().getCurrHead()); |
480 | } | ||
474 | 481 | ||
475 | // we must do this now, or else resizing may not work properly | 482 | // we must do this now, or else resizing may not work properly |
476 | applyDecorations(); | 483 | applyDecorations(); |