mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix strut error
Change-Id: Id983c0aaf6c8e07329c9dd9b2d66eb46520facff
This commit is contained in:
parent
cbaaf52e82
commit
84b880384b
Notes:
Deepin Code Review
2017-11-14 15:23:39 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 14 Nov 2017 15:23:38 +0800 Reviewed-on: https://cr.deepin.io/28427 Project: dde/dde-dock Branch: refs/heads/master
@ -124,11 +124,15 @@ public:
|
||||
|
||||
Q_PROPERTY(ushort ScreenHeight READ screenHeight NOTIFY ScreenHeightChanged)
|
||||
inline ushort screenHeight() const
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenHeight"))) / qApp->devicePixelRatio(); }
|
||||
{ return screenRawHeight() / qApp->devicePixelRatio(); }
|
||||
inline ushort screenRawHeight() const
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenHeight"))); }
|
||||
|
||||
Q_PROPERTY(ushort ScreenWidth READ screenWidth NOTIFY ScreenWidthChanged)
|
||||
inline ushort screenWidth() const
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenWidth"))) / qApp->devicePixelRatio(); }
|
||||
{ return screenRawWidth() / qApp->devicePixelRatio(); }
|
||||
inline ushort screenRawWidth() const
|
||||
{ return qreal(qvariant_cast< ushort >(property("ScreenWidth"))); }
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
inline QDBusPendingReply<> Apply()
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
Position position() const;
|
||||
int screenHeight() const;
|
||||
int screenWidth() const;
|
||||
const int screenRawHeight() const { return m_displayInter->screenRawHeight(); }
|
||||
const int screenRawWidth() const { return m_displayInter->screenRawWidth(); }
|
||||
int expandTimeout() const;
|
||||
int narrowTimeout() const;
|
||||
|
||||
|
@ -33,6 +33,22 @@
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
const QPoint rawXPosition(const QPoint &scaledPos)
|
||||
{
|
||||
QRect g = qApp->primaryScreen()->geometry();
|
||||
for (auto *screen : qApp->screens())
|
||||
{
|
||||
const QRect &sg = screen->geometry();
|
||||
if (sg.contains(scaledPos))
|
||||
{
|
||||
g = sg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return g.topLeft() + (scaledPos - g.topLeft()) * qApp->devicePixelRatio();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
||||
@ -206,14 +222,20 @@ void MainWindow::compositeChanged()
|
||||
void MainWindow::interalMove(const QPoint &p)
|
||||
{
|
||||
const auto ratio = devicePixelRatioF();
|
||||
QPoint rp = p * ratio;
|
||||
QPoint rp = rawXPosition(p);
|
||||
|
||||
if (m_settings->hideMode() != HideMode::KeepShowing &&
|
||||
m_settings->hideState() == HideState::Hide &&
|
||||
m_posChangeAni->state() == QVariantAnimation::Stopped)
|
||||
{
|
||||
const QRect &r = m_settings->primaryRawRect();
|
||||
rp.setY(r.bottom());
|
||||
switch (m_settings->position())
|
||||
{
|
||||
case Left: rp.setX(r.x() - 1); break;
|
||||
case Top: rp.setY(r.y() - 1); break;
|
||||
case Right: rp.setX(r.right() - 2); break;
|
||||
case Bottom: rp.setY(r.bottom() - 2); break;
|
||||
}
|
||||
}
|
||||
|
||||
int h;
|
||||
@ -391,63 +413,63 @@ void MainWindow::setStrutPartial()
|
||||
if (m_settings->hideMode() != Dock::KeepShowing)
|
||||
return;
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const int maxScreenHeight = m_settings->screenRawHeight();
|
||||
const int maxScreenWidth = m_settings->screenRawWidth();
|
||||
const Position side = m_settings->position();
|
||||
const int maxScreenHeight = m_settings->screenHeight();
|
||||
const int maxScreenWidth = m_settings->screenWidth();
|
||||
const QPoint p = rawXPosition(m_posChangeAni->endValue().toPoint());
|
||||
const QSize s = m_settings->windowSize();
|
||||
|
||||
XcbMisc::Orientation orientation = XcbMisc::OrientationTop;
|
||||
uint strut = 0;
|
||||
uint strutStart = 0;
|
||||
uint strutEnd = 0;
|
||||
|
||||
const QPoint p = m_posChangeAni->endValue().toPoint();
|
||||
const QRect r = QRect(p, m_settings->windowSize());
|
||||
QRect strutArea(0, 0, maxScreenWidth, maxScreenHeight);
|
||||
|
||||
qDebug() << "screen info: " << r << p << strutArea;
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case Position::Top:
|
||||
orientation = XcbMisc::OrientationTop;
|
||||
strut = r.bottom() + 1;
|
||||
strutStart = r.left();
|
||||
strutEnd = r.right();
|
||||
strut = p.y() + s.height() * ratio;
|
||||
strutStart = p.x();
|
||||
strutEnd = p.x() + s.width() * ratio;
|
||||
strutArea.setLeft(strutStart);
|
||||
strutArea.setRight(strutEnd);
|
||||
strutArea.setBottom(r.bottom());
|
||||
strutArea.setBottom(strut);
|
||||
break;
|
||||
case Position::Bottom:
|
||||
orientation = XcbMisc::OrientationBottom;
|
||||
strut = maxScreenHeight - p.y();
|
||||
strutStart = r.left();
|
||||
strutEnd = r.right();
|
||||
strutStart = p.x();
|
||||
strutEnd = p.x() + s.width() * ratio;
|
||||
strutArea.setLeft(strutStart);
|
||||
strutArea.setRight(strutEnd);
|
||||
strutArea.setTop(p.y());
|
||||
break;
|
||||
case Position::Left:
|
||||
orientation = XcbMisc::OrientationLeft;
|
||||
strut = r.right() + 1;
|
||||
strutStart = r.top();
|
||||
strutEnd = r.bottom();
|
||||
strutArea.setTop(r.top());
|
||||
strutArea.setBottom(r.bottom());
|
||||
strutArea.setRight(r.right());
|
||||
strut = p.x() + s.width() * ratio;
|
||||
strutStart = p.y();
|
||||
strutEnd = p.y() + s.height() * ratio;
|
||||
strutArea.setTop(strutStart);
|
||||
strutArea.setBottom(strutEnd);
|
||||
strutArea.setRight(strut);
|
||||
break;
|
||||
case Position::Right:
|
||||
orientation = XcbMisc::OrientationRight;
|
||||
strut = maxScreenWidth - r.left();
|
||||
strutStart = r.top();
|
||||
strutEnd = r.bottom();
|
||||
strutArea.setTop(r.top());
|
||||
strutArea.setBottom(r.bottom());
|
||||
strutArea.setLeft(r.left());
|
||||
strut = maxScreenWidth - p.x();
|
||||
strutStart = p.y();
|
||||
strutEnd = p.y() + s.height() * ratio;
|
||||
strutArea.setTop(strutStart);
|
||||
strutArea.setBottom(strutEnd);
|
||||
strutArea.setLeft(p.x());
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
qDebug() << "screen info: " << p << strutArea;
|
||||
|
||||
// pass if strut area is intersect with other screen
|
||||
int count = 0;
|
||||
const QRect pr = m_settings->primaryRect();
|
||||
@ -463,7 +485,7 @@ void MainWindow::setStrutPartial()
|
||||
if (count > 0)
|
||||
return;
|
||||
|
||||
m_xcbMisc->set_strut_partial(winId(), orientation, strut * qApp->devicePixelRatio(), strutStart, strutEnd);
|
||||
m_xcbMisc->set_strut_partial(winId(), orientation, strut, strutStart, strutEnd);
|
||||
}
|
||||
|
||||
void MainWindow::expand()
|
||||
|
Loading…
x
Reference in New Issue
Block a user