mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 17:33:50 +03:00
add actions for LastActiveWindow
This commit is contained in:
parent
6898623bd6
commit
f3eacf169e
@ -101,10 +101,16 @@ public:
|
||||
virtual void setEdgeStateFor(QWindow *view, bool active) const = 0;
|
||||
|
||||
virtual void releaseMouseEventFor(WindowId wid) const = 0;
|
||||
|
||||
virtual void requestActivate(WindowId wid) const = 0;
|
||||
virtual void requestToggleMaximized(WindowId wid) const = 0;
|
||||
virtual void requestClose(WindowId wid) const = 0;
|
||||
virtual void requestMoveWindow(WindowId wid, QPoint from) const = 0;
|
||||
virtual void requestToggleKeepAbove(WindowId wid) const = 0;
|
||||
virtual void requestToggleMinimized(WindowId wid) const = 0;
|
||||
virtual void requestToggleMaximized(WindowId wid) const = 0;
|
||||
|
||||
virtual bool windowCanBeDragged(WindowId wid) const = 0;
|
||||
|
||||
virtual QIcon iconFor(WindowId wid) const = 0;
|
||||
virtual WindowId winIdFor(QString appId, QRect geometry) const = 0;
|
||||
virtual AppData appDataFor(WindowId wid) const = 0;
|
||||
|
@ -252,9 +252,16 @@ void LastActiveWindow::setInformation(const WindowInfoWrap &info)
|
||||
}
|
||||
|
||||
//! FUNCTIONALITY
|
||||
void LastActiveWindow::requestToggleMaximize()
|
||||
|
||||
|
||||
void LastActiveWindow::requestActivate()
|
||||
{
|
||||
m_wm->requestToggleMaximized(m_winId);
|
||||
m_wm->requestActivate(m_winId);
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestClose()
|
||||
{
|
||||
m_wm->requestClose(m_winId);
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestMove(int localX, int localY)
|
||||
@ -272,6 +279,21 @@ void LastActiveWindow::requestMove(int localX, int localY)
|
||||
emit draggingStarted();
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestToggleKeepAbove()
|
||||
{
|
||||
m_wm->requestToggleKeepAbove(m_winId);
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestToggleMinimized()
|
||||
{
|
||||
m_wm->requestToggleMinimized(m_winId);
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestToggleMaximized()
|
||||
{
|
||||
m_wm->requestToggleMaximized(m_winId);
|
||||
}
|
||||
|
||||
bool LastActiveWindow::canBeDragged()
|
||||
{
|
||||
return m_wm->windowCanBeDragged(m_winId);
|
||||
|
@ -84,8 +84,13 @@ public:
|
||||
void setInformation(const WindowInfoWrap &info);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void requestToggleMaximize();
|
||||
Q_INVOKABLE void requestActivate();
|
||||
Q_INVOKABLE void requestClose();
|
||||
Q_INVOKABLE void requestMove(int localX, int localY);
|
||||
Q_INVOKABLE void requestToggleKeepAbove();
|
||||
Q_INVOKABLE void requestToggleMinimized();
|
||||
Q_INVOKABLE void requestToggleMaximized();
|
||||
|
||||
Q_INVOKABLE bool canBeDragged();
|
||||
|
||||
signals:
|
||||
|
@ -458,6 +458,16 @@ void WaylandInterface::requestActivate(WindowId wid) const
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandInterface::requestClose(WindowId wid) const
|
||||
{
|
||||
auto w = windowFor(wid);
|
||||
|
||||
if (w) {
|
||||
w->requestClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WaylandInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
{
|
||||
if (windowCanBeDragged(wid)) {
|
||||
@ -469,15 +479,43 @@ void WaylandInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandInterface::requestToggleMaximized(WindowId wid) const
|
||||
void WaylandInterface::requestToggleKeepAbove(WindowId wid) const
|
||||
{
|
||||
auto w = windowFor(wid);
|
||||
|
||||
if (w) {
|
||||
w->requestToggleKeepAbove();
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandInterface::requestToggleMinimized(WindowId wid) const
|
||||
{
|
||||
auto w = windowFor(wid);
|
||||
|
||||
if (w && isValidWindow(w)) {
|
||||
w->requestToggleMaximized();
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
if (!m_currentDesktop.isEmpty()) {
|
||||
w->requestEnterVirtualDesktop(m_currentDesktop);
|
||||
}
|
||||
#endif
|
||||
w->requestToggleMinimized();
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandInterface::requestToggleMaximized(WindowId wid) const
|
||||
{
|
||||
auto w = windowFor(wid);
|
||||
|
||||
if (w && isValidWindow(w)) {
|
||||
#if KF5_VERSION_MINOR >= 52
|
||||
if (!m_currentDesktop.isEmpty()) {
|
||||
w->requestEnterVirtualDesktop(m_currentDesktop);
|
||||
}
|
||||
#endif
|
||||
w->requestToggleMaximized();
|
||||
}
|
||||
}
|
||||
|
||||
bool WaylandInterface::isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const
|
||||
{
|
||||
if (!w || (w->appId() != QLatin1String("org.kde.plasmashell"))) {
|
||||
|
@ -79,10 +79,16 @@ public:
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
|
||||
void requestActivate(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
void requestClose(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
void requestToggleKeepAbove(WindowId wid) const override;
|
||||
void requestToggleMinimized(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
|
||||
bool windowCanBeDragged(WindowId wid) const;
|
||||
|
||||
QIcon iconFor(WindowId wid) const;
|
||||
WindowId winIdFor(QString appId, QRect geometry) const override;
|
||||
AppData appDataFor(WindowId wid) const override;
|
||||
|
@ -416,6 +416,18 @@ WindowId XWindowInterface::winIdFor(QString appId, QRect geometry) const
|
||||
return activeWindow();
|
||||
}
|
||||
|
||||
void XWindowInterface::requestClose(WindowId wid) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
|
||||
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NETRootInfo ri(QX11Info::connection(), NET::CloseWindow);
|
||||
ri.closeWindowRequest(wInfo.wid().toUInt());
|
||||
}
|
||||
|
||||
void XWindowInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
@ -442,11 +454,53 @@ void XWindowInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
ri.moveResizeRequest(wInfo.wid().toUInt(), validX, validY, NET::Move);
|
||||
}
|
||||
|
||||
void XWindowInterface::requestToggleKeepAbove(WindowId wid) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
|
||||
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NETWinInfo ni(QX11Info::connection(), wid.toUInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2());
|
||||
|
||||
if (wInfo.isKeepAbove()) {
|
||||
ni.setState(NET::States(), NET::StaysOnTop);
|
||||
} else {
|
||||
ni.setState(NET::StaysOnTop, NET::StaysOnTop);
|
||||
}
|
||||
}
|
||||
|
||||
void XWindowInterface::requestToggleMinimized(WindowId wid) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
|
||||
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wInfo.isMinimized()) {
|
||||
bool onCurrent = isOnCurrentDesktop(wid);
|
||||
|
||||
KWindowSystem::unminimizeWindow(wid.toUInt());
|
||||
|
||||
if (onCurrent) {
|
||||
KWindowSystem::forceActiveWindow(wid.toUInt());
|
||||
}
|
||||
} else {
|
||||
KWindowSystem::minimizeWindow(wid.toUInt());
|
||||
}
|
||||
}
|
||||
|
||||
void XWindowInterface::requestToggleMaximized(WindowId wid) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
bool restore = wInfo.isMaxHoriz() && wInfo.isMaxVert();
|
||||
|
||||
if (wInfo.isMinimized()) {
|
||||
KWindowSystem::unminimizeWindow(wid.toUInt());
|
||||
}
|
||||
|
||||
NETWinInfo ni(QX11Info::connection(), wid.toInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2());
|
||||
|
||||
if (restore) {
|
||||
|
@ -63,10 +63,16 @@ public:
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
|
||||
void requestActivate(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
void requestClose(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
void requestToggleKeepAbove(WindowId wid) const override;
|
||||
void requestToggleMinimized(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
|
||||
bool windowCanBeDragged(WindowId wid) const override;
|
||||
|
||||
QIcon iconFor(WindowId wid) const override;
|
||||
WindowId winIdFor(QString appId, QRect geometry) const override;
|
||||
AppData appDataFor(WindowId wid) const override;
|
||||
|
@ -105,8 +105,7 @@ Loader {
|
||||
|
||||
dragWindowTimer.stop();
|
||||
restoreGrabberTimer.stop();
|
||||
latteView.windowsTracker.lastActiveWindow.requestToggleMaximize();
|
||||
//tasksModel.requestToggleMaximized(tasksModel.activeTask);
|
||||
latteView.windowsTracker.lastActiveWindow.requestToggleMaximized();
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
|
Loading…
Reference in New Issue
Block a user