From 76c565684f0bec0ac02062cba134abd0dd3ce1aa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 8 Nov 2024 23:57:59 +0100 Subject: Prefer drm cursor over x11 on x11, to fix correct position and size when x11 output is scaled --- src/capture/kms.c | 8 +++++--- src/utils.c | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/capture/kms.c b/src/capture/kms.c index 5292012..fd85134 100644 --- a/src/capture/kms.c +++ b/src/capture/kms.c @@ -636,11 +636,13 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c gsr_kms_response_item *cursor_drm_fd = find_cursor_drm_if_on_monitor(self, drm_fd->connector_id, capture_is_combined_plane); // The cursor is handled by x11 on x11 instead of using the cursor drm plane because on prime systems with a dedicated nvidia gpu // the cursor plane is not available when the cursor is on the monitor controlled by the nvidia device. - if(self->is_x11) { + // TODO: This doesn't work properly with software cursor on x11 since it will draw the x11 cursor on top of the cursor already in the framebuffer. + // Detect if software cursor is used on x11 somehow. + if(cursor_drm_fd) { + render_drm_cursor(self, color_conversion, cursor_drm_fd, target_pos, texture_rotation, output_size); + } else if(self->is_x11) { const vec2i cursor_monitor_offset = self->capture_pos; render_x11_cursor(self, color_conversion, cursor_monitor_offset, target_pos, output_size); - } else if(cursor_drm_fd) { - render_drm_cursor(self, color_conversion, cursor_drm_fd, target_pos, texture_rotation, output_size); } } diff --git a/src/utils.c b/src/utils.c index 976401f..a8e4dc2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -94,9 +94,9 @@ void for_each_active_monitor_output_x11_not_cached(Display *display, active_moni if(out_info && out_info->crtc && out_info->connection == RR_Connected) { XRRCrtcInfo *crt_info = XRRGetCrtcInfo(display, screen_res, out_info->crtc); if(crt_info && crt_info->mode) { - // We want to use the current mode info width/height instead of crtc info width/height becuase crtc info is scaled if the monitor is scaled - // (xrandr --output DP-1 --scale 1.5). Normally this is not an issue for x11 applications, but gpu screen recorder captures the drm framebuffer - // instead of x11 api. This drm framebuffer which doesn't increase in size when using xrandr scaling. + // We want to use the current mode info width/height (mode_info->width/height) instead of crtc info width/height (crt_info->width/height) because crtc info + // is scaled if the monitor is scaled (xrandr --output DP-1 --scale 1.5). Normally this is not an issue for x11 applications, + // but gpu screen recorder captures the drm framebuffer instead of x11 api. This drm framebuffer which doesn't increase in size when using xrandr scaling. // Maybe a better option would be to get the drm crtc size instead. const XRRModeInfo *mode_info = get_mode_info(screen_res, crt_info->mode); if(mode_info && out_info->nameLen < (int)sizeof(display_name)) { -- cgit v1.2.3