Currently, X11Window and Unmanaged call finishCompositing(), which tries to destroy the window item and other associated compositing data. Usually, it has no any effect on the window item and the effect window because they are moved to the Deleted. However, it has some effect on the XDamage handle. If the X11 window is unmapped, it will destroy the XDamage handle. If the X11 window is destroyed, it will do nothing. Why does it behave like that? Because that's how the XDamage spec is written. This change removes the call to finishCompositing() and refactors how the XDamage is handled so Window::finishCompositing() is more generic. If the X11 window is destroyed, SurfaceItemX11::forgetDamage() will be called and SurfaceItemX11::~SurfaceItemX11() won't attempt to destroy the damage handle. If the X11 window is unmapped, SurfaceItemX11::destroyDamage() will be called and destroyDamage() in SurfaceItemX11::~SurfaceItemX11() will noop. If compositing has been restarted, destroyDamage() in SurfaceItemX11::~SurfaceItemX11() will destroy the damage handle.
76 lines
1.6 KiB
C++
76 lines
1.6 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "scene/surfaceitem.h"
|
|
|
|
#include <xcb/damage.h>
|
|
#include <xcb/xfixes.h>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
/**
|
|
* The SurfaceItemX11 class represents an X11 surface in the scene.
|
|
*/
|
|
class KWIN_EXPORT SurfaceItemX11 : public SurfaceItem
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SurfaceItemX11(Window *window, Scene *scene, Item *parent = nullptr);
|
|
~SurfaceItemX11() override;
|
|
|
|
Window *window() const;
|
|
|
|
void preprocess() override;
|
|
|
|
void processDamage();
|
|
bool fetchDamage();
|
|
void waitForDamage();
|
|
void forgetDamage();
|
|
void destroyDamage();
|
|
|
|
QVector<QRectF> shape() const override;
|
|
QRegion opaque() const override;
|
|
|
|
private Q_SLOTS:
|
|
void handleBufferGeometryChanged(const QRectF &old);
|
|
void handleGeometryShapeChanged();
|
|
void handleWindowClosed(Window *deleted);
|
|
|
|
protected:
|
|
std::unique_ptr<SurfacePixmap> createPixmap() override;
|
|
|
|
private:
|
|
Window *m_window;
|
|
xcb_damage_damage_t m_damageHandle = XCB_NONE;
|
|
xcb_xfixes_fetch_region_cookie_t m_damageCookie;
|
|
bool m_isDamaged = false;
|
|
bool m_havePendingDamageRegion = false;
|
|
};
|
|
|
|
class KWIN_EXPORT SurfacePixmapX11 final : public SurfacePixmap
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SurfacePixmapX11(SurfaceItemX11 *item, QObject *parent = nullptr);
|
|
~SurfacePixmapX11() override;
|
|
|
|
xcb_pixmap_t pixmap() const;
|
|
xcb_visualid_t visual() const;
|
|
|
|
void create() override;
|
|
bool isValid() const override;
|
|
|
|
private:
|
|
SurfaceItemX11 *m_item;
|
|
xcb_pixmap_t m_pixmap = XCB_PIXMAP_NONE;
|
|
};
|
|
|
|
} // namespace KWaylandServer
|