Use shared code, minor code simplification
This commit is contained in:
parent
9b0cedf961
commit
2da8086673
2 changed files with 19 additions and 14 deletions
|
@ -3,6 +3,14 @@
|
|||
|
||||
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 @@ namespace RectangleUtil {
|
|||
* 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -223,11 +223,8 @@ bool isWindowVisibleOnSomeHeadOrScreen(FluxboxWindow const& w) {
|
|||
|
||||
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 @@ void FluxboxWindow::init() {
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue