Welcome to Waylan Martin Gra ßlin mgraesslin@ke.org BlueSystems Akaemy 2015 26.07.2015
Agena 1 Architecture 2 Evolution of KWin 3 The kwin Project 4 What s next? Welcome to Waylan Martin Gra ßlin
Agena 1 Architecture 2 Evolution of KWin 3 The kwin Project 4 What s next? Welcome to Waylan Martin Gra ßlin
Architecture as presente last year Welcome to Waylan Martin Gra ßlin
Current architecture Welcome to Waylan Martin Gra ßlin
Backen plugins for ifferent platforms KWin internal Platform Abstraction Create OpenGL context an surface QPainter fallback for no OpenGL Output information Input event hanling Libinput If backen oesn t provie input, libinput library is use. Welcome to Waylan Martin Gra ßlin
Available backen plugins Winowe/Neste Platforms X11 (supports OpenGL, QPainter) Waylan (supports OpenGL, QPainter) Full Platforms DRM (supports OpenGL through GBM, QPainter) fbev (supports QPainter) Anroi hwcomposer/libhybris (supports OpenGL, input) This Presentation runs on the DRM platform! Welcome to Waylan Martin Gra ßlin
Architecture summary KWin is a Waylan server KWin supports wl shell clients both OpenGL an SHM KWin supports Xwaylan base clients KWin can rener on top of DRM/KMS KWin support input through libinput Neste KWin Waylan servers on X11/Waylan for easy testing Welcome to Waylan Martin Gra ßlin
Agena 1 Architecture 2 Evolution of KWin 3 The kwin Project 4 What s next? Welcome to Waylan Martin Gra ßlin
Simplifie KWin (Core) architecture before Waylan Welcome to Waylan Martin Gra ßlin
Simplifie KWin (Core) architecture as of toay Welcome to Waylan Martin Gra ßlin
How to start KWin Welcome to Waylan Martin Gra ßlin
Starting KWin as X11 application How to start X? KWin s startup is highly X11 epenent Qt s XCB plugin requires X11 in QApplication ctor Starting Xwaylan before KWin requires a running Waylan server Waylan server requires event loop Event loop requires QApplication Xwaylan requires wl rm KWin nees to move away from xcb QPA Welcome to Waylan Martin Gra ßlin
Is QtWaylan any better? New Startup First start Waylan server Create QApplication Startup Compositor/Scene Startup Xwaylan Wait for Xwaylan being starte Continue with X specific startup coe Welcome to Waylan Martin Gra ßlin
Similar problems as xcb QPA Rountrips are evil Requires Waylan server at QApplication startup Does rountrip to server in startup (blocks gui threa) Cannot create a QThrea before creating QApplication QtWaylan ispatches events while waiting for the rountrip Welcome to Waylan Martin Gra ßlin
Still many workarouns neee Blocking OpenGL context creation // HACK: create a QWinow in a threa to force QtWaylan to create the // client buffer integration. // this performs an eglinitialize which woul block as it oes a rountrip // to the Waylan server in the main threa. // By moving into a threa we get the initialize without hitting the problem // This nees to be one before creating the Workspace as from insie // Workspace the angerous coe gets hit in the main threa QFutureWatcher<voi> *eglinitwatcher = new QFutureWatcher<voi>(this); eglinitwatcher->setfuture(qtconcurrent::run([] { QWinow w; w.setsurfacetype(qsurface::rasterglsurface); w.create(); })); Welcome to Waylan Martin Gra ßlin
More workarouns BypassWinowManagerHint neee for each Winow on X11 bool ApplicationWaylan::notify(QObject *o, QEvent *e) { if (QWinow *w = qobject_cast< QWinow* >(o)) { if (e->type() == QEvent::Show) { // on QtWaylan winows with X11BypassWinowManagerHint are not shown, // thus we nee to remove it. As the flag is interprete only before // the PlatformWinow is create we nee to estroy the winow first if (w->flags() & Qt::X11BypassWinowManagerHint) { w->setflags(w->flags() & ~Qt::X11BypassWinowManagerHint); w->estroy(); w->show(); return false; } } } return Application::notify(o, e); } Welcome to Waylan Martin Gra ßlin
Do we nee our own QPA plugin? Further issues Cannot share composite OpenGL context with QtQuick Cannot use threae QtQuick rener loop QtQuick on hwcomposer aborts Intercept all input insie KWin anyway Have coe to create X11 an Waylan winows Have coe to create OpenGL context Have coe to o low level event processing Welcome to Waylan Martin Gra ßlin
Agena 1 Architecture 2 Evolution of KWin 3 The kwin Project 4 What s next? Welcome to Waylan Martin Gra ßlin
I propose to rename kwin to kwin because it swallows all features (Kai-Uwe Broulik) Welcome to Waylan Martin Gra ßlin
Fixing the X11 security issues Generic issues on X11 KGlobalAccel is a global key logger Screen lockers are not secure (see Blog post Why screen lockers on X11 cannot be secure ) All winows can eit all attributes of winows of foreign processes Winows can place themselves Winows can bypass Winow Managers Clients can warp pointer Clients can grab foreign winow content Welcome to Waylan Martin Gra ßlin
KWin nees more knowlege about the winows More control to the compositor KGlobalAccel move into KWin Screen Locking nees to move into KWin Nees to know which winows belong to virtual keyboar Nees to know which process is esktop shell Nees to know which process is screen shot application Nees to know which process hanles power management Nees to know the session splash screen Nees to authorize processes to access special interfaces Welcome to Waylan Martin Gra ßlin
Suggestions for the problems appreciate! It s tricky Don t uplicate coe Don t har epen on specific technology Everything shoul be flexible How to hanle e.g. a shell process crash Don t harm user experience (no UAC) What about ke? Welcome to Waylan Martin Gra ßlin
Agena 1 Architecture 2 Evolution of KWin 3 The kwin Project 4 What s next? Welcome to Waylan Martin Gra ßlin
XDG Shell So far only wl shell support wl shell is rather limite We make it useable with a Qt extension No support for Weston-emo clients No support for GTK+ clients XDG Shell uner heavy evelopment Unstable protocol mechanism GTK, Qt, Weston on real systems out of sync Nee to get our (Qt, Plasma) nees into the protocol Welcome to Waylan Martin Gra ßlin
Winow Decorations Issues with Qt eco Minimize button oes nothing No visible istinction between active/inactive state Cannot configure button orer Cannot a our own buttons It s not a goo client-sie eco solution, moels server sie Possible Solution 1 Implement a better plugin base on KDecoration Maybe better Solution? Disable Qt eco at runtime Rea Qt::FramelessWinowHint in Extene surface Create server eco for all Qt Winows Welcome to Waylan Martin Gra ßlin
Improvements in KWin Lot s of features still missing Geometry hanling missing Winow types mostly missing Interaction with Plasma nees improvements Lots of small bugs here an there Winow Rules missing Please help us! Plasma on Waylan on too.ke.org Welcome to Waylan Martin Gra ßlin
KWinowSystem Moele aroun X11 Everywhere global Winow I Mixes API for own an foreign winows Platform abstraction is not a solution to support Waylan Iea Create a new API exposing a QAbstractItemMoel which can be use by Task Managers. Welcome to Waylan Martin Gra ßlin
Polish, polish, polish Please Help! Starting KWin: kwin waylan xwaylan Starting Plasma: startplasmacompositor Welcome to Waylan Martin Gra ßlin
Tuesay is Waylan Day Lab 0.5w 10:30 Waylan an Powerevil an KScreen 11:30 Waylan an Plasma 15:00 Waylan an Applications Welcome to Waylan Martin Gra ßlin
What is KWaylan Client? Qt style convenient library for Waylan Allow to use Waylan APIs in a Qt way Not a complete wrapper of Waylan yet Can integrate with QtWaylan QPA Aitional KWin/Plasma specific Waylan interfaces Doesn t that uplicate QtWaylan? QtWaylan is a QPA plugin KWaylan is an API which coul be use to write a Waylan QPA plugin KWaylan is to QtWaylan, what KWinowSystem is to xcb QPA plugin Welcome to Waylan Martin Gra ßlin
Aitional Interfaces provie by KWaylan Alreay implemente org ke kwin shaow (e.g. Plasma panel shaow) org ke kwin ile (KF5IleTime) org ke kwin fake input (keconnect) org ke plasma shell org ke plasma winow management More to come, e.g. Blur an Backgroun contrast effect Highlight Winows Present Winows Slie Winows Welcome to Waylan Martin Gra ßlin
New Repository: kwaylan-integration New in Plasma 5.4 Plugin for KWinowSystem Plugin for KIleTime Place for any framework plugin which nees to epen on KWaylan Welcome to Waylan Martin Gra ßlin
What is KWaylan Server? The other sie Qt-style API to implement a Waylan server Wrapper for the core Waylan protocols Wrapper for the KWin/Plasma specific interfaces No renering! Implements lots of generic Waylan server functionality Welcome to Waylan Martin Gra ßlin
Builing a Waylan Server with KWaylan auto isplay = new KWaylan::Server::Display(this); isplay->start(); auto compositor = isplay->createcompositor(isplay); compositor->create(); auto shell = isplay->createshell(isplay); shell->create(); isplay->createshm(); auto seat = isplay->createseat(isplay); seat->create(); isplay->createdatadevicemanager(isplay)->create(); isplay->createile(isplay)->create(); auto plasmashell = isplay->createplasmashell(isplay); plasmashell->create(); auto qtextenesurface = isplay->createqtsurfaceextension(isplay); qtextenesurface->create(); auto winowmanagement = isplay->createplasmawinowmanagement(isplay); winowmanagement->create(); auto shaowmanager = isplay->createshaowmanager(isplay); shaowmanager->create(); Welcome to Waylan Martin Gra ßlin
Interacting with the server Example for a create object connect(m_plasmashell, &PlasmaShellInterface::surfaceCreate, [this] (PlasmaShellSurfaceInterface *surface) { if (ShellClient *client = finclient(surface->surface())) { client->installplasmashellsurface(surface); } } ); Welcome to Waylan Martin Gra ßlin
Interacting with the server Example for upating information in the server voi InputReirection::processPointerMotion(const QPointF &pos, uint32_t time) { // KWin internal hanling for pointer motion remove for reaability #if HAVE_WAYLAND if (auto seat = finseat()) { seat->settimestamp(time); seat->setpointerpos(pos); } #enif } Welcome to Waylan Martin Gra ßlin
Why not QtCompositor? Comparable to Client vs QPA Our own interfaces are no fit for integration into Qt QtCompositor has not seen a release yet Focus on QtQuick useless for our nees Lot s of things which just oesn t fit our usecases Welcome to Waylan Martin Gra ßlin