From 537dca9a304bb96ad5dfb400c8f8ef3fde9693e9 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 1 May 2011 00:42:34 +0200 Subject: [PATCH] Fix bounds checking for "dropbox" and "moving disque" if the origin of the work-area is different from (0,0). --- src/Config.h | 4 ++-- src/Dialog_About.cpp | 28 +++++++++++++++++----------- src/Dialog_About.h | 1 - src/Dialog_DropBox.cpp | 17 ++++++++--------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/Config.h b/src/Config.h index a0834f76..edf69c10 100644 --- a/src/Config.h +++ b/src/Config.h @@ -29,8 +29,8 @@ #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Alpha -#define VER_LAMEXP_PATCH 7 -#define VER_LAMEXP_BUILD 469 +#define VER_LAMEXP_PATCH 8 +#define VER_LAMEXP_BUILD 470 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index 7c39a474..0ca5892d 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -187,12 +187,12 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta fourthButton->setMinimumWidth(90); QPixmap disque(":/images/Disque.png"); - m_screenGeometry = QApplication::desktop()->availableGeometry(); + QRect screenGeometry = QApplication::desktop()->availableGeometry(); m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); m_disque->installEventFilter(this); m_disque->setStyleSheet("background:transparent;"); m_disque->setAttribute(Qt::WA_TranslucentBackground); - m_disque->setGeometry(qrand() % (m_screenGeometry.width() - disque.width()), qrand() % (m_screenGeometry.height() - disque.height()), disque.width(), disque.height()); + m_disque->setGeometry(qrand() % (screenGeometry.width() - disque.width()), qrand() % (screenGeometry.height() - disque.height()), disque.width(), disque.height()); m_disque->setPixmap(disque); m_disque->setWindowOpacity(0.01); m_disque->show(); @@ -493,7 +493,7 @@ void AboutDialog::moveDisque(void) { if(m_disqueDelay != _I64_MAX) { - double delay = static_cast(perfCount.QuadPart) - static_cast(m_disqueDelay); + const double delay = static_cast(perfCount.QuadPart) - static_cast(m_disqueDelay); delta = max(1, min(128, static_cast(ceil(delay / static_cast(perfFrequ.QuadPart) / 0.00512)))); } m_disqueDelay = perfCount.QuadPart; @@ -501,32 +501,38 @@ void AboutDialog::moveDisque(void) if(m_disque) { + QRect screenGeometry = QApplication::desktop()->availableGeometry(); + const int minX = screenGeometry.left(); + const int maxX = screenGeometry.width() - m_disque->width() + screenGeometry.left(); + const int minY = screenGeometry.top(); + const int maxY = screenGeometry.height() - m_disque->height() + screenGeometry.top(); + QPoint pos = m_disque->pos(); pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta); pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta); - if(pos.x() <= 0) + if(pos.x() <= minX) { m_disqueFlags[0] = true; - pos.setX(0); + pos.setX(minX); m_rotateNext = true; } - else if(pos.x() >= m_screenGeometry.width() - m_disque->width()) + else if(pos.x() >= maxX) { m_disqueFlags[0] = false; - pos.setX(m_screenGeometry.width() - m_disque->width()); + pos.setX(maxX); m_rotateNext = true; } - if(pos.y() <= 0) + if(pos.y() <= minY) { m_disqueFlags[1] = true; - pos.setY(0); + pos.setY(minY); m_rotateNext = true; } - else if(pos.y() >= m_screenGeometry.height()- m_disque->height()) + else if(pos.y() >= maxY) { m_disqueFlags[1] = false; - pos.setY(m_screenGeometry.height() - m_disque->height()); + pos.setY(maxY); m_rotateNext = true; } diff --git a/src/Dialog_About.h b/src/Dialog_About.h index eae2e2b9..359de118 100644 --- a/src/Dialog_About.h +++ b/src/Dialog_About.h @@ -54,7 +54,6 @@ private: QLabel *m_disque; QTimer * m_disqueTimer; bool m_disqueFlags[2]; - QRect m_screenGeometry; QPixmap *m_cartoon[4]; bool m_rotateNext; __int64 m_disqueDelay; diff --git a/src/Dialog_DropBox.cpp b/src/Dialog_DropBox.cpp index eb849cc0..e29d7ea0 100644 --- a/src/Dialog_DropBox.cpp +++ b/src/Dialog_DropBox.cpp @@ -116,8 +116,8 @@ void DropBox::showEvent(QShowEvent *event) if(m_firstShow) { m_firstShow = false; - int max_x = screenGeometry.width() - frameGeometry().width(); - int max_y = screenGeometry.height() - frameGeometry().height(); + int max_x = screenGeometry.width() - frameGeometry().width() + screenGeometry.left(); + int max_y = screenGeometry.height() - frameGeometry().height() + screenGeometry.top(); move(max_x, max_y); QTimer::singleShot(333, this, SLOT(showToolTip())); } @@ -180,14 +180,13 @@ void DropBox::mouseMoveEvent(QMouseEvent *event) static const int magnetic = 22; QRect screenGeometry = QApplication::desktop()->availableGeometry(); - int delta_x = m_mouseReferencePoint.x() - event->globalX(); - int delta_y = m_mouseReferencePoint.y() - event->globalY(); - - int max_x = screenGeometry.width() - frameGeometry().width(); - int max_y = screenGeometry.height() - frameGeometry().height(); + const int delta_x = m_mouseReferencePoint.x() - event->globalX(); + const int delta_y = m_mouseReferencePoint.y() - event->globalY(); + const int max_x = screenGeometry.width() - frameGeometry().width() + screenGeometry.left(); + const int max_y = screenGeometry.height() - frameGeometry().height() + screenGeometry.top(); - int new_x = min(max_x, max(0, m_windowReferencePoint.x() - delta_x)); - int new_y = min(max_y, max(0, m_windowReferencePoint.y() - delta_y)); + int new_x = min(max_x, max(screenGeometry.left(), m_windowReferencePoint.x() - delta_x)); + int new_y = min(max_y, max(screenGeometry.top(), m_windowReferencePoint.y() - delta_y)); if(new_x < magnetic) {