mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Window shrinks when dragged beyond the top

Open vvyoko opened this issue 3 months ago β€’ 3 comments

mpv Information

last version without config
https://github.com/zhongfly/mpv-winbuild/releases/download/2025-09-13-d837c43/mpv-x86_64-v3-20250913-git-d837c43.7z

mpv v0.40.0-302-gd837c4365 Copyright Β© 2000-2025 mpv/MPlayer/mplayer2 projects
 built on Sep 11 2025 18:08:44
libplacebo version: v7.354.0 (v7.351.0-67-g515da95-dirty)
FFmpeg version: N-121039-ga4fd3f27f
FFmpeg library versions:
   libavcodec      62.15.100
   libavdevice     62.2.100
   libavfilter     11.8.100
   libavformat     62.5.100
   libavutil       60.13.100
   libswresample   6.2.100
   libswscale      9.3.100

Other Information

- Windows version: 10.0.19044.5131
- GPU model, driver and version: amd 7450
- Source of mpv: https://github.com/zhongfly/mpv-winbuild/releases/tag/2025-09-13-d837c43
- Latest known working version: no?
- Issue started after the following happened: Drag the window beyond the top

Reproduction Steps

Play a file and drag the window beyond the top

Expected Behavior

Dont change window size

Actual Behavior

Only top will shrinks Other directions are normal

Log File

Image

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • [x] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [x] I provided all required information including system and mpv version.
  • [x] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [x] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [x] I attached the full, untruncated log file.
  • [x] I attached the backtrace in the case of a crash.

vvyoko avatar Sep 13 '25 15:09 vvyoko

Below is an online translation.

It looks like it's a windows problem. I've also encountered it in other programs recently

It appears this is an issue related to Windows Snap. Settings β†’ Multitasking β†’ Snap windows.

I personally dislike the feature where a window automatically maximizes when dragged to the top of the screen, so I chose to turn it off. However, during testing, I found that when the Snap windows feature is disabled, dragging any window toward the top of the screen causes it to automatically shrink (or reset its top edge). It seems I cannot reliably move any window to the very top edge of the screen regardless of the setting: Disabled: The window automatically shrinks. Enabled: The window either automatically maximizes or is forced to reset its top edge (Y coordinate) to the screen boundary, preventing movement slightly above the top edge.

Not mpv`s problem Should this issue be closed?

vvyoko avatar Oct 14 '25 07:10 vvyoko

I just added a way to my libmpv player to prevent it... Record the position and restore it when it moves beyond the top of the screen... Now it can work with Windows Snap turned off

on_start.add_callback(on_start_funkSnap_ext, true)

on_start_funkSnap_ext()
{
    static hEvent := 0
    static posH := 0

    EVENT_SYSTEM_MOVESIZEEND := 0x000B

    mp.on_file_readed.add_callback(on_file_readed_snap)
    mp.on_exit.add_callback((*) => DllCall("user32\UnhookWinEvent", "ptr", hEvent))

    DllCall("user32\SetWinEventHook",
        "uint", EVENT_SYSTEM_MOVESIZEEND,      ; eventMin (EVENT_OBJECT_DESTROY)
        "uint", EVENT_SYSTEM_MOVESIZEEND,      ; eventMax
        "ptr", 0,            ; hmodWinEventProc (不用樑块)
        "ptr", CallbackCreate(WinEventHandler), ; lpfnWinEventProc (ε›žθ°ƒε‡½ζ•°εœ°ε€)
        "uint", 0,           ; idProcess (0 = ζ‰€ζœ‰θΏ›η¨‹)
        "uint", 0,           ; idThread (0 = ζ‰€ζœ‰ηΊΏη¨‹)
        "uint", WINEVENT_OUTOFCONTEXT := 0x0000)      ; dwFlags


    on_file_readed_snap()
    {
        if !WinExist(mp.ahk_id)
            return
        WinGetPos(, , , &h, mp.ahk_id)
        posH := h
    }

    WinEventHandler(hHook, event, hwnd, idObject, idChild, dwmsEventTime)
    {
        if (idObject || hwnd != mp.hwnd)
            return
        dr := monitors.GetWorkRect()
        WinGetPos(&x, &y, &w, &h, mp.ahk_id)

        if y < dr.y
        {
            if posH
                WinMove(x, dr.y, w, posH, mp.ahk_id)
        }
        else
            posH := h
    }
}

vvyoko avatar Oct 14 '25 08:10 vvyoko

I have refactored how we handle window move/size. Because we have few lingering bugs there. Likely this issue will be fixed too, but I didn't have time to finish it, for some time, and would need to refresh my memory what is remaining there to adjust.

kasper93 avatar Oct 14 '25 09:10 kasper93