core: fix segfault when cursor_shape is not supported (#76)

Co-authored-by: alcubierre-drive <alcubierre-drive>
This commit is contained in:
Lennart Klebl 2024-06-11 17:18:23 +02:00 committed by GitHub
parent 36d974181d
commit 67e0f34e27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 6 deletions

View File

@ -82,7 +82,9 @@ void Events::handleCapabilities(void* data, wl_seat* wl_seat, uint32_t capabilit
if (capabilities & WL_SEAT_CAPABILITY_POINTER) { if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
const auto POINTER = wl_seat_get_pointer(wl_seat); const auto POINTER = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(POINTER, &pointerListener, wl_seat); wl_pointer_add_listener(POINTER, &pointerListener, wl_seat);
g_pHyprpicker->m_pCursorShapeDevice = wp_cursor_shape_manager_v1_get_pointer(g_pHyprpicker->m_pCursorShape, POINTER); g_pHyprpicker->m_pCursorShapeDevice = (g_pHyprpicker->m_pCursorShape) ?
wp_cursor_shape_manager_v1_get_pointer(g_pHyprpicker->m_pCursorShape, POINTER) :
nullptr;
} else { } else {
Debug::log(CRIT, "Hyprpicker cannot work without a pointer!"); Debug::log(CRIT, "Hyprpicker cannot work without a pointer!");
g_pHyprpicker->finish(1); g_pHyprpicker->finish(1);
@ -103,11 +105,14 @@ void Events::handlePointerEnter(void* data, struct wl_pointer* wl_pointer, uint3
if (!ls->pCursorImg) if (!ls->pCursorImg)
break; break;
// wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale); if (g_pHyprpicker->m_pCursorShapeDevice) {
// wl_surface_attach(ls->pCursorSurface, wl_cursor_image_get_buffer(ls->pCursorImg), 0, 0); wp_cursor_shape_device_v1_set_shape(g_pHyprpicker->m_pCursorShapeDevice, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR);
// wl_pointer_set_cursor(wl_pointer, serial, ls->pCursorSurface, ls->pCursorImg->hotspot_x / ls->m_pMonitor->scale, ls->pCursorImg->hotspot_y / ls->m_pMonitor->scale); } else {
// wl_surface_commit(ls->pCursorSurface); wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale);
wp_cursor_shape_device_v1_set_shape(g_pHyprpicker->m_pCursorShapeDevice, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR); wl_surface_attach(ls->pCursorSurface, wl_cursor_image_get_buffer(ls->pCursorImg), 0, 0);
wl_pointer_set_cursor(wl_pointer, serial, ls->pCursorSurface, ls->pCursorImg->hotspot_x / ls->m_pMonitor->scale, ls->pCursorImg->hotspot_y / ls->m_pMonitor->scale);
wl_surface_commit(ls->pCursorSurface);
}
} }
} }
} }