From c8b0c9a1b22a6760551cae6cdccb47dc65356579 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 4 Apr 2025 23:54:26 +0200 Subject: Fix possible incorrect monitor --- src/CursorTrackerWayland.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/CursorTrackerWayland.cpp') diff --git a/src/CursorTrackerWayland.cpp b/src/CursorTrackerWayland.cpp index a7473b9..5f37d0a 100644 --- a/src/CursorTrackerWayland.cpp +++ b/src/CursorTrackerWayland.cpp @@ -399,24 +399,39 @@ namespace gsr { return; for(uint32_t i = 0; i < planes->count_planes; ++i) { + drmModePlanePtr plane = nullptr; + const drm_connector *connector = nullptr; int crtc_x = 0; int crtc_y = 0; int crtc_id = 0; bool is_cursor = false; - const uint32_t property_mask = plane_get_properties(drm_fd, planes->planes[i], &crtc_x, &crtc_y, &crtc_id, &is_cursor); + uint32_t property_mask = 0; + + plane = drmModeGetPlane(drm_fd, planes->planes[i]); + if(!plane) + goto next; + + if(!plane->fb_id) + goto next; + + property_mask = plane_get_properties(drm_fd, planes->planes[i], &crtc_x, &crtc_y, &crtc_id, &is_cursor); if(property_mask != plane_property_all || crtc_id <= 0) - continue; + goto next; - const drm_connector *connector = get_drm_connector_by_crtc_id(&connectors, crtc_id); + connector = get_drm_connector_by_crtc_id(&connectors, crtc_id); if(!connector) - continue; + goto next; if(crtc_x >= 0 && crtc_x <= connector->size.x && crtc_y >= 0 && crtc_y <= connector->size.y) { latest_cursor_position.x = crtc_x; latest_cursor_position.y = crtc_y; latest_crtc_id = crtc_id; + drmModeFreePlane(plane); break; } + + next: + drmModeFreePlane(plane); } drmModeFreePlaneResources(planes); -- cgit v1.2.3-70-g09d2