[vlc-commits] display: reorient mouse pointer position
Rémi Denis-Courmont
git at videolan.org
Mon Dec 31 17:40:17 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 31 15:38:50 2018 +0200| [638cf7ef5fc40cd78084849c801bb396b8a6c400] | committer: Rémi Denis-Courmont
display: reorient mouse pointer position
Handle non-standard video orientation when translating the cursor
coordinates.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=638cf7ef5fc40cd78084849c801bb396b8a6c400
---
src/video_output/display.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 093889f61a..5bff2867b2 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -236,12 +236,48 @@ void vout_display_TranslateMouseState(vout_display_t *vd, vlc_mouse_t *video,
return;
}
+ const int wx = window->i_x, wy = window->i_y;
+ int x, y;
+
+ switch (vd->source.orientation) {
+ case ORIENT_TOP_LEFT:
+ x = wx;
+ y = wy;
+ break;
+ case ORIENT_TOP_RIGHT:
+ x = place.width - wx;
+ y = wy;
+ break;
+ case ORIENT_BOTTOM_LEFT:
+ x = wx;
+ y = place.height - wy;
+ break;
+ case ORIENT_BOTTOM_RIGHT:
+ x = place.width - wx;
+ y = place.height - wy;
+ break;
+ case ORIENT_LEFT_TOP:
+ x = wy;
+ y = wx;
+ break;
+ case ORIENT_LEFT_BOTTOM:
+ x = wy;
+ y = place.width - wx;
+ break;
+ case ORIENT_RIGHT_TOP:
+ x = place.height - wy;
+ y = wx;
+ break;
+ case ORIENT_RIGHT_BOTTOM:
+ x = place.height - wy;
+ y = place.width - wx;
+ break;
+ }
+
video->i_x = vd->source.i_x_offset
- + (int64_t)(window->i_x - place.x)
- * vd->source.i_visible_width / place.width;
+ + (int64_t)(x - place.x) * vd->source.i_visible_width / place.width;
video->i_y = vd->source.i_y_offset
- + (int64_t)(window->i_y - place.y)
- * vd->source.i_visible_height / place.height;
+ + (int64_t)(y - place.y) * vd->source.i_visible_height / place.height;
video->i_pressed = window->i_pressed;
video->b_double_click = window->b_double_click;
}
More information about the vlc-commits
mailing list