Monitor settings take effect after Awesome load and don't refresh
Notice: If this is hard to understand, I can record a video with this issue, to better visualize it. I'm really bad at explaining, hence this wall of text. Sorry if it's confusing.
Output of awesome --version:
awesome v4.3 (Too long) • Compiled against Lua 5.3.6 (running with Lua 5.3) • D-Bus support: ✔ • execinfo support: ✔ • xcb-randr version: 1.6 • LGI version: 0.9.2
How to reproduce the issue:
Have your secondary monitor plugged first, primary second. Set your second plugged monitor to primary and first plugged monitor as secondary via xrandr (or Arandr) in the rc.lua config. Open two different windows, for example a terminal and browser, one on monitor 1, the other on monitor 2, and refresh Awesome. The opened windows should swap places, so the window from monitor 1 will move to monitor 2, and the window from monitor 2 will move to monitor 1. This only happens once, so if you refresh the WM again, nothing changes.
In other words, you have one monitor in front of you (this one is plugged in as the second monitor), and you have another one to your left or right side (this one is plugged in first), and you set the monitor in front of you to primary via xrandr command, and Awesome still considers the left monitor as primary, until you restart Awesome. Again, you can see this happening by opening two windows, one on each monitor, and restarting afterwards. Does only happen once after each boot, so once the monitor settings are updated, and you restart Awesome, restarting it again for the second time doesn't reproduce it - you have to reboot to Awesome.
Actual result:
Upon freshly launching Awesome (rebooting the system or just booting up), the first plugged screen, which is set to primary, but changed to secondary via xrandr command (which is launched in the config) is still considered primary. You have to refresh Awesome (mod + ctrl + r) to make it actually take your new monitor settings into consideration, and use the second plugged monitor as primary. Awesome does not update the stored information of which monitor is primary and which is secondary - it requires you to refresh it so that the new settings take effect for the purpose of the WM.
First plugged monitor is the primary monitor by default Linux settings. Awesomewm reads that and adjusts its settings to that, so even if your secondary monitor is set to primary, it still considers the now secondary monitor to be primary until you restart Awesome. This information is never updated, until you restart the WM. You can tell this is happening because once you freshly boot to Awesome, open any window on your second plugged monitor, which is set to primary via xrandr, and then restarting Awesome, all windows from primary monitor jump to secondary, and all from secondary jump to primary. The Awesome calendar also opens on the wrong monitor, but systray updates itself at all times.
I also verified that xrandr command works as intended. The command is taken from Arandr, and executed via a bash script. Removing that shows my secondary screen as primary and vice versa (basically in order how they're plugged in), and Awesome also behaves accordingly. After I set my screens, via Arandr or xrandr command, the systray does update, so jumps to my new primary screen, but calendar still opens on my new secondary screen (which was previously primary), so once I restart Awesome (again, via mod + ctrl + r), my windows from old secondary screen (now primary) and old primary screen (now secondary) swap places.
Expected result:
Upon launching Awesome, and changing the monitor settings from first = primary, second = secondary to first = secondary and second = primary via the config in .config/awesome/lua.rc, the WM should adjust itself to the newly set monitors. In the example above, when I freshly boot into Awesome, and open one window on each screen, and then restart Awesome, the windows should not swap places, and the calendar should always open on the primary screen, even if the primary screen is now a different monitor.
Make Awesome constantly read which monitor is set to primary, because right now it only reads it upon launching the WM, and doesn't update it till you restart Awesome.
Hello,
I only skim-read the issue, from what I get, it's about screen configuration that awesome doesn't handle as expected...
We had a big refactor of the screen handling. So maybe your issue is solved in the git version. Could you give it a try? @Elv13 can you confirm that?
Small update. I realized that Xrandr doesn't set the primary monitor properly. When I trigger Xrandr in .xinitrc to change my primary monitor, nothing happens, but when I do it in AwesomeWM, again, nothing happens, until I restart Awesome again. Same for terminal, so it's not tied to Awesome. The issue is only and only primary screen, everything else is set appropriately.
Might be also tied to Nvidia in some way.
just to clarify, with openbox - it happens exactly the same as with awesome wm?