]> git.sesse.net Git - vlc/commitdiff
libvlc_video_get_cursor: get the current mouse video coordinates
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 11 Feb 2010 16:26:54 +0000 (18:26 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 11 Feb 2010 16:27:24 +0000 (18:27 +0200)
include/vlc/libvlc_media_player.h
src/control/video.c
src/libvlc.sym

index d8c930b940c265f11ed3fe728e9c571fdf2485e8..029ddb17f1441dfa72e998a48bdf39ea626c7713 100644 (file)
@@ -588,6 +588,32 @@ int libvlc_video_get_height( libvlc_media_player_t *p_mi );
 VLC_DEPRECATED_API
 int libvlc_video_get_width( libvlc_media_player_t *p_mi );
 
+/**
+ * Get the mouse pointer coordinates over a video.
+ * Coordinates are expressed in terms of the decoded video resolution,
+ * <b>not</b> in terms of pixels on the screen/viewport (to get the latter,
+ * you can query your windowing system directly).
+ *
+ * Either of the coordinates may be negative or larger than the corresponding
+ * dimension of the video, if the cursor is outside the rendering area.
+ *
+ * @warning The coordinates may be out-of-date if the pointer is not located
+ * on the video rendering area. LibVLC does not track the pointer if it is
+ * outside of the video widget.
+ *
+ * @note LibVLC does not support multiple pointers (it does of course support
+ * multiple input devices sharing the same pointer) at the moment.
+ *
+ * \param p_mi media player
+ * \param num number of the video (starting from, and most commonly 0)
+ * \param px pointer to get the abscissa [OUT]
+ * \param py pointer to get the ordinate [OUT]
+ * \return 0 on success, -1 if the specified video does not exist
+ */
+VLC_PUBLIC_API
+int libvlc_video_get_cursor( libvlc_media_player_t *p_mi, unsigned num,
+                             int *px, int *py );
+
 /**
  * Get the current video scaling factor.
  * See also libvlc_video_set_scale().
index e9f8ed728caea2ceb7145a8bd3d4cd273e9943c0..db90825c92744bdd3e4bbbbe25e959f900f6146b 100644 (file)
@@ -186,6 +186,19 @@ int libvlc_video_get_width( libvlc_media_player_t *p_mi )
     return width;
 }
 
+int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num,
+                             int *px, int *py )
+{
+    vout_thread_t *p_vout = GetVout (mp, num);
+    if (p_vout == NULL)
+        return -1;
+
+    *px = var_GetInteger (p_vout, "mouse-x");
+    *py = var_GetInteger (p_vout, "mouse-y");
+    vlc_object_release (p_vout);
+    return 0;
+}
+
 unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi )
 {
     size_t n;
index d0a21c4252e1debc0b003ecf9786cc26bffd0f01..15965ef09fb3f9a8d68c5f7b328e5efb2aa703ea 100644 (file)
@@ -165,6 +165,7 @@ libvlc_video_get_chapter_description
 libvlc_video_get_crop_geometry
 libvlc_video_get_size
 libvlc_video_get_height
+libvlc_video_get_cursor
 libvlc_video_get_logo_int
 libvlc_video_get_marquee_int
 libvlc_video_get_marquee_string