mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
enable requestMove through the visibilitymanager
This commit is contained in:
parent
578623836b
commit
e63a43afe5
@ -34,6 +34,7 @@
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
#include <QPoint>
|
||||
#include <QPointer>
|
||||
#include <QScreen>
|
||||
|
||||
@ -82,6 +83,9 @@ public:
|
||||
virtual void enableBlurBehind(QWindow &view) const = 0;
|
||||
virtual void setEdgeStateFor(QWindow *view, bool active) const = 0;
|
||||
|
||||
virtual void requestMoveActiveWindow(QPoint from) const = 0;
|
||||
virtual bool activeWindowCanBeDragged() const = 0;
|
||||
|
||||
void addDock(WindowId wid);
|
||||
void removeDock(WindowId wid);
|
||||
|
||||
|
@ -1040,6 +1040,19 @@ void VisibilityManagerPrivate::deleteEdgeGhostWindow()
|
||||
emit q->supportsKWinEdgesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
//! Window Functions
|
||||
void VisibilityManagerPrivate::requestMoveActiveWindow(int localX, int localY)
|
||||
{
|
||||
QPoint globalPoint{dockView->x() + localX, dockView->y() + localY};
|
||||
wm->requestMoveActiveWindow(globalPoint);
|
||||
}
|
||||
|
||||
bool VisibilityManagerPrivate::activeWindowCanBeDragged()
|
||||
{
|
||||
return wm->activeWindowCanBeDragged();
|
||||
}
|
||||
|
||||
//! END: VisibilityManagerPrivate implementation
|
||||
|
||||
|
||||
@ -1187,5 +1200,17 @@ bool VisibilityManager::supportsKWinEdges() const
|
||||
return (d->edgeGhostWindow != nullptr);
|
||||
}
|
||||
|
||||
//! END: VisibilityManager implementation
|
||||
//! Window Functions
|
||||
void VisibilityManager::requestMoveActiveWindow(int localX, int localY)
|
||||
{
|
||||
d->requestMoveActiveWindow(localX, localY);
|
||||
}
|
||||
|
||||
bool VisibilityManager::activeWindowCanBeDragged()
|
||||
{
|
||||
return d->activeWindowCanBeDragged();
|
||||
}
|
||||
|
||||
//! END: VisibilityManager implementation
|
||||
|
||||
}
|
||||
|
@ -104,6 +104,10 @@ public:
|
||||
|
||||
bool supportsKWinEdges() const;
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void requestMoveActiveWindow(int localX, int localY);
|
||||
Q_INVOKABLE bool activeWindowCanBeDragged();
|
||||
|
||||
signals:
|
||||
void mustBeShown(QPrivateSignal);
|
||||
void mustBeHide(QPrivateSignal);
|
||||
|
@ -82,6 +82,9 @@ public:
|
||||
|
||||
void updateStrutsBasedOnLayoutsAndActivities();
|
||||
|
||||
void requestMoveActiveWindow(int localX, int localY);
|
||||
bool activeWindowCanBeDragged();
|
||||
|
||||
void saveConfig();
|
||||
void restoreConfig();
|
||||
|
||||
|
@ -285,6 +285,8 @@ WindowInfoWrap WaylandInterface::requestInfoActive() const
|
||||
|
||||
winfoWrap.setIsKeepAbove(w->isKeepAbove());
|
||||
|
||||
winfoWrap.setHasSkipTaskbar(w->skipTaskbar());
|
||||
|
||||
return winfoWrap;
|
||||
}
|
||||
|
||||
@ -346,6 +348,16 @@ WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
|
||||
return winfoWrap;
|
||||
}
|
||||
|
||||
bool WaylandInterface::activeWindowCanBeDragged() const
|
||||
{
|
||||
WindowInfoWrap activeInfo = requestInfoActive();
|
||||
return (activeInfo.isValid() && !activeInfo.isPlasmaDesktop() && !activeInfo.hasSkipTaskbar());
|
||||
}
|
||||
|
||||
void WaylandInterface::requestMoveActiveWindow(QPoint from) const
|
||||
{
|
||||
//to be supported
|
||||
}
|
||||
|
||||
inline bool WaylandInterface::isValidWindow(const KWayland::Client::PlasmaWindow *w) const
|
||||
{
|
||||
|
@ -75,6 +75,9 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void requestMoveActiveWindow(QPoint from) const override;
|
||||
bool activeWindowCanBeDragged() const;
|
||||
|
||||
void setEdgeStateFor(QWindow *view, bool active) const override;
|
||||
|
||||
void initWindowManagement(KWayland::Client::PlasmaWindowManagement *windowManagement);
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
, m_isFullscreen(false)
|
||||
, m_isShaded(false)
|
||||
, m_isPlasmaDesktop(false)
|
||||
, m_isKeepAbove(false) {
|
||||
, m_isKeepAbove(false)
|
||||
, m_hasSkipTaskbar(false) {
|
||||
}
|
||||
|
||||
WindowInfoWrap(const WindowInfoWrap &o) noexcept
|
||||
@ -56,7 +57,8 @@ public:
|
||||
, m_isFullscreen(o.m_isFullscreen)
|
||||
, m_isShaded(o.m_isShaded)
|
||||
, m_isPlasmaDesktop(o.m_isPlasmaDesktop)
|
||||
, m_isKeepAbove(o.m_isKeepAbove) {
|
||||
, m_isKeepAbove(o.m_isKeepAbove)
|
||||
, m_hasSkipTaskbar(o.m_hasSkipTaskbar) {
|
||||
}
|
||||
|
||||
WindowInfoWrap(WindowInfoWrap &&o) noexcept
|
||||
@ -70,7 +72,8 @@ public:
|
||||
, m_isFullscreen(o.m_isFullscreen)
|
||||
, m_isShaded(o.m_isShaded)
|
||||
, m_isPlasmaDesktop(o.m_isPlasmaDesktop)
|
||||
, m_isKeepAbove(o.m_isKeepAbove) {
|
||||
, m_isKeepAbove(o.m_isKeepAbove)
|
||||
, m_hasSkipTaskbar(o.m_hasSkipTaskbar) {
|
||||
}
|
||||
|
||||
inline WindowInfoWrap &operator=(WindowInfoWrap &&rhs) noexcept;
|
||||
@ -108,6 +111,9 @@ public:
|
||||
inline bool isKeepAbove() const noexcept;
|
||||
inline void setIsKeepAbove(bool isKeepAbove) noexcept;
|
||||
|
||||
inline bool hasSkipTaskbar() const noexcept;
|
||||
inline void setHasSkipTaskbar(bool skipTaskbar) noexcept;
|
||||
|
||||
inline QRect geometry() const noexcept;
|
||||
inline void setGeometry(const QRect &geometry) noexcept;
|
||||
|
||||
@ -127,6 +133,7 @@ private:
|
||||
bool m_isShaded : 1;
|
||||
bool m_isPlasmaDesktop : 1;
|
||||
bool m_isKeepAbove: 1;
|
||||
bool m_hasSkipTaskbar: 1;
|
||||
};
|
||||
|
||||
// BEGIN: definitions
|
||||
@ -143,6 +150,7 @@ inline WindowInfoWrap &WindowInfoWrap::operator=(WindowInfoWrap &&rhs) noexcept
|
||||
m_isShaded = rhs.m_isShaded;
|
||||
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
|
||||
m_isKeepAbove = rhs.m_isKeepAbove;
|
||||
m_hasSkipTaskbar = rhs.m_hasSkipTaskbar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -159,6 +167,7 @@ inline WindowInfoWrap &WindowInfoWrap::operator=(const WindowInfoWrap &rhs) noex
|
||||
m_isShaded = rhs.m_isShaded;
|
||||
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
|
||||
m_isKeepAbove = rhs.m_isKeepAbove;
|
||||
m_hasSkipTaskbar = rhs.m_hasSkipTaskbar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -272,6 +281,16 @@ inline void WindowInfoWrap::setIsKeepAbove(bool isKeepAbove) noexcept
|
||||
m_isKeepAbove = isKeepAbove;
|
||||
}
|
||||
|
||||
inline bool WindowInfoWrap::hasSkipTaskbar() const noexcept
|
||||
{
|
||||
return m_hasSkipTaskbar;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setHasSkipTaskbar(bool skipTaskbar) noexcept
|
||||
{
|
||||
m_hasSkipTaskbar = skipTaskbar;
|
||||
}
|
||||
|
||||
inline QRect WindowInfoWrap::geometry() const noexcept
|
||||
{
|
||||
return m_geometry;
|
||||
|
@ -311,15 +311,49 @@ WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const
|
||||
winfoWrap.setIsShaded(winfo.hasState(NET::Shaded));
|
||||
winfoWrap.setGeometry(winfo.frameGeometry());
|
||||
winfoWrap.setIsKeepAbove(winfo.hasState(NET::KeepAbove));
|
||||
winfoWrap.setHasSkipTaskbar(winfo.hasState(NET::SkipTaskbar));
|
||||
} else if (m_desktopId == wid) {
|
||||
winfoWrap.setIsValid(true);
|
||||
winfoWrap.setIsPlasmaDesktop(true);
|
||||
winfoWrap.setWid(wid);
|
||||
winfoWrap.setHasSkipTaskbar(true);
|
||||
}
|
||||
|
||||
return winfoWrap;
|
||||
}
|
||||
|
||||
bool XWindowInterface::activeWindowCanBeDragged() const
|
||||
{
|
||||
WindowInfoWrap activeInfo = requestInfoActive();
|
||||
return (activeInfo.isValid() && !activeInfo.isPlasmaDesktop() && !activeInfo.hasSkipTaskbar());
|
||||
}
|
||||
|
||||
void XWindowInterface::requestMoveActiveWindow(QPoint from) const
|
||||
{
|
||||
WindowInfoWrap activeInfo = requestInfoActive();
|
||||
|
||||
if (!activeInfo.isValid() || activeInfo.isPlasmaDesktop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int borderX{activeInfo.geometry().width() > 120 ? 60 : 10};
|
||||
int borderY{10};
|
||||
|
||||
//! find min/max values for x,y based on active window geometry
|
||||
int minX = activeInfo.geometry().x() + borderX;
|
||||
int maxX = activeInfo.geometry().x() + activeInfo.geometry().width() - borderX;
|
||||
int minY = activeInfo.geometry().y() + borderY;
|
||||
int maxY = activeInfo.geometry().y() + activeInfo.geometry().height() - borderY;
|
||||
|
||||
//! set the point from which this window will be moved,
|
||||
//! make sure that it is in window boundaries
|
||||
int validX = qBound(minX, from.x(), maxX);
|
||||
int validY = qBound(minY, from.y(), maxY);
|
||||
|
||||
NETRootInfo ri(QX11Info::connection(), NET::WMMoveResize);
|
||||
ri.moveResizeRequest(activeInfo.wid().toUInt(), validX, validY, NET::Move);
|
||||
}
|
||||
|
||||
|
||||
bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
{
|
||||
|
@ -58,6 +58,9 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void requestMoveActiveWindow(QPoint from) const override;
|
||||
bool activeWindowCanBeDragged() const override;
|
||||
|
||||
void setEdgeStateFor(QWindow *view, bool active) const override;
|
||||
|
||||
private:
|
||||
|
@ -1641,8 +1641,10 @@ DragDrop.DropArea {
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
if (dock.visibility.activeWindowCanBeDragged()) {
|
||||
drawWindowTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
onDoubleClicked: {
|
||||
drawWindowTimer.stop();
|
||||
@ -1654,9 +1656,9 @@ DragDrop.DropArea {
|
||||
id: drawWindowTimer
|
||||
interval: 350
|
||||
onTriggered: {
|
||||
if (rootMouseArea.pressed) {
|
||||
if (rootMouseArea.pressed && dock.visibility.activeWindowCanBeDragged()) {
|
||||
dock.disableGrabItemBehavior();
|
||||
tasksModel.requestMove(tasksModel.activeTask);
|
||||
dock.visibility.requestMoveActiveWindow(rootMouseArea.mouseX, rootMouseArea.mouseY);
|
||||
restoreGrabberTimer.start();
|
||||
}
|
||||
}
|
||||
@ -1671,14 +1673,29 @@ DragDrop.DropArea {
|
||||
}
|
||||
}
|
||||
|
||||
////////// Dragging windows etc....
|
||||
TaskManager.TasksModel {
|
||||
id: tasksModel
|
||||
sortMode: TaskManager.TasksModel.SortVirtualDesktop
|
||||
groupMode: TaskManager.TasksModel.GroupDisabled
|
||||
|
||||
virtualDesktop: virtualDesktopInfo.currentDesktop
|
||||
activity: activityInfo.currentActivity
|
||||
screenGeometry: plasmoid.screenGeometry
|
||||
filterByScreen: plasmoid.configuration.showForCurrentScreenOnly
|
||||
|
||||
filterByVirtualDesktop: true
|
||||
filterByScreen: true
|
||||
filterByActivity: true
|
||||
}
|
||||
TaskManager.VirtualDesktopInfo {
|
||||
id: virtualDesktopInfo
|
||||
}
|
||||
|
||||
TaskManager.ActivityInfo {
|
||||
id: activityInfo
|
||||
}
|
||||
|
||||
////////// Dragging windows etc....
|
||||
|
||||
Loader{
|
||||
active: root.debugModeWindow
|
||||
|
Loading…
Reference in New Issue
Block a user