2020-05-18 19:37:41 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2020-05-18 19:37:41 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <kwin_export.h>
|
|
|
|
|
|
|
|
#include <QImage>
|
2020-07-13 16:02:45 +00:00
|
|
|
#include <QSharedDataPointer>
|
2020-05-18 19:37:41 +00:00
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2020-07-13 16:02:45 +00:00
|
|
|
class KXcursorSpritePrivate;
|
|
|
|
class KXcursorThemePrivate;
|
|
|
|
|
2020-05-18 19:37:41 +00:00
|
|
|
/**
|
|
|
|
* The KXcursorSprite class represents a single sprite in the Xcursor theme.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT KXcursorSprite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructs an empty XcursorSprite.
|
|
|
|
*/
|
|
|
|
KXcursorSprite();
|
|
|
|
|
2020-07-13 16:02:45 +00:00
|
|
|
/**
|
|
|
|
* Constructs a copy of the KXcursorSprite object @a other.
|
|
|
|
*/
|
|
|
|
KXcursorSprite(const KXcursorSprite &other);
|
|
|
|
|
2020-05-18 19:37:41 +00:00
|
|
|
/**
|
|
|
|
* Constructs an XcursorSprite with the specified @a data, @a hotspot, and @a delay.
|
|
|
|
*/
|
|
|
|
KXcursorSprite(const QImage &data, const QPoint &hotspot,
|
|
|
|
const std::chrono::milliseconds &delay);
|
|
|
|
|
2020-07-13 16:02:45 +00:00
|
|
|
/**
|
|
|
|
* Destructs the KXcursorSprite object.
|
|
|
|
*/
|
|
|
|
~KXcursorSprite();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assigns the value of @a other to the Xcursor sprite object.
|
|
|
|
*/
|
|
|
|
KXcursorSprite &operator=(const KXcursorSprite &other);
|
|
|
|
|
2020-05-18 19:37:41 +00:00
|
|
|
/**
|
|
|
|
* Returns the image for this sprite.
|
|
|
|
*/
|
|
|
|
QImage data() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the hotspot for this sprite. (0, 0) corresponds to the upper left corner.
|
|
|
|
*
|
2020-07-13 16:05:34 +00:00
|
|
|
* The coordinates of the hotspot are in device independent pixels.
|
2020-05-18 19:37:41 +00:00
|
|
|
*/
|
|
|
|
QPoint hotspot() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the time interval between this sprite and the next one, in milliseconds.
|
|
|
|
*/
|
|
|
|
std::chrono::milliseconds delay() const;
|
|
|
|
|
|
|
|
private:
|
2020-07-13 16:02:45 +00:00
|
|
|
QSharedDataPointer<KXcursorSpritePrivate> d;
|
2020-05-18 19:37:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The KXcursorTheme class represents an Xcursor theme.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT KXcursorTheme
|
|
|
|
{
|
|
|
|
public:
|
2020-07-13 16:02:45 +00:00
|
|
|
/**
|
|
|
|
* Constructs an empty Xcursor theme.
|
|
|
|
*/
|
|
|
|
KXcursorTheme();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a copy of the KXcursorTheme object @a other.
|
|
|
|
*/
|
|
|
|
KXcursorTheme(const KXcursorTheme &other);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructs the KXcursorTheme object.
|
|
|
|
*/
|
|
|
|
~KXcursorTheme();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assigns the value of @a other to the Xcursor theme object.
|
|
|
|
*/
|
|
|
|
KXcursorTheme &operator=(const KXcursorTheme &other);
|
|
|
|
|
2020-05-18 19:37:41 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if the Xcursor theme is empty; otherwise returns @c false.
|
|
|
|
*/
|
|
|
|
bool isEmpty() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of cursor sprites for the cursor with the given @a name.
|
|
|
|
*/
|
|
|
|
QVector<KXcursorSprite> shape(const QByteArray &name) const;
|
|
|
|
|
|
|
|
/**
|
2021-05-02 10:37:45 +00:00
|
|
|
* Loads the Xcursor theme with the given @ themeName and the desired @a size.
|
|
|
|
* The @a dpr specifies the desired scale factor. If no theme with the provided
|
|
|
|
* name exists, an empty KXcursorTheme is returned.
|
2020-05-18 19:37:41 +00:00
|
|
|
*/
|
|
|
|
static KXcursorTheme fromTheme(const QString &themeName, int size, qreal dpr);
|
|
|
|
|
|
|
|
private:
|
2021-05-02 10:37:45 +00:00
|
|
|
KXcursorTheme(const QMap<QByteArray, QVector<KXcursorSprite>> ®istry);
|
2020-07-13 16:02:45 +00:00
|
|
|
QSharedDataPointer<KXcursorThemePrivate> d;
|
2020-05-18 19:37:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|