Skip to content

Commit

Permalink
give signedness to width/height. fix #211.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Dec 27, 2017
1 parent 3fb1aab commit 5ed338c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
19 changes: 10 additions & 9 deletions src/wmwinlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,16 @@ void WindowList::showFocused(int x, int y) {

int xiscreen = manager->getScreenForRect(x, y, 1, 1);
int dx, dy;
unsigned dw, dh;
manager->getScreenGeometry(&dx, &dy, &dw, &dh, xiscreen);

px = x - getFrame()->width() / 2;
py = y - getFrame()->height() / 2;
if (px + getFrame()->width() > dx + dw)
px = dx + dw - getFrame()->width();
if (py + getFrame()->height() > dy + dh)
py = dx + dh - getFrame()->height();
unsigned uw, uh;
manager->getScreenGeometry(&dx, &dy, &uw, &uh, xiscreen);
int dw = int(uw), dh = int(uh);

px = x - int(getFrame()->width() / 2);
py = y - int(getFrame()->height() / 2);
if (px + int(getFrame()->width()) > dx + dw)
px = dx + dw - int(getFrame()->width());
if (py + int(getFrame()->height()) > dy + dh)
py = dx + dh - int(getFrame()->height());
if (px < dx)
px = dx;
if (py < dy)
Expand Down
41 changes: 21 additions & 20 deletions src/ypopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ bool YPopupWindow::popup(YWindow *owner,
MSG(("x: %d y: %d x_delta: %d y_delta: %d", x, y, x_delta, y_delta));

int dx, dy;
unsigned dw, dh;
desktop->getScreenGeometry(&dx, &dy, &dw, &dh, xiScreen);
unsigned uw, uh;
desktop->getScreenGeometry(&dx, &dy, &uw, &uh, xiScreen);
int dw = int(uw), dh = int(uh);

{ // check available space on left and right
int spaceRight = dx + dw - x;
Expand All @@ -140,48 +141,48 @@ bool YPopupWindow::popup(YWindow *owner,
int bspace = y - y_delta;

/* !!! FIX this to maximize visible area */
if ((x + width() > dx + dw) || (fFlags & pfFlipHorizontal)) {
if ((x + int(width()) > dx + dw) || (fFlags & pfFlipHorizontal)) {
if (//(lspace >= rspace) &&
(fFlags & (pfCanFlipHorizontal | pfFlipHorizontal)))
{
x -= width() + x_delta;
x -= int(width()) + x_delta;
fFlags |= pfFlipHorizontal;
} else
x = dx + dw - width();
x = dx + dw - int(width());
}
if ((y + height() > dy + dh) || (fFlags & pfFlipVertical)) {
if ((y + int(height()) > dy + dh) || (fFlags & pfFlipVertical)) {
if (//(tspace >= bspace) &&
(fFlags & (pfCanFlipVertical | pfFlipVertical)))
{
y -= height() + y_delta;
y -= int(height()) + y_delta;
fFlags |= pfFlipVertical;
} else
y = dy + dh - height();
y = dy + dh - int(height());
}
if (x < dx && (x + width() < dx + dw / 2)) {
if (x < dx && (x + int(width()) < dx + dw / 2)) {
if ((rspace >= lspace) &&
(fFlags & pfCanFlipHorizontal))
x += width() + x_delta;
x += int(width()) + x_delta;
else
x = dx;
}
if (y < dy && (y + height() < dy + dh / 2)) {
if (y < dy && (y + int(height()) < dy + dh / 2)) {
if ((bspace >= tspace) &&
(fFlags & pfCanFlipVertical))
y += height() + y_delta;
y += int(height()) + y_delta;
else
y = dy;
}

if (forWindow == 0) {
if ((x + width() > dx + dw))
x = dw - width();
if ((x + int(width()) > dx + dw))
x = dw - int(width());

if (x < dx)
x = dx;

if ((y + height() > dy + dh))
y = dh - height();
if ((y + int(height()) > dy + dh))
y = dh - int(height());

if (y < dy)
y = dy;
Expand Down Expand Up @@ -240,8 +241,8 @@ bool YPopupWindow::handleKey(const XKeyEvent &/*key*/) {
void YPopupWindow::handleButton(const XButtonEvent &button) {
if ((button.x_root >= x() &&
button.y_root >= y() &&
button.x_root < int (x() + width()) &&
button.y_root < int (y() + height()) &&
button.x_root < x() + int(width()) &&
button.y_root < y() + int(height()) &&
button.window == handle()) /*|
button.button == Button4 ||
button.button == Button5*/)
Expand Down Expand Up @@ -269,8 +270,8 @@ void YPopupWindow::handleButton(const XButtonEvent &button) {
void YPopupWindow::handleMotion(const XMotionEvent &motion) {
if (motion.x_root >= x() &&
motion.y_root >= y() &&
motion.x_root < int (x() + width()) &&
motion.y_root < int (y() + height()) &&
motion.x_root < x() + int(width()) &&
motion.y_root < y() + int(height()) &&
motion.window == handle())
{
YWindow::handleMotion(motion);
Expand Down

0 comments on commit 5ed338c

Please sign in to comment.