Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rescreen runs on event hook when there (probably) is no relevant change to screen display configuration. #243

Open
1 of 2 tasks
thomasf opened this issue Nov 7, 2020 · 3 comments

Comments

@thomasf
Copy link

thomasf commented Nov 7, 2020

Problem Description

When I turn on my TV which is connected to multiple devices including my desktop computer XMonad runs 'rescreen' which causes some issues with layout being reset and panels being moved around. The layout issue is probably mostly because I use XMonad.Layout.LayoutScreens but the panels (a bunch of xmobar's) moving around I am not so sure about.
The root issue is that when the TV is turned on it's detected by X as a new display even if the TV itself is turned to a different channel where another computer is connected and X never adds the newly connected display to screen 0.

Configuration File

uncommenting this line in Main.hs seems to work for not :

-- configuration changes in the root may mean display settings have changed
-- handle (ConfigureEvent {ev_window = w}) = whenX (isRoot w) rescreen

Checklist

@liskin
Copy link
Member

liskin commented Nov 7, 2020

You can achieve the same thing by setting handleEventHook in your configuration to something like this:

noRescreenEventHook (ConfigureEvent {ev_window = w}) = do
    r <- asks theRoot
    return $ All $ w /= r
noRescreenEventHook _ = mempty

Whenever handleEventHook returns All False, xmonad's default hook doesn't get invoked.

But, and that's a big bold but, you shouldn't do this. When ConfigureEvent is being delivered to xmonad, it's already too late. By then, the screen layout has already been changed, and having xmonad ignore it will only make things worse. Something else in your system is reacting to the TV being connected and calling xrandr to change the layout, and you need to address that, not make xmonad ignore the changes that already happened.

@thomasf
Copy link
Author

thomasf commented Nov 7, 2020

Thanks for the info.. ignoring the event seems to work for me in practise though even if it isn't optimal.

The TV turns up as a disabled output when it's turned on so it should not affect layout. I also use a static xorg.conf setting for all scaling and resolutions so no auto setup for newly connected displays should happen.

Visualised by nvidia-settings:

tv on:

image

tv off:

image

xrandr (with TV on, only difference is that HDM-1 is connected or NC when TV is off):

$ xrandr
Screen 0: minimum 8 x 8, current 5520 x 2688, maximum 32767 x 32767
DVI-D-0 connected 1680x2688+3840+0 left (normal left inverted right x axis y axis) 474mm x 296mm
   1680x1050     59.95*+
   1280x1024     75.02    60.02
   1152x864      75.00
   1024x768      75.03    60.00
   800x600       75.00    60.32
   640x480       75.00    59.94
HDMI-0 disconnected (normal left inverted right x axis y axis)
HDMI-1 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +  59.94    50.00    29.97    25.00    23.98    60.05    60.00    50.04
   1360x768      60.02
   1280x1024     60.02
   1280x720      60.00    59.94    50.00
   1152x864      60.00
   1024x768      60.00
   800x600       60.32
   720x576       50.00
   720x480       59.94
   640x480       59.95    59.93    59.94
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 connected primary 3840x2160+0+264 (normal left inverted right x axis y axis) 609mm x 349mm
   3840x2160     60.00*+  29.98
   2560x1440     59.95
   2048x1280     59.96
   2048x1080     24.00
   1920x1200     59.88
   1920x1080     60.00    60.00    59.94    50.00    23.98
   1600x1200     60.00
   1600x900      60.00
   1280x1024     75.02    60.02
   1280x720      59.94    50.00
   1152x864      75.00
   1024x768      75.03    60.00
   800x600       75.00    60.32
   720x576       50.00
   720x480       59.94
   640x480       75.00    59.93    59.94
DP-3 disconnected (normal left inverted right x axis y axis)

@liskin
Copy link
Member

liskin commented Nov 7, 2020

Oh, I see. You're getting a ConfigureEvent without any real change in the screen layout, which resets the effect of X.L.LayoutScreens, and you don't actually need a proper rescreen to work as you're not connecting screens dynamically. Okay, in that case it's fine to ignore the ConfigureEvent like that.

And if we actually wanted to fix this in xmonad somehow, rather than making rescreen optional (well, it already kind of is as you can use the handleEventHook to ignore it) we could make rescreen check if the XineramaScreenInfo actually changed and only rescreen if it did. That would in fact be a very good idea as it would solve other problems as well. Like getting a bunch of ConfigureEvents in a row whenever xrandr is invoked, which used to mess stuff up for me and which I work around by clearing those duplicate events from the queue: https://github.com/liskin/dotfiles/blob/18dfd71861031cb9cbab7d69d931ae3433acac8a/.xmonad/xmonad.hs#L312

But I'm not sure if this warrants adding another field to the XState record. But we'd need to keep that state somewhere, and we can't use the WindowSet which can be modified by X.L.LayoutScreens...

@thomasf thomasf changed the title make rescreen on configuration changes in root optional. rescreen runs on event hook when there (probably) is no real change to screen display configuration. Nov 7, 2020
thomasf added a commit to thomasf/dotfiles-thomasf-xmonad that referenced this issue Nov 7, 2020
Just have to remember to rescreen manually when I actually need or want it to
happen.

ref: xmonad/xmonad#243
@thomasf thomasf changed the title rescreen runs on event hook when there (probably) is no real change to screen display configuration. rescreen runs on event hook when there (probably) is no relevant change to screen display configuration. Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants