summaryrefslogtreecommitdiffstats
path: root/video/out/w32_common.c
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2023-12-04 23:30:42 -0500
committersfan5 <sfan5@live.de>2023-12-10 16:35:40 +0100
commit66ebce758f732372cf71ebac8fcb2d1bb4f85496 (patch)
tree663e7c4f263ed8581c8591f65cc329535159dfe3 /video/out/w32_common.c
parent57367377505b6b2edc87004fa3192d831d515aa5 (diff)
downloadmpv-66ebce758f732372cf71ebac8fcb2d1bb4f85496.tar.bz2
mpv-66ebce758f732372cf71ebac8fcb2d1bb4f85496.tar.xz
win32: temporarily disable aero shake while dragging hack is active
The dragging hack can cause unwanted aero shake activation. Prevent this by saving the window arrangement state before dragging, temporarily disable it while dragging hack is active, and restore to the original state after dragging ends.
Diffstat (limited to 'video/out/w32_common.c')
-rwxr-xr-xvideo/out/w32_common.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index a1f5cd9973..e2874cc9b1 100755
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -182,6 +182,7 @@ struct vo_w32_state {
bool cleared;
bool dragging;
+ BOOL win_arranging;
};
static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc)
@@ -485,9 +486,12 @@ static bool handle_mouse_down(struct vo_w32_state *w32, int btn, int x, int y)
// needs to be kept resonsive.
// Workaround this by intercepting the loop in the WM_MOVING message,
// where the up-to-date value is available.
+ SystemParametersInfoW(SPI_GETWINARRANGING, 0, &w32->win_arranging, 0);
w32->dragging = true;
SendMessage(w32->window, WM_NCLBUTTONDOWN, HTCAPTION, 0);
w32->dragging = false;
+ SystemParametersInfoW(SPI_SETWINARRANGING, w32->win_arranging, 0, 0);
+
mp_input_put_key(w32->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP);
// Indicate the message was handled, so DefWindowProc won't be called
@@ -1252,6 +1256,12 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
// Prevent the window from being moved if the window dragging hack
// is active, and the window is currently in fullscreen.
if (w32->dragging && w32->current_fs) {
+ // Temporarily disable window arrangement to prevent aero shake
+ // from being activated. The original system setting will be restored
+ // after the dragging hack ends.
+ if (w32->win_arranging) {
+ SystemParametersInfoW(SPI_SETWINARRANGING, FALSE, 0, 0);
+ }
*rc = w32->windowrc;
return TRUE;
}