diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CursorTracker/CursorTrackerWayland.cpp | 34 | ||||
-rw-r--r-- | src/Overlay.cpp | 20 | ||||
-rw-r--r-- | src/gui/SettingsPage.cpp | 2 |
3 files changed, 21 insertions, 35 deletions
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; } diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 685d95e..8a60b91 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -37,6 +37,7 @@ #include <X11/Xcursor/Xcursor.h> #include <mglpp/system/Rect.hpp> #include <mglpp/window/Event.hpp> +#include <mglpp/system/Utf8.hpp> extern "C" { #include <mgl/mgl.h> @@ -903,6 +904,7 @@ namespace gsr { // Wayland doesn't allow XGrabPointer/XGrabKeyboard when a wayland application is focused. // If the focused window is a wayland application then don't use override redirect and instead create // a fullscreen window for the ui. + // TODO: (x11_cursor_window && is_window_fullscreen_on_monitor(display, x11_cursor_window, *focused_monitor)) const bool prevent_game_minimizing = gsr_info.system_info.display_server != DisplayServer::WAYLAND || x11_cursor_window || is_wlroots; if(prevent_game_minimizing) { @@ -1640,10 +1642,22 @@ namespace gsr { return result; } - // TODO: Utf8 truncate static void truncate_string(std::string &str, int max_length) { - if((int)str.size() > max_length) - str.replace(str.begin() + max_length, str.end(), "..."); + int index = 0; + size_t byte_index = 0; + + while(index < max_length && byte_index < str.size()) { + uint32_t codepoint = 0; + size_t codepoint_length = 0; + mgl::utf8_decode((const unsigned char*)str.c_str() + byte_index, str.size() - byte_index, &codepoint, &codepoint_length); + if(codepoint_length == 0) + codepoint_length = 1; + + index += 1; + byte_index += codepoint_length; + } + + str.erase(byte_index); } void Overlay::save_video_in_current_game_directory(const char *video_filepath, NotificationType notification_type) { diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index ce556b9..1230290 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -768,7 +768,6 @@ namespace gsr { list->add_widget(std::move(replay_storage_button)); list->set_visible(gsr_info->system_info.gsr_version >= GsrVersion{5, 5, 0}); - replay_storage_list_ptr = list.get(); return list; } @@ -837,7 +836,6 @@ namespace gsr { notifications_subsection_ptr->set_visible(advanced_view); set_application_audio_options_visible(audio_track_section_list_ptr, advanced_view, *gsr_info); settings_scrollable_page_ptr->reset_scroll(); - replay_storage_list_ptr->set_visible(advanced_view && gsr_info->system_info.gsr_version >= GsrVersion{5, 5, 0}); } void SettingsPage::add_replay_widgets() { |