From fd668695db7ed5724888e71b4df34285fd72b495 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Mon, 28 Oct 2019 19:59:19 +1100 Subject: [PATCH] linux-capture: Fix cursor draw bug when cropping window cap. When cropping the left or top of a window capture, OBS would misalign the drawn cursor, placing it as if the entire window were being captured. Instead, offset the captured cursor by the same number of pixels, thus placing the cursor back where it belongs. --- plugins/linux-capture/xcompcap-main.cpp | 3 ++- plugins/linux-capture/xcursor.c | 5 +++-- plugins/linux-capture/xcursor.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/linux-capture/xcompcap-main.cpp b/plugins/linux-capture/xcompcap-main.cpp index a705c5672..9d3b15333 100644 --- a/plugins/linux-capture/xcompcap-main.cpp +++ b/plugins/linux-capture/xcompcap-main.cpp @@ -664,7 +664,8 @@ void XCompcapMain::render(gs_effect_t *effect) effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); while (gs_effect_loop(effect, "Draw")) { - xcursor_render(p->cursor); + xcursor_render(p->cursor, -p->cur_cut_left, + -p->cur_cut_top); } } } diff --git a/plugins/linux-capture/xcursor.c b/plugins/linux-capture/xcursor.c index 85bb73a4e..021fd4244 100644 --- a/plugins/linux-capture/xcursor.c +++ b/plugins/linux-capture/xcursor.c @@ -103,7 +103,7 @@ void xcursor_tick(xcursor_t *data) XFree(xc); } -void xcursor_render(xcursor_t *data) +void xcursor_render(xcursor_t *data, int x_offset, int y_offset) { if (!data->tex) return; @@ -117,7 +117,8 @@ void xcursor_render(xcursor_t *data) gs_enable_color(true, true, true, false); gs_matrix_push(); - gs_matrix_translate3f(data->render_x, data->render_y, 0.0f); + gs_matrix_translate3f(data->render_x + x_offset, + data->render_y + y_offset, 0.0f); gs_draw_sprite(data->tex, 0, 0, 0); gs_matrix_pop(); diff --git a/plugins/linux-capture/xcursor.h b/plugins/linux-capture/xcursor.h index 663156146..3c03a7b5d 100644 --- a/plugins/linux-capture/xcursor.h +++ b/plugins/linux-capture/xcursor.h @@ -61,7 +61,7 @@ void xcursor_tick(xcursor_t *data); * * This needs to be executed within a valid render context */ -void xcursor_render(xcursor_t *data); +void xcursor_render(xcursor_t *data, int x_offset, int y_offset); /** * Specify offset for the cursor