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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

set(DS_VERSION "0.0.34" CACHE STRING "Define project version")
set(DS_VERSION "1.99.0" CACHE STRING "Define project version")
project(DDEShell
VERSION "${DS_VERSION}"
DESCRIPTION "dde-shell"
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Build-Depends:
libqt6svg6,
libdtk6declarative, qml6-module-qtquick-controls2-styles-chameleon, qt6-declarative-private-dev,
libyaml-cpp-dev,
qt6-l10n-tools, qt6-svg-dev, dde-tray-loader-dev (>= 1.99.5),
qt6-l10n-tools, qt6-svg-dev, dde-tray-loader-dev (> 1.99.6),
dde-application-manager-api (>= 1.2.16), dde-control-center-dev (>= 6.0.73)
Standards-Version: 3.9.8
Homepage: http://www.deepin.org
Expand Down
2 changes: 2 additions & 0 deletions frame/popupwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ DS_BEGIN_NAMESPACE
PopupWindow::PopupWindow(QWindow *parent)
: QQuickWindowQmlImpl(parent)
{
setMinimumHeight(10);
setMinimumWidth(10);
}

void PopupWindow::mouseReleaseEvent(QMouseEvent *event)
Expand Down
14 changes: 14 additions & 0 deletions frame/qml/PanelPopupWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ PopupWindow {
return value
}

// FIXME: The contentItem of QQuickWindow originally maintains the same size as the Window in the resizeEvent of QQuickWindow,
// but there will be inconsistencies under Wayland. Maybe it is a bug of QtWayland.
Binding {
target: root.contentItem
property: "width"
value: root.width
}

Binding {
target: root.contentItem
property: "height"
value: root.height
}

width: 10
height: 10
flags: (Qt.platform.pluginName === "xcb" ? (Qt.Tool | Qt.WindowStaysOnTopHint) : Qt.Popup)
Expand Down
1 change: 1 addition & 0 deletions panels/dock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ qt_add_qml_module(dock-plugin
qt_generate_wayland_protocol_server_sources(dock-plugin
FILES
${DDE_TRAY_LOADER_PROTOCOL}
${WaylandProtocols_DATADIR}/staging/fractional-scale/fractional-scale-v1.xml
)

target_link_libraries(dock-plugin PUBLIC
Expand Down
6 changes: 6 additions & 0 deletions panels/dock/DockCompositor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Item {
property ListModel fixedPluginSurfaces: ListModel {}

property var compositor: waylandCompositor
property var panelScale: 1.0

signal pluginSurfacesUpdated()
signal popupCreated(var popup)
Expand Down Expand Up @@ -107,5 +108,10 @@ Item {
dockCompositor.requestShutdown()
}
}

PluginScaleManager{
id: pluginScaleManager
pluginScale: dockCompositor.panelScale * 120
}
}
}
18 changes: 18 additions & 0 deletions panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ bool DockPanel::init()
else {
m_dockScreen = window()->screen();
}
rootObject()->installEventFilter(this);
Q_EMIT devicePixelRatioChanged(window()->devicePixelRatio());
}
});

Expand Down Expand Up @@ -391,6 +393,22 @@ QString DockPanel::screenName() const
return {};
return m_dockScreen->name();
}

qreal DockPanel::devicePixelRatio() const
{
if (!window())
return 1.0;
return window()->devicePixelRatio();
}

bool DockPanel::eventFilter(QObject *watched, QEvent *event)
{
if (watched == window() && event->type() == QEvent::DevicePixelRatioChange) {
Q_EMIT devicePixelRatioChanged(window()->devicePixelRatio());
}

return false;
}
}

#include "dockpanel.moc"
8 changes: 8 additions & 0 deletions panels/dock/dockpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
Q_PROPERTY(QString screenName READ screenName NOTIFY screenNameChanged FINAL)

Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged FINAL)

Q_PROPERTY(bool debugMode READ debugMode FINAL CONSTANT)

public:
Expand Down Expand Up @@ -82,6 +84,11 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
void setDockScreen(QScreen *screen);
QString screenName() const;

qreal devicePixelRatio() const;

protected:
bool eventFilter(QObject *watched, QEvent *event) override;

private Q_SLOTS:
void onWindowGeometryChanged();
void launcherVisibleChanged(bool visible);
Expand All @@ -103,6 +110,7 @@ private Q_SLOTS:
void dockScreenChanged(QScreen *screen);
void screenNameChanged();
void requestClosePopup();
void devicePixelRatioChanged(qreal ratio);

private:
ColorTheme m_theme;
Expand Down
3 changes: 0 additions & 3 deletions panels/dock/loadtrayplugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ void LoadTrayPlugins::setProcessEnv(QProcess *process)
if (!process) return;

QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("QT_SCALE_FACTOR", QString::number(qApp->devicePixelRatio()));
env.insert("D_DXCB_DISABLE_OVERRIDE_HIDPI", "1");

// TODO: use protocols to determine the environment instead of environment variables
env.remove("DDE_CURRENT_COMPOSITOR");

Expand Down
4 changes: 4 additions & 0 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ Window {
return Qt.size(Panel.frontendWindowRect.width, Panel.frontendWindowRect.height)
})

DockCompositor.panelScale = Qt.binding(function(){
return Panel.devicePixelRatio
})

dock.itemIconSizeBase = dock.dockItemMaxSize
dock.visible = Panel.hideState !== Dock.Hide
changeDragAreaAnchor()
Expand Down
124 changes: 120 additions & 4 deletions panels/dock/pluginmanagerextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,74 @@
#include <QJsonObject>
#include <QJsonParseError>

PluginScaleManager::PluginScaleManager(QWaylandCompositor *compositor)
: QWaylandCompositorExtensionTemplate(compositor)
, m_compositor(compositor)
{
}

void PluginScaleManager::setPluginScale(const uint32_t &scale)
{
if (scale == m_scale)
return;
m_scale = scale;
if (!m_compositor)
return;

auto outputs = m_compositor->outputs();
std::for_each(outputs.begin(), outputs.end(), [this](auto *output) {
// 120 is base of fractional scale.
output->setScaleFactor(std::ceil(m_scale / 120));
});

Q_EMIT pluginScaleChanged(m_scale);
}

uint32_t PluginScaleManager::pluginScale()
{
return m_scale;
}

void PluginScaleManager::initialize()
{
QWaylandCompositorExtensionTemplate::initialize();
QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
Q_ASSERT(compositor);

init(compositor->display(), 1);
m_compositor = compositor;
connect(compositor, &QWaylandCompositor::outputAdded, this, [this](auto *output) {
output->setScaleFactor(std::ceil(m_scale / 120));
});
}

void PluginScaleManager::wp_fractional_scale_manager_v1_get_fractional_scale(Resource *resource, uint32_t id, struct ::wl_resource *surface)
{
QWaylandSurface *qwaylandSurface = QWaylandSurface::fromResource(surface);
QWaylandResource shellSurfaceResource(
wl_resource_create(resource->client(), &::wp_fractional_scale_v1_interface, wl_resource_get_version(resource->handle), id));
auto pluginScale = new PluginScale(this, qwaylandSurface, shellSurfaceResource);
pluginScale->send_preferred_scale(m_scale);
}

PluginScale::PluginScale(PluginScaleManager *manager, QWaylandSurface *surface, const QWaylandResource &resource)
{
setParent(manager);
init(resource.resource());
setExtensionContainer(surface);
QWaylandCompositorExtension::initialize();

connect(manager, &PluginScaleManager::pluginScaleChanged, this, [this](uint32_t scale) {
send_preferred_scale(scale);
});
}

void PluginScale::wp_fractional_scale_v1_destroy(Resource *resource)
{
Q_UNUSED(resource)
deleteLater();
}

PluginSurface::PluginSurface(PluginManager* manager, const QString& pluginId, const QString& itemKey, const QString &displayName, int pluginFlags, int pluginType, int sizePolicy, QWaylandSurface *surface, const QWaylandResource &resource)
: m_manager(manager)
, m_surface(surface)
Expand All @@ -29,8 +97,6 @@ PluginSurface::PluginSurface(PluginManager* manager, const QString& pluginId, co
init(resource.resource());
setExtensionContainer(surface);
QWaylandCompositorExtension::initialize();

connect(surface, &QWaylandSurface::bufferSizeChanged, this, &PluginSurface::sizeChanged);
}

QWaylandQuickShellIntegration* PluginSurface::createIntegration(QWaylandQuickShellSurfaceItem *item)
Expand Down Expand Up @@ -73,9 +139,14 @@ uint32_t PluginSurface::pluginSizePolicy () const
return m_sizePolicy;
}

QSize PluginSurface::pluginSize() const
int PluginSurface::height() const
{
return m_surface->bufferSize() / qApp->devicePixelRatio();
return m_height;
}

int PluginSurface::width() const
{
return m_width;
}

QString PluginSurface::dccIcon() const
Expand Down Expand Up @@ -151,6 +222,23 @@ void PluginSurface::setGlobalPos(const QPoint &pos)
send_raw_global_pos(p.x(), p.y());
}

void PluginSurface::plugin_source_size(Resource *resource, int32_t width, int32_t height)
{
Q_UNUSED(resource);
if (width == 0 || height == 0)
return;

if (height != m_height) {
m_height = height;
Q_EMIT heightChanged();
}

if (width != m_width) {
m_width = width;
Q_EMIT widthChanged();
}
}

PluginPopup::PluginPopup(PluginManager* manager, const QString &pluginId, const QString &itemKey, int x, int y, int popupType, QWaylandSurface *surface, const QWaylandResource &resource)
: m_manager(manager)
, m_surface(surface)
Expand Down Expand Up @@ -215,6 +303,16 @@ void PluginPopup::setY(int32_t y)
Q_EMIT yChanged();
}

int PluginPopup::height() const
{
return m_height;
}

int PluginPopup::width() const
{
return m_width;
}

int32_t PluginPopup::popupType() const
{
return m_popupType;
Expand All @@ -238,6 +336,24 @@ void PluginPopup::plugin_popup_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}

void PluginPopup::plugin_popup_source_size(Resource *resource, int32_t width, int32_t height)
{
Q_UNUSED(resource);
if (width == 0 || height == 0)
return;

if (height != m_height) {
m_height = height;
Q_EMIT heightChanged();
}

if (width != m_width) {
m_width = width;
Q_EMIT widthChanged();
}
}

PluginManager::PluginManager(QWaylandCompositor *compositor)
: QWaylandCompositorExtensionTemplate(compositor)
{
Expand Down
Loading
Loading