polybar-dwm/src
Vincent Bernat 151a263654
fix(monitor): do not include outputs when monitors are supported (#2485)
* fix(monitor): do not include outputs when monitors are supported

Previously, when splitting an output into two monitors, `polybar -m`
would report both the splitted monitors and the output. This was not
caught by the the clone detection as the detection works by removing
monitors contained into another monitors (and monitors were excluded
from that logic) and we want the other way around: outputs covered by
monitors should be ignored.

Instead of trying to detect covered outputs, the solution is quite
simple: when monitors are supported, do not consider outputs, unless
we request all outputs. A monitor can be set primary (and RandR
reports primary outputs as primary monitors). The only information we
would miss from monitors are things like refresh rate and EDID. We
don't need that, so we are fine.

As monitors are only created for connected output (and they are in
this case "active") or disconnected output if they are mapped (and
they are in this case "inactive"), I am a bit unsure if we have
exactly the same behaviour as previously when `connected_only` is set
to `false`.

As some modules require an output, we keep the output in the
`monitor_t` structure and we ensure it is correctly set when using
monitors. A monitor can have 0 or several outputs. We only handle the
0 and 1 cases. When a monitor has more outputs, only the first one is
used. AFAIK, only the xbacklight module needs that and I think we are
fine waiting for a user needing this module and merging monitors.

The C++ binding fail to expose the `outputs()` method to iterate over
the outputs of a monitor. This seems to be a bug in XPP. The field is
correctly defined in the RandR XML file and it works with the Python
binding.

```xml
	<struct name="MonitorInfo">
		<field type="ATOM" name="name" />
		<field type="BOOL" name="primary" />
		<field type="BOOL" name="automatic" />
		<field type="CARD16" name="nOutput" />
		<field type="INT16" name="x" />
		<field type="INT16" name="y" />
		<field type="CARD16" name="width" /> <!-- pixels -->
		<field type="CARD16" name="height" /> <!-- pixels -->
		<field type="CARD32" name="width_in_millimeters" />
		<field type="CARD32" name="height_in_millimeters" />
		<list type="OUTPUT" name="outputs">
		    <fieldref>nOutput</fieldref>
		</list>
	</struct>
```

Falling back to C only to access the list of outputs is not enough
because the list is appended to the structure and not visible through
the public API. When copied, the structure loses the list of monitors.

Also, change the mention "XRandR monitor" to "no output" when there is
no output attached. People using monitors know what it means and it is
useful to catch a future regression where we don't have an output at
all (which would break the brightness plugin).

Fix #2481

* Update CHANGELOG.md

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-09-02 18:07:21 +02:00
..
adapters Remove undefined behaviors and clean code (#1769) 2021-02-15 23:32:56 +01:00
cairo
components Universal Visibility Action (#2320 cont'd) (#2426) 2021-07-07 21:43:49 +02:00
drawtypes
events
modules feat(ipc): allow receiving arbitrary text on IPC socket (#2463) 2021-07-11 20:42:28 +02:00
tags Cleanup 2021-02-12 20:01:22 +01:00
utils fix(color): Rename type() function to get_type 2021-03-01 00:05:44 +01:00
x11 fix(monitor): do not include outputs when monitors are supported (#2485) 2021-09-02 18:07:21 +02:00
CMakeLists.txt Use CMAKE_EXE_LINKER_FLAGS 2021-07-11 14:47:26 +02:00
ipc.cpp refactor(cmake): Allow targets to be enabled individually 2020-12-24 02:20:38 +01:00
main.cpp fix(monitor): do not include outputs when monitors are supported (#2485) 2021-09-02 18:07:21 +02:00
settings.cpp.cmake cmake: Stop using CMAKE_* variables for flags 2021-07-11 14:47:26 +02:00