Adaptation has no compositing effect

This commit is contained in:
reionwong 2021-08-16 08:58:33 +08:00
parent 2a1361f36f
commit b7dc7ec898
5 changed files with 40 additions and 11 deletions

View file

@ -31,6 +31,11 @@ Item {
property bool isHorizontal: Settings.direction === DockSettings.Bottom property bool isHorizontal: Settings.direction === DockSettings.Bottom
property real windowRadius: isHorizontal ? root.height * 0.3 : root.width * 0.3 property real windowRadius: isHorizontal ? root.height * 0.3 : root.width * 0.3
property bool compositing: windowHelper.compositing
onCompositingChanged: {
mainWindow.updateSize()
}
DropArea { DropArea {
anchors.fill: parent anchors.fill: parent
@ -41,9 +46,9 @@ Item {
Rectangle { Rectangle {
id: _background id: _background
anchors.fill: parent anchors.fill: parent
radius: windowHelper.compositing ? windowRadius : 0 radius: root.compositing ? windowRadius : 0
color: FishUI.Theme.darkMode ? "#595959" : "#FFFFFF" color: FishUI.Theme.darkMode ? "#595959" : "#FFFFFF"
opacity: windowHelper.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.4 : 1 opacity: root.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.4 : 0.9
border.width: 0 border.width: 0
Behavior on color { Behavior on color {

View file

@ -91,12 +91,23 @@ MainWindow::~MainWindow()
{ {
} }
void MainWindow::updateSize()
{
resizeWindow();
}
QRect MainWindow::windowRect() const QRect MainWindow::windowRect() const
{ {
const QRect screenGeometry = screen()->geometry(); const QRect screenGeometry = screen()->geometry();
const QRect availableGeometry = screen()->availableGeometry(); const QRect availableGeometry = screen()->availableGeometry();
bool isHorizontal = m_settings->direction() == DockSettings::Bottom; bool isHorizontal = m_settings->direction() == DockSettings::Bottom;
bool compositing = false;
QQuickItem *item = qobject_cast<QQuickItem *>(rootObject());
if (item) {
compositing = item->property("compositing").toBool();
}
QSize newSize(0, 0); QSize newSize(0, 0);
QPoint position(0, 0); QPoint position(0, 0);
@ -114,21 +125,23 @@ QRect MainWindow::windowRect() const
length = appCount * iconSize; length = appCount * iconSize;
} }
int margins = compositing ? DockSettings::self()->edgeMargins() / 2 : 0;
switch (m_settings->direction()) { switch (m_settings->direction()) {
case DockSettings::Left: case DockSettings::Left:
newSize = QSize(iconSize, length); newSize = QSize(iconSize, length);
position.setX(screenGeometry.x() + DockSettings::self()->edgeMargins() / 2); position.setX(screenGeometry.x() + margins);
// Handle the top statusbar. // Handle the top statusbar.
position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2); position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2);
break; break;
case DockSettings::Bottom: case DockSettings::Bottom:
newSize = QSize(length, iconSize); newSize = QSize(length, iconSize);
position.setX(screenGeometry.x() + (screenGeometry.width() - newSize.width()) / 2); position.setX(screenGeometry.x() + (screenGeometry.width() - newSize.width()) / 2);
position.setY(screenGeometry.y() + screenGeometry.height() - newSize.height() - DockSettings::self()->edgeMargins() / 2); position.setY(screenGeometry.y() + screenGeometry.height() - newSize.height() - margins);
break; break;
case DockSettings::Right: case DockSettings::Right:
newSize = QSize(iconSize, length); newSize = QSize(iconSize, length);
position.setX(screenGeometry.x() + screenGeometry.width() - newSize.width() - DockSettings::self()->edgeMargins() / 2); position.setX(screenGeometry.x() + screenGeometry.width() - newSize.width() - margins);
position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2); position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2);
break; break;
default: default:
@ -186,8 +199,15 @@ void MainWindow::initSlideWindow()
void MainWindow::updateViewStruts() void MainWindow::updateViewStruts()
{ {
bool compositing = false;
QQuickItem *item = qobject_cast<QQuickItem *>(rootObject());
if (item) {
compositing = item->property("compositing").toBool();
}
if (m_settings->visibility() == DockSettings::AlwaysShow || m_activity->launchPad()) { if (m_settings->visibility() == DockSettings::AlwaysShow || m_activity->launchPad()) {
XWindowInterface::instance()->setViewStruts(this, m_settings->direction(), geometry()); XWindowInterface::instance()->setViewStruts(this, m_settings->direction(), geometry(), compositing);
} else { } else {
clearViewStruts(); clearViewStruts();
} }

View file

@ -37,6 +37,8 @@ public:
explicit MainWindow(QQuickView *parent = nullptr); explicit MainWindow(QQuickView *parent = nullptr);
~MainWindow(); ~MainWindow();
Q_INVOKABLE void updateSize();
signals: signals:
void resizingFished(); void resizingFished();
void iconSizeChanged(); void iconSizeChanged();

View file

@ -143,7 +143,7 @@ bool XWindowInterface::isAcceptableWindow(quint64 wid)
return !NET::typeMatchesMask(info.windowType(NET::AllTypesMask), normalFlag); return !NET::typeMatchesMask(info.windowType(NET::AllTypesMask), normalFlag);
} }
void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction direction, const QRect &rect) void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction direction, const QRect &rect, bool compositing)
{ {
NETExtendedStrut strut; NETExtendedStrut strut;
@ -151,25 +151,27 @@ void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction dire
const QRect currentScreen {screen->geometry()}; const QRect currentScreen {screen->geometry()};
const QRect wholeScreen { {0, 0}, screen->virtualSize() }; const QRect wholeScreen { {0, 0}, screen->virtualSize() };
// const int edgeMargins = compositing ? DockSettings::self()->edgeMargins() : 0;
int edgeMargins = 0;
switch (direction) { switch (direction) {
case DockSettings::Left: { case DockSettings::Left: {
const int leftOffset = { screen->geometry().left() }; const int leftOffset = { screen->geometry().left() };
strut.left_width = rect.width() + leftOffset + DockSettings::self()->edgeMargins(); strut.left_width = rect.width() + leftOffset + edgeMargins;
strut.left_start = rect.y(); strut.left_start = rect.y();
strut.left_end = rect.y() + rect.height() - 1; strut.left_end = rect.y() + rect.height() - 1;
break; break;
} }
case DockSettings::Bottom: { case DockSettings::Bottom: {
const int bottomOffset { wholeScreen.bottom() - currentScreen.bottom() }; const int bottomOffset { wholeScreen.bottom() - currentScreen.bottom() };
strut.bottom_width = rect.height() + bottomOffset + DockSettings::self()->edgeMargins(); strut.bottom_width = rect.height() + bottomOffset + edgeMargins;
strut.bottom_start = rect.x(); strut.bottom_start = rect.x();
strut.bottom_end = rect.x() + rect.width(); strut.bottom_end = rect.x() + rect.width();
break; break;
} }
case DockSettings::Right: { case DockSettings::Right: {
const int rightOffset = {wholeScreen.right() - currentScreen.right()}; const int rightOffset = {wholeScreen.right() - currentScreen.right()};
strut.right_width = rect.width() + rightOffset + DockSettings::self()->edgeMargins(); strut.right_width = rect.width() + rightOffset + edgeMargins;
strut.right_start = rect.y(); strut.right_start = rect.y();
strut.right_end = rect.y() + rect.height() - 1; strut.right_end = rect.y() + rect.height() - 1;
break; break;

View file

@ -47,7 +47,7 @@ public:
QString requestWindowClass(quint64 wid); QString requestWindowClass(quint64 wid);
bool isAcceptableWindow(quint64 wid); bool isAcceptableWindow(quint64 wid);
void setViewStruts(QWindow *view, DockSettings::Direction direction, const QRect &rect); void setViewStruts(QWindow *view, DockSettings::Direction direction, const QRect &rect, bool compositing = false);
void clearViewStruts(QWindow *view); void clearViewStruts(QWindow *view);
void startInitWindows(); void startInitWindows();