2017-04-25 17:48:36 +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/>.
*/
# ifndef WAYLANDINTERFACE_H
# define WAYLANDINTERFACE_H
2018-12-02 03:05:52 +03:00
// local
2019-05-26 00:58:42 +03:00
# include <config-latte.h>
2017-04-25 17:48:36 +03:00
# include "abstractwindowinterface.h"
# include "windowinfowrap.h"
2018-12-02 03:05:52 +03:00
// Qt
2017-06-29 23:33:12 +03:00
# include <QMap>
2018-12-02 03:05:52 +03:00
# include <QObject>
2017-06-11 00:33:46 +03:00
2018-12-02 03:05:52 +03:00
// KDE
2017-06-11 00:33:46 +03:00
# include <KWayland/Client/registry.h>
# include <KWayland/Client/connection_thread.h>
# include <KWayland/Client/plasmawindowmanagement.h>
# include <KWayland/Client/plasmashell.h>
# include <KWayland/Client/surface.h>
2018-12-02 03:05:52 +03:00
# include <KWindowInfo>
# include <KWindowEffects>
2017-04-25 17:48:36 +03:00
2019-05-11 15:43:10 +03:00
namespace Latte {
2018-12-06 15:35:34 +03:00
class Corona ;
2017-06-29 23:33:12 +03:00
namespace Private {
2019-05-11 15:43:10 +03:00
//! this class is used to create the struts inside wayland
2018-01-13 13:55:13 +03:00
class GhostWindow ;
2017-06-29 23:33:12 +03:00
}
2019-05-11 15:43:10 +03:00
}
namespace Latte {
namespace WindowSystem {
2017-06-29 23:33:12 +03:00
2018-07-03 22:15:45 +03:00
class WaylandInterface : public AbstractWindowInterface
{
2017-04-25 17:48:36 +03:00
Q_OBJECT
public :
explicit WaylandInterface ( QObject * parent = nullptr ) ;
~ WaylandInterface ( ) override ;
2019-12-26 17:53:37 +03:00
void setViewExtraFlags ( QObject * view , bool isPanelWindow = true , Latte : : Types : : Visibility mode = Latte : : Types : : WindowsGoBelow ) override ;
2018-12-06 17:09:42 +03:00
void setViewStruts ( QWindow & view , const QRect & rect
2017-06-16 00:56:55 +03:00
, Plasma : : Types : : Location location ) override ;
2018-01-21 12:53:15 +03:00
void setWindowOnActivities ( QWindow & view , const QStringList & activities ) override ;
2017-04-25 17:48:36 +03:00
2018-12-06 17:09:42 +03:00
void removeViewStruts ( QWindow & view ) const override ;
2017-04-25 17:48:36 +03:00
2017-06-09 01:10:49 +03:00
WindowId activeWindow ( ) const override ;
WindowInfoWrap requestInfo ( WindowId wid ) const override ;
2017-04-25 17:48:36 +03:00
WindowInfoWrap requestInfoActive ( ) const override ;
void skipTaskBar ( const QDialog & dialog ) const override ;
2017-06-16 00:56:55 +03:00
void slideWindow ( QWindow & view , Slide location ) const override ;
void enableBlurBehind ( QWindow & view ) const override ;
2017-04-25 17:48:36 +03:00
2019-04-01 23:50:25 +03:00
void requestActivate ( WindowId wid ) const override ;
2019-06-02 01:07:47 +03:00
void requestClose ( WindowId wid ) const override ;
2018-10-28 22:10:08 +03:00
void requestMoveWindow ( WindowId wid , QPoint from ) const override ;
2019-06-02 01:57:03 +03:00
void requestToggleIsOnAllDesktops ( WindowId wid ) const override ;
2019-06-02 01:07:47 +03:00
void requestToggleKeepAbove ( WindowId wid ) const override ;
void requestToggleMinimized ( WindowId wid ) const override ;
void requestToggleMaximized ( WindowId wid ) const override ;
2019-12-26 17:53:37 +03:00
void setKeepAbove ( WindowId wid , bool active ) const override ;
void setKeepBelow ( WindowId wid , bool active ) const override ;
2019-06-02 01:07:47 +03:00
2019-07-31 16:44:43 +03:00
bool windowCanBeDragged ( WindowId wid ) const override ;
bool windowCanBeMaximized ( WindowId wid ) const override ;
2019-06-02 01:07:47 +03:00
2019-05-27 18:56:24 +03:00
QIcon iconFor ( WindowId wid ) const ;
2019-04-01 23:50:25 +03:00
WindowId winIdFor ( QString appId , QRect geometry ) const override ;
2019-06-01 01:20:54 +03:00
AppData appDataFor ( WindowId wid ) const override ;
2018-10-28 11:03:22 +03:00
2020-01-03 14:32:08 +03:00
void setActiveEdge ( QWindow * view , bool active ) const override ;
2018-03-28 20:39:52 +03:00
2019-06-10 17:30:25 +03:00
void switchToNextVirtualDesktop ( ) const override ;
void switchToPreviousVirtualDesktop ( ) const override ;
2019-07-15 14:53:40 +03:00
void registerIgnoredWindow ( WindowId wid ) override ;
void unregisterIgnoredWindow ( WindowId wid ) override ;
2018-03-02 00:53:28 +03:00
void initWindowManagement ( KWayland : : Client : : PlasmaWindowManagement * windowManagement ) ;
2019-05-26 00:58:42 +03:00
# if KF5_VERSION_MINOR >= 52
//! VirtualDesktopsSupport
void initVirtualDesktopManagement ( KWayland : : Client : : PlasmaVirtualDesktopManagement * virtualDesktopManagement ) ;
# endif
2019-12-22 14:36:51 +03:00
private slots :
void updateWindow ( ) ;
void windowUnmapped ( ) ;
2017-04-25 17:48:36 +03:00
private :
2017-06-11 00:33:46 +03:00
void init ( ) ;
2019-02-11 20:40:24 +03:00
bool isValidWindow ( const KWayland : : Client : : PlasmaWindow * w ) const ;
bool isPlasmaDesktop ( const KWayland : : Client : : PlasmaWindow * w ) const ;
2019-11-02 11:45:37 +03:00
bool isPlasmaPanel ( const KWayland : : Client : : PlasmaWindow * w ) const ;
2017-06-11 00:33:46 +03:00
void windowCreatedProxy ( KWayland : : Client : : PlasmaWindow * w ) ;
2019-12-22 14:36:51 +03:00
void trackWindow ( KWayland : : Client : : PlasmaWindow * w ) ;
void untrackWindow ( KWayland : : Client : : PlasmaWindow * w ) ;
2018-10-28 22:10:08 +03:00
KWayland : : Client : : PlasmaWindow * windowFor ( WindowId wid ) const ;
2018-12-06 15:35:34 +03:00
KWayland : : Client : : PlasmaShell * waylandCoronaInterface ( ) const ;
2017-04-25 17:48:36 +03:00
2019-05-26 00:58:42 +03:00
# if KF5_VERSION_MINOR >= 52
//! VirtualDesktopsSupport
void setCurrentDesktop ( QString desktop ) ;
void addDesktop ( const QString & id , quint32 position ) ;
# endif
private :
2017-06-29 23:33:12 +03:00
friend class Private : : GhostWindow ;
mutable QMap < WindowId , Private : : GhostWindow * > m_ghostWindows ;
2018-03-02 00:53:28 +03:00
KWayland : : Client : : PlasmaWindowManagement * m_windowManagement { nullptr } ;
2019-05-26 00:58:42 +03:00
# if KF5_VERSION_MINOR >= 52
//! VirtualDesktopsSupport
KWayland : : Client : : PlasmaVirtualDesktopManagement * m_virtualDesktopManagement { nullptr } ;
QStringList m_desktops ;
# endif
2018-12-06 15:35:34 +03:00
Latte : : Corona * m_corona { nullptr } ;
2017-04-25 17:48:36 +03:00
} ;
2019-05-11 15:43:10 +03:00
}
2017-04-25 17:48:36 +03:00
}
# endif // WAYLANDINTERFACE_H