mpv icon indicating copy to clipboard operation
mpv copied to clipboard

GUI embedding for Wayland

Open ghost opened this issue 12 years ago • 19 comments

Right now, the mpv window can be embedded inside of a foreign window on the following platforms: x11, win32, cocoa.

Just wayland is missing.

Ideally, this would work via --wid, and no changes would be required for our qtexample. Though I'm not sure if this is possible.

I think @giselher did some work into this direction, but I'm not sure about its current state. I'm creating this issue to track/communicate this.

ghost avatar Nov 04 '14 17:11 ghost

Hi, sorry that I have been on radio silence for a while. I was quite busy, but I still intend to finish embedding.

I don't know where we want to go with this though. Maybe we can render in an opengl window or buffer without the need for a nested compositor, but I don't know how feasible that is.

giselher avatar Dec 16 '14 12:12 giselher

I'm glad you're back!

This issue isn't terrible high-priority, but it would be nice if it would work eventually.

I don't know where we want to go with this though. Maybe we can render in an opengl window or buffer without the need for a nested compositor, but I don't know how feasible that is.

It should probably go by what GUI toolkits are doing or planning to do. For example this (amazingly) works on all other platforms. I'm probably being naive here, and have no idea whether it could work this way on wayland.

ghost avatar Dec 16 '14 12:12 ghost

It should probably go by what GUI toolkits are doing or planning to do. For example this (amazingly) works on all other platforms. I'm probably being naive here, and have no idea whether it could work this way on wayland.

I will try this soon, but I can't image what a WinID will be under wayland. Maybe a wl_display pointer?

giselher avatar Dec 16 '14 14:12 giselher

I can't image what a WinID will be under wayland. Maybe a wl_display pointer?

Who knows. Maybe it's not even implemented.

ghost avatar Dec 16 '14 14:12 ghost

well i hope this is finished soon... - i use smplayer, and having a external window rendered for mpv in wayland is a pain.

EndlessEden avatar Jan 13 '16 05:01 EndlessEden

Seems unlikely. It's not even clear whether Wayland can support this kind of embedding. I'm tending towards saying that programs which embed mpv should use the opengl-cb API. (Of course smplayer can't do that, because it's backwards and attemps to coerce mpv into pretending to support a mplayer slave-mode-like protocol.)

ghost avatar Jan 13 '16 10:01 ghost

The Wayland way to do that is for the host app to implement a small embedded compositor, and forward the surface as a sub-surface. There is a GTK+-based proof-of-concept available here.

sardemff7 avatar May 19 '16 17:05 sardemff7

Sure (I heard that before), but I already decided that opengl-cb embedding is better.

ghost avatar May 19 '16 18:05 ghost

Hi, I'm a little confused on why this still open. Are there plans to make the --wid option to work with wayland by doing some work "under the hood" inside mpv?

kokoko3k avatar Oct 31 '16 10:10 kokoko3k

Commit 8d8d4c5cb1 should add support for this. In theory setting the parent to mpv xdg_toplevel should work. Then you can use the xdg interface to manipulate its position, gravity, anchoring, etc.

ghost avatar Oct 05 '17 15:10 ghost

Sorry, but xdg_toplevel.set_parent() does not support placement in any way. Also, I am not familiar with mpv internals, but does mpv creates its own Wayland connection? If so, you cannot pass xdg_toplevels around, each connection is a separate client sharing no namespace. If mpv does not create its own connection, then embedding should be done using a subsurface, with mpv giving a wl_surface to the parent. If mpv creates its own connection, you need to use xdg-foreign, and then mpv cannot create an xdg_surface. And placement is not supported either, one would need to extend xdg-forgein (or create a new protocol) to allow subsurface creation, I guess.

sardemff7 avatar Oct 05 '17 16:10 sardemff7

Seems quite a lot more complicated than I thought it would be. If there's any real interest I'll investigate.

ghost avatar Oct 05 '17 16:10 ghost

Definitely for me, as my gui to mpv is written in Gambas and i don't think there is a way to display anything from mpv inside the main ui other than embedding his window, or using Xwayland, of course

kokoko3k avatar Oct 05 '17 17:10 kokoko3k

I would have thought the xdg interface object would have provided access to the wayland connection for mpv to use.

If it doesn't work, it should be removed again.

Not that I have much confidence in the architectural awereness of someone who uses Gambas.

ghost avatar Oct 05 '17 19:10 ghost

Sorry?

kokoko3k avatar Oct 05 '17 21:10 kokoko3k

You're experiencing prejudice against BASIC programmers.

ghost avatar Oct 05 '17 23:10 ghost

Well, Gambas looks to be worse than that: BASIC meets Java meets GNU. Quite revolting.

ghost avatar Oct 06 '17 15:10 ghost

@sardemff7: https://github.com/atomnuker/mpv/commit/dc59f993222792b595393ed64021f35bdc6a67ec This would add support for the new xdg-foreign-v2 protocol. Its currently only supported by kde git master. Do you think this is sufficient now?

ghost avatar Oct 14 '17 17:10 ghost

Hello everybody, I know this is a very old issue report, but I wanted to ask, whether it would be possible to make wayland-embedding in libmpv possible, too? This would be great!!! The vlc guys think about this, too (see here ;-) a function as mpv_set_wl_surface or similar would be great. Rendering through OpenGL doesn't work for me and a simpler alternative in Wayland would be very important! Thanks in advance, Max

MaxPerl avatar Dec 30 '21 13:12 MaxPerl