2017-01-02 17:05:30 -05:00
/*
* Copyright 2016 Smith AR < audoban @ openmailbox . org >
* Michail Vourlakos < mvourlakos @ gmail . com >
*
* 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 < http : //www.gnu.org/licenses/>.
*/
2016-12-25 09:25:27 +02:00
# ifndef VISIBILITYMANAGER_H
# define VISIBILITYMANAGER_H
2018-12-02 02:05:52 +02:00
// local
2018-12-13 19:51:22 +02:00
# include "../plasma/quick/containmentview.h"
2018-10-14 13:54:09 +03:00
# include "../schemecolors.h"
2018-12-20 18:59:38 +02:00
# include "../wm/abstractwindowinterface.h"
2018-12-02 01:29:18 +02:00
# include "../wm/windowinfowrap.h"
2018-12-07 18:55:35 +02:00
# include "../../liblatte2/types.h"
2016-12-25 09:25:27 +02:00
2018-12-02 02:05:52 +02:00
// Qt
2016-12-25 18:12:31 -05:00
# include <QObject>
2016-12-25 09:25:27 +02:00
# include <QTimer>
2018-12-02 02:05:52 +02:00
// Plasma
2016-12-25 09:25:27 +02:00
# include <Plasma/Containment>
2016-12-29 00:42:55 -05:00
namespace Latte {
2018-12-20 18:59:38 +02:00
class Corona ;
class View ;
2018-12-09 00:29:35 +02:00
namespace ViewPart {
2018-12-20 18:59:38 +02:00
class ScreenEdgeGhostWindow ;
}
}
2016-12-29 00:42:55 -05:00
2018-12-20 18:59:38 +02:00
namespace Latte {
namespace ViewPart {
2016-12-29 00:42:55 -05:00
2018-07-03 22:15:45 +03:00
class VisibilityManager : public QObject
{
2016-12-25 09:25:27 +02:00
Q_OBJECT
2017-01-16 14:07:49 -05:00
2018-12-07 18:55:35 +02:00
Q_PROPERTY ( Latte : : Types : : Visibility mode READ mode WRITE setMode NOTIFY modeChanged )
2017-03-12 04:01:27 -05:00
Q_PROPERTY ( bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged )
Q_PROPERTY ( bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged )
2016-12-30 02:18:08 -05:00
Q_PROPERTY ( bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged )
2017-01-02 03:06:47 -05:00
Q_PROPERTY ( bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged )
2016-12-28 02:54:26 -05:00
Q_PROPERTY ( bool containsMouse READ containsMouse NOTIFY containsMouseChanged )
2017-12-24 20:54:45 +02:00
//! Dynamic Background Feature (needed options)
Q_PROPERTY ( bool enabledDynamicBackground READ enabledDynamicBackground WRITE setEnabledDynamicBackground NOTIFY enabledDynamicBackgroundChanged )
Q_PROPERTY ( bool existsWindowMaximized READ existsWindowMaximized NOTIFY existsWindowMaximizedChanged )
Q_PROPERTY ( bool existsWindowSnapped READ existsWindowSnapped NOTIFY existsWindowSnappedChanged )
2018-10-14 13:54:09 +03:00
Q_PROPERTY ( SchemeColors * touchingWindowScheme READ touchingWindowScheme NOTIFY touchingWindowSchemeChanged )
2017-12-24 20:54:45 +02:00
2018-03-28 20:39:52 +03:00
//! KWin Edges Support Options
Q_PROPERTY ( bool enableKWinEdges READ enableKWinEdges WRITE setEnableKWinEdges NOTIFY enableKWinEdgesChanged )
Q_PROPERTY ( bool supportsKWinEdges READ supportsKWinEdges NOTIFY supportsKWinEdgesChanged )
2016-12-25 18:12:31 -05:00
Q_PROPERTY ( int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged )
Q_PROPERTY ( int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged )
2017-01-16 14:07:49 -05:00
2016-12-25 09:25:27 +02:00
public :
explicit VisibilityManager ( PlasmaQuick : : ContainmentView * view ) ;
2016-12-25 18:12:31 -05:00
virtual ~ VisibilityManager ( ) ;
2017-01-16 14:07:49 -05:00
2018-12-07 18:55:35 +02:00
Latte : : Types : : Visibility mode ( ) const ;
void setMode ( Latte : : Types : : Visibility mode ) ;
2017-01-16 14:07:49 -05:00
2018-01-21 11:53:15 +02:00
void setWindowOnActivities ( QWindow & window , const QStringList & activities ) ;
2018-03-28 20:39:52 +03:00
void applyActivitiesToHiddenWindows ( const QStringList & activities ) ;
2018-01-13 12:55:13 +02:00
2017-03-12 04:01:27 -05:00
bool raiseOnDesktop ( ) const ;
void setRaiseOnDesktop ( bool enable ) ;
bool raiseOnActivity ( ) const ;
void setRaiseOnActivity ( bool enable ) ;
2016-12-28 03:00:01 -05:00
bool isHidden ( ) const ;
2016-12-30 02:18:08 -05:00
void setIsHidden ( bool isHidden ) ;
2017-01-16 14:07:49 -05:00
2017-01-02 03:06:47 -05:00
bool blockHiding ( ) const ;
void setBlockHiding ( bool blockHiding ) ;
2017-01-16 14:07:49 -05:00
2016-12-28 03:00:01 -05:00
bool containsMouse ( ) const ;
2017-01-16 14:07:49 -05:00
2016-12-25 18:12:31 -05:00
int timerShow ( ) const ;
void setTimerShow ( int msec ) ;
2017-01-16 14:07:49 -05:00
2016-12-25 18:12:31 -05:00
int timerHide ( ) const ;
void setTimerHide ( int msec ) ;
2017-01-16 14:07:49 -05:00
2017-12-24 20:54:45 +02:00
//! Dynamic Background functions
bool enabledDynamicBackground ( ) const ;
void setEnabledDynamicBackground ( bool active ) ;
bool existsWindowMaximized ( ) const ;
bool existsWindowSnapped ( ) const ;
2018-10-14 13:54:09 +03:00
SchemeColors * touchingWindowScheme ( ) const ;
2018-03-28 20:39:52 +03:00
//! KWin Edges Support functions
bool enableKWinEdges ( ) const ;
void setEnableKWinEdges ( bool enable ) ;
bool supportsKWinEdges ( ) const ;
2018-10-28 10:03:22 +02:00
public slots :
2018-10-28 21:10:08 +02:00
Q_INVOKABLE void requestToggleMaximizeForActiveWindow ( ) ;
2018-10-28 10:03:22 +02:00
Q_INVOKABLE void requestMoveActiveWindow ( int localX , int localY ) ;
Q_INVOKABLE bool activeWindowCanBeDragged ( ) ;
2016-12-25 18:12:31 -05:00
signals :
2018-12-20 18:59:38 +02:00
void mustBeShown ( ) ;
void mustBeHide ( ) ;
2017-01-16 14:07:49 -05:00
2016-12-25 18:12:31 -05:00
void modeChanged ( ) ;
2017-03-12 04:01:27 -05:00
void raiseOnDesktopChanged ( ) ;
void raiseOnActivityChanged ( ) ;
2016-12-28 02:54:26 -05:00
void isHiddenChanged ( ) ;
2017-01-02 03:06:47 -05:00
void blockHidingChanged ( ) ;
2016-12-28 02:54:26 -05:00
void containsMouseChanged ( ) ;
2016-12-25 18:12:31 -05:00
void timerShowChanged ( ) ;
void timerHideChanged ( ) ;
2018-10-14 13:54:09 +03:00
void touchingWindowSchemeChanged ( ) ;
2017-01-16 14:07:49 -05:00
2017-12-24 20:54:45 +02:00
//! Dynamic Background signals (from options)
void enabledDynamicBackgroundChanged ( ) ;
void existsWindowMaximizedChanged ( ) ;
void existsWindowSnappedChanged ( ) ;
2018-03-28 20:39:52 +03:00
//! KWin Edges Support signals
void enableKWinEdgesChanged ( ) ;
void supportsKWinEdgesChanged ( ) ;
2018-12-20 18:59:38 +02:00
private slots :
void saveConfig ( ) ;
void restoreConfig ( ) ;
private :
void setContainsMouse ( bool contains ) ;
void raiseView ( bool raise ) ;
void raiseViewTemporarily ( ) ;
void updateHiddenState ( ) ;
//! the notification window is not sending a remove signal and creates windows of geometry (0x0 0,0),
//! this is a garbage collector to collect such windows in order to not break the windows array validity.
void cleanupFaultyWindows ( ) ;
//! Dynamic Background Feature
void setExistsWindowMaximized ( bool windowMaximized ) ;
void setExistsWindowSnapped ( bool windowSnapped ) ;
void setTouchingWindowScheme ( SchemeColors * scheme ) ;
void updateAvailableScreenGeometry ( ) ;
void updateDynamicBackgroundWindowFlags ( ) ;
//! KWin Edges Support functions
void createEdgeGhostWindow ( ) ;
void deleteEdgeGhostWindow ( ) ;
void updateKWinEdgesSupport ( ) ;
void setViewGeometry ( const QRect & rect ) ;
void windowAdded ( WindowId id ) ;
void dodgeActive ( WindowId id ) ;
void dodgeMaximized ( WindowId id ) ;
void dodgeWindows ( WindowId id ) ;
void checkAllWindows ( ) ;
bool intersects ( const WindowInfoWrap & winfo ) ;
bool isMaximizedInCurrentScreen ( const WindowInfoWrap & winfo ) ;
bool isTouchingPanelEdge ( const WindowInfoWrap & winfo ) ;
void updateStrutsBasedOnLayoutsAndActivities ( ) ;
void viewEventManager ( QEvent * ev ) ;
2016-12-28 02:54:26 -05:00
private :
2018-12-20 18:59:38 +02:00
AbstractWindowInterface * wm ;
Types : : Visibility m_mode { Types : : None } ;
std : : array < QMetaObject : : Connection , 5 > connections ;
QMap < WindowId , WindowInfoWrap > windows ;
QTimer m_timerShow ;
QTimer m_timerHide ;
QTimer m_timerCheckWindows ;
QTimer m_timerStartUp ;
QRect m_viewGeometry ;
bool m_isHidden { false } ;
bool dragEnter { false } ;
bool m_blockHiding { false } ;
bool m_containsMouse { false } ;
bool raiseTemporarily { false } ;
bool raiseOnDesktopChange { false } ;
bool raiseOnActivityChange { false } ;
bool hideNow { false } ;
//! Dynamic Background flags and needed information
bool enabledDynamicBackgroundFlag { false } ;
bool windowIsSnappedFlag { false } ;
bool windowIsMaximizedFlag { false } ;
QRect availableScreenGeometry ;
QList < QRect > snappedWindowsGeometries ;
std : : array < QMetaObject : : Connection , 7 > connectionsDynBackground ;
WindowId lastActiveWindowWid ;
SchemeColors * touchingScheme { nullptr } ;
//! KWin Edges
bool enableKWinEdgesFromUser { true } ;
std : : array < QMetaObject : : Connection , 1 > connectionsKWinEdges ;
ScreenEdgeGhostWindow * edgeGhostWindow { nullptr } ;
Latte : : Corona * m_corona { nullptr } ;
Latte : : View * m_latteView { nullptr } ;
2017-03-12 13:09:38 -05:00
2016-12-25 09:25:27 +02:00
} ;
2016-12-29 00:42:55 -05:00
2018-12-09 00:29:35 +02:00
}
2016-12-29 00:42:55 -05:00
}
2016-12-25 18:12:31 -05:00
# endif // VISIBILITYMANAGER_H