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 {
|
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.
|
* Determines if a point is inside a rectangle-like objects border.
|
||||||
|
@ -10,18 +18,17 @@ namespace RectangleUtil {
|
||||||
* height.
|
* height.
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @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.
|
* @returns true if point is inside the rectangle-like object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename RectangleLike>
|
template <typename RectangleLike>
|
||||||
bool insideBorder(const RectangleLike& rect,
|
bool insideBorder(const RectangleLike& rect,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
int border_width) {
|
int border) {
|
||||||
return
|
const int w = static_cast<int>(rect.width()) - border;
|
||||||
x >= rect.x() + border_width &&
|
const int h = static_cast<int>(rect.height()) - border;
|
||||||
x < rect.x() + (int)rect.width() + border_width &&
|
return insideRectangle(rect.x() + border, rect.y() + border, w, h, x, y);
|
||||||
y >= rect.y() + border_width &&
|
|
||||||
y < rect.y() + (int)rect.height() + border_width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -223,11 +223,8 @@ bool isWindowVisibleOnSomeHeadOrScreen(FluxboxWindow const& w) {
|
||||||
|
|
||||||
if (w.screen().hasXinerama()) { // xinerama available => use head info
|
if (w.screen().hasXinerama()) { // xinerama available => use head info
|
||||||
return (0 != w.screen().getHead(real_x, real_y)); // if visible on some head
|
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> {
|
class SetClientCmd:public FbTk::Command<void> {
|
||||||
|
@ -464,14 +461,15 @@ void FluxboxWindow::init() {
|
||||||
|
|
||||||
setWindowType(m_client->getWindowType());
|
setWindowType(m_client->getWindowType());
|
||||||
|
|
||||||
|
bool is_visible = isWindowVisibleOnSomeHeadOrScreen(*this);
|
||||||
|
|
||||||
if (fluxbox.isStartup())
|
if (fluxbox.isStartup())
|
||||||
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))
|
m_placed = is_visible;
|
||||||
m_placed = true;
|
|
||||||
} else {
|
} else {
|
||||||
if (!isWindowVisibleOnSomeHeadOrScreen(*this)) {
|
if (!is_visible) {
|
||||||
int cur = screen().getHead(fbWindow());
|
int cur = screen().getHead(fbWindow());
|
||||||
move(screen().getHeadX(cur), screen().getHeadY(cur));
|
move(screen().getHeadX(cur), screen().getHeadY(cur));
|
||||||
m_placed = false; // allow placement strategy to fix position
|
m_placed = false; // allow placement strategy to fix position
|
||||||
|
|
Loading…
Reference in a new issue