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 real windowRadius: isHorizontal ? root.height * 0.3 : root.width * 0.3
property bool compositing: windowHelper.compositing
onCompositingChanged: {
mainWindow.updateSize()
}
DropArea {
anchors.fill: parent
@ -41,9 +46,9 @@ Item {
Rectangle {
id: _background
anchors.fill: parent
radius: windowHelper.compositing ? windowRadius : 0
radius: root.compositing ? windowRadius : 0
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
Behavior on color {

View file

@ -91,12 +91,23 @@ MainWindow::~MainWindow()
{
}
void MainWindow::updateSize()
{
resizeWindow();
}
QRect MainWindow::windowRect() const
{
const QRect screenGeometry = screen()->geometry();
const QRect availableGeometry = screen()->availableGeometry();
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);
QPoint position(0, 0);
@ -114,21 +125,23 @@ QRect MainWindow::windowRect() const
length = appCount * iconSize;
}
int margins = compositing ? DockSettings::self()->edgeMargins() / 2 : 0;
switch (m_settings->direction()) {
case DockSettings::Left:
newSize = QSize(iconSize, length);
position.setX(screenGeometry.x() + DockSettings::self()->edgeMargins() / 2);
position.setX(screenGeometry.x() + margins);
// Handle the top statusbar.
position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2);
break;
case DockSettings::Bottom:
newSize = QSize(length, iconSize);
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;
case DockSettings::Right:
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);
break;
default:
@ -186,8 +199,15 @@ void MainWindow::initSlideWindow()
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()) {
XWindowInterface::instance()->setViewStruts(this, m_settings->direction(), geometry());
XWindowInterface::instance()->setViewStruts(this, m_settings->direction(), geometry(), compositing);
} else {
clearViewStruts();
}

View file

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

View file

@ -143,7 +143,7 @@ bool XWindowInterface::isAcceptableWindow(quint64 wid)
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;
@ -151,25 +151,27 @@ void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction dire
const QRect currentScreen {screen->geometry()};
const QRect wholeScreen { {0, 0}, screen->virtualSize() };
// const int edgeMargins = compositing ? DockSettings::self()->edgeMargins() : 0;
int edgeMargins = 0;
switch (direction) {
case DockSettings::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_end = rect.y() + rect.height() - 1;
break;
}
case DockSettings::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_end = rect.x() + rect.width();
break;
}
case DockSettings::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_end = rect.y() + rect.height() - 1;
break;

View file

@ -47,7 +47,7 @@ public:
QString requestWindowClass(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 startInitWindows();