Commit Graph

353 Commits (c46c92e20460f8450aa291b35710da8c7010899b)

Author SHA1 Message Date
Martin Gräßlin d60c377890 [wayland] Introduce a ShellClient
The ShellClient is a Toplevel subclass for a
KWayland::Server::ShellSurfaceInterface. It gets created when a new
ShellSurfaceInterface is created and destoryed when it gets unmapped.

So far the usage is still rather limited. The ShellClient is opened
at position (0/0). While it's possible to pass pointer events to it,
it's not yet possible to activate it, so no keyboard focus.
2015-05-08 12:43:44 +02:00
Martin Gräßlin 2afaa60dc5 [wayland] A backend can mark whether it is ready
Replaces the functionality of the WaylandBackend and makes it available
to all backends by providing the functionality directly in
AbstractBackend. By default a backend is not ready and the implementation
must call setReady(true) to indicate that setup has finished
successfully. The compositor won't start till the backend indicates that
it is ready.
2015-05-05 19:05:31 +02:00
Martin Gräßlin 72db1e63a3 [wayland] Move backend implementations into a backends/<name> directory
The aim is to be able to create a plugin for each of the backends.
The following directories are created:
* backends/drm
* backends/fbdev
* backends/wayland
* backends/x11
2015-05-05 13:05:37 +02:00
Martin Gräßlin 49f58059c6 [wayland] Backends are no longer singletons
They are installed in the WaylandServer, thus we don't need an explicit
singleton accessor. If we need to differentiate we can cast.
2015-03-23 14:29:07 +01:00
Martin Gräßlin 6bf44b7db4 [wayland] Add an X11 output backend
This new backend allows to start a kwin_wayland server nested on an
X-Server by using a normal X11 window as output. This allows testing
kwin_wayland without needing to start another Wayland server first.

The behavior is triggered by using new command line arguments:
--windowed
--x11-display=<:0>

With optional --width and --height arguments.

In this mode the WaylandBackend is not created at all.

So far the backend is not fully integrated yet and only the QPainter
backend supports this mode.
2015-03-20 14:08:53 +01:00
Martin Gräßlin 862bb95ffb [wayland] Do not start composite timer if Workspace is not ready yet
Could cause a race during startup resulting in crash.
2015-03-18 16:27:22 +01:00
Martin Gräßlin fafa22d0c6 [wayland] Invoke frame rendered callback on damaged windows
Introduces a new time counter on Compositor to indicate the elapsed
time sine the compositor started.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 659c416879 [wayland] Handle damage events from SurfaceInterface
On Wayland we get the damage from the SurfaceInterface instead of
using a damage handle. This change ensures that the damage handle
interaction is only used on platform X11, while on Wayland we get
the damage from the SurfaceInterface directly.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 50ef02fa1b [wayland] Start Compositor and Scene before Workspace
For Xwayland we need to have the Scene (and EglDisplay) created prior
to starting Xwayland and having X11. This requires creating the
Compositor before creating Workspace and starting Xwayland.

To support this the startup of Compositor is split into two parts:
prior and after Workspace creation.

The change might also be interesting for the kwin_x11 case as it could
result in the compositor being up in a quicker way.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 659ff1c732 [wayland] Don't check whether GLX is available
We won't use it, so let's not check for it.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 58d79e2da4 Compositor: connect to configChanged emitted by Options instead of Workspace
Removes dependency to Workspace in ctor.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 147af71f8a Drop Workspace dependency from Scene
Only used for one connect which can also be done outside of Scene.
Subclasses got the singleton pointer and just passed to the parent.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 7c3197b1eb Use new ctors for KXMessages and KSelectionOwner
Allows to pass the connection and rootWindow and doesn't depend on
QX11Info.
2015-03-17 10:20:19 +01:00
Martin Gräßlin c383d6074c Replace QX11Info::appScreen() with KWin::Application::x11ScreenNumber()
No need to go through QX11Info for information we have.
2015-03-17 09:44:53 +01:00
Fredrik Höglund 38f1945c6c Use swap events to drive repaints
Don't start the composite timer at the end of performPaint() when a
buffer swap is pending and vsync is enabled.  Instead set
m_composeAtSwapCompletion to true so performPaint() gets called again
as soon as the swap completes.

This makes the repaint cycle look like this:

    scene->paint()
    SwapBuffers()
    Process events
          ·
          ·
    Swap completes
    Fetch and reset damage (if applicable)
    scene->paint()
    SwapBuffers()
    Process events
          ·
          ·
    Swap completes
    ...

This results in a noticeable improvement in animation smoothness with
drivers that support GLX_INTEL_swap_event, since we're now able to
consistently render at the monitor refresh rate.
2015-01-06 07:51:50 +01:00
Daniel Pastushchak 0d997b1093 Introduce categorized logging for kwin core
Done by Daniel Pastushchak for KDE during GCI-2014.
2014-12-05 14:27:15 +01:00
Martin Gräßlin f78ff8eaa5 Do not emit DecorationSettings::alphaChannelSupportedChanged on tear down
The Compositor is destroyed before the Client and Decorations are
destroyed on shutdown. This meant the Decorations reacted needlessly
on the alpha channel supported. E.g. Aurorae recreated the Decoration
and most likely crashed in Qt.

With this change the signal gets disconnected and the Decorations
just don't do anything.
2014-12-03 13:10:35 +01:00
Martin Gräßlin c2e53b9a2f Merge branch 'kdecorations2'
Conflicts:
	effects.cpp
	paintredirector.cpp
2014-12-02 08:38:10 +01:00
Martin Gräßlin bf4ba54647 Remove displayWidth and displayHeight from the compositor
Instead of getting size from displayWidth() and displayHeight() use
the information we have from Screens. This means there is only one
place to have the information and by that we can ensure that all
components use the same data to rely on. displayWidth/displayHeight
seem to provide the wrong information when unplugging an output
without disabling the output. This results in rendering artefacts.
But KWin::Screens has the correct information available.
2014-11-27 09:00:19 +01:00
Martin Gräßlin 21dca7ac14 Keep a QPointer<DecoratedClientImpl> in Client
This allows to remove the internal access to the DecoratedClientPrivate
in the KDecoration API.
2014-10-21 07:46:44 +02:00
Martin Gräßlin e32da9d9e0 Merge branch 'master' into kdecorations2
Conflicts:
	CMakeLists.txt
	paintredirector.cpp
	scene_opengl.h
	scene_qpainter.h
	scene_xrender.h
2014-10-20 16:04:52 +02:00
Fredrik Höglund 32e9de1e23 Refactor the swap completion interface
Move the buffer-swap-pending state from the compositing backends to
the Compositor class. The Compositor is the only class that needs to
access the state, and this way it to do it without calling through
a chain of virtual functions. This commit adds two new functions to
Compositor; aboutToSwapBuffers() and bufferSwapComplete(). The
backends call these functions to set and reset the buffer-swap-pending
state.

This commit also renames a number of functions and variables to make
their meaning clear.

The act of promoting the contents of the back buffer to become the
contents of the front buffer is referred to as posting the buffer,
presenting the buffer, or swapping the buffers; rendering the buffer
is what paintScreen() does.
2014-09-18 20:21:20 +02:00
Fredrik Höglund 3b4907d060 Add support for explicit command stream synchronization
Create and import X sync fences into GL and use them to synchronize
the kwin command stream with the X command stream.

This prevents damaged windows from being composited by kwin before
the rendering that triggered the damage events have finished on
the GPU.

Requires GL_EXT_x11_sync_object.

Tested-by: Marco Martin <notmart@gmail.com>
2014-09-12 14:50:12 +02:00
Martin Gräßlin 3185530ed6 [kwin-wayland] Create dedicated thread for wayland connection
The Wayland event queue is moved into a dedicated thread and a
new class is created for just creating the connection and listening
for events. The WaylandBackend creates the thread and uses an event
queue for the main thread.

REVIEW: 119761
2014-08-18 08:51:24 +02:00
Martin Gräßlin c8c0bace31 Destroy DecorationRenderer in setup/finish compositing
So far the DecorationRenderer got destroyed and recreated after
the signal compositing toggled was emitted. But that's too late for
e.g. the OpenGL Textures to be destroyed. So lets trigger the destroy
directly in setup/finish compositing. The new renderer will still be
created after the compositing toggled is emitted - we don't want to
have it recreated for the still active compositer type.
2014-07-25 14:02:27 +02:00
Martin Gräßlin 0030eb7f84 Initial import of support for new KDecoration2 based decorations
NOTE: this is not working completely yet, lots of code is still ifdefed
other parts are still broken.

The main difference for the new decoration API is that it is neither
QWidget nor QWindow based. It's just a QObject which processes input
events and has a paint method to render the decoration. This means all
the workarounds for the QWidget interception are removed. Also the paint
redirector is removed. Instead each compositor has now its own renderer
which can be optimized for the specific case. E.g. the OpenGL compositor
renders to a scratch image which gets copied into the combined texture,
the XRender compositor copies into the XPixmaps.

Input events are also changed. The events are composed into QMouseEvents
and passed through the decoration, which might accept them. If they are
not accpted we assume that it's a press on the decoration area allowing
us to resize/move the window. Input events are not completely working
yet, e.g. wheel events are not yet processed and double click on deco
is not yet working.

Overall KDecoration2 is way more stateful and KWin core needs more
adjustments for it. E.g. borders are allowed to be disabled at any time.
2014-07-25 14:02:26 +02:00
Martin Gräßlin a290209b3d Create dedicated class for CompositorDBusInterface
Similar to the already existing DBusInterface wrapper for the
org.kde.KWin interface a new CompositorDBusInterface is introduced for
org.kde.kwin.Compositing.

That way the DBus interface is split from the implementation and DBus
specific methods are no longer required in the Compositor class.

The deprecated DBus methods
* toggleCompositing(bool)
* setCompositing(bool)

are removed.

REVIEW: 118463
2014-06-10 10:52:25 +02:00
Martin Gräßlin 4c241f0920 Only connect the Scene::resetCompositing signal when Scene got constructed
SceneOpenGL::createScene() might return a null pointer and in this case
we should not try to connect to it.

REVIEW: 118462
2014-06-02 10:46:34 +02:00
Martin Gräßlin f70951ef76 [Compositor] Improve debug output for compositing suspended
Map the flags to a user readable name.

BUG: 334558
REVIEW: 118140
2014-05-15 10:59:53 +02:00
Martin Gräßlin bef0bf8a4f Do not register dbus service org.kde.kwin.Compositing
Just use org.kde.KWin - there's object and interface to differentiate.
2014-05-15 10:55:29 +02:00
Martin Gräßlin 8005aa8b5a Export supported openGLPlatformInterfaces to the DBus interface
Allows the KCM to know which platforms are supported (e.g. glx and egl or
just egl).
2014-05-13 09:23:03 +02:00
Martin Gräßlin 88d55997f7 Port away from DefaultScreen(display())
The screen number is provided through QX11Info.
2014-05-05 08:09:09 +02:00
Martin Gräßlin 8e63102855 Discard all deleted before constructing the Scene
The Scene connects to the deletedRemoved signal and tries to remove the
Deleted from it's list of Windows, which will fail because a SceneWindow
doesn't get created for an existing Deleted in the Scene setup.

It doesn't make sense to create a SceneWindow for a Deleted as there is
no pixmap around anyway. Thus the best approach is to ensure that there
are no Deleted by just discarding all prior to creating the Scene.

BUG: 333275
REVIEW: 117557
2014-04-23 15:05:27 +02:00
Martin Gräßlin 93e5ebac63 Try to wait for DESTROY_NOTIFY before releasing an Unmanaged
So far the Unmanaged got released after an XCB_UNMAP_NOTIFY. This event
gets created after xcb_unmap_window or after xcb_destroy_window. In the
latter case the window is already distroyed and any of KWin's cleanup
calls will cause a BadWindow (or similar) error.

The idea to circumvent these errors is to try to wait for the
DESTROY_NOTIFY event. To do so the processing of the release is slightly
delayed. If KWin gets the destroy notify before the delay times out the
Unamanged gets released immediately but with a Destroy flag. For this a
new enum ReleaseToplevel is introduced and Unmanage::release takes this
as an argument instead of the bool which indicated OnShutdown. Also this
enum is added to Toplevel::finishCompositing so that it can ignore the
destroyed case and not generate an error.

REVIEW: 117422
2014-04-16 13:32:11 +02:00
Martin Gräßlin ca9642b80f Watch whether the Wayland socket goes away
The Wayland Backend watches the socket it uses for communicating with the
Wayland compositor. If the socket is removed we have to perform a kind of
emergency stop. The backend tears down all data structures created from
the Wayland display and emits a signal that the system compositor died.

In addition the Wayland Backend starts to monitor the XDG_RUNTIME_DIR for
the socket to be added again. If the socket is created again the backend
reinitializes the Wayland connection.

This also requires the Compositor to restart. Therefore it connects to
the new signals emitted by the Wayland Backend to stop and start
compositing.
2014-03-19 09:30:17 +01:00
Martin Gräßlin 3346e04769 [kwin] Remove config-X11.h includes
None of the defines is used.
2014-03-18 10:00:49 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin abecbf2369 [kwin] Port away from deprecated functionality in KWindowSystem
Less warnings and more type safety.
2014-03-17 10:22:20 +01:00
Martin Gräßlin c7d986c7fe [kwin] Remove the legacy OpenGL 1 compositing backend
KWin already has a de facto OpenGL 2 dependency through QML. Combined
with the fact that the OpenGL 1 backend is basically unmaintained and
also unused, it's better to remove it for the new major release.

This change includes:
 * Removal of cmake option KWIN_BUILD_OPENGL_1_COMPOSITING
 * Removal of KWIN_HAVE_OPENGL_1 compile option and all code
   ifdef'ed with it (partially removal of if-else constructs)
 * Removal of CompositingType::OpenGL1Compositing (flags are kept
   as a core flag should get introduced)
 * Driver recommendation for OpenGL1Compositing changed to XRender
   (should be evaluated whether the drivers can provide GL2)
 * Removal of configuration option "GLLegacy"
 * Removal of fooMatrix function in kwinglutils
 * Removal of ARBBlurShader
 * Removal of legacy code path in GLVertexBuffer
 * Removal of GLShaderManager::disable
 * if-blocks with ShaderManager::instance()->isValid() removed

REVIEW: 116042
2014-03-10 08:59:11 +01:00
Martin Gräßlin b9e894bc4b Remove link to 4.0 release notes
http://techbase.kde.org/Projects/KWin/4.0-release-notes#Setting_up
is not really up to date any more and it's strange having 5.0 link to
the 4.0 release notes.

REVIEW: 116637
2014-03-07 07:46:15 +01:00
Martin Gräßlin b65d54f4d2 Enforce compositing if required
In the Wayland world we need to have a compositor. This means we have to
enforce that the compositor is running. If the setup fails we have to
quit, because it doesn't make any sense any more to be running.

A new method requiresCompositing() is added to the Application. If it
returns true the useCompositing option will always return true and the
unredirect fullscreen option will always return false. That way
compositing is enforced at startup and cannot end by unredirecting.

In addition this method is checked if actions are performed which would
suspend compositing. E.g. the shortcut to toggle compositing. Restarting
the compositor is still possible in order to change the selected
compositing backend without a restart. But if it fails KWin will quit.
2014-01-09 15:16:42 +01:00
Martin Gräßlin 0c559c163d New QPainter based compositor called SceneQPainter
This compositor uses only the QPainter API to perform rendering. The
window's X Pixmap is mapped to a QImage using XShm. As rendering backend
a QImage is used.

The new compositing type "QPainterCompositing" is introduced. Effects
need to be adjusted to explicitly check the compositing type and no
longer assume the compositing type is XRender if it's not OpenGL.

This compositor can be selected with using "Q" as the value for
KWIN_COMPOSE env variable or setting the config value to "QPainter".
The GUI is not yet adjusted to select this compositor.

The QPainter scene provides currently the following features:
* 2D transformations (translation and scalation)
* opacity modifications
* rendering of decorations (new PaintRedirector sub class)
* rendering of shadows
* rendering of effect frames
* rendering to a Wayland surface

The following features are currently not provided:
* saturation changes
* brightness changes
* 3D transformations
* rendering to X Overlay window
* offscreen rendering (e.g. needed for screen shot effect)
* custom rendering in the effects to the current back buffer
2014-01-09 13:29:40 +01:00
Martin Gräßlin b28effff23 A Scene doesn't need to use an X11 Overlay Window
Only the X based Scenes need an overlay window, so the Compositor doesn't
need to check for it in the Wayland case.

OverlayWindow is moved from OpenGLBackend to the sub classes which need
to provide it.
2014-01-08 09:22:40 +01:00
Martin Gräßlin c9779825d1 Support frame callback in Wayland backend
The egl wayland backend registers for the callback for a rendered frame.
This allows to throttle KWin's compositor so that we don't render frames
which wouldn't end up on the screen.

For this the Scene provides a method to query whether the last frame got
rendered. By default this returns true in all backends. The Egl Wayland
backend returns true or false depending on whether the callback for the
last frame was recieved.

In case the last frame has not been renderd when performCompositing is
tried to be called, the method returns just like in the case when the
overlay window is not visible. Once the frame callback has been recieved
performCompositing is invoked again.
2014-01-08 09:22:40 +01:00
Martin Gräßlin cfa1ead9e1 Introduce an XRenderBackend similar to OpenGLBackend
An abstract backend is split out of SceneXRender which takes care of
managing the render pictures and swapping them after a frame is rendered.

Having this abstract allows to implement further backends for XRender
which do not use the Overlay Window for compositing.

To have it consistant the SceneXRender is now also created by a factory
method.
2014-01-08 09:22:40 +01:00
Martin Gräßlin 08a09d27f8 [kwin] Remove the KActionCollection for the client keys
Not needed as we can also find the action as a child of Workspace.
2013-12-10 10:15:23 +01:00
Martin Gräßlin a6f32bf3e8 [kwin] Do not use a KActionCollection for Workspace's global shortcut actions
The ActionCollection was only used for two features:
* setting the object name
* finding the action for retrieving it's shortcut

This can also be achieved by just setting the object name and searching
for the children of the Workspace singleton.
2013-12-10 10:01:13 +01:00
Martin Gräßlin d90be88446 [kwin] Connect the Compositor to a reinit signal
Allows to force a reinit from the config module again.
2013-12-03 07:11:30 +01:00
Martin Gräßlin ba66fd9ef6 [kwin] NETWinInfo2 becomes NETWinInfo
And takes a xcb_connection_t instead of Display. Also our own class
is adjusted to no longer need the connection being passed in.
2013-11-18 13:56:28 +01:00
Martin Gräßlin 324aae916a [kwin] Drop testapp for detecting whether direct rendering works on glx
The main purpose of the opengl testapp was to set the environment
variable LIBGL_ALWAYS_INDIRECT if direct rendering is not supported
before glx gets initialized.

With Qt5 we may no longer set this environment variable. QtQuick
requires direct rendering. On IvyBridge QtQuick is crashing if the
variable is set. Thus we are no longer allowed to set it and thus the
complete test becomes pointless.

The test app basically whitelisted most drivers anyway, the only
drivers which were problematic are the proprietary Catalyst drivers.
It that's still a problem we can also disable OpenGL compositing on
those drivers through the recommendation in the GLPlatform.

This also means that the KWIN_DIRECT_GL variable is no longer useful.
2013-11-05 14:48:40 +01:00