2018-03-28 20:39:52 +03:00
/*
* Copyright 2018 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/>.
*/
# ifndef SCREENEDGEGHOSTWINDOW_H
# define SCREENEDGEGHOSTWINDOW_H
2018-12-02 02:05:52 +02:00
// Qt
2018-03-28 20:39:52 +03:00
# include <QObject>
# include <QQuickView>
2018-05-20 22:50:23 +03:00
# include <QTimer>
2018-03-28 20:39:52 +03:00
namespace KWayland {
namespace Client {
class PlasmaShellSurface ;
}
}
namespace Latte {
2018-12-06 12:15:58 +02:00
class View ;
2018-03-28 20:39:52 +03:00
}
namespace Latte {
2018-12-09 00:15:17 +02:00
namespace ViewPart {
2018-03-28 20:39:52 +03:00
//! What is the importance of this class?
//!
//! Plasma is activating the screen edges for the main panel window
2019-01-01 11:19:44 +02:00
//! unfortunately this isn't possible for the Latte case.
2018-03-28 20:39:52 +03:00
//! When a window is hidden at an edge it becomes NOT visible
//! unfortunately that means that all the animations are
//! stopped (Qt behaviour) and that creates confusion to the user after the window
//! reappears because various animations are played (adding-removing tasks/launchers)
2019-01-01 11:19:44 +02:00
//! that aren't relevant any more.
2018-03-28 20:39:52 +03:00
//!
//! In order to workaround the above behaviour Latte is using a
2018-12-06 16:09:42 +02:00
//! fake window to communicate with KWin and the MAIN Latte::View window
2018-03-28 20:39:52 +03:00
//! continues to use only mask technique to hide
//!
//! KDE BUGS: https://bugs.kde.org/show_bug.cgi?id=382219
//! https://bugs.kde.org/show_bug.cgi?id=392464
2018-07-03 22:15:45 +03:00
class ScreenEdgeGhostWindow : public QQuickView
{
2018-03-28 20:39:52 +03:00
Q_OBJECT
public :
2018-12-06 12:15:58 +02:00
ScreenEdgeGhostWindow ( Latte : : View * view ) ;
2018-03-28 20:39:52 +03:00
~ ScreenEdgeGhostWindow ( ) override ;
2019-02-24 19:09:48 +02:00
bool containsMouse ( ) const ;
2018-03-28 20:39:52 +03:00
int location ( ) ;
void hideWithMask ( ) ;
void showWithMask ( ) ;
2018-12-06 16:09:42 +02:00
Latte : : View * parentView ( ) ;
2018-03-28 20:39:52 +03:00
KWayland : : Client : : PlasmaShellSurface * surface ( ) ;
signals :
2018-11-13 19:06:33 +02:00
void containsMouseChanged ( bool contains ) ;
2018-03-28 20:39:52 +03:00
protected :
bool event ( QEvent * ev ) override ;
private slots :
2018-05-20 22:50:23 +03:00
void startGeometryTimer ( ) ;
2018-03-28 20:39:52 +03:00
void updateGeometry ( ) ;
2018-04-01 01:28:11 +03:00
void fixGeometry ( ) ;
2018-03-28 20:39:52 +03:00
private :
2019-02-24 19:09:48 +02:00
void setContainsMouse ( bool contains ) ;
2018-03-28 20:39:52 +03:00
void setupWaylandIntegration ( ) ;
private :
2019-03-11 16:09:50 +02:00
bool m_delayedContainsMouse { false } ;
2019-02-24 19:09:48 +02:00
bool m_containsMouse { false } ;
2018-03-28 20:39:52 +03:00
bool m_inDelete { false } ;
2018-04-01 01:28:11 +03:00
QRect m_calculatedGeometry ;
2018-03-28 20:39:52 +03:00
2019-03-11 16:09:50 +02:00
QTimer m_delayedMouseTimer ;
2018-05-20 22:50:23 +03:00
QTimer m_fixGeometryTimer ;
2019-05-14 17:40:44 +03:00
//! HACK: Timers in order to handle KWin faulty
//! behavior that hides Views when closing Activities
//! with no actual reason
QTimer m_visibleHackTimer1 ;
QTimer m_visibleHackTimer2 ;
//! Connections for the KWin visibility hack
QList < QMetaObject : : Connection > connectionsHack ;
2018-12-06 12:51:15 +02:00
Latte : : View * m_latteView { nullptr } ;
2018-03-28 20:39:52 +03:00
KWayland : : Client : : PlasmaShellSurface * m_shellSurface { nullptr } ;
} ;
}
2018-12-09 00:15:17 +02:00
}
2018-03-28 20:39:52 +03:00
# endif