kwin/src/windowitem.h
Vlad Zahorodnii 47113e09b8 scene: Introduce window items
Currently, dealing with sub-surfaces is very difficult due to the scene
design being heavily influenced by X11 requirements.

The goal of this change is to re-work scene abstractions to make improving
the wayland support easier.

The Item class is based on the QQuickItem class. My hope is that one day
we will be able to transition to QtQuick for painting scene, but in
meanwhile it makes more sense to have a minimalistic internal item class.

The WindowItem class represents a window. The SurfaceItem class represents
the contents of either an X11, or a Wayland, or an internal surface. The
DecorationItem and the ShadowItem class represent the server-side deco and
drop-shadow, respectively.

At the moment, the SurfaceItem is bound to the scene window, but the long
term plan is to break that connection so we could re-use the SurfaceItem
for things such as software cursors and drag-and-drop additional icons.

One of the responsibilities of the Item is to schedule repaints as needed.
Ideally, there shouldn't be any addRepaint() calls in the core code. The
Item class schedules repaints on geometry updates. In the future, it also
has to request an update if its opacity or visibility changes.
2021-03-31 13:56:55 +00:00

90 lines
2 KiB
C++

/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "item.h"
namespace KDecoration2
{
class Decoration;
}
namespace KWin
{
/**
* The WindowItem class represents a window in the scene.
*
* A WindowItem is made of a surface with client contents and optionally a server-side frame
* and a drop-shadow.
*/
class KWIN_EXPORT WindowItem : public Item
{
Q_OBJECT
public:
SurfaceItem *surfaceItem() const;
DecorationItem *decorationItem() const;
ShadowItem *shadowItem() const;
void setShadow(Shadow *shadow);
protected:
explicit WindowItem(Scene::Window *window, Item *parent = nullptr);
void updateSurfaceItem(SurfaceItem *surfaceItem);
private Q_SLOTS:
void updateDecorationItem();
void updateSurfacePosition();
private:
QScopedPointer<SurfaceItem> m_surfaceItem;
QScopedPointer<DecorationItem> m_decorationItem;
QScopedPointer<ShadowItem> m_shadowItem;
};
/**
* The WindowItemX11 class represents an X11 window (both on X11 and Wayland sessions).
*
* Note that Xwayland windows and Wayland surfaces are associated asynchronously. This means
* that the surfaceItem() function can return @c null until the window is fully initialized.
*/
class KWIN_EXPORT WindowItemX11 : public WindowItem
{
Q_OBJECT
public:
explicit WindowItemX11(Scene::Window *window, Item *parent = nullptr);
private Q_SLOTS:
void initialize();
};
/**
* The WindowItemWayland class represents a Wayland window.
*/
class KWIN_EXPORT WindowItemWayland : public WindowItem
{
Q_OBJECT
public:
explicit WindowItemWayland(Scene::Window *window, Item *parent = nullptr);
};
/**
* The WindowItemInternal class represents a window created by the compositor, for
* example, the task switcher, etc.
*/
class KWIN_EXPORT WindowItemInternal : public WindowItem
{
Q_OBJECT
public:
explicit WindowItemInternal(Scene::Window *window, Item *parent = nullptr);
};
} // namespace KWin