[vlc-commits] window: use separate callbacks for fullscreen
Rémi Denis-Courmont
git at videolan.org
Sun Dec 2 18:41:50 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec 1 17:38:16 2018 +0200| [f7795c4a13fed4343ec6f1cf4b1a4e2f14bf9769] | committer: Rémi Denis-Courmont
window: use separate callbacks for fullscreen
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7795c4a13fed4343ec6f1cf4b1a4e2f14bf9769
---
include/vlc_vout_window.h | 22 ++++------
modules/gui/macosx/VLCVideoOutputProvider.m | 52 ++++++++++++++--------
modules/gui/minimal_macosx/intf.m | 39 +++++++++++------
modules/gui/qt/main_interface.cpp | 22 +++++++---
modules/gui/qt/main_interface.hpp | 3 ++
modules/gui/qt/qt.cpp | 2 +
modules/gui/skins2/src/skin_main.cpp | 33 +++++++++-----
modules/video_output/wayland/xdg-shell.c | 67 ++++++++++++++++-------------
modules/video_output/wdummy.c | 2 -
modules/video_output/xcb/window.c | 25 ++++++++---
10 files changed, 166 insertions(+), 101 deletions(-)
diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index 0a28bd690e..3c9f6073d6 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -61,8 +61,6 @@ enum vout_window_type {
enum vout_window_control {
VOUT_WINDOW_SET_STATE, /* unsigned state */
VOUT_WINDOW_SET_SIZE, /* unsigned i_width, unsigned i_height */
- VOUT_WINDOW_SET_FULLSCREEN, /* void */
- VOUT_WINDOW_UNSET_FULLSCREEN, /* void */
};
/**
@@ -145,6 +143,9 @@ struct vout_window_operations {
* Destroys the window and releases all associated resources.
*/
void (*destroy)(vout_window_t *);
+
+ void (*unset_fullscreen)(vout_window_t *);
+ void (*set_fullscreen)(vout_window_t *, const char *id);
};
typedef struct vout_window_owner {
@@ -286,26 +287,21 @@ static inline int vout_window_SetSize(vout_window_t *window,
* Requests fullscreen mode.
*
* \param id nul-terminated output identifier, NULL for default
- *
- * \retval VLC_SUCCESS The request has been queued to the windowing system
- * (that does <b>not</b> imply that the request is complete nor succesful).
- * \retval VLC_EGENERIC The request could not be queued, e.g. the back-end does
- * not implement toggling between fullscreen and windowed modes.
*/
-static inline int vout_window_SetFullScreen(vout_window_t *window,
+static inline void vout_window_SetFullScreen(vout_window_t *window,
const char *id)
{
- return vout_window_Control(window, VOUT_WINDOW_SET_FULLSCREEN, id);
+ if (window->ops->set_fullscreen != NULL)
+ window->ops->set_fullscreen(window, id);
}
/**
* Requests windowed mode.
- *
- * \return \see vout_window_SetFullScreen()
*/
-static inline int vout_window_UnsetFullScreen(vout_window_t *window)
+static inline void vout_window_UnsetFullScreen(vout_window_t *window)
{
- return vout_window_Control(window, VOUT_WINDOW_UNSET_FULLSCREEN);
+ if (window->ops->unset_fullscreen != NULL)
+ window->ops->unset_fullscreen(window);
}
/**
diff --git a/modules/gui/macosx/VLCVideoOutputProvider.m b/modules/gui/macosx/VLCVideoOutputProvider.m
index 950b4bee69..cf7c080da2 100644
--- a/modules/gui/macosx/VLCVideoOutputProvider.m
+++ b/modules/gui/macosx/VLCVideoOutputProvider.m
@@ -39,6 +39,37 @@
#import "VLCPlaylist.h"
#import "NSScreen+VLCAdditions.h"
+static const char windowed;
+
+static void WindowSetFullscreen(vout_window_t *wnd, const char *psz_id)
+{
+ if (var_InheritBool(getIntf(), "video-wallpaper")) {
+ msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
+ return;
+ }
+
+ int i_full = psz_id == &windowed;
+ BOOL b_animation = YES;
+
+ @autoreleasepool {
+ VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
+ if (!voutProvider) {
+ return VLC_EGENERIC;
+ }
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [voutProvider setFullscreen:i_full
+ forWindow:p_wnd
+ withAnimation:b_animation];
+ });
+ }
+}
+
+static void WindowUnsetFullscreen(vout_window_t *wnd)
+{
+ WindowSetFullscreen(wnd, &windowed);
+}
+
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
static int WindowControl(vout_window_t *, int i_query, va_list);
@@ -47,6 +78,8 @@ static void WindowClose(vout_window_t *);
static const struct vout_window_operations ops = {
WindowControl,
WindowClose,
+ WindowUnsetFullscreen,
+ WindowSetFullscreen,
};
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
@@ -128,25 +161,6 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
break;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- {
- if (var_InheritBool(getIntf(), "video-wallpaper")) {
- msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
- goto out;
- }
-
- int i_full = i_query == VOUT_WINDOW_SET_FULLSCREEN;
- BOOL b_animation = YES;
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [voutProvider setFullscreen:i_full
- forWindow:p_wnd
- withAnimation:b_animation];
- });
-
- break;
- }
default:
{
msg_Warn(p_wnd, "unsupported control query: %i", i_query );
diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m
index 4afd8773ce..cb163d860f 100644
--- a/modules/gui/minimal_macosx/intf.m
+++ b/modules/gui/minimal_macosx/intf.m
@@ -100,12 +100,37 @@ static void Run(intf_thread_t *p_intf)
/*****************************************************************************
* Vout window management
*****************************************************************************/
+
+static void WindowUnsetFullscreen(vout_window_t *p_wnd)
+{
+ NSWindow* o_window = [(__bridge id)p_wnd->handle.nsobject window];
+
+ @autoreleasepool {
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [(VLCMinimalVoutWindow*)o_window leaveFullscreen];
+ });
+ }
+}
+
+static void WindowSetFullscreen(vout_window_t *p_wnd, const char *psz_id)
+{
+ NSWindow* o_window = [(__bridge id)p_wnd->handle.nsobject window];
+
+ @autoreleasepool {
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [(VLCMinimalVoutWindow*)o_window enterFullscreen];
+ });
+ }
+}
+
static int WindowControl(vout_window_t *, int i_query, va_list);
static void WindowClose(vout_window_t *);
static const struct vout_window_operations ops = {
WindowControl,
WindowClose,
+ WindowUnsetFullscreen,
+ WindowSetFullscreen,
};
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
@@ -167,20 +192,6 @@ static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
}
return VLC_SUCCESS;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- {
- int i_full = i_query == VOUT_WINDOW_SET_FULLSCREEN;
- @autoreleasepool {
- dispatch_sync(dispatch_get_main_queue(), ^{
- if (i_full)
- [(VLCMinimalVoutWindow*)o_window enterFullscreen];
- else
- [(VLCMinimalVoutWindow*)o_window leaveFullscreen];
- });
- }
- return VLC_SUCCESS;
- }
default:
msg_Warn(p_wnd, "unsupported control query");
return VLC_EGENERIC;
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 7b38d7f1c8..23472c7c7d 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -972,7 +972,21 @@ void MainInterface::setInterfaceAlwaysOnTop( bool on_top )
}
}
-/* Asynchronous call from WindowControl function */
+/* Asynchronous calls for video window contrlos */
+void MainInterface::requestVideoWindowed( struct vout_window_t *wnd )
+{
+ MainInterface *p_mi = (MainInterface *)wnd->sys;
+
+ emit p_mi->askVideoSetFullScreen( false );
+}
+
+void MainInterface::requestVideoFullScreen( vout_window_t *wnd, const char * )
+{
+ MainInterface *p_mi = (MainInterface *)wnd->sys;
+
+ emit p_mi->askVideoSetFullScreen( true );
+}
+
int MainInterface::controlVideo( int i_query, va_list args )
{
switch( i_query )
@@ -993,12 +1007,6 @@ int MainInterface::controlVideo( int i_query, va_list args )
emit askVideoOnTop( on_top != 0 );
return VLC_SUCCESS;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- emit askVideoSetFullScreen( true );
- return VLC_SUCCESS;
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- emit askVideoSetFullScreen( false );
- return VLC_SUCCESS;
default:
msg_Warn( p_intf, "unsupported control query" );
return VLC_EGENERIC;
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index b4fe5eb880..87f5fc9aae 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -73,7 +73,10 @@ public:
bool getVideo( struct vout_window_t *,
unsigned int i_width, unsigned int i_height, bool );
void releaseVideo( void );
+
int controlVideo( int i_query, va_list args );
+ static void requestVideoWindowed( struct vout_window_t * );
+ static void requestVideoFullScreen( struct vout_window_t *, const char * );
/* Getters */
QSystemTrayIcon *getSysTray() { return sysTray; }
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index f7d973bcd6..e6960a1b8b 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -697,6 +697,8 @@ static int WindowControl( vout_window_t *, int i_query, va_list );
static const struct vout_window_operations window_ops = {
WindowControl,
WindowClose,
+ MainInterface::requestVideoWindowed,
+ MainInterface::requestVideoFullScreen,
};
static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index ce42fa51b7..da0fae219e 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -342,9 +342,32 @@ static void WindowCloseLocal( intf_thread_t* pIntf, vlc_object_t *pObj )
VoutManager::instance( pIntf )->releaseWnd( pWnd );
}
+static void WindowUnsetFullscreen( vout_window_t *pWnd )
+{
+ vout_window_sys_t *sys = pWnd->sys;
+ intf_thread_t *pIntf = sys->pIntf;
+ AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
+ CmdSetFullscreen* pCmd = new CmdSetFullscreen( pIntf, pWnd, false );
+
+ pQueue->push( CmdGenericPtr( pCmd ) );
+}
+
+static void WindowSetFullscreen( vout_window_t *pWnd, const char * )
+{
+ vout_window_sys_t *sys = pWnd->sys;
+ intf_thread_t *pIntf = sys->pIntf;
+ AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
+ // Post a set fullscreen command
+ CmdSetFullscreen* pCmd = new CmdSetFullscreen( pIntf, pWnd, true );
+
+ pQueue->push( CmdGenericPtr( pCmd ) );
+}
+
static const struct vout_window_operations window_ops = {
WindowControl,
WindowClose,
+ WindowUnsetFullscreen,
+ WindowSetFullscreen,
};
static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
@@ -440,16 +463,6 @@ static int WindowControl( vout_window_t *pWnd, int query, va_list args )
return VLC_EGENERIC;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- {
- // Post a set fullscreen command
- CmdSetFullscreen* pCmd = new CmdSetFullscreen( pIntf, pWnd,
- query == VOUT_WINDOW_SET_FULLSCREEN );
- pQueue->push( CmdGenericPtr( pCmd ) );
- return VLC_SUCCESS;
- }
-
case VOUT_WINDOW_SET_STATE:
{
unsigned i_arg = va_arg( args, unsigned );
diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
index e482c94320..8bb524e0eb 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -197,36 +197,6 @@ static int Control(vout_window_t *wnd, int cmd, va_list ap)
break;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- {
- const char *idstr = va_arg(ap, const char *);
- struct wl_output *output = NULL;
-
- if (idstr != NULL)
- {
- char *end;
- unsigned long name = strtoul(idstr, &end, 10);
-
- assert(*end == '\0' && name <= UINT32_MAX);
- output = wl_registry_bind(sys->registry, name,
- &wl_output_interface, 1);
- }
- else
- if (sys->default_output != 0)
- output = wl_registry_bind(sys->registry, sys->default_output,
- &wl_output_interface, 1);
-
- xdg_toplevel_set_fullscreen(sys->toplevel, output);
-
- if (output != NULL)
- wl_output_destroy(output);
- break;
- }
-
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- xdg_toplevel_unset_fullscreen(sys->toplevel);
- break;
-
default:
msg_Err(wnd, "request %d not implemented", cmd);
return VLC_EGENERIC;
@@ -238,9 +208,46 @@ static int Control(vout_window_t *wnd, int cmd, va_list ap)
static void Close(vout_window_t *);
+static void UnsetFullscreen(vout_window_t *wnd)
+{
+ vout_window_sys_t *sys = wnd->sys;
+
+ xdg_toplevel_unset_fullscreen(sys->toplevel);
+ wl_display_flush(wnd->display.wl);
+}
+
+static void SetFullscreen(vout_window_t *wnd, const char *idstr)
+{
+ vout_window_sys_t *sys = wnd->sys;
+ struct wl_output *output = NULL;
+
+ if (idstr != NULL)
+ {
+ char *end;
+ unsigned long name = strtoul(idstr, &end, 10);
+
+ assert(*end == '\0' && name <= UINT32_MAX);
+ output = wl_registry_bind(sys->registry, name,
+ &wl_output_interface, 1);
+ }
+ else
+ if (sys->default_output != 0)
+ output = wl_registry_bind(sys->registry, sys->default_output,
+ &wl_output_interface, 1);
+
+ xdg_toplevel_set_fullscreen(sys->toplevel, output);
+
+ if (output != NULL)
+ wl_output_destroy(output);
+
+ wl_display_flush(wnd->display.wl);
+}
+
static const struct vout_window_operations ops = {
.control = Control,
.destroy = Close,
+ .unset_fullscreen = UnsetFullscreen,
+ .set_fullscreen = SetFullscreen,
};
#ifdef XDG_SHELL
diff --git a/modules/video_output/wdummy.c b/modules/video_output/wdummy.c
index f3fc8630d5..1e55953a76 100644
--- a/modules/video_output/wdummy.c
+++ b/modules/video_output/wdummy.c
@@ -44,8 +44,6 @@ static int Control(vout_window_t *wnd, int query, va_list ap)
}
case VOUT_WINDOW_SET_STATE:
- case VOUT_WINDOW_SET_FULLSCREEN:
- case VOUT_WINDOW_UNSET_FULLSCREEN:
/* These controls deserve a proper window provider. Move along. */
return VLC_EGENERIC;
diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index f6ba98b516..4fea35d5ee 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -446,12 +446,6 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
break;
}
- case VOUT_WINDOW_SET_FULLSCREEN:
- case VOUT_WINDOW_UNSET_FULLSCREEN:
- change_wm_state (wnd, cmd == VOUT_WINDOW_SET_FULLSCREEN,
- p_sys->wm_state_fullscreen);
- break;
-
default:
msg_Err (wnd, "request %d not implemented", cmd);
return VLC_EGENERIC;
@@ -460,6 +454,23 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
return VLC_SUCCESS;
}
+static void UnsetFullscreen(vout_window_t *wnd)
+{
+ vout_window_sys_t *sys = wnd->sys;
+
+ change_wm_state(wnd, false, sys->wm_state_fullscreen);
+ xcb_flush(sys->conn);
+}
+
+static void SetFullscreen(vout_window_t *wnd, const char *idstr)
+{
+ vout_window_sys_t *sys = wnd->sys;
+
+ (void) idstr; /* TODO */
+ change_wm_state(wnd, true, sys->wm_state_fullscreen);
+ xcb_flush(sys->conn);
+}
+
/** Set an X window property from a nul-terminated string */
static inline
void set_string (xcb_connection_t *conn, xcb_window_t window,
@@ -564,6 +575,8 @@ static void set_wm_deco(xcb_connection_t *conn, xcb_window_t window, bool on)
static void Close(vout_window_t *);
static const struct vout_window_operations ops = {
+ .set_fullscreen = SetFullscreen,
+ .unset_fullscreen = UnsetFullscreen,
.control = Control,
.destroy = Close,
};
More information about the vlc-commits
mailing list