Skip to content

WIP tmp #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ include(KDEGitCommitHooks)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick WaylandClient DBus LinguistTools Sql)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
find_package(WaylandProtocols REQUIRED)
find_package(TreelandProtocols REQUIRED)
find_package(PkgConfig REQUIRED)

add_subdirectory(frame)
1 change: 1 addition & 0 deletions frame/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -83,6 +83,7 @@ set_target_properties(dde-shell-frame PROPERTIES
qt_generate_wayland_protocol_client_sources(dde-shell-frame FILES
${CMAKE_CURRENT_SOURCE_DIR}/layershell/protocol/wlr-layer-shell-unstable-v1.xml
${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-dde-shell-v1.xml
)

set_target_properties(dde-shell-frame PROPERTIES
49 changes: 48 additions & 1 deletion frame/layershell/qwaylandlayershellsurface.cpp
Original file line number Diff line number Diff line change
@@ -9,11 +9,13 @@
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include <wayland-wlr-layer-shell-unstable-v1-client-protocol.h>

#include <QLoggingCategory>

Check warning on line 12 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

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

#include <QtWaylandClient/private/qwaylandinputdevice_p.h>

Check warning on line 14 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandinputdevice_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/private/qwaylandscreen_p.h>

Check warning on line 15 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandscreen_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/private/qwaylandsurface_p.h>

Check warning on line 16 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandsurface_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/private/qwaylandwindow_p.h>

Check warning on line 17 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandwindow_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <private/qwaylandnativeinterface_p.h>

Check warning on line 18 in frame/layershell/qwaylandlayershellsurface.cpp

GitHub Actions / cppcheck

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

Q_LOGGING_CATEGORY(layershellsurface, "dde.shell.layershell.surface")

@@ -45,7 +47,8 @@
}
}

init(shell->get_layer_surface(window->waylandSurface()->object(), output, m_dlayerShellWindow->layer(), m_dlayerShellWindow->scope()));
m_surface = window->waylandSurface()->object();
init(shell->get_layer_surface(m_surface, output, m_dlayerShellWindow->layer(), m_dlayerShellWindow->scope()));

set_layer(m_dlayerShellWindow->layer());
connect(m_dlayerShellWindow, &DLayerShellWindow::layerChanged, this, [this, window](){
@@ -80,6 +83,7 @@
if (m_requestSize.isValid()) {
set_size(m_requestSize.width(), m_requestSize.height());
}
m_ddeShellSurface.reset(TreeLandDDEShellManager::instance()->getDDEShellSurface(m_surface));
}

QWaylandLayerShellSurface::~QWaylandLayerShellSurface()
@@ -166,4 +170,47 @@
}
}

bool QWaylandLayerShellSurface::resize(QtWaylandClient::QWaylandInputDevice *inputDevice, Qt::Edges edges)
{
if (!m_ddeShellSurface) {
m_ddeShellSurface.reset(TreeLandDDEShellManager::instance()->getDDEShellSurface(m_surface));
}

if (TreeLandDDEShellManager::instance()->isActive() && m_ddeShellSurface) {
m_ddeShellSurface->resize(inputDevice->wl_seat(), inputDevice->serial(), 1);
return true;
}

return false;
}

TreeLandDDEShellManager::TreeLandDDEShellManager()
: QWaylandClientExtensionTemplate<TreeLandDDEShellManager>(treeland_dde_shell_manager_v1_interface.version)
{
}

TreeLandDDEShellManager *TreeLandDDEShellManager::instance()
{
static TreeLandDDEShellManager _instance;
return &_instance;
}

DDEShellSurface *TreeLandDDEShellManager::getDDEShellSurface(struct ::wl_surface *surface)
{
if (isActive())
return new DDEShellSurface(this->get_shell_surface(surface));
return nullptr;
}

DDEShellSurface::DDEShellSurface(struct ::treeland_dde_shell_surface_v1 *object)
: QWaylandClientExtensionTemplate<DDEShellSurface>(treeland_dde_shell_surface_v1_interface.version)
, treeland_dde_shell_surface_v1(object)
{
}

DDEShellSurface::~DDEShellSurface()
{
destroy();
}

DS_END_NAMESPACE
29 changes: 28 additions & 1 deletion frame/layershell/qwaylandlayershellsurface_p.h
Original file line number Diff line number Diff line change
@@ -8,11 +8,14 @@
#include "dlayershellwindow.h"

#include <private/qwaylandwindow_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>

Check warning on line 11 in frame/layershell/qwaylandlayershellsurface_p.h

GitHub Actions / cppcheck

Include file: <qwayland-wlr-layer-shell-unstable-v1.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>

Check warning on line 12 in frame/layershell/qwaylandlayershellsurface_p.h

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandshellsurface_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DS_BEGIN_NAMESPACE
#include "qwayland-treeland-dde-shell-v1.h"

Check warning on line 14 in frame/layershell/qwaylandlayershellsurface_p.h

GitHub Actions / cppcheck

Include file: "qwayland-treeland-dde-shell-v1.h" not found.
#include <QtWaylandClient/QWaylandClientExtension>

Check warning on line 15 in frame/layershell/qwaylandlayershellsurface_p.h

GitHub Actions / cppcheck

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

DS_BEGIN_NAMESPACE
class DDEShellSurface;
class QWaylandLayerShellSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1
{
Q_OBJECT
@@ -28,6 +31,7 @@
void applyConfigure() override;
void setWindowGeometry(const QRect &geometry) override;
void attachPopup(QWaylandShellSurface *popup) override;
bool resize(QtWaylandClient::QWaylandInputDevice *, Qt::Edges) override;

private:
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
@@ -37,10 +41,33 @@
bool anchorsSizeConflict() const;
void trySetAnchorsAndSize();

struct ::wl_surface *m_surface;
QScopedPointer<DDEShellSurface> m_ddeShellSurface;
DLayerShellWindow* m_dlayerShellWindow;
QSize m_pendingSize;
QSize m_requestSize;
bool m_configured = false;
};

class TreeLandDDEShellManager : public QWaylandClientExtensionTemplate<TreeLandDDEShellManager>, public QtWayland::treeland_dde_shell_manager_v1
{
Q_OBJECT

private:
explicit TreeLandDDEShellManager();

public:
static TreeLandDDEShellManager *instance();
DDEShellSurface *getDDEShellSurface(struct ::wl_surface *surface);
};

class DDEShellSurface : public QWaylandClientExtensionTemplate<DDEShellSurface>, public QtWayland::treeland_dde_shell_surface_v1
{
Q_OBJECT

public:
explicit DDEShellSurface(struct ::treeland_dde_shell_surface_v1 *object);
~DDEShellSurface() override;
};

DS_END_NAMESPACE
22 changes: 21 additions & 1 deletion panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ void DockPanel::setHideMode(const HideMode& mode)
Q_EMIT hideStateChanged(hideState());
}

Position DockPanel::position()
Position DockPanel::position() const
{
return SETTINGS->position();
}
@@ -330,6 +330,26 @@ void DockPanel::openDockSettings() const
.call();
}

void DockPanel::startSystemResize() const
{
Qt::Edge edge;
switch (position()) {
case Position::Top:
edge = Qt::BottomEdge;
break;
case Position::Bottom:
edge = Qt::TopEdge;
break;
case Position::Left:
edge = Qt::RightEdge;
break;
case Position::Right:
edge = Qt::LeftEdge;
break;
}
window()->startSystemResize(edge);
}

void DockPanel::launcherVisibleChanged(bool visible)
{
if (visible == m_launcherShown) return;
3 changes: 2 additions & 1 deletion panels/dock/dockpanel.h
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
HideMode hideMode();
void setHideMode(const HideMode& mode);

Position position();
Position position() const;
void setPosition(const Position& position);

ItemAlignment itemAlignment();
@@ -75,6 +75,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
bool debugMode() const;

Q_INVOKABLE void openDockSettings() const;
Q_INVOKABLE void startSystemResize() const;

bool showInPrimary() const;
void setShowInPrimary(bool newShowInPrimary);
79 changes: 12 additions & 67 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
@@ -24,24 +24,30 @@ Window {
(Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth)
// TODO
signal dockCenterPartPosChanged()
signal pressedAndDragging(bool isDragging)

property int dockCenterPartCount: dockCenterPartModel.count

property int dockSize: Applet.dockSize
property int dockItemMaxSize: dockSize
property int itemIconSizeBase: 0
property int itemSpacing: 0

property bool isDragging: false

property real dockItemIconSize: dockItemMaxSize * 9 / 14

// NOTE: -1 means not set its size, follow the platform size
width: Panel.position == Dock.Top || Panel.position == Dock.Bottom ? -1 : dockSize
height: Panel.position == Dock.Left || Panel.position == Dock.Right ? -1 : dockSize
color: "transparent"
flags: Qt.WindowDoesNotAcceptFocus
maximumHeight: useColumnLayout ? Screen.height : Dock.MAX_DOCK_SIZE
minimumHeight: useColumnLayout? Screen.height : Dock.MIN_DOCK_SIZE
maximumWidth: useColumnLayout ? Dock.MAX_DOCK_SIZE : Screen.width
minimumWidth: useColumnLayout ? Dock.MIN_DOCK_SIZE : Screen.width

Binding {
target: Applet
property: "dockSize"
value: useColumnLayout ? width : height
}

function blendColorAlpha(fallback) {
var appearance = DS.applet("org.deepin.ds.dde-appearance")
@@ -72,12 +78,6 @@ Window {
}
}

Binding on itemIconSizeBase {
when: !isDragging
value: dockItemMaxSize
restoreMode: Binding.RestoreNone
}

// only add blendColor effect when DWindow.enableBlurWindow is true,
// avoid to updating blur area frequently.--
D.StyledBehindWindowBlur {
@@ -360,10 +360,6 @@ Window {

MouseArea {
id: dragArea
property point oldMousePos: Qt.point(0, 0)
property int oldDockSize: 0
property list<int> recentDeltas: []
property int averageCount: 5
hoverEnabled: true
propagateComposedEvents: true

@@ -375,59 +371,9 @@ Window {
}

onPressed: function(mouse) {
dock.isDragging = true
oldMousePos = mapToGlobal(mouse.x, mouse.y)
oldDockSize = dockSize
recentDeltas = []
Panel.requestClosePopup()
DS.grabMouse(Panel.rootObject, true)
}

// this used for blocking MouseEvent sent to bottom MouseArea
onClicked: {}

onPositionChanged: function(mouse) {
if (!dock.isDragging) return
var newPos = mapToGlobal(mouse.x, mouse.y)
var xChange = newPos.x - oldMousePos.x
var yChange = newPos.y - oldMousePos.y

if (Panel.position === Dock.Bottom || Panel.position === Dock.Top) {
recentDeltas.push(yChange)
} else {
recentDeltas.push(xChange)
}

if (recentDeltas.length > averageCount) {
recentDeltas.shift()
}
// Taking the average makes the data smooth without jumps
var changeAverage = recentDeltas.reduce(function(acc, val) { return acc + val; }, 0) / recentDeltas.length;

var newDockSize = 0
if (Panel.position == Dock.Bottom) {
newDockSize = Math.min(Math.max(oldDockSize - changeAverage, Dock.MIN_DOCK_SIZE), Dock.MAX_DOCK_SIZE)
} else if (Panel.position == Dock.Top) {
newDockSize = Math.min(Math.max(oldDockSize + changeAverage, Dock.MIN_DOCK_SIZE), Dock.MAX_DOCK_SIZE)
} else if (Panel.position == Dock.Left) {
newDockSize = Math.min(Math.max(oldDockSize + changeAverage, Dock.MIN_DOCK_SIZE), Dock.MAX_DOCK_SIZE)
} else {
newDockSize = Math.min(Math.max(oldDockSize - changeAverage, Dock.MIN_DOCK_SIZE), Dock.MAX_DOCK_SIZE)
}

if (newDockSize !== dockSize) {
dockSize = newDockSize
}

pressedAndDragging(true)
}

onReleased: function(mouse) {
dock.isDragging = false
Applet.dockSize = dockSize
itemIconSizeBase = dockItemMaxSize
pressedAndDragging(false)
DS.grabMouse(Panel.rootObject, false)
Panel.startSystemResize()
return
}

function anchorToTop() {
@@ -556,7 +502,6 @@ Window {
return Panel.devicePixelRatio
})

dock.itemIconSizeBase = dock.dockItemMaxSize
dock.visible = Panel.hideState !== Dock.Hide
changeDragAreaAnchor()
}