Commit Graph

39 Commits (b19c3c1c8e52870b704ae1eb2207721f87dc35dd)

Author SHA1 Message Date
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
Martin Gräßlin bd12134f05 Deep copy the shadow pixmaps
At least with NVIDIA drivers we get bad alloc errors in glXCreatePixmap
for the shared pixmaps.
2011-03-30 20:33:08 +02:00
Martin Gräßlin 12220a0d59 Initial implementation of new Shadows in KWin
For a complete documentation of new functionality refer to:
http://community.kde.org/KWin/Shadow

The current implementation includes a new Shadow class and Toplevel
holds a pointer to an instance of this class. The Shadow class reads
the data from the X11 Property. There is one extended class located
in SceneOpenGL to render the shadow.

Compositor is adjusted to include the shadow region into the painting
passes.

Implementation for XRender still missing and Shadow needs to respond
to size changes of the Toplevel to update cached shadow region and
WindowQuads.
2011-03-27 12:33:07 +02:00