-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mac: add support for --force-window-position #15500
base: master
Are you sure you want to change the base?
Conversation
After testing, it was found that the mouse can still interact with the NSView (rather NSWindow) to move the window. This issue is currently being fixed. |
Download the artifacts for this pull request: |
Fixed. I assume that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry this is not doing what the option is supposed to do.
video/out/mac/common.swift
Outdated
@@ -437,7 +444,7 @@ class Common: NSObject { | |||
let y = CGFloat(-geo.win.y1) | |||
let x = CGFloat(geo.win.x0) | |||
let wr = screen.convertRectFromBacking(NSRect(x: x, y: y, width: width, height: height)) | |||
return (wr, Bool(geo.flags & Int32(VO_WIN_FORCE_POS))) | |||
return (wr, Bool(geo.flags & Int32(option.vo.force_window_position))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's wrong. this is a bitwise and operation, eg it is supposed to check if VO_WIN_FORCE_POS
is included in the set bits of geo.flags. in this case it's already properly set in the underlying function, eg the geo pointer that is passed to vo_calc_window_geometry
.
Lines 137 to 139 in dbb3291
if (opts->geometry.xy_valid || opts->force_window_position || force_center) | |
out_geo->flags |= VO_WIN_FORCE_POS; | |
} |
see also other implementations https://github.com/search?q=repo%3Ampv-player%2Fmpv%20VO_WIN_FORCE_POS&type=code
video/out/mac/common.swift
Outdated
@@ -411,6 +417,7 @@ class Common: NSObject { | |||
|
|||
func getWindowGeometry(forScreen screen: NSScreen, | |||
videoOut vo: UnsafeMutablePointer<vo>) -> (NSRect, Bool) { | |||
let option = OptionHelper(vo, vo.pointee.global) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just use option
(class var), no need to instantiate a new option helper
video/out/mac/common.swift
Outdated
@@ -104,6 +104,12 @@ class Common: NSObject { | |||
window.setMinimized(minimized) | |||
window.makeMain() | |||
window.makeKey() | |||
window.isMovable = !forcePosition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you misunderstanding the option here (https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst?plain=1#L3569-L3572)?
Forcefully move mpv's video output window to default location whenever
there is a change in video parameters, video stream or file. This used to
be the default behavior. Currently only affects X11 and SDL VOs.
this just prevents window dragging on title bar and background.
i believe the only part missing here is the the position on init. though i have to check what exactly didn't work properly.
I shall have a look. |
@Akemi Hi, I reviewed the code, and for the first commit, my question is: Line 137 in dbb3291
Why it's opts->geometry.xy_valid || opts->force_window_position || force_center ratheropts->geometry.xy_valid && opts->force_window_position || force_center ?Is this the intended behaviour? As for the second commit, yes, I misunderstood the meaning of this option. My current understanding is that when running the script below, the option expects the top-left corner of the window (as defined by the geometry setting) to remain fixed when switching between different resolutions. Is that right? #!/usr/bin/env bash
EXEC_PATH="mpv"
while [[ "$1" != "" ]]; do
case "$1" in
--exec_path )
shift
EXEC_PATH="$1"
;;
esac
shift
done
RESOLUTIONS=(
"1280x720"
"854x480"
"640x360"
"426x240"
)
DURATION=1.5
rm -f res_*.mkv list.txt recycle.mkv
for RES in "${RESOLUTIONS[@]}"; do
WIDTH=$(echo $RES | cut -d'x' -f1)
HEIGHT=$(echo $RES | cut -d'x' -f2)
OUTPUT="res_${WIDTH}x${HEIGHT}.mkv"
ffmpeg -f lavfi -i "testsrc=size=${WIDTH}x${HEIGHT}:rate=30:duration=${DURATION}" -pix_fmt yuv420p -c:v libx264 -crf 20 -y "${OUTPUT}"
echo "file '$(pwd)/${OUTPUT}'" >> list.txt
done
ffmpeg -f concat -safe 0 -i list.txt -c copy recycle.mkv
rm -f res_*.mkv list.txt
ffmpeg -stream_loop -1 -re -i recycle.mkv -c copy -f matroska - 2>/dev/null | "${EXEC_PATH}" --geometry=500:500 --force-window-position - Save it into test_force_pos.sh and run
or
|
specific example, without geometry options set but with
the default location can be influenced by the various geometry/autofit options. |
for macvk this most likely needs to be added here. the manual needs updating to for this option, when adding this https://github.com/mpv-player/mpv/blame/master/DOCS/man/options.rst#L3569-L3572 |
@Akemi, could you review the newly submitted commit? Now the fixed position is anchored to the top-left corner. (centre alignment would be more complex as |
i don't know what you mean "Now the fixed position is anchored to the top-left corner"? what exactly is the problem or what behaviour changed from the previous behaviour? the frame is set according to what please also update the manual. |
I don’t have an X11 testing environment, so I’m unsure about the behaviour of [Edit] |
first of all the manual is not completely clear how this is supposed to behave especially with i am not sure why it's relevant that the window is positioned by the top left corner? it was like this before and is supposed to be like that (see geometry https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst?plain=1#L3398-L3399 "from the top-left corner"). if it were an issue, it would be unrelated to this and would need fixing somewhere else (eg we only flip the origin here https://github.com/mpv-player/mpv/blob/master/video/out/mac/common.swift#L436-L437 to align it with the macOS coordinate system). either macOS or macvk, the former if we update cocoa-cb too to support this. |
Then it seems there’s nothing more to modify in this PR. However, I did notice that the geometry calculations are incorrect. In my test code, I used --geometry=500:500, but the result was (308, 275). Can you verify this issue? |
i can't verify nor deny any issue like this. this depends on your setup (hdipi, resolution, screen, config, etc) and which values you actually compare. this is the wrong place for reporting an issue in the first place. a simple check on my setup does what it is supposed to do on the main monitor. though that doesn't mean that something isn't broken or broke at some point because of various reasons. |
It is certainly not a requirement for this PR. I’m just mentioning it to see if this issue has already been identified. I will carry out a full test later and submit a new issue. |
(that's a lot less changes than i anticipated.)
This pull request includes a bug fix and adds support for a feature.
Common::getWindowGeometry -> (NSRect, Bool)
mpv/video/out/mac/common.swift
Line 440 in dbb3291
Int32(VO_WIN_FORCE_POS)
is always a constant 1, irrespective of--force-window-position
. As a result, whenever--geometry
is passed,forcePosition
is returned as 1.You can easily verify this by:
a) Adding a breakpoint just before the return statement, or
b) Including a debug line such as
print("Bool", Bool(geo.flags & Int32(VO_WIN_FORCE_POS)))
Then:
[Notice] The objc func
control
used variableforcePosition
in one case within a switch statement. However, I don't know the corresponding trigger condition. Could someone who knows provide the related code or help me test it?mpv/video/out/mac/common.swift
Line 537 in dbb3291
simple.
https://developer.apple.com/documentation/appkit/nswindow/ismovable