2015-03-04 08:21:10 +00:00
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project .
Copyright ( C ) 2015 Martin Gräßlin < mgraesslin @ kde . org >
This program 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 .
This program 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 KWIN_SHELL_CLIENT_H
# define KWIN_SHELL_CLIENT_H
2015-03-16 08:14:04 +00:00
# include "abstract_client.h"
2016-04-22 12:13:37 +00:00
# include <KWayland/Server/xdgshell_interface.h>
2015-03-04 08:21:10 +00:00
namespace KWayland
{
namespace Server
{
class ShellSurfaceInterface ;
2015-12-17 10:14:54 +00:00
class ServerSideDecorationInterface ;
2015-06-09 17:10:56 +00:00
class PlasmaShellSurfaceInterface ;
2015-06-09 22:59:53 +00:00
class QtExtendedSurfaceInterface ;
2015-03-04 08:21:10 +00:00
}
}
namespace KWin
{
2015-08-18 12:46:44 +00:00
class KWIN_EXPORT ShellClient : public AbstractClient
2015-03-04 08:21:10 +00:00
{
Q_OBJECT
public :
ShellClient ( KWayland : : Server : : ShellSurfaceInterface * surface ) ;
2016-04-22 12:13:37 +00:00
ShellClient ( KWayland : : Server : : XdgShellSurfaceInterface * surface ) ;
ShellClient ( KWayland : : Server : : XdgShellPopupInterface * surface ) ;
2015-03-04 08:21:10 +00:00
virtual ~ ShellClient ( ) ;
QStringList activities ( ) const override ;
2015-12-08 09:11:26 +00:00
QPoint clientContentPos ( ) const override ;
2015-03-04 08:21:10 +00:00
QSize clientSize ( ) const override ;
QRect transparentRect ( ) const override ;
NET : : WindowType windowType ( bool direct = false , int supported_types = 0 ) const override ;
void debug ( QDebug & stream ) const override ;
double opacity ( ) const override ;
2015-03-16 08:13:19 +00:00
void setOpacity ( double opacity ) override ;
2015-03-04 08:21:10 +00:00
QByteArray windowRole ( ) const override ;
KWayland : : Server : : ShellSurfaceInterface * shellSurface ( ) const {
return m_shellSurface ;
}
2015-03-16 08:14:04 +00:00
void blockActivityUpdates ( bool b = true ) override ;
QString caption ( bool full = true , bool stripped = false ) const override ;
void closeWindow ( ) override ;
AbstractClient * findModal ( bool allow_itself = false ) override ;
bool isCloseable ( ) const override ;
2015-05-21 13:59:27 +00:00
bool isFullScreenable ( ) const override ;
2015-03-16 08:14:04 +00:00
bool isFullScreen ( ) const override ;
bool isMaximizable ( ) const override ;
bool isMinimizable ( ) const override ;
bool isMovable ( ) const override ;
bool isMovableAcrossScreens ( ) const override ;
bool isResizable ( ) const override ;
bool isShown ( bool shaded_is_shown ) const override ;
2016-07-04 13:06:20 +00:00
bool isHiddenInternal ( ) const override {
return m_unmapped ;
}
2015-05-23 07:02:11 +00:00
void hideClient ( bool hide ) override ;
2015-03-16 08:14:04 +00:00
MaximizeMode maximizeMode ( ) const override ;
2015-10-12 08:17:38 +00:00
QRect geometryRestore ( ) const override {
return m_geomMaximizeRestore ;
}
2015-03-16 08:14:04 +00:00
bool noBorder ( ) const override ;
const WindowRules * rules ( ) const override ;
void setFullScreen ( bool set , bool user = true ) override ;
void setNoBorder ( bool set ) override ;
2015-12-17 14:47:36 +00:00
void updateDecoration ( bool check_workspace_pos , bool force = false ) override ;
2015-03-16 08:14:04 +00:00
void setOnAllActivities ( bool set ) override ;
void setShortcut ( const QString & cut ) override ;
const QKeySequence & shortcut ( ) const override ;
void takeFocus ( ) override ;
void updateWindowRules ( Rules : : Types selection ) override ;
bool userCanSetFullScreen ( ) const override ;
bool userCanSetNoBorder ( ) const override ;
bool wantsInput ( ) const override ;
2015-05-27 09:48:33 +00:00
using AbstractClient : : resizeWithChecks ;
void resizeWithChecks ( int w , int h , ForceGeometry_t force = NormalGeometrySet ) override ;
2015-10-13 08:52:01 +00:00
using AbstractClient : : setGeometry ;
void setGeometry ( int x , int y , int w , int h , ForceGeometry_t force = NormalGeometrySet ) override ;
2015-06-19 22:14:49 +00:00
bool hasStrut ( ) const override ;
2015-03-16 08:14:04 +00:00
2015-08-18 12:40:26 +00:00
void setInternalFramebufferObject ( const QSharedPointer < QOpenGLFramebufferObject > & fbo ) override ;
2016-05-02 15:47:39 +00:00
quint32 windowId ( ) const override {
2015-05-18 12:51:40 +00:00
return m_windowId ;
}
2015-05-21 08:31:19 +00:00
bool isInternal ( ) const ;
2015-11-16 10:19:38 +00:00
bool isLockScreen ( ) const override ;
bool isInputMethod ( ) const override ;
2015-06-06 01:26:24 +00:00
QWindow * internalWindow ( ) const {
return m_internalWindow ;
}
2015-05-18 12:51:40 +00:00
2015-06-09 17:10:56 +00:00
void installPlasmaShellSurface ( KWayland : : Server : : PlasmaShellSurfaceInterface * surface ) ;
2015-06-09 22:59:53 +00:00
void installQtExtendedSurface ( KWayland : : Server : : QtExtendedSurfaceInterface * surface ) ;
2015-12-17 10:14:54 +00:00
void installServerSideDecoration ( KWayland : : Server : : ServerSideDecorationInterface * decoration ) ;
2015-06-09 17:10:56 +00:00
bool isInitialPositionSet ( ) const ;
2015-09-11 10:11:01 +00:00
bool isTransient ( ) const override ;
2015-09-11 11:31:41 +00:00
bool hasTransientPlacementHint ( ) const override ;
QPoint transientPlacementHint ( ) const override ;
2015-09-11 10:11:01 +00:00
2015-12-07 13:27:06 +00:00
QMatrix4x4 inputTransformation ( ) const override ;
2016-08-19 10:33:59 +00:00
bool setupCompositing ( ) override ;
void finishCompositing ( ReleaseReason releaseReason = ReleaseReason : : Release ) override ;
2016-08-30 11:16:52 +00:00
// TODO: const-ref
void placeIn ( QRect & area ) ;
2015-03-04 08:21:10 +00:00
protected :
void addDamage ( const QRegion & damage ) override ;
2015-03-16 08:14:04 +00:00
bool belongsToSameApplication ( const AbstractClient * other , bool active_hack ) const override ;
2015-07-07 14:15:58 +00:00
void doSetActive ( ) override ;
2015-09-17 09:06:59 +00:00
Layer layerForDock ( ) const override ;
2015-10-13 08:22:18 +00:00
void changeMaximize ( bool horizontal , bool vertical , bool adjust ) override ;
2015-10-13 11:52:03 +00:00
void setGeometryRestore ( const QRect & geo ) override {
m_geomMaximizeRestore = geo ;
}
2015-10-28 10:16:48 +00:00
void doResizeSync ( ) override ;
bool isWaitingForMoveResizeSync ( ) const override ;
2015-12-07 15:18:30 +00:00
bool acceptsFocus ( ) const override ;
2016-08-11 15:32:39 +00:00
void doMinimize ( ) override ;
2015-03-04 08:21:10 +00:00
2015-05-19 10:03:53 +00:00
private Q_SLOTS :
void clientFullScreenChanged ( bool fullScreen ) ;
2015-03-04 08:21:10 +00:00
private :
2016-04-18 09:55:40 +00:00
void init ( ) ;
2016-04-22 12:13:37 +00:00
template < class T >
void initSurface ( T * shellSurface ) ;
2015-05-19 10:03:53 +00:00
void requestGeometry ( const QRect & rect ) ;
2015-10-13 08:52:01 +00:00
void doSetGeometry ( const QRect & rect ) ;
2015-12-17 14:47:36 +00:00
void createDecoration ( const QRect & oldgeom ) ;
2015-03-04 08:21:10 +00:00
void destroyClient ( ) ;
2015-06-03 19:19:00 +00:00
void unmap ( ) ;
2015-05-18 12:51:40 +00:00
void createWindowId ( ) ;
void findInternalWindow ( ) ;
2015-05-20 06:27:48 +00:00
void updateInternalWindowGeometry ( ) ;
2015-06-19 23:11:42 +00:00
void updateIcon ( ) ;
2015-07-22 06:38:00 +00:00
void markAsMapped ( ) ;
2015-09-11 10:11:01 +00:00
void setTransient ( ) ;
2016-06-03 11:37:24 +00:00
bool shouldExposeToWindowManagement ( ) ;
2016-04-22 12:13:37 +00:00
KWayland : : Server : : XdgShellSurfaceInterface : : States xdgSurfaceStates ( ) const ;
2015-03-04 08:21:10 +00:00
static void deleteClient ( ShellClient * c ) ;
KWayland : : Server : : ShellSurfaceInterface * m_shellSurface ;
2016-04-22 12:13:37 +00:00
KWayland : : Server : : XdgShellSurfaceInterface * m_xdgShellSurface ;
KWayland : : Server : : XdgShellPopupInterface * m_xdgShellPopup ;
2015-03-04 08:21:10 +00:00
QSize m_clientSize ;
2015-05-19 10:03:53 +00:00
ClearablePoint m_positionAfterResize ; // co-ordinates saved from a requestGeometry call, real geometry will be updated after the next damage event when the client has resized
QRect m_geomFsRestore ; //size and position of the window before it was set to fullscreen
2015-04-30 11:48:59 +00:00
bool m_closing = false ;
2015-05-18 12:51:40 +00:00
quint32 m_windowId = 0 ;
QWindow * m_internalWindow = nullptr ;
2016-05-09 12:48:10 +00:00
Qt : : WindowFlags m_internalWindowFlags = Qt : : WindowFlags ( ) ;
2015-06-03 19:19:00 +00:00
bool m_unmapped = true ;
2015-06-07 01:28:38 +00:00
MaximizeMode m_maximizeMode = MaximizeRestore ;
QRect m_geomMaximizeRestore ; // size and position of the window before it was set to maximize
2015-06-08 19:27:55 +00:00
NET : : WindowType m_windowType = NET : : Normal ;
2015-06-09 17:10:56 +00:00
QPointer < KWayland : : Server : : PlasmaShellSurfaceInterface > m_plasmaShellSurface ;
2015-06-09 22:59:53 +00:00
QPointer < KWayland : : Server : : QtExtendedSurfaceInterface > m_qtExtendedSurface ;
2015-12-17 10:14:54 +00:00
KWayland : : Server : : ServerSideDecorationInterface * m_serverDecoration = nullptr ;
2015-12-17 14:47:36 +00:00
bool m_userNoBorder = false ;
2015-10-08 08:05:40 +00:00
bool m_fullScreen = false ;
2015-10-08 09:04:06 +00:00
bool m_transient = false ;
2015-12-18 16:26:21 +00:00
bool m_internal ;
2016-02-18 07:27:02 +00:00
qreal m_opacity = 1.0 ;
2016-06-09 14:54:06 +00:00
class RequestGeometryBlocker {
public :
RequestGeometryBlocker ( ShellClient * client )
: m_client ( client )
{
m_client - > m_requestGeometryBlockCounter + + ;
}
~ RequestGeometryBlocker ( )
{
m_client - > m_requestGeometryBlockCounter - - ;
if ( m_client - > m_requestGeometryBlockCounter = = 0 ) {
if ( m_client - > m_blockedRequestGeometry . isValid ( ) ) {
m_client - > requestGeometry ( m_client - > m_blockedRequestGeometry ) ;
}
}
}
private :
ShellClient * m_client ;
} ;
friend class RequestGeometryBlocker ;
int m_requestGeometryBlockCounter = 0 ;
QRect m_blockedRequestGeometry ;
2016-06-16 11:30:32 +00:00
QString m_caption ;
2016-08-19 10:33:59 +00:00
bool m_compositingSetup = false ;
2015-03-04 08:21:10 +00:00
} ;
}
2015-10-05 15:35:53 +00:00
Q_DECLARE_METATYPE ( KWin : : ShellClient * )
2015-03-04 08:21:10 +00:00
# endif