2015-02-09 12:28:37 +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/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "wayland_server.h"
2019-09-24 08:48:08 +00:00
# include "x11client.h"
2016-04-07 07:24:17 +00:00
# include "platform.h"
2015-03-04 08:21:10 +00:00
# include "composite.h"
2017-11-16 20:48:19 +00:00
# include "idle_inhibition.h"
2015-02-20 13:54:21 +00:00
# include "screens.h"
2019-08-30 21:36:58 +00:00
# include "xdgshellclient.h"
2015-02-09 15:08:53 +00:00
# include "workspace.h"
2015-02-09 12:28:37 +00:00
2015-04-02 12:37:23 +00:00
// Client
# include <KWayland/Client/connection_thread.h>
2015-08-17 07:42:12 +00:00
# include <KWayland/Client/event_queue.h>
2015-04-02 12:37:23 +00:00
# include <KWayland/Client/registry.h>
2018-08-22 12:56:48 +00:00
# include <KWayland/Client/compositor.h>
2018-08-21 20:06:42 +00:00
# include <KWayland/Client/seat.h>
# include <KWayland/Client/datadevicemanager.h>
2015-11-10 10:35:00 +00:00
# include <KWayland/Client/shm_pool.h>
2015-05-18 09:23:45 +00:00
# include <KWayland/Client/surface.h>
2015-04-02 12:37:23 +00:00
// Server
2017-12-22 14:22:24 +00:00
# include <KWayland/Server/appmenu_interface.h>
2015-02-09 12:28:37 +00:00
# include <KWayland/Server/compositor_interface.h>
2015-04-30 07:22:31 +00:00
# include <KWayland/Server/datadevicemanager_interface.h>
2017-12-27 08:50:39 +00:00
# include <KWayland/Server/datasource_interface.h>
2015-02-09 12:28:37 +00:00
# include <KWayland/Server/display.h>
2015-09-01 09:30:30 +00:00
# include <KWayland/Server/dpms_interface.h>
2015-07-02 11:21:30 +00:00
# include <KWayland/Server/idle_interface.h>
2017-11-16 20:48:19 +00:00
# include <KWayland/Server/idleinhibit_interface.h>
2019-10-26 03:40:01 +00:00
# include <KWayland/Server/linuxdmabuf_v1_interface.h>
2015-02-09 12:28:37 +00:00
# include <KWayland/Server/output_interface.h>
2015-06-09 17:10:56 +00:00
# include <KWayland/Server/plasmashell_interface.h>
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
# include <KWayland/Server/plasmavirtualdesktop_interface.h>
2015-06-12 23:48:11 +00:00
# include <KWayland/Server/plasmawindowmanagement_interface.h>
2016-11-25 06:17:43 +00:00
# include <KWayland/Server/pointerconstraints_interface.h>
2016-10-27 07:10:08 +00:00
# include <KWayland/Server/pointergestures_interface.h>
2015-06-09 22:59:53 +00:00
# include <KWayland/Server/qtsurfaceextension_interface.h>
2015-02-25 08:35:42 +00:00
# include <KWayland/Server/seat_interface.h>
2015-12-17 10:14:54 +00:00
# include <KWayland/Server/server_decoration_interface.h>
2018-01-04 18:32:18 +00:00
# include <KWayland/Server/server_decoration_palette_interface.h>
2015-07-15 09:24:19 +00:00
# include <KWayland/Server/shadow_interface.h>
2016-03-21 15:44:07 +00:00
# include <KWayland/Server/subcompositor_interface.h>
2015-08-31 13:47:01 +00:00
# include <KWayland/Server/blur_interface.h>
2016-03-10 18:57:07 +00:00
# include <KWayland/Server/outputmanagement_interface.h>
# include <KWayland/Server/outputconfiguration_interface.h>
2019-01-01 17:37:18 +00:00
# include <KWayland/Server/xdgdecoration_interface.h>
2016-04-22 12:13:37 +00:00
# include <KWayland/Server/xdgshell_interface.h>
2017-10-13 09:32:02 +00:00
# include <KWayland/Server/xdgforeign_interface.h>
2018-05-18 13:16:13 +00:00
# include <KWayland/Server/xdgoutput_interface.h>
2019-06-21 14:02:50 +00:00
# include <KWayland/Server/keystate_interface.h>
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
# include <KWayland/Server/filtered_display.h>
// KF
# include <KServiceTypeTrader>
2015-02-09 12:28:37 +00:00
2015-05-18 09:23:45 +00:00
// Qt
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
# include <QCryptographicHash>
2018-11-07 11:49:09 +00:00
# include <QDir>
# include <QFileInfo>
2015-08-17 07:42:12 +00:00
# include <QThread>
2015-05-18 09:23:45 +00:00
# include <QWindow>
2015-02-25 13:15:32 +00:00
// system
# include <sys/types.h>
# include <sys/socket.h>
2016-06-20 09:21:16 +00:00
# include <unistd.h>
2015-02-25 13:15:32 +00:00
2015-11-05 13:09:23 +00:00
//screenlocker
# include <KScreenLocker/KsldApp>
2015-02-09 12:28:37 +00:00
using namespace KWayland : : Server ;
namespace KWin
{
KWIN_SINGLETON_FACTORY ( WaylandServer )
WaylandServer : : WaylandServer ( QObject * parent )
: QObject ( parent )
{
2015-09-01 09:30:30 +00:00
qRegisterMetaType < KWayland : : Server : : OutputInterface : : DpmsMode > ( ) ;
2015-02-09 12:28:37 +00:00
}
2015-11-10 13:38:45 +00:00
WaylandServer : : ~ WaylandServer ( )
{
destroyInputMethodConnection ( ) ;
}
2015-11-10 07:52:40 +00:00
void WaylandServer : : destroyInternalConnection ( )
2015-08-17 07:42:12 +00:00
{
2016-02-02 11:00:12 +00:00
emit terminatingInternalClientConnection ( ) ;
2015-08-17 07:42:12 +00:00
if ( m_internalConnection . client ) {
2017-07-08 13:21:16 +00:00
// delete all connections hold by plugins like e.g. widget style
const auto connections = KWayland : : Client : : ConnectionThread : : connections ( ) ;
for ( auto c : connections ) {
if ( c = = m_internalConnection . client ) {
continue ;
}
emit c - > connectionDied ( ) ;
}
2015-11-10 10:35:00 +00:00
delete m_internalConnection . registry ;
2018-08-22 12:56:48 +00:00
delete m_internalConnection . compositor ;
2018-08-21 20:06:42 +00:00
delete m_internalConnection . seat ;
delete m_internalConnection . ddm ;
2015-11-10 10:35:00 +00:00
delete m_internalConnection . shm ;
2015-10-22 08:07:02 +00:00
dispatch ( ) ;
2015-08-17 07:42:12 +00:00
m_internalConnection . client - > deleteLater ( ) ;
m_internalConnection . clientThread - > quit ( ) ;
m_internalConnection . clientThread - > wait ( ) ;
2015-11-10 10:43:30 +00:00
delete m_internalConnection . clientThread ;
2015-11-10 07:52:40 +00:00
m_internalConnection . client = nullptr ;
2015-11-10 13:27:43 +00:00
m_internalConnection . server - > destroy ( ) ;
2016-06-14 14:42:52 +00:00
m_internalConnection . server = nullptr ;
2015-08-17 07:42:12 +00:00
}
}
2015-02-09 12:28:37 +00:00
2015-11-18 09:29:10 +00:00
void WaylandServer : : terminateClientConnections ( )
{
destroyInternalConnection ( ) ;
destroyInputMethodConnection ( ) ;
2016-04-26 10:47:02 +00:00
if ( m_display ) {
const auto connections = m_display - > connections ( ) ;
for ( auto it = connections . begin ( ) ; it ! = connections . end ( ) ; + + it ) {
( * it ) - > destroy ( ) ;
}
2015-11-18 09:29:10 +00:00
}
}
2016-04-22 12:13:37 +00:00
template < class T >
void WaylandServer : : createSurface ( T * surface )
{
if ( ! Workspace : : self ( ) ) {
// it's possible that a Surface gets created before Workspace is created
return ;
}
if ( surface - > client ( ) = = m_xwayland . client ) {
// skip Xwayland clients, those are created using standard X11 way
return ;
}
if ( surface - > client ( ) = = m_screenLockerClientConnection ) {
ScreenLocker : : KSldApp : : self ( ) - > lockScreenShown ( ) ;
}
2019-08-30 21:36:58 +00:00
XdgShellClient * client = new XdgShellClient ( surface ) ;
2019-01-30 00:59:22 +00:00
if ( ServerSideDecorationInterface * deco = ServerSideDecorationInterface : : get ( surface - > surface ( ) ) ) {
client - > installServerSideDecoration ( deco ) ;
}
2017-02-07 18:18:18 +00:00
auto it = std : : find_if ( m_plasmaShellSurfaces . begin ( ) , m_plasmaShellSurfaces . end ( ) ,
[ client ] ( PlasmaShellSurfaceInterface * surface ) {
return client - > surface ( ) = = surface - > surface ( ) ;
}
) ;
if ( it ! = m_plasmaShellSurfaces . end ( ) ) {
client - > installPlasmaShellSurface ( * it ) ;
m_plasmaShellSurfaces . erase ( it ) ;
}
2017-12-22 14:22:24 +00:00
if ( auto menu = m_appMenuManager - > appMenuForSurface ( surface - > surface ( ) ) ) {
client - > installAppMenu ( menu ) ;
}
2018-01-04 18:32:18 +00:00
if ( auto palette = m_paletteManager - > paletteForSurface ( surface - > surface ( ) ) ) {
client - > installPalette ( palette ) ;
}
2019-08-26 07:44:04 +00:00
m_clients < < client ;
2016-04-22 12:13:37 +00:00
if ( client - > readyForPainting ( ) ) {
emit shellClientAdded ( client ) ;
} else {
2019-08-30 21:36:58 +00:00
connect ( client , & XdgShellClient : : windowShown , this , & WaylandServer : : shellClientShown ) ;
2016-04-22 12:13:37 +00:00
}
2017-10-13 09:32:02 +00:00
//not directly connected as the connection is tied to client instead of this
2017-10-16 15:17:15 +00:00
connect ( m_XdgForeign , & KWayland : : Server : : XdgForeignInterface : : transientChanged , client , [ this ] ( KWayland : : Server : : SurfaceInterface * child ) {
2017-10-13 09:32:02 +00:00
emit foreignTransientChanged ( child ) ;
} ) ;
2016-04-22 12:13:37 +00:00
}
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
class KWinDisplay : public KWayland : : Server : : FilteredDisplay
{
public :
KWinDisplay ( QObject * parent )
: KWayland : : Server : : FilteredDisplay ( parent )
{ }
static QByteArray sha256 ( const QString & fileName )
{
QFile f ( fileName ) ;
if ( f . open ( QFile : : ReadOnly ) ) {
QCryptographicHash hash ( QCryptographicHash : : Sha256 ) ;
if ( hash . addData ( & f ) ) {
return hash . result ( ) ;
}
}
return QByteArray ( ) ;
}
bool isTrustedOrigin ( KWayland : : Server : : ClientConnection * client ) const {
2019-11-06 13:39:58 +00:00
const auto fullPathSha = sha256 ( client - > executablePath ( ) ) ;
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
const auto localSha = sha256 ( QLatin1String ( " /proc/ " ) + QString : : number ( client - > processId ( ) ) + QLatin1String ( " /exe " ) ) ;
const bool trusted = ! localSha . isEmpty ( ) & & fullPathSha = = localSha ;
if ( ! trusted ) {
qCWarning ( KWIN_CORE ) < < " Could not trust " < < client - > executablePath ( ) < < " sha " < < localSha < < fullPathSha ;
}
return trusted ;
}
QStringList fetchRequestedInterfaces ( KWayland : : Server : : ClientConnection * client ) const {
const auto serviceQuery = QStringLiteral ( " exist Exec and exist [X-KDE-Wayland-Interfaces] and '%1' =~ Exec " ) . arg ( client - > executablePath ( ) ) ;
const auto servicesFound = KServiceTypeTrader : : self ( ) - > query ( QStringLiteral ( " Application " ) , serviceQuery ) ;
if ( servicesFound . isEmpty ( ) ) {
2019-10-10 14:34:44 +00:00
qCDebug ( KWIN_CORE ) < < " Could not find the desktop file for " < < client - > executablePath ( ) ;
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
return { } ;
}
2019-10-10 14:34:44 +00:00
const auto interfaces = servicesFound . first ( ) - > property ( " X-KDE-Wayland-Interfaces " ) . toStringList ( ) ;
qCDebug ( KWIN_CORE ) < < " Interfaces for " < < client - > executablePath ( ) < < interfaces ;
return interfaces ;
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
}
QSet < QByteArray > interfacesBlackList = { " org_kde_kwin_remote_access_manager " , " org_kde_plasma_window_management " , " org_kde_kwin_fake_input " , " org_kde_kwin_keystate " } ;
bool allowInterface ( KWayland : : Server : : ClientConnection * client , const QByteArray & interfaceName ) override {
if ( client - > processId ( ) = = getpid ( ) ) {
return true ;
}
if ( ! interfacesBlackList . contains ( interfaceName ) ) {
return true ;
}
if ( client - > executablePath ( ) . isEmpty ( ) ) {
qCWarning ( KWIN_CORE ) < < " Could not identify process with pid " < < client - > processId ( ) ;
return false ;
}
{
auto requestedInterfaces = client - > property ( " requestedInterfaces " ) ;
if ( requestedInterfaces . isNull ( ) ) {
requestedInterfaces = fetchRequestedInterfaces ( client ) ;
client - > setProperty ( " requestedInterfaces " , requestedInterfaces ) ;
}
if ( ! requestedInterfaces . toStringList ( ) . contains ( QString : : fromUtf8 ( interfaceName ) ) ) {
2019-09-05 14:47:13 +00:00
qCWarning ( KWIN_CORE ) < < " Did not grant the interface " < < interfaceName < < " to " < < client - > executablePath ( ) < < " . Please request it under X-KDE-Wayland-Interfaces " ;
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
return false ;
}
}
{
auto trustedOrigin = client - > property ( " isPrivileged " ) ;
if ( trustedOrigin . isNull ( ) ) {
trustedOrigin = isTrustedOrigin ( client ) ;
client - > setProperty ( " isPrivileged " , trustedOrigin ) ;
}
if ( ! trustedOrigin . toBool ( ) ) {
return false ;
}
}
qCDebug ( KWIN_CORE ) < < " authorized " < < client - > executablePath ( ) < < interfaceName ;
return true ;
}
} ;
2020-03-17 05:48:05 +00:00
bool WaylandServer : : init ( const QByteArray & socketName , InitializationFlags flags )
2015-02-09 12:28:37 +00:00
{
2015-11-05 13:09:23 +00:00
m_initFlags = flags ;
Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.
Reviewers: #plasma, #kwin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22571
2019-07-12 15:27:32 +00:00
m_display = new KWinDisplay ( this ) ;
2015-02-09 12:28:37 +00:00
if ( ! socketName . isNull ( ) & & ! socketName . isEmpty ( ) ) {
m_display - > setSocketName ( QString : : fromUtf8 ( socketName ) ) ;
2019-01-25 12:04:14 +00:00
} else {
m_display - > setAutomaticSocketNaming ( true ) ;
2015-02-09 12:28:37 +00:00
}
m_display - > start ( ) ;
2016-07-04 07:09:03 +00:00
if ( ! m_display - > isRunning ( ) ) {
return false ;
}
2015-02-09 12:28:37 +00:00
m_compositor = m_display - > createCompositor ( m_display ) ;
m_compositor - > create ( ) ;
2015-02-09 15:08:53 +00:00
connect ( m_compositor , & CompositorInterface : : surfaceCreated , this ,
[ this ] ( SurfaceInterface * surface ) {
// check whether we have a Toplevel with the Surface's id
Workspace * ws = Workspace : : self ( ) ;
if ( ! ws ) {
// it's possible that a Surface gets created before Workspace is created
return ;
}
2015-04-30 07:23:27 +00:00
if ( surface - > client ( ) ! = xWaylandConnection ( ) ) {
// setting surface is only relevat for Xwayland clients
return ;
}
2015-02-09 15:08:53 +00:00
auto check = [ surface ] ( const Toplevel * t ) {
return t - > surfaceId ( ) = = surface - > id ( ) ;
} ;
if ( Toplevel * t = ws - > findToplevel ( check ) ) {
t - > setSurface ( surface ) ;
}
}
) ;
2018-09-14 11:04:33 +00:00
2020-03-17 14:21:35 +00:00
m_tabletManager = m_display - > createTabletManagerInterface ( m_display ) ;
2018-09-14 11:04:33 +00:00
m_xdgShell = m_display - > createXdgShell ( XdgShellInterfaceVersion : : Stable , m_display ) ;
m_xdgShell - > create ( ) ;
connect ( m_xdgShell , & XdgShellInterface : : surfaceCreated , this , & WaylandServer : : createSurface < XdgShellSurfaceInterface > ) ;
connect ( m_xdgShell , & XdgShellInterface : : xdgPopupCreated , this , & WaylandServer : : createSurface < XdgShellPopupInterface > ) ;
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
2019-01-01 17:37:18 +00:00
m_xdgDecorationManager = m_display - > createXdgDecorationManager ( m_xdgShell , m_display ) ;
m_xdgDecorationManager - > create ( ) ;
connect ( m_xdgDecorationManager , & XdgDecorationManagerInterface : : xdgDecorationInterfaceCreated , this , [ this ] ( XdgDecorationInterface * deco ) {
2020-03-04 07:55:26 +00:00
if ( XdgShellClient * client = findXdgShellClient ( deco - > surface ( ) - > surface ( ) ) ) {
2019-01-01 17:37:18 +00:00
client - > installXdgDecoration ( deco ) ;
}
} ) ;
2015-02-09 12:28:37 +00:00
m_display - > createShm ( ) ;
2015-02-25 08:35:42 +00:00
m_seat = m_display - > createSeat ( m_display ) ;
m_seat - > create ( ) ;
2016-10-27 07:10:08 +00:00
m_display - > createPointerGestures ( PointerGesturesInterfaceVersion : : UnstableV1 , m_display ) - > create ( ) ;
2016-11-25 06:17:43 +00:00
m_display - > createPointerConstraints ( PointerConstraintsInterfaceVersion : : UnstableV1 , m_display ) - > create ( ) ;
2018-08-21 20:06:42 +00:00
m_dataDeviceManager = m_display - > createDataDeviceManager ( m_display ) ;
m_dataDeviceManager - > create ( ) ;
2017-12-29 17:29:19 +00:00
m_idle = m_display - > createIdle ( m_display ) ;
m_idle - > create ( ) ;
auto idleInhibition = new IdleInhibition ( m_idle ) ;
2020-03-04 07:55:26 +00:00
connect ( this , & WaylandServer : : shellClientAdded , idleInhibition , & IdleInhibition : : registerClient ) ;
2017-11-16 20:48:19 +00:00
m_display - > createIdleInhibitManager ( IdleInhibitManagerInterfaceVersion : : UnstableV1 , m_display ) - > create ( ) ;
2015-06-09 17:10:56 +00:00
m_plasmaShell = m_display - > createPlasmaShell ( m_display ) ;
m_plasmaShell - > create ( ) ;
connect ( m_plasmaShell , & PlasmaShellInterface : : surfaceCreated ,
[ this ] ( PlasmaShellSurfaceInterface * surface ) {
2020-03-04 07:55:26 +00:00
if ( XdgShellClient * client = findXdgShellClient ( surface - > surface ( ) ) ) {
2015-06-09 17:10:56 +00:00
client - > installPlasmaShellSurface ( surface ) ;
2017-02-07 18:18:18 +00:00
} else {
m_plasmaShellSurfaces < < surface ;
connect ( surface , & QObject : : destroyed , this ,
[ this , surface ] {
m_plasmaShellSurfaces . removeOne ( surface ) ;
}
) ;
2015-06-09 17:10:56 +00:00
}
}
) ;
2017-12-22 14:22:24 +00:00
m_appMenuManager = m_display - > createAppMenuManagerInterface ( m_display ) ;
m_appMenuManager - > create ( ) ;
connect ( m_appMenuManager , & AppMenuManagerInterface : : appMenuCreated ,
[ this ] ( AppMenuInterface * appMenu ) {
2020-03-04 07:55:26 +00:00
if ( XdgShellClient * client = findXdgShellClient ( appMenu - > surface ( ) ) ) {
2017-12-22 14:22:24 +00:00
client - > installAppMenu ( appMenu ) ;
}
}
) ;
2018-01-04 18:32:18 +00:00
m_paletteManager = m_display - > createServerSideDecorationPaletteManager ( m_display ) ;
m_paletteManager - > create ( ) ;
connect ( m_paletteManager , & ServerSideDecorationPaletteManagerInterface : : paletteCreated ,
[ this ] ( ServerSideDecorationPaletteInterface * palette ) {
2020-03-04 07:55:26 +00:00
if ( XdgShellClient * client = findXdgShellClient ( palette - > surface ( ) ) ) {
2018-01-04 18:32:18 +00:00
client - > installPalette ( palette ) ;
}
}
) ;
2017-12-22 14:22:24 +00:00
2015-06-12 23:48:11 +00:00
m_windowManagement = m_display - > createPlasmaWindowManagement ( m_display ) ;
m_windowManagement - > create ( ) ;
m_windowManagement - > setShowingDesktopState ( PlasmaWindowManagementInterface : : ShowingDesktopState : : Disabled ) ;
connect ( m_windowManagement , & PlasmaWindowManagementInterface : : requestChangeShowingDesktop , this ,
[ ] ( PlasmaWindowManagementInterface : : ShowingDesktopState state ) {
if ( ! workspace ( ) ) {
return ;
}
bool set = false ;
switch ( state ) {
case PlasmaWindowManagementInterface : : ShowingDesktopState : : Disabled :
set = false ;
break ;
case PlasmaWindowManagementInterface : : ShowingDesktopState : : Enabled :
set = true ;
break ;
default :
Q_UNREACHABLE ( ) ;
break ;
}
if ( set = = workspace ( ) - > showingDesktop ( ) ) {
return ;
}
workspace ( ) - > setShowingDesktop ( set ) ;
}
) ;
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
m_virtualDesktopManagement = m_display - > createPlasmaVirtualDesktopManagement ( m_display ) ;
m_virtualDesktopManagement - > create ( ) ;
m_windowManagement - > setPlasmaVirtualDesktopManagementInterface ( m_virtualDesktopManagement ) ;
2015-07-15 09:24:19 +00:00
auto shadowManager = m_display - > createShadowManager ( m_display ) ;
shadowManager - > create ( ) ;
2015-09-01 09:30:30 +00:00
m_display - > createDpmsManager ( m_display ) - > create ( ) ;
2015-12-17 10:14:54 +00:00
m_decorationManager = m_display - > createServerSideDecorationManager ( m_display ) ;
connect ( m_decorationManager , & ServerSideDecorationManagerInterface : : decorationCreated , this ,
[ this ] ( ServerSideDecorationInterface * deco ) {
2020-03-04 07:55:26 +00:00
if ( XdgShellClient * c = findXdgShellClient ( deco - > surface ( ) ) ) {
2015-12-17 10:14:54 +00:00
c - > installServerSideDecoration ( deco ) ;
}
2018-01-18 20:17:15 +00:00
connect ( deco , & ServerSideDecorationInterface : : modeRequested , this ,
2020-03-15 19:59:29 +00:00
[ deco ] ( ServerSideDecorationManagerInterface : : Mode mode ) {
2018-01-18 20:17:15 +00:00
// always acknowledge the requested mode
deco - > setMode ( mode ) ;
}
) ;
2015-12-17 10:14:54 +00:00
}
) ;
m_decorationManager - > create ( ) ;
2016-03-10 18:57:07 +00:00
m_outputManagement = m_display - > createOutputManagement ( m_display ) ;
connect ( m_outputManagement , & OutputManagementInterface : : configurationChangeRequested ,
2020-03-15 19:59:29 +00:00
this , [ ] ( KWayland : : Server : : OutputConfigurationInterface * config ) {
2019-08-28 18:54:37 +00:00
kwinApp ( ) - > platform ( ) - > requestOutputsChange ( config ) ;
2016-03-10 18:57:07 +00:00
} ) ;
2016-04-27 19:03:47 +00:00
m_outputManagement - > create ( ) ;
2016-03-21 15:44:07 +00:00
2018-05-18 13:16:13 +00:00
m_xdgOutputManager = m_display - > createXdgOutputManager ( m_display ) ;
m_xdgOutputManager - > create ( ) ;
2016-03-21 15:44:07 +00:00
m_display - > createSubCompositor ( m_display ) - > create ( ) ;
2016-07-04 07:09:03 +00:00
2017-10-13 09:32:02 +00:00
m_XdgForeign = m_display - > createXdgForeignInterface ( m_display ) ;
m_XdgForeign - > create ( ) ;
2019-06-21 14:02:50 +00:00
m_keyState = m_display - > createKeyStateInterface ( m_display ) ;
m_keyState - > create ( ) ;
2016-07-04 07:09:03 +00:00
return true ;
2015-06-12 23:48:11 +00:00
}
2019-10-26 03:40:01 +00:00
KWayland : : Server : : LinuxDmabufUnstableV1Interface * WaylandServer : : linuxDmabuf ( )
{
if ( ! m_linuxDmabuf ) {
m_linuxDmabuf = m_display - > createLinuxDmabufInterface ( m_display ) ;
m_linuxDmabuf - > create ( ) ;
}
return m_linuxDmabuf ;
}
2017-10-13 09:32:02 +00:00
SurfaceInterface * WaylandServer : : findForeignTransientForSurface ( SurfaceInterface * surface )
{
return m_XdgForeign - > transientFor ( surface ) ;
}
2016-06-07 09:43:56 +00:00
void WaylandServer : : shellClientShown ( Toplevel * t )
{
2019-08-30 21:36:58 +00:00
XdgShellClient * c = dynamic_cast < XdgShellClient * > ( t ) ;
2016-06-07 09:43:56 +00:00
if ( ! c ) {
2019-08-30 21:36:58 +00:00
qCWarning ( KWIN_CORE ) < < " Failed to cast a Toplevel which is supposed to be a XdgShellClient to XdgShellClient " ;
2016-06-07 09:43:56 +00:00
return ;
}
2019-08-30 21:36:58 +00:00
disconnect ( c , & XdgShellClient : : windowShown , this , & WaylandServer : : shellClientShown ) ;
2016-06-07 09:43:56 +00:00
emit shellClientAdded ( c ) ;
}
2015-06-12 23:48:11 +00:00
void WaylandServer : : initWorkspace ( )
{
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
VirtualDesktopManager : : self ( ) - > setVirtualDesktopManagement ( m_virtualDesktopManagement ) ;
2015-06-12 23:48:11 +00:00
if ( m_windowManagement ) {
connect ( workspace ( ) , & Workspace : : showingDesktopChanged , this ,
[ this ] ( bool set ) {
using namespace KWayland : : Server ;
m_windowManagement - > setShowingDesktopState ( set ?
PlasmaWindowManagementInterface : : ShowingDesktopState : : Enabled :
PlasmaWindowManagementInterface : : ShowingDesktopState : : Disabled
) ;
}
) ;
}
2015-11-06 11:21:34 +00:00
2016-04-25 06:51:33 +00:00
if ( hasScreenLockerIntegration ( ) ) {
2017-09-30 14:33:45 +00:00
if ( m_internalConnection . interfacesAnnounced ) {
initScreenLocker ( ) ;
} else {
connect ( m_internalConnection . registry , & KWayland : : Client : : Registry : : interfacesAnnounced , this , & WaylandServer : : initScreenLocker ) ;
}
} else {
emit initialized ( ) ;
}
}
2015-11-06 14:08:13 +00:00
2017-09-30 14:33:45 +00:00
void WaylandServer : : initScreenLocker ( )
{
2020-03-15 21:40:56 +00:00
auto * screenLockerApp = ScreenLocker : : KSldApp : : self ( ) ;
2017-09-30 14:33:45 +00:00
ScreenLocker : : KSldApp : : self ( ) - > setGreeterEnvironment ( kwinApp ( ) - > processStartupEnvironment ( ) ) ;
ScreenLocker : : KSldApp : : self ( ) - > initialize ( ) ;
2020-03-15 21:40:56 +00:00
connect ( ScreenLocker : : KSldApp : : self ( ) , & ScreenLocker : : KSldApp : : aboutToLock , this ,
[ this , screenLockerApp ] ( ) {
if ( m_screenLockerClientConnection ) {
// Already sent data to KScreenLocker.
return ;
}
int clientFd = createScreenLockerConnection ( ) ;
if ( clientFd < 0 ) {
return ;
}
ScreenLocker : : KSldApp : : self ( ) - > setWaylandFd ( clientFd ) ;
for ( auto * seat : m_display - > seats ( ) ) {
connect ( seat , & KWayland : : Server : : SeatInterface : : timestampChanged ,
screenLockerApp , & ScreenLocker : : KSldApp : : userActivity ) ;
}
2017-09-30 14:33:45 +00:00
}
) ;
2015-11-06 14:08:13 +00:00
2017-09-30 14:33:45 +00:00
connect ( ScreenLocker : : KSldApp : : self ( ) , & ScreenLocker : : KSldApp : : unlocked , this ,
2020-03-15 21:40:56 +00:00
[ this , screenLockerApp ] ( ) {
if ( m_screenLockerClientConnection ) {
m_screenLockerClientConnection - > destroy ( ) ;
delete m_screenLockerClientConnection ;
m_screenLockerClientConnection = nullptr ;
}
for ( auto * seat : m_display - > seats ( ) ) {
disconnect ( seat , & KWayland : : Server : : SeatInterface : : timestampChanged ,
screenLockerApp , & ScreenLocker : : KSldApp : : userActivity ) ;
}
ScreenLocker : : KSldApp : : self ( ) - > setWaylandFd ( - 1 ) ;
2016-04-25 06:51:33 +00:00
}
2017-09-30 14:33:45 +00:00
) ;
2020-03-17 05:48:05 +00:00
if ( m_initFlags . testFlag ( InitializationFlag : : LockScreen ) ) {
2017-09-30 14:33:45 +00:00
ScreenLocker : : KSldApp : : self ( ) - > lock ( ScreenLocker : : EstablishLock : : Immediate ) ;
2015-11-05 13:09:23 +00:00
}
2016-08-16 07:26:17 +00:00
emit initialized ( ) ;
2015-02-20 13:54:21 +00:00
}
2015-02-09 12:28:37 +00:00
2016-12-03 13:54:32 +00:00
WaylandServer : : SocketPairConnection WaylandServer : : createConnection ( )
2015-02-25 13:15:32 +00:00
{
2016-12-03 13:54:32 +00:00
SocketPairConnection ret ;
2015-02-25 13:15:32 +00:00
int sx [ 2 ] ;
if ( socketpair ( AF_UNIX , SOCK_STREAM | SOCK_CLOEXEC , 0 , sx ) < 0 ) {
qCWarning ( KWIN_CORE ) < < " Could not create socket " ;
2016-12-03 13:54:32 +00:00
return ret ;
}
ret . connection = m_display - > createClient ( sx [ 0 ] ) ;
ret . fd = sx [ 1 ] ;
return ret ;
}
2020-03-15 21:40:56 +00:00
int WaylandServer : : createScreenLockerConnection ( )
{
const auto socket = createConnection ( ) ;
if ( ! socket . connection ) {
return - 1 ;
}
m_screenLockerClientConnection = socket . connection ;
connect ( m_screenLockerClientConnection , & KWayland : : Server : : ClientConnection : : disconnected ,
this , [ this ] { m_screenLockerClientConnection = nullptr ; } ) ;
return socket . fd ;
}
2016-12-03 13:54:32 +00:00
int WaylandServer : : createXWaylandConnection ( )
{
const auto socket = createConnection ( ) ;
if ( ! socket . connection ) {
2015-02-25 13:15:32 +00:00
return - 1 ;
}
2016-12-03 13:54:32 +00:00
m_xwayland . client = socket . connection ;
2015-11-10 13:21:48 +00:00
m_xwayland . destroyConnection = connect ( m_xwayland . client , & KWayland : : Server : : ClientConnection : : disconnected , this ,
2015-04-21 07:21:49 +00:00
[ ] {
qFatal ( " Xwayland Connection died " ) ;
}
) ;
2016-12-03 13:54:32 +00:00
return socket . fd ;
2015-02-25 13:15:32 +00:00
}
2015-11-10 13:21:48 +00:00
void WaylandServer : : destroyXWaylandConnection ( )
{
if ( ! m_xwayland . client ) {
return ;
}
disconnect ( m_xwayland . destroyConnection ) ;
m_xwayland . client - > destroy ( ) ;
m_xwayland . client = nullptr ;
}
2015-06-13 02:06:12 +00:00
int WaylandServer : : createInputMethodConnection ( )
{
2016-12-03 13:54:32 +00:00
const auto socket = createConnection ( ) ;
if ( ! socket . connection ) {
2015-06-13 02:06:12 +00:00
return - 1 ;
}
2016-12-03 13:54:32 +00:00
m_inputMethodServerConnection = socket . connection ;
return socket . fd ;
2015-06-13 02:06:12 +00:00
}
2015-11-10 13:38:45 +00:00
void WaylandServer : : destroyInputMethodConnection ( )
{
if ( ! m_inputMethodServerConnection ) {
return ;
}
m_inputMethodServerConnection - > destroy ( ) ;
m_inputMethodServerConnection = nullptr ;
}
2015-04-02 12:37:23 +00:00
void WaylandServer : : createInternalConnection ( )
{
2016-12-03 13:54:32 +00:00
const auto socket = createConnection ( ) ;
if ( ! socket . connection ) {
2015-04-02 12:37:23 +00:00
return ;
}
2016-12-03 13:54:32 +00:00
m_internalConnection . server = socket . connection ;
2015-04-02 12:37:23 +00:00
using namespace KWayland : : Client ;
2015-08-17 07:42:12 +00:00
m_internalConnection . client = new ConnectionThread ( ) ;
2016-12-03 13:54:32 +00:00
m_internalConnection . client - > setSocketFd ( socket . fd ) ;
2015-08-17 07:42:12 +00:00
m_internalConnection . clientThread = new QThread ;
m_internalConnection . client - > moveToThread ( m_internalConnection . clientThread ) ;
m_internalConnection . clientThread - > start ( ) ;
2015-04-02 12:37:23 +00:00
connect ( m_internalConnection . client , & ConnectionThread : : connected , this ,
[ this ] {
2015-08-17 07:42:12 +00:00
Registry * registry = new Registry ( this ) ;
2020-04-15 23:58:05 +00:00
EventQueue * eventQueue = new EventQueue ( registry ) ;
2015-08-17 07:42:12 +00:00
eventQueue - > setup ( m_internalConnection . client ) ;
registry - > setEventQueue ( eventQueue ) ;
2015-04-02 12:37:23 +00:00
registry - > create ( m_internalConnection . client ) ;
2015-08-14 07:28:46 +00:00
m_internalConnection . registry = registry ;
2015-04-02 12:37:23 +00:00
connect ( registry , & Registry : : shmAnnounced , this ,
2015-08-14 07:28:46 +00:00
[ this ] ( quint32 name , quint32 version ) {
2015-08-17 07:42:12 +00:00
m_internalConnection . shm = m_internalConnection . registry - > createShmPool ( name , version , this ) ;
2015-04-02 12:37:23 +00:00
}
) ;
2017-09-30 14:33:45 +00:00
connect ( registry , & Registry : : interfacesAnnounced , this ,
2018-08-21 20:06:42 +00:00
[ this , registry ] {
2017-09-30 14:33:45 +00:00
m_internalConnection . interfacesAnnounced = true ;
2018-08-21 20:06:42 +00:00
2018-08-22 12:56:48 +00:00
const auto compInterface = registry - > interface ( Registry : : Interface : : Compositor ) ;
if ( compInterface . name ! = 0 ) {
m_internalConnection . compositor = registry - > createCompositor ( compInterface . name , compInterface . version , this ) ;
}
2018-08-21 20:06:42 +00:00
const auto seatInterface = registry - > interface ( Registry : : Interface : : Seat ) ;
if ( seatInterface . name ! = 0 ) {
m_internalConnection . seat = registry - > createSeat ( seatInterface . name , seatInterface . version , this ) ;
}
const auto ddmInterface = registry - > interface ( Registry : : Interface : : DataDeviceManager ) ;
if ( ddmInterface . name ! = 0 ) {
m_internalConnection . ddm = registry - > createDataDeviceManager ( ddmInterface . name , ddmInterface . version , this ) ;
}
2017-09-30 14:33:45 +00:00
}
) ;
2015-04-02 12:37:23 +00:00
registry - > setup ( ) ;
}
) ;
m_internalConnection . client - > initConnection ( ) ;
}
2020-03-04 07:55:26 +00:00
void WaylandServer : : removeClient ( AbstractClient * c )
2015-03-04 08:21:10 +00:00
{
m_clients . removeAll ( c ) ;
emit shellClientRemoved ( c ) ;
}
2015-05-18 09:33:00 +00:00
void WaylandServer : : dispatch ( )
{
if ( ! m_display ) {
return ;
}
2015-08-18 06:15:00 +00:00
if ( m_internalConnection . server ) {
m_internalConnection . server - > flush ( ) ;
2015-05-18 09:33:00 +00:00
}
m_display - > dispatchEvents ( 0 ) ;
}
2020-03-04 07:55:26 +00:00
static AbstractClient * findClientInList ( const QList < AbstractClient * > & clients , quint32 id )
2015-05-18 12:51:40 +00:00
{
2015-05-21 08:35:03 +00:00
auto it = std : : find_if ( clients . begin ( ) , clients . end ( ) ,
2020-03-04 07:55:26 +00:00
[ id ] ( AbstractClient * c ) {
2015-05-18 12:51:40 +00:00
return c - > windowId ( ) = = id ;
}
) ;
2015-05-21 08:35:03 +00:00
if ( it = = clients . end ( ) ) {
2015-05-18 12:51:40 +00:00
return nullptr ;
}
return * it ;
}
2020-03-04 07:55:26 +00:00
static AbstractClient * findClientInList ( const QList < AbstractClient * > & clients , KWayland : : Server : : SurfaceInterface * surface )
2015-06-09 17:10:56 +00:00
{
auto it = std : : find_if ( clients . begin ( ) , clients . end ( ) ,
2020-03-04 07:55:26 +00:00
[ surface ] ( AbstractClient * c ) {
2015-06-09 17:10:56 +00:00
return c - > surface ( ) = = surface ;
}
) ;
if ( it = = clients . end ( ) ) {
return nullptr ;
}
return * it ;
}
2020-03-04 07:55:26 +00:00
AbstractClient * WaylandServer : : findClient ( quint32 id ) const
2015-05-21 08:35:03 +00:00
{
if ( id = = 0 ) {
return nullptr ;
}
2020-03-04 07:55:26 +00:00
if ( AbstractClient * c = findClientInList ( m_clients , id ) ) {
2015-05-21 08:35:03 +00:00
return c ;
}
return nullptr ;
}
2020-03-04 07:55:26 +00:00
AbstractClient * WaylandServer : : findClient ( SurfaceInterface * surface ) const
2015-06-09 17:10:56 +00:00
{
if ( ! surface ) {
return nullptr ;
}
2020-03-04 07:55:26 +00:00
if ( AbstractClient * c = findClientInList ( m_clients , surface ) ) {
2015-06-09 17:10:56 +00:00
return c ;
}
return nullptr ;
}
2020-03-04 07:55:26 +00:00
XdgShellClient * WaylandServer : : findXdgShellClient ( SurfaceInterface * surface ) const
2016-08-22 14:55:48 +00:00
{
2020-03-04 07:55:26 +00:00
return qobject_cast < XdgShellClient * > ( findClient ( surface ) ) ;
2016-08-22 14:55:48 +00:00
}
2015-05-21 07:59:45 +00:00
quint32 WaylandServer : : createWindowId ( SurfaceInterface * surface )
{
auto it = m_clientIds . constFind ( surface - > client ( ) ) ;
quint16 clientId = 0 ;
if ( it ! = m_clientIds . constEnd ( ) ) {
clientId = it . value ( ) ;
} else {
clientId = createClientId ( surface - > client ( ) ) ;
}
Q_ASSERT ( clientId ! = 0 ) ;
quint32 id = clientId ;
// TODO: this does not prevent that two surfaces of same client get same id
id = ( id < < 16 ) | ( surface - > id ( ) & 0xFFFF ) ;
if ( findClient ( id ) ) {
qCWarning ( KWIN_CORE ) < < " Invalid client windowId generated: " < < id ;
return 0 ;
}
return id ;
}
quint16 WaylandServer : : createClientId ( ClientConnection * c )
{
2020-03-17 14:32:20 +00:00
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
2020-03-15 19:59:29 +00:00
const QSet < unsigned short > ids ( m_clientIds . constBegin ( ) , m_clientIds . constEnd ( ) ) ;
2020-03-17 14:32:20 +00:00
# else
2020-03-17 14:43:50 +00:00
const auto ids = m_clientIds . values ( ) . toSet ( ) ;
2020-03-17 14:32:20 +00:00
# endif
2015-05-21 07:59:45 +00:00
quint16 id = 1 ;
if ( ! ids . isEmpty ( ) ) {
for ( quint16 i = ids . count ( ) + 1 ; i > = 1 ; i - - ) {
if ( ! ids . contains ( i ) ) {
id = i ;
break ;
}
}
}
Q_ASSERT ( ! ids . contains ( id ) ) ;
m_clientIds . insert ( c , id ) ;
connect ( c , & ClientConnection : : disconnected , this ,
[ this ] ( ClientConnection * c ) {
m_clientIds . remove ( c ) ;
}
) ;
return id ;
}
2015-11-16 10:19:38 +00:00
bool WaylandServer : : isScreenLocked ( ) const
{
2016-04-25 06:51:33 +00:00
if ( ! hasScreenLockerIntegration ( ) ) {
return false ;
}
2016-02-02 09:19:46 +00:00
return ScreenLocker : : KSldApp : : self ( ) - > lockState ( ) = = ScreenLocker : : KSldApp : : Locked | |
ScreenLocker : : KSldApp : : self ( ) - > lockState ( ) = = ScreenLocker : : KSldApp : : AcquiringLock ;
2015-11-16 10:19:38 +00:00
}
2016-04-25 06:51:33 +00:00
bool WaylandServer : : hasScreenLockerIntegration ( ) const
{
2020-03-17 05:48:05 +00:00
return ! m_initFlags . testFlag ( InitializationFlag : : NoLockScreenIntegration ) ;
2016-04-25 06:51:33 +00:00
}
2018-12-02 12:09:37 +00:00
bool WaylandServer : : hasGlobalShortcutSupport ( ) const
{
2020-03-17 05:48:05 +00:00
return ! m_initFlags . testFlag ( InitializationFlag : : NoGlobalShortcuts ) ;
2018-12-02 12:09:37 +00:00
}
2017-12-29 17:29:19 +00:00
void WaylandServer : : simulateUserActivity ( )
{
if ( m_idle ) {
m_idle - > simulateUserActivity ( ) ;
}
}
2019-06-21 14:02:50 +00:00
void WaylandServer : : updateKeyState ( KWin : : Xkb : : LEDs leds )
{
if ( ! m_keyState )
return ;
m_keyState - > setState ( KeyStateInterface : : Key : : CapsLock , leds & KWin : : Xkb : : LED : : CapsLock ? KeyStateInterface : : State : : Locked : KeyStateInterface : : State : : Unlocked ) ;
m_keyState - > setState ( KeyStateInterface : : Key : : NumLock , leds & KWin : : Xkb : : LED : : NumLock ? KeyStateInterface : : State : : Locked : KeyStateInterface : : State : : Unlocked ) ;
m_keyState - > setState ( KeyStateInterface : : Key : : ScrollLock , leds & KWin : : Xkb : : LED : : ScrollLock ? KeyStateInterface : : State : : Locked : KeyStateInterface : : State : : Unlocked ) ;
}
2015-02-09 12:28:37 +00:00
}