[vlc-commits] window: add callback for key press events

Rémi Denis-Courmont git at videolan.org
Sun May 20 19:51:07 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 20 11:03:06 2018 +0300| [57c428eab7c0be0c86c9f0ed824f27dd16013744] | committer: Rémi Denis-Courmont

window: add callback for key press events

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=57c428eab7c0be0c86c9f0ed824f27dd16013744
---

 include/vlc_vout_window.h | 4 +++-
 src/video_output/window.c | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index 65bef05f4b..f764c38fc1 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -121,6 +121,7 @@ struct vout_window_callbacks {
     void (*closed)(vout_window_t *);
     void (*mouse_event)(vout_window_t *,
                         const vout_window_mouse_event_t *mouse);
+    void (*keyboard_event)(vout_window_t *, unsigned key);
 };
 
 typedef struct vout_window_owner {
@@ -384,7 +385,8 @@ static inline void vout_window_ReportMouseDoubleClick(vout_window_t *window,
 
 static inline void vout_window_ReportKeyPress(vout_window_t *window, int key)
 {
-    var_SetInteger(window->obj.libvlc, "key-pressed", key);
+    if (window->owner.cbs->keyboard_event != NULL)
+        window->owner.cbs->keyboard_event(window, key);
 }
 
 /** @} */
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 64e3b8ccf7..62a5f1248d 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -163,10 +163,19 @@ static void vout_display_window_MouseEvent(vout_window_t *window,
     vout_WindowMouseEvent(vout, mouse);
 }
 
+static void vout_display_window_KeyboardEvent(vout_window_t *window,
+                                              unsigned key)
+{
+    vout_thread_t *vout = (vout_thread_t *)window->obj.parent;
+
+    vout_SendEventKey(vout, key);
+}
+
 static const struct vout_window_callbacks vout_display_window_cbs = {
     .resized = vout_display_window_ResizeNotify,
     .closed = vout_display_window_CloseNotify,
     .mouse_event = vout_display_window_MouseEvent,
+    .keyboard_event = vout_display_window_KeyboardEvent,
 };
 
 /**



More information about the vlc-commits mailing list