소스 검색

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.
Chris Angelico 6 년 전
부모
커밋
fd668695db
3개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 1
      plugins/linux-capture/xcompcap-main.cpp
  2. 3 2
      plugins/linux-capture/xcursor.c
  3. 1 1
      plugins/linux-capture/xcursor.h

+ 2 - 1
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);
 		}
 	}
 }

+ 3 - 2
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();
 

+ 1 - 1
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