sway icon indicating copy to clipboard operation
sway copied to clipboard

Output mirroring and complex layout configurations

Open ddevault opened this issue 7 years ago • 57 comments

First step is to make these two statements true:

  • Outputs always render the tiled views in their own sway_container and never anyone else's
  • Floating views are rendered with respect to the output layout, and can show on multiple outputs

Then, we should start to introduce two new kinds of configuration to each output config:

  • Layout configuration
  • Mirroring configuration

A layout configuration stores how much of the output's space is allocated to its sway_container:

output HDMI-A-1 layout 100x100@10,10

Bonus: could subdivide the output into multiple layouts

output HDMI-A-1 res 1920x1080 layout 960x1080@0,0 layout 960x1080@960,0 subdivides a 1080p output into two halves, which each get their own workspace (useful for ultrawides, for example)

If no layout is specified, the default layout is used - WxH@0,0

No layout at all can also be specified via layout none, in which case no workspace is allocated.

Separately, you can specify a mirroring configuration via mirror [source output] [at X,Y], which will draw tiling windows from the source output onto the configured output at the target position. You can specify this several times.

Some example configurations:

Normal configuration

output HDMI-A-1 res 1920x1080
output DP-1 res 1920x1080 pos 1920,0

basic-side-by-side

Basic mirroring

output HDMI-A-1 res 1920x1080
output DP-1 layout none mirror HDMI-A-1

basic-mirroring

Disjoint resolution mirroring

output DP-1 res 1280x720
output HDMI-A-1 res 1920x1080 layout none mirror DP-1

disjoint-res-mirroring

Disjoint resolution mirroring with floating views

Note: this is the same config as the last example

output DP-1 res 1280x720
output HDMI-A-1 res 1920x1080 layout none mirror DP-1

disjoint-res-mirroring-float

Disjoint resolution mirroring with multiple layouts

output DP-1 res 1280x720
output HDMI-A-1 res 1920x1080 mirror DP-1

disjoint-res-mirroring-multi

Disjoint resolution mirroring with multiple layouts and double mirroring

output DP-1 res 1280x720 mirror HDMI-A-1
output HDMI-A-1 res 1920x1080 mirror DP-1

disjoint-res-mirroring-multi-double

Partial mirroring plus partial layout

output HDMI-A-1 res 1920x1080
output DP-1 res 1920x1080 mirror HDMI-A-1 at -1800,0 layout 1800x1080@120,0

mirroring-overlap

Unanswered questions:

  • z-ordering config

ddevault avatar Mar 30 '18 17:03 ddevault

wlr-output-layout has no support for z-ordering so we'll have to address it there.

acrisci avatar Mar 30 '18 17:03 acrisci

I don't think that's in scope for wlr-output-layout, we'll probably want to store that info on sway's structures

ddevault avatar Mar 30 '18 17:03 ddevault

do you have a roadmap for this issue already?

onorua avatar Mar 15 '19 18:03 onorua

We never have ETAs.

emersion avatar Mar 15 '19 18:03 emersion

This message is for people following this ticket and looking for a workaround for the current lack of screen mirroring for instance to use an overhead projector.

The trick is that the mouse and the floating windows are rendered according to their global coordinates. Also sway does not complain when outputs have overlapping geometries so you can do something like

swaymsg output  eDP-1 pos 0 0 
swaymsg output  HDMI-A-2 pos 0 0 

At first that does not seem to do anything except that the mouse is now displayed on both screens. What is interesting is that all floating windows are now also rendered on both screens.

I am pretty sure that during my first experiments fullscreen windows were rendered on both screens but unfortunately I cannot reproduce that anymore (another trick needed)?

That setup is not without issues. The main one is that sway is tracking the mouse coordinates to between switch between the output workspaces. Consequently, unexpected and mostly unnoticeable switches between the 2 overlapping workspaces can happen during common actions using the mouse (e.g. moving, resizing, leaving or entering floating windows).

schauveau avatar Mar 23 '19 11:03 schauveau

I'd prefer a looser coupling between layouts and outputs. Instead of having workspaces on outputs, you have them on layouts. Layouts can have an arbitrary position and size (but probably should not intersect). Outputs can also be arbitrarily positioned. They act as viewports into the layout plane instead of directly having workspaces. To make an output into a viewport (i.e. have no workspaces itself), the output configuration line gets the 'viewport' keyword. If an output happens to view a region where some layouts lie it'll be a viewport for them. Dunno how DPI scaling of outputs/viewports could be handled.

Example:

layout 100x100 pos 0,0
layout 100x100 pos 100,0
layout 100x100 pos 0,100
layout 100x100 pos 100,100
output DP-1 res 100x100 pos 50,50 viewport

screenshot-2019-04-02T18:50:59Z The black rectangles are layouts, the red one is a output/viewport. In this (unrealistic) example you'd see a corner of each of the four layouts on output DP-1.

minus7 avatar Apr 02 '19 18:04 minus7

// Mirrorring +1 for a config allowing you to mirror any output ... ideally be able to switch with keyboard shortcut to mirror-mode, because my default should be:

// Stacking on top My setup is 99.9% of all cases: Laptop screen + 1 external screen / Beamer.

@ddevault : With a notebook in-front of a desktop monitor, I would love to extend the external screen above my laptop screen. And have a generic config, that by default stacks the external screen on-top of the laptop screen.

It seems to me that with the current sway-output syntax this should not be possible, because the 0|0 coordinate is in the top left corner and thus I would need to use the height of the external screen in the sway config... but this height can vary depending on screen model... and I am looking for a way to use the "*" to match any external screen.

Tormen avatar Apr 04 '19 18:04 Tormen

I hope mirroring comes soon, that is the missing feature that forced me back to X11 :-(

tpanum avatar Apr 25 '19 08:04 tpanum

What I am using in the mean-time is a small script cycles through the available screens and disables all others.

Like this you can at least easily move everything to an output (e.g. external screen or projector).

Maybe that can be an idea for Thomas as well.

Tormen

On Thu, 25 Apr 2019 01:24:18 -0700 Thomas Kobber Panum [email protected] wrote:

I hope mirroring comes soon, that is the missing feature that forced me back to X11 :-(

Tormen avatar Apr 25 '19 10:04 Tormen

Would this issue also cover handling different output configurations with different combinations of connected displays?

e.g. if I am using just my laptop screen, then that should be turned on if I have connected my laptop to my external monitor, then the external display should be on and the laptop screen should be off.

There is currently no way to declare this (from what I can tell) in sway configuration.

MichaelAquilina avatar May 13 '19 10:05 MichaelAquilina

There are no plans to support such thing in sway. You can use a helper client instead, such as kanshi.

emersion avatar May 13 '19 10:05 emersion

Was not aware of kanshis existance. Thanks for the heads up @emersion :)

MichaelAquilina avatar May 13 '19 10:05 MichaelAquilina

Is there any progress on this? Honestly speaking, not being able to switch between dual and mirror mode is a major problem for most laptop users to the point that they can't use sway at all.

torwag avatar Sep 10 '19 06:09 torwag

Is there any progress on this? Honestly speaking, not being able to switch between dual and mirror mode is a major problem for most laptop users to the point that they can't use sway at all.

I'm not sure about not being able to use sway at all, but I agree it would be nice to at least have mirroring work. It is a bit of a bummer to have to switch back to i3 for conferences when I have to project the screen for audiences.

Would it be better to split mirroring off as a sub-feature and implement instead of waiting for this whole feature set to be done together?

J0nnyMak0 avatar Oct 30 '19 15:10 J0nnyMak0

Some hint for conferences and presentations: I was able to make OBS Studio (with wlrobs) to display a window with real time contents of another display (big screen/projector) which I can view on laptop display which is quite enough for presentations. I suppose there should be more lightweight solution but I haven't got enough time to dig into it.

m-khvoinitsky avatar Oct 30 '19 16:10 m-khvoinitsky

Would it be better to split mirroring off as a sub-feature and implement instead of waiting for this whole feature set to be done together?

Yes. The plan was never to implement everything in this issue at once. Incremental pull requests are welcome.

emersion avatar Oct 30 '19 22:10 emersion

I see this enhancement is not in a milestone or project. So I am wondering how far are we with the two first steps mentioned by OP @ddevault

First step is to make these two statements true:

  • Outputs always render the tiled views in their own sway_container and never anyone else's
  • Floating views are rendered with respect to the output layout, and can show on multiple outputs

in regards to starting work on the following?

Then, we should start to introduce two new kinds of configuration to each output config:

  • Layout configuration
  • Mirroring configuration

I get the incremental PR approach. Though as an sway dev "outsider", it is hard to tell which state or where in the process this enhancement is. Could you enlighten me?

Thanks

salkin-mada avatar Jan 19 '20 13:01 salkin-mada

Floating views are rendered with respect to the output layout, and can show on multiple outputs

I just launched both an Xwayland (xeyes) and a wayland native app (alacritty) each, set them to floating, and dragged them between my outputs. They both rendered partially on each output as expected conformal to the defined layout. So at least one of two prerequisites is met.

danshick avatar Feb 04 '20 18:02 danshick

Is mosaic of displays something that fits here or that should have its own issue?

pedrocr avatar Feb 26 '20 15:02 pedrocr

For @torwag or anyone else that like me come here from a search, I have a non-solution that I settled on for now. I just run swaymsg output eDP-1 disable to disable the laptop screen so everything is moved to the external monitor, that's what I was trying to achieve with mirroring anyway. You can then swaymsg output eDP-1 enable to enable it back. There's also an entry on the sway wiki about doing it automatically when lid is closed: https://github.com/swaywm/sway/wiki#clamshell-mode

Hope someone finds this helpful.

tasn avatar Mar 05 '20 12:03 tasn

@tasn Indeed this is not a solution at all. Sway does manage very well extended workspace across multiple screens. What is missing is a mirroring mode to be able to see what is being presented when the secondary screen is behind you for instance. Your solution does not change anything on that subject.

X-dark avatar Mar 05 '20 12:03 X-dark

I wasn't trying to claim that it does. I was just suggesting that for the use-case of plugging your laptop into a dock, there's a workaround until this is implemented.

tasn avatar Mar 05 '20 12:03 tasn

Currently you can run wayvnc server on one screen and use a vnc client to display that on another screen. it works somewhat better and is usable for slideshows.

artizirk avatar Mar 05 '20 12:03 artizirk

The requirement for mirroring for me is to do presentations and meetings. Often you don't see the big screen at all, so you need to be able to look at your laptop screen in order to see what everyone else is seeing. Sway is great, but I've had to move back to i3wm just to support mirroring.

victortrac avatar Mar 05 '20 14:03 victortrac

Many presentation applications support "presentation mode" which has one view that you can put on the big screen, and one just for you with notes + timer. I always use that when giving talks. I agree mirroring would be useful, just trying to help with solutions for some common use-cases, at least the ones I encounter. :)

tasn avatar Mar 05 '20 14:03 tasn

If you're looking for a presentation tools for pdfs: pdfpc might be an option

csicar avatar Mar 05 '20 14:03 csicar

Back when I switched to sway from i3 I did this willingly to take the pain of the missing output mirroring. Then it turned out such pain never materialized, as almost every program you are likely to want to use for presenting offers some sort of dual-screen presentation mode. I mostly use my own, but for my occasional PDF slides I discovered by accident that Okular does it too: Start the presentation with Cntrl-Shift-p and move the full-screen slide to the beamer with Win-Shift-2 (or whatever). The regular Okular window reappears behind the moved audience view; you can navigate its pages, and the audience view will happily follow in sync.

Last Friday I gave a full-day course using Jupyter Lab. For the first time I was really going to miss output mirroring, so I thought, which brought me back here. The suggestion of using VNC struck me as such a kludge!

I installed wayvnc and gave my course, using vinagre to remote-control the audience view.

Now, output mirroring is such a kludge! It forces you to sacrifice your entire internal screen to the audience. VNC does exactly the right thing: It displays the audience view in a window that you can move, resize, hide, etc., giving you full control over the presentation without getting in the way.

I no longer see any use case for output mirroring.

Edit: In the meantime, wl-mirror has appeared on the scene. This does exactly the right thing and is much more lightweight than VNC.

piater avatar Mar 08 '20 21:03 piater

Output mirroring, or at least mirroring of the contents of a sway "container" is something that is definitely something very needed outside of just presenting a single application.

Doing hands-on courses or presentations often means you have to show multiple applications side-by-side (e.g. terminal and browser), and at least until screen recording and streaming works well on wayland you can't even outsource this to an application (e.g. obs) in a simple way. And even if such applications exist, the simplicity of just saying "mirror" will deter MANY people from switching to sway if they use it regularly and sway doesn't support it.

On a different note: Complex Layout configurations

Ultrawide and 4K screens are becoming more popular, and many people that had multiple screens previously are switching or thinking about switching to a single larger monitor. In such situations complex layout configurations like splitting a single monitor into two or more logical workspaces is a MUST. It's pretty much unusable otherwise.

Ferdi265 avatar Apr 22 '20 16:04 Ferdi265

I tried to read into the sway and wlroots code base multiple times, and even tried to ask on IRC for some documentation, but the answer was mostly "implement it yourself and send a patch", and "just read the code".

Ferdi265 avatar Apr 22 '20 16:04 Ferdi265

Ultrawide and 4K screens are becoming more popular, and many people that had multiple screens previously are switching or thinking about switching to a single larger monitor. In such situations complex layout configurations like splitting a single monitor into two or more logical workspaces is a MUST.

That's exactly why I'm interested in this.

csicar avatar Apr 24 '20 22:04 csicar