mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-11-16 16:15:58 +01:00
core: avoid leaving garbage buffers on exit
This commit is contained in:
parent
0eea88367a
commit
deaca6a4d8
3 changed files with 16 additions and 9 deletions
|
@ -276,7 +276,8 @@ void Events::handleBufferRelease(void* data, struct wl_buffer* wl_buffer) {
|
|||
void Events::handleSCBuffer(void* data, struct zwlr_screencopy_frame_v1* frame, uint32_t format, uint32_t width, uint32_t height, uint32_t stride) {
|
||||
const auto PLS = (CLayerSurface*)data;
|
||||
|
||||
g_pHyprpicker->createBuffer(&PLS->screenBuffer, width, height, format, stride);
|
||||
if (!PLS->screenBuffer.buffer)
|
||||
g_pHyprpicker->createBuffer(&PLS->screenBuffer, width, height, format, stride);
|
||||
|
||||
zwlr_screencopy_frame_v1_copy(frame, PLS->screenBuffer.buffer);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
|
|||
}
|
||||
|
||||
zwlr_layer_surface_v1_set_size(pLayerSurface, 0, 0);
|
||||
zwlr_layer_surface_v1_set_anchor(pLayerSurface, ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
|
||||
zwlr_layer_surface_v1_set_anchor(
|
||||
pLayerSurface, ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(pLayerSurface, -1);
|
||||
zwlr_layer_surface_v1_set_keyboard_interactivity(pLayerSurface, true);
|
||||
zwlr_layer_surface_v1_add_listener(pLayerSurface, &Events::layersurfaceListener, this);
|
||||
|
@ -38,4 +39,8 @@ CLayerSurface::~CLayerSurface() {
|
|||
|
||||
if (g_pHyprpicker->m_pWLDisplay)
|
||||
wl_display_flush(g_pHyprpicker->m_pWLDisplay);
|
||||
|
||||
g_pHyprpicker->destroyBuffer(&buffers[0]);
|
||||
g_pHyprpicker->destroyBuffer(&buffers[1]);
|
||||
g_pHyprpicker->destroyBuffer(&screenBuffer);
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
#include "hyprpicker.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
#include "events/Events.hpp"
|
||||
|
||||
void sigHandler(int sig) {
|
||||
g_pHyprpicker->m_vLayerSurfaces.clear();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void CHyprpicker::init() {
|
||||
m_pWLDisplay = wl_display_connect(nullptr);
|
||||
|
||||
|
@ -11,6 +16,8 @@ void CHyprpicker::init() {
|
|||
return;
|
||||
}
|
||||
|
||||
signal(SIGTERM, sigHandler);
|
||||
|
||||
m_pWLRegistry = wl_display_get_registry(m_pWLDisplay);
|
||||
|
||||
wl_registry_add_listener(m_pWLRegistry, &Events::registryListener, nullptr);
|
||||
|
@ -42,12 +49,6 @@ void CHyprpicker::init() {
|
|||
}
|
||||
|
||||
void CHyprpicker::finish(int code) {
|
||||
for (auto& ls : m_vLayerSurfaces) {
|
||||
destroyBuffer(&ls->buffers[0]);
|
||||
destroyBuffer(&ls->buffers[1]);
|
||||
destroyBuffer(&ls->screenBuffer);
|
||||
}
|
||||
|
||||
m_vLayerSurfaces.clear();
|
||||
|
||||
if (m_pWLDisplay) {
|
||||
|
|
Loading…
Reference in a new issue