File indexing completed on 2025-03-16 08:15:02
0001 /* 0002 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <kwin_export.h> 0010 0011 #include <QImage> 0012 #include <QList> 0013 #include <QSharedDataPointer> 0014 0015 #include <chrono> 0016 0017 namespace KWin 0018 { 0019 0020 class KXcursorSpritePrivate; 0021 class KXcursorThemePrivate; 0022 0023 /** 0024 * The KXcursorSprite class represents a single sprite in the Xcursor theme. 0025 */ 0026 class KWIN_EXPORT KXcursorSprite 0027 { 0028 public: 0029 /** 0030 * Constructs an empty XcursorSprite. 0031 */ 0032 KXcursorSprite(); 0033 0034 /** 0035 * Constructs a copy of the KXcursorSprite object @a other. 0036 */ 0037 KXcursorSprite(const KXcursorSprite &other); 0038 0039 /** 0040 * Constructs an XcursorSprite with the specified @a data, @a hotspot, and @a delay. 0041 */ 0042 KXcursorSprite(const QImage &data, const QPoint &hotspot, 0043 const std::chrono::milliseconds &delay); 0044 0045 /** 0046 * Destructs the KXcursorSprite object. 0047 */ 0048 ~KXcursorSprite(); 0049 0050 /** 0051 * Assigns the value of @a other to the Xcursor sprite object. 0052 */ 0053 KXcursorSprite &operator=(const KXcursorSprite &other); 0054 0055 /** 0056 * Returns the image for this sprite. 0057 */ 0058 QImage data() const; 0059 0060 /** 0061 * Returns the hotspot for this sprite. (0, 0) corresponds to the upper left corner. 0062 * 0063 * The coordinates of the hotspot are in device independent pixels. 0064 */ 0065 QPoint hotspot() const; 0066 0067 /** 0068 * Returns the time interval between this sprite and the next one, in milliseconds. 0069 */ 0070 std::chrono::milliseconds delay() const; 0071 0072 private: 0073 QSharedDataPointer<KXcursorSpritePrivate> d; 0074 }; 0075 0076 /** 0077 * The KXcursorTheme class represents an Xcursor theme. 0078 */ 0079 class KWIN_EXPORT KXcursorTheme 0080 { 0081 public: 0082 /** 0083 * Constructs an empty Xcursor theme. 0084 */ 0085 KXcursorTheme(); 0086 0087 /** 0088 * Loads the Xcursor theme with the given @ themeName and the desired @a size. 0089 * The @a dpr specifies the desired scale factor. If no theme with the provided 0090 * name exists, the cursor theme will be empty. 0091 */ 0092 KXcursorTheme(const QString &theme, int size, qreal devicePixelRatio); 0093 0094 /** 0095 * Constructs a copy of the KXcursorTheme object @a other. 0096 */ 0097 KXcursorTheme(const KXcursorTheme &other); 0098 0099 /** 0100 * Destructs the KXcursorTheme object. 0101 */ 0102 ~KXcursorTheme(); 0103 0104 /** 0105 * Assigns the value of @a other to the Xcursor theme object. 0106 */ 0107 KXcursorTheme &operator=(const KXcursorTheme &other); 0108 0109 bool operator==(const KXcursorTheme &other); 0110 bool operator!=(const KXcursorTheme &other); 0111 0112 /** 0113 * Returns @c true if the Xcursor theme is empty; otherwise returns @c false. 0114 */ 0115 bool isEmpty() const; 0116 0117 /** 0118 * Returns the list of cursor sprites for the cursor with the given @a name. 0119 */ 0120 QList<KXcursorSprite> shape(const QByteArray &name) const; 0121 0122 private: 0123 QSharedDataPointer<KXcursorThemePrivate> d; 0124 }; 0125 0126 } // namespace KWin