1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00
latte-dock/app/view/visibilitymanager.h

273 lines
7.7 KiB
C
Raw Permalink Normal View History

2017-01-03 01:05:30 +03:00
/*
2021-05-27 18:01:00 +03:00
SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
2017-01-03 01:05:30 +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
#include <coretypes.h>
#include "../plasma/quick/containmentview.h"
2018-12-02 03:05:52 +03:00
// Qt
2016-12-26 02:12:31 +03:00
#include <QObject>
#include <QTimer>
2018-12-02 03:05:52 +03:00
// Plasma
#include <Plasma/Containment>
2016-12-29 08:42:55 +03:00
namespace Latte {
class Corona;
class View;
namespace ViewPart {
class FloatingGapWindow;
class ScreenEdgeGhostWindow;
}
2019-05-11 15:43:10 +03:00
namespace WindowSystem {
class AbstractWindowInterface;
}
}
2016-12-29 08:42:55 +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
{
Q_OBJECT
Q_PROPERTY(bool hidingIsBlocked READ hidingIsBlocked NOTIFY hidingIsBlockedChanged)
2017-01-16 22:07:49 +03:00
Q_PROPERTY(Latte::Types::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged)
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)
Q_PROPERTY(bool isShownFully READ isShownFully WRITE setIsShownFully NOTIFY isShownFullyChanged)
Q_PROPERTY(bool isBelowLayer READ isBelowLayer NOTIFY isBelowLayerChanged)
Q_PROPERTY(bool isSidebar READ isSidebar NOTIFY isSidebarChanged)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
//! Floating Gap Window to identify mouse between the screenEdge and the view when it does not accept any other
//! user input
Q_PROPERTY(bool isFloatingGapWindowEnabled READ isFloatingGapWindowEnabled WRITE setIsFloatingGapWindowEnabled NOTIFY isFloatingGapWindowEnabledChanged)
//! 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
//! Struts
Q_PROPERTY(int strutsThickness READ strutsThickness WRITE setStrutsThickness NOTIFY strutsThicknessChanged)
public:
static const QRect ISHIDDENMASK;
explicit VisibilityManager(PlasmaQuick::ContainmentView *view);
2016-12-26 02:12:31 +03:00
virtual ~VisibilityManager();
2017-01-16 22:07:49 +03:00
Latte::Types::Visibility mode() const;
void setMode(Latte::Types::Visibility mode);
2017-01-16 22:07:49 +03:00
void applyActivitiesToHiddenWindows(const QStringList &activities);
bool raiseOnDesktop() const;
void setRaiseOnDesktop(bool enable);
bool raiseOnActivity() const;
void setRaiseOnActivity(bool enable);
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
bool isShownFully() const;
void setIsShownFully(bool fully);
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
bool isFloatingGapWindowEnabled() const;
void setIsFloatingGapWindowEnabled(bool enabled);
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
bool isSidebar() const;
bool hasBlockHidingEvent(const QString &type);
//! KWin Edges Support functions
bool enableKWinEdges() const;
void setEnableKWinEdges(bool enable);
bool supportsKWinEdges() const;
//! Struts
int strutsThickness() const;
void setStrutsThickness(int thickness);
//! Used mostly to show / hide Sidebars
void toggleHiddenState();
2019-04-12 19:08:00 +03:00
public slots:
Q_INVOKABLE void hide();
Q_INVOKABLE void show();
Q_INVOKABLE void setViewOnBackLayer();
Q_INVOKABLE void setViewOnFrontLayer();
Q_INVOKABLE void addBlockHidingEvent(const QString &type);
Q_INVOKABLE void removeBlockHidingEvent(const QString &type);
void initViewFlags();
2016-12-26 02:12:31 +03:00
signals:
void mustBeShown();
void mustBeHide();
2017-01-16 22:07:49 +03:00
void slideOutFinished();
void slideInFinished();
void frameExtentsCleared();
2016-12-26 02:12:31 +03:00
void modeChanged();
void raiseOnDesktopChanged();
void raiseOnActivityChanged();
void isBelowLayerChanged();
void isFloatingGapWindowEnabledChanged();
void isHiddenChanged();
void isSidebarChanged();
void isShownFullyChanged();
void hidingIsBlockedChanged();
void containsMouseChanged();
void strutsThicknessChanged();
2016-12-26 02:12:31 +03:00
void timerShowChanged();
void timerHideChanged();
2017-01-16 22:07:49 +03:00
//! KWin Edges Support signals
void enableKWinEdgesChanged();
void supportsKWinEdgesChanged();
private slots:
void saveConfig();
void restoreConfig();
void setIsBelowLayer(bool below);
void onHeadThicknessChanged();
void onHidingIsBlockedChanged();
void onIsFloatingGapWindowEnabledChanged();
void publishFrameExtents(bool forceUpdate = false); //! direct
//! KWin Edges Support functions
void updateKWinEdgesSupport();
void updateSidebarState();
private:
void setContainsMouse(bool contains);
void raiseView(bool raise);
void raiseViewTemporarily();
//! KWin Edges Support functions
void createEdgeGhostWindow();
void deleteEdgeGhostWindow();
void updateGhostWindowState();
//! Floating Gap Support functions
void createFloatingGapWindow();
void deleteFloatingGapWindow();
bool supportsFloatingGap() const;
void updateStrutsBasedOnLayoutsAndActivities(bool forceUpdate = false);
void viewEventManager(QEvent *ev);
void checkMouseInFloatingArea();
bool windowContainsMouse();
2019-05-01 23:04:39 +03:00
QRect acceptableStruts();
private slots:
void dodgeAllWindows();
2019-04-23 09:58:06 +03:00
void dodgeActive();
void dodgeMaximized();
void updateHiddenState();
void updateStrutsAfterTimer();
bool isValidMode() const;
private:
void startTimerHide(const int &msec = 0);
bool canSetStrut() const;
private:
2019-05-11 15:43:10 +03:00
WindowSystem::AbstractWindowInterface *m_wm;
Types::Visibility m_mode{Types::None};
std::array<QMetaObject::Connection, 6> m_connections;
QTimer m_timerShow;
QTimer m_timerHide;
QTimer m_timerPublishFrameExtents;
//! This timer is very important because it blocks how fast struts are updated.
//! By using this timer we help the window manager in order to correspond to new
//! struts (for example changing windows maximized state or geometry) without
//! createing binding loops between the app and the window manager.
//! That was reproducable in a floating panel when we were dragging the active window.
QTimer m_timerBlockStrutsUpdate;
bool m_isBelowLayer{false};
bool m_isHidden{false};
bool m_isFloatingGapWindowEnabled{false};
bool m_isSidebar{false};
bool m_isShownFully{false};
bool m_dragEnter{false};
bool m_containsMouse{false};
bool m_raiseTemporarily{false};
bool m_raiseOnDesktopChange{false};
bool m_raiseOnActivityChange{false};
bool m_hideNow{false};
//! valid on demand sidebar hidden state in order to be checked after slide-ins/outs
bool m_isRequestedShownSidebarOnDemand{false};
int m_frameExtentsHeadThicknessGap{0};
int m_timerHideInterval{700};
Plasma::Types::Location m_frameExtentsLocation{Plasma::Types::BottomEdge};
int m_strutsThickness{0};
QStringList m_blockHidingEvents;
2019-05-01 23:04:39 +03:00
QRect m_publishedStruts;
QRect m_lastMask;
2019-05-01 23:04:39 +03:00
//! KWin Edges
bool m_enableKWinEdgesFromUser{true};
std::array<QMetaObject::Connection, 1> m_connectionsKWinEdges;
ScreenEdgeGhostWindow *m_edgeGhostWindow{nullptr};
//! Floating Gap
FloatingGapWindow *m_floatingGapWindow{nullptr};
Latte::Corona *m_corona{nullptr};
Latte::View *m_latteView{nullptr};
};
2016-12-29 08:42:55 +03:00
}
2016-12-29 08:42:55 +03:00
}
2016-12-26 02:12:31 +03:00
#endif // VISIBILITYMANAGER_H