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.
This commit is contained in:
Chris Angelico 2019-10-28 19:59:19 +11:00 committed by jp9000
parent cafc9995d8
commit fd668695db
3 changed files with 6 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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