1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-10 21:18:19 +03:00

drop TaskManager for drag/double click panel

--use the visibilitymanager in order to drag
and maximize/restore an active window. Update
also the wayland functions for these features.
This commit is contained in:
Michail Vourlakos 2018-10-28 21:10:08 +02:00
parent 5d6b9eb2ba
commit 24806d8909
9 changed files with 122 additions and 74 deletions

View File

@ -83,8 +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;
virtual void requestToggleMaximized(WindowId wid) const = 0;
virtual void requestMoveWindow(WindowId wid, QPoint from) const = 0;
virtual bool windowCanBeDragged(WindowId wid) const = 0;
void addDock(WindowId wid);
void removeDock(WindowId wid);

View File

@ -1042,15 +1042,37 @@ void VisibilityManagerPrivate::deleteEdgeGhostWindow()
}
//! Window Functions
void VisibilityManagerPrivate::requestToggleMaximizeForActiveWindow()
{
WindowInfoWrap actInfo = wm->requestInfoActive();
//active window can be toggled only when it is in the same screen
if (actInfo.isValid() && !actInfo.geometry().isNull() && dockView->screenGeometry().contains(actInfo.geometry().center())) {
wm->requestToggleMaximized(actInfo.wid());
}
}
void VisibilityManagerPrivate::requestMoveActiveWindow(int localX, int localY)
{
QPoint globalPoint{dockView->x() + localX, dockView->y() + localY};
wm->requestMoveActiveWindow(globalPoint);
WindowInfoWrap actInfo = wm->requestInfoActive();
//active window can be dragged only when it is in the same screen
if (actInfo.isValid() && !actInfo.geometry().isNull() && dockView->screenGeometry().contains(actInfo.geometry().center())) {
QPoint globalPoint{dockView->x() + localX, dockView->y() + localY};
wm->requestMoveWindow(actInfo.wid(), globalPoint);
}
}
bool VisibilityManagerPrivate::activeWindowCanBeDragged()
{
return wm->activeWindowCanBeDragged();
WindowInfoWrap actInfo = wm->requestInfoActive();
//active window can be dragged only when it is in the same screen
if (actInfo.isValid() && !actInfo.geometry().isNull() && dockView->screenGeometry().contains(actInfo.geometry().center())) {
return wm->windowCanBeDragged(actInfo.wid());
}
return false;
}
//! END: VisibilityManagerPrivate implementation
@ -1201,6 +1223,11 @@ bool VisibilityManager::supportsKWinEdges() const
}
//! Window Functions
void VisibilityManager::requestToggleMaximizeForActiveWindow()
{
d->requestToggleMaximizeForActiveWindow();
}
void VisibilityManager::requestMoveActiveWindow(int localX, int localY)
{
d->requestMoveActiveWindow(localX, localY);

View File

@ -105,6 +105,7 @@ public:
bool supportsKWinEdges() const;
public slots:
Q_INVOKABLE void requestToggleMaximizeForActiveWindow();
Q_INVOKABLE void requestMoveActiveWindow(int localX, int localY);
Q_INVOKABLE bool activeWindowCanBeDragged();

View File

@ -82,6 +82,7 @@ public:
void updateStrutsBasedOnLayoutsAndActivities();
void requestToggleMaximizeForActiveWindow();
void requestMoveActiveWindow(int localX, int localY);
bool activeWindowCanBeDragged();

View File

@ -318,45 +318,71 @@ bool WaylandInterface::isOnCurrentActivity(WindowId wid) const
WindowInfoWrap WaylandInterface::requestInfo(WindowId wid) const
{
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
return w->isValid() && w->internalId() == wid;
});
if (it == m_windowManagement->windows().constEnd())
return {};
WindowInfoWrap winfoWrap;
auto w = *it;
auto w = windowFor(wid);
if (isValidWindow(w)) {
winfoWrap.setIsValid(true);
winfoWrap.setWid(wid);
winfoWrap.setIsActive(w->isActive());
winfoWrap.setIsMinimized(w->isMinimized());
winfoWrap.setIsMaxVert(w->isMaximized());
winfoWrap.setIsMaxHoriz(w->isMaximized());
winfoWrap.setIsFullscreen(w->isFullscreen());
winfoWrap.setIsShaded(w->isShaded());
winfoWrap.setGeometry(w->geometry());
} else if (w->appId() == QLatin1String("org.kde.plasmashell")) {
winfoWrap.setIsValid(true);
winfoWrap.setIsPlasmaDesktop(true);
winfoWrap.setWid(wid);
if (w) {
if (isValidWindow(w)) {
winfoWrap.setIsValid(true);
winfoWrap.setWid(wid);
winfoWrap.setIsActive(w->isActive());
winfoWrap.setIsMinimized(w->isMinimized());
winfoWrap.setIsMaxVert(w->isMaximized());
winfoWrap.setIsMaxHoriz(w->isMaximized());
winfoWrap.setIsFullscreen(w->isFullscreen());
winfoWrap.setIsShaded(w->isShaded());
winfoWrap.setGeometry(w->geometry());
winfoWrap.setHasSkipTaskbar(w->skipTaskbar());
} else if (w->appId() == QLatin1String("org.kde.plasmashell")) {
winfoWrap.setIsValid(true);
winfoWrap.setIsPlasmaDesktop(true);
winfoWrap.setWid(wid);
}
} else {
return {};
}
return winfoWrap;
}
bool WaylandInterface::activeWindowCanBeDragged() const
KWayland::Client::PlasmaWindow *WaylandInterface::windowFor(WindowId wid) const
{
WindowInfoWrap activeInfo = requestInfoActive();
return (activeInfo.isValid() && !activeInfo.isPlasmaDesktop() && !activeInfo.hasSkipTaskbar());
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
return w->isValid() && w->internalId() == wid;
});
if (it == m_windowManagement->windows().constEnd()) {
return nullptr;
}
return *it;
}
void WaylandInterface::requestMoveActiveWindow(QPoint from) const
bool WaylandInterface::windowCanBeDragged(WindowId wid) const
{
//to be supported
WindowInfoWrap winfo = requestInfo(wid);
return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.hasSkipTaskbar());
}
void WaylandInterface::requestMoveWindow(WindowId wid, QPoint from) const
{
if (windowCanBeDragged(wid)) {
auto w = windowFor(wid);
if (w && isValidWindow(w)) {
w->requestMove();
}
}
}
void WaylandInterface::requestToggleMaximized(WindowId wid) const
{
auto w = windowFor(wid);
if (w && isValidWindow(w)) {
w->requestToggleMaximized();
}
}
inline bool WaylandInterface::isValidWindow(const KWayland::Client::PlasmaWindow *w) const

View File

@ -75,8 +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 requestToggleMaximized(WindowId wid) const override;
void requestMoveWindow(WindowId wid, QPoint from) const override;
bool windowCanBeDragged(WindowId wid) const;
void setEdgeStateFor(QWindow *view, bool active) const override;
@ -86,6 +87,7 @@ private:
void init();
inline bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const;
void windowCreatedProxy(KWayland::Client::PlasmaWindow *w);
KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const;
KWayland::Client::PlasmaShell *waylandDockCoronaInterface() const;
QSignalMapper *mapper{nullptr};

View File

@ -322,28 +322,28 @@ WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const
return winfoWrap;
}
bool XWindowInterface::activeWindowCanBeDragged() const
bool XWindowInterface::windowCanBeDragged(WindowId wid) const
{
WindowInfoWrap activeInfo = requestInfoActive();
return (activeInfo.isValid() && !activeInfo.isPlasmaDesktop() && !activeInfo.hasSkipTaskbar());
WindowInfoWrap winfo = requestInfo(wid);
return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.hasSkipTaskbar());
}
void XWindowInterface::requestMoveActiveWindow(QPoint from) const
void XWindowInterface::requestMoveWindow(WindowId wid, QPoint from) const
{
WindowInfoWrap activeInfo = requestInfoActive();
WindowInfoWrap wInfo = requestInfo(wid);
if (!activeInfo.isValid() || activeInfo.isPlasmaDesktop()) {
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
return;
}
int borderX{activeInfo.geometry().width() > 120 ? 60 : 10};
int borderX{wInfo.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;
int minX = wInfo.geometry().x() + borderX;
int maxX = wInfo.geometry().x() + wInfo.geometry().width() - borderX;
int minY = wInfo.geometry().y() + borderY;
int maxY = wInfo.geometry().y() + wInfo.geometry().height() - borderY;
//! set the point from which this window will be moved,
//! make sure that it is in window boundaries
@ -351,9 +351,22 @@ void XWindowInterface::requestMoveActiveWindow(QPoint from) const
int validY = qBound(minY, from.y(), maxY);
NETRootInfo ri(QX11Info::connection(), NET::WMMoveResize);
ri.moveResizeRequest(activeInfo.wid().toUInt(), validX, validY, NET::Move);
ri.moveResizeRequest(wInfo.wid().toUInt(), validX, validY, NET::Move);
}
void XWindowInterface::requestToggleMaximized(WindowId wid) const
{
WindowInfoWrap wInfo = requestInfo(wid);
bool restore = wInfo.isMaxHoriz() && wInfo.isMaxVert();
NETWinInfo ni(QX11Info::connection(), wid.toInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2());
if (restore) {
ni.setState(NET::States(), NET::Max);
} else {
ni.setState(NET::Max, NET::Max);
}
}
bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
{

View File

@ -58,8 +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 requestToggleMaximized(WindowId wid) const override;
void requestMoveWindow(WindowId wid, QPoint from) const override;
bool windowCanBeDragged(WindowId wid) const override;
void setEdgeStateFor(QWindow *view, bool active) const override;

View File

@ -22,8 +22,6 @@ import QtQuick 2.7
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.taskmanager 0.1 as TaskManager
MouseArea{
id: mainArea
@ -71,7 +69,8 @@ MouseArea{
onDoubleClicked: {
drawWindowTimer.stop();
restoreGrabberTimer.stop();
tasksModel.requestToggleMaximized(tasksModel.activeTask);
dock.visibility.requestToggleMaximizeForActiveWindow();
//tasksModel.requestToggleMaximized(tasksModel.activeTask);
}
function activateDragging(){
@ -99,27 +98,4 @@ MouseArea{
mainArea.lastPressY = -1;
}
}
////////// Dragging windows etc....
TaskManager.TasksModel {
id: tasksModel
sortMode: TaskManager.TasksModel.SortVirtualDesktop
groupMode: TaskManager.TasksModel.GroupDisabled
virtualDesktop: virtualDesktopInfo.currentDesktop
activity: activityInfo.currentActivity
screenGeometry: plasmoid.screenGeometry
filterByVirtualDesktop: true
filterByScreen: true
filterByActivity: true
}
TaskManager.VirtualDesktopInfo {
id: virtualDesktopInfo
}
TaskManager.ActivityInfo {
id: activityInfo
}
////////// Dragging windows etc....
}