Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix segmentation fault when cursor_shape_manager_v1 is not supported #76

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading