Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/core/qml/Decoration.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Item {
id: root

required property SurfaceWrapper surface
readonly property SurfaceItem surfaceItem: surface.surfaceItem

visible: surface && surface.visibleDecoration && surface.visible
x: shadow.boundingRect.x
Expand All @@ -19,7 +18,9 @@ Item {
height: shadow.boundingRect.height

MouseArea {
enabled: surface.type !== SurfaceWrapper.Type.XdgPopup && surface.type !== SurfaceWrapper.Type.Layer
enabled: surface.type !== SurfaceWrapper.Type.XdgPopup
&& surface.type !== SurfaceWrapper.Type.Layer
&& surface.type !== SurfaceWrapper.Type.Undetermined
property int edges: 0

anchors {
Expand Down Expand Up @@ -73,7 +74,7 @@ Item {

Border {
visible: surface.visibleDecoration
parent: surfaceItem
parent: surface.surfaceItem ? surface.surfaceItem : surface.prelaunchSplash
z: SurfaceItem.ZOrder.ContentItem + 1
anchors.fill: parent
radius: surface.radius
Expand Down
13 changes: 8 additions & 5 deletions src/core/qml/PrelaunchSplash.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import QtQuick.Controls
Item {
id: splash

property string logoPath: ""
required property string logoPath
required property real initialRadius
property bool destroyAfterFade: false
signal destroyRequested

// Fill the entire parent (SurfaceWrapper)
anchors.fill: parent

Rectangle {
radius: 10 // TODO: use Decoration's radius
id: background
color: "#ffffff"
// Fill parent; size is dictated by parent
anchors.fill: parent
radius: initialRadius

// Centered logo
Image {
Expand Down Expand Up @@ -55,12 +56,14 @@ Item {
target: splash
from: 1.0
to: 0.0
duration: 500
duration: 400

onFinished: {
splash.visible = false
if (splash.destroyAfterFade) {
splash.destroy();
// Request C++ side to destroy this item to avoid calling destroy()
// on an object owned by C++.
splash.destroyRequested();
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/core/qmlengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,10 @@ QQuickItem *QmlEngine::createWindowPicker(QQuickItem *parent)
return createComponent(windowPickerComponent, parent);
}

QQuickItem *QmlEngine::createPrelaunchSplash(QQuickItem *parent, const QString &logoPath)
QQuickItem *QmlEngine::createPrelaunchSplash(QQuickItem *parent, const QString &logoPath, qreal initialRadius)
{
QVariantMap properties;
if (!logoPath.isEmpty()) {
properties["logoPath"] = logoPath;
}
return createComponent(prelaunchSplashComponent, parent, properties);
return createComponent(prelaunchSplashComponent, parent, {
{ "logoPath", QVariant::fromValue(logoPath) },
{ "initialRadius", QVariant::fromValue(initialRadius) },
});
}
4 changes: 3 additions & 1 deletion src/core/qmlengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class QmlEngine : public QQmlApplicationEngine
QQuickItem *createShowDesktopAnimation(SurfaceWrapper *surface, QQuickItem *parent, bool show);
QQuickItem *createCaptureSelector(QQuickItem *parent, CaptureManagerV1 *captureManager);
QQuickItem *createWindowPicker(QQuickItem *parent);
QQuickItem *createPrelaunchSplash(QQuickItem *parent, const QString &logoPath = QString());
QQuickItem *createPrelaunchSplash(QQuickItem *parent,
const QString &logoPath,
qreal initialRadius);

QQmlComponent *surfaceContentComponent()
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/shellhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void ShellHandler::updateWrapperContainer(SurfaceWrapper *wrapper,
if (qobject_cast<Workspace *>(oldContainer) == nullptr) {
oldContainer->removeSurface(wrapper);
m_workspace->addSurface(wrapper);
}
}
// else do nothing, already in workspace
} else {
m_workspace->addSurface(wrapper);
Expand Down
149 changes: 89 additions & 60 deletions src/surface/surfacewrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Copyright (C) 2024 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "surface/surfacewrapper.h"

Check warning on line 4 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "surface/surfacewrapper.h" not found.

#include "seat/helper.h"
#include "treelandconfig.hpp"
#include "common/treelandlogging.h"

Check warning on line 6 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common/treelandlogging.h" not found.
#include "core/qmlengine.h"

Check warning on line 7 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "core/qmlengine.h" not found.
#include "output/output.h"

Check warning on line 8 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "output/output.h" not found.
#include "seat/helper.h"

Check warning on line 9 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "seat/helper.h" not found.
#include "treelandconfig.hpp"

Check warning on line 10 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "treelandconfig.hpp" not found.
#include "workspace/workspace.h"

Check warning on line 11 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "workspace/workspace.h" not found.
#include "common/treelandlogging.h"

#include <QTimer>

#include <winputpopupsurfaceitem.h>

Check warning on line 13 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <winputpopupsurfaceitem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wlayersurface.h>

Check warning on line 14 in src/surface/surfacewrapper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wlayersurface.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wlayersurfaceitem.h>
#include <woutput.h>
#include <woutputitem.h>
Expand Down Expand Up @@ -91,23 +89,21 @@
{
QQmlEngine::setContextForObject(this, qmlEngine->rootContext());
if (initialSize.isValid() && initialSize.width() > 0 && initialSize.height() > 0) {
// Also set implicit size to keep QML layout consistent
// Also set implicit size to keep QML layout consistent
setImplicitSize(initialSize.width(), initialSize.height());
qInfo() << "Prelaunch Splash: set initial size to" << initialSize;
} else {
setImplicitSize(800, 600);
}
setNoDecoration(false);

m_prelaunchSplash = m_engine->createPrelaunchSplash(this);
m_prelaunchSplash->setZ(9999999999);
m_prelaunchSplash = m_engine->createPrelaunchSplash(this, QString(), radius());
m_prelaunchSplash->setZ(99999);
// Connect to QML signal so C++ can destroy the QML item when requested
connect(m_prelaunchSplash,
SIGNAL(destroyRequested()),
this,
SLOT(onPrelaunchSplashDestroyRequested()));

connect(m_prelaunchSplash, &QQuickItem::visibleChanged,
this, [this] {
if (m_surfaceItem)
setImplicitSize(m_surfaceItem->implicitWidth(), m_surfaceItem->implicitHeight());
updateVisible();
});
setNoDecoration(false);
}

SurfaceWrapper::~SurfaceWrapper()
Expand Down Expand Up @@ -183,53 +179,55 @@
requestCancelMinimize();
});
m_shellSurface->safeConnect(&WToplevelSurface::requestMaximize,
this,
&SurfaceWrapper::requestMaximize);
this,
&SurfaceWrapper::requestMaximize);
m_shellSurface->safeConnect(&WToplevelSurface::requestCancelMaximize,
this,
&SurfaceWrapper::requestCancelMaximize);
this,
&SurfaceWrapper::requestCancelMaximize);
m_shellSurface->safeConnect(&WToplevelSurface::requestMove,
this,
&SurfaceWrapper::requestMove);
this,
&SurfaceWrapper::requestMove);
m_shellSurface->safeConnect(&WToplevelSurface::requestResize,
this,
[this](WSeat *, Qt::Edges edge, quint32) {
Q_EMIT requestResize(edge);
});
this,
[this](WSeat *, Qt::Edges edge, quint32) {
Q_EMIT requestResize(edge);
});
m_shellSurface->safeConnect(&WToplevelSurface::requestFullscreen,
this,
&SurfaceWrapper::requestFullscreen);
this,
&SurfaceWrapper::requestFullscreen);
m_shellSurface->safeConnect(&WToplevelSurface::requestCancelFullscreen,
this,
&SurfaceWrapper::requestCancelFullscreen);
this,
&SurfaceWrapper::requestCancelFullscreen);

if (m_type == Type::XdgToplevel) {
m_shellSurface->safeConnect(&WToplevelSurface::requestShowWindowMenu,
this,
[this](WSeat *, QPoint pos, quint32) {
Q_EMIT requestShowWindowMenu(
{ pos.x() + m_surfaceItem->leftPadding(),
pos.y() + m_surfaceItem->topPadding() });
});
this,
[this](WSeat *, QPoint pos, quint32) {
Q_EMIT requestShowWindowMenu(
{ pos.x() + m_surfaceItem->leftPadding(),
pos.y() + m_surfaceItem->topPadding() });
});
}
}
m_shellSurface->surface()->safeConnect(&WSurface::mappedChanged,
this,
&SurfaceWrapper::onMappedChanged);
this,
&SurfaceWrapper::onMappedChanged);

connect(m_surfaceItem,
&WSurfaceItem::boundingRectChanged,
this,
&SurfaceWrapper::updateBoundingRect);
connect(m_surfaceItem, &WSurfaceItem::implicitWidthChanged, this, [this] {
setImplicitWidth(m_surfaceItem->implicitWidth());
});
connect(m_surfaceItem, &WSurfaceItem::implicitHeightChanged, this, [this] {
setImplicitHeight(m_surfaceItem->implicitHeight());
});

if (!m_prelaunchSplash || !m_prelaunchSplash->isVisible())
Q_EMIT surfaceItemChanged();

if (!m_prelaunchSplash || !m_prelaunchSplash->isVisible()) {
setImplicitSize(m_surfaceItem->implicitWidth(), m_surfaceItem->implicitHeight());
connect(m_surfaceItem, &WSurfaceItem::implicitWidthChanged, this, [this] {
setImplicitWidth(m_surfaceItem->implicitWidth());
});
connect(m_surfaceItem, &WSurfaceItem::implicitHeightChanged, this, [this] {
setImplicitHeight(m_surfaceItem->implicitHeight());
});
connect(m_surfaceItem,
&WSurfaceItem::boundingRectChanged,
this,
&SurfaceWrapper::updateBoundingRect);
}

if (auto client = m_shellSurface->waylandClient()) {
connect(client->socket(),
Expand Down Expand Up @@ -322,14 +320,13 @@

// Assign new shell surface (QPointer auto-detects destruction)
m_shellSurface = shellSurface;

m_type = type;

// Call setup() to initialize surfaceItem related features
setup();
// setNoDecoration not called updateTitleBar when type is Undetermined
updateTitleBar();

// After conversion refresh visibility and bounding rect
updateBoundingRect();
QMetaObject::invokeMethod(m_prelaunchSplash, "hideAndDestroy", Qt::QueuedConnection);
}

Expand Down Expand Up @@ -373,6 +370,32 @@
m_surfaceItem->setFocus(false, reason);
}

void SurfaceWrapper::onPrelaunchSplashDestroyRequested()
{
if (m_surfaceItem) {
setImplicitSize(m_surfaceItem->implicitWidth(), m_surfaceItem->implicitHeight());
connect(m_surfaceItem, &WSurfaceItem::implicitWidthChanged, this, [this] {
setImplicitWidth(m_surfaceItem->implicitWidth());
});
connect(m_surfaceItem, &WSurfaceItem::implicitHeightChanged, this, [this] {
setImplicitHeight(m_surfaceItem->implicitHeight());
});
connect(m_surfaceItem,
&WSurfaceItem::boundingRectChanged,
this,
&SurfaceWrapper::updateBoundingRect);
}
if (m_decoration)
m_decoration->stackBefore(m_surfaceItem);
updateVisible();

if (!m_prelaunchSplash)
return;
m_prelaunchSplash->deleteLater();
m_prelaunchSplash = nullptr;
Q_EMIT prelaunchSplashChanged();
}

WSurface *SurfaceWrapper::surface() const
{
if (!m_shellSurface)
Expand All @@ -391,6 +414,11 @@
return m_surfaceItem;
}

QQuickItem *SurfaceWrapper::prelaunchSplash() const
{
return m_prelaunchSplash;
}

bool SurfaceWrapper::resize(const QSizeF &size)
{
// No surfaceItem in prelaunch mode -> return false
Expand Down Expand Up @@ -744,7 +772,7 @@
return;

m_noDecoration = newNoDecoration;
if (m_titleBarState == TitleBarState::Default)
if (m_titleBarState == TitleBarState::Default && m_type != Type::Undetermined)
updateTitleBar();

if (m_noDecoration) {
Expand All @@ -755,7 +783,7 @@
} else {
Q_ASSERT(!m_decoration);
m_decoration = m_engine->createDecoration(this, this);
m_decoration->stackBefore(m_surfaceItem);
m_decoration->stackBefore(m_surfaceItem ? m_surfaceItem : m_prelaunchSplash);
connect(m_decoration, &QQuickItem::xChanged, this, &SurfaceWrapper::updateBoundingRect);
connect(m_decoration, &QQuickItem::yChanged, this, &SurfaceWrapper::updateBoundingRect);
connect(m_decoration, &QQuickItem::widthChanged, this, &SurfaceWrapper::updateBoundingRect);
Expand All @@ -775,8 +803,7 @@
return;

// No surfaceItem in prelaunch mode -> early return
if (!m_surfaceItem)
return;
Q_ASSERT(m_surfaceItem);

if (noTitleBar() == !m_titleBar)
return;
Expand Down Expand Up @@ -951,7 +978,8 @@
if (m_wrapperAboutToRemove)
return;

// In prelaunch mode there is no shellSurface; update state only without calling shellSurface methods
// In prelaunch mode there is no shellSurface; update state only without calling shellSurface
// methods
if (!m_shellSurface) {
m_previousSurfaceState.setValueBypassingBindings(m_surfaceState);
m_surfaceState.setValueBypassingBindings(newSurfaceState);
Expand Down Expand Up @@ -1097,7 +1125,7 @@
bool mapped = surface()->mapped() && !m_hideByLockScreen;
if (!m_isProxy) {
if (mapped) {
//createNewOrClose(OPEN_ANIMATION);
// createNewOrClose(OPEN_ANIMATION);
if (m_coverContent) {
m_coverContent->setVisible(true);
}
Expand Down Expand Up @@ -1202,7 +1230,8 @@

qreal radius = m_radius;

// TODO: Handle: XdgToplevel, popup, InputPopup, XWayland (bypass, window type: menu/normal/popup)
// TODO: Handle: XdgToplevel, popup, InputPopup, XWayland (bypass, window type:
// menu/normal/popup)
if (radius < 1 && m_type != Type::Layer) {
radius = Helper::instance()->config()->windowRadius();
}
Expand Down
Loading
Loading