Commit Graph

52 Commits (master)

Author SHA1 Message Date
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol 3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56:08 +02:00
Vlad Zahorodnii 15af09c70a Introduce Toplevel::frameGeometryChanged signal
Summary:
Currently we have two signals that are emitted when the Toplevel's geometry
changes - geometryShapeChanged() and geometryChanged(). The former signal
is used primarily to invalidate cached window quads and the latter is
sort of emitted when the frame geometry changes. But it's not that easy. We
have a bunch of connects that link those signals together...

The worst part about all of this is that the window quads cache gets
invalidated every time a geometry update occurs, for example when user
moves a window around on the screen.

This change introduces a new signal and deprecates the existing geometryChanged
signal. frameGeometryChanged is similar to geometryChanged except that it is
emitted when an _actual_ geometry change has occurred.

We do still emit geometryShapeChanged signal. However, in long term, we
need to get rid of this signal or come up with something that makes sense
and doesn't require us to waste computational resources.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26863
2020-02-12 10:52:26 +02:00
Vlad Zahorodnii fb598c65b8 Provide a KWindowShadow implementation for internal clients
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T12496

Differential Revision: https://phabricator.kde.org/D26459
2020-01-22 02:21:36 +02:00
Vlad Zahorodnii 7d4471eba6 Rename geometry property to frameGeometry
Summary:
In order to properly implement xdg_surface.set_window_geometry we need
two kinds of geometry - frame and buffer. The frame geometry specifies
visible bounds of the client on the screen, excluding client-side drop
shadows. The buffer geometry specifies rectangle on the screen that the
attached buffer or x11 pixmap occupies on the screen.

This change renames the geometry property to frameGeometry in order to
reflect the new meaning assigned to it as well to make it easier to
differentiate between frame geometry and buffer geometry in the future.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24334
2019-10-02 11:46:37 +03:00
Vlad Zahorodnii 99d3185949 Rename getShadow method to updateShadow
Summary: getShadow is not a getter method as it doesn't return a shadow.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24298
2019-09-29 15:26:53 +03:00
Vlad Zahorodnii 62a7db7028 Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.

This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 17:48:21 +03:00
David Edmundson 515f3cbb4e Avoid crash without XWayland
Summary: readX11ShadowProperty fails without an X connection

Test Plan: Tested by Kai who didn't have xwayland

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D21965
2019-06-23 17:58:49 +02:00
David Edmundson 576c667124 Avoid deleting ourselves midway through updateShadow
Summary:
If updating a shadow means that there should be no shadow, shadow ends
up deleting itself midway through the method.

It's cleaner and safer to leave that to the caller.

This new change matches the existing documentation for
Shadow::updateShadow which states

> In case the Property has been withdrawn the method returns @c false.
> In that case the owner should delete the Shadow.

Test Plan:
Created an ASAN of kwin
Relevant testMaximised no longer fails

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17380
2018-12-06 12:55:12 +00:00
Vlad Zagorodniy 90a26e2e8d Try to invalidate quad cache when shadow is changed
Summary:
213239a0ea tried to address the case when
a wayland client gets shadow after it was mapped, but because of poor
testing from my side, another bug was introduced. If a decoration tooltip
or the user actions popup is shown, then in some cases it can be blank.

Usually, SurfaceInterface::shadowChanged proceeds SurfaceInterface::sizeChanged,
so when the shadow is installed, window quads cache is rebuilt. But
because shell client already knows the geometry of the internal client,
goemetryShapeChanged is not emitted, thus the cache is not updated.

It would be better just to invalidate the cache when the shadow is
installed, uninstalled, or updated. This reduces the number of
unnecessary invocations of Scene::Window::buildQuads and also moves
handling of the window quads cache away from the Shadow class.

BUG: 399490
FIXED-IN: 5.15.0

Test Plan: Decoration tooltips are no longer blank.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17215
2018-12-05 20:05:15 +02:00
Vlad Zagorodniy 213239a0ea [shadow] Rebuild quads after creation of shadow
Summary:
If a shadow is installed for already rendered window, the shadow won't
be initially rendered because we don't rebuild window quad cache.

BUG: 398572
FIXED-IN: 5.14.0

Test Plan: Can't reproduce 398572 anymore.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15475
2018-09-13 16:20:04 +03:00
Vlad Zagorodniy ce9965ccad Fix typo
Summary: crate -> create

Test Plan: Still compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14584
2018-08-04 22:35:40 +03:00
Martin Flöser 537b36d1cb Only try creating X11 shadow if we have an X11 connection
Summary:
Otherwise it crashes for the first window being created in a
KWin/Wayland without XWayland support.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7894
2017-09-23 11:49:01 +02:00
Martin Gräßlin fe8fc6f83d Ensure to directly delete old Shadow on update
Summary:
So far when deleting a Shadow we used deleteLater which caused it
to be deleted in the next event cycle. This could in worst case result
in the Shadow being deleted after compositing got suspended. Thus the
Shadow not getting removed from the DecorationShadowCache which in
turn would mess up rendering on resume of compositing as the cache
returns a texture created for a different context.

BUG: 361154
FIXED-IN: 5.7.4

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2483
2016-08-18 16:08:42 +02:00
Martin Gräßlin 24bdfc6317 Make Toplevel::window() no longer virtual and introduce ::windowId()
Summary:
Toplevel::window() is the actual X11 window. This makes it difficult
to use as the generic identifier for both X11 and Wayland. The Wayland
ShellClient already had a windowId() which is now added to Toplevel as
a virtual method. On X11 (Toplevel default) it returns the window().

The method window() now returns XCB_WINDOW_NONE for classes without
the Toplevel::m_client, such as ShellClient. Thus it allows to properly
check whether we are on Wayland or X11.

The code is adjusted to use windowId where a generic id is needed and
to properly check whether the window is valid before using it where
a window() is used.

This also fixes at least one additional unknown issue in
Workspace::setActiveClient

where the windowId of a Wayland client was passed to X11.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1527
2016-05-17 14:13:24 +02:00
Ivan Čukić 2c95a4e6b9 Checking whether m_topLevel is not null before getting its property
Summary:
From the rest of this method, it is obvious that m_topLevel can
be null in any part of the method - we are checking against it
being null in a few places in the method - both before and after
the affending lines.

Now, there is one place where the check is not applied, and
potentially calls ->window() on the null pointer.

p.s. If there are more places where kwin does clear_or_something(); return;
it could benefit from introducing on_scope_exit and similar tricks - see
Alexandrescu's 'Declarative control flow' presentation.

Reviewers: graesslin

Reviewed By: graesslin

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1346
2016-04-08 09:25:28 +02:00
Martin Gräßlin d28fba8839 DecorationShadow operates on AbstractClient 2015-12-18 16:41:49 +01:00
Martin Gräßlin 3139dcd3b9 Drop cmakedefine HAVE_WAYLAND
Now a required build dependency.
2015-08-12 11:39:20 +02:00
Heiko Becker 105cda7769 Fix build without wayland
Without this I get: "shadow.cpp:133:1: error: no return statement in
function returning non-void [-Werror=return-type]"

REVIEW: 124390
2015-07-20 08:53:55 +02:00
Martin Gräßlin df1146bfa6 [wayland] Shadow gains support for a Wayland protocol
For Wayland clients we now are able to get shadows.

Internally this reuses large parts of the X11 implementation. This
could be improved to make the Scene's better aware of the Wayland
shadow, so that less memory is needed.
2015-07-15 11:25:16 +02:00
Martin Gräßlin 7508cd49e0 Trigger rebuilding of quads after creating a new DecorationShadow
If there were already a shadow, the quads are rebuild, but not if
we created a new shadow. This is not a problem if the shadow exists
before the quads are built for the first time (e.g. when managing
the window), but if the shadow is created later on the quads are
incorrect and the shadow doesn't get rendered at all. This happens
for example with Aurorae based decoration themes, where the creation
of the first shadow is delayed into the next event cycle.
2015-01-27 11:42:21 +01:00
Martin Gräßlin 2910645df0 [scene-xrender] Implement support for DecorationShadow
The DecorationShadow on XRender is implemented by creating the
required QPixmaps in ::prepareBackend. That way the rendering
infrastructure can be shared with the window based shadows.

BUG: 342758
REVIEW: 122009
2015-01-19 09:30:01 +01:00
Martin Gräßlin f103cd0bea DecorationShadow elements are QRects 2014-11-12 09:06:03 +01:00
Martin Gräßlin b337a0b52e DecorationShadow uses QRect to set element sizes 2014-11-11 17:02:15 +01:00
Martin Gräßlin 1afc355759 DecorationShadow uses QMargins for padding 2014-11-11 15:18:35 +01:00
Hugo Pereira Da Costa 931c43b6c4 added missing .data() to make connect/disconnect compile 2014-11-04 10:37:39 +01:00
Martin Gräßlin 7353bf4c28 [shadow] Needs to keep a QPointer to the DecorationShadow
The DecorationShadow might be deleted at any time, so we better
keep track of it properly.
2014-10-28 11:01:43 +01:00
Martin Gräßlin 08d146de91 Introduce support for DecorationShadow
Surprisingly the DecorationShadow is modelled after the Shadow in KWin.
It provides the same offsets and a QImage exactly like the OpenGL
implementation needs it. This makes it easy to hook it into our existing
Shadow implementation with only a few changes.

Shadow now first tries to create a Shadow from the Decoration and only
if that fails it tries the X11 property. The pixmaps are not initialized
for the DecorationShadow and because of that currently only the OpenGL
backend gets initialized for DecorationShadows. The other backends might
need adjustments and also a transition to just using one image.
2014-07-25 14:02:27 +02:00
Martin Gräßlin b45eeae352 [Xcb::Wrapper] Introduce a Property and StringProperty Wrapper subclass
The Xcb::Property can wrap the xcb_get_property call and provides
convenient access methods to read the value of the reply with checks
applied. For this it provides a templated ::value method for reading a
single value or reading an array. There's also a ::toBool and
::toByteArray which performs the conversion directly with default values
for the type and format checks.

Xcb::TransientFor is changed to be derived from Property instead of
Wrapper directly, so that the reading of the property value can be
shared.

Xcb::StringProperty is a convenient wrapper derived from Property to
handle the reading of a string property providing a cast to QByteArray
operator. This replaces the ::getStringProperty from utils. Though the
separator functionality from ::getStringProperty is not provided as that
is only used in one function and handled there.

All the custom usages of xcb_get_property or getStringProperty are
replaced to use this new wrapper. That simplifies the code and ensures
that all properties are read in the same way.

REVIEW: 117574
2014-04-17 07:41:33 +02:00
Martin Gräßlin 1a0e586b9c Pass creation of Shadow sub class instance to Scene
Instead of having the Shadow factory method check the compositor type and
do the decision which Shadow sub class to create, a pure virtual method in
Scene is called which returns the specific Shadow sub class instance.
2014-01-07 15:34:19 +01:00
Martin Gräßlin 634a84e5c0 Port reading the shadow property to XCB 2013-09-11 08:21:44 +02:00
Martin Gräßlin bd7da7ccd0 Bring back shadows
Main problem here was that it still used fromX11Pixmap. It's changed to
XCB and gets the image data with xcb_get_image, constructs a QImage from
retrieved data and copies it to QPixmap. That's performing a deep copy
which we want (and also had in the old code).
2013-07-31 15:25:39 +02:00
Martin Gräßlin f210d42d14 Disable Shadow System for porting
Shadow system needs to change to not pass XPixmap handles around. That
was handy in Qt 4 but is difficult in both Widget Style and KWin in Qt5.
2013-07-24 09:47:03 +02:00
Thomas Lübking 6146fa39a4 rebuild quads when removing shadows for empty prop
BUG: 320786
FIXED-IN: 4.11
REVIEW: 110871
2013-06-10 16:34:18 +02:00
Martin Gräßlin 6d2dfe06e7 Introduce dedicated OpenGL1 and OpenGL2 compositing types
The CompositingType enum turns into flags and two new values are
introduced: OpenGL1Compositing and OpenGL2Compositing.

Those new values are or-ed to OpenGLCompositing so that a simple check
for the flag OpenGLCompositing works in case of one of those two new
values. To make the generic check for OpenGL compositing easier a method
in EffectsHandler is introduced to just check for this.

The scenes now return either OpenGL1Compositing or OpenGL2Compositing
depending on which Scene implementation. None returns OpenGLCompositing.
2012-09-29 15:33:57 +02:00
Thomas Lübking 7b3c58280b Support withdrawal of shadows
The Oxygen deco uses this to remove built-in shadows from decorated windows when adding (legacy...) decoration shadows

CCBUG: 291774
REVIEW: 103751
(cherry picked from commit a97bdc64fa2a676f99738abd371a99126fb8e93d)
2012-01-25 00:21:07 +01:00
Thomas Lübking 065666e35b simplify general shadow building code
REVIEW: 103236
(cherry picked from commit 4089e5a1842906bb388d18ccb6a7b0437b8699e2)
2011-11-27 15:04:02 +01:00
Thomas Lübking f3d1261680 fix shadow quad update, allows to change shadow size with property update
(been OpenGL issue only)
fix TopLevel::visibleRect, broke shaded windows with empty (too big) shadows

REVIEW: 103231
(cherry picked from commit 535d40e7b4ca5a4431446c3d5c70e6d52f541fae)
2011-11-27 15:03:18 +01:00
Martin Gräßlin 987bc837d9 Remove define KWIN_HAVE_OPENGL_COMPOSITING
Due to changes in build system we have always either OpenGL or OpenGL ES.
This allows to remove the KWIN_HAVE_OPENGL_COMPOSITING define. In the
effects the define is kept as KWIN_HAVE_OPENGL which can be used in
future to build also an XRender only effect system.
2011-08-13 16:46:43 +02:00
Martin Gräßlin b837a3fca1 Render Shadow with only one GL texture
Copies the shadow parts into one image and creates a GLTexture
from the image, so that we can render the complete shadow with
just one texture and one painting pass.

Should remove most of the overhead involved when rendering the new Shadows.

As a side effect this should fix missing shadows with non-NPOT GPUs and
a rendering glitch reported with NVIDIA.

REVIEW: 101742
2011-07-03 09:24:28 +02:00
Martin Gräßlin 04020f0b42 Deep copy of Shadow pixmap again
Basically revert of fb9afb61f8c1e7db4ae034435a9d54b5e87977d5.
Fixes an issue of black shadows which could sometimes happen in
OpenGL backend.
2011-06-19 20:54:14 +02:00
Martin Gräßlin 3775616a13 Do not deep copy the shadow pixmaps
The deep copy does not work with raster as it creates a non-native
pixmap. In fact the deep copy is not needed any more as it was a
safety check during development when apps using raster could crash
kwin.
2011-05-14 21:04:28 +02:00
Martin Gräßlin 911b037fe8 Add another pixmap safety check in Shadow creation
Do not only check for null pixmaps but also that the
pixmap contains a 32 bit depth as we don't want shadows
without alpha.
2011-05-14 21:02:11 +02:00
Jacopo De Simoi e688058235 kwin: Implement shadows in XRender compositor
There are still some glitches to be fixed, but
it works well for most use-cases.
2011-04-28 11:39:48 -04:00
Martin Gräßlin a9ce4aa2af Don't render a Shadow if the Shadow overlaps the window 2011-04-03 13:05:35 +02:00
Martin Gräßlin 7287019050 Update cached Shadow information on size changes
In order to notice when the geometry changes a new signal is
added to toplevel and both Unmanaged and Client connect all their
signals which are emitted whenever the geometry changes in some way
to this new signal.

Shadow connects to the signal and updates the quads and region
whenever the size changes.
2011-04-03 12:43:57 +02:00
Martin Gräßlin 38e9ab9a4e Move ownership on Shadow from Toplevel to Scene::Window
The Shadow is clearly an aspect of the compositor. Therefore the
Shadow has to be owned and controlled by the Scene::Window.
Nevertheless Toplevel needs to know about the Shadow cause of reading
the property.
2011-04-03 11:31:33 +02:00
Martin Gräßlin c82fed057f Verify that Shadow pixmaps are valid
At least in rekonq the shadow pixmaps are not valid causing
an exception to be thrown and crashing kwin.
2011-04-02 19:03:08 +02:00
Martin Gräßlin 89aa8ee8db Fix repainting of shadow after window closes
Unmanaged needs to repaint the complete geometry including shadow
when it ends compositing. Therefore we need to track the shadow
passing to deleted correctly. Disadvantage: when turning off
compositing the shadow is kept. Need to solve in a better way!
2011-04-01 21:49:44 +02:00