0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

4531 Commits

Author SHA1 Message Date
nanahi
3e17d9da8f vo_gpu: use fbo texture height for fragment coordinate calculation
Previous fix only worked when the video output doesn't have vertical
black bars. This fixes the cases like fullscreen, video-zoom etc.

Fixes: https://github.com/mpv-player/mpv/pull/13528
2024-02-24 21:12:17 +01:00
nanahi
84015959cc osdep/io: move I/O utility functions to misc/io_utils
The purpose of osdep/io is to provide a wrapper for POSIX I/O functions
on Windows. The last 2 functions are utility functions which don't serve
this purpose.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
nanahi
ae1a4ed28a vo_gpu: fix fragment coordinate calculation when dithering
When doing the dithering pass, the fragment coordinate is queried, but
doesn't take the fbo texture flipped property into account. This results
in different dithering patterns when toggling between fbo flipped and
non-flipped state. This can be reproduced with --vo=gpu --gpu-api=opengl
and easily seen with --dither-depth=1 when toggling between playing and
pausing.

Fix this by flipping the fragment y coordinate if the fbo is flipped
when calculating dithering coordinate.
2024-02-22 12:35:40 +01:00
nanahi
74f2260cd6 vo_gpu: fix fragment coordinate calculation when drawing checkerboard
When redrawing cached frames while the fbo texture is flipped,
the texture after drawing to screen pass will be flipped when blitting.
However, when rendering the checkerboard, the fragment coordinate
doesn't take this into account, so the coordinate before flipping is used,
resulting in different checkerboard location when toggling between
flipped and non-flipped state. This can be reproduced with --vo=gpu
and --gpu-api=opengl: the checkerboard patterns when playing and
pausing are different (vertically flipped).

Fix this by flipping the fragment y coordinate if the fbo is flipped
when calculating checkerboard coordinate.
2024-02-22 12:35:40 +01:00
nanahi
531704e35d x11_common: handle window dragging in ButtonPress event
Begin the _NET_WM_MOVERESIZE window dragging in ButtonPress event
to match the behavior of win32 and wayland, simplify logic by dropping
the win_drag_button1_down hack required by the old method, and fix a race
condition described in commit 19f101db68,
which happens when moving the mouse and releasing the button at the same time.

The race condition can be easily triggered when using a touch screen
(tested with libinput driver), where a tap is translated to MotionNotify,
ButtonPress, MotionNotify, and ButtonRelease in sequence, with the last 2
events having the same timestamp. This has caused some window managers to
not stop dragging after the ButtonRelease, resulting in window being stuck
in dragging state after a single tap.
2024-02-21 22:39:28 +01:00
der richter
d954646d29 various: make mentions of macOS consistent
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
2024-02-21 20:46:53 +01:00
der richter
0e441525cf vo: make libmpv last in the auto-probing order for cocoa-cb only
this partially reverts commit 7b5a258. back then the only properly
working vo on macOS was cocoa-cb (libmpv). it would always use the
deprecated opengl cocoa backend or no vo at all. because of that libmpv
was moved to the top of the auto-probing order, so the preferred vo
was used on macOS only.

we now have a working vulkan gpu/gpu-next backend on macOS which should
be the new default vo. though disabling the auto-probing again for
libmpv would probably cause the undesired behaviour on macOS that
cocoa-cb would never be auto selected again. especially if not build
with vulkan support or without vulkan driver on macOS, this would lead
to no video output at all. so instead of completely reverting the
mentioned commit, we instead move libmpv to the bottom of the
auto-probing order but only auto select it when mpv was built with
cocoa-cb support. this restores the previous behaviour on all other
platforms besides macOS, but also lets us auto select cocoa-cb if
supported.
2024-02-20 20:42:02 +01:00
Julian Orth
0ef78c1aa5 wayland_common: update pointer serial on pointer_enter 2024-02-18 18:21:02 +00:00
der richter
ac275a823d cocoa-cb: lock CGLContext on uninit and manual redraw
this fixes a crash on quit, when a CATransaction from a system owned
thread/event is happening at the same time. locking the context
synchronises these access and prevents the race condition.

the draw operation induced by any display call from the CAOpenGLLayer
doesn't need that lock, since the display function already does lock
that current context.

Fixes #11681
2024-02-18 17:25:05 +01:00
Dudemanguy
bd5b80ba2c vo_gpu_next: fix some lut-related memory leaks 2024-02-17 18:56:20 +00:00
Dudemanguy
85e84f6d92 vo_gpu_next: move gpu-next opts to specific sub option
This matches the general workflow in the codebase. We keep a cache of
these new options and update them if needed.

Fixes #13481 and fixes #11518.
2024-02-17 18:56:20 +00:00
Dudemanguy
073858fcdd vo: remove VOCTRL_SET_EQUALIZER and simplify into UPDATE_VIDEO
Since 03cf150ff3, the only purpose of this
VOCTRL was to signal a redraw to the vo. It actualy could have been
removed in 531868fe0d, but this was
missed. The UPDATE_VIDEO flag is better anyway because it allows us to
handle a wide variety of options scattered around that require the VO to
update itself and redraw. We can remove both of the custom callbacks in
vo.c and only leave the VOCTRL_VO_OPTS_CHANGED one. Additionally, that
commit also introduced vo_set_want_redraw, but this is redundant and not
needed. The VOs that use VOCTRL_UPDATE_RENDER_OPTS already set
vo->want_redraw, and those are the only VOs where these options are
relevant in the first place. So we can remove this as well and just let
the big callback in player/command do everything.
2024-02-17 18:56:20 +00:00
nanahi
fb33bb7fc4 wayland_common: drop shape device check when spawning cursor
It's only necessary to check the existance of cursor_shape_manager.
Also drop the pointer check to handle multi-seat since a removed seat
sets the cursor_seat to NULL.
2024-02-17 16:09:41 +00:00
nanahi
b441a5dd1f wayland_common: properly determine has_keyboard_input
Track has_keyboard_input per seat and consider mpv having keyboard input
if at least one seat has keyboard input.
2024-02-17 16:09:41 +00:00
nanahi
a6ae2e7e60 wayland_common: handle scroll accumulation for each seat
Since it's needed to determine whether an axis event has axis_value120,
do this per seat to avoid interference between seats.
2024-02-17 16:09:41 +00:00
nanahi
04bc6a4a43 wayland_common: handle keyboard state per seat
Avoids modifiers from mulitple seats from interfering with each other
and messing up xkb states.
2024-02-17 16:09:41 +00:00
nanahi
b6dcf9ecee wayland_common: set cursor visibility for all seats for voctrl
For VOCTRL_SET_CURSOR_VISIBILITY, set cursors visibility for all seats.
The return is VO_NOTAVAIL is none of the seats have cursor, and
VO_FALSE if setting visibility failed for at least one seat.
2024-02-17 16:09:41 +00:00
nanahi
b86768b356 wayland_common: handle removal of seats 2024-02-17 16:09:41 +00:00
nanahi
cdca02a34d wayland_common: prevent cursor_seat stale reference
Set it to NULL on vo uninit.
2024-02-17 16:09:41 +00:00
nanahi
a593a9ec12 wayland_common: handle cursor_shape_device per seat
The cursor_shape_device is per pointer, which is per seat. Handle it
together with other seat objects. This in turn also handles cursor
visibility per seat.
2024-02-17 16:09:41 +00:00
nanahi
27d973ba34 wayland_common: drop unnecessary xdg_toplevel null check
The vo init already fails if xdg_toplevel creation fails, so these
checks after the vo is initialized is unnecessary.
2024-02-17 16:09:41 +00:00
nanahi
2274311b25 wayland_common: implement multi-seat support
On a multi-seat setup, wl_registry_global advertises wl_seat multiple times,
one for each seat. if wl->seat is already set, the previous value will be
overwritten, preventing it from being freed.

Additionally, if the latter seat doesn't have the capabilities of the
former seat, the keyboard/pointer/touch input devices will be destroyed
because the current wl_seat_capabilities doesn't distinguish between
different seats. This casues keyboard/pointer/touch not working if the
latter seat has no such capabilities.

Fix this by implementing multi-seat support.
This allows receiving inputs from all devices on all seats.
All seat-specific objects (wl_keyboard/pointer/touch, wl_data_device)
are grouped with their respective seats so they can be managed together.

Note that currently inputs from all seats are interleaved with each other
and modify the same global input states.
2024-02-17 16:09:41 +00:00
nanahi
5557eda842 wayland_common: indentation nit 2024-02-17 16:09:41 +00:00
nanahi
e0ddc0f69e vulkan/context_win: make --alpha work and runtime changeable
If libplacebo manages to create a vulkan swapchain that allows
alpha composition mode to be controlled by the DWM API,
this makes it runtime changeable.
2024-02-17 16:06:33 +00:00
nanahi
095038b1bc opengl/context_win: make --alpha runtime changeable
Same as d3d11, but since SetPixelFormat can be only called once,
cAlphaBits in PIXELFORMATDESCRIPTOR must be set to make this work.
2024-02-17 16:06:33 +00:00
nanahi
8de67a4af5 d3d11: make --alpha runtime changeable
The DWM compositor transparency API is runtime changeable.
Handle this in update_render_opts.
2024-02-17 16:06:33 +00:00
nanahi
117622cd4a opengl/context_win: make --alpha=yes work
Specify cAlphaBits in PIXELFORMATDESCRIPTOR makes the pixel format
transparent, as is already the case for d3d11. Also makes the
window transparent when --alpha=yes is used.

Works on --vo=gpu and --vo=gpu-next.
2024-02-17 16:06:33 +00:00
nanahi
a61026aec3 d3d11: set window to transparent if --alpha=yes is specified
This makes --alpha=yes work with d3d11 and --d3d11-flip=no.
transparent window doesn't work with flip model swapchain by design.
2024-02-17 16:06:33 +00:00
nanahi
cef378b0a3 w32_common: add function to control window transparency state
Use the DWM API to enable and disable compositor transparency.
2024-02-17 16:06:33 +00:00
Dudemanguy
c0c32b270e vo_gpu_next: don't add 0 width/height sub bitmaps to pl_overlay
Previously, libplacebo would fail to render the image since mpv was
feeding it bogus bitmaps with 0 width/height. An easy way to encounter
this would be to set sub-scale to 0 with bitmap/image subs.
2024-02-16 22:46:31 +01:00
Dudemanguy
25bba7c811 vo_gpu_next: move the frame->redraw check for blended subtitles
Cosmetic. Since the previous commit eliminated wasteful redraws, nuke
the comment while we're at it.
2024-02-15 16:43:11 +00:00
Kacper Michajłow
5098a27e66 vo: ensure that frames are not eaten on reconfig
This avoids clearing the queued frame and the currently displayed one on
VO reconfiguration requests that happen when new frames arrive. Instead,
let those frames be fully displayed.

Fixes mf:// playback issues introduced after commit ef11d31.

Instead of removing the frame timing check embrace and fix it to wake up
the playloop as needed. The frame display duration is problematic to
handle as both VO and playloop thread would already be sleeping, but in
certain use cases it is needed to display frames in full, so in this
case, let the VO sleep to the end of frame, wake up the core as
requested and go back sleeping.

Note that this patch series reintroduces 0c9ac5835, which is esenitally
fixed in this commit. It is still not perfect, but it is better than
just busy waiting on playloop, even if those events when this would be
needed are quite rare.
2024-02-15 16:39:58 +00:00
Kacper Michajłow
a329bb546c Reapply "video: remove another redundant wakeup"
This reverts commit 44c398c3e1.
2024-02-15 16:39:58 +00:00
Kacper Michajłow
0bf4da0f5e Revert "vo: remove frame timing check from vo_still_displaying()"
This reverts commit ef11d31c3a.
2024-02-15 16:39:58 +00:00
sfan5
4981690fb6 x11_common: fix Xft.dpi detection ignoring --hidpi-window-scale
closes #13466
fixes: 4b69164147
2024-02-12 13:51:25 +01:00
nanahi
71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
Guido Cella
86e0882733 wayland: don't press keys again when releasing modifiers
Since 1f8013ff3f, if you release a modifier before a regular key on
Wayland, that key gets immediately pressed again because
keyboard_handle_modifiers() calls mp_input_put_key() regardless of
whether a modifier is pressed or released, e.g. if you press Ctrl+s it
easy to take an another screenshot with s by accident. Fix this by
releasing keys when releasing modifiers.

Ideally, releasing the modifier should input the key alone after
--input-ar-delay, while this patch disables it forever, e.g. on X11 if
you type something in the console, hold Ctrl+h, and release Ctrl, it
starts typing h instead of deleting characters. This doesn't work
because keyboard_handle_key() is only called when you first press a key,
while on X11 KeyPress keeps getting sent as you hold down the key. But
this difference in behavior between X11 and Wayland can also be
reproduced with GTK and Qt applications, so I guess this is acceptable.
2024-02-11 04:01:14 +00:00
Philip Langdale
f5c4f0b0f4 hwdec_drmprime: check for AV_PIX_FMT_P210 before using it
This isn't present in older ffmpeg releases.

Fixes #13454
2024-02-10 13:29:04 -08:00
Dudemanguy
a45518cf57 wayland: set current_output on surface leave if applicable
When the mpv surface leaves the output, we no longer mark it as the
current output. However, this implicitly depends on there being a
preceding surface entrance event to a different output. This is not
necessarily the case. Consider moving the window from monitor 1, to
monitor 1-2, and then back to 1 again. mpv gets the entrance event to
monitor 2 and sets that as the current output to work off of. Then when
you move back to only monitor 1, it removes monitor 2 from the current
output. However, monitor 1 is not updated again as the current output
because there is not a new surface entrance event in this case (the
window never left). So the numbers that mpv's core is using are
incorrect and for the wrong monitor. Luckily, we already keep track of
what outputs the mpv surface is currently on no matter how many there
are so it is simply a matter of setting current output again in the
leave event if we have a different output that has the mpv surface.

Ref: https://github.com/swaywm/sway/issues/7932
2024-02-08 22:26:15 +00:00
Kacper Michajłow
9ce2bafbe9 vo_vdpau: cosmetic changes to timings
Remove unneded range check.
Print time difference with more precision.
Use the same data formats for fps and interval as in other VOs.
2024-02-07 14:45:07 +00:00
Dudemanguy
343a5fd345 player: remove all rpi-specific code
vo_rpi and its related code has pretty much historically been a
disaster in mpv. The build regularly gets broken and since nobody uses
it, it takes months for anyone to notice. There was also that time where
fullscreen was broken for about a year and a half. Also building in waf
was entirely broken for about a couple of years or so due to mysterious
reasons no one ever figured out (meson magically fixed it).

Anyways, once again the build is broken due to rpi being forgotten about
again, but instead of pretending to support this crap. Just drop it all.
Nowadays, mmal hwdec is a relic since these devices are better off using
the v4l2m2m ffmpeg fork instead which actually uses KMS properly. RPI 1
and 2 probably can't do this and will remain broken but oh well blame
Broadcom for being special snowflakes and not using standard APIs (my
rockpro worked out of the box; just saying). RPI 2 is nearly 10 years
old anyways, so I think you can afford a new SBC by now. If we were
nicer, there would be a deprecation period, but this is broken in the
last major release anyway so too late.

Closes #13402.
2024-02-05 17:41:06 +00:00
Dudemanguy
531868fe0d player: ensure runtime updates of certain rendering options
When adding things like brightness or gamma, the video obviously needs a
redraw if paused. This happened to work in the normal case because the
OSD notification triggered a redraw, but if you use no-osd the picture
won't change. Fix this by adding another option flag, UPDATE_VIDEO, and
simply signalling we want a redraw. This gets handled along with the
normal osd redrawing check in the playloop so something like "no-osd add
gamma 1" actually works.
2024-02-05 17:23:47 +00:00
Dan Oscarsson
b23e8b2ffb vo_vdpau: fix timing for nanoseconds
df764bc0c3 and
c82c55b4b9 blindly converted the units for
this VO since neither of us actually have the hardware/setup to test the
VO. Well it was not actually correct (maybe just one was wrong or both
who knows) since vo_vdpau using timing very differently than all the
other VOs and no one reported on it until just now. Anyways, just apply
this random patch from @DanOscarsson which apparently works for him and
call it a day. Fixes #13397.
2024-02-04 10:01:49 -06:00
nanahi
27cb193f0e wayland_common: warn if scrolling will be broken
Since the scroll event handler is moved to wl_pointer_frame, version 5 of
wl_seat is required. Warn that scrolling is broken if the compositor
doesn't support that verison.
2024-02-04 02:14:11 +00:00
nanahi
e0f9cf61b9 wayland_common: add touch listener boilerplate
Required if seat version >=6 is used.
2024-02-04 02:14:11 +00:00
nanahi
b3edb46fd9 wayland_common: prefer axis_value120 if supported
Prefer axis_value120 for high resolution scrolling if supported, which
matches the existing win32 behavior.
2024-02-04 02:14:11 +00:00
nanahi
f95b7146d7 wayland_common: properly handle high resolution scrolling
Commit f54ad8eb05 broke high resolution
scrolling because one logical mouse click is generated for every scroll
event, no matter the magnitude. This makes scrolling on trackpad way
too fast.

Revert the axis scaling change in that commit and clamp the resulting
value between -1 and 1 to make sure mouse wheel scrolling works as
intended on compositors which send a value larger than 10 for these events.
2024-02-04 02:14:11 +00:00
nanahi
aaaadc9d6b x11_common: support --title-bar
Some X11 window managers support controlling the title bar independently
from other window decorations with _MOTIF_WM_HINTS. This allows hiding
the title bar while keeping other decorations like the resizing borders.

Let mpv respect the --title-bar option on X11 so --no-title-bar can hide
the title bar only like on win32.
2024-02-02 11:39:30 +01:00
Dudemanguy
adcc6794b5 wayland: look for "default" cursor as well as "left_ptr"
Some themes are apparently getting rid of "left_ptr" and using the
cursor spec names instead. Check for "default" as well. Fixes #13376.
2024-02-01 15:26:46 +00:00
Kacper Michajłow
e2e75906da io: add mp_save_file
Move from vo_gpu_next.c to io.c and return result.
2024-01-31 15:38:21 +00:00