mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: popupwindow is out of bounds at the edge of the screen
set the minimum value of x of popupwindow to the current screen and the maximum value to the maximum x of the current screen log:
This commit is contained in:
parent
0a103e62bd
commit
15e5a0fadb
@ -7,6 +7,8 @@
|
|||||||
#include "imageutil.h"
|
#include "imageutil.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "dbusutil.h"
|
#include "dbusutil.h"
|
||||||
|
#include "dockscreen.h"
|
||||||
|
#include "displaymanager.h"
|
||||||
|
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -18,6 +20,9 @@
|
|||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
|
#define DOCK_SCREEN DockScreen::instance()
|
||||||
|
#define DIS_INS DisplayManager::instance()
|
||||||
|
|
||||||
DockPopupWindow::DockPopupWindow(QWidget *parent)
|
DockPopupWindow::DockPopupWindow(QWidget *parent)
|
||||||
: DBlurEffectWidget(parent)
|
: DBlurEffectWidget(parent)
|
||||||
, m_model(false)
|
, m_model(false)
|
||||||
@ -127,6 +132,14 @@ void DockPopupWindow::show(const int x, const int y)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
blockButtonRelease();
|
blockButtonRelease();
|
||||||
|
QScreen *screen = DIS_INS->screen(DOCK_SCREEN->current());
|
||||||
|
if (!screen)
|
||||||
|
return;
|
||||||
|
QRect screenRect = screen->geometry();
|
||||||
|
if (getContent()->width() > screenRect.width()) {
|
||||||
|
displayPoint.setX(qMax(screenRect.x(), displayPoint.x()));
|
||||||
|
displayPoint.setX(qMin(screenRect.x() + screenRect.width() - getContent()->width(), displayPoint.x()));
|
||||||
|
}
|
||||||
move(displayPoint);
|
move(displayPoint);
|
||||||
resize(m_lastWidget->size());
|
resize(m_lastWidget->size());
|
||||||
DBlurEffectWidget::show();
|
DBlurEffectWidget::show();
|
||||||
@ -215,7 +228,10 @@ void DockPopupWindow::onButtonPress(int type, int x, int y, const QString &key)
|
|||||||
{
|
{
|
||||||
if (!m_enableMouseRelease)
|
if (!m_enableMouseRelease)
|
||||||
return;
|
return;
|
||||||
QRect screenRect = this->screen()->geometry();
|
QScreen *screen = DIS_INS->screen(DOCK_SCREEN->current());
|
||||||
|
if (!screen)
|
||||||
|
return;
|
||||||
|
QRect screenRect = screen->geometry();
|
||||||
QRect popupRect(((pos() - screenRect.topLeft()) * qApp->devicePixelRatio() + screenRect.topLeft()), size() * qApp->devicePixelRatio());
|
QRect popupRect(((pos() - screenRect.topLeft()) * qApp->devicePixelRatio() + screenRect.topLeft()), size() * qApp->devicePixelRatio());
|
||||||
if (popupRect.contains(QPoint(x, y)))
|
if (popupRect.contains(QPoint(x, y)))
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user