[vlc-commits] window: add events for fullscreen and window state
Rémi Denis-Courmont
git at videolan.org
Sun May 20 19:52:27 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 20 10:51:39 2018 +0300| [5efdbb4f9b4287f7f0ca0d27b2401412194dd267] | committer: Rémi Denis-Courmont
window: add events for fullscreen and window state
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5efdbb4f9b4287f7f0ca0d27b2401412194dd267
---
include/vlc_vout_window.h | 42 +++++++++++++++++++++++++++++++++++++++++-
src/video_output/window.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index beee306fb3..bc0431d047 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -70,7 +70,7 @@ enum vout_window_control {
/**
* Window management state.
*/
-enum {
+enum vout_window_state {
VOUT_WINDOW_STATE_NORMAL,
VOUT_WINDOW_STATE_ABOVE,
VOUT_WINDOW_STATE_BELOW,
@@ -117,6 +117,9 @@ typedef struct vout_window_cfg_t {
struct vout_window_callbacks {
void (*resized)(vout_window_t *, unsigned width, unsigned height);
void (*closed)(vout_window_t *);
+ void (*state_changed)(vout_window_t *, unsigned state);
+ void (*windowed)(vout_window_t *);
+ void (*fullscreened)(vout_window_t *, const char *id);
void (*mouse_event)(vout_window_t *,
const vout_window_mouse_event_t *mouse);
void (*keyboard_event)(vout_window_t *, unsigned key);
@@ -318,6 +321,43 @@ static inline void vout_window_ReportClose(vout_window_t *window)
window->owner.cbs->closed(window);
}
+/**
+ * Reports the current window state.
+ *
+ * This notifies the owner of the window that the state of the window changed.
+ * \param state \see vout_window_state
+ */
+static inline void vout_window_ReportState(vout_window_t *window,
+ unsigned state)
+{
+ if (window->owner.cbs->state_changed != NULL)
+ window->owner.cbs->state_changed(window, state);
+}
+
+/**
+ * Reports that the window is not in full screen.
+ *
+ * This notifies the owner of the window that the window is windowed, i.e. not
+ * in full screen mode.
+ */
+static inline void vout_window_ReportWindowed(vout_window_t *window)
+{
+ if (window->owner.cbs->windowed != NULL)
+ window->owner.cbs->windowed(window);
+}
+
+/**
+ * Reports that the window is in full screen.
+ *
+ * \param id fullscreen output nul-terminated identifier, NULL for default
+ */
+static inline void vout_window_ReportFullscreen(vout_window_t *window,
+ const char *id)
+{
+ if (window->owner.cbs->fullscreened != NULL)
+ window->owner.cbs->fullscreened(window, id);
+}
+
static inline void vout_window_SendMouseEvent(vout_window_t *window,
const vout_window_mouse_event_t *mouse)
{
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 19a93cbc17..13f5ca89a7 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -150,6 +150,36 @@ static void vout_display_window_CloseNotify(vout_window_t *window)
msg_Err(window, "window closed");
}
+static void vout_display_window_StateNotify(vout_window_t *window,
+ unsigned state)
+{
+ static const char states[][8] = {
+ [VOUT_WINDOW_STATE_NORMAL] = "normal",
+ [VOUT_WINDOW_STATE_ABOVE] = "above",
+ [VOUT_WINDOW_STATE_BELOW] = "below",
+ };
+
+ assert(state < ARRAY_SIZE(states));
+ msg_Dbg(window, "window state changed: %s", states[state]);
+ var_SetInteger(window->obj.parent, "window-state", state);
+}
+
+static void vout_display_window_FullscreenNotify(vout_window_t *window,
+ const char *id)
+{
+ msg_Dbg(window, (id != NULL) ? "window set to fullscreen on %s"
+ : "window set to fullscreen", id);
+ var_SetString(window->obj.parent, "window-fullscreen-output",
+ (id != NULL) ? id : "");
+ var_SetBool(window->obj.parent, "window-fullscreen", true);
+}
+
+static void vout_display_window_WindowingNotify(vout_window_t *window)
+{
+ msg_Dbg(window, "window set windowed");
+ var_SetBool(window->obj.parent, "window-fullscreen", false);
+}
+
static void vout_display_window_MouseEvent(vout_window_t *window,
const vout_window_mouse_event_t *ev)
{
@@ -213,6 +243,9 @@ static void vout_display_window_KeyboardEvent(vout_window_t *window,
static const struct vout_window_callbacks vout_display_window_cbs = {
.resized = vout_display_window_ResizeNotify,
.closed = vout_display_window_CloseNotify,
+ .state_changed = vout_display_window_StateNotify,
+ .fullscreened = vout_display_window_FullscreenNotify,
+ .windowed = vout_display_window_WindowingNotify,
.mouse_event = vout_display_window_MouseEvent,
.keyboard_event = vout_display_window_KeyboardEvent,
};
@@ -237,6 +270,10 @@ vout_window_t *vout_display_window_New(vout_thread_t *vout,
};
vout_window_t *window;
+ var_Create(vout, "window-state", VLC_VAR_INTEGER);
+ var_Create(vout, "window-fullscreen", VLC_VAR_BOOL);
+ var_Create(vout, "window-fullscreen-output", VLC_VAR_STRING);
+
window = vout_window_New((vlc_object_t *)vout, modlist, cfg, &owner);
free(modlist);
if (window == NULL)
@@ -250,8 +287,12 @@ vout_window_t *vout_display_window_New(vout_thread_t *vout,
*/
void vout_display_window_Delete(vout_window_t *window)
{
+ vout_thread_t *vout = (vout_thread_t *)(window->obj.parent);
vout_display_window_t *state = window->owner.sys;
vout_window_Delete(window);
+ var_Destroy(vout, "window-fullscreen-output");
+ var_Destroy(vout, "window-fullscreen");
+ var_Destroy(vout, "window-state");
free(state);
}
More information about the vlc-commits
mailing list