From fded9b8d57facde1a01e9456d9fd9c3b6955dd23 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 25 May 2025 14:56:46 +0200 Subject: Match gsr monitor name with wayland monitor name. Thanks info@leocodes --- meson.build | 2 +- project.conf | 2 +- src/CursorTracker/CursorTrackerWayland.cpp | 34 ++++-------------------------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/meson.build b/meson.build index 7672724..8b53fdd 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('gsr-ui', ['c', 'cpp'], version : '1.6.4', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends') +project('gsr-ui', ['c', 'cpp'], version : '1.6.5', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends') if get_option('buildtype') == 'debug' add_project_arguments('-g3', language : ['c', 'cpp']) diff --git a/project.conf b/project.conf index 8e27245..16f0d59 100644 --- a/project.conf +++ b/project.conf @@ -1,7 +1,7 @@ [package] name = "gsr-ui" type = "executable" -version = "1.6.4" +version = "1.6.5" platforms = ["posix"] [lang.cpp] diff --git a/src/CursorTracker/CursorTrackerWayland.cpp b/src/CursorTracker/CursorTrackerWayland.cpp index b28b978..7af86b4 100644 --- a/src/CursorTracker/CursorTrackerWayland.cpp +++ b/src/CursorTracker/CursorTrackerWayland.cpp @@ -9,14 +9,8 @@ namespace gsr { static const int MAX_CONNECTORS = 32; - static const int CONNECTOR_TYPE_COUNTS = 32; static const uint32_t plane_property_all = 0xF; - typedef struct { - int type; - int count; - } drm_connector_type_count; - typedef enum { PLANE_PROPERTY_CRTC_X = 1 << 0, PLANE_PROPERTY_CRTC_Y = 1 << 1, @@ -105,22 +99,6 @@ namespace gsr { return get_drm_property_by_name(drm_fd, &properties, name, result); } - static drm_connector_type_count* drm_connector_types_get_index(drm_connector_type_count *type_counts, int *num_type_counts, int connector_type) { - for(int i = 0; i < *num_type_counts; ++i) { - if(type_counts[i].type == connector_type) - return &type_counts[i]; - } - - if(*num_type_counts == CONNECTOR_TYPE_COUNTS) - return NULL; - - const int index = *num_type_counts; - type_counts[index].type = connector_type; - type_counts[index].count = 0; - ++*num_type_counts; - return &type_counts[index]; - } - // Note: this monitor name logic is kept in sync with gpu screen recorder static std::string get_monitor_name_from_crtc_id(int drm_fd, uint32_t crtc_id) { std::string result; @@ -128,27 +106,23 @@ namespace gsr { if(!resources) return result; - drm_connector_type_count type_counts[CONNECTOR_TYPE_COUNTS]; - int num_type_counts = 0; - for(int i = 0; i < resources->count_connectors; ++i) { uint64_t connector_crtc_id = 0; drmModeConnectorPtr connector = drmModeGetConnectorCurrent(drm_fd, resources->connectors[i]); if(!connector) continue; - drm_connector_type_count *connector_type = drm_connector_types_get_index(type_counts, &num_type_counts, connector->connector_type); const char *connection_name = drmModeGetConnectorTypeName(connector->connector_type); - if(connector_type) - ++connector_type->count; + if(!connection_name) + goto next; if(connector->connection != DRM_MODE_CONNECTED) goto next; - if(connector_type && connector_get_property_by_name(drm_fd, connector, "CRTC_ID", &connector_crtc_id) && connector_crtc_id == crtc_id) { + if(connector_get_property_by_name(drm_fd, connector, "CRTC_ID", &connector_crtc_id) && connector_crtc_id == crtc_id) { result = connection_name; result += "-"; - result += std::to_string(connector_type->count); + result += std::to_string(connector->connector_type_id); drmModeFreeConnector(connector); break; } -- cgit v1.2.3-70-g09d2