diff --git a/app/view/windowstracker.cpp b/app/view/windowstracker.cpp index 26e988c6..3f8dff1c 100644 --- a/app/view/windowstracker.cpp +++ b/app/view/windowstracker.cpp @@ -1,169 +1,174 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "windowstracker.h" // local #include "positioner.h" #include "view.h" #include "../lattecorona.h" #include "../layouts/manager.h" #include "../wm/schemecolors.h" #include "../wm/tracker/lastactivewindow.h" #include "../wm/tracker/trackerwindows.h" #include "../../liblatte2/types.h" namespace Latte { namespace ViewPart { WindowsTracker::WindowsTracker(Latte::View *parent) : QObject(parent), m_latteView(parent) { qDebug() << "WindowsTracker creating..."; m_corona = qobject_cast(m_latteView->corona()); m_wm = m_corona->wm(); init(); m_wm->windowsTracker()->addView(m_latteView); connect(lastActiveWindow(), &WindowSystem::Tracker::LastActiveWindow::draggingStarted, this, &WindowsTracker::activeWindowDraggingStarted); emit lastActiveWindowChanged(); } WindowsTracker::~WindowsTracker() { qDebug() << "WindowsTracker removing..."; m_wm->windowsTracker()->removeView(m_latteView); } void WindowsTracker::init() { connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::enabledChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit enabledChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowMaximizedChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowTouchingChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowTouchingChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowActiveChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowActiveChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowMaximizedChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowMaximizedChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowTouchingChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit existsWindowTouchingChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowSchemeChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit activeWindowSchemeChanged(); } }); connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::touchingWindowSchemeChanged, this, [&](const Latte::View *view) { if (m_latteView == view) { emit touchingWindowSchemeChanged(); } }); } bool WindowsTracker::activeWindowMaximized() const { return m_wm->windowsTracker()->activeWindowMaximized(m_latteView); } bool WindowsTracker::activeWindowTouching() const { return m_wm->windowsTracker()->activeWindowTouching(m_latteView); } bool WindowsTracker::existsWindowActive() const { return m_wm->windowsTracker()->existsWindowActive(m_latteView); } bool WindowsTracker::existsWindowMaximized() const { return m_wm->windowsTracker()->existsWindowMaximized(m_latteView); } bool WindowsTracker::existsWindowTouching() const { return m_wm->windowsTracker()->existsWindowTouching(m_latteView); } WindowSystem::SchemeColors *WindowsTracker::activeWindowScheme() const { return m_wm->windowsTracker()->activeWindowScheme(m_latteView); } WindowSystem::SchemeColors *WindowsTracker::touchingWindowScheme() const { return m_wm->windowsTracker()->touchingWindowScheme(m_latteView); } bool WindowsTracker::enabled() const { return m_wm->windowsTracker()->enabled(m_latteView); } void WindowsTracker::setEnabled(bool active) { m_wm->windowsTracker()->setEnabled(m_latteView, active); } WindowSystem::Tracker::LastActiveWindow *WindowsTracker::lastActiveWindow() { return m_wm->windowsTracker()->lastActiveWindow(m_latteView); } //! Window Functions void WindowsTracker::setWindowOnActivities(QWindow &window, const QStringList &activities) { m_wm->setWindowOnActivities(window, activities); } +void WindowsTracker::requestMoveLastWindowFromCurrentScreen(int localX, int localY) +{ + m_wm->windowsTracker()->lastActiveWindow(m_latteView)->requestMove(m_latteView, localX, localY); +} + } } diff --git a/app/view/windowstracker.h b/app/view/windowstracker.h index d313285a..9926c898 100644 --- a/app/view/windowstracker.h +++ b/app/view/windowstracker.h @@ -1,104 +1,107 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WINDOWSTRACKER_H #define WINDOWSTRACKER_H // local #include "../wm/abstractwindowinterface.h" // Qt #include namespace Latte{ class Corona; class View; namespace WindowSystem { class AbstractWindowInterface; class SchemeColors; namespace Tracker { class LastActiveWindow; } } } namespace Latte { namespace ViewPart { class WindowsTracker : public QObject { Q_OBJECT Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool activeWindowMaximized READ activeWindowMaximized NOTIFY activeWindowMaximizedChanged) Q_PROPERTY(bool activeWindowTouching READ activeWindowTouching NOTIFY activeWindowTouchingChanged) Q_PROPERTY(bool existsWindowActive READ existsWindowActive NOTIFY existsWindowActiveChanged) Q_PROPERTY(bool existsWindowMaximized READ existsWindowMaximized NOTIFY existsWindowMaximizedChanged) Q_PROPERTY(bool existsWindowTouching READ existsWindowTouching NOTIFY existsWindowTouchingChanged) Q_PROPERTY(Latte::WindowSystem::SchemeColors *activeWindowScheme READ activeWindowScheme NOTIFY activeWindowSchemeChanged) Q_PROPERTY(Latte::WindowSystem::SchemeColors *touchingWindowScheme READ touchingWindowScheme NOTIFY touchingWindowSchemeChanged) Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *lastActiveWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) public: explicit WindowsTracker(Latte::View *parent); virtual ~WindowsTracker(); bool enabled() const; void setEnabled(bool active); bool activeWindowMaximized() const; bool activeWindowTouching() const; bool existsWindowActive() const; bool existsWindowMaximized() const; bool existsWindowTouching() const; WindowSystem::SchemeColors *activeWindowScheme() const; WindowSystem::SchemeColors *touchingWindowScheme() const; WindowSystem::Tracker::LastActiveWindow *lastActiveWindow(); void setWindowOnActivities(QWindow &window, const QStringList &activities); +public slots: + Q_INVOKABLE void requestMoveLastWindowFromCurrentScreen(int localX, int localY); + signals: void enabledChanged(); void activeWindowDraggingStarted(); void activeWindowMaximizedChanged(); void activeWindowTouchingChanged(); void existsWindowActiveChanged(); void existsWindowMaximizedChanged(); void existsWindowTouchingChanged(); void activeWindowSchemeChanged(); void touchingWindowSchemeChanged(); void lastActiveWindowChanged(); private: void init(); private: Latte::Corona *m_corona{nullptr}; Latte::View *m_latteView{nullptr}; WindowSystem::AbstractWindowInterface *m_wm; }; } } #endif diff --git a/app/wm/tracker/lastactivewindow.cpp b/app/wm/tracker/lastactivewindow.cpp index 0f70a716..5113d018 100644 --- a/app/wm/tracker/lastactivewindow.cpp +++ b/app/wm/tracker/lastactivewindow.cpp @@ -1,367 +1,368 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "lastactivewindow.h" // local #include "trackedgeneralinfo.h" #include "trackerwindows.h" #include "../abstractwindowinterface.h" #include "../tasktools.h" #include "../../view/view.h" -#include "../../view/visibilitymanager.h" // Qt #include #include #include namespace Latte { namespace WindowSystem { namespace Tracker { LastActiveWindow::LastActiveWindow(TrackedGeneralInfo *trackedInfo) : QObject(trackedInfo), m_trackedInfo(trackedInfo), m_windowsTracker(trackedInfo->wm()->windowsTracker()), m_wm(trackedInfo->wm()) { connect(m_windowsTracker, &Windows::activeWindowChanged, this, &LastActiveWindow::windowChanged); connect(m_windowsTracker, &Windows::windowChanged, this, &LastActiveWindow::windowChanged); connect(m_windowsTracker, &Windows::windowRemoved, this, &LastActiveWindow::windowRemoved); } LastActiveWindow::~LastActiveWindow() { } bool LastActiveWindow::isActive() const { return m_isActive; } void LastActiveWindow::setActive(bool active) { if (m_isActive == active) { return; } m_isActive = active; emit isActiveChanged(); } bool LastActiveWindow::isMinimized() const { return m_isMinimized; } void LastActiveWindow::setIsMinimized(bool minimized) { if (m_isMinimized == minimized) { return; } m_isMinimized = minimized; emit isMinimizedChanged(); } bool LastActiveWindow::isMaximized() const { return m_isMaximized; } void LastActiveWindow::setIsMaximized(bool maximized) { if (m_isMaximized == maximized) { return; } m_isMaximized = maximized; emit isMaximizedChanged(); } bool LastActiveWindow::isFullScreen() const { return m_isFullScreen; } void LastActiveWindow::setIsFullScreen(bool fullscreen) { if (m_isFullScreen == fullscreen) { return; } m_isFullScreen = fullscreen; emit isFullScreenChanged(); } bool LastActiveWindow::isKeepAbove() const { return m_isKeepAbove; } void LastActiveWindow::setIsKeepAbove(bool above) { if (m_isKeepAbove == above) { return; } m_isKeepAbove = above; emit isKeepAboveChanged(); } bool LastActiveWindow::isOnAllDesktops() const { return m_isOnAllDesktops; } void LastActiveWindow::setIsOnAllDesktops(bool all) { if (m_isOnAllDesktops == all) { return; } m_isOnAllDesktops = all; emit isOnAllDesktopsChanged(); } bool LastActiveWindow::isShaded() const { return m_isShaded; } void LastActiveWindow::setIsShaded(bool shaded) { if (m_isShaded == shaded) { return; } m_isShaded = shaded; emit isShadedChanged(); } bool LastActiveWindow::hasSkipTaskbar() const { return m_hasSkipTaskbar; } void LastActiveWindow::setHasSkipTaskbar(bool skip) { if (m_hasSkipTaskbar == skip) { return; } m_hasSkipTaskbar = skip; emit hasSkipTaskbarChanged(); } QRect LastActiveWindow::geometry() const { return m_geometry; } void LastActiveWindow::setGeometry(QRect geometry) { if (m_geometry == geometry) { return; } m_geometry = geometry; emit geometryChanged(); } QString LastActiveWindow::appName() const { return m_appName; } void LastActiveWindow::setAppName(QString appName) { if (m_appName == appName) { return; } m_appName = appName; emit appNameChanged(); } QString LastActiveWindow::display() const { return m_display; } void LastActiveWindow::setDisplay(QString display) { if (m_display == display) { return; } m_display = display; emit displayChanged(); } QIcon LastActiveWindow::icon() const { return m_icon; } void LastActiveWindow::setIcon(QIcon icon) { m_icon = icon; emit iconChanged(); } QVariant LastActiveWindow::winId() const { return m_winId; } void LastActiveWindow::setWinId(QVariant winId) { if (m_winId == winId) { return; } if (!m_history.contains(winId)) { m_history.prepend(winId); } else { int p = m_history.indexOf(winId); //! move to start m_history.move(p, 0); } m_winId = winId; emit winIdChanged(); } void LastActiveWindow::setInformation(const WindowInfoWrap &info) { setWinId(info.wid()); setActive(info.isActive()); setIsMinimized(info.isMinimized()); setIsMaximized(info.isMaxVert() || info.isMaxHoriz()); setIsOnAllDesktops(info.isOnAllDesktops()); setAppName(info.appName()); setDisplay(info.display()); setGeometry(info.geometry()); setIsKeepAbove(info.isKeepAbove()); if (info.appName().isEmpty()) { setAppName(m_windowsTracker->appNameFor(info.wid())); } else { setAppName(info.appName()); } if (info.icon().isNull()) { setIcon(m_windowsTracker->iconFor(info.wid())); } else { setIcon(info.icon()); } } //! PRIVATE SLOTS void LastActiveWindow::windowChanged(const WindowId &wid) { if (m_winId == wid && !wid.isNull()) { setInformation(m_windowsTracker->infoFor(wid)); } else if (m_history.contains(wid)) { //! remove from history minimized windows or windows that changed screen //! and update information accordingly with the first window found from //! history after the removal WindowInfoWrap winfo = m_windowsTracker->infoFor(wid); if (winfo.isMinimized() || !m_trackedInfo->isTracking(winfo)) { m_history.removeAll(wid); if (m_history.count() > 0) { setInformation(m_windowsTracker->infoFor(m_history[0])); } } } } void LastActiveWindow::windowRemoved(const WindowId &wid) { if (m_history.contains(wid)) { m_history.removeAll(wid); if (m_history.count() > 0) { setInformation(m_windowsTracker->infoFor(m_history[0])); } } } //! FUNCTIONALITY void LastActiveWindow::requestActivate() { m_wm->requestActivate(m_winId); } void LastActiveWindow::requestClose() { m_wm->requestClose(m_winId); } -void LastActiveWindow::requestMove(int localX, int localY) +void LastActiveWindow::requestMove(Latte::View *fromView, int localX, int localY) { - QPoint globalPoint{m_trackedInfo->view()->x() + localX, m_trackedInfo->view()->y() + localY}; + QPoint globalPoint{fromView->x() + localX, fromView->y() + localY}; m_wm->requestMoveWindow(m_winId, globalPoint); + auto viewId = m_winId; + //! This timer is needed because otherwise the mouse position //! in the dragged window changes to TopLeft corner - QTimer::singleShot(250, this, [&]() { - m_wm->releaseMouseEventFor(m_trackedInfo->view()->winId()); + QTimer::singleShot(250, this, [&, viewId]() { + m_wm->releaseMouseEventFor(viewId); }); emit draggingStarted(); } void LastActiveWindow::requestToggleIsOnAllDesktops() { m_wm->requestToggleIsOnAllDesktops(m_winId); } 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); } } } } diff --git a/app/wm/tracker/lastactivewindow.h b/app/wm/tracker/lastactivewindow.h index b105f439..871c831f 100644 --- a/app/wm/tracker/lastactivewindow.h +++ b/app/wm/tracker/lastactivewindow.h @@ -1,171 +1,171 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WINDOWSYSTEMLASTACTIVEWINDOW_H #define WINDOWSYSTEMLASTACTIVEWINDOW_H // local #include "../windowinfowrap.h" #include "../abstractwindowinterface.h" // Qt #include #include namespace Latte { class View; namespace WindowSystem { class AbstractWindowInterface; namespace Tracker { class TrackedGeneralInfo; class Windows; } } } namespace Latte { namespace WindowSystem { namespace Tracker { class LastActiveWindow : public QObject { Q_OBJECT Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged) Q_PROPERTY(bool isMinimized READ isMinimized NOTIFY isMinimizedChanged) Q_PROPERTY(bool isMaximized READ isMaximized NOTIFY isMaximizedChanged) Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged) Q_PROPERTY(bool isKeepAbove READ isKeepAbove NOTIFY isKeepAboveChanged) Q_PROPERTY(bool isOnAllDesktops READ isOnAllDesktops NOTIFY isOnAllDesktopsChanged) Q_PROPERTY(bool isShaded READ isShaded NOTIFY isShadedChanged) Q_PROPERTY(bool hasSkipTaskbar READ hasSkipTaskbar NOTIFY hasSkipTaskbarChanged) Q_PROPERTY(QString appName READ appName NOTIFY appNameChanged) Q_PROPERTY(QString display READ display NOTIFY displayChanged) Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) Q_PROPERTY(QVariant winId READ winId NOTIFY winIdChanged) public: LastActiveWindow(TrackedGeneralInfo *trackedInfo); ~LastActiveWindow() override; bool isActive() const; bool isMinimized() const; bool isMaximized() const; bool isFullScreen() const; bool isKeepAbove() const; bool isOnAllDesktops() const; bool isShaded() const; bool hasSkipTaskbar() const; QString appName() const; QString display() const; QRect geometry() const; QIcon icon() const; QVariant winId() const; void setInformation(const WindowInfoWrap &info); public slots: Q_INVOKABLE void requestActivate(); Q_INVOKABLE void requestClose(); - Q_INVOKABLE void requestMove(int localX, int localY); Q_INVOKABLE void requestToggleIsOnAllDesktops(); Q_INVOKABLE void requestToggleKeepAbove(); Q_INVOKABLE void requestToggleMinimized(); Q_INVOKABLE void requestToggleMaximized(); Q_INVOKABLE bool canBeDragged(); + void requestMove(Latte::View *fromView, int localX, int localY); private slots: void windowChanged(const WindowId &wid); void windowRemoved(const WindowId &wid); signals: void draggingStarted(); void iconChanged(); void isActiveChanged(); void isMinimizedChanged(); void isMaximizedChanged(); void isFullScreenChanged(); void isKeepAboveChanged(); void isOnAllDesktopsChanged(); void isShadedChanged(); void hasSkipTaskbarChanged(); void appNameChanged(); void displayChanged(); void geometryChanged(); void winIdChanged(); private: void setActive(bool active); void setIsMinimized(bool minimized); void setIsMaximized(bool maximized); void setIsFullScreen(bool fullscreen); void setIsKeepAbove(bool above); void setIsOnAllDesktops(bool all); void setIsShaded(bool shaded); void setHasSkipTaskbar(bool skip); void setAppName(QString appName); void setDisplay(QString display); void setGeometry(QRect geometry); void setIcon(QIcon icon); void setWinId(QVariant winId); private: bool m_isActive{false}; bool m_isMinimized{false}; bool m_isMaximized{false}; bool m_isFullScreen{false}; bool m_isKeepAbove{false}; bool m_isOnAllDesktops{false}; bool m_isShaded{false}; bool m_hasSkipTaskbar{false}; QString m_appName; QString m_display; QRect m_geometry; QIcon m_icon; QVariant m_winId; QList m_history; TrackedGeneralInfo *m_trackedInfo{nullptr}; AbstractWindowInterface *m_wm{nullptr}; Tracker::Windows *m_windowsTracker{nullptr}; }; } } } #endif diff --git a/app/wm/tracker/trackedgeneralinfo.cpp b/app/wm/tracker/trackedgeneralinfo.cpp index 90554a94..0b121fff 100644 --- a/app/wm/tracker/trackedgeneralinfo.cpp +++ b/app/wm/tracker/trackedgeneralinfo.cpp @@ -1,157 +1,149 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "trackedgeneralinfo.h" //local #include "trackerwindows.h" #include "../schemecolors.h" -#include "../../view/view.h" namespace Latte { namespace WindowSystem { namespace Tracker { -TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *view) +TrackedGeneralInfo::TrackedGeneralInfo(Tracker::Windows *tracker) : QObject(tracker) , m_wm(tracker->wm()), - m_view(view), m_tracker(tracker) { m_lastActiveWindow = new LastActiveWindow(this); emit lastActiveWindowChanged(); } TrackedGeneralInfo::~TrackedGeneralInfo() { if (m_lastActiveWindow) { auto law = m_lastActiveWindow; m_lastActiveWindow = nullptr; emit lastActiveWindowChanged(); law->deleteLater(); } } bool TrackedGeneralInfo::enabled() const { return m_enabled; } void TrackedGeneralInfo::setEnabled(bool enabled) { if (m_enabled == enabled) { return; } m_enabled = enabled; } bool TrackedGeneralInfo::activeWindowMaximized() const { return m_activeWindowMaximized; } void TrackedGeneralInfo::setActiveWindowMaximized(bool activeMaximized) { if (m_activeWindowMaximized == activeMaximized) { return; } m_activeWindowMaximized = activeMaximized; } bool TrackedGeneralInfo::existsWindowActive() const { return m_existsWindowActive; } void TrackedGeneralInfo::setExistsWindowActive(bool exists) { if (m_existsWindowActive == exists) { return; } m_existsWindowActive = exists; } bool TrackedGeneralInfo::existsWindowMaximized() const { return m_existsWindowMaximized; } void TrackedGeneralInfo::setExistsWindowMaximized(bool maximized) { if (m_existsWindowMaximized == maximized) { return; } m_existsWindowMaximized = maximized; } LastActiveWindow *TrackedGeneralInfo::lastActiveWindow() const { return m_lastActiveWindow; } SchemeColors *TrackedGeneralInfo::activeWindowScheme() const { return m_activeWindowScheme; } void TrackedGeneralInfo::setActiveWindowScheme(SchemeColors *scheme) { if (m_activeWindowScheme == scheme) { return; } m_activeWindowScheme = scheme; } -Latte::View *TrackedGeneralInfo::view() -{ - return m_view; -} - AbstractWindowInterface *TrackedGeneralInfo::wm() { return m_wm; } - void TrackedGeneralInfo::setActiveWindow(const WindowId &wid) { m_lastActiveWindow->setInformation(m_tracker->infoFor(wid)); } bool TrackedGeneralInfo::isTracking(const WindowInfoWrap &winfo) const { return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.isMinimized() && winfo.isOnDesktop(m_wm->currentDesktop()) - && winfo.isOnActivity(m_wm->currentActivity()) - && m_view->isOnActivity(m_wm->currentActivity())); + && winfo.isOnActivity(m_wm->currentActivity())); + /*&& m_view->isOnActivity(m_wm->currentActivity()));*/ } } } } diff --git a/app/wm/tracker/trackedgeneralinfo.h b/app/wm/tracker/trackedgeneralinfo.h index d3c3929d..0e5ba19f 100644 --- a/app/wm/tracker/trackedgeneralinfo.h +++ b/app/wm/tracker/trackedgeneralinfo.h @@ -1,100 +1,97 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WINDOWSYSTEMTRACKEDGENERALINFO_H #define WINDOWSYSTEMTRACKEDGENERALINFO_H // local #include "lastactivewindow.h" #include "../windowinfowrap.h" // Qt #include namespace Latte { -class View; namespace WindowSystem { class SchemeColors; namespace Tracker { class Windows; } } } namespace Latte { namespace WindowSystem { namespace Tracker { class TrackedGeneralInfo : public QObject { Q_OBJECT Q_PROPERTY(Latte::WindowSystem::Tracker::LastActiveWindow *activeWindow READ lastActiveWindow NOTIFY lastActiveWindowChanged) public: - TrackedGeneralInfo(Tracker::Windows *tracker, Latte::View *view); + TrackedGeneralInfo(Tracker::Windows *tracker); ~TrackedGeneralInfo() override; bool enabled() const; void setEnabled(bool enabled); bool activeWindowMaximized() const; void setActiveWindowMaximized(bool activeMaximized); bool existsWindowActive() const; void setExistsWindowActive(bool exists); bool existsWindowMaximized() const; void setExistsWindowMaximized(bool maximized); LastActiveWindow *lastActiveWindow() const; SchemeColors *activeWindowScheme() const; void setActiveWindowScheme(SchemeColors *scheme); - Latte::View *view(); AbstractWindowInterface *wm(); void setActiveWindow(const WindowId &wid); virtual bool isTracking(const WindowInfoWrap &winfo) const; signals: void lastActiveWindowChanged(); private: bool m_enabled; bool m_activeWindowMaximized; bool m_existsWindowActive; bool m_existsWindowMaximized; - Latte::View *m_view{nullptr}; LastActiveWindow *m_lastActiveWindow{nullptr}; SchemeColors *m_activeWindowScheme{nullptr}; AbstractWindowInterface *m_wm{nullptr}; Tracker::Windows *m_tracker{nullptr}; }; } } } #endif diff --git a/app/wm/tracker/trackedviewinfo.cpp b/app/wm/tracker/trackedviewinfo.cpp index c7183dce..1a0d81b8 100644 --- a/app/wm/tracker/trackedviewinfo.cpp +++ b/app/wm/tracker/trackedviewinfo.cpp @@ -1,106 +1,112 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "trackedviewinfo.h" //local #include "trackerwindows.h" #include "../schemecolors.h" #include "../../view/view.h" namespace Latte { namespace WindowSystem { namespace Tracker { TrackedViewInfo::TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view) - : TrackedGeneralInfo(tracker, view) + : TrackedGeneralInfo(tracker) , + m_view(view) { } TrackedViewInfo::~TrackedViewInfo() { } bool TrackedViewInfo::activeWindowTouching() const { return m_activeWindowTouching; } void TrackedViewInfo::setActiveWindowTouching(bool touching) { if (m_activeWindowTouching == touching) { return; } m_activeWindowTouching = touching; } bool TrackedViewInfo::existsWindowTouching() const { return m_existsWindowTouching; } void TrackedViewInfo::setExistsWindowTouching(bool touching) { if (m_existsWindowTouching == touching) { return; } m_existsWindowTouching = touching; } QRect TrackedViewInfo::availableScreenGeometry() const { return m_availableScreenGeometry; } void TrackedViewInfo::setAvailableScreenGeometry(QRect geometry) { if (m_availableScreenGeometry == geometry) { return; } m_availableScreenGeometry = geometry; } SchemeColors *TrackedViewInfo::touchingWindowScheme() const { return m_touchingWindowScheme; } void TrackedViewInfo::setTouchingWindowScheme(SchemeColors *scheme) { if (m_touchingWindowScheme == scheme) { return; } m_touchingWindowScheme = scheme; } +Latte::View *TrackedViewInfo::view() const +{ + return m_view; +} + bool TrackedViewInfo::isTracking(const WindowInfoWrap &winfo) const { return TrackedGeneralInfo::isTracking(winfo) && m_availableScreenGeometry.contains(winfo.geometry().center()); } } } } diff --git a/app/wm/tracker/trackedviewinfo.h b/app/wm/tracker/trackedviewinfo.h index ce2ec461..ddaf3102 100644 --- a/app/wm/tracker/trackedviewinfo.h +++ b/app/wm/tracker/trackedviewinfo.h @@ -1,80 +1,84 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WINDOWSYSTEMTRACKEDVIEWINFO_H #define WINDOWSYSTEMTRACKEDVIEWINFO_H // local #include "trackedgeneralinfo.h" #include "../windowinfowrap.h" // Qt #include #include namespace Latte { class View; namespace WindowSystem { class SchemeColors; namespace Tracker { class Windows; } } } namespace Latte { namespace WindowSystem { namespace Tracker { class TrackedViewInfo : public TrackedGeneralInfo { Q_OBJECT public: TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view); ~TrackedViewInfo() override; bool activeWindowTouching() const; void setActiveWindowTouching(bool touching); bool existsWindowTouching() const; void setExistsWindowTouching(bool touching); QRect availableScreenGeometry() const; void setAvailableScreenGeometry(QRect geometry); SchemeColors *touchingWindowScheme() const; void setTouchingWindowScheme(SchemeColors *scheme); + Latte::View *view() const; + bool isTracking(const WindowInfoWrap &winfo) const override; private: bool m_activeWindowTouching; bool m_existsWindowTouching; QRect m_availableScreenGeometry; SchemeColors *m_touchingWindowScheme{nullptr}; + + Latte::View *m_view{nullptr}; }; } } } #endif diff --git a/containment/package/contents/ui/layouts/EnvironmentActions.qml b/containment/package/contents/ui/layouts/EnvironmentActions.qml index ce6f282b..fdc2ba3c 100644 --- a/containment/package/contents/ui/layouts/EnvironmentActions.qml +++ b/containment/package/contents/ui/layouts/EnvironmentActions.qml @@ -1,283 +1,283 @@ /* * Copyright 2019 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.7 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.latte 0.2 as Latte import "loaders" as Loaders Loader { id: environmentLoader sourceComponent: MouseArea{ id: mainArea width: { if (root.isHorizontal) { return useAllLayouts ? root.maxLength : root.realPanelLength; } else { return root.isHovered ? (root.iconSize + root.thickMargins)*root.zoomFactor : (root.iconSize + root.thickMargins) } } height: { if (root.isVertical) { return useAllLayouts ? root.maxLength : root.realPanelLength; } else { return root.isHovered ? (root.iconSize + root.thickMargins)*root.zoomFactor : (root.iconSize + root.thickMargins) } } hoverEnabled: true readonly property bool useAllLayouts: panelUserSetAlignment === Latte.Types.Justify && !root.inConfigureAppletsMode property int lastPressX: -1 property int lastPressY: -1 onContainsMouseChanged: { if (root.mouseInHoverableArea()) { root.stopCheckRestoreZoomTimer(); } else { root.initializeHoveredIndexes(); root.startCheckRestoreZoomTimer() } } onPressed: { if (!root.dragActiveWindowEnabled) { return; } if (latteView.windowsTracker.lastActiveWindow.canBeDragged()) { lastPressX = mouse.x; lastPressY = mouse.y; dragWindowTimer.start(); } } onReleased: { lastPressX = -1; lastPressY = -1; } onPositionChanged: { if (!root.dragActiveWindowEnabled) { return; } var stepX = Math.abs(lastPressX-mouse.x); var stepY = Math.abs(lastPressY-mouse.y); var threshold = 5; var tryDrag = mainArea.pressed && (stepX>threshold || stepY>threshold); if ( tryDrag && latteView.windowsTracker.lastActiveWindow.canBeDragged()) { dragWindowTimer.stop(); activateDragging(); } } onDoubleClicked: { if (!root.dragActiveWindowEnabled) { return; } dragWindowTimer.stop(); restoreGrabberTimer.stop(); latteView.windowsTracker.lastActiveWindow.requestToggleMaximized(); } onWheel: { if (root.scrollAction === Latte.Types.ScrollNone) { root.emptyAreasWheel(wheel); return; } var delta = 0; if (wheel.angleDelta.y>=0 && wheel.angleDelta.x>=0) { delta = Math.max(wheel.angleDelta.y, wheel.angleDelta.x); } else { delta = Math.min(wheel.angleDelta.y, wheel.angleDelta.x); } var angle = delta / 8; if (angle>10) { if (pagerLoader.active) { var next; if (pagerLoader.item.model.currentPage === pagerLoader.item.count - 1){ next = 0; } else { next = Math.min(pagerLoader.item.model.currentPage + 1, pagerLoader.item.count - 1); } if (pagerLoader.item.count > 1){ //console.log("+++ changing from: " + pagerLoader.item.model.currentPage + " to ::: " + next); pagerLoader.item.model.changePage(next); } } else if (tasksLoader.active) { tasksLoader.item.activateNextPrevTask(true); } } else if (angle<-10) { if (pagerLoader.active) { var prev; if (pagerLoader.item.model.currentPage === 0){ prev = pagerLoader.item.count - 1; } else { prev = Math.max(pagerLoader.item.model.currentPage - 1, 0); } if (pagerLoader.item.count > 1){ //console.log("--- changing from: " + pagerLoader.item.model.currentPage + " to ::: " + prev); pagerLoader.item.model.changePage(prev); } } else if (tasksLoader.active) { tasksLoader.item.activateNextPrevTask(false); } } } Loaders.Pager{ id: pagerLoader } Loaders.Tasks{ id: tasksLoader } function activateDragging(){ latteView.disableGrabItemBehavior(); - latteView.windowsTracker.lastActiveWindow.requestMove(mainArea.mouseX, mainArea.mouseY); + latteView.windowsTracker.requestMoveLastWindowFromCurrentScreen(mainArea.mouseX, mainArea.mouseY); restoreGrabberTimer.start(); } //! Timers Timer { id: dragWindowTimer interval: 500 onTriggered: { if (mainArea.pressed && latteView.windowsTracker.lastActiveWindow.canBeDragged()) { mainArea.activateDragging(); } } } Timer { id: restoreGrabberTimer interval: 50 onTriggered: { latteView.restoreGrabItemBehavior(); mainArea.lastPressX = -1; mainArea.lastPressY = -1; } } states:[ State { name: "bottom" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) AnchorChanges { target: mainArea anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } }, State { name: "top" when: (plasmoid.location === PlasmaCore.Types.TopEdge) AnchorChanges { target: mainArea anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } }, State { name: "left" when: (plasmoid.location === PlasmaCore.Types.LeftEdge) AnchorChanges { target: mainArea anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } }, State { name: "right" when: (plasmoid.location === PlasmaCore.Types.RightEdge) AnchorChanges { target: mainArea anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } } ] } states:[ State { name: "bottom" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) AnchorChanges { target: environmentLoader anchors{ top:undefined; bottom: _mainLayout.bottom; left:undefined; right:undefined; horizontalCenter: _mainLayout.horizontalCenter; verticalCenter:undefined} } }, State { name: "top" when: (plasmoid.location === PlasmaCore.Types.TopEdge) AnchorChanges { target: environmentLoader anchors{ top: _mainLayout.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter: _mainLayout.horizontalCenter; verticalCenter:undefined} } }, State { name: "left" when: (plasmoid.location === PlasmaCore.Types.LeftEdge) AnchorChanges { target: environmentLoader anchors{ top:undefined; bottom:undefined; left: _mainLayout.left; right:undefined; horizontalCenter:undefined; verticalCenter: _mainLayout.verticalCenter} } }, State { name: "right" when: (plasmoid.location === PlasmaCore.Types.RightEdge) AnchorChanges { target: environmentLoader anchors{ top:undefined; bottom:undefined; left:undefined; right: _mainLayout.right; horizontalCenter:undefined; verticalCenter: _mainLayout.verticalCenter} } } ] }