Skip to content
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

Property change observers for geometry and autofit #3872

Closed
ghost opened this issue Dec 4, 2016 · 14 comments
Closed

Property change observers for geometry and autofit #3872

ghost opened this issue Dec 4, 2016 · 14 comments

Comments

@ghost
Copy link

ghost commented Dec 4, 2016

This carries on from the discussion in comment #2301 (comment) and downwards.

Currently, mpv doesn't have any runtime property change observers for the geometry and autofit properties. They are read once at startup and applied, and after that they're immutable (changing them doesn't cause the GUI to react).

I would like to propose that the following properties get runtime property change observers in every GUI:

geometry
autofit
autofit-larger
autofit-smaller

It would open up some incredible possibilities for mpv.

# Place a small, borderless, floating player in the bottom left of the screen
Alt+s set border no; set ontop yes; set autofit 20%x20%; set geometry +15-15

# Place a small, borderless, floating player in the bottom right of the screen
Alt+d set border no; set ontop yes; set autofit 20%x20%; set geometry -15-15

# Place a small, borderless, floating player in the top left of the screen
Alt+w set border no; set ontop yes; set autofit 20%x20%; set geometry +15+15

# Place a small, borderless, floating player in the top right of the screen
Alt+e set border no; set ontop yes; set autofit 20%x20%; set geometry +15-15

# Place a larger, bordered, non-floating player in the center of the screen
Alt+r set border yes; set ontop no; set autofit 80%x80%; set geometry 50%:50%

Incredibly efficient player management! Imagine opening a video, and deciding "well, I'd like to watch this while working on other things"...

Do you want to re-scale the window to the appropriate final size you want, toggle the always on top mode, press a button to remove the border, and then manually drag it into position?

Or do you want to press a single button to automatically size it and put it into any corner you want?

Property change observers for geometry and autofit would make that possible. Such an ability would definitely put mpv a league above the other players out there!

Edit: Linux has window managers that can sometimes achieve this (not all of them). On macOS there's no window manager (there are some ways to achieve it with Accessibility and AppleScript but it is fragile). On Windows there is no window manager at all. So adding this to mpv core seems like the best and most universal solution.

@Argon-
Copy link
Member

Argon- commented Dec 5, 2016

This sounds like something your window manager should do.
(I'm aware that you have no choice on OSX but there are other possibilities)

@ghost
Copy link
Author

ghost commented Dec 8, 2016

@Argon-

This sounds like something your window manager might be able to do.

If you'd said the above, I would agree.

But Windows and OSX users do not have such window management built-in. It requires tricky 3rd party apps.

If mpv would just have property change observers for those properties, it could run its rescale/position code at runtime and would be able to let the player move itself based on user commands. Seriously, don't diss this as "let's force people to use a Linux window manager for that". As a video player, it's extremely useful to be able to quickly rescale and move the player to "preset" locations and modes (on-top, borderless, etc), regardless of OS and without needing any extra apps.

The ability to move and resize the player via Lua and keybindings would be hugely appreciated by all the non-Linux users. ;-)

@vitorgalvao
Copy link
Contributor

Came here to ask the same.

@SteveJobzniak I saw your quick-scale script and the other issue. Think maybe this could be accomplished with a script as well? In my case I was trying to get ontop and fullscreen=no, which we can already do, but add geometry="25%+100%+100%" (the same as geometry="100%:100%" and autofit="25%"). That’s when I realised it wasn’t currently possible.

Since this can only be done before opening the file, maybe we could in the script:

  1. Get the full path to the currently playing file.
  2. Quit the file and save the position.
  3. Reopen with necessary flags as argumentes.

That’d be far from ideal, but may work. Not sure it would since we’d have to close the active file.

I do agree that leaving this to the window manager is nonsensical. On anything but Linux, even the most popular and capable window managers lack such fine control (especially for sticking something to bottom right).

@ghost
Copy link
Author

ghost commented Aug 15, 2017

Edit: Just a note regarding my quick-scale script a guy mentioned above - it has been moved to https://github.com/SteveJobzniak/mpv-tools

@vitorgalvao Moving the window is sadly impossible after mpv has launched. I think the ability should be added to the LUA functions. It would be incredibly useful for "press a button to make the video ontop in a corner".

@vitorgalvao
Copy link
Contributor

Moving the window is sadly impossible after mpv has launched.

I know, that’s why my suggestion is to call a command that closes mpv and then relaunches it with the arguments we want, moving it on the relaunch.

@ghost
Copy link
Author

ghost commented Aug 15, 2017

@vitorgalvao Okay. Or... that time can be spent writing C++ code instead and adding window-move (via geometry property listener) to mpv's Lua engine. ;)

@kesdoputr
Copy link

Is this project still alive?I'm using quick-scale and it work's fine.
But if i can use one hotkey to setting up the video window that would be perfect.

ex.Sometimes i will set the video to 480 width,put to rihgt-bottom and ontop
and do other things like watch web or play some games.
Now i do this things with --geometry 480-0-0 --ontop

By the way,i'm using cycle-video-rotate too, how can i disable the osd when i rotate a video?
It seems not work to use like
Alt+left no-osd script-message Cycle_Video_Rotate -90

Anyway thx for your watching.

@ghost
Copy link
Author

ghost commented Sep 17, 2017

@kesdoputr Hi. Glad you like the scripts. no-osd is just for built-in mpv commands. If you want to disable the OSD message, just edit the code of cycle-video-rotate.lua to remove the lines that do the OSD output. You can find it if you look inside the code.

And yes, I still agree that mpv would be better with 'geometry' change support at runtime to allow scripting hotkeys to move the player around to do things like you say, "picture in picture on-top in the corner" with a hotkey easily, etc. It would make mpv even more unique as a powerful video player.

@kesdoputr
Copy link

Thx for your reply and now i can rotate video without osd.
And wish oneday geometry can be changed when playing a video.

etc.now i use autohotkey to move window if i need to move window when playing.

@winneon
Copy link

winneon commented Sep 25, 2017

This really should be something mpv natively supports. The WM should not be fully responsible for this functionality.

@ghost
Copy link
Author

ghost commented Sep 25, 2017

@winneon Exactly. And since mpv already supports moving/resizing the window at startup, it already has all code necessary for moving/resizing its own window.

@Akemi Akemi mentioned this issue Dec 12, 2017
@ghost
Copy link
Author

ghost commented Dec 12, 2017

We had a chat on IRC about this ticket. Someone suggested that it may be as simple as calling the geometry commands listed in https://github.com/mpv-player/mpv/blob/master/video/out/win_state.c from the property observers for geometry/autofit.

So it seems like it's possible to do the following:

  • In the observers for geometry/autofit properties: Trigger the window geometry events via those win_state functions.
  • Later: Improve the property setters so that setting geometry or autofit to the same value repeatedly will trigger a window resize every time (normally, setting it to "50%50%" repeatedly would do nothing on the subsequent attempts; but in this window manager situation, we need to be able to repeatedly set the same value, so that we can force the window to move to the desired location again in case the user has manually grabbed the window and moved it away from where its last mpv geometry value placed it).

The only problem regarding the 2nd step is that window backends should ignore repeated requests to move to the exact same position/property value that we're already at (to avoid wasteful OS windowing syscalls). But as that file says on line 75, "all windowing backends" are able to deal with "avoiding resize on reconfig() with no size change", so it seems harmless to repeatedly send the same geometry command value to the windowing backends.

@phanirithvij
Copy link

phanirithvij commented Mar 27, 2020

Hi is this being worked on? I'd like to move the mpv window using key bindings instead of using the mouse. It's been so long since this ticket was opened, the author became a ghost.

@ghost
Copy link

ghost commented Mar 27, 2020

I did, but nobody cared, so now it isn't.
Closing and locking this since original author is gone (became "ghost").

@ghost ghost closed this as completed Mar 27, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants