Skip to content
Open
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
57 changes: 56 additions & 1 deletion panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
// for old api compatible
#include "dockdbusproxy.h"
#include "dockfrontadaptor.h"
#include "dockdaemonadaptor.h"

Check warning on line 17 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dockdaemonadaptor.h" not found.

#include <DGuiApplicationHelper>

Check warning on line 19 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 20 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 21 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 22 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 23 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 24 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 25 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 26 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <wayland/xdgactivation.h>

Expand All @@ -45,6 +47,10 @@
, m_contextDragging(false)
, m_isResizing(false)
{
connect(this, &DockPanel::fashionModeChanged, this, &DockPanel::syncSpotlightTracking);
connect(this, &DockPanel::hideStateChanged, this, &DockPanel::syncSpotlightTracking);
connect(this, &DockPanel::rootObjectChanged, this, &DockPanel::syncSpotlightTracking);

// The org.deepin.dde.Dock1 service name is used as the readiness flag of the
// Type=dbus systemd unit (dde-shell@DDE.service). It must only be acquired
// after the QML DockCompositor is created, so that tray plugin loader
Expand Down Expand Up @@ -546,13 +552,62 @@

bool DockPanel::eventFilter(QObject *watched, QEvent *event)
{
if (watched == window() && event->type() == QEvent::DevicePixelRatioChange) {
if (watched != window())
return false;

if (event->type() == QEvent::DevicePixelRatioChange) {
Q_EMIT devicePixelRatioChanged(window()->devicePixelRatio());
} else if (m_spotlightTracking) {
// Observe the window before delivery to Qt Quick controls. No
// per-item handlers, coordinate reports or periodic cursor queries.
switch (event->type()) {
case QEvent::Enter:
setCursorPosition(static_cast<QEnterEvent *>(event)->position());
setContainsMouse(true);
break;
case QEvent::MouseMove: {
const auto position = static_cast<QMouseEvent *>(event)->position();
setCursorPosition(position);
// A pressed control may keep its grab after the pointer leaves.
setContainsMouse(QRectF(QPointF(), window()->size()).contains(position));
break;
}
case QEvent::Leave:
case QEvent::Hide:
setContainsMouse(false);
break;
default:
break;
}
}

return false;
}

void DockPanel::syncSpotlightTracking()
{
// Cache the mode so the hot event path never needs to query settings.
m_spotlightTracking = fashionMode() && hideState() == Show;
if (!m_spotlightTracking)
setContainsMouse(false);
Comment thread
wjyrich marked this conversation as resolved.
}

void DockPanel::setContainsMouse(bool containsMouse)
{
if (m_containsMouse == containsMouse)
return;
m_containsMouse = containsMouse;
Q_EMIT containsMouseChanged(containsMouse);
}

void DockPanel::setCursorPosition(const QPointF &cursorPosition)
{
if (m_cursorPosition == cursorPosition)
return;
m_cursorPosition = cursorPosition;
Q_EMIT cursorPositionChanged(cursorPosition);
}

bool DockPanel::contextDragging() const
{
return m_contextDragging;
Expand Down
15 changes: 15 additions & 0 deletions panels/dock/dockpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include "dsglobal.h"
#include "constants.h"

#include <QDBusContext>

Check warning on line 11 in panels/dock/dockpanel.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusContext> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>
#include <QPointF>

namespace dock {
class DockHelper;
Expand Down Expand Up @@ -44,6 +45,8 @@
Q_PROPERTY(bool debugMode READ debugMode FINAL CONSTANT)

Q_PROPERTY(bool contextDragging READ contextDragging WRITE setContextDragging NOTIFY contextDraggingChanged FINAL)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged FINAL)
Q_PROPERTY(QPointF cursorPosition READ cursorPosition NOTIFY cursorPositionChanged FINAL)

public:
explicit DockPanel(QObject *parent = nullptr);
Expand Down Expand Up @@ -119,6 +122,9 @@
bool contextDragging() const;
void setContextDragging(bool newContextDragging);

bool containsMouse() const { return m_containsMouse; }
QPointF cursorPosition() const { return m_cursorPosition; }

bool isResizing() const;
void setIsResizing(bool resizing);

Expand All @@ -129,6 +135,7 @@
void onWindowGeometryChanged();
void launcherVisibleChanged(bool visible);
void updateDockScreen();
void syncSpotlightTracking();

Q_SIGNALS:
void geometryChanged(QRect geometry);
Expand Down Expand Up @@ -156,12 +163,20 @@
void fashionModeEnabledChanged(bool enabled);

void contextDraggingChanged();
void containsMouseChanged(bool containsMouse);
void cursorPositionChanged(const QPointF &cursorPosition);
void isResizingChanged(bool isResizing);

// Emitted when async XEmbed window move completes
void xembedWindowMoveResult(uint32_t wid, bool success);

private:
void setContainsMouse(bool containsMouse);
void setCursorPosition(const QPointF &cursorPosition);

bool m_spotlightTracking = false;
bool m_containsMouse = false;
QPointF m_cursorPosition;
ColorTheme m_theme;
HideState m_hideState;
DockHelper* m_helper;
Expand Down
55 changes: 55 additions & 0 deletions panels/dock/package/DockSpotlight.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick

Item {
id: spotlight
property bool containsMouse: false
property point cursorPosition: Qt.point(0, 0)
property real itemSize: 48
property bool darkTheme: false
readonly property real baseRadius: Math.max(0, Math.min(itemSize * 3.0, height * 3.0, width * 0.18))
readonly property real coreRadius: baseRadius * 0.35

clip: true
enabled: false
visible: opacity > 0
opacity: containsMouse ? 1 : 0

Behavior on opacity {
NumberAnimation { duration: 90; easing.type: Easing.OutQuad }
}

// Move a single transform instead of evaluating both images' coordinates
// on every pointer event. Both layers share the same cached 256px texture.
Item {
x: Math.max(0, Math.min(spotlight.cursorPosition.x, spotlight.width))
y: Math.max(0, Math.min(spotlight.cursorPosition.y, spotlight.height))

Image {
objectName: "spotlightImage"
width: spotlight.baseRadius * 2
height: spotlight.baseRadius * 2.6
x: -width / 2
y: -height / 2
source: "SpotlightGradient.png"
Comment thread
wjyrich marked this conversation as resolved.
fillMode: Image.Stretch
smooth: true
opacity: spotlight.darkTheme ? 0.14 : 0.2
}

Image {
objectName: "spotlightCoreImage"
width: spotlight.coreRadius * 2
height: width
x: -width / 2
y: -height / 2
source: "SpotlightGradient.png"
fillMode: Image.Stretch
smooth: true
opacity: spotlight.darkTheme ? 0.23 : 0.32
}
}
}
Binary file added panels/dock/package/SpotlightGradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,17 @@ Window {
}
}

Loader {
anchors.fill: parent
active: dock.fashionDock.enabled && Panel.hideState === Dock.Show
sourceComponent: DockSpotlight {
containsMouse: Panel.containsMouse
cursorPosition: dockContainer.mapFromItem(null, Panel.cursorPosition)
itemSize: dock.dockItemMaxSize
darkTheme: Panel.colorTheme === Dock.Dark
}
}

TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
gesturePolicy: TapHandler.WithinBounds
Expand Down
Loading