Skip to content

Commit

Permalink
core: fix segfault when cursor_shape is not supported (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: alcubierre-drive <alcubierre-drive>
  • Loading branch information
alcubierre-drive authored Jun 11, 2024
1 parent 36d9741 commit 67e0f34
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/events/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ void Events::handleCapabilities(void* data, wl_seat* wl_seat, uint32_t capabilit
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
const auto POINTER = wl_seat_get_pointer(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 {
Debug::log(CRIT, "Hyprpicker cannot work without a pointer!");
g_pHyprpicker->finish(1);
Expand All @@ -103,11 +105,14 @@ void Events::handlePointerEnter(void* data, struct wl_pointer* wl_pointer, uint3
if (!ls->pCursorImg)
break;

// wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale);
// 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);
wp_cursor_shape_device_v1_set_shape(g_pHyprpicker->m_pCursorShapeDevice, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR);
if (g_pHyprpicker->m_pCursorShapeDevice) {
wp_cursor_shape_device_v1_set_shape(g_pHyprpicker->m_pCursorShapeDevice, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR);
} else {
wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale);
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);
}
}
}
}
Expand Down

0 comments on commit 67e0f34

Please sign in to comment.