mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Merge tag '5.1.0.11' into uos
dde 5.0.0.3 # Conflicts: # frame/util/docksettings.cpp # frame/util/docksettings.h # frame/window/mainwindow.cpp # gschema/com.deepin.dde.dock.module.gschema.xml
This commit is contained in:
commit
01d7a23d02
@ -22,7 +22,6 @@
|
||||
#include "window/mainwindow.h"
|
||||
#include "window/accessible.h"
|
||||
#include "util/themeappicon.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
|
||||
#include <QAccessible>
|
||||
#include <QDir>
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "docksettings.h"
|
||||
#include "item/appitem.h"
|
||||
#include "util/utils.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QX11Info>
|
||||
@ -71,7 +70,7 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
, m_keepShownAct(tr("Keep Shown"), this)
|
||||
, m_keepHiddenAct(tr("Keep Hidden"), this)
|
||||
, m_smartHideAct(tr("Smart Hide"), this)
|
||||
, m_displayInter(new DisplayInter("com.deepin.daemon.Display", "/com/deepin/daemon/Display", QDBusConnection::sessionBus(), this))
|
||||
, m_displayInter(new DBusDisplay(this))
|
||||
, m_itemManager(DockItemManager::instance(this))
|
||||
, m_trashPluginShow(true)
|
||||
, m_isMouseMoveCause(false)
|
||||
@ -80,12 +79,9 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
m_settingsMenu.setAccessibleName("settingsmenu");
|
||||
checkService();
|
||||
|
||||
onMonitorListChanged(m_displayInter->monitors());
|
||||
|
||||
m_primaryRawRect = m_displayInter->primaryRect();
|
||||
m_currentRawRect = m_primaryRawRect;
|
||||
m_screenRawHeight = m_displayInter->screenHeight();
|
||||
m_screenRawWidth = m_displayInter->screenWidth();
|
||||
m_primaryRawRect = m_displayInter->primaryRawRect();
|
||||
m_screenRawHeight = m_displayInter->screenRawHeight();
|
||||
m_screenRawWidth = m_displayInter->screenRawWidth();
|
||||
m_position = Dock::Position(m_dockInter->position());
|
||||
m_displayMode = Dock::DisplayMode(m_dockInter->displayMode());
|
||||
m_hideMode = Dock::HideMode(m_dockInter->hideMode());
|
||||
@ -155,11 +151,10 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
connect(m_itemManager, &DockItemManager::itemRemoved, this, &DockSettings::dockItemCountChanged, Qt::QueuedConnection);
|
||||
connect(m_itemManager, &DockItemManager::trayVisableCountChanged, this, &DockSettings::trayVisableCountChanged, Qt::QueuedConnection);
|
||||
|
||||
connect(m_displayInter, &DisplayInter::PrimaryRectChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DisplayInter::ScreenHeightChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DisplayInter::ScreenWidthChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DisplayInter::PrimaryChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DisplayInter::MonitorsChanged, this, &DockSettings::onMonitorListChanged);
|
||||
connect(m_displayInter, &DBusDisplay::PrimaryRectChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DBusDisplay::ScreenHeightChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DBusDisplay::ScreenWidthChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(m_displayInter, &DBusDisplay::PrimaryChanged, this, &DockSettings::primaryScreenChanged, Qt::QueuedConnection);
|
||||
connect(GSettingsByTrash(), &QGSettings::changed, this, &DockSettings::onTrashGSettingsChanged);
|
||||
QTimer::singleShot(0, this, [=] {onGSettingsChanged("enable");});
|
||||
|
||||
@ -168,8 +163,8 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
connect(app, &DApplication::iconThemeChanged, this, &DockSettings::gtkIconThemeChanged);
|
||||
}
|
||||
|
||||
calculateMultiScreensPos();
|
||||
calculateWindowConfig();
|
||||
updateForbidPostions();
|
||||
resetFrontendGeometry();
|
||||
|
||||
QTimer::singleShot(0, this, [ = ] {onOpacityChanged(m_dockInter->opacity());});
|
||||
@ -178,20 +173,6 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
});
|
||||
}
|
||||
|
||||
const QList<QRect> DockSettings::monitorsRect() const
|
||||
{
|
||||
QList<QRect> monsRect;
|
||||
QMapIterator<Monitor *, MonitorInter *> iterator(m_monitors);
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
Monitor *monitor = iterator.key();
|
||||
if (monitor) {
|
||||
monsRect << monitor->rect();
|
||||
}
|
||||
}
|
||||
return monsRect;
|
||||
}
|
||||
|
||||
DockSettings &DockSettings::Instance()
|
||||
{
|
||||
static DockSettings settings;
|
||||
@ -268,7 +249,7 @@ const QRect DockSettings::windowRect(const Position position, const bool hide)
|
||||
}
|
||||
}
|
||||
|
||||
const QRect primaryRect = this->currentRect();
|
||||
const QRect primaryRect = this->primaryRect();
|
||||
const int offsetX = (primaryRect.width() - size.width()) / 2;
|
||||
const int offsetY = (primaryRect.height() - size.height()) / 2;
|
||||
int margin = hide ? 0 : this->dockMargin();
|
||||
@ -286,6 +267,7 @@ const QRect DockSettings::windowRect(const Position position, const bool hide)
|
||||
case Bottom:
|
||||
p = QPoint(offsetX, primaryRect.height() - size.height() - margin);
|
||||
break;
|
||||
default: Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
return QRect(primaryRect.topLeft() + p, size);
|
||||
@ -334,9 +316,13 @@ void DockSettings::showDockSettingsMenu()
|
||||
m_fashionModeAct.setChecked(m_displayMode == Fashion);
|
||||
m_efficientModeAct.setChecked(m_displayMode == Efficient);
|
||||
m_topPosAct.setChecked(m_position == Top);
|
||||
m_topPosAct.setEnabled(!m_forbidPositions.contains(Top));
|
||||
m_bottomPosAct.setChecked(m_position == Bottom);
|
||||
m_bottomPosAct.setEnabled(!m_forbidPositions.contains(Bottom));
|
||||
m_leftPosAct.setChecked(m_position == Left);
|
||||
m_leftPosAct.setEnabled(!m_forbidPositions.contains(Left));
|
||||
m_rightPosAct.setChecked(m_position == Right);
|
||||
m_rightPosAct.setEnabled(!m_forbidPositions.contains(Right));
|
||||
m_keepShownAct.setChecked(m_hideMode == KeepShowing);
|
||||
m_keepHiddenAct.setChecked(m_hideMode == KeepHidden);
|
||||
m_smartHideAct.setChecked(m_hideMode == SmartHide);
|
||||
@ -370,7 +356,7 @@ void DockSettings::menuActionClicked(QAction *action)
|
||||
return m_dockInter->setDisplayMode(Efficient);
|
||||
|
||||
m_isMouseMoveCause = false;
|
||||
calculateMultiScreensPos();
|
||||
// calculateMultiScreensPos();
|
||||
if (action == &m_topPosAct)
|
||||
return m_dockInter->setPosition(Top);
|
||||
if (action == &m_bottomPosAct)
|
||||
@ -473,16 +459,15 @@ void DockSettings::dockItemCountChanged()
|
||||
void DockSettings::primaryScreenChanged()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
m_primaryRawRect = m_displayInter->primaryRect();
|
||||
m_screenRawHeight = m_displayInter->screenHeight();
|
||||
m_screenRawWidth = m_displayInter->screenWidth();
|
||||
m_primaryRawRect = m_displayInter->primaryRawRect();
|
||||
m_screenRawHeight = m_displayInter->screenRawHeight();
|
||||
m_screenRawWidth = m_displayInter->screenRawWidth();
|
||||
|
||||
//为了防止当后端发送错误值,然后发送正确值时,任务栏没有移动在相应的位置
|
||||
//当qt没有获取到屏幕资源时候,move函数会失效。可以直接return
|
||||
if (m_screenRawHeight == 0 || m_screenRawWidth == 0){
|
||||
return;
|
||||
}
|
||||
calculateMultiScreensPos();
|
||||
emit dataChanged();
|
||||
calculateWindowConfig();
|
||||
|
||||
@ -507,16 +492,75 @@ void DockSettings::updateFrontendGeometry()
|
||||
resetFrontendGeometry();
|
||||
}
|
||||
|
||||
void DockSettings::setDockScreen(const QString &scrName)
|
||||
bool DockSettings::test(const Position pos, const QList<QRect> &otherScreens) const
|
||||
{
|
||||
m_isMouseMoveCause = true;
|
||||
QList<Monitor*> monitors = m_monitors.keys();
|
||||
for (Monitor *monitor : monitors) {
|
||||
if (monitor && monitor->name() == scrName) {
|
||||
m_mouseCauseDockScreen = monitor;
|
||||
break;
|
||||
}
|
||||
QRect maxStrut(0, 0, m_screenRawWidth, m_screenRawHeight);
|
||||
switch (pos) {
|
||||
case Top:
|
||||
maxStrut.setBottom(m_primaryRawRect.top() - 1);
|
||||
maxStrut.setLeft(m_primaryRawRect.left());
|
||||
maxStrut.setRight(m_primaryRawRect.right());
|
||||
break;
|
||||
case Bottom:
|
||||
maxStrut.setTop(m_primaryRawRect.bottom() + 1);
|
||||
maxStrut.setLeft(m_primaryRawRect.left());
|
||||
maxStrut.setRight(m_primaryRawRect.right());
|
||||
break;
|
||||
case Left:
|
||||
maxStrut.setRight(m_primaryRawRect.left() - 1);
|
||||
maxStrut.setTop(m_primaryRawRect.top());
|
||||
maxStrut.setBottom(m_primaryRawRect.bottom());
|
||||
break;
|
||||
case Right:
|
||||
maxStrut.setLeft(m_primaryRawRect.right() + 1);
|
||||
maxStrut.setTop(m_primaryRawRect.top());
|
||||
maxStrut.setBottom(m_primaryRawRect.bottom());
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
if (maxStrut.width() == 0 || maxStrut.height() == 0)
|
||||
return true;
|
||||
|
||||
for (const auto &r : otherScreens)
|
||||
if (maxStrut.intersects(r))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DockSettings::updateForbidPostions()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
const auto &screens = qApp->screens();
|
||||
if (screens.size() < 2)
|
||||
return m_forbidPositions.clear();
|
||||
|
||||
QSet<Position> forbids;
|
||||
QList<QRect> rawScreenRects;
|
||||
for (auto *s : screens) {
|
||||
qInfo() << s->name() << s->geometry();
|
||||
|
||||
if (s == qApp->primaryScreen())
|
||||
continue;
|
||||
|
||||
const QRect &g = s->geometry();
|
||||
rawScreenRects << QRect(g.topLeft(), g.size() * s->devicePixelRatio());
|
||||
}
|
||||
|
||||
qInfo() << rawScreenRects << m_screenRawWidth << m_screenRawHeight;
|
||||
|
||||
if (!test(Top, rawScreenRects))
|
||||
forbids << Top;
|
||||
if (!test(Bottom, rawScreenRects))
|
||||
forbids << Bottom;
|
||||
if (!test(Left, rawScreenRects))
|
||||
forbids << Left;
|
||||
if (!test(Right, rawScreenRects))
|
||||
forbids << Right;
|
||||
|
||||
m_forbidPositions = std::move(forbids);
|
||||
}
|
||||
|
||||
void DockSettings::onOpacityChanged(const double value)
|
||||
@ -536,7 +580,7 @@ void DockSettings::trayVisableCountChanged(const int &count)
|
||||
void DockSettings::calculateWindowConfig()
|
||||
{
|
||||
if (m_displayMode == Dock::Efficient) {
|
||||
m_dockWindowSize = int(m_dockInter->windowSizeEfficient());
|
||||
m_dockWindowSize = m_dockInter->windowSizeEfficient();
|
||||
if (m_dockWindowSize > WINDOW_MAX_SIZE || m_dockWindowSize < WINDOW_MIN_SIZE) {
|
||||
m_dockWindowSize = EffICIENT_DEFAULT_HEIGHT;
|
||||
m_dockInter->setWindowSize(EffICIENT_DEFAULT_HEIGHT);
|
||||
@ -546,17 +590,20 @@ void DockSettings::calculateWindowConfig()
|
||||
case Top:
|
||||
case Bottom:
|
||||
m_mainWindowSize.setHeight(m_dockWindowSize);
|
||||
m_mainWindowSize.setWidth(currentRect().width());
|
||||
m_mainWindowSize.setWidth(primaryRect().width());
|
||||
break;
|
||||
|
||||
case Left:
|
||||
case Right:
|
||||
m_mainWindowSize.setHeight(currentRect().height());
|
||||
m_mainWindowSize.setHeight(primaryRect().height());
|
||||
m_mainWindowSize.setWidth(m_dockWindowSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
} else if (m_displayMode == Dock::Fashion) {
|
||||
m_dockWindowSize = int(m_dockInter->windowSizeFashion());
|
||||
m_dockWindowSize = m_dockInter->windowSizeFashion();
|
||||
if (m_dockWindowSize > WINDOW_MAX_SIZE || m_dockWindowSize < WINDOW_MIN_SIZE) {
|
||||
m_dockWindowSize = FASHION_DEFAULT_HEIGHT;
|
||||
m_dockInter->setWindowSize(FASHION_DEFAULT_HEIGHT);
|
||||
@ -566,15 +613,17 @@ void DockSettings::calculateWindowConfig()
|
||||
case Top:
|
||||
case Bottom: {
|
||||
m_mainWindowSize.setHeight(m_dockWindowSize);
|
||||
m_mainWindowSize.setWidth(this->currentRect().width() - MAINWINDOW_MARGIN * 2);
|
||||
m_mainWindowSize.setWidth(this->primaryRect().width() - MAINWINDOW_MARGIN * 2);
|
||||
break;
|
||||
}
|
||||
case Left:
|
||||
case Right: {
|
||||
m_mainWindowSize.setHeight(this->currentRect().height() - MAINWINDOW_MARGIN * 2);
|
||||
m_mainWindowSize.setHeight(this->primaryRect().height() - MAINWINDOW_MARGIN * 2);
|
||||
m_mainWindowSize.setWidth(m_dockWindowSize);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
@ -611,7 +660,6 @@ void DockSettings::checkService()
|
||||
|
||||
if (!ifc->isServiceRegistered(serverName)) {
|
||||
connect(ifc, &QDBusConnectionInterface::serviceOwnerChanged, this, [ = ](const QString & name, const QString & oldOwner, const QString & newOwner) {
|
||||
Q_UNUSED(oldOwner)
|
||||
if (name == serverName && !newOwner.isEmpty()) {
|
||||
|
||||
m_dockInter = new DBusDock(serverName, "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this);
|
||||
@ -628,272 +676,6 @@ void DockSettings::checkService()
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::calculateMultiScreensPos()
|
||||
{
|
||||
QList<Monitor *> monitors = m_monitors.keys();
|
||||
for (Monitor *monitor : monitors) {
|
||||
monitor->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
}
|
||||
|
||||
switch (m_monitors.size()) {
|
||||
case 0:
|
||||
break;
|
||||
case 1: {
|
||||
QList<Monitor*>screens = m_monitors.keys();
|
||||
Monitor* s1 = screens.at(0);
|
||||
s1->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
twoScreensCalPos();
|
||||
break;
|
||||
case 3:
|
||||
treeScreensCalPos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::monitorAdded(const QString &path)
|
||||
{
|
||||
MonitorInter *inter = new MonitorInter("com.deepin.daemon.Display", path, QDBusConnection::sessionBus(), this);
|
||||
Monitor *mon = new Monitor(this);
|
||||
|
||||
connect(inter, &MonitorInter::XChanged, mon, &Monitor::setX);
|
||||
connect(inter, &MonitorInter::YChanged, mon, &Monitor::setY);
|
||||
connect(inter, &MonitorInter::WidthChanged, mon, &Monitor::setW);
|
||||
connect(inter, &MonitorInter::HeightChanged, mon, &Monitor::setH);
|
||||
connect(inter, &MonitorInter::MmWidthChanged, mon, &Monitor::setMmWidth);
|
||||
connect(inter, &MonitorInter::MmHeightChanged, mon, &Monitor::setMmHeight);
|
||||
connect(inter, &MonitorInter::RotationChanged, mon, &Monitor::setRotate);
|
||||
connect(inter, &MonitorInter::NameChanged, mon, &Monitor::setName);
|
||||
connect(inter, &MonitorInter::CurrentModeChanged, mon, &Monitor::setCurrentMode);
|
||||
connect(inter, &MonitorInter::ModesChanged, mon, &Monitor::setModeList);
|
||||
connect(inter, &MonitorInter::RotationsChanged, mon, &Monitor::setRotateList);
|
||||
connect(inter, &MonitorInter::EnabledChanged, mon, &Monitor::setMonitorEnable);
|
||||
connect(m_displayInter, static_cast<void (DisplayInter::*)(const QString &) const>(&DisplayInter::PrimaryChanged), mon, &Monitor::setPrimary);
|
||||
|
||||
// NOTE: DO NOT using async dbus call. because we need to have a unique name to distinguish each monitor
|
||||
Q_ASSERT(inter->isValid());
|
||||
mon->setName(inter->name());
|
||||
|
||||
mon->setMonitorEnable(inter->enabled());
|
||||
mon->setPath(path);
|
||||
mon->setX(inter->x());
|
||||
mon->setY(inter->y());
|
||||
mon->setW(inter->width());
|
||||
mon->setH(inter->height());
|
||||
mon->setRotate(inter->rotation());
|
||||
mon->setCurrentMode(inter->currentMode());
|
||||
mon->setModeList(inter->modes());
|
||||
|
||||
mon->setRotateList(inter->rotations());
|
||||
mon->setPrimary(m_displayInter->primary());
|
||||
mon->setMmWidth(inter->mmWidth());
|
||||
mon->setMmHeight(inter->mmHeight());
|
||||
|
||||
m_monitors.insert(mon, inter);
|
||||
inter->setSync(false);
|
||||
}
|
||||
|
||||
void DockSettings::monitorRemoved(const QString &path)
|
||||
{
|
||||
Monitor *monitor = nullptr;
|
||||
for (auto it(m_monitors.cbegin()); it != m_monitors.cend(); ++it) {
|
||||
if (it.key()->path() == path) {
|
||||
monitor = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!monitor)
|
||||
return;
|
||||
|
||||
m_monitors.value(monitor)->deleteLater();
|
||||
m_monitors.remove(monitor);
|
||||
|
||||
monitor->deleteLater();
|
||||
|
||||
calculateMultiScreensPos();
|
||||
}
|
||||
|
||||
void DockSettings::twoScreensCalPos()
|
||||
{
|
||||
QList<Monitor*>screens = m_monitors.keys();
|
||||
Monitor* s1 = screens.at(0);
|
||||
Monitor* s2 = screens.at(1);
|
||||
if (!s1 && !s2)
|
||||
return;
|
||||
|
||||
// 只在某屏显示时,其它屏禁用
|
||||
bool s1Enabled = s1->enable();
|
||||
bool s2Enabled = s2->enable();
|
||||
if (!s1Enabled || !s2Enabled) {
|
||||
if (!s1Enabled && s2Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s2->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
} else if (!s2Enabled && s1Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
s2->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
} else if (!s1Enabled && !s2Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s2->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
combination(screens);
|
||||
}
|
||||
|
||||
void DockSettings::treeScreensCalPos()
|
||||
{
|
||||
QList<Monitor*>screens = m_monitors.keys();
|
||||
Monitor* s1 = screens.at(0);
|
||||
Monitor* s2 = screens.at(1);
|
||||
Monitor* s3 = screens.at(2);
|
||||
if (!s1 && !s2 && !s3)
|
||||
return;
|
||||
|
||||
// 只在某屏显示时,其它屏禁用
|
||||
bool s1Enabled = s1->enable();
|
||||
bool s2Enabled = s2->enable();
|
||||
bool s3Enabled = s3->enable();
|
||||
if (!s1Enabled || !s2Enabled || !s3Enabled) {
|
||||
if (!s1Enabled && !s2Enabled && s3Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s2->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s3->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
} else if (!s1Enabled && s2Enabled && !s3Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s2->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
s3->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
} else if (s1Enabled && !s2Enabled && !s3Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(true, true, true, true));
|
||||
s2->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s3->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
} else if (!s1Enabled && !s2Enabled && !s3Enabled) {
|
||||
s1->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s2->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
s3->setDockPosition(Monitor::DockPosition(false, false, false, false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
combination(screens);
|
||||
}
|
||||
|
||||
void DockSettings::combination(QList<Monitor *> &screens)
|
||||
{
|
||||
if (screens.size() < 2)
|
||||
return;
|
||||
|
||||
Monitor *last = screens.takeLast();
|
||||
|
||||
for (Monitor *screen : screens) {
|
||||
calculateRelativePos(last, screen);
|
||||
}
|
||||
|
||||
combination(screens);
|
||||
}
|
||||
|
||||
void DockSettings::calculateRelativePos(Monitor *s1, Monitor *s2)
|
||||
{
|
||||
/* 鼠标可移动区另算 */
|
||||
if (!s1 && !s2)
|
||||
return;
|
||||
|
||||
// 对齐
|
||||
bool isAligment = false;
|
||||
// 左右拼
|
||||
// s1左 s2右
|
||||
if (s1->right() == s2->left() ) {
|
||||
isAligment = (s1->topRight() == s2->topLeft())
|
||||
&& (s1->bottomRight() == s2->bottomLeft());
|
||||
if (isAligment) {
|
||||
s1->dockPosition().rightDock = false;
|
||||
s2->dockPosition().leftDock = false;
|
||||
} else {
|
||||
if (!s1->isPrimary())
|
||||
s1->dockPosition().rightDock = false;
|
||||
if (!s2->isPrimary())
|
||||
s2->dockPosition().leftDock = false;
|
||||
}
|
||||
}
|
||||
// s1右 s2左
|
||||
if (s1->left() == s2->right()) {
|
||||
isAligment = (s1->topLeft() == s2->topRight())
|
||||
&& (s1->bottomLeft() == s2->bottomRight());
|
||||
if (isAligment) {
|
||||
s1->dockPosition().leftDock = false;
|
||||
s2->dockPosition().rightDock = false;
|
||||
} else {
|
||||
if (!s1->isPrimary())
|
||||
s1->dockPosition().leftDock = false;
|
||||
if (!s2->isPrimary())
|
||||
s2->dockPosition().rightDock = false;
|
||||
}
|
||||
}
|
||||
// 上下拼
|
||||
// s1上 s2下
|
||||
if (s1->top() == s2->bottom()) {
|
||||
isAligment = (s1->bottomLeft() == s2->topLeft())
|
||||
&& (s1->bottomRight() == s2->topRight());
|
||||
if (isAligment) {
|
||||
s1->dockPosition().bottomDock = false;
|
||||
s2->dockPosition().topDock = false;
|
||||
} else {
|
||||
if (!s1->isPrimary())
|
||||
s1->dockPosition().bottomDock = false;
|
||||
if (!s2->isPrimary())
|
||||
s2->dockPosition().topDock = false;
|
||||
}
|
||||
}
|
||||
// s1下 s2上
|
||||
if (s1->bottom() == s2->top()) {
|
||||
isAligment = (s1->topLeft() == s2->bottomLeft())
|
||||
&& (s1->topRight() == s2->bottomRight());
|
||||
if (isAligment) {
|
||||
s1->dockPosition().topDock = false;
|
||||
s2->dockPosition().bottomDock = false;
|
||||
} else {
|
||||
if (!s1->isPrimary())
|
||||
s1->dockPosition().topDock = false;
|
||||
if (!s2->isPrimary())
|
||||
s2->dockPosition().bottomDock = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 对角拼
|
||||
bool isDiagonal = (s1->topLeft() == s2->bottomRight())
|
||||
|| (s1->topRight() == s2->bottomLeft())
|
||||
|| (s1->bottomLeft() == s2->topRight())
|
||||
|| (s1->bottomRight() == s2->topLeft());
|
||||
if (isDiagonal) {
|
||||
auto position = Monitor::DockPosition(false, false, false, false);
|
||||
if (!s1->isPrimary())
|
||||
s2->setDockPosition(position);
|
||||
if (!s2->isPrimary())
|
||||
s1->setDockPosition(position);
|
||||
|
||||
switch (m_position) {
|
||||
case Top:
|
||||
s1->dockPosition().topDock = true;
|
||||
s2->dockPosition().topDock = true;
|
||||
break;
|
||||
case Bottom:
|
||||
s1->dockPosition().bottomDock = true;
|
||||
s2->dockPosition().bottomDock = true;
|
||||
break;
|
||||
case Left:
|
||||
s1->dockPosition().leftDock = true;
|
||||
s2->dockPosition().leftDock = true;
|
||||
break;
|
||||
case Right:
|
||||
s1->dockPosition().rightDock = true;
|
||||
s2->dockPosition().rightDock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::onTrashGSettingsChanged(const QString &key)
|
||||
{
|
||||
if (key != "enable") {
|
||||
@ -906,25 +688,3 @@ void DockSettings::onTrashGSettingsChanged(const QString &key)
|
||||
m_trashPluginShow = GSettingsByTrash()->keys().contains("enable") && GSettingsByTrash()->get("enable").toBool();
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::onMonitorListChanged(const QList<QDBusObjectPath> &mons)
|
||||
{
|
||||
if (mons.isEmpty())
|
||||
return;
|
||||
|
||||
QList<QString> ops;
|
||||
for (const auto *mon : m_monitors.keys())
|
||||
ops << mon->path();
|
||||
|
||||
QList<QString> pathList;
|
||||
for (const auto op : mons) {
|
||||
const QString path = op.path();
|
||||
pathList << path;
|
||||
if (!ops.contains(path))
|
||||
monitorAdded(path);
|
||||
}
|
||||
|
||||
for (const auto op : ops)
|
||||
if (!pathList.contains(op))
|
||||
monitorRemoved(op);
|
||||
}
|
||||
|
@ -24,10 +24,12 @@
|
||||
#define DOCKSETTINGS_H
|
||||
|
||||
#include "constants.h"
|
||||
#include "dbus/dbusmenumanager.h"
|
||||
#include "dbus/dbusdisplay.h"
|
||||
#include "monitor.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
|
||||
#include <com_deepin_dde_daemon_dock.h>
|
||||
#include <com_deepin_daemon_display.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
@ -35,11 +37,13 @@
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
|
||||
#include <QStyleFactory>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
using namespace Dock;
|
||||
using DBusDock = com::deepin::dde::daemon::Dock;
|
||||
using DisplayInter = com::deepin::daemon::Display;
|
||||
|
||||
class DockItemManager;
|
||||
class DockSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -60,7 +64,6 @@ public:
|
||||
const QRect currentRect();
|
||||
const QList<QRect> monitorsRect() const;
|
||||
inline const QRect primaryRawRect() const { return m_primaryRawRect; }
|
||||
inline const QRect currentRawRect() const { return m_currentRawRect; }
|
||||
inline const QRect frontendWindowRect() const { return m_frontendRect; }
|
||||
inline const QSize windowSize() const { return m_mainWindowSize; }
|
||||
inline const quint8 Opacity() const { return m_opacity * 255; }
|
||||
@ -105,29 +108,22 @@ private slots:
|
||||
void dockItemCountChanged();
|
||||
void primaryScreenChanged();
|
||||
void resetFrontendGeometry();
|
||||
void updateForbidPostions();
|
||||
void onOpacityChanged(const double value);
|
||||
void trayVisableCountChanged(const int &count);
|
||||
void onWindowSizeChanged();
|
||||
void onTrashGSettingsChanged(const QString &key);
|
||||
void onMonitorListChanged(const QList<QDBusObjectPath> &mons);
|
||||
|
||||
private:
|
||||
DockSettings(QWidget *parent = nullptr);
|
||||
DockSettings(QWidget *parent = 0);
|
||||
DockSettings(DockSettings const &) = delete;
|
||||
DockSettings operator =(DockSettings const &) = delete;
|
||||
|
||||
bool test(const Position pos, const QList<QRect> &otherScreens) const;
|
||||
void calculateWindowConfig();
|
||||
void gtkIconThemeChanged();
|
||||
void checkService();
|
||||
|
||||
void calculateMultiScreensPos();
|
||||
void monitorAdded(const QString &path);
|
||||
void monitorRemoved(const QString &path);
|
||||
void twoScreensCalPos();
|
||||
void treeScreensCalPos();
|
||||
void combination(QList<Monitor*> &screens);
|
||||
void calculateRelativePos(Monitor *s1, Monitor *s2);
|
||||
|
||||
private:
|
||||
int m_dockWindowSize;
|
||||
bool m_autoHide;
|
||||
@ -156,7 +152,7 @@ private:
|
||||
QAction m_keepHiddenAct;
|
||||
QAction m_smartHideAct;
|
||||
|
||||
DisplayInter *m_displayInter;
|
||||
DBusDisplay *m_displayInter;
|
||||
DockItemManager *m_itemManager;
|
||||
bool m_trashPluginShow;
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "panel/mainpanelcontrol.h"
|
||||
#include "controller/dockitemmanager.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/docksettings.h"
|
||||
|
||||
#include <DStyle>
|
||||
#include <DPlatformWindowHandle>
|
||||
@ -131,20 +130,15 @@ const QPoint scaledPos(const QPoint &rawXPos)
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: DBlurEffectWidget(parent)
|
||||
|
||||
, m_launched(false)
|
||||
|
||||
, m_mainPanel(new MainPanelControl(this))
|
||||
|
||||
, m_platformWindowHandle(this)
|
||||
, m_wmHelper(DWindowManagerHelper::instance())
|
||||
, m_eventInter(new XEventMonitor("com.deepin.api.XEventMonitor", "/com/deepin/api/XEventMonitor", QDBusConnection::sessionBus()))
|
||||
|
||||
, m_regionMonitor(new DRegionMonitor(this))
|
||||
, m_positionUpdateTimer(new QTimer(this))
|
||||
, m_expandDelayTimer(new QTimer(this))
|
||||
, m_leaveDelayTimer(new QTimer(this))
|
||||
, m_shadowMaskOptimizeTimer(new QTimer(this))
|
||||
|
||||
, m_panelShowAni(new QVariantAnimation(this))
|
||||
, m_panelHideAni(new QVariantAnimation(this))
|
||||
, m_xcbMisc(XcbMisc::instance())
|
||||
@ -544,7 +538,7 @@ void MainWindow::initConnections()
|
||||
connect(m_dragWidget, &DragWidget::dragPointOffset, this, &MainWindow::onMainWindowSizeChanged);
|
||||
connect(m_dragWidget, &DragWidget::dragFinished, this, &MainWindow::onDragFinished);
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &MainWindow::themeTypeChanged);
|
||||
connect(m_eventInter, &XEventMonitor::CursorMove, this, &MainWindow::onRegionMonitorChanged);
|
||||
connect(m_regionMonitor, &DRegionMonitor::cursorMove, this, &MainWindow::onRegionMonitorChanged);
|
||||
}
|
||||
|
||||
const QPoint MainWindow::x11GetWindowPos()
|
||||
@ -674,7 +668,7 @@ void MainWindow::setStrutPartial()
|
||||
const Position side = m_curDockPos;
|
||||
const QPoint &p = rawXPosition(m_settings->windowRect(m_curDockPos).topLeft());
|
||||
const QSize &s = m_settings->windowSize();
|
||||
const QRect &primaryRawRect = m_settings->currentRawRect();
|
||||
const QRect &primaryRawRect = m_settings->primaryRawRect();
|
||||
|
||||
XcbMisc::Orientation orientation = XcbMisc::OrientationTop;
|
||||
uint strut = 0;
|
||||
@ -831,14 +825,15 @@ void MainWindow::resetPanelEnvironment(const bool visible, const bool resetPosit
|
||||
void MainWindow::updatePanelVisible()
|
||||
{
|
||||
if (m_settings->hideMode() == KeepShowing) {
|
||||
if (!m_registerKey.isEmpty()){
|
||||
m_eventInter->UnregisterArea(m_registerKey);
|
||||
if (m_regionMonitor->registered()){
|
||||
m_regionMonitor->unregisterRegion();
|
||||
}
|
||||
return expand();
|
||||
}
|
||||
|
||||
if (m_registerKey.isEmpty()){
|
||||
updateRegionMonitorWatch();
|
||||
if (!m_regionMonitor->registered()){
|
||||
m_regionMonitor->registerRegion();
|
||||
m_regionMonitor->setCoordinateType(DRegionMonitor::ScaleRatio);
|
||||
}
|
||||
|
||||
const Dock::HideState state = m_settings->hideState();
|
||||
@ -1039,98 +1034,31 @@ void MainWindow::themeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onRegionMonitorChanged(int x, int y, const QString &key)
|
||||
void MainWindow::onRegionMonitorChanged()
|
||||
{
|
||||
if (m_registerKey != key)
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
return;
|
||||
|
||||
QScreen *screen = Utils::screenAtByScaled(QPoint(x, y));
|
||||
|
||||
if (screen->name() == m_settings->currentDockScreen()) {
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
return;
|
||||
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
} else {
|
||||
// 移动Dock至相应屏相应位置
|
||||
m_mouseCauseDock = true;
|
||||
m_settings->setDockScreen(screen->name());
|
||||
positionChanged(m_curDockPos, m_curDockPos);
|
||||
}
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void MainWindow::updateRegionMonitorWatch()
|
||||
{
|
||||
if (!m_registerKey.isEmpty()) {
|
||||
m_eventInter->UnregisterArea(m_registerKey);
|
||||
m_registerKey.clear();
|
||||
}
|
||||
|
||||
const int flags = Motion | Button | Key;
|
||||
|
||||
QList<QRect> screensRect = m_settings->monitorsRect();
|
||||
QList<MonitRect> monitorAreas;
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
return;
|
||||
|
||||
int val = 5;
|
||||
const qreal scale = devicePixelRatioF();
|
||||
int val = 3;
|
||||
int x, y, w, h;
|
||||
|
||||
auto func = [&](MonitRect &monitRect){
|
||||
monitRect.x1 = int(x * scale);
|
||||
monitRect.y1 = int(y * scale);
|
||||
monitRect.x2 = int((x + w) * scale);
|
||||
monitRect.y2 = int((y + h) * scale);
|
||||
monitorAreas << monitRect;
|
||||
};
|
||||
|
||||
if (screensRect.size()) {
|
||||
MonitRect monitRect;
|
||||
switch (m_curDockPos) {
|
||||
case Dock::Top: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y();
|
||||
w = rect.width();
|
||||
h = val;
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Bottom: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y() + rect.height() - val;
|
||||
w = rect.width();
|
||||
h = val;
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Left: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y();
|
||||
w = val;
|
||||
h = rect.height();
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Right: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x() + rect.width() - val;
|
||||
y = rect.y();
|
||||
w = val;
|
||||
h = rect.height();
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_registerKey = m_eventInter->RegisterAreas(monitorAreas , flags);
|
||||
const int margin = m_settings->dockMargin();
|
||||
if (Dock::Top == m_curDockPos) {
|
||||
m_regionMonitor->setWatchedRegion(QRegion(margin * scale, 0, (m_settings->primaryRect().width() - margin*2) * scale, val *scale));
|
||||
} else if (Dock::Bottom == m_curDockPos) {
|
||||
m_regionMonitor->setWatchedRegion(QRegion(margin * scale, (m_settings->primaryRect().height() - val)* scale, (m_settings->primaryRect().width() - margin*2)*scale, val * scale));
|
||||
} else if (Dock::Left == m_curDockPos) {
|
||||
m_regionMonitor->setWatchedRegion(QRegion(0, margin * scale, val * scale, (m_settings->primaryRect().height() - margin*2) * scale));
|
||||
} else {
|
||||
m_registerKey = m_eventInter->RegisterFullScreen();
|
||||
m_regionMonitor->setWatchedRegion(QRegion((m_settings->primaryRect().width() - val) * scale, margin * scale, val * scale, (m_settings->primaryRect().height()- margin*2)*scale));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,39 +24,34 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "xcb/xcb_misc.h"
|
||||
#include "dbus/dbusdisplay.h"
|
||||
#include "dbus/dbusdockadaptors.h"
|
||||
#include "dbus/sni/statusnotifierwatcher_interface.h"
|
||||
#include "util/docksettings.h"
|
||||
#include "panel/mainpanelcontrol.h"
|
||||
|
||||
#include <com_deepin_api_xeventmonitor.h>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QRect>
|
||||
|
||||
#include <DPlatformWindowHandle>
|
||||
#include <DWindowManagerHelper>
|
||||
#include <DBlurEffectWidget>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <QWidget>
|
||||
#include <DRegionMonitor>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
using XEventMonitor = ::com::deepin::api::XEventMonitor;
|
||||
|
||||
class DockSettings;
|
||||
class DragWidget;
|
||||
class MainPanel;
|
||||
class MainPanelControl;
|
||||
class QTimer;
|
||||
class DBusDockAdaptors;
|
||||
class MainWindow : public DBlurEffectWidget, public MainPanelDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum Flag{
|
||||
Motion = 1 << 0,
|
||||
Button = 1 << 1,
|
||||
Key = 1 << 2
|
||||
};
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void setEffectEnabled(const bool enabled);
|
||||
void setComposite(const bool hasComposite);
|
||||
@ -88,7 +83,7 @@ private:
|
||||
void x11MoveWindow(const int x, const int y);
|
||||
void x11MoveResizeWindow(const int x, const int y, const int w, const int h);
|
||||
bool appIsOnDock(const QString &appDesktop);
|
||||
void onRegionMonitorChanged(int x, int y, const QString &key);
|
||||
void onRegionMonitorChanged();
|
||||
void updateRegionMonitorWatch();
|
||||
void getTrayVisableItemCount();
|
||||
|
||||
@ -124,9 +119,7 @@ private:
|
||||
|
||||
DPlatformWindowHandle m_platformWindowHandle;
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
XEventMonitor *m_eventInter;
|
||||
QString m_registerKey;
|
||||
QStringList m_registerKeys;
|
||||
DRegionMonitor *m_regionMonitor;
|
||||
|
||||
QTimer *m_positionUpdateTimer;
|
||||
QTimer *m_expandDelayTimer;
|
||||
|
@ -179,9 +179,9 @@ void SoundItem::refreshIcon()
|
||||
QString volumeString;
|
||||
if (mute)
|
||||
volumeString = "muted";
|
||||
else if (volmue / 1000.0f >= double(2) / 3)
|
||||
else if (volmue / 100.0f >= double(2) / 3)
|
||||
volumeString = "high";
|
||||
else if (volmue / 1000.0f >= double(1) / 3)
|
||||
else if (volmue / 100.0f >= double(1) / 3)
|
||||
volumeString = "medium";
|
||||
else
|
||||
volumeString = "low";
|
||||
|
Loading…
x
Reference in New Issue
Block a user