| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <QIcon> |
| 4 |
#include <QPointer> |
| 5 |
#include <QtWaylandClient/QWaylandClientExtensionTemplate> |
| 6 |
|
| 7 |
#include "qwayland-wlr-foreign-toplevel-management-unstable-v1.h" |
| 8 |
#include "wayland-wlr-foreign-toplevel-management-unstable-v1-client-protocol.h" |
| 9 |
|
| 10 |
typedef quintptr WId; |
| 11 |
|
| 12 |
class LXQtTaskbarWlrootsWindow; |
| 13 |
|
| 14 |
class LXQtTaskbarWlrootsWindowManagment : public QWaylandClientExtensionTemplate<LXQtTaskbarWlrootsWindowManagment>, |
| 15 |
public QtWayland::zwlr_foreign_toplevel_manager_v1 |
| 16 |
{ |
| 17 |
Q_OBJECT |
| 18 |
public: |
| 19 |
static constexpr int version = 16; |
| 20 |
|
| 21 |
LXQtTaskbarWlrootsWindowManagment(); |
| 22 |
~LXQtTaskbarWlrootsWindowManagment(); |
| 23 |
|
| 24 |
inline bool isShowingDesktop() const { return m_isShowingDesktop; } |
| 25 |
inline void setShowingDesktop(bool show) { m_isShowingDesktop = show; } |
| 26 |
|
| 27 |
protected: |
| 28 |
void zwlr_foreign_toplevel_manager_v1_toplevel(struct ::zwlr_foreign_toplevel_handle_v1 *toplevel); |
| 29 |
void zwlr_foreign_toplevel_manager_v1_finished() {}; |
| 30 |
|
| 31 |
Q_SIGNALS: |
| 32 |
void windowCreated(WId wid); |
| 33 |
|
| 34 |
private: |
| 35 |
bool m_isShowingDesktop = false; |
| 36 |
}; |
| 37 |
|
| 38 |
using WindowState = QtWayland::zwlr_foreign_toplevel_handle_v1::state; |
| 39 |
|
| 40 |
class WindowProperties { |
| 41 |
public: |
| 42 |
/** Title of the window */ |
| 43 |
QString title = QString::fromUtf8( "untitled" ); |
| 44 |
bool titleChanged = false; |
| 45 |
|
| 46 |
/** appId of the window */ |
| 47 |
QString appId = QString::fromUtf8( "unidentified" ); |
| 48 |
bool appIdChanged = false; |
| 49 |
|
| 50 |
/** List of outputs which the window is currently on */ |
| 51 |
QList<::wl_output *> outputs; |
| 52 |
bool outputsChanged = false; |
| 53 |
|
| 54 |
/** Is maximized */ |
| 55 |
bool maximized = false; |
| 56 |
bool maximizedChanged = false; |
| 57 |
|
| 58 |
/** Is minimized */ |
| 59 |
bool minimized = false; |
| 60 |
bool minimizedChanged = false; |
| 61 |
|
| 62 |
/** Is active */ |
| 63 |
bool activated = false; |
| 64 |
bool activatedChanged = false; |
| 65 |
|
| 66 |
/** Is fullscreen */ |
| 67 |
bool fullscreen = false; |
| 68 |
bool fullscreenChanged = false; |
| 69 |
|
| 70 |
/** Parent of this view, can be null */ |
| 71 |
::zwlr_foreign_toplevel_handle_v1 * parent = nullptr; |
| 72 |
bool parentChanged = false; |
| 73 |
|
| 74 |
/** List of outputs from which window has left */ |
| 75 |
QList<::wl_output *> outputsLeft; |
| 76 |
}; |
| 77 |
|
| 78 |
class LXQtTaskbarWlrootsWindow : public QObject, |
| 79 |
public QtWayland::zwlr_foreign_toplevel_handle_v1 |
| 80 |
{ |
| 81 |
Q_OBJECT |
| 82 |
public: |
| 83 |
LXQtTaskbarWlrootsWindow(::zwlr_foreign_toplevel_handle_v1 *id); |
| 84 |
~LXQtTaskbarWlrootsWindow(); |
| 85 |
|
| 86 |
inline WId getWindowId() const { return reinterpret_cast<WId>(this); } |
| 87 |
|
| 88 |
void activate(); |
| 89 |
|
| 90 |
QIcon icon; |
| 91 |
WindowProperties windowState; |
| 92 |
WId parentWindow = 0; |
| 93 |
::zwlr_foreign_toplevel_handle_v1 *ID = nullptr; |
| 94 |
|
| 95 |
Q_SIGNALS: |
| 96 |
void titleChanged(); |
| 97 |
void appIdChanged(); |
| 98 |
void outputsChanged(); |
| 99 |
|
| 100 |
/** Individual state change signals */ |
| 101 |
void maximizedChanged(); |
| 102 |
void minimizedChanged(); |
| 103 |
void activatedChanged(); |
| 104 |
void fullscreenChanged(); |
| 105 |
|
| 106 |
void parentChanged(); |
| 107 |
|
| 108 |
/** Bulk state change signal */ |
| 109 |
void stateChanged(); |
| 110 |
|
| 111 |
/** First state change signal: Before this, the window did not have a valid state */ |
| 112 |
void windowReady(); |
| 113 |
|
| 114 |
/** All state changes have been sent. */ |
| 115 |
void done(); |
| 116 |
|
| 117 |
/** Window closed signal */ |
| 118 |
void closed(); |
| 119 |
|
| 120 |
protected: |
| 121 |
void zwlr_foreign_toplevel_handle_v1_title(const QString &title); |
| 122 |
void zwlr_foreign_toplevel_handle_v1_app_id(const QString &app_id); |
| 123 |
void zwlr_foreign_toplevel_handle_v1_output_enter(struct ::wl_output *output); |
| 124 |
void zwlr_foreign_toplevel_handle_v1_output_leave(struct ::wl_output *output); |
| 125 |
void zwlr_foreign_toplevel_handle_v1_state(wl_array *state); |
| 126 |
void zwlr_foreign_toplevel_handle_v1_done(); |
| 127 |
void zwlr_foreign_toplevel_handle_v1_closed(); |
| 128 |
void zwlr_foreign_toplevel_handle_v1_parent(struct ::zwlr_foreign_toplevel_handle_v1 *parent); |
| 129 |
|
| 130 |
private: |
| 131 |
void setParentWindow(LXQtTaskbarWlrootsWindow *parent); |
| 132 |
|
| 133 |
QMetaObject::Connection parentWindowUnmappedConnection; |
| 134 |
|
| 135 |
WindowProperties m_pendingState; |
| 136 |
|
| 137 |
bool initDone = false; |
| 138 |
}; |