Welcome to Wayland Martin Gr alin mgraesslin@kde.org BlueSystems - - PowerPoint PPT Presentation

welcome to wayland
SMART_READER_LITE
LIVE PREVIEW

Welcome to Wayland Martin Gr alin mgraesslin@kde.org BlueSystems - - PowerPoint PPT Presentation

Welcome to Wayland Martin Gr alin mgraesslin@kde.org BlueSystems Akademy 2015 26.07.2015 Agenda default 1 Architecture 2 Evolution of KWin 3 The kwind Project 4 Whats next? Welcome to Wayland Martin Gr alin Agenda default


slide-1
SLIDE 1

Welcome to Wayland

Martin Gr¨ aßlin mgraesslin@kde.org BlueSystems

Akademy 2015

26.07.2015

slide-2
SLIDE 2

default

Agenda

1 Architecture 2 Evolution of KWin 3 The kwind Project 4 What’s next?

Welcome to Wayland — Martin Gr¨ aßlin

slide-3
SLIDE 3

default

Agenda

1 Architecture 2 Evolution of KWin 3 The kwind Project 4 What’s next?

Welcome to Wayland — Martin Gr¨ aßlin

slide-4
SLIDE 4

default

Architecture as presented last year

Welcome to Wayland — Martin Gr¨ aßlin

slide-5
SLIDE 5

default

Current architecture

Welcome to Wayland — Martin Gr¨ aßlin

slide-6
SLIDE 6

default

Backend plugins for different platforms

KWin internal Platform Abstraction Create OpenGL context and surface QPainter fallback for no OpenGL Output information Input event handling Libinput If backend doesn’t provide input, libinput library is used.

Welcome to Wayland — Martin Gr¨ aßlin

slide-7
SLIDE 7

default

Available backend plugins

Windowed/Nested Platforms X11 (supports OpenGL, QPainter) Wayland (supports OpenGL, QPainter) Full Platforms DRM (supports OpenGL through GBM, QPainter) fbdev (supports QPainter) Android hwcomposer/libhybris (supports OpenGL, input) This Presentation runs on the DRM platform!

Welcome to Wayland — Martin Gr¨ aßlin

slide-8
SLIDE 8

default

Architecture summary

KWin is a Wayland server KWin supports wl shell clients both OpenGL and SHM KWin supports Xwayland based clients KWin can render on top of DRM/KMS KWin support input through libinput Nested KWin Wayland servers on X11/Wayland for easy testing

Welcome to Wayland — Martin Gr¨ aßlin

slide-9
SLIDE 9

default

Agenda

1 Architecture 2 Evolution of KWin 3 The kwind Project 4 What’s next?

Welcome to Wayland — Martin Gr¨ aßlin

slide-10
SLIDE 10

default

Simplified KWin (Core) architecture before Wayland

Welcome to Wayland — Martin Gr¨ aßlin

slide-11
SLIDE 11

default

Simplified KWin (Core) architecture as of today

Welcome to Wayland — Martin Gr¨ aßlin

slide-12
SLIDE 12

default

How to start KWin

Welcome to Wayland — Martin Gr¨ aßlin

slide-13
SLIDE 13

default

Starting KWin as X11 application

How to start X? KWin’s startup is highly X11 dependent Qt’s XCB plugin requires X11 in QApplication ctor Starting Xwayland before KWin requires a running Wayland server Wayland server requires event loop Event loop requires QApplication Xwayland requires wl drm KWin needs to move away from xcb QPA

Welcome to Wayland — Martin Gr¨ aßlin

slide-14
SLIDE 14

default

Is QtWayland any better?

New Startup First start Wayland server Create QApplication Startup Compositor/Scene Startup Xwayland Wait for Xwayland being started Continue with X specific startup code

Welcome to Wayland — Martin Gr¨ aßlin

slide-15
SLIDE 15

default

Similar problems as xcb QPA

Roundtrips are evil Requires Wayland server at QApplication startup Does roundtrip to server in startup (blocks gui thread) Cannot create a QThread before creating QApplication QtWayland dispatches events while waiting for the roundtrip

Welcome to Wayland — Martin Gr¨ aßlin

slide-16
SLIDE 16

default

Still many workarounds needed

Blocking OpenGL context creation

// HACK: create a QWindow in a thread to force QtWayland to create the // client buffer integration. // this performs an eglInitialize which would block as it does a roundtrip // to the Wayland server in the main thread. // By moving into a thread we get the initialize without hitting the problem // This needs to be done before creating the Workspace as from inside // Workspace the dangerous code gets hit in the main thread QFutureWatcher<void> *eglInitWatcher = new QFutureWatcher<void>(this); eglInitWatcher->setFuture(QtConcurrent::run([] { QWindow w; w.setSurfaceType(QSurface::RasterGLSurface); w.create(); }));

Welcome to Wayland — Martin Gr¨ aßlin

slide-17
SLIDE 17

default

More workarounds

BypassWindowManagerHint needed for each Window on X11

bool ApplicationWayland::notify(QObject *o, QEvent *e) { if (QWindow *w = qobject_cast< QWindow* >(o)) { if (e->type() == QEvent::Show) { // on QtWayland windows with X11BypassWindowManagerHint are not shown, // thus we need to remove it. As the flag is interpreted only before // the PlatformWindow is created we need to destroy the window first if (w->flags() & Qt::X11BypassWindowManagerHint) { w->setFlags(w->flags() & ~Qt::X11BypassWindowManagerHint); w->destroy(); w->show(); return false; } } } return Application::notify(o, e); }

Welcome to Wayland — Martin Gr¨ aßlin

slide-18
SLIDE 18

default

Do we need our own QPA plugin?

Further issues Cannot share composited OpenGL context with QtQuick Cannot use threaded QtQuick render loop QtQuick on hwcomposer aborts Intercept all input inside KWin anyway Have code to create X11 and Wayland windows Have code to create OpenGL context Have code to do low level event processing

Welcome to Wayland — Martin Gr¨ aßlin

slide-19
SLIDE 19

default

Agenda

1 Architecture 2 Evolution of KWin 3 The kwind Project 4 What’s next?

Welcome to Wayland — Martin Gr¨ aßlin

slide-20
SLIDE 20

default

I propose to rename kwin to kwind because it swallows all features (Kai-Uwe Broulik)

Welcome to Wayland — Martin Gr¨ aßlin

slide-21
SLIDE 21

default

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 windows can edit all attributes of windows of foreign processes Windows can place themselves Windows can bypass Window Managers Clients can warp pointer Clients can grab foreign window content

Welcome to Wayland — Martin Gr¨ aßlin

slide-22
SLIDE 22

default

KWin needs more knowledge about the windows

More control to the compositor KGlobalAccel moved into KWin Screen Locking needs to move into KWin Needs to know which windows belong to virtual keyboard Needs to know which process is desktop shell Needs to know which process is screen shot application Needs to know which process handles power management Needs to know the session splash screen Needs to authorize processes to access special interfaces

Welcome to Wayland — Martin Gr¨ aßlin

slide-23
SLIDE 23

default

Suggestions for the problems appreciated!

It’s tricky Don’t duplicate code Don’t hard depend on specific technology Everything should be flexible How to handle e.g. a shell process crash Don’t harm user experience (no UAC) What about kded?

Welcome to Wayland — Martin Gr¨ aßlin

slide-24
SLIDE 24

default

Agenda

1 Architecture 2 Evolution of KWin 3 The kwind Project 4 What’s next?

Welcome to Wayland — Martin Gr¨ aßlin

slide-25
SLIDE 25

default

XDG Shell

So far only wl shell support wl shell is rather limited We make it useable with a Qt extension No support for Weston-demo clients No support for GTK+ clients XDG Shell under heavy development Unstable protocol mechanism GTK, Qt, Weston on real systems out of sync Need to get our (Qt, Plasma) needs into the protocol

Welcome to Wayland — Martin Gr¨ aßlin

slide-26
SLIDE 26

default

Window Decorations

Issues with Qt deco Minimize button does nothing No visible distinction between active/inactive state Cannot configure button order Cannot add our own buttons It’s not a good client-side deco solution, models server side Possible Solution 1 Implement a better plugin based on KDecoration Maybe better Solution? Disable Qt deco at runtime Read Qt::FramelessWindowHint in Extended surface Create server deco for all Qt Windows

Welcome to Wayland — Martin Gr¨ aßlin

slide-27
SLIDE 27

default

Improvements in KWin

Lot’s of features still missing Geometry handling missing Window types mostly missing Interaction with Plasma needs improvements Lots of small bugs here and there Window Rules missing Please help us! Plasma on Wayland on todo.kde.org

Welcome to Wayland — Martin Gr¨ aßlin

slide-28
SLIDE 28

default

KWindowSystem

Modeled around X11 Everywhere global Window Id Mixes API for own and foreign windows Platform abstraction is not a solution to support Wayland Idea Create a new API exposing a QAbstractItemModel which can be used by Task Managers.

Welcome to Wayland — Martin Gr¨ aßlin

slide-29
SLIDE 29

default

Polish, polish, polish

Please Help! Starting KWin: kwin wayland –xwayland Starting Plasma: startplasmacompositor

Welcome to Wayland — Martin Gr¨ aßlin

slide-30
SLIDE 30

default

Tuesday is Wayland Day

Lab 0.5w 10:30 Wayland and Powerdevil and KScreen 11:30 Wayland and Plasma 15:00 Wayland and Applications

Welcome to Wayland — Martin Gr¨ aßlin

slide-31
SLIDE 31

default

What is KWayland Client?

Qt style convenient library for Wayland Allow to use Wayland APIs in a Qt way Not a complete wrapper of Wayland yet Can integrate with QtWayland QPA Additional KWin/Plasma specific Wayland interfaces Doesn’t that duplicate QtWayland? QtWayland is a QPA plugin KWayland is an API which could be used to write a Wayland QPA plugin KWayland is to QtWayland, what KWindowSystem is to xcb QPA plugin

Welcome to Wayland — Martin Gr¨ aßlin

slide-32
SLIDE 32

default

Additional Interfaces provided by KWayland

Already implemented

  • rg kde kwin shadow (e.g. Plasma panel shadow)
  • rg kde kwin idle (KF5IdleTime)
  • rg kde kwin fake input (kdeconnect)
  • rg kde plasma shell
  • rg kde plasma window management

More to come, e.g. Blur and Background contrast effect Highlight Windows Present Windows Slide Windows

Welcome to Wayland — Martin Gr¨ aßlin

slide-33
SLIDE 33

default

New Repository: kwayland-integration

New in Plasma 5.4 Plugin for KWindowSystem Plugin for KIdleTime Place for any framework plugin which needs to depend on KWayland

Welcome to Wayland — Martin Gr¨ aßlin

slide-34
SLIDE 34

default

What is KWayland Server?

The other side Qt-style API to implement a Wayland server Wrapper for the core Wayland protocols Wrapper for the KWin/Plasma specific interfaces No rendering! Implements lots of generic Wayland server functionality

Welcome to Wayland — Martin Gr¨ aßlin

slide-35
SLIDE 35

default

Building a Wayland Server with KWayland

auto display = new KWayland::Server::Display(this); display->start(); auto compositor = display->createCompositor(display); compositor->create(); auto shell = display->createShell(display); shell->create(); display->createShm(); auto seat = display->createSeat(display); seat->create(); display->createDataDeviceManager(display)->create(); display->createIdle(display)->create(); auto plasmaShell = display->createPlasmaShell(display); plasmaShell->create(); auto qtExtendedSurface = display->createQtSurfaceExtension(display); qtExtendedSurface->create(); auto windowManagement = display->createPlasmaWindowManagement(display); windowManagement->create(); auto shadowManager = display->createShadowManager(display); shadowManager->create();

Welcome to Wayland — Martin Gr¨ aßlin

slide-36
SLIDE 36

default

Interacting with the server

Example for a created object

connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated, [this] (PlasmaShellSurfaceInterface *surface) { if (ShellClient *client = findClient(surface->surface())) { client->installPlasmaShellSurface(surface); } } );

Welcome to Wayland — Martin Gr¨ aßlin

slide-37
SLIDE 37

default

Interacting with the server

Example for updating information in the server

void InputRedirection::processPointerMotion(const QPointF &pos, uint32_t time) { // KWin internal handling for pointer motion removed for readability #if HAVE_WAYLAND if (auto seat = findSeat()) { seat->setTimestamp(time); seat->setPointerPos(pos); } #endif }

Welcome to Wayland — Martin Gr¨ aßlin

slide-38
SLIDE 38

default

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 needs Lot’s of things which just doesn’t fit our usecases

Welcome to Wayland — Martin Gr¨ aßlin