2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
The base class for compositing, implementing shared functionality
|
|
|
|
between the OpenGL and XRender backends.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
Design:
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
When compositing is turned on, XComposite extension is used to redirect
|
|
|
|
drawing of windows to pixmaps and XDamage extension is used to get informed
|
|
|
|
about damage (changes) to window contents. This code is mostly in composite.cpp .
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-12-27 06:52:58 +00:00
|
|
|
Compositor::performCompositing() starts one painting pass. Painting is done
|
2007-04-29 17:35:43 +00:00
|
|
|
by painting the screen, which in turn paints every window. Painting can be affected
|
|
|
|
using effects, which are chained. E.g. painting a screen means that actually
|
|
|
|
paintScreen() of the first effect is called, which possibly does modifications
|
|
|
|
and calls next effect's paintScreen() and so on, until Scene::finalPaintScreen()
|
|
|
|
is called.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
There are 3 phases of every paint (not necessarily done together):
|
|
|
|
The pre-paint phase, the paint phase and the post-paint phase.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
The pre-paint phase is used to find out about how the painting will be actually
|
|
|
|
done (i.e. what the effects will do). For example when only a part of the screen
|
|
|
|
needs to be updated and no effect will do any transformation it is possible to use
|
|
|
|
an optimized paint function. How the painting will be done is controlled
|
|
|
|
by the mask argument, see PAINT_WINDOW_* and PAINT_SCREEN_* flags in scene.h .
|
|
|
|
For example an effect that decides to paint a normal windows as translucent
|
|
|
|
will need to modify the mask in its prePaintWindow() to include
|
|
|
|
the PAINT_WINDOW_TRANSLUCENT flag. The paintWindow() function will then get
|
|
|
|
the mask with this flag turned on and will also paint using transparency.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
The paint pass does the actual painting, based on the information collected
|
|
|
|
using the pre-paint pass. After running through the effects' paintScreen()
|
|
|
|
either paintGenericScreen() or optimized paintSimpleScreen() are called.
|
|
|
|
Those call paintWindow() on windows (not necessarily all), possibly using
|
|
|
|
clipping to optimize performance and calling paintWindow() first with only
|
|
|
|
PAINT_WINDOW_OPAQUE to paint the opaque parts and then later
|
|
|
|
with PAINT_WINDOW_TRANSLUCENT to paint the transparent parts. Function
|
|
|
|
paintWindow() again goes through effects' paintWindow() until
|
|
|
|
finalPaintWindow() is called, which calls the window's performPaint() to
|
|
|
|
do the actual painting.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
The post-paint can be used for cleanups and is also used for scheduling
|
|
|
|
repaints during the next painting pass for animations. Effects wanting to
|
|
|
|
repaint certain parts can manually damage them during post-paint and repaint
|
|
|
|
of these parts will be done during the next paint pass.
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
#include <QQuickWindow>
|
2012-03-29 18:17:57 +00:00
|
|
|
#include <QVector2D>
|
2012-03-25 18:06:26 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "deleted.h"
|
|
|
|
#include "effects.h"
|
2011-07-06 09:58:23 +00:00
|
|
|
#include "overlaywindow.h"
|
2014-11-25 07:40:23 +00:00
|
|
|
#include "screens.h"
|
2011-03-27 10:33:07 +00:00
|
|
|
#include "shadow.h"
|
2015-11-23 10:33:49 +00:00
|
|
|
#include "wayland_server.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-11-10 13:28:06 +00:00
|
|
|
#include "thumbnailitem.h"
|
2008-09-18 15:27:13 +00:00
|
|
|
|
2015-02-09 17:56:05 +00:00
|
|
|
#include <KWayland/Server/buffer_interface.h>
|
2016-03-21 15:37:45 +00:00
|
|
|
#include <KWayland/Server/subcompositor_interface.h>
|
2015-02-09 17:56:05 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Scene
|
|
|
|
//****************************************
|
|
|
|
|
2015-02-23 13:41:45 +00:00
|
|
|
Scene::Scene(QObject *parent)
|
|
|
|
: QObject(parent)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-10-29 14:55:56 +00:00
|
|
|
last_time.invalidate(); // Initialize the timer
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
Scene::~Scene()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-03-05 12:25:20 +00:00
|
|
|
Q_ASSERT(m_windows.isEmpty());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// returns mask and possibly modified region
|
2013-11-21 09:44:06 +00:00
|
|
|
void Scene::paintScreen(int* mask, const QRegion &damage, const QRegion &repaint,
|
2020-04-20 14:11:21 +00:00
|
|
|
QRegion *updateRegion, QRegion *validRegion, const QMatrix4x4 &projection, const QRect &outputGeometry, const qreal screenScale)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-11-25 07:40:23 +00:00
|
|
|
const QSize &screenSize = screens()->size();
|
|
|
|
const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height());
|
2013-11-23 14:08:17 +00:00
|
|
|
*mask = (damage == displayRegion) ? 0 : PAINT_SCREEN_REGION;
|
2013-02-18 22:17:46 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
updateTimeDiff();
|
|
|
|
// preparation step
|
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->startPaint();
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2013-11-23 14:08:17 +00:00
|
|
|
QRegion region = damage;
|
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
ScreenPrePaintData pdata;
|
|
|
|
pdata.mask = *mask;
|
2013-11-23 14:08:17 +00:00
|
|
|
pdata.paint = region;
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintScreen(pdata, time_diff);
|
2007-07-07 14:01:32 +00:00
|
|
|
*mask = pdata.mask;
|
2013-11-23 14:08:17 +00:00
|
|
|
region = pdata.paint;
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (*mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) {
|
|
|
|
// Region painting is not possible with transformations,
|
|
|
|
// because screen damage doesn't match transformed positions.
|
2007-04-29 17:35:43 +00:00
|
|
|
*mask &= ~PAINT_SCREEN_REGION;
|
2013-11-23 14:08:17 +00:00
|
|
|
region = infiniteRegion();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (*mask & PAINT_SCREEN_REGION) {
|
|
|
|
// make sure not to go outside visible screen
|
2013-11-23 14:08:17 +00:00
|
|
|
region &= displayRegion;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
// whole screen, not transformed, force region to be full
|
2013-11-23 14:08:17 +00:00
|
|
|
region = displayRegion;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-11-23 14:08:17 +00:00
|
|
|
|
|
|
|
painted_region = region;
|
2013-11-21 09:44:06 +00:00
|
|
|
repaint_region = repaint;
|
2013-11-23 14:08:17 +00:00
|
|
|
|
2012-01-29 17:20:50 +00:00
|
|
|
if (*mask & PAINT_SCREEN_BACKGROUND_FIRST) {
|
2013-11-23 14:08:17 +00:00
|
|
|
paintBackground(region);
|
2012-01-29 17:20:50 +00:00
|
|
|
}
|
2013-11-23 14:08:17 +00:00
|
|
|
|
2020-04-20 14:11:21 +00:00
|
|
|
ScreenPaintData data(projection, outputGeometry, screenScale);
|
2013-11-23 14:08:17 +00:00
|
|
|
effects->paintScreen(*mask, region, data);
|
|
|
|
|
|
|
|
foreach (Window *w, stacking_order) {
|
2012-01-29 17:20:50 +00:00
|
|
|
effects->postPaintWindow(effectWindow(w));
|
|
|
|
}
|
2013-11-23 14:08:17 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
effects->postPaintScreen();
|
2013-11-23 14:08:17 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// make sure not to go outside of the screen area
|
2013-11-21 09:44:06 +00:00
|
|
|
*updateRegion = damaged_region;
|
2013-11-23 14:08:17 +00:00
|
|
|
*validRegion = (region | painted_region) & displayRegion;
|
|
|
|
|
2013-11-21 09:44:06 +00:00
|
|
|
repaint_region = QRegion();
|
|
|
|
damaged_region = QRegion();
|
|
|
|
|
2008-02-25 11:32:21 +00:00
|
|
|
// make sure all clipping is restored
|
2011-01-30 14:34:42 +00:00
|
|
|
Q_ASSERT(!PaintClipper::clip());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Compute time since the last painting pass.
|
|
|
|
void Scene::updateTimeDiff()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-08-29 04:47:07 +00:00
|
|
|
if (!last_time.isValid()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// Painting has been idle (optimized out) for some time,
|
|
|
|
// which means time_diff would be huge and would break animations.
|
|
|
|
// Simply set it to one (zero would mean no change at all and could
|
|
|
|
// cause problems).
|
|
|
|
time_diff = 1;
|
2011-10-29 15:36:26 +00:00
|
|
|
last_time.start();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2012-03-29 20:11:28 +00:00
|
|
|
|
2013-04-10 20:14:17 +00:00
|
|
|
time_diff = last_time.restart();
|
2011-10-29 15:36:26 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (time_diff < 0) // check time rollback
|
2007-04-29 17:35:43 +00:00
|
|
|
time_diff = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Painting pass is optimized away.
|
|
|
|
void Scene::idle()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// Don't break time since last paint for the next pass.
|
2011-10-29 15:06:54 +00:00
|
|
|
last_time.invalidate();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// the function that'll be eventually called by paintScreen() above
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-29 16:25:20 +00:00
|
|
|
if (mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS))
|
2011-01-30 14:34:42 +00:00
|
|
|
paintGenericScreen(mask, data);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
paintSimpleScreen(mask, region);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// The generic painting code that can handle even transformations.
|
|
|
|
// It simply paints bottom-to-top.
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::paintGenericScreen(int orig_mask, const ScreenPaintData &)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-29 17:20:50 +00:00
|
|
|
if (!(orig_mask & PAINT_SCREEN_BACKGROUND_FIRST)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
paintBackground(infiniteRegion());
|
2012-01-29 17:20:50 +00:00
|
|
|
}
|
2019-01-11 19:55:04 +00:00
|
|
|
QVector<Phase2Data> phase2;
|
2019-01-12 13:39:16 +00:00
|
|
|
phase2.reserve(stacking_order.size());
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (Window * w, stacking_order) { // bottom to top
|
2011-07-06 08:01:23 +00:00
|
|
|
Toplevel* topw = w->window();
|
|
|
|
|
|
|
|
// Reset the repaint_region.
|
|
|
|
// This has to be done here because many effects schedule a repaint for
|
|
|
|
// the next frame within Effects::prePaintWindow.
|
2012-02-07 16:01:41 +00:00
|
|
|
topw->resetRepaints();
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
WindowPrePaintData data;
|
2011-01-30 14:34:42 +00:00
|
|
|
data.mask = orig_mask | (w->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT);
|
2007-04-29 17:35:43 +00:00
|
|
|
w->resetPaintingEnabled();
|
2007-07-07 14:01:32 +00:00
|
|
|
data.paint = infiniteRegion(); // no clipping, so doesn't really matter
|
|
|
|
data.clip = QRegion();
|
2007-07-18 15:01:59 +00:00
|
|
|
data.quads = w->buildQuads();
|
2007-04-29 17:35:43 +00:00
|
|
|
// preparation step
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintWindow(effectWindow(w), data, time_diff);
|
2019-08-31 14:28:37 +00:00
|
|
|
#if !defined(QT_NO_DEBUG)
|
2012-01-29 16:25:20 +00:00
|
|
|
if (data.quads.isTransformed()) {
|
2013-09-02 16:42:20 +00:00
|
|
|
qFatal("Pre-paint calls are not allowed to transform quads!");
|
2012-01-29 16:25:20 +00:00
|
|
|
}
|
2007-07-19 16:11:27 +00:00
|
|
|
#endif
|
2012-01-29 17:20:50 +00:00
|
|
|
if (!w->isPaintingEnabled()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2012-01-29 17:20:50 +00:00
|
|
|
}
|
2019-01-12 12:39:28 +00:00
|
|
|
phase2.append({w, infiniteRegion(), data.clip, data.mask, data.quads});
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2012-01-29 16:25:20 +00:00
|
|
|
foreach (const Phase2Data & d, phase2) {
|
|
|
|
paintWindow(d.window, d.mask, d.region, d.quads);
|
|
|
|
}
|
2013-11-21 09:44:06 +00:00
|
|
|
|
2014-11-25 07:40:23 +00:00
|
|
|
const QSize &screenSize = screens()->size();
|
|
|
|
damaged_region = QRegion(0, 0, screenSize.width(), screenSize.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// The optimized case without any transformations at all.
|
|
|
|
// It can paint only the requested region and can use clipping
|
|
|
|
// to reduce painting and improve performance.
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::paintSimpleScreen(int orig_mask, const QRegion ®ion)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT((orig_mask & (PAINT_SCREEN_TRANSFORMED
|
2012-01-29 16:25:20 +00:00
|
|
|
| PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) == 0);
|
2019-01-11 16:26:22 +00:00
|
|
|
QVector<Phase2Data> phase2data;
|
2019-01-12 13:39:16 +00:00
|
|
|
phase2data.reserve(stacking_order.size());
|
2011-07-06 08:01:23 +00:00
|
|
|
|
|
|
|
QRegion dirtyArea = region;
|
2019-09-27 13:59:44 +00:00
|
|
|
bool opaqueFullscreen = false;
|
|
|
|
|
|
|
|
// Traverse the scene windows from bottom to top.
|
|
|
|
for (int i = 0; i < stacking_order.count(); ++i) {
|
|
|
|
Window *window = stacking_order[i];
|
|
|
|
Toplevel *toplevel = window->window();
|
2007-07-07 14:01:32 +00:00
|
|
|
WindowPrePaintData data;
|
2019-09-27 13:59:44 +00:00
|
|
|
data.mask = orig_mask | (window->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT);
|
|
|
|
window->resetPaintingEnabled();
|
2007-07-07 14:01:32 +00:00
|
|
|
data.paint = region;
|
2019-09-27 13:59:44 +00:00
|
|
|
data.paint |= toplevel->repaints();
|
2011-07-06 08:01:23 +00:00
|
|
|
|
|
|
|
// Reset the repaint_region.
|
|
|
|
// This has to be done here because many effects schedule a repaint for
|
|
|
|
// the next frame within Effects::prePaintWindow.
|
2019-09-27 13:59:44 +00:00
|
|
|
toplevel->resetRepaints();
|
2012-02-21 18:22:08 +00:00
|
|
|
|
2009-04-22 17:29:56 +00:00
|
|
|
// Clip out the decoration for opaque windows; the decoration is drawn in the second pass
|
2013-02-18 22:17:46 +00:00
|
|
|
opaqueFullscreen = false; // TODO: do we care about unmanged windows here (maybe input windows?)
|
2019-09-27 13:59:44 +00:00
|
|
|
if (window->isOpaque()) {
|
|
|
|
AbstractClient *client = dynamic_cast<AbstractClient *>(toplevel);
|
|
|
|
if (client) {
|
|
|
|
opaqueFullscreen = client->isFullScreen();
|
2012-10-12 09:34:05 +00:00
|
|
|
}
|
2019-09-27 10:33:42 +00:00
|
|
|
if (!(client && client->decorationHasAlpha())) {
|
|
|
|
data.clip = window->decorationShape().translated(window->pos());
|
2012-10-12 09:34:05 +00:00
|
|
|
}
|
2019-09-27 10:33:42 +00:00
|
|
|
data.clip |= window->clientShape().translated(window->pos() + window->bufferOffset());
|
2019-09-27 13:59:44 +00:00
|
|
|
} else if (toplevel->hasAlpha() && toplevel->opacity() == 1.0) {
|
2019-09-27 10:33:42 +00:00
|
|
|
const QRegion clientShape = window->clientShape().translated(window->pos() + window->bufferOffset());
|
|
|
|
const QRegion opaqueShape = toplevel->opaqueRegion().translated(window->pos() + toplevel->clientPos());
|
|
|
|
data.clip = clientShape & opaqueShape;
|
2011-10-22 09:02:49 +00:00
|
|
|
} else {
|
|
|
|
data.clip = QRegion();
|
|
|
|
}
|
2019-09-27 13:59:44 +00:00
|
|
|
data.quads = window->buildQuads();
|
2007-04-29 17:35:43 +00:00
|
|
|
// preparation step
|
2019-09-27 13:59:44 +00:00
|
|
|
effects->prePaintWindow(effectWindow(window), data, time_diff);
|
2019-08-31 14:28:37 +00:00
|
|
|
#if !defined(QT_NO_DEBUG)
|
2012-01-29 16:25:20 +00:00
|
|
|
if (data.quads.isTransformed()) {
|
2013-09-02 16:42:20 +00:00
|
|
|
qFatal("Pre-paint calls are not allowed to transform quads!");
|
2012-01-29 16:25:20 +00:00
|
|
|
}
|
2007-07-19 16:11:27 +00:00
|
|
|
#endif
|
2019-09-27 13:59:44 +00:00
|
|
|
if (!window->isPaintingEnabled()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-07-14 12:17:33 +00:00
|
|
|
dirtyArea |= data.paint;
|
2007-12-07 17:03:59 +00:00
|
|
|
// Schedule the window for painting
|
2019-09-27 13:59:44 +00:00
|
|
|
phase2data.append({ window, data.paint, data.clip, data.mask, data.quads });
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-01-10 17:56:14 +00:00
|
|
|
|
2013-11-21 09:44:06 +00:00
|
|
|
// Save the part of the repaint region that's exclusively rendered to
|
|
|
|
// bring a reused back buffer up to date. Then union the dirty region
|
|
|
|
// with the repaint region.
|
|
|
|
const QRegion repaintClip = repaint_region - dirtyArea;
|
|
|
|
dirtyArea |= repaint_region;
|
2013-02-18 22:17:46 +00:00
|
|
|
|
2014-11-25 07:40:23 +00:00
|
|
|
const QSize &screenSize = screens()->size();
|
|
|
|
const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height());
|
2013-02-18 22:17:46 +00:00
|
|
|
bool fullRepaint(dirtyArea == displayRegion); // spare some expensive region operations
|
|
|
|
if (!fullRepaint) {
|
|
|
|
extendPaintRegion(dirtyArea, opaqueFullscreen);
|
|
|
|
fullRepaint = (dirtyArea == displayRegion);
|
|
|
|
}
|
|
|
|
|
2011-07-06 08:01:23 +00:00
|
|
|
QRegion allclips, upperTranslucentDamage;
|
2013-11-21 09:44:06 +00:00
|
|
|
upperTranslucentDamage = repaint_region;
|
|
|
|
|
2013-02-18 22:17:46 +00:00
|
|
|
// This is the occlusion culling pass
|
2012-01-10 17:56:14 +00:00
|
|
|
for (int i = phase2data.count() - 1; i >= 0; --i) {
|
2019-01-11 16:26:22 +00:00
|
|
|
Phase2Data *data = &phase2data[i];
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2019-09-27 13:59:44 +00:00
|
|
|
if (fullRepaint) {
|
2013-02-18 22:17:46 +00:00
|
|
|
data->region = displayRegion;
|
2019-09-27 13:59:44 +00:00
|
|
|
} else {
|
2013-02-18 22:17:46 +00:00
|
|
|
data->region |= upperTranslucentDamage;
|
2019-09-27 13:59:44 +00:00
|
|
|
}
|
2012-02-07 16:01:41 +00:00
|
|
|
|
2012-01-10 17:56:14 +00:00
|
|
|
// subtract the parts which will possibly been drawn as part of
|
2011-07-06 08:01:23 +00:00
|
|
|
// a higher opaque window
|
|
|
|
data->region -= allclips;
|
|
|
|
|
2011-10-22 09:02:49 +00:00
|
|
|
// Here we rely on WindowPrePaintData::setTranslucent() to remove
|
|
|
|
// the clip if needed.
|
2019-01-13 21:25:43 +00:00
|
|
|
if (!data->clip.isEmpty() && !(data->mask & PAINT_WINDOW_TRANSLUCENT)) {
|
2012-01-10 17:56:14 +00:00
|
|
|
// clip away the opaque regions for all windows below this one
|
2011-07-06 08:01:23 +00:00
|
|
|
allclips |= data->clip;
|
2012-01-10 17:56:14 +00:00
|
|
|
// extend the translucent damage for windows below this by remaining (translucent) regions
|
2019-09-27 13:59:44 +00:00
|
|
|
if (!fullRepaint) {
|
2013-02-18 22:17:46 +00:00
|
|
|
upperTranslucentDamage |= data->region - data->clip;
|
2019-09-27 13:59:44 +00:00
|
|
|
}
|
2013-02-18 22:17:46 +00:00
|
|
|
} else if (!fullRepaint) {
|
2012-01-10 17:56:14 +00:00
|
|
|
upperTranslucentDamage |= data->region;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2012-01-10 17:56:14 +00:00
|
|
|
QRegion paintedArea;
|
2011-07-06 08:01:23 +00:00
|
|
|
// Fill any areas of the root window not covered by opaque windows
|
|
|
|
if (!(orig_mask & PAINT_SCREEN_BACKGROUND_FIRST)) {
|
2012-01-10 17:56:14 +00:00
|
|
|
paintedArea = dirtyArea - allclips;
|
|
|
|
paintBackground(paintedArea);
|
2011-07-06 08:01:23 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 17:56:14 +00:00
|
|
|
// Now walk the list bottom to top and draw the windows.
|
|
|
|
for (int i = 0; i < phase2data.count(); ++i) {
|
2019-01-11 16:26:22 +00:00
|
|
|
Phase2Data *data = &phase2data[i];
|
2011-07-06 08:01:23 +00:00
|
|
|
|
2012-01-10 17:56:14 +00:00
|
|
|
// add all regions which have been drawn so far
|
|
|
|
paintedArea |= data->region;
|
|
|
|
data->region = paintedArea;
|
2011-07-06 08:01:23 +00:00
|
|
|
|
|
|
|
paintWindow(data->window, data->mask, data->region, data->quads);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-11-21 09:44:06 +00:00
|
|
|
|
|
|
|
if (fullRepaint) {
|
2013-02-18 22:17:46 +00:00
|
|
|
painted_region = displayRegion;
|
2020-04-14 02:35:09 +00:00
|
|
|
damaged_region = displayRegion - repaintClip;
|
2013-11-21 09:44:06 +00:00
|
|
|
} else {
|
2013-02-18 22:17:46 +00:00
|
|
|
painted_region |= paintedArea;
|
2013-11-21 09:44:06 +00:00
|
|
|
|
|
|
|
// Clip the repainted region from the damaged region.
|
|
|
|
// It's important that we don't add the union of the damaged region
|
|
|
|
// and the repainted region to the damage history. Otherwise the
|
|
|
|
// repaint region will grow with every frame until it eventually
|
|
|
|
// covers the whole back buffer, at which point we're always doing
|
|
|
|
// full repaints.
|
|
|
|
damaged_region = paintedArea - repaintClip;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-01-11 18:55:17 +00:00
|
|
|
void Scene::addToplevel(Toplevel *c)
|
2013-06-24 07:53:11 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!m_windows.contains(c));
|
2013-06-24 07:53:11 +00:00
|
|
|
Scene::Window *w = createWindow(c);
|
|
|
|
m_windows[ c ] = w;
|
|
|
|
connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SLOT(windowGeometryShapeChanged(KWin::Toplevel*)));
|
|
|
|
connect(c, SIGNAL(windowClosed(KWin::Toplevel*,KWin::Deleted*)), SLOT(windowClosed(KWin::Toplevel*,KWin::Deleted*)));
|
2017-08-24 16:57:38 +00:00
|
|
|
//A change of scale won't affect the geometry in compositor co-ordinates, but will affect the window quads.
|
|
|
|
if (c->surface()) {
|
|
|
|
connect(c->surface(), &KWayland::Server::SurfaceInterface::scaleChanged, this, std::bind(&Scene::windowGeometryShapeChanged, this, c));
|
|
|
|
}
|
Add context object to screenScaleChanged connection
Currently internal window test fails because several internal clients
outlive tests where each one of them was created. Given that the scene
doesn't specify the context object when it creates screenScaleChanged
connection, we may call windowGeometryShapeChanged on a deleted scene
object.
ASAN output:
=================================================================
==23416==ERROR: AddressSanitizer: heap-use-after-free on address 0x60800005ffe0 at pc 0x7fdfb0451c26 bp 0x7fffc32fefb0 sp 0x7fffc32fefa8
READ of size 8 at 0x60800005ffe0 thread T0
#0 0x7fdfb0451c25 in QHash<KWin::Toplevel*, KWin::Scene::Window*>::findNode(KWin::Toplevel* const&, unsigned int*) const /usr/include/qt5/QtCore/qhash.h:933
#1 0x7fdfb044c1eb in QHash<KWin::Toplevel*, KWin::Scene::Window*>::contains(KWin::Toplevel* const&) const /usr/include/qt5/QtCore/qhash.h:908
#2 0x7fdfb04369c1 in KWin::Scene::windowGeometryShapeChanged(KWin::Toplevel*) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/scene.cpp:440
#3 0x7fdfb045c017 in void std::__invoke_impl<void, void (KWin::Scene::*&)(KWin::Toplevel*), KWin::Scene*&, KWin::Toplevel*&>(std::__invoke_memfun_deref, void (KWin::Scene::*&)(KWin::Toplevel*), KWin::Scene*&, KWin::Toplevel*&) /usr/include/c++/9/bits/invoke.h:73
#4 0x7fdfb045ba9c in std::__invoke_result<void (KWin::Scene::*&)(KWin::Toplevel*), KWin::Scene*&, KWin::Toplevel*&>::type std::__invoke<void (KWin::Scene::*&)(KWin::Toplevel*), KWin::Scene*&, KWin::Toplevel*&>(void (KWin::Scene::*&)(KWin::Toplevel*), KWin::Scene*&, KWin::Toplevel*&) /usr/include/c++/9/bits/invoke.h:95
#5 0x7fdfb045bc84 in void std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) /usr/include/c++/9/functional:400
#6 0x7fdfb045b7c0 in void std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>::operator()<, void>() /usr/include/c++/9/functional:484
#7 0x7fdfb045b3c2 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)> >::call(std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>&, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:146
#8 0x7fdfb045abd4 in void QtPrivate::Functor<std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>, 0>::call<QtPrivate::List<>, void>(std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>&, void*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:256
#9 0x7fdfb045a5b6 in QtPrivate::QFunctorSlotObject<std::_Bind<void (KWin::Scene::*(KWin::Scene*, KWin::Toplevel*))(KWin::Toplevel*)>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/qt5/QtCore/qobjectdefs_impl.h:439
#10 0x7fdfa5794137 in QMetaObject::activate(QObject*, int, int, void**) (/usr/lib64/libQt5Core.so.5+0x2b3137)
#11 0x7fdfafeea2ca in KWin::Toplevel::screenScaleChanged() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/kwin_autogen/EWIEGA46WW/moc_toplevel.cpp:834
#12 0x7fdfb0425712 in KWin::Toplevel::checkScreen() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/toplevel.cpp:538
#13 0x7fdfafee3221 in KWin::Toplevel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/kwin_autogen/EWIEGA46WW/moc_toplevel.cpp:371
#14 0x7fdfa5793fd7 in QMetaObject::activate(QObject*, int, int, void**) (/usr/lib64/libQt5Core.so.5+0x2b2fd7)
#15 0x7fdfafedefca in KWin::Screens::changed() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/kwin_autogen/EWIEGA46WW/moc_screens.cpp:276
#16 0x7fdf9a199281 in operator() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/plugins/platforms/virtual/screens_virtual.cpp:45
#17 0x7fdf9a199c7b in call /usr/include/qt5/QtCore/qobjectdefs_impl.h:146
#18 0x7fdf9a199b50 in call<QtPrivate::List<bool>, void> /usr/include/qt5/QtCore/qobjectdefs_impl.h:256
#19 0x7fdf9a199afc in impl /usr/include/qt5/QtCore/qobjectdefs_impl.h:439
#20 0x7fdfa5794137 in QMetaObject::activate(QObject*, int, int, void**) (/usr/lib64/libQt5Core.so.5+0x2b3137)
#21 0x7fdf9a17a37b in KWin::VirtualBackend::virtualOutputsSet(bool) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/plugins/platforms/virtual/KWinWaylandVirtualBackend_autogen/EWIEGA46WW/moc_virtual_backend.cpp:177
#22 0x7fdf9a18c476 in KWin::VirtualBackend::setVirtualOutputs(int, QVector<QRect>, QVector<int>) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/plugins/platforms/virtual/virtual_backend.cpp:141
#23 0x7fdf9a1794e2 in KWin::VirtualBackend::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/plugins/platforms/virtual/KWinWaylandVirtualBackend_autogen/EWIEGA46WW/moc_virtual_backend.cpp:94
#24 0x7fdfa577794a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/usr/lib64/libQt5Core.so.5+0x29694a)
#25 0x7fdfa57790d1 in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (/usr/lib64/libQt5Core.so.5+0x2980d1)
#26 0x45a3e0 in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) /usr/include/qt5/QtCore/qobjectdefs.h:444
#27 0x44bf37 in KWin::InternalWindowTest::testScale() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/autotests/integration/internal_window.cpp:693
#28 0x4562ec in KWin::InternalWindowTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/autotests/integration/testInternalWindow_autogen/include/internal_window.moc:169
#29 0x7fdfa577794a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/usr/lib64/libQt5Core.so.5+0x29694a)
#30 0x7fdfaf047962 (/usr/lib64/libQt5Test.so.5+0x19962)
#31 0x7fdfaf048352 (/usr/lib64/libQt5Test.so.5+0x1a352)
#32 0x7fdfaf048910 (/usr/lib64/libQt5Test.so.5+0x1a910)
#33 0x7fdfaf048cda in QTest::qRun() (/usr/lib64/libQt5Test.so.5+0x1acda)
#34 0x7fdfaf048edb in QTest::qExec(QObject*, int, char**) (/usr/lib64/libQt5Test.so.5+0x1aedb)
#35 0x455d7b in main /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/autotests/integration/internal_window.cpp:807
#36 0x7fdfa5002bca in __libc_start_main (/lib64/libc.so.6+0x26bca)
#37 0x415029 in _start (/home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/bin/testInternalWindow+0x415029)
0x60800005ffe0 is located 64 bytes inside of 96-byte region [0x60800005ffa0,0x608000060000)
freed by thread T0 here:
#0 0x7fdfb2042595 in operator delete(void*, unsigned long) (/usr/lib64/libasan.so.5+0x10d595)
#1 0x7fdf98774c4e in KWin::SceneQPainter::~SceneQPainter() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/plugins/scenes/qpainter/scene_qpainter.cpp:70
#2 0x7fdfb03fef41 in KWin::Compositor::stop() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/composite.cpp:451
#3 0x7fdfb03fffe6 in KWin::Compositor::reinitialize() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/composite.cpp:527
#4 0x7fdfb03ffe2f in KWin::Compositor::configChanged() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/composite.cpp:517
#5 0x7fdfaffaf481 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWin::Compositor::*)()>::call(void (KWin::Compositor::*)(), KWin::Compositor*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:152
#6 0x7fdfaffa4deb in void QtPrivate::FunctionPointer<void (KWin::Compositor::*)()>::call<QtPrivate::List<>, void>(void (KWin::Compositor::*)(), KWin::Compositor*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:185
#7 0x7fdfaff9c765 in QtPrivate::QSlotObject<void (KWin::Compositor::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/qt5/QtCore/qobjectdefs_impl.h:414
#8 0x7fdfa5794137 in QMetaObject::activate(QObject*, int, int, void**) (/usr/lib64/libQt5Core.so.5+0x2b3137)
#9 0x7fdfafed441e in KWin::Options::configChanged() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/kwin_autogen/EWIEGA46WW/moc_options.cpp:1790
#10 0x7fdfb02584c6 in KWin::Options::updateSettings() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/options.cpp:772
#11 0x7fdfaff461db in KWin::Workspace::slotReconfigure() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/workspace.cpp:897
#12 0x446f67 in KWin::InternalWindowTest::testModifierClickUnrestrictedMove() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/autotests/integration/internal_window.cpp:620
#13 0x45624d in KWin::InternalWindowTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/build/autotests/integration/testInternalWindow_autogen/include/internal_window.moc:166
#14 0x7fdfa577794a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/usr/lib64/libQt5Core.so.5+0x29694a)
#15 0x7fdfaf047962 (/usr/lib64/libQt5Test.so.5+0x19962)
#16 0x7fdfaf048352 (/usr/lib64/libQt5Test.so.5+0x1a352)
previously allocated by thread T0 here:
#0 0x7fdfb204110f in operator new(unsigned long) (/usr/lib64/libasan.so.5+0x10c10f)
#1 0x7fdf98774992 in KWin::SceneQPainter::createScene(QObject*) /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/plugins/scenes/qpainter/scene_qpainter.cpp:58
#2 0x7fdf9878db95 in KWin::QPainterFactory::create(QObject*) const /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/plugins/scenes/qpainter/scene_qpainter.cpp:870
#3 0x7fdfb03f9488 in KWin::Compositor::setupStart() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/composite.cpp:238
#4 0x7fdfb0404ca4 in KWin::WaylandCompositor::start() /home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.12/composite.cpp:862
#5 0x7fdfaffaf481 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWin::Compositor::*)()>::call(void (KWin::Compositor::*)(), KWin::Compositor*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:152
#6 0x7fdfaffa4deb in void QtPrivate::FunctionPointer<void (KWin::Compositor::*)()>::call<QtPrivate::List<>, void>(void (KWin::Compositor::*)(), KWin::Compositor*, void**) /usr/include/qt5/QtCore/qobjectdefs_impl.h:185
#7 0x7fdfaff9c765 in QtPrivate::QSlotObject<void (KWin::Compositor::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) /usr/include/qt5/QtCore/qobjectdefs_impl.h:414
#8 0x7fdfa57a0df1 (/usr/lib64/libQt5Core.so.5+0x2bfdf1)
SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/qt5/QtCore/qhash.h:933 in QHash<KWin::Toplevel*, KWin::Scene::Window*>::findNode(KWin::Toplevel* const&, unsigned int*) const
Shadow bytes around the buggy address:
0x0c1080003fa0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x0c1080003fb0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x0c1080003fc0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x0c1080003fd0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
0x0c1080003fe0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
=>0x0c1080003ff0: fa fa fa fa fd fd fd fd fd fd fd fd[fd]fd fd fd
0x0c1080004000: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c1080004010: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 05 fa
0x0c1080004020: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x0c1080004030: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 04
0x0c1080004040: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 01
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==23416==ABORTING
(EE) failed to read Wayland events: Connection reset by peer
2019-09-10 11:37:22 +00:00
|
|
|
connect(c, &Toplevel::screenScaleChanged, this,
|
|
|
|
[this, c] {
|
|
|
|
windowGeometryShapeChanged(c);
|
|
|
|
}
|
|
|
|
);
|
2013-06-24 07:53:11 +00:00
|
|
|
c->effectWindow()->setSceneWindow(w);
|
2019-09-29 11:26:04 +00:00
|
|
|
c->updateShadow();
|
2013-06-24 07:53:11 +00:00
|
|
|
w->updateShadow(c->shadow());
|
Try to invalidate quad cache when shadow is changed
Summary:
213239a0ea0a9c0967bb68d1eda7a8d4d6a09498 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-11-27 13:25:22 +00:00
|
|
|
connect(c, &Toplevel::shadowChanged, this,
|
|
|
|
[w] {
|
|
|
|
w->invalidateQuadsCache();
|
|
|
|
}
|
|
|
|
);
|
2013-06-24 07:53:11 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 18:55:17 +00:00
|
|
|
void Scene::removeToplevel(Toplevel *toplevel)
|
2013-06-24 07:53:11 +00:00
|
|
|
{
|
2019-01-11 18:55:17 +00:00
|
|
|
Q_ASSERT(m_windows.contains(toplevel));
|
|
|
|
delete m_windows.take(toplevel);
|
|
|
|
toplevel->effectWindow()->setSceneWindow(nullptr);
|
2013-06-24 07:53:11 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 18:55:17 +00:00
|
|
|
void Scene::windowClosed(Toplevel *toplevel, Deleted *deleted)
|
2013-06-24 07:53:11 +00:00
|
|
|
{
|
2019-01-11 18:55:17 +00:00
|
|
|
if (!deleted) {
|
|
|
|
removeToplevel(toplevel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_ASSERT(m_windows.contains(toplevel));
|
|
|
|
Window *window = m_windows.take(toplevel);
|
|
|
|
window->updateToplevel(deleted);
|
|
|
|
if (window->shadow()) {
|
|
|
|
window->shadow()->setToplevel(deleted);
|
|
|
|
}
|
|
|
|
m_windows[deleted] = window;
|
2013-06-24 07:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::windowGeometryShapeChanged(Toplevel *c)
|
|
|
|
{
|
|
|
|
if (!m_windows.contains(c)) // this is ok, shape is not valid by default
|
|
|
|
return;
|
|
|
|
Window *w = m_windows[ c ];
|
|
|
|
w->discardShape();
|
|
|
|
}
|
|
|
|
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::createStackingOrder(const QList<Toplevel *> &toplevels)
|
2013-06-24 07:53:11 +00:00
|
|
|
{
|
|
|
|
// TODO: cache the stacking_order in case it has not changed
|
|
|
|
foreach (Toplevel *c, toplevels) {
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(m_windows.contains(c));
|
2013-06-24 07:53:11 +00:00
|
|
|
stacking_order.append(m_windows[ c ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::clearStackingOrder()
|
|
|
|
{
|
|
|
|
stacking_order.clear();
|
|
|
|
}
|
|
|
|
|
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 14:46:54 +00:00
|
|
|
static Scene::Window *s_recursionCheck = nullptr;
|
2012-03-29 18:17:57 +00:00
|
|
|
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::paintWindow(Window* w, int mask, const QRegion &_region, const WindowQuadList &quads)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-12-07 17:03:59 +00:00
|
|
|
// no painting outside visible screen (and no transformations)
|
2020-03-13 16:41:56 +00:00
|
|
|
const QRegion region = _region & QRect({0, 0}, screens()->size());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (region.isEmpty()) // completely clipped
|
2007-12-07 17:03:59 +00:00
|
|
|
return;
|
2014-01-24 11:34:16 +00:00
|
|
|
if (w->window()->isDeleted() && w->window()->skipsCloseAnimation()) {
|
|
|
|
// should not get painted
|
|
|
|
return;
|
|
|
|
}
|
2007-12-07 17:03:59 +00:00
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
if (s_recursionCheck == w) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:35:12 +00:00
|
|
|
WindowPaintData data(w->window()->effectWindow(), screenProjectionMatrix());
|
2007-07-07 14:01:32 +00:00
|
|
|
data.quads = quads;
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(effectWindow(w), mask, region, data);
|
2011-11-10 13:28:06 +00:00
|
|
|
// paint thumbnails on top of window
|
2012-03-29 18:17:57 +00:00
|
|
|
paintWindowThumbnails(w, region, data.opacity(), data.brightness(), data.saturation());
|
|
|
|
// and desktop thumbnails
|
|
|
|
paintDesktopThumbnails(w);
|
|
|
|
}
|
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
static void adjustClipRegion(AbstractThumbnailItem *item, QRegion &clippingRegion)
|
|
|
|
{
|
|
|
|
if (item->clip() && item->clipTo()) {
|
|
|
|
// the x/y positions of the parent item are not correct. The margins are added, though the size seems fine
|
|
|
|
// that's why we have to get the offset by inspecting the anchors properties
|
|
|
|
QQuickItem *parentItem = item->clipTo();
|
|
|
|
QPointF offset;
|
|
|
|
QVariant anchors = parentItem->property("anchors");
|
|
|
|
if (anchors.isValid()) {
|
|
|
|
if (QObject *anchorsObject = anchors.value<QObject*>()) {
|
|
|
|
offset.setX(anchorsObject->property("leftMargin").toReal());
|
|
|
|
offset.setY(anchorsObject->property("topMargin").toReal());
|
|
|
|
}
|
|
|
|
}
|
2014-05-23 18:39:21 +00:00
|
|
|
QRectF rect = QRectF(parentItem->position() - offset, QSizeF(parentItem->width(), parentItem->height()));
|
|
|
|
if (QQuickItem *p = parentItem->parentItem()) {
|
|
|
|
rect = p->mapRectToScene(rect);
|
|
|
|
}
|
2013-08-08 09:39:39 +00:00
|
|
|
clippingRegion &= rect.adjusted(0,0,-1,-1).translated(item->window()->position()).toRect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::paintWindowThumbnails(Scene::Window *w, const QRegion ®ion, qreal opacity, qreal brightness, qreal saturation)
|
2012-03-29 18:17:57 +00:00
|
|
|
{
|
2011-11-10 13:28:06 +00:00
|
|
|
EffectWindowImpl *wImpl = static_cast<EffectWindowImpl*>(effectWindow(w));
|
2019-08-10 11:31:49 +00:00
|
|
|
for (QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> >::const_iterator it = wImpl->thumbnails().constBegin();
|
2011-11-10 13:28:06 +00:00
|
|
|
it != wImpl->thumbnails().constEnd();
|
|
|
|
++it) {
|
|
|
|
if (it.value().isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-03-29 13:46:53 +00:00
|
|
|
WindowThumbnailItem *item = it.key();
|
2011-11-10 13:28:06 +00:00
|
|
|
if (!item->isVisible()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
EffectWindowImpl *thumb = it.value().data();
|
2015-11-30 13:35:12 +00:00
|
|
|
WindowPaintData thumbData(thumb, screenProjectionMatrix());
|
2012-03-29 18:17:57 +00:00
|
|
|
thumbData.setOpacity(opacity);
|
|
|
|
thumbData.setBrightness(brightness * item->brightness());
|
|
|
|
thumbData.setSaturation(saturation * item->saturation());
|
2011-11-10 13:28:06 +00:00
|
|
|
|
2012-09-07 13:57:28 +00:00
|
|
|
const QRect visualThumbRect(thumb->expandedGeometry());
|
|
|
|
|
|
|
|
QSizeF size = QSizeF(visualThumbRect.size());
|
2012-03-24 09:40:44 +00:00
|
|
|
size.scale(QSizeF(item->width(), item->height()), Qt::KeepAspectRatio);
|
2012-09-07 13:57:28 +00:00
|
|
|
if (size.width() > visualThumbRect.width() || size.height() > visualThumbRect.height()) {
|
|
|
|
size = QSizeF(visualThumbRect.size());
|
2012-07-09 17:34:20 +00:00
|
|
|
}
|
2012-09-19 18:21:18 +00:00
|
|
|
thumbData.setXScale(size.width() / static_cast<qreal>(visualThumbRect.width()));
|
|
|
|
thumbData.setYScale(size.height() / static_cast<qreal>(visualThumbRect.height()));
|
2012-03-29 18:17:57 +00:00
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
if (!item->window()) {
|
2012-03-25 18:06:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-12-12 21:09:52 +00:00
|
|
|
const QPointF point = item->mapToScene(QPointF(0,0));
|
2012-09-19 18:21:18 +00:00
|
|
|
qreal x = point.x() + w->x() + (item->width() - size.width())/2;
|
|
|
|
qreal y = point.y() + w->y() + (item->height() - size.height()) / 2;
|
|
|
|
x -= thumb->x();
|
|
|
|
y -= thumb->y();
|
2012-09-07 13:57:28 +00:00
|
|
|
// compensate shadow topleft padding
|
2012-09-19 18:49:55 +00:00
|
|
|
x += (thumb->x()-visualThumbRect.x())*thumbData.xScale();
|
|
|
|
y += (thumb->y()-visualThumbRect.y())*thumbData.yScale();
|
2012-09-19 18:21:18 +00:00
|
|
|
thumbData.setXTranslation(x);
|
|
|
|
thumbData.setYTranslation(y);
|
2011-11-10 13:28:06 +00:00
|
|
|
int thumbMask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS;
|
2012-07-12 15:20:17 +00:00
|
|
|
if (thumbData.opacity() == 1.0) {
|
2011-11-10 13:28:06 +00:00
|
|
|
thumbMask |= PAINT_WINDOW_OPAQUE;
|
|
|
|
} else {
|
|
|
|
thumbMask |= PAINT_WINDOW_TRANSLUCENT;
|
|
|
|
}
|
2012-03-24 13:51:28 +00:00
|
|
|
QRegion clippingRegion = region;
|
|
|
|
clippingRegion &= QRegion(wImpl->x(), wImpl->y(), wImpl->width(), wImpl->height());
|
2013-08-08 09:39:39 +00:00
|
|
|
adjustClipRegion(item, clippingRegion);
|
2012-03-24 13:51:28 +00:00
|
|
|
effects->drawWindow(thumb, thumbMask, clippingRegion, thumbData);
|
2011-11-10 13:28:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
void Scene::paintDesktopThumbnails(Scene::Window *w)
|
|
|
|
{
|
|
|
|
EffectWindowImpl *wImpl = static_cast<EffectWindowImpl*>(effectWindow(w));
|
|
|
|
for (QList<DesktopThumbnailItem*>::const_iterator it = wImpl->desktopThumbnails().constBegin();
|
|
|
|
it != wImpl->desktopThumbnails().constEnd();
|
|
|
|
++it) {
|
|
|
|
DesktopThumbnailItem *item = *it;
|
|
|
|
if (!item->isVisible()) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-08-08 09:39:39 +00:00
|
|
|
if (!item->window()) {
|
2012-03-29 18:17:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
s_recursionCheck = w;
|
|
|
|
|
|
|
|
ScreenPaintData data;
|
2014-11-25 07:40:23 +00:00
|
|
|
const QSize &screenSize = screens()->size();
|
|
|
|
QSize size = screenSize;
|
2012-03-29 18:17:57 +00:00
|
|
|
|
|
|
|
size.scale(item->width(), item->height(), Qt::KeepAspectRatio);
|
2014-11-25 07:40:23 +00:00
|
|
|
data *= QVector2D(size.width() / double(screenSize.width()),
|
|
|
|
size.height() / double(screenSize.height()));
|
2013-08-08 09:39:39 +00:00
|
|
|
const QPointF point = item->mapToScene(item->position());
|
2012-03-29 18:17:57 +00:00
|
|
|
const qreal x = point.x() + w->x() + (item->width() - size.width())/2;
|
|
|
|
const qreal y = point.y() + w->y() + (item->height() - size.height()) / 2;
|
|
|
|
const QRect region = QRect(x, y, item->width(), item->height());
|
|
|
|
QRegion clippingRegion = region;
|
|
|
|
clippingRegion &= QRegion(wImpl->x(), wImpl->y(), wImpl->width(), wImpl->height());
|
2013-08-08 09:39:39 +00:00
|
|
|
adjustClipRegion(item, clippingRegion);
|
2012-03-29 18:17:57 +00:00
|
|
|
data += QPointF(x, y);
|
|
|
|
const int desktopMask = PAINT_SCREEN_TRANSFORMED | PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
|
|
|
|
paintDesktop(item->desktop(), desktopMask, clippingRegion, data);
|
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 14:46:54 +00:00
|
|
|
s_recursionCheck = nullptr;
|
2012-03-29 18:17:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data)
|
|
|
|
{
|
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->paintDesktop(desktop, mask, region, data);
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// the function that'll be eventually called by paintWindow() above
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
effects->drawWindow(w, mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// will be eventually called from drawWindow()
|
2020-03-13 16:41:56 +00:00
|
|
|
void Scene::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-12-04 15:12:59 +00:00
|
|
|
if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) {
|
2015-11-23 10:33:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-13 20:41:02 +00:00
|
|
|
w->sceneWindow()->performPaint(mask, region, data);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-02-18 22:17:46 +00:00
|
|
|
void Scene::extendPaintRegion(QRegion ®ion, bool opaqueFullscreen)
|
|
|
|
{
|
|
|
|
Q_UNUSED(region);
|
|
|
|
Q_UNUSED(opaqueFullscreen);
|
|
|
|
}
|
|
|
|
|
2020-01-09 17:06:14 +00:00
|
|
|
bool Scene::blocksForRetrace() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-09 17:18:22 +00:00
|
|
|
bool Scene::syncsToVBlank() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:15:46 +00:00
|
|
|
void Scene::screenGeometryChanged(const QSize &size)
|
|
|
|
{
|
2013-06-19 10:26:34 +00:00
|
|
|
if (!overlayWindow()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-26 15:14:23 +00:00
|
|
|
overlayWindow()->resize(size);
|
2011-11-26 15:15:46 +00:00
|
|
|
}
|
|
|
|
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
bool Scene::makeOpenGLContextCurrent()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::doneOpenGLContextCurrent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-03 16:43:38 +00:00
|
|
|
void Scene::triggerFence()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-11-30 13:35:12 +00:00
|
|
|
QMatrix4x4 Scene::screenProjectionMatrix() const
|
|
|
|
{
|
|
|
|
return QMatrix4x4();
|
|
|
|
}
|
|
|
|
|
2017-08-08 15:13:59 +00:00
|
|
|
xcb_render_picture_t Scene::xrenderBufferPicture() const
|
|
|
|
{
|
|
|
|
return XCB_RENDER_PICTURE_NONE;
|
|
|
|
}
|
|
|
|
|
2017-08-09 04:56:23 +00:00
|
|
|
QPainter *Scene::scenePainter() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-11 12:59:09 +00:00
|
|
|
QImage *Scene::qpainterRenderBuffer() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-09-08 13:49:52 +00:00
|
|
|
QVector<QByteArray> Scene::openGLPlatformInterfaceExtensions() const
|
|
|
|
{
|
|
|
|
return QVector<QByteArray>{};
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//****************************************
|
|
|
|
// Scene::Window
|
|
|
|
//****************************************
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Scene::Window::Window(Toplevel * c)
|
|
|
|
: toplevel(c)
|
|
|
|
, filter(ImageFilterFast)
|
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 14:46:54 +00:00
|
|
|
, m_shadow(nullptr)
|
2013-05-10 10:07:56 +00:00
|
|
|
, m_currentPixmap()
|
|
|
|
, m_previousPixmap()
|
|
|
|
, m_referencePixmapCounter(0)
|
2011-01-30 14:34:42 +00:00
|
|
|
, disable_painting(0)
|
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 14:46:54 +00:00
|
|
|
, cached_quad_list(nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Scene::Window::~Window()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 09:31:33 +00:00
|
|
|
delete m_shadow;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
void Scene::Window::referencePreviousPixmap()
|
|
|
|
{
|
|
|
|
if (!m_previousPixmap.isNull() && m_previousPixmap->isDiscarded()) {
|
|
|
|
m_referencePixmapCounter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::Window::unreferencePreviousPixmap()
|
|
|
|
{
|
|
|
|
if (m_previousPixmap.isNull() || !m_previousPixmap->isDiscarded()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_referencePixmapCounter--;
|
|
|
|
if (m_referencePixmapCounter == 0) {
|
|
|
|
m_previousPixmap.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[x11] Fix visual artifacts during interactive resize
Summary:
When a window is being interactively resized, its contents may jump. The
reason why that happens is because KWin renders partially resized client
window. Composite extension spec says that a window will get a new pixmap
each time it is resized or mapped. This applies to the frame window, but
not to the client window itself. If the client window is resized,
off-screen storage for the frame window won't be reallocated. Therefore,
KWin may render partially resized client window if the client doesn't
attempt to be in sync with our rendering loop. Currently, the only way
to do that is to use extended frame counters, which are not supported by
KWin.
So, in order to fix visual artifacts during interactive resize, we need
somehow forcefully re-allocate off-screen storage for the frame window.
Unfortunately, Composite extension doesn't provide any request to do
that, so the only option we have is to resize the frame window.
BUG: 415839
FIXED-IN: 5.18.0
Reviewers: #kwin
Subscribers: davidedmundson, ngraham, alexde, fredrik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D26914
2020-02-03 11:29:43 +00:00
|
|
|
void Scene::Window::discardPixmap()
|
2013-05-10 10:07:56 +00:00
|
|
|
{
|
2015-05-21 11:30:01 +00:00
|
|
|
if (!m_currentPixmap.isNull()) {
|
|
|
|
if (m_currentPixmap->isValid()) {
|
|
|
|
m_previousPixmap.reset(m_currentPixmap.take());
|
|
|
|
m_previousPixmap->markAsDiscarded();
|
|
|
|
} else {
|
|
|
|
m_currentPixmap.reset();
|
|
|
|
}
|
2013-05-10 10:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[x11] Fix visual artifacts during interactive resize
Summary:
When a window is being interactively resized, its contents may jump. The
reason why that happens is because KWin renders partially resized client
window. Composite extension spec says that a window will get a new pixmap
each time it is resized or mapped. This applies to the frame window, but
not to the client window itself. If the client window is resized,
off-screen storage for the frame window won't be reallocated. Therefore,
KWin may render partially resized client window if the client doesn't
attempt to be in sync with our rendering loop. Currently, the only way
to do that is to use extended frame counters, which are not supported by
KWin.
So, in order to fix visual artifacts during interactive resize, we need
somehow forcefully re-allocate off-screen storage for the frame window.
Unfortunately, Composite extension doesn't provide any request to do
that, so the only option we have is to resize the frame window.
BUG: 415839
FIXED-IN: 5.18.0
Reviewers: #kwin
Subscribers: davidedmundson, ngraham, alexde, fredrik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D26914
2020-02-03 11:29:43 +00:00
|
|
|
void Scene::Window::updatePixmap()
|
|
|
|
{
|
|
|
|
if (m_currentPixmap.isNull()) {
|
|
|
|
m_currentPixmap.reset(createWindowPixmap());
|
|
|
|
}
|
|
|
|
if (!m_currentPixmap->isValid()) {
|
|
|
|
m_currentPixmap->create();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void Scene::Window::discardShape()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// it is created on-demand and cached, simply
|
|
|
|
// reset the flag
|
2019-09-27 10:33:42 +00:00
|
|
|
m_bufferShapeIsValid = false;
|
Try to invalidate quad cache when shadow is changed
Summary:
213239a0ea0a9c0967bb68d1eda7a8d4d6a09498 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-11-27 13:25:22 +00:00
|
|
|
invalidateQuadsCache();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-27 10:33:42 +00:00
|
|
|
QRegion Scene::Window::bufferShape() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-27 10:33:42 +00:00
|
|
|
if (m_bufferShapeIsValid) {
|
|
|
|
return m_bufferShape;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2019-09-27 10:33:42 +00:00
|
|
|
|
|
|
|
const QRect bufferGeometry = toplevel->bufferGeometry();
|
|
|
|
|
|
|
|
if (toplevel->shape()) {
|
2019-12-02 17:36:13 +00:00
|
|
|
auto cookie = xcb_shape_get_rectangles_unchecked(connection(), toplevel->frameId(), XCB_SHAPE_SK_BOUNDING);
|
2019-09-27 10:33:42 +00:00
|
|
|
ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(connection(), cookie, nullptr));
|
|
|
|
if (!reply.isNull()) {
|
|
|
|
m_bufferShape = QRegion();
|
|
|
|
const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data());
|
|
|
|
const int rectCount = xcb_shape_get_rectangles_rectangles_length(reply.data());
|
|
|
|
for (int i = 0; i < rectCount; ++i) {
|
|
|
|
m_bufferShape += QRegion(rects[i].x, rects[i].y, rects[i].width, rects[i].height);
|
|
|
|
}
|
|
|
|
// make sure the shape is sane (X is async, maybe even XShape is broken)
|
|
|
|
m_bufferShape &= QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
|
|
|
|
} else {
|
|
|
|
m_bufferShape = QRegion();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_bufferShape = QRegion(0, 0, bufferGeometry.width(), bufferGeometry.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bufferShapeIsValid = true;
|
|
|
|
|
|
|
|
return m_bufferShape;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-05-27 16:04:58 +00:00
|
|
|
QRegion Scene::Window::clientShape() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-27 10:33:42 +00:00
|
|
|
if (AbstractClient *client = qobject_cast<AbstractClient *>(toplevel)) {
|
|
|
|
if (client->isShade()) {
|
2012-09-07 07:40:44 +00:00
|
|
|
return QRegion();
|
2019-09-27 10:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-02 17:36:13 +00:00
|
|
|
|
|
|
|
const QRegion shape = bufferShape();
|
|
|
|
const QMargins bufferMargins = toplevel->bufferMargins();
|
|
|
|
if (bufferMargins.isNull()) {
|
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QRect clippingRect = QRect(QPoint(0, 0), toplevel->bufferGeometry().size()) - toplevel->bufferMargins();
|
|
|
|
return shape & clippingRect;
|
2019-09-27 10:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QRegion Scene::Window::decorationShape() const
|
|
|
|
{
|
2020-01-28 18:45:58 +00:00
|
|
|
return QRegion(toplevel->rect()) - toplevel->transparentRect();
|
2019-09-27 10:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPoint Scene::Window::bufferOffset() const
|
|
|
|
{
|
|
|
|
const QRect bufferGeometry = toplevel->bufferGeometry();
|
|
|
|
const QRect frameGeometry = toplevel->frameGeometry();
|
|
|
|
return bufferGeometry.topLeft() - frameGeometry.topLeft();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-22 17:29:56 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool Scene::Window::isVisible() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-09-07 07:40:44 +00:00
|
|
|
if (toplevel->isDeleted())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!toplevel->isOnCurrentDesktop())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!toplevel->isOnCurrentActivity())
|
2010-05-15 20:18:57 +00:00
|
|
|
return false;
|
2015-06-03 19:19:00 +00:00
|
|
|
if (AbstractClient *c = dynamic_cast<AbstractClient*>(toplevel))
|
|
|
|
return c->isShown(true);
|
2007-04-29 17:35:43 +00:00
|
|
|
return true; // Unmanaged is always visible
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Scene::Window::isOpaque() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return toplevel->opacity() == 1.0 && !toplevel->hasAlpha();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Scene::Window::isPaintingEnabled() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return !disable_painting;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Scene::Window::resetPaintingEnabled()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
disable_painting = 0;
|
2012-09-07 07:40:44 +00:00
|
|
|
if (toplevel->isDeleted())
|
2007-04-29 17:35:43 +00:00
|
|
|
disable_painting |= PAINT_DISABLED_BY_DELETE;
|
2012-03-29 18:12:34 +00:00
|
|
|
if (static_cast<EffectsHandlerImpl*>(effects)->isDesktopRendering()) {
|
|
|
|
if (!toplevel->isOnDesktop(static_cast<EffectsHandlerImpl*>(effects)->currentRenderedDesktop())) {
|
|
|
|
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!toplevel->isOnCurrentDesktop())
|
|
|
|
disable_painting |= PAINT_DISABLED_BY_DESKTOP;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!toplevel->isOnCurrentActivity())
|
2010-05-15 20:18:57 +00:00
|
|
|
disable_painting |= PAINT_DISABLED_BY_ACTIVITY;
|
2015-09-14 11:53:46 +00:00
|
|
|
if (AbstractClient *c = dynamic_cast<AbstractClient*>(toplevel)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c->isMinimized())
|
2007-04-29 17:35:43 +00:00
|
|
|
disable_painting |= PAINT_DISABLED_BY_MINIMIZE;
|
2016-07-04 13:06:20 +00:00
|
|
|
if (c->isHiddenInternal()) {
|
|
|
|
disable_painting |= PAINT_DISABLED;
|
2015-09-14 11:53:46 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Scene::Window::enablePainting(int reason)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
disable_painting &= ~reason;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Scene::Window::disablePainting(int reason)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
disable_painting |= reason;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
WindowQuadList Scene::Window::buildQuads(bool force) const
|
|
|
|
{
|
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 14:46:54 +00:00
|
|
|
if (cached_quad_list != nullptr && !force)
|
2008-03-20 11:17:50 +00:00
|
|
|
return *cached_quad_list;
|
2019-08-26 07:44:04 +00:00
|
|
|
|
2019-09-27 10:33:42 +00:00
|
|
|
WindowQuadList ret = makeContentsQuads();
|
2016-11-21 17:33:12 +00:00
|
|
|
|
2019-09-27 10:33:42 +00:00
|
|
|
if (!toplevel->frameMargins().isNull()) {
|
2015-12-03 12:50:38 +00:00
|
|
|
AbstractClient *client = dynamic_cast<AbstractClient*>(toplevel);
|
2009-12-01 09:31:47 +00:00
|
|
|
QRegion center = toplevel->transparentRect();
|
2019-09-27 10:33:42 +00:00
|
|
|
const QRegion decoration = decorationShape();
|
2017-11-01 17:54:21 +00:00
|
|
|
qreal decorationScale = 1.0;
|
2016-11-21 17:33:12 +00:00
|
|
|
|
2013-03-16 11:21:59 +00:00
|
|
|
QRect rects[4];
|
2013-06-02 14:53:56 +00:00
|
|
|
bool isShadedClient = false;
|
2013-03-16 11:21:59 +00:00
|
|
|
|
2013-06-02 14:53:56 +00:00
|
|
|
if (client) {
|
2014-07-25 10:55:28 +00:00
|
|
|
client->layoutDecorationRects(rects[0], rects[1], rects[2], rects[3]);
|
2017-11-01 17:54:21 +00:00
|
|
|
decorationScale = client->screenScale();
|
2013-06-02 14:53:56 +00:00
|
|
|
isShadedClient = client->isShade() || center.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isShadedClient) {
|
2013-03-16 11:21:59 +00:00
|
|
|
const QRect bounding = rects[0] | rects[1] | rects[2] | rects[3];
|
2017-11-01 17:54:21 +00:00
|
|
|
ret += makeDecorationQuads(rects, bounding, decorationScale);
|
2013-06-02 14:53:56 +00:00
|
|
|
} else {
|
2017-11-01 17:54:21 +00:00
|
|
|
ret += makeDecorationQuads(rects, decoration, decorationScale);
|
2008-03-20 11:17:50 +00:00
|
|
|
}
|
2013-06-02 14:53:56 +00:00
|
|
|
|
2007-07-18 15:01:59 +00:00
|
|
|
}
|
2014-07-24 06:55:57 +00:00
|
|
|
if (m_shadow && toplevel->wantsShadowToBeRendered()) {
|
2011-04-03 09:31:33 +00:00
|
|
|
ret << m_shadow->shadowQuads();
|
2011-03-27 10:33:07 +00:00
|
|
|
}
|
2012-09-07 07:40:44 +00:00
|
|
|
effects->buildQuads(toplevel->effectWindow(), ret);
|
2016-02-01 20:41:48 +00:00
|
|
|
cached_quad_list.reset(new WindowQuadList(ret));
|
2011-01-30 14:34:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2007-07-18 15:01:59 +00:00
|
|
|
|
2017-11-01 17:54:21 +00:00
|
|
|
WindowQuadList Scene::Window::makeDecorationQuads(const QRect *rects, const QRegion ®ion, qreal textureScale) const
|
2013-03-16 11:21:59 +00:00
|
|
|
{
|
|
|
|
WindowQuadList list;
|
|
|
|
|
[scene] Fix decoration texture bleeding
Summary:
Quite long time ago, window decorations were painted on real X11 windows.
The nicest thing about that approach is that we get both contents of the
client and the frame window at the same time. However, somewhere around
KDE 4.2 - 4.3 times, decoration rendering architecture had been changed
to what we have now.
I've mentioned the previous decoration rendering design because it didn't
have a problem that the new design has, namely the texture bleeding issue.
In the name of better performance, opengl scene puts all decoration parts
to an atlas. This is totally reasonable, however we must be super cautious
about things such as the GL_LINEAR filter.
The GL_LINEAR filter may need to sample a couple of neighboring texels
in order to produce the final texel value. However, since all decoration
parts now live in a single texture, we have to make sure that we don't
sample texels that belong to another decoration part.
This patch fixes the texture bleeding problem by padding each individual
decoration part in the atlas. There is another solution for this problem
though. We could render a window into an offscreen texture and then map
that texture on the transformed window geometry. This would work well and
we definitely need an offscreen rendering path in the opengl scene,
however it's not feasible at the moment since we need to break the window
quads API. Also, it would be great to have as less as possible stuff going
on between invocation of Scene::Window::performPaint() and getting the
corresponding pixel data on the screen.
There is a good chance that the new padding stuff may make you vomit. If
it does so, I'm all ears for the suggestions how to make the code more
nicer.
BUG: 257566
BUG: 360549
CCBUG: 412573
FIXED-IN: 5.18.0
Reviewers: #kwin
Subscribers: fredrik, kwin, fvogt
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D25611
2019-11-28 12:00:58 +00:00
|
|
|
const int padding = 1;
|
|
|
|
|
|
|
|
const QPoint topSpritePosition(padding, padding);
|
|
|
|
const QPoint bottomSpritePosition(padding, topSpritePosition.y() + rects[1].height() + 2 * padding);
|
|
|
|
const QPoint leftSpritePosition(bottomSpritePosition.y() + rects[3].height() + 2 * padding, padding);
|
|
|
|
const QPoint rightSpritePosition(leftSpritePosition.x() + rects[0].width() + 2 * padding, padding);
|
|
|
|
|
2013-03-15 17:01:44 +00:00
|
|
|
const QPoint offsets[4] = {
|
[scene] Fix decoration texture bleeding
Summary:
Quite long time ago, window decorations were painted on real X11 windows.
The nicest thing about that approach is that we get both contents of the
client and the frame window at the same time. However, somewhere around
KDE 4.2 - 4.3 times, decoration rendering architecture had been changed
to what we have now.
I've mentioned the previous decoration rendering design because it didn't
have a problem that the new design has, namely the texture bleeding issue.
In the name of better performance, opengl scene puts all decoration parts
to an atlas. This is totally reasonable, however we must be super cautious
about things such as the GL_LINEAR filter.
The GL_LINEAR filter may need to sample a couple of neighboring texels
in order to produce the final texel value. However, since all decoration
parts now live in a single texture, we have to make sure that we don't
sample texels that belong to another decoration part.
This patch fixes the texture bleeding problem by padding each individual
decoration part in the atlas. There is another solution for this problem
though. We could render a window into an offscreen texture and then map
that texture on the transformed window geometry. This would work well and
we definitely need an offscreen rendering path in the opengl scene,
however it's not feasible at the moment since we need to break the window
quads API. Also, it would be great to have as less as possible stuff going
on between invocation of Scene::Window::performPaint() and getting the
corresponding pixel data on the screen.
There is a good chance that the new padding stuff may make you vomit. If
it does so, I'm all ears for the suggestions how to make the code more
nicer.
BUG: 257566
BUG: 360549
CCBUG: 412573
FIXED-IN: 5.18.0
Reviewers: #kwin
Subscribers: fredrik, kwin, fvogt
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D25611
2019-11-28 12:00:58 +00:00
|
|
|
QPoint(-rects[0].x(), -rects[0].y()) + leftSpritePosition,
|
|
|
|
QPoint(-rects[1].x(), -rects[1].y()) + topSpritePosition,
|
|
|
|
QPoint(-rects[2].x(), -rects[2].y()) + rightSpritePosition,
|
|
|
|
QPoint(-rects[3].x(), -rects[3].y()) + bottomSpritePosition,
|
2013-03-15 17:01:44 +00:00
|
|
|
};
|
|
|
|
|
2013-09-16 17:50:02 +00:00
|
|
|
const Qt::Orientation orientations[4] = {
|
|
|
|
Qt::Vertical, // Left
|
|
|
|
Qt::Horizontal, // Top
|
|
|
|
Qt::Vertical, // Right
|
|
|
|
Qt::Horizontal, // Bottom
|
2013-03-16 23:40:15 +00:00
|
|
|
};
|
|
|
|
|
2013-03-16 11:21:59 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2017-12-02 09:05:45 +00:00
|
|
|
const QRegion intersectedRegion = (region & rects[i]);
|
|
|
|
for (const QRect &r : intersectedRegion) {
|
2013-03-16 11:21:59 +00:00
|
|
|
if (!r.isValid())
|
|
|
|
continue;
|
|
|
|
|
2013-09-16 17:50:02 +00:00
|
|
|
const bool swap = orientations[i] == Qt::Vertical;
|
|
|
|
|
2013-03-16 11:21:59 +00:00
|
|
|
const int x0 = r.x();
|
|
|
|
const int y0 = r.y();
|
|
|
|
const int x1 = r.x() + r.width();
|
|
|
|
const int y1 = r.y() + r.height();
|
|
|
|
|
2017-11-01 17:54:21 +00:00
|
|
|
const int u0 = (x0 + offsets[i].x()) * textureScale;
|
|
|
|
const int v0 = (y0 + offsets[i].y()) * textureScale;
|
|
|
|
const int u1 = (x1 + offsets[i].x()) * textureScale;
|
|
|
|
const int v1 = (y1 + offsets[i].y()) * textureScale;
|
2013-03-16 11:21:59 +00:00
|
|
|
|
2013-09-16 17:50:02 +00:00
|
|
|
WindowQuad quad(WindowQuadDecoration);
|
|
|
|
quad.setUVAxisSwapped(swap);
|
|
|
|
|
|
|
|
if (swap) {
|
|
|
|
quad[0] = WindowVertex(x0, y0, v0, u0); // Top-left
|
|
|
|
quad[1] = WindowVertex(x1, y0, v0, u1); // Top-right
|
|
|
|
quad[2] = WindowVertex(x1, y1, v1, u1); // Bottom-right
|
|
|
|
quad[3] = WindowVertex(x0, y1, v1, u0); // Bottom-left
|
|
|
|
} else {
|
|
|
|
quad[0] = WindowVertex(x0, y0, u0, v0); // Top-left
|
|
|
|
quad[1] = WindowVertex(x1, y0, u1, v0); // Top-right
|
|
|
|
quad[2] = WindowVertex(x1, y1, u1, v1); // Bottom-right
|
|
|
|
quad[3] = WindowVertex(x0, y1, u0, v1); // Bottom-left
|
|
|
|
}
|
|
|
|
|
2013-03-16 11:21:59 +00:00
|
|
|
list.append(quad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:33:42 +00:00
|
|
|
WindowQuadList Scene::Window::makeContentsQuads() const
|
Try to invalidate quad cache when shadow is changed
Summary:
213239a0ea0a9c0967bb68d1eda7a8d4d6a09498 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-11-27 13:25:22 +00:00
|
|
|
{
|
2019-09-27 10:33:42 +00:00
|
|
|
const QRegion contentsRegion = clientShape();
|
|
|
|
if (contentsRegion.isEmpty()) {
|
|
|
|
return WindowQuadList();
|
|
|
|
}
|
|
|
|
|
|
|
|
const QPointF geometryOffset = bufferOffset();
|
|
|
|
const qreal textureScale = toplevel->bufferScale();
|
|
|
|
|
|
|
|
WindowQuadList quads;
|
|
|
|
quads.reserve(contentsRegion.rectCount());
|
|
|
|
|
|
|
|
for (const QRectF &rect : contentsRegion) {
|
|
|
|
WindowQuad quad(WindowQuadContents);
|
|
|
|
|
|
|
|
const qreal x0 = rect.left() + geometryOffset.x();
|
|
|
|
const qreal y0 = rect.top() + geometryOffset.y();
|
|
|
|
const qreal x1 = rect.right() + geometryOffset.x();
|
|
|
|
const qreal y1 = rect.bottom() + geometryOffset.y();
|
|
|
|
|
|
|
|
const qreal u0 = rect.left() * textureScale;
|
|
|
|
const qreal v0 = rect.top() * textureScale;
|
|
|
|
const qreal u1 = rect.right() * textureScale;
|
|
|
|
const qreal v1 = rect.bottom() * textureScale;
|
|
|
|
|
|
|
|
quad[0] = WindowVertex(QPointF(x0, y0), QPointF(u0, v0));
|
|
|
|
quad[1] = WindowVertex(QPointF(x1, y0), QPointF(u1, v0));
|
|
|
|
quad[2] = WindowVertex(QPointF(x1, y1), QPointF(u1, v1));
|
|
|
|
quad[3] = WindowVertex(QPointF(x0, y1), QPointF(u0, v1));
|
|
|
|
|
|
|
|
quads << quad;
|
|
|
|
}
|
|
|
|
|
|
|
|
return quads;
|
Try to invalidate quad cache when shadow is changed
Summary:
213239a0ea0a9c0967bb68d1eda7a8d4d6a09498 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-11-27 13:25:22 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:33:42 +00:00
|
|
|
void Scene::Window::invalidateQuadsCache()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-27 10:33:42 +00:00
|
|
|
cached_quad_list.reset();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-18 15:01:59 +00:00
|
|
|
|
2016-08-18 14:03:26 +00:00
|
|
|
void Scene::Window::updateShadow(Shadow* shadow)
|
|
|
|
{
|
|
|
|
if (m_shadow == shadow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete m_shadow;
|
|
|
|
m_shadow = shadow;
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
//****************************************
|
|
|
|
// WindowPixmap
|
|
|
|
//****************************************
|
|
|
|
WindowPixmap::WindowPixmap(Scene::Window *window)
|
|
|
|
: m_window(window)
|
|
|
|
, m_pixmap(XCB_PIXMAP_NONE)
|
|
|
|
, m_discarded(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-21 15:37:45 +00:00
|
|
|
WindowPixmap::WindowPixmap(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface, WindowPixmap *parent)
|
|
|
|
: m_window(parent->m_window)
|
|
|
|
, m_pixmap(XCB_PIXMAP_NONE)
|
|
|
|
, m_discarded(false)
|
|
|
|
, m_parent(parent)
|
|
|
|
, m_subSurface(subSurface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-10 10:07:56 +00:00
|
|
|
WindowPixmap::~WindowPixmap()
|
|
|
|
{
|
2020-03-19 17:25:55 +00:00
|
|
|
qDeleteAll(m_children);
|
|
|
|
|
2016-04-25 08:54:17 +00:00
|
|
|
if (m_pixmap != XCB_WINDOW_NONE) {
|
2013-05-10 10:07:56 +00:00
|
|
|
xcb_free_pixmap(connection(), m_pixmap);
|
|
|
|
}
|
2015-06-12 14:22:41 +00:00
|
|
|
if (m_buffer) {
|
|
|
|
using namespace KWayland::Server;
|
|
|
|
QObject::disconnect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
|
|
|
|
m_buffer->unref();
|
|
|
|
}
|
2013-05-10 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowPixmap::create()
|
|
|
|
{
|
2013-10-14 22:43:41 +00:00
|
|
|
if (isValid() || toplevel()->isDeleted()) {
|
2013-05-10 10:07:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-06-26 14:27:15 +00:00
|
|
|
// always update from Buffer on Wayland, don't try using XPixmap
|
|
|
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
2015-02-09 17:56:05 +00:00
|
|
|
// use Buffer
|
|
|
|
updateBuffer();
|
2016-03-21 15:37:45 +00:00
|
|
|
if ((m_buffer || !m_fbo.isNull()) && m_subSurface.isNull()) {
|
2015-02-09 17:56:05 +00:00
|
|
|
m_window->unreferencePreviousPixmap();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-09-13 14:51:53 +00:00
|
|
|
XServerGrabber grabber;
|
2013-05-10 10:07:56 +00:00
|
|
|
xcb_pixmap_t pix = xcb_generate_id(connection());
|
2019-12-02 17:36:13 +00:00
|
|
|
xcb_void_cookie_t namePixmapCookie = xcb_composite_name_window_pixmap_checked(connection(), toplevel()->frameId(), pix);
|
|
|
|
Xcb::WindowAttributes windowAttributes(toplevel()->frameId());
|
|
|
|
Xcb::WindowGeometry windowGeometry(toplevel()->frameId());
|
2013-05-10 10:07:56 +00:00
|
|
|
if (xcb_generic_error_t *error = xcb_request_check(connection(), namePixmapCookie)) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << error->error_code;
|
2013-05-10 10:07:56 +00:00
|
|
|
free(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// check that the received pixmap is valid and actually matches what we
|
|
|
|
// know about the window (i.e. size)
|
|
|
|
if (!windowAttributes || windowAttributes->map_state != XCB_MAP_STATE_VIEWABLE) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this;
|
2013-05-10 10:07:56 +00:00
|
|
|
xcb_free_pixmap(connection(), pix);
|
|
|
|
return;
|
|
|
|
}
|
2019-09-27 10:33:42 +00:00
|
|
|
const QRect bufferGeometry = toplevel()->bufferGeometry();
|
|
|
|
if (windowGeometry.size() != bufferGeometry.size()) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Creating window pixmap failed: " << this;
|
2013-05-10 10:07:56 +00:00
|
|
|
xcb_free_pixmap(connection(), pix);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_pixmap = pix;
|
2019-09-27 10:33:42 +00:00
|
|
|
m_pixmapSize = bufferGeometry.size();
|
2019-12-02 17:36:13 +00:00
|
|
|
m_contentsRect = QRect(toplevel()->clientPos(), toplevel()->clientSize());
|
2013-05-10 10:07:56 +00:00
|
|
|
m_window->unreferencePreviousPixmap();
|
|
|
|
}
|
|
|
|
|
2016-03-21 15:37:45 +00:00
|
|
|
WindowPixmap *WindowPixmap::createChild(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface)
|
|
|
|
{
|
|
|
|
Q_UNUSED(subSurface)
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-02-09 17:56:05 +00:00
|
|
|
bool WindowPixmap::isValid() const
|
|
|
|
{
|
2019-08-26 07:44:04 +00:00
|
|
|
if (!m_buffer.isNull() || !m_fbo.isNull() || !m_internalImage.isNull()) {
|
2016-04-25 08:54:17 +00:00
|
|
|
return true;
|
2015-02-09 17:56:05 +00:00
|
|
|
}
|
|
|
|
return m_pixmap != XCB_PIXMAP_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowPixmap::updateBuffer()
|
|
|
|
{
|
2016-03-21 15:37:45 +00:00
|
|
|
using namespace KWayland::Server;
|
2016-04-01 07:22:32 +00:00
|
|
|
if (SurfaceInterface *s = surface()) {
|
2016-03-21 15:37:45 +00:00
|
|
|
QVector<WindowPixmap*> oldTree = m_children;
|
|
|
|
QVector<WindowPixmap*> children;
|
2015-03-04 06:54:40 +00:00
|
|
|
using namespace KWayland::Server;
|
2016-03-21 15:37:45 +00:00
|
|
|
const auto subSurfaces = s->childSubSurfaces();
|
|
|
|
for (const auto &subSurface : subSurfaces) {
|
|
|
|
if (subSurface.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto it = std::find_if(oldTree.begin(), oldTree.end(), [subSurface] (WindowPixmap *p) { return p->m_subSurface == subSurface; });
|
|
|
|
if (it != oldTree.end()) {
|
|
|
|
children << *it;
|
|
|
|
(*it)->updateBuffer();
|
|
|
|
oldTree.erase(it);
|
|
|
|
} else {
|
|
|
|
WindowPixmap *p = createChild(subSurface);
|
|
|
|
if (p) {
|
|
|
|
p->create();
|
|
|
|
children << p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setChildren(children);
|
|
|
|
qDeleteAll(oldTree);
|
2015-02-09 17:56:05 +00:00
|
|
|
if (auto b = s->buffer()) {
|
2016-03-21 15:37:45 +00:00
|
|
|
if (b == m_buffer) {
|
|
|
|
// no change
|
|
|
|
return;
|
|
|
|
}
|
2015-03-04 06:54:40 +00:00
|
|
|
if (m_buffer) {
|
|
|
|
QObject::disconnect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
|
|
|
|
m_buffer->unref();
|
|
|
|
}
|
2015-02-09 17:56:05 +00:00
|
|
|
m_buffer = b;
|
2015-03-04 06:54:40 +00:00
|
|
|
m_buffer->ref();
|
|
|
|
QObject::connect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
|
2016-03-21 15:37:45 +00:00
|
|
|
} else if (m_subSurface) {
|
|
|
|
if (m_buffer) {
|
|
|
|
QObject::disconnect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
|
|
|
|
m_buffer->unref();
|
|
|
|
m_buffer.clear();
|
|
|
|
}
|
2015-02-09 17:56:05 +00:00
|
|
|
}
|
2019-08-26 07:44:04 +00:00
|
|
|
} else if (toplevel()->internalFramebufferObject()) {
|
|
|
|
m_fbo = toplevel()->internalFramebufferObject();
|
|
|
|
} else if (!toplevel()->internalImageObject().isNull()) {
|
|
|
|
m_internalImage = toplevel()->internalImageObject();
|
2016-03-21 15:37:45 +00:00
|
|
|
} else {
|
|
|
|
if (m_buffer) {
|
|
|
|
QObject::disconnect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
|
|
|
|
m_buffer->unref();
|
|
|
|
m_buffer.clear();
|
|
|
|
}
|
2015-02-09 17:56:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 07:19:00 +00:00
|
|
|
KWayland::Server::SurfaceInterface *WindowPixmap::surface() const
|
|
|
|
{
|
|
|
|
if (!m_subSurface.isNull()) {
|
|
|
|
return m_subSurface->surface().data();
|
|
|
|
} else {
|
|
|
|
return toplevel()->surface();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
//****************************************
|
|
|
|
// Scene::EffectFrame
|
|
|
|
//****************************************
|
|
|
|
Scene::EffectFrame::EffectFrame(EffectFrameImpl* frame)
|
2011-01-30 14:34:42 +00:00
|
|
|
: m_effectFrame(frame)
|
|
|
|
{
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
Scene::EffectFrame::~EffectFrame()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2017-08-10 16:13:42 +00:00
|
|
|
SceneFactory::SceneFactory(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SceneFactory::~SceneFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|