2017-01-03 01:05:30 +03: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 10:25:27 +03:00
# ifndef VISIBILITYMANAGER_H
# define VISIBILITYMANAGER_H
2019-08-18 12:57:06 +03:00
# include <array>
2018-12-02 03:05:52 +03:00
// local
2020-04-24 14:52:16 +03:00
# include <coretypes.h>
2018-12-13 20:51:22 +03:00
# include "../plasma/quick/containmentview.h"
2016-12-25 10:25:27 +03:00
2018-12-02 03:05:52 +03:00
// Qt
2016-12-26 02:12:31 +03:00
# include <QObject>
2016-12-25 10:25:27 +03:00
# include <QTimer>
2018-12-02 03:05:52 +03:00
// Plasma
2016-12-25 10:25:27 +03:00
# include <Plasma/Containment>
2020-04-22 14:09:42 +03:00
2016-12-29 08:42:55 +03:00
namespace Latte {
2018-12-20 19:59:38 +03:00
class Corona ;
class View ;
2018-12-09 01:29:35 +03:00
namespace ViewPart {
2020-01-22 01:11:37 +03:00
class FloatingGapWindow ;
2018-12-20 19:59:38 +03:00
class ScreenEdgeGhostWindow ;
}
2019-05-11 15:43:10 +03:00
namespace WindowSystem {
class AbstractWindowInterface ;
}
2018-12-20 19:59:38 +03:00
}
2016-12-29 08:42:55 +03:00
2018-12-20 19:59:38 +03:00
namespace Latte {
namespace ViewPart {
2016-12-29 08:42:55 +03:00
2018-07-03 22:15:45 +03:00
class VisibilityManager : public QObject
{
2016-12-25 10:25:27 +03:00
Q_OBJECT
2020-04-05 14:40:32 +03:00
Q_PROPERTY ( bool hidingIsBlocked READ hidingIsBlocked NOTIFY hidingIsBlockedChanged )
2017-01-16 22:07:49 +03:00
2018-12-07 19:55:35 +03:00
Q_PROPERTY ( Latte : : Types : : Visibility mode READ mode WRITE setMode NOTIFY modeChanged )
2017-03-12 12:01:27 +03:00
Q_PROPERTY ( bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged )
2020-04-05 14:40:32 +03:00
Q_PROPERTY ( bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged )
2016-12-30 10:18:08 +03:00
Q_PROPERTY ( bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged )
2020-04-05 14:40:32 +03:00
Q_PROPERTY ( bool isBelowLayer READ isBelowLayer NOTIFY isBelowLayerChanged )
2016-12-28 10:54:26 +03:00
Q_PROPERTY ( bool containsMouse READ containsMouse NOTIFY containsMouseChanged )
2017-12-24 21:54:45 +03: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-26 02:12:31 +03:00
Q_PROPERTY ( int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged )
Q_PROPERTY ( int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged )
2017-01-16 22:07:49 +03:00
2021-01-07 16:02:16 +03:00
//! Struts
Q_PROPERTY ( int strutsThickness READ strutsThickness WRITE setStrutsThickness NOTIFY strutsThicknessChanged )
2016-12-25 10:25:27 +03:00
public :
2020-10-27 20:12:48 +03:00
static const QRect ISHIDDENMASK ;
2016-12-25 10:25:27 +03:00
explicit VisibilityManager ( PlasmaQuick : : ContainmentView * view ) ;
2016-12-26 02:12:31 +03:00
virtual ~ VisibilityManager ( ) ;
2017-01-16 22:07:49 +03:00
2018-12-07 19:55:35 +03:00
Latte : : Types : : Visibility mode ( ) const ;
void setMode ( Latte : : Types : : Visibility mode ) ;
2017-01-16 22:07:49 +03:00
2018-03-28 20:39:52 +03:00
void applyActivitiesToHiddenWindows ( const QStringList & activities ) ;
2018-01-13 13:55:13 +03:00
2017-03-12 12:01:27 +03:00
bool raiseOnDesktop ( ) const ;
void setRaiseOnDesktop ( bool enable ) ;
bool raiseOnActivity ( ) const ;
void setRaiseOnActivity ( bool enable ) ;
2019-12-27 14:38:22 +03:00
bool isBelowLayer ( ) const ;
2016-12-28 11:00:01 +03:00
bool isHidden ( ) const ;
2016-12-30 10:18:08 +03:00
void setIsHidden ( bool isHidden ) ;
2017-01-16 22:07:49 +03:00
2020-04-05 14:40:32 +03:00
bool hidingIsBlocked ( ) const ;
2017-01-16 22:07:49 +03:00
2016-12-28 11:00:01 +03:00
bool containsMouse ( ) const ;
2017-01-16 22:07:49 +03:00
2016-12-26 02:12:31 +03:00
int timerShow ( ) const ;
void setTimerShow ( int msec ) ;
2017-01-16 22:07:49 +03:00
2016-12-26 02:12:31 +03:00
int timerHide ( ) const ;
void setTimerHide ( int msec ) ;
2017-01-16 22:07:49 +03:00
2020-07-28 18:49:55 +03:00
bool isSidebar ( ) const ;
2018-03-28 20:39:52 +03:00
//! KWin Edges Support functions
bool enableKWinEdges ( ) const ;
void setEnableKWinEdges ( bool enable ) ;
bool supportsKWinEdges ( ) const ;
2021-01-07 16:02:16 +03:00
//! Struts
int strutsThickness ( ) const ;
void setStrutsThickness ( int thickness ) ;
2020-07-29 00:02:50 +03:00
//! Used mostly to show / hide Sidebars
2020-03-01 18:19:24 +03:00
void toggleHiddenState ( ) ;
2019-04-12 19:08:00 +03:00
public slots :
Q_INVOKABLE void hide ( ) ;
Q_INVOKABLE void show ( ) ;
2019-12-27 14:38:22 +03:00
Q_INVOKABLE void setViewOnBackLayer ( ) ;
Q_INVOKABLE void setViewOnFrontLayer ( ) ;
2020-04-05 14:40:32 +03:00
Q_INVOKABLE void addBlockHidingEvent ( const QString & type ) ;
Q_INVOKABLE void removeBlockHidingEvent ( const QString & type ) ;
2019-12-26 22:58:21 +03:00
void initViewFlags ( ) ;
2016-12-26 02:12:31 +03:00
signals :
2018-12-20 19:59:38 +03:00
void mustBeShown ( ) ;
void mustBeHide ( ) ;
2017-01-16 22:07:49 +03:00
2019-05-11 09:08:18 +03:00
void slideOutFinished ( ) ;
2019-05-02 00:10:29 +03:00
void slideInFinished ( ) ;
2020-05-12 14:45:31 +03:00
void frameExtentsCleared ( ) ;
2016-12-26 02:12:31 +03:00
void modeChanged ( ) ;
2017-03-12 12:01:27 +03:00
void raiseOnDesktopChanged ( ) ;
void raiseOnActivityChanged ( ) ;
2019-12-27 14:38:22 +03:00
void isBelowLayerChanged ( ) ;
2016-12-28 10:54:26 +03:00
void isHiddenChanged ( ) ;
2020-04-05 14:40:32 +03:00
void hidingIsBlockedChanged ( ) ;
2016-12-28 10:54:26 +03:00
void containsMouseChanged ( ) ;
2021-01-07 16:02:16 +03:00
void strutsThicknessChanged ( ) ;
2016-12-26 02:12:31 +03:00
void timerShowChanged ( ) ;
void timerHideChanged ( ) ;
2017-01-16 22:07:49 +03:00
2018-03-28 20:39:52 +03:00
//! KWin Edges Support signals
void enableKWinEdgesChanged ( ) ;
void supportsKWinEdgesChanged ( ) ;
2018-12-20 19:59:38 +03:00
private slots :
void saveConfig ( ) ;
void restoreConfig ( ) ;
2019-12-27 14:38:22 +03:00
void setIsBelowLayer ( bool below ) ;
2020-08-20 19:58:45 +03:00
void onHeadThicknessChanged ( ) ;
void onHidingIsBlockedChanged ( ) ;
2020-04-05 14:40:32 +03:00
2020-05-12 10:30:05 +03:00
void publishFrameExtents ( bool forceUpdate = false ) ; //! direct
2020-05-11 17:31:03 +03:00
2020-07-29 00:58:21 +03:00
//! Floating Gap Helper window creation/removal
void updateFloatingGapWindow ( ) ;
2019-06-20 10:25:18 +03:00
//! KWin Edges Support functions
void updateKWinEdgesSupport ( ) ;
2018-12-20 19:59:38 +03:00
private :
void setContainsMouse ( bool contains ) ;
void raiseView ( bool raise ) ;
void raiseViewTemporarily ( ) ;
//! KWin Edges Support functions
void createEdgeGhostWindow ( ) ;
void deleteEdgeGhostWindow ( ) ;
2019-02-24 20:09:48 +03:00
void updateGhostWindowState ( ) ;
2018-12-20 19:59:38 +03:00
2020-01-22 01:11:37 +03:00
//! Floating Gap Support functions
void createFloatingGapWindow ( ) ;
void deleteFloatingGapWindow ( ) ;
bool supportsFloatingGap ( ) const ;
2019-05-14 17:56:22 +03:00
void updateStrutsBasedOnLayoutsAndActivities ( bool forceUpdate = false ) ;
2018-12-20 19:59:38 +03:00
void viewEventManager ( QEvent * ev ) ;
2020-01-22 01:11:37 +03:00
void checkMouseInFloatingArea ( ) ;
bool windowContainsMouse ( ) ;
2019-05-01 23:04:39 +03:00
QRect acceptableStruts ( ) ;
2019-02-07 21:24:52 +03:00
private slots :
void dodgeAllWindows ( ) ;
2019-04-23 09:58:06 +03:00
void dodgeActive ( ) ;
void dodgeMaximized ( ) ;
2019-05-02 00:10:29 +03:00
void updateHiddenState ( ) ;
2019-02-07 21:24:52 +03:00
2020-04-15 16:47:15 +03:00
bool isValidMode ( ) const ;
2020-07-29 00:13:16 +03:00
private :
void startTimerHide ( const int & msec = 0 ) ;
2016-12-28 10:54:26 +03:00
private :
2019-05-11 15:43:10 +03:00
WindowSystem : : AbstractWindowInterface * m_wm ;
2018-12-20 19:59:38 +03:00
Types : : Visibility m_mode { Types : : None } ;
2019-04-23 10:54:53 +03:00
std : : array < QMetaObject : : Connection , 5 > m_connections ;
2018-12-20 19:59:38 +03:00
QTimer m_timerShow ;
QTimer m_timerHide ;
QTimer m_timerStartUp ;
2020-05-11 17:31:03 +03:00
QTimer m_timerPublishFrameExtents ;
2019-04-23 10:41:35 +03:00
2019-12-27 14:38:22 +03:00
bool m_isBelowLayer { false } ;
2018-12-20 19:59:38 +03:00
bool m_isHidden { false } ;
2019-04-23 10:54:53 +03:00
bool m_dragEnter { false } ;
2018-12-20 19:59:38 +03:00
bool m_containsMouse { false } ;
2019-04-23 10:54:53 +03:00
bool m_raiseTemporarily { false } ;
bool m_raiseOnDesktopChange { false } ;
bool m_raiseOnActivityChange { false } ;
bool m_hideNow { false } ;
2018-12-20 19:59:38 +03:00
2020-05-11 17:31:03 +03:00
int m_frameExtentsHeadThicknessGap { 0 } ;
2020-07-29 00:13:16 +03:00
int m_timerHideInterval { 700 } ;
2020-05-11 17:31:03 +03:00
Plasma : : Types : : Location m_frameExtentsLocation { Plasma : : Types : : BottomEdge } ;
2021-01-07 16:02:16 +03:00
int m_strutsThickness { 0 } ;
2020-04-05 14:40:32 +03:00
QStringList m_blockHidingEvents ;
2019-05-01 23:04:39 +03:00
QRect m_publishedStruts ;
2020-11-30 22:06:24 +03:00
QRect m_lastMask ;
2019-05-01 23:04:39 +03:00
2018-12-20 19:59:38 +03:00
//! KWin Edges
2019-04-23 10:54:53 +03:00
bool m_enableKWinEdgesFromUser { true } ;
std : : array < QMetaObject : : Connection , 1 > m_connectionsKWinEdges ;
ScreenEdgeGhostWindow * m_edgeGhostWindow { nullptr } ;
2018-12-20 19:59:38 +03:00
2020-01-22 01:11:37 +03:00
//! Floating Gap
FloatingGapWindow * m_floatingGapWindow { nullptr } ;
2018-12-20 19:59:38 +03:00
Latte : : Corona * m_corona { nullptr } ;
Latte : : View * m_latteView { nullptr } ;
2017-03-12 21:09:38 +03:00
2016-12-25 10:25:27 +03:00
} ;
2016-12-29 08:42:55 +03:00
2018-12-09 01:29:35 +03:00
}
2016-12-29 08:42:55 +03:00
}
2016-12-26 02:12:31 +03:00
# endif // VISIBILITYMANAGER_H