lxqt / lxqt-panel

The LXQt desktop panel
https://lxqt-project.org
GNU Lesser General Public License v2.1
185 stars 135 forks source link

Optionally, don't move panel to existing screen(s) when removing its screen? #1622

Open DarNCelsius opened 3 years ago

DarNCelsius commented 3 years ago

Panels seem to be multi-monitor aware only if those monitors are actually turned on.

Expected Behavior

I'd expect panels configured to be on displays that are turned off to be hidden.

Current Behavior

If I configure a panel to be on desktop 2 (my TV in this case), and then turn the TV off, the panel configured for it is moved in front of my default panel on my primary monitor.

Possible Solution

At the moment, the only desktops I can configure in the panel settings are ones that are turned on. The panel configured for desktop 2 doesn't even have a position configured if the TV is turned off. It might be useful if the panel config retained the 'desktop=X' setting, and hid the panel accordingly when the desktop can't be found. Here's the saved display setup: monitors

System Information
tsujan commented 3 years ago

When you remove a screen, the app has no way of "knowing" what you will do later. It adjusts itself to the available screen(s).

DarNCelsius commented 3 years ago

That's what I meant - it should adjust itself by hiding/deactivating panels, not moving them. It works like I described in Cinnamon and XFCE. It could be worked out in conjunction with lxqt-config-monitor/xrandr I imagine.

If you won't even look into it though, I'll hack around it with autorandr and disable lxqt-config-monitor.

tsujan commented 3 years ago

You add a screen and then you remove it because you don't like its position. And you may repeat that several times. It's totally impractical to leave hidden panels in that way.

DarNCelsius commented 3 years ago

I'm not sure you understand? What I'm saying is that panels configured for the bottom of desktop 2 is being moved to the bottom of desktop 1 when desktop 2 is not there. As soon as desktop 2 is there again, the panel goes where it should. It's only when the desktop is gone that the panel should also be gone if you know what I mean. Right now I'm getting two panels on top of each other when only one monitor is on.

It might be better if the panel config knew about the different monitors on the system. AFAICS desktop 1 and 2 in lxqt-panel correspond to Primary/DisplayPort-0 and HDMI-A-0 respectively.

This is how xfce4-panel handles it: monitors2monitors3

In short, if the panel is configured to show on desktop 2, it should not show on desktop 1.

tsujan commented 3 years ago

xfce is free to use any X11 code but, not depending on X11 and being agnostic toward WMs, lxqt-panel can only be aware of screens (their addition/removal/change).

DarNCelsius commented 3 years ago

That's all you really need. The panel configuration picks up desktops fine when they are on, so it should be just as easy to detect when they are not.

When the TV is on, I have a choice of "desktop 1" and "desktop 2". When it is off, I have only "desktop". So if a panel has "bottom of desktop 2" configured, but "desktop 2" does not exist at that point, simply deactivate it. Similarly, if "desktop 2" gets turned on at some point, activate it.

I hope you understand what I mean. English is not my first language. :)

tsujan commented 3 years ago

I think I've understood your point. IMO, https://github.com/lxqt/lxqt-panel/issues/1622#issuecomment-846912892 is still pertinent. Suppose I have 3 monitors and put multiple panels on their corresponding screens. Then I decide to use only my main monitor. I don't know how xfce handles it; several "dead" panels? That doesn't seem practical.

DarNCelsius commented 3 years ago

I don't really know how they do it in code. You could simply not create the panels that don't belong to an active desktop? Similarly create them when the desktop becomes active again. Saves memory and prevents the primary desktop having panels moved over from the other two inactive ones.

tsujan commented 3 years ago

As you see, a closed report isn't the end of discussion. All developers have received email notifications and they could re-open the report if they have a working idea.

To me, having "dead" panels is a bad idea but, if other devs have a different opinion that they can implement, I'll accept it.

DarNCelsius commented 3 years ago

Well, they are only as "dead" as the monitor they belong to. ;)

Having the option for a panel to be on all desktops would also work for my use case here.

tsujan commented 3 years ago

Well, they are only as "dead" as the monitor they belong to. ;)

It's not that simple. A dead panel may contain a single-instance widget like Status Notifier. When it's dead, the user may add it to an existing panel (because he needs it). Then, if the dead panel is made "alive", complications will arise. A config file with dead entries is also another problem. Most probably, there are more issues...

DarNCelsius commented 3 years ago

Yes, I know that could present a problem. For me it doesn't - I only have the single-instances on my primary monitor.

I realize it's not as trivial as I make it sound, but checks could be made in code to ensure these things work well together. Maybe a priority system where items on the Primary monitor/desktop 0 gets priority over the others.

tsujan commented 3 years ago

For me it doesn't...

Codes aren't written in that way. If they were, they would be buggy.

DarNCelsius commented 3 years ago

Yes of course - I was only saying what was my specific case. I do know a little about programming so I realize you have to account for all possible combinations. :)

DarNCelsius commented 3 years ago

This output is produced by running lxqt-panel with different config files from the command line.

This is with only the primary monitor connected:

WinIdChange 1c00007 handle QWidgetWindow(0x55912e4ddf70, name="LXQtPanel panel1Window") QScreen(0x55912da9b520, name="DisplayPort-0")
WinIdChange 1c0000e handle QWidgetWindow(0x55912e956ab0, name="LXQtPanel panel_{ce913b44-10f2-45b9-b2ca-e239cdd371d8}Window") QScreen(0x55912da9b520, name="DisplayPort-0")

This is with both connected:

WinIdChange 3a00007 handle QWidgetWindow(0x559a7aee47f0, name="LXQtPanel panel1Window") QScreen(0x559a7a49db40, name="DisplayPort-0")
StatusNotifier: registration of service org.kde.StatusNotifierWatcher queued, we can become primary after existing one deregisters
WinIdChange 3a0000e handle QWidgetWindow(0x559a7b35f690, name="LXQtPanel panel_{ce913b44-10f2-45b9-b2ca-e239cdd371d8}Window") QScreen(0x559a7a49db40, name="DisplayPort-0")
WinIdChange 3a00010 handle QWidgetWindow(0x559a7ba279d0, name="LXQtPanel panel_{4540730b-c492-443a-818e-41860bf0e34f}Window") QScreen(0x559a7a49dc30, name="HDMI-A-0")

There seems to be readily available access to monitor names already. There also already seems to be a priority queue going on for single instances.

elviosak commented 3 years ago

the panel configured for it is moved in front of my default panel on my primary monitor.

We could solve this by lowering panels that are not on their configured screen so they will stay "behind" the correct ones. @tsujan what do u think? I don't think hiding or removing panels is a good idea, it could leave users without any panel and no way to create one (if u run it, the panel will just be hidden/removed again)

tsujan commented 3 years ago

We could solve this by lowering panels that are not on their configured screen so they will stay "behind" the correct ones.

There's no way to know which panel is more important. So, I don't think lowering panels is a good thing to do.

I don't think hiding or removing panels is a good idea

I agree completely.

EDIT: Lowering has another drawback too: panels can have translucent backgrounds and/or be auto-hiding.

elviosak commented 3 years ago

There's no way to know which panel is more important. So, I don't think lowering panels is a good thing to do.

I think assuming the one configured for the screen is a decent choice, the current behavior is also not bad, but i think the first one would be better.

EDIT: Lowering has another drawback too: panels can have translucent backgrounds and/or be auto-hiding.

Is this different with the current behavior? Lowering would just reorder them so i expect the rest would stay the same.

tsujan commented 3 years ago

IMO, lowering would do nothing at best — just more code. No panel is more important than another; it depends on how the user arranges them.

If a panel disappeared just because its screen disappeared, we would have a bug to fix. We don't have that bug. Honestly, I see this report as a too personal use case. If one wants to remove a monitor, they could put its panel where it could be used after the removal.

elviosak commented 3 years ago

It would be a very minimal change, it should be enough to add lower(); to this if block: https://github.com/lxqt/lxqt-panel/blob/master/panel/lxqtpanel.cpp#L395 I just tried here and it works as expected

But it depends if some other people agree that the panel that is on its configured position/screen is more important than the relocated one.

DarNCelsius commented 3 years ago

Thanks for looking into it. :)

I don't think lowering would be a solution. Panels of different sizes might still be visible, which is indeed the case for me: lxqtpaneloverlap You can see my main panel behind the "desktop 2" one there.

I was thinking something like this: lxqtpanelopts Where you have an option to have the panel follow the display and close/open as that display goes offline/online.

Looking through the source code, it seems to be easy to check the option setting, the availability of the display, and then call/not call LXQtPanelApplication::addPanel(). This way, the default (unchecked) is the current behavior, and the new (checked) behavior is to respect the "desktop" setting.

tsujan commented 3 years ago

Reopened for contributors to find it more easily. A correct implementation (1) should be optional (with the current behavior as the default) and (2) should not hide an existing panel (= waste of resources) but remove and create it when needed.

jonesmz commented 3 years ago

I have a similar need.

I have a two multi-monitor computers, one is Linux with LXQT. The other is Windows, owned by my employer.

These two computers are connected to the same monitors with a multi-monitor KVM switch.

Any time I switch from Linux/LXQT to Windows, the KVM switch disconnects the monitors from the computer, and connects them to the other computer. LXQT detects this and re-arranges everything, much to my annoyance.

I switch the KVM back and forth many times during a typical work-day, and at this point have simply accepted that LXQT is going to put my panel on the wrong screen.

If I could tell LXQT one of:

1) Same panel across multiple screens or 2) If the screen a panel is assigned to disappears, leave it hidden

that would remove this annoyance.