From 83d5ba42f8a98fc0df177efef4333f74a0481f61 Mon Sep 17 00:00:00 2001 From: pants Date: Mon, 21 Sep 2026 14:18:06 -0700 Subject: init --- src/canvas/wayland/window/waylandshm.hpp | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/canvas/wayland/window/waylandshm.hpp (limited to 'src/canvas/wayland/window/waylandshm.hpp') diff --git a/src/canvas/wayland/window/waylandshm.hpp b/src/canvas/wayland/window/waylandshm.hpp new file mode 100644 index 0000000..f275c4c --- /dev/null +++ b/src/canvas/wayland/window/waylandshm.hpp @@ -0,0 +1,77 @@ +// Display images inside a terminal +// Copyright (C) 2023 JustKidding +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef WAYLAND_SHM_WINDOW_H +#define WAYLAND_SHM_WINDOW_H + +#include "../wayland.hpp" +#include "image.hpp" +#include "shm.hpp" +#include "wayland-xdg-shell-client-protocol.h" +#include "waylandwindow.hpp" + +#include +#include +#include +#include +#include + +class WaylandShmWindow : public WaylandWindow +{ + public: + WaylandShmWindow(WaylandCanvas *canvas, std::unique_ptr new_image, struct XdgStructAgg *xdg_agg, + WaylandConfig *config); + ~WaylandShmWindow() override; + static void xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial); + static void wl_surface_frame_done(void *data, struct wl_callback *callback, uint32_t time); + + void draw() override {} + void wl_draw(int32_t scale_factor) override; + void generate_frame() override; + void show() override; + void hide() override; + + void finish_init() override; + + std::mutex draw_mutex; + std::atomic visible{false}; + std::unique_ptr shm; + int32_t output_scale; + + private: + WaylandConfig *config; + + struct xdg_wm_base *xdg_base = nullptr; + struct wl_surface *surface = nullptr; + struct xdg_surface *xdg_surface = nullptr; + struct xdg_toplevel *xdg_toplevel = nullptr; + struct wl_callback *callback; + + std::unique_ptr image; + std::string appid; + + struct XdgStructAgg *xdg_agg; + void *this_ptr; + + void move_window(); + void xdg_setup(); + + void setup_listeners(); + void delete_wayland_structs(); + void delete_xdg_structs(); +}; + +#endif -- cgit v1.2.3