74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <EGL/egl.h>
|
|
#include <wayland-egl.h>
|
|
|
|
#include <atomic>
|
|
|
|
#include <QSize>
|
|
#include <QString>
|
|
|
|
#include <qwayland-fractional-scale-v1.h>
|
|
#include <qwayland-viewporter.h>
|
|
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
|
#include <wayland-client-protocol.h>
|
|
|
|
namespace ZShell::internal {
|
|
|
|
class WallpaperService;
|
|
|
|
class WallpaperSurface : public QtWayland::zwlr_layer_surface_v1,
|
|
public QtWayland::wp_viewport,
|
|
public QtWayland::wp_fractional_scale_v1 {
|
|
public:
|
|
WallpaperSurface(
|
|
WallpaperService* service,
|
|
wl_surface* surface,
|
|
wl_output* output,
|
|
const QString& screen);
|
|
~WallpaperSurface() override;
|
|
|
|
[[nodiscard]] const QString& screen() const { return m_screen; }
|
|
|
|
[[nodiscard]] const QSize& size() const { return m_size; }
|
|
[[nodiscard]] const QSize& bufferSize() const { return m_bufferSize; }
|
|
[[nodiscard]] EGLSurface eglSurface() const { return m_eglSurface; }
|
|
|
|
void markDirty();
|
|
[[nodiscard]] bool needsDraw() const;
|
|
|
|
[[nodiscard]] bool frameReady() const;
|
|
|
|
void requestFrame();
|
|
|
|
void endDraw();
|
|
|
|
private:
|
|
void zwlr_layer_surface_v1_configure(
|
|
uint32_t serial, uint32_t width, uint32_t height) override;
|
|
void zwlr_layer_surface_v1_closed() override;
|
|
void wp_fractional_scale_v1_preferred_scale(uint32_t scale) override;
|
|
|
|
void updateBuffer();
|
|
|
|
void onFrameDone();
|
|
|
|
WallpaperService* m_service;
|
|
QString m_screen;
|
|
wl_surface* m_surface;
|
|
wl_egl_window* m_window = nullptr;
|
|
EGLSurface m_eglSurface = EGL_NO_SURFACE;
|
|
|
|
QSize m_size;
|
|
QSize m_bufferSize;
|
|
qreal m_scale = 1.0;
|
|
|
|
bool configured = false;
|
|
|
|
std::atomic<bool> m_dirty{false};
|
|
std::atomic<bool> m_frameReady{true};
|
|
struct wl_callback* m_frameCallback = nullptr;
|
|
};
|
|
|
|
} // namespace ZShell::internal
|