diff --git a/plugins/win-capture/cursor-capture.c b/plugins/win-capture/cursor-capture.c index b244de98b..76a63190a 100644 --- a/plugins/win-capture/cursor-capture.c +++ b/plugins/win-capture/cursor-capture.c @@ -188,15 +188,20 @@ void cursor_capture(struct cursor_data *data) } void cursor_draw(struct cursor_data *data, long x_offset, long y_offset, - float x_scale, float y_scale) + float x_scale, float y_scale, long width, long height) { - long x = data->cursor_pos.x + x_offset - data->x_hotspot; - long y = data->cursor_pos.y + y_offset - data->y_hotspot; + long x = data->cursor_pos.x + x_offset; + long y = data->cursor_pos.y + y_offset; + long x_draw = x - data->x_hotspot; + long y_draw = y - data->y_hotspot; + + if (x < 0 || x > width || y < 0 || y > height) + return; if (data->visible && !!data->texture) { gs_matrix_push(); gs_matrix_scale3f(x_scale, y_scale, 1.0f); - obs_source_draw(data->texture, x, y, 0, 0, false); + obs_source_draw(data->texture, x_draw, y_draw, 0, 0, false); gs_matrix_pop(); } } diff --git a/plugins/win-capture/cursor-capture.h b/plugins/win-capture/cursor-capture.h index 5db7708ca..36df19127 100644 --- a/plugins/win-capture/cursor-capture.h +++ b/plugins/win-capture/cursor-capture.h @@ -13,5 +13,5 @@ struct cursor_data { extern void cursor_capture(struct cursor_data *data); extern void cursor_draw(struct cursor_data *data, long x_offset, long y_offset, - float x_scale, float y_scale); + float x_scale, float y_scale, long width, long height); extern void cursor_data_free(struct cursor_data *data); diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index bd0ca1915..85bd78f48 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -982,7 +982,9 @@ static inline void game_capture_render_cursor(struct game_capture *gc) float y_scale = (float)gc->global_hook_info->cy / (float)gc->global_hook_info->base_cy; - cursor_draw(&gc->cursor_data, -p.x, -p.y, x_scale, y_scale); + cursor_draw(&gc->cursor_data, -p.x, -p.y, x_scale, y_scale, + gc->global_hook_info->base_cx, + gc->global_hook_info->base_cy); } static void game_capture_render(void *data, gs_effect_t *effect)