dont deadlock while receiving events

This commit is contained in:
Raphael Robatsch 2021-10-25 19:02:35 +02:00
commit 7298730969
7 changed files with 134 additions and 80 deletions

View file

@ -3,10 +3,12 @@
#pragma once
#include <wayland-client.h>
#include <memory>
#include <vector>
#include <QColor>
#include <QString>
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "net-tapesoftware-dwl-wm-unstable-v1-client-protocol.h"
extern wl_display *display;
extern wl_compositor *compositor;
@ -17,3 +19,17 @@ extern std::vector<QString> tagNames;
struct ColorScheme {
QColor fg, bg;
};
// wayland smart pointers
template<typename T>
struct wl_deleter;
#define WL_DELETER(type, fn) template<> struct wl_deleter<type> { void operator()(type *v) { if(v) fn(v); } }
template<typename T>
using wl_unique_ptr = std::unique_ptr<T, wl_deleter<T>>;
WL_DELETER(wl_surface, wl_surface_destroy);
WL_DELETER(zwlr_layer_surface_v1, zwlr_layer_surface_v1_destroy);
WL_DELETER(wl_buffer, wl_buffer_destroy);
WL_DELETER(wl_output, wl_output_release);
WL_DELETER(znet_tapesoftware_dwl_wm_monitor_v1, znet_tapesoftware_dwl_wm_monitor_v1_release);