From 5ed338c1538b06952ba47588d8d7f19ecef53425 Mon Sep 17 00:00:00 2001 From: Bert Gijsbers Date: Wed, 27 Dec 2017 17:28:30 +0100 Subject: [PATCH] give signedness to width/height. fix #211. --- src/wmwinlist.cc | 19 ++++++++++--------- src/ypopup.cc | 41 +++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/wmwinlist.cc b/src/wmwinlist.cc index 1fccff8a1..9231a4a24 100644 --- a/src/wmwinlist.cc +++ b/src/wmwinlist.cc @@ -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) diff --git a/src/ypopup.cc b/src/ypopup.cc index bf8b0dd4c..a9eeee10e 100644 --- a/src/ypopup.cc +++ b/src/ypopup.cc @@ -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; @@ -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; @@ -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*/) @@ -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);