mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-09-11 19:07:40 +03:00
fix crashes with removing outputs
This commit is contained in:
parent
f77a664e9d
commit
1a147160cf
@ -86,6 +86,22 @@ void Events::ls_configure(void *data, zwlr_layer_surface_v1 *surface, uint32_t s
|
||||
Debug::log(LOG, "configure for %s", PLAYERSURFACE->m_pMonitor->name.c_str());
|
||||
}
|
||||
|
||||
void Events::handleLSClosed(void *data, zwlr_layer_surface_v1 *zwlr_layer_surface_v1) {
|
||||
const auto PLAYERSURFACE = (CLayerSurface*)data;
|
||||
|
||||
for (auto& m : g_pHyprpaper->m_vMonitors) {
|
||||
std::erase_if(m->layerSurfaces, [&](const auto& other) { return other.get() == PLAYERSURFACE; });
|
||||
if (m->pCurrentLayerSurface == PLAYERSURFACE) {
|
||||
if (m->layerSurfaces.empty()) {
|
||||
m->pCurrentLayerSurface = nullptr;
|
||||
} else {
|
||||
m->pCurrentLayerSurface = m->layerSurfaces.begin()->get();
|
||||
g_pHyprpaper->recheckMonitor(m.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Events::handleGlobal(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) {
|
||||
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||
g_pHyprpaper->m_sCompositor = (wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 4);
|
||||
@ -109,6 +125,12 @@ void Events::handleGlobal(void *data, struct wl_registry *registry, uint32_t nam
|
||||
}
|
||||
|
||||
void Events::handleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) {
|
||||
// todo
|
||||
for (auto& m : g_pHyprpaper->m_vMonitors) {
|
||||
if (m->wayland_name == name) {
|
||||
Debug::log(LOG, "Destroying output %s", m->name.c_str());
|
||||
std::erase_if(g_pHyprpaper->m_vMonitors, [&](const auto& other) { return other->wayland_name == name; });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace Events {
|
||||
|
||||
void ls_configure(void *data, zwlr_layer_surface_v1 *surface, uint32_t serial, uint32_t width, uint32_t height);
|
||||
|
||||
void handleLSClosed(void *data, zwlr_layer_surface_v1 *zwlr_layer_surface_v1);
|
||||
|
||||
void handleGlobal(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
|
||||
|
||||
void handleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name);
|
||||
@ -35,7 +37,7 @@ namespace Events {
|
||||
|
||||
inline const wl_output_listener outputListener = {.geometry = geometry, .mode = mode, .done = done, .scale = scale, .name = name, .description = description};
|
||||
|
||||
inline const zwlr_layer_surface_v1_listener layersurfaceListener = { .configure = ls_configure };
|
||||
inline const zwlr_layer_surface_v1_listener layersurfaceListener = { .configure = ls_configure, .closed = handleLSClosed };
|
||||
|
||||
inline const struct wl_registry_listener registryListener = { .global = handleGlobal, .global_remove = handleGlobalRemove };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user