Commit Graph

6400 Commits

Author SHA1 Message Date
nanahi
9f2ac08851 clipboard-wayland: add Wayland clipboard backend
This adds a "native" Wayland clipboard backend based on the
ext-data-control-v1 protocol.
This backend overcomes the limitation of the VO (Wayland core protocol)
backend, and does not require the presence of the VO window to receive clipboard
updates.
This backend also supports primary selection if supported by the compositor.

The backend runs in a separate thread, so clipboard reading
does not stall the player like the VO backend.
2025-01-27 18:51:31 +01:00
Attila Fidan
fbf366d124 video/out/wayland_common: create per-seat objects on seat hotplug
This is to allow data device and text input to be used on seats that are
hotplugged after vo init.
2025-01-27 18:51:10 +01:00
verygoodlee
57a8105f1a win32: fix menu click failure caused by excessive menu-data updates
basically a copy of tsl0922/mpv-menu-plugin#77

if you have 200+ menu items and update `menu-data` about 400 times,
clicking menu item will not execute any command, the reason is that the
menu identifier greater than the max value of 16-bit unsigned integer.

1. make menu id always less than 0xF000 as mpv-player/mpv@861908c7 said
2. old menu items are never reused, should delete by DeleteMenu()
   instead of RemoveMenu(), destroys the handle and frees the memory
2025-01-26 22:19:26 +01:00
nanahi
c776f5f2c9 various: use mp_poll instead of poll
mp_poll supports higher time resolution than poll, so use it
when the timeout is not 0 or infinite. Also use time conversion
macros.
2025-01-26 22:15:30 +01:00
nanahi
88ee25da12 video/out/wayland_common: remove useless flag
POLLHUP is only returned in revents and ignored in events,
so there is no need for it to be here.
2025-01-26 22:15:30 +01:00
Attila Fidan
98627b027d video/out/wayland_common: fix crash with multi-seat drag and drop
If you have two seats connected, both with the pointer capability, and
use two hands to start a drag and drop operation with each pointer, then
move one pointer to the mpv window, then the other, mpv fails the
!wl->dnd_offer->offer assert in device.enter, because it expects that
the compositor wouldn't just call device.enter again before device.leave
or offer.finish.

The data device is per-seat, so this commit makes mpv track the data
device's offers per-seat rather than in vo_wayland_state, which makes
more sense and is easier to reason about when multi-seat is involved.
2025-01-26 16:32:30 +00:00
Attila Fidan
51dc6286b6 video/out/wayland_common: support IME usage via text-input-v3
This is useful for text input in, for example, console.lua. Each
character in the commit string gets turned into an mpv key press.
Pre-edit strings are not handled, since there's currently no good way to
handle that or make it useful to text input scripts. Like win32, which I
tested in wine, another limitation is that the composition window is
always positioned at the top left of the window, since we cannot get
useful positioning hints from mpv scripts. It allows the composition
window to be within the window and avoids obstructing the console
prompt.

This can be enabled/disabled with --input-ime=<yes|no> (default: yes).
2025-01-25 03:14:44 +00:00
Attila Fidan
c9412b4721 video/out/wayland_common: ignore clipboard offers w/o wanted MIME type
Some Wayland clients not offering text/plain will send their non-text
data regardless of the MIME type requested in wl_data_offer.receive. We
should just not call receive if they haven't offered a MIME type we
want.
2025-01-18 12:51:05 +01:00
nanahi
c42b19b806 video/out/gpu/video: allow taking transparent screenshots
Use RGBA format to take transparent screenshots when the video has
an alpha channel.
2025-01-05 21:32:55 +01:00
Filip Hejsek
0a0ceb7439 vulkan/context_display: implement display fps and resolution info
Implement VOCTRL_GET_DISPLAY_FPS and VOCTRL_GET_DISPLAY_RES by returning
values obtained from Vulkan.

Currently, display fps and resolution info is not available in the
displayvk context. Display fps is needed for display sync to work
properly. The information is also used as the value of a few properties.

This slightly improves parity with the drm context.
2025-01-04 22:40:03 +00:00
Kacper Michajłow
59d1dc43b9 various: fix typos 2025-01-04 15:59:49 +02:00
Kacper Michajłow
efcee92d0e various: remove double new line at the end of file 2025-01-04 15:59:49 +02:00
Neko Asakura
50042f5ee0 mac: add support for --force-window-position 2024-12-31 14:49:39 +01:00
Dudemanguy
3218e74aaa x11: allow display sync modes to report no visibility
When this was originally implemented, I lazily skipped the optimization
when using display sync because mpv would rip through all the frames
without waiting since there was no blocking. With the previous commits,
we now fall back on the audio sync logic when the window is not visible,
so the extra condition can be removed.
2024-12-28 16:51:28 +00:00
Dudemanguy
a2fe5ee900 player/video: fallback to audio sync logic if VO is not visible
The previous commit put all the pieces in place so now this can be
implemented. Scheduling frames is already written with the assumption
that display sync maybe turn on/off at any time. So all that needs to be
done is check if the VO reports that it is not visible. If so, simply
flip mpctx->display_sync_active to false for that frame and skip the
display sync frame handling. It will become true again when the mpv
window comes back into view.
2024-12-28 16:51:28 +00:00
Dudemanguy
91c1b65de0 vo: change draw_frame API to a boolean
x11 and wayland VOs + backends all have logic that skips drawing frames
when the mpv isn't visible for efficiency reasons. This is implemented
in each individual VO, but it is useful for the core to be aware of this
as well. Currently, the display-sync modes on x11 do not try to be
efficient and always render anyways because there is no blocking on the
graphics API level if you skip rendering a frame (wayland works here by
accident). This means mpv would otherwise blaze through frames which is
not what anyone wants. We can instead improve this by implementing the
blocking mechanism in the core and using that when appropriate. This
commit does not implement that yet, but simply switches the draw_frame
to a boolean. Receiving false means that the VO is not drawing frames
and it should be treated as if the surface was hidden.
2024-12-28 16:51:28 +00:00
der richter
4dbf81c94c mac/title: use enum for material values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter
4063cdf20b mac/title: use enum for appearance values instead of generic integers 2024-12-28 14:30:41 +01:00
der richter
cd9fa6daf0 mac/title: remove old libmpv color setter fallback 2024-12-28 01:46:41 +01:00
der richter
51af3caa77 mac/title: remove old libmpv material setter fallback 2024-12-28 01:46:41 +01:00
der richter
11a9f355c7 mac/title: remove old libmpv appearance setter fallback 2024-12-28 01:46:41 +01:00
der richter
bba198a713 mac: use isBundle function instead of manually checking bundle usage 2024-12-26 15:00:57 +01:00
Kacper Michajłow
d9eb9ed844 video/sws_utils: remove unused mp_image_swscale
This has been used before 2c43d2b75a. Now
that we have also zimg support, using swscale directly may not be wanted
depending on the user options.
2024-12-25 18:01:56 +01:00
der richter
d82701962f libmpv: deprecate MPV_RENDER_PARAM_AMBIENT_LIGHT render parameter
the equivalent options have been deprecated since mpv 0.35 in ac39661
and 2207236.

also bumping the MPV_CLIENT_API_VERSION to 2.5, since 2.4 was forgotten
in 6f619d5.
2024-12-21 16:15:44 +01:00
der richter
e785296a1c cocoa-cb: use new ambient-light property and remove old libmpv usage 2024-12-21 16:15:44 +01:00
der richter
e0f82b1a77 gamma-auto.lua: add this script as replacement for --gamma-auto
also mention this replacement for --gamma-auto.
2024-12-21 16:15:44 +01:00
der richter
2b06728df9 command: add ambient-light property
make it observable to make it usable as a replacement for --gamma-auto.
2024-12-21 16:15:44 +01:00
der richter
811062279e vo: change VOCTRL_GET_AMBIENT_LUX from int to double 2024-12-21 16:15:44 +01:00
Dudemanguy
96bebf0935 x11: simplify --geometry and --auto-window-resize logic
There were a few pitfalls with the way this was previously implemented
because --geometry implicitly depended on --auto-window-resize being
enabled to operate in a few cases. Instead, let's change the logic a bit
so that instead we choose whether or not to reuse the old rc (i.e. don't
resize) and use the wh_valid and xy_valid fields within the m_geometry
struct instead of using x11->geometry_change. This fixes several edge
cases involving setting the position with --geometry when using
--auto-window-resize=no.
2024-12-20 18:03:30 +00:00
nanahi
b174d98042 video/out/wayland_common: make all XF86 special keys mappable
Forgotten in 417869f845.
2024-12-20 14:54:35 +00:00
llyyr
7fffaf8557 vo: update base_vsync even for initial samples
This is still used for caclulating a/v sync and delay remaining even
for initial samples, so we should always update it to the actual vsync
for those initial samples so we have something to work with at least.

And if we receive bogus values, also reset it to 0 along with
prev_vsync.

Not having base_vsync set to _some_ value completely breaks
vsync_skip_detection, and mpv stays stuck in a permanent mistimed state
where every frame is marked as delayed and never recovers from it.
2024-12-11 16:42:13 +01:00
llyyr
bd915439d0 vo: use display clock to determine frame_end in display synced case 2024-12-11 16:42:13 +01:00
llyyr
84728fb5e9 vo: extract display synced frame end calculation
into get_display_synced_frame_end. Used in next commit.
2024-12-11 16:42:13 +01:00
Kacper Michajłow
3df8b0b297 video/out/gpu/video: don't pass big structs by value when not needed 2024-12-10 14:14:09 +01:00
Kacper Michajłow
db70ae6fa2 hwdec_vaapi: don't jump over variable init in try_format_upload 2024-12-10 10:17:34 +01:00
Kacper Michajłow
fe546c1841 w32_common: guard recursive call to mp_dispatch_queue_process
This is already done in WndProc, but the flag was not set if we exited
event loop and were processing mpv dispatch messages in fallback loop.

This fixes the case when Window is destroyed externally or otherwise
event loop fails for whatever reason. Calling vo_w32_uninit does call
DestroyWindow() through dispatch, which in turn calls WndProc, so we
need to guard recursive call.
2024-12-09 19:20:52 +01:00
Kacper Michajłow
8eea5902ba options/m_option: restore m_geometry_apply centering ability
This fixes geometry uses where it is expected to be centered. For
example this fixes video-crop option.

Fixes: e01eab4385
Fixes: #15398
2024-12-08 18:14:04 +01:00
Guido Cella
f7e6e30a49 aspect: add --video-recenter
This ignores --video-align-{x,y} when the video is smaller than the
window in the respective direction.

After zooming in, panning and zooming out, this is useful to recenter
the video in the window.

Unlike doing this by observing osd-dimensions in a script, this is done
before rerendering, so you don't see the image being rendered uncentered
for an instant after zooming out, before being rerendered centered.

Also update --video-align docs while at it.

This doesn't work well with --video-pan-{x,y} because you can move the
output rectangle far away from the image, and when zooming out pan is
abruptly reset to the center. It doesn't feel like natural like zooming
out after changing --video-align-{x,y}. So this commit doesn't set pan
to 0. Also this leaves a way to move scaled images within the window
even with --video-recenter.
2024-12-02 22:31:14 +01:00
llyyr
1a03d6ab84 vulkan/context: propagate --gpu-sw on vulkan contexts 2024-12-01 12:22:15 +01:00
der richter
dec0d02f9f vo_gpu: undeprecate --gamma-factor
deprecated since 0.35 in ac39661 and 2207236.
2024-11-30 02:32:39 +01:00
Kacper Michajłow
6ea2cd72ec vf_format: fix format=dolbyvision=no metadata stripping
If p->colormatrix is 0 if not set by user, so it would always override
_orig parameters with Dolby Vision ones and restore that erroneously.

Fixes: e2365bfece
2024-11-28 17:33:31 +01:00
nanahi
d9f30cc079 video/out/wayland_common: support clipboard monitoring
Works by notifying property update when clipboard content is
updated.
2024-11-27 20:31:41 +01:00
nanahi
d47ce38e20 video/out/wayland_common: implement VOCTRL_GET_CLIPBOARD
This adds support for VOCTRL_GET_CLIPBOARD which makes the VO
clipboard backend be able to get clipboard content for Wayland.
2024-11-27 20:31:41 +01:00
nanahi
b93d3046e2 video/out/wayland_common: implement clipboard support
Clipboard contents are available as selection data offers under
Wayland. The offer can become invalid at any time, so request the
text format content immediately when an offer is received,
and cache the content for later use.
2024-11-27 20:31:41 +01:00
nanahi
fa3a167347 video/out/wayland_common: generalize check_fd 2024-11-27 20:31:41 +01:00
nanahi
240ebd6ad3 vo: add VOCTRL_GET/SET_CLIPBOARD
This adds VOCTRLs needed for VO-based clipboard backend.
2024-11-27 20:31:41 +01:00
der richter
639ef09807 mac: implement VOCTRL_BEGIN_DRAGGING
this removes the old isMovableByWindowBackground mechanism with the
newer performDrag(with:) function.
2024-11-27 18:48:47 +01:00
Guido Cella
f7e2a8c1cc bstr: add bstr_xappend0 2024-11-27 15:37:42 +01:00
Guido Cella
b9e6030053 command: highlight selected list items with color
Instead of printing circles in show-text ${playlist}, ${chapter-list}
and ${edition-list}, introduce --osd-selected-color and
--osd-selected-outline-color to reduce clutter, make the selected item
easier to differentiate, and have visual consistency with select.lua.

The defaults are taken from the style of the selected item in the
console. These new options are also used there, replacing the hardcoded
styles. Due to being user-configurable, selected item styles are changed
to take priority over default item styles.

The default selected style is yellow and bold. The bold (hardcoded)
allows differentiating the selected item with color blindness. There is
also a separate --osd-selected-outline-color option defaulting to black,
since without it if the user changes --osd-outline-color yellow text
becomes unreadable without a black border. --osd-selected-back-color is
omitted for now.

Text and background colors are inverted for the selected item in the
terminal. This is hardcoded, adding an option is overkill.

A disadvantage of this commit is that if you run print-text ${playlist}
with a VO, the selected style ASS is printed to the terminal (but ASS
printed in the console is interpreted). This commit avoids printing the
reset ASS sequence for non-selected items to reduce clutter in this
case.
2024-11-27 15:37:42 +01:00
Kacper Michajłow
5730c631fd player/video: update dynamic hdr params 2024-11-24 11:32:12 +01:00