Skip to content
New issue

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

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

Already on GitHub? # to your account

cmd line gets out of viewport when system display scaling is in use on Windows #427

Closed
karschdn opened this issue Jan 15, 2021 · 8 comments
Labels
bug Something isn't working Windows Issue applies to Microsoft Windows

Comments

@karschdn
Copy link

karschdn commented Jan 15, 2021

Describe the bug

After opening wezterm I get a cmd line. Then I start writing down commands. As soon as the cmd line runs out of the lower boundary of the window, the view does not scroll to the position to see it again.

Only after resizing the window it scrolls to the right position.

Very strange for me. Hopefully it is the same on your side. Wezterm fits to my visual requirements and I would love to use it. But it is not possible with this bug. I have no time to resize every cmd window after creating it :)

Environment:

  • OS: Windows 10 pro 1809
  • Version: wezterm 20201101-103216-403d002d-237-g42b95cd4

To Reproduce

  • download nightly build for windows (also reproducable with latest stable)
  • unpack zip
  • open unpacked folder in explorer
  • double click on "wezterm.exe"
  • press enter until to cmd line runs out of focus (do not resize window before)
  • as soon as you resize the window the view jumps to the last cmd line and everything is fine from now on

Configuration

Removing config does not help, but here it is...

return {
	window_background_image = "C:/media/desktop_16-9.jpg",
	initial_rows = 70,
	initial_cols = 300, 
	window_close_confirmation = "NeverPrompt",
	window_background_opacity = 0.7,
	window_background_image_hsb = {
	  brightness = 0.7,
  
	  -- You can adjust the hue by scaling its value.
	  -- a multiplier of 1.0 leaves the value unchanged.
	  hue = 1.0,
  
	  -- You can adjust the saturation also.
	  saturation = 1.0,
	}
	
  }

Expected behavior

When pressing enter, the view should scroll down to the last line (like it is done if I have resized the window one time)

Screenshots

image

@karschdn karschdn added the bug Something isn't working label Jan 15, 2021
@karschdn
Copy link
Author

Nobody else have this problem? http://www.southbaypc.com/autosizer/ helps here to force a resize but it is still ugly because it needs to be triggered.

@wez
Copy link
Member

wez commented Jan 17, 2021

Hmm, I'm not sure if we're capturing the repro steps because I don't see this behavior.
Here's what I'm trying:

  • Run wezterm.exe -n this starts wezterm with the default configuration, as though there was no local config
  • The gui starts and the window is sized so that exactly 24 rows * pixel height of the font are present in the client area
  • hitting enter ~24 times to make the text scroll always has the cursor on the bottom line, and there are no partial lines.

From your screenshot, there are at least 32 rows in your terminal, and the partial row at the bottom leads me to believe that the window has been resized.

If I make my window taller and deliberately size it so that there is a partial row at the bottom, I see a blank space like this:

image

Is there something about your setup or environment that wasn't captured in the issue description?

@karschdn
Copy link
Author

karschdn commented Jan 18, 2021

hmmm, i played around with my display settings. When putting the scaling to 100% the problem is not there. Due to hardware (native monitor resolution, display size, 4K, ... age of the person in front of the monitor :) ) I have to set it to 200% and then starting with -n looks like this and my problem occurs:

image

(ahm, after reviewing my screenshot I have to say that it looks too big :) I am not that handicaped :) )

@wez
Copy link
Member

wez commented Jan 18, 2021

age of the person in front of the monitor :)

Heh, I've recently started to hold books at arms length to read and my font sizes on screen have gone up a couple of points :-p
I've avoided 4K displays because I don't find that they have very much space once you've doubled the font sizes to be able to read anything again :)
I've found that I really love ultrawide monitors for the extra screen real estate. I'm not mentioning this as a pre-requisite for using wezterm so much as just a generally recommendation!

i have to set it to 200% and then it looks like this and my problem occurs:

Thanks; I'll look at this with a different system display scaling when I'm next in front of my windows computer! It sounds like wezterm may need to take that into account when it computes the effective dpi of the screen.

With that in mind, you may wish to try playing with configuring the dpi in your config explicitly as a workaround. I would guess that you either need to set it to half or double the default value of 96.0. I'm guessing half is probably right to compensate for the whole screen scaling:

return {
   dpi = 48.0, -- or 192.0
}

You may then need to increase the font_size to get to your preferred readable size.

(ahm, after reviewing my screenshot I have to say that it looks to big :) I am not that handicaped :) )

No judgements here: you need to look after your eyes!

@wez wez added the Windows Issue applies to Microsoft Windows label Jan 18, 2021
@wez wez changed the title cmd line gets out of viewport cmd line gets out of viewport when system display scaling is in use on Windows Jan 18, 2021
@karschdn
Copy link
Author

karschdn commented Jan 18, 2021

Thanks for your hints !

192 dpi does the job for me. Even without font size changes. So, fix could be something like newdpi=default dpi * windows scaling. (I am only guessing :) )

return {
   dpi = 192.0
}

( sounds like the difference of our ages is not that high :) )

wez added a commit that referenced this issue Jan 18, 2021
The heart of this issue was that the resize callbacks have two
layers of state; one in the low level window and one in the application
level window.

On Windows, the system triggers the low level callback prior to
opengl being initialized.  Since the application level depends on
the opengl state, there are some code paths where it NOPs and
returns early if opengl isn't yet initialized.

When the system-wide display scaling is set to say 200%, the application
layer can't know the effective DPI of the window it is creating because
it doesn't know which monitor will be used or what its DPI will be.

New windows are created at the default DPI of 96, and we rely on the
resize events to detect the actual DPI and adjust the scaling in
the window.

The early call of the resize callback meant that the low level and
application level size/dpi state was out of sync and the result was
that the window had half as many pixels as it should, but that the
terminal model was still sized as though it had the correct amount
(twice as many as visible).  This resulted in the window being too
small for the viewport.

The resolution is simple: we now suppress emitting the resize processing
until opengl has been initialized.

The test scenario for this is:

* Set system scaling to 100%
* Launch wezterm
* Set system scaling to 200%
* Observe that wezterm scales to match
* Press CTRL-SHIFT-N to spawn a new window
* Observe that the new window size matches the other window (previously
  this one would be half the size)

While I was looking at this, I noticed that the manifest didn't
match the DPI awareness that we have in the code, so update that.

refs: #427
@wez
Copy link
Member

wez commented Jan 18, 2021

Thanks for playing with the dpi and confirming that theory!

I've pushed a commit that resolves this; it should show up in the nightly builds within an hour or two. If you're interested in the gory details and the simple fix, you can read the commit message: aee3778

Once you're on that build, you can (and should, especially if you have multiple monitors with varying dpi!) remove the dpi setting from your config.

@karschdn
Copy link
Author

Nightly build works for me! Thank you very much for fixing it!

Well managed product (docu, change process, response time, ... )

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working Windows Issue applies to Microsoft Windows
Projects
None yet
Development

No branches or pull requests

2 participants