[vlc-commits] vout:win32: handle the Always On Top of the non-parented window internally
Steve Lhomme
git at videolan.org
Tue Apr 2 16:32:52 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Mar 26 16:32:50 2019 +0100| [04e5b905451ea95c16c157bf9abe8359f79dd4b7] | committer: Steve Lhomme
vout:win32: handle the Always On Top of the non-parented window internally
When we receive our IDM_TOGGLE_ON_TOP we post WM_VLC_SET_TOP_STATE to our window.
No need to go through the vout_display_SendWindowState().
This is only used for the external window. In GUI/embedded mode the above/normal
state is handled by the GUI and we don't have to change menus in the chromeless
window.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=04e5b905451ea95c16c157bf9abe8359f79dd4b7
---
modules/video_output/win32/common.c | 22 ----------------------
modules/video_output/win32/direct3d9.c | 4 ++--
modules/video_output/win32/events.c | 32 +++++++++++++++++++++++++++++---
modules/video_output/win32/events.h | 3 ++-
4 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index ef634e0f7e..0cb2162d61 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -387,28 +387,6 @@ int CommonControl(vout_display_t *vd, display_win32_area_t *area, vout_display_s
return VLC_SUCCESS;
}
#if !VLC_WINSTORE_APP
- case VOUT_DISPLAY_CHANGE_WINDOW_STATE: { /* unsigned state */
- const unsigned state = va_arg(args, unsigned);
- const bool is_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
- if (sys->event != NULL)
- {
-#ifdef MODULE_NAME_IS_direct3d9
- if (sys->use_desktop && is_on_top)
- return VLC_EGENERIC;
-#endif
- HMENU hMenu = GetSystemMenu(sys->hwnd, FALSE);
-
- if (is_on_top && !(GetWindowLong(sys->hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) {
- CheckMenuItem(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_CHECKED);
- SetWindowPos(sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
- } else if (!is_on_top && (GetWindowLong(sys->hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) {
- CheckMenuItem(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_UNCHECKED);
- SetWindowPos(sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
- }
- sys->is_on_top = is_on_top;
- }
- return VLC_SUCCESS;
- }
case VOUT_DISPLAY_CHANGE_FULLSCREEN: {
bool fs = va_arg(args, int);
if (sys->event != NULL)
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 2be530a354..41268ba0fb 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -923,13 +923,13 @@ static void UpdateDesktopMode(vout_display_t *vd)
if (sys->desktop_save.is_fullscreen)
vout_display_SendEventFullscreen(vd, false);
if (sys->desktop_save.is_on_top)
- vout_display_SendWindowState(vd, VOUT_WINDOW_STATE_NORMAL);
+ EventThreadSetAbove( sys->sys.event, false );
} else {
/* Restore fullscreen/on_top */
if (sys->desktop_save.is_fullscreen)
vout_display_SendEventFullscreen(vd, true);
if (sys->desktop_save.is_on_top)
- vout_display_SendWindowState(vd, VOUT_WINDOW_STATE_ABOVE);
+ EventThreadSetAbove( sys->sys.event, true );
}
}
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index f65c0c1c88..6d040d5f8d 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -45,7 +45,8 @@
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-#define WM_VLC_CHANGE_TEXT (WM_APP + 1)
+#define WM_VLC_CHANGE_TEXT (WM_APP + 1)
+#define WM_VLC_SET_TOP_STATE (WM_APP + 2)
struct event_thread_t
{
@@ -862,6 +863,18 @@ static void Win32VoutCloseWindow( event_thread_t *p_event )
CloseGestures( p_event->p_gesture);
}
+static void SetAbove( event_thread_t *p_event, bool is_on_top )
+{
+ HMENU hMenu = GetSystemMenu(p_event->hwnd, FALSE);
+ if (is_on_top && !(GetWindowLong(p_event->hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) {
+ CheckMenuItem(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_CHECKED);
+ SetWindowPos(p_event->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
+ } else if (!is_on_top && (GetWindowLong(p_event->hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) {
+ CheckMenuItem(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_UNCHECKED);
+ SetWindowPos(p_event->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
+ }
+}
+
/*****************************************************************************
* WinVoutEventProc: This is the window event processing function.
*****************************************************************************
@@ -967,8 +980,12 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
{
msg_Dbg(vd, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP");
HMENU hMenu = GetSystemMenu(p_event->hwnd, FALSE);
- vout_display_SendWindowState(vd, (GetMenuState(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND) & MF_CHECKED) ?
- VOUT_WINDOW_STATE_NORMAL : VOUT_WINDOW_STATE_ABOVE);
+ const bool is_on_top = (GetMenuState(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND) & MF_CHECKED) == 0;
+#ifdef MODULE_NAME_IS_direct3d9
+ if (p_event->use_desktop && is_on_top)
+ return 0;
+#endif
+ SetAbove( p_event, is_on_top);
return 0;
}
default:
@@ -976,6 +993,10 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
}
break;
+ case WM_VLC_SET_TOP_STATE:
+ SetAbove( p_event, wParam != 0);
+ return 0;
+
case WM_PAINT:
case WM_NCPAINT:
case WM_ERASEBKGND:
@@ -998,6 +1019,11 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
return DefWindowProc(hwnd, message, wParam, lParam);
}
+void EventThreadSetAbove( event_thread_t *p_event, bool is_on_top )
+{
+ PostMessage( p_event->hwnd, WM_VLC_SET_TOP_STATE, is_on_top != 0, 0);
+}
+
static struct
{
int i_dxkey;
diff --git a/modules/video_output/win32/events.h b/modules/video_output/win32/events.h
index c4e18593e1..15cdb05897 100644
--- a/modules/video_output/win32/events.h
+++ b/modules/video_output/win32/events.h
@@ -54,7 +54,8 @@ void EventThreadStop( event_thread_t * );
void EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
int EventThreadGetWindowStyle( event_thread_t * );
void EventThreadUpdatePlace( event_thread_t *p_event,
- const vout_display_place_t *p_place );
+ const vout_display_place_t *p_place );
+void EventThreadSetAbove( event_thread_t *, bool );
bool EventThreadGetAndResetSizeChanged( event_thread_t * );
# ifdef __cplusplus
More information about the vlc-commits
mailing list