all repos — fluxbox @ 2da808667301d27110497e036b8cbdec6f65023d

custom fork of the fluxbox windowmanager

Use shared code, minor code simplification
Mathias Gumz akira at fluxbox dot org
commit

2da808667301d27110497e036b8cbdec6f65023d

parent

9b0cedf9618f382c8691d3243668771e065732b2

2 files changed, 19 insertions(+), 14 deletions(-)

jump to
M src/RectangleUtil.hhsrc/RectangleUtil.hh

@@ -3,6 +3,14 @@ #define RECTANGLEUTIL_HH

namespace RectangleUtil { +inline bool insideRectangle(int x, int y, int width, int height, int px, int py) { + + return + px >= x && + px < (x + width) && + py >= y && + py < (y + height); +} /* * Determines if a point is inside a rectangle-like objects border.

@@ -10,18 +18,17 @@ * @param rect A rectangle-like object that has accessors for x, y, width, and

* height. * @param x * @param y - * @param border_width The size of the border. + * @param border The size of the border. * @returns true if point is inside the rectangle-like object. */ + template <typename RectangleLike> bool insideBorder(const RectangleLike& rect, int x, int y, - int border_width) { - return - x >= rect.x() + border_width && - x < rect.x() + (int)rect.width() + border_width && - y >= rect.y() + border_width && - y < rect.y() + (int)rect.height() + border_width; + int border) { + const int w = static_cast<int>(rect.width()) - border; + const int h = static_cast<int>(rect.height()) - border; + return insideRectangle(rect.x() + border, rect.y() + border, w, h, x, y); }
M src/Window.ccsrc/Window.cc

@@ -223,11 +223,8 @@ 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 } + return RectangleUtil::insideRectangle(0, 0, w.screen().width(), w.screen().height(), real_x, real_y); } class SetClientCmd:public FbTk::Command<void> {

@@ -464,14 +461,15 @@ associateClientWindow();

setWindowType(m_client->getWindowType()); + bool is_visible = isWindowVisibleOnSomeHeadOrScreen(*this); + if (fluxbox.isStartup()) m_placed = true; else if (m_client->isTransient() || m_client->normal_hint_flags & (PPosition|USPosition)) { - if (isWindowVisibleOnSomeHeadOrScreen(*this)) - m_placed = true; + m_placed = is_visible; } else { - if (!isWindowVisibleOnSomeHeadOrScreen(*this)) { + if (!is_visible) { int cur = screen().getHead(fbWindow()); move(screen().getHeadX(cur), screen().getHeadY(cur)); m_placed = false; // allow placement strategy to fix position