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

Window is resized after Mac sleeps when connected to external monitor #4633

Open
ryanmsnyder opened this issue Dec 1, 2023 · 8 comments
Open
Labels
bug Something isn't working

Comments

@ryanmsnyder
Copy link

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20231201-121352-6d58e519

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When my M1 MBP is connected to my 4K external display and is in clamshell mode, if it goes to sleep and is awakened, wezterm windows get smaller (mostly the height but the width also changes a little). I've only been able to reproduce this when my macOS Display settings are scaled. When selecting 3840 x 2160 as the resolution, the wezterm window is not resized after the Mac sleeps and wakes.

To Reproduce

  1. Attach MacBook to external monitor in clamshell
  2. In macOS System Settings > Displays, change the resolution to a scaled resolution (my monitor is 4K but selecting 3840 x 2160 makes application/text way too small so I prefer 2560 x 1440):
image 3. Maximize wezterm window (but not in macOS full screen mode): image
  1. Put Mac to sleep

  2. Wake Mac

  3. The Wezterm window is now much smaller in height (the width changed a little as well):

image

Configuration

The issue also occurs with no config (wezterm -n)

Expected Behavior

The wezterm windows should remain the same size after waking the Mac.

Logs

After executing WEZTERM_LOG=wezterm_gui::termwindow=trace,wezterm_gui::termwindow::render=info,info wezterm start --always-new-process, I put my MBP to sleep/locked the screen. These are the logs once the MBP was awakened/unlocked:

16:02:27.217  DEBUG  wezterm_gui::termwindow             > Resized { dimensions: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 }, window_state: (empty), live_resizing: true }
16:02:27.219  TRACE  wezterm_gui::termwindow::resize     > resize event, live=true current cells: RowsAndCols { rows: 24, cols: 80 }, current dims: Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 }, new dims: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 } window_state:(empty)
16:02:27.219  TRACE  wezterm_gui::termwindow::resize     > dpi_changed=true, font_scale_changed=false scale_changed=true simple_dpi_change=true
16:02:27.222  TRACE  wezterm_gui::termwindow::resize     > scaling_changed, follow with applying dimensions. scale_changed_cells=Some(RowsAndCols { rows: 24, cols: 80 })
16:02:27.222  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 } scale_changed_cells Some(RowsAndCols { rows: 24, cols: 80 }). window_state (empty)
16:02:27.230  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions computed size TerminalSize { rows: 24, cols: 80, pixel_width: 640, pixel_height: 408, dpi: 72 }, dims Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 }
16:02:27.232  TRACE  wezterm_gui::termwindow::resize     > scale changed so resize from Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 } to Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 } RowsAndCols { rows: 24, cols: 80 } (event called with Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 })
16:02:27.233  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:27.236  DEBUG  wezterm_gui::termwindow             > Resized { dimensions: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 }, window_state: (empty), live_resizing: false }
16:02:27.236  TRACE  wezterm_gui::termwindow::resize     > resize event, live=false current cells: RowsAndCols { rows: 24, cols: 80 }, current dims: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 }, new dims: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 } window_state:(empty)
16:02:27.244  TRACE  wezterm_gui::termwindow::resize     > dimensions didn't change NOP!
16:02:27.397  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:27.397  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:27.398  DEBUG  wezterm_gui::termwindow             > NeedRepaint
16:02:27.581  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:28.233  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:28.233  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:28.234  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.441  DEBUG  wezterm_gui::termwindow             > Resized { dimensions: Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 }, window_state: (empty), live_resizing: true }
16:02:32.441  TRACE  wezterm_gui::termwindow::resize     > resize event, live=true current cells: RowsAndCols { rows: 24, cols: 80 }, current dims: Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 }, new dims: Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 } window_state:(empty)
16:02:32.441  TRACE  wezterm_gui::termwindow::resize     > dpi_changed=true, font_scale_changed=false scale_changed=true simple_dpi_change=true
16:02:32.462  TRACE  wezterm_gui::termwindow::resize     > scaling_changed, follow with applying dimensions. scale_changed_cells=Some(RowsAndCols { rows: 24, cols: 80 })
16:02:32.462  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 } scale_changed_cells Some(RowsAndCols { rows: 24, cols: 80 }). window_state (empty)
16:02:32.558  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions computed size TerminalSize { rows: 24, cols: 80, pixel_width: 1360, pixel_height: 816, dpi: 144 }, dims Dimensions { pixel_width: 1365, pixel_height: 816, dpi: 144 }
16:02:32.560  TRACE  wezterm_gui::termwindow::resize     > scale changed so resize from Dimensions { pixel_width: 645, pixel_height: 408, dpi: 72 } to Dimensions { pixel_width: 1365, pixel_height: 816, dpi: 144 } RowsAndCols { rows: 24, cols: 80 } (event called with Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 })
16:02:32.561  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.563  DEBUG  wezterm_gui::termwindow             > Resized { dimensions: Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 }, window_state: (empty), live_resizing: false }
16:02:32.563  TRACE  wezterm_gui::termwindow::resize     > resize event, live=false current cells: RowsAndCols { rows: 24, cols: 80 }, current dims: Dimensions { pixel_width: 1365, pixel_height: 816, dpi: 144 }, new dims: Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 } window_state:(empty)
16:02:32.563  TRACE  wezterm_gui::termwindow::resize     > dpi_changed=false, font_scale_changed=false scale_changed=false simple_dpi_change=false
16:02:32.585  TRACE  wezterm_gui::termwindow::resize     > scaling_changed, follow with applying dimensions. scale_changed_cells=None
16:02:32.585  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 } scale_changed_cells None. window_state (empty)
16:02:32.585  TRACE  wezterm_gui::termwindow::resize     > apply_dimensions computed size TerminalSize { rows: 24, cols: 80, pixel_width: 1360, pixel_height: 816, dpi: 144 }, dims Dimensions { pixel_width: 1366, pixel_height: 816, dpi: 144 }
16:02:32.630  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.631  DEBUG  wezterm_gui::termwindow             > NeedRepaint
16:02:32.644  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.645  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.646  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.646  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.646  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:32.646  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:33.565  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:33.566  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })
16:02:33.568  DEBUG  wezterm_gui::termwindow             > Notification(Any { .. })

Debug Overlay:

Debug Overlay
wezterm version: 20231201-121352-6d58e519 aarch64-apple-darwin
Window Environment: macOS 13.6.1 (22G313)
OpenGL: Apple M1 Pro 4.1 Metal - 83.1
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
> wezterm.gui.screens()
{
    "active": {
        "effective_dpi": 144,
        "height": 2880,
        "max_fps": 60,
        "name": "DELL U2720Q",
        "scale": 2,
        "width": 5120,
        "x": 0,
        "y": 0,
    },
    "by_name": {
        "DELL U2720Q": {
            "effective_dpi": 144,
            "height": 2880,
            "max_fps": 60,
            "name": "DELL U2720Q",
            "scale": 2,
            "width": 5120,
            "x": 0,
            "y": 0,
        },
    },
    "main": {
        "effective_dpi": 144,
        "height": 2880,
        "max_fps": 60,
        "name": "DELL U2720Q",
        "scale": 2,
        "width": 5120,
        "x": 0,
        "y": 0,
    },
    "origin_x": 0,
    "origin_y": 0,
    "virtual_height": 2880,
    "virtual_width": 5120,
}

Anything else?

I looked at many other issues that were possibly similar but this problem seemed to be different. Here are those issues:

I also tried to reproduce the issue with other applications including other terminals but all of them kept their window size after sleep/wake.

@ryanmsnyder ryanmsnyder added the bug Something isn't working label Dec 1, 2023
@mragab
Copy link

mragab commented Dec 17, 2023

I have the same issue with an M1 MBP and an external monitor; when coming back from sleep, the window height of Wezterm is shrunk every time.

• I have the external monitor set as the main display at a resolution of 3440 x 1440, and the MBP display mirrors the external display.

• Note: I also have the same issue with Alacritty; aside from that, I haven't seen this with any other applications.

@kronning6
Copy link

I've been experiencing this same issue. My window after waking from sleep looks just like the screenshots of the issue poster. I recently switched from Alacritty to WezTerm hoping the issue was just with Alacritty, but the issue is exactly the same. I've spent some time troubleshooting and have determined that this issue isn't present in iTerm. It also exists whether my window manager app Rectangle.app is running or not. Please let me know if there's more info I can provide.

Alternatively I'm wondering if there could be a workaround to add an event for when the machine wakes from sleep.

Environment:

  • 2021 16 inch MacBook Pro with M1 Pro in clamshell mode
  • 2016 LG UltraFine monitor (WezTerm is full sized on this monitor)
  • 2022 LG DualUp monitor
  • zsh, tmux,neovim

@gilmarsquinelato
Copy link

I'm having the same issue, and to reproduce it I have the external display set as extended, and use both the MacBook display and the external one simultaneously. Then I lock my Mac (Cmd+Ctrl+Q), then press Esc to turn off the screen, after this, I wait until my external display shows that the input was lost and turned off.
Once this happens you can login back and the issue will happen.

I tested the kitty terminal and this issue doesn't happen.
Could it be some mac config in the app or a code that recognizes this kind of behaviour?

@twils0
Copy link

twils0 commented Sep 10, 2024

To keep this issue alive, I'll add simply: I'm having this issue as well.

@vnovichek
Copy link

Same here

@snobb
Copy link

snobb commented Oct 19, 2024

Had to switch to kitty because of this.

Also albeit out of scope but font rendering is really hard to get right in wezterm. More nobs to turn comparing to Kitty but much harder to get it right. Kitty is bearable with the default settings.

@twils0
Copy link

twils0 commented Oct 28, 2024

I can confirm. Alacritty has this same issue.

@andreiz
Copy link

andreiz commented Oct 31, 2024

Same issue, M1 Max Studio with external monitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants