mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-04 22:10:44 +09:00
Fix possible incorrect monitor
This commit is contained in:
2
TODO
2
TODO
@@ -153,4 +153,4 @@ Use /dev/input/eventN (or /dev/hidrawN) instead of /dev/input/jsN for joystick i
|
|||||||
|
|
||||||
Verify if cursor tracker monitor name is always correct. It uses the wayland monitor name for recording, but gpu screen recorder uses a custom name created from the drm connector name.
|
Verify if cursor tracker monitor name is always correct. It uses the wayland monitor name for recording, but gpu screen recorder uses a custom name created from the drm connector name.
|
||||||
|
|
||||||
Notification with the focused monitor (with CursorTrackerWayland) assumes that the x11 monitor name is the same as the drm monitor name.
|
Notification with the focused monitor (with CursorTrackerWayland) assumes that the x11 monitor name is the same as the drm monitor name. Same for find_monitor_by_name.
|
||||||
@@ -399,24 +399,39 @@ namespace gsr {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for(uint32_t i = 0; i < planes->count_planes; ++i) {
|
for(uint32_t i = 0; i < planes->count_planes; ++i) {
|
||||||
|
drmModePlanePtr plane = nullptr;
|
||||||
|
const drm_connector *connector = nullptr;
|
||||||
int crtc_x = 0;
|
int crtc_x = 0;
|
||||||
int crtc_y = 0;
|
int crtc_y = 0;
|
||||||
int crtc_id = 0;
|
int crtc_id = 0;
|
||||||
bool is_cursor = false;
|
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;
|
||||||
if(property_mask != plane_property_all || crtc_id <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const drm_connector *connector = get_drm_connector_by_crtc_id(&connectors, crtc_id);
|
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)
|
||||||
|
goto next;
|
||||||
|
|
||||||
|
connector = get_drm_connector_by_crtc_id(&connectors, crtc_id);
|
||||||
if(!connector)
|
if(!connector)
|
||||||
continue;
|
goto next;
|
||||||
|
|
||||||
if(crtc_x >= 0 && crtc_x <= connector->size.x && crtc_y >= 0 && crtc_y <= connector->size.y) {
|
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.x = crtc_x;
|
||||||
latest_cursor_position.y = crtc_y;
|
latest_cursor_position.y = crtc_y;
|
||||||
latest_crtc_id = crtc_id;
|
latest_crtc_id = crtc_id;
|
||||||
|
drmModeFreePlane(plane);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next:
|
||||||
|
drmModeFreePlane(plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
drmModeFreePlaneResources(planes);
|
drmModeFreePlaneResources(planes);
|
||||||
|
|||||||
@@ -216,6 +216,16 @@ namespace gsr {
|
|||||||
return &monitors.front();
|
return &monitors.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the first monitor if not found. Assumes there is at least one monitor connected.
|
||||||
|
static const Monitor* find_monitor_by_name(const std::vector<Monitor> &monitors, const std::string &name) {
|
||||||
|
assert(!monitors.empty());
|
||||||
|
for(const Monitor &monitor : monitors) {
|
||||||
|
if(monitor.name == name)
|
||||||
|
return &monitor;
|
||||||
|
}
|
||||||
|
return &monitors.front();
|
||||||
|
}
|
||||||
|
|
||||||
static std::string get_power_supply_online_filepath() {
|
static std::string get_power_supply_online_filepath() {
|
||||||
std::string result;
|
std::string result;
|
||||||
const char *paths[] = {
|
const char *paths[] = {
|
||||||
@@ -846,7 +856,7 @@ namespace gsr {
|
|||||||
mgl::vec2i cursor_position = get_cursor_position(display, &x11_cursor_window);
|
mgl::vec2i cursor_position = get_cursor_position(display, &x11_cursor_window);
|
||||||
const Monitor *focused_monitor = nullptr;
|
const Monitor *focused_monitor = nullptr;
|
||||||
if(cursor_info) {
|
if(cursor_info) {
|
||||||
focused_monitor = find_monitor_at_position(monitors, cursor_info->position);
|
focused_monitor = find_monitor_by_name(monitors, cursor_info->monitor_name);
|
||||||
cursor_position = cursor_info->position;
|
cursor_position = cursor_info->position;
|
||||||
} else {
|
} else {
|
||||||
const mgl::vec2i monitor_position_query_value = (x11_cursor_window || gsr_info.system_info.display_server != DisplayServer::WAYLAND) ? cursor_position : create_window_get_center_position(display);
|
const mgl::vec2i monitor_position_query_value = (x11_cursor_window || gsr_info.system_info.display_server != DisplayServer::WAYLAND) ? cursor_position : create_window_get_center_position(display);
|
||||||
|
|||||||
Reference in New Issue
Block a user