Repository: wezterm/wezterm (language: rust)

Issue:
Changing window size decreases dpi on linux hdpi monitor when overriding the dpi in the config
### What Operating System(s) are you seeing this problem on?

Linux X11

### Which Wayland compositor or X11 Window manager(s) are you using?

XFCE4

### WezTerm version

wezterm 20221119-145034-49b9839f

### Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

### Describe the bug

My host machine is macOS(Retina 5K). I have a ArchLinux XFCE4 vm running and I also use wezterm on my linux machine. Here is my config file:
```
$ cat .wezterm.lua 
local wezterm = require 'wezterm';

return {
  font = wezterm.font("Fira Code"),
  color_scheme = "Builtin Solarized Dark",
  dpi = 144.0,
  window_background_opacity = 0.90,
}
```

When I launch wezterm (from any where) its scaling is OK. But when I change the size of the wezterm window it decreases like I did not set `dpi` value. Here is a picture

![wez-ss](https://user-images.githubusercontent.com/10853207/210351359-e24cc39c-a426-48fb-99a4-e093c8e012c8.png)

Look at the picture the big in size is the one when I first run wezterm. The smaller one is the one which I resized window.

### To Reproduce

While using an HDPI screen Install Archlinux with XFCE4. Install latest wezterm. Set the wezterm config to the values I have shared above. Then change window size.

### Configuration

```
$ cat .wezterm.lua 
local wezterm = require 'wezterm';

return {
  font = wezterm.font("Fira Code"),
  color_scheme = "Builtin Solarized Dark",
  dpi = 144.0,
  window_background_opacity = 0.90,
}
```

### Expected Behavior

After setting `dpi` value to 144, the window and fonts should stay as the same size when I change size of window.

### Logs

$ WEZTERM_LOG=wezterm_gui::termwindow=trace,wezterm_gui::termwindow::render=info,info wezterm > wez.log
12:28:38.564  TRACE  wezterm_gui::termwindow > using render_metrics RenderMetrics {
    descender: -7.0,
    descender_row: 24,
    descender_plus_two: 26,
    underline_height: 1,
    strike_row: 12,
    cell_size: 14x29,
}
12:28:38.570  TRACE  wezterm_gui::termwindow > Initial geometry was TerminalSize { rows: 24, cols: 80, pixel_width: 640, pixel_height: 384, dpi: 144 } but dpi-adjusted geometry is TerminalSize { rows: 24, cols: 80, pixel_width: 1120, pixel_height: 696, dpi: 144 }; update the kernel pixel geometry for the ptys!
12:28:38.570  TRACE  wezterm_gui::termwindow > TermWindow::new_window called with mux_window_id 0 TerminalSize { rows: 24, cols: 80, pixel_width: 1120, pixel_height: 696, dpi: 144 } Dimensions { pixel_width: 1148, pixel_height: 774, dpi: 144 }
12:28:38.571  TRACE  wezterm_gui::termwindow > RequestedWindowGeometry { width: Pixels(1148.0), height: Pixels(774.0), x: None, y: None, origin: ScreenCoordinateSystem }
12:28:38.584  DEBUG  wezterm_gui::termwindow > FocusChanged(true)
12:28:38.584  TRACE  wezterm_gui::termwindow > Setting focus to true
12:28:38.658  DEBUG  wezterm_gui::termwindow > KeyEvent(KeyEvent { key: Char('\r'), modifiers: NONE, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(Return), modifiers: NONE, phys_code: Some(Return), raw_code: 36, repeat_count: 1, key_is_down: false, handled: Handled(false) }) })
12:28:38.658  TRACE  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('\r'), modifiers: NONE, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(Return), modifiers: NONE, phys_code: Some(Return), raw_code: 36, repeat_count: 1, key_is_down: false, handled: Handled(false) }) } 
12:28:38.669  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:38.669  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.707  DEBUG  wezterm_gui::termwindow           > OpenGL initialized! virgl (AMD Radeon Pro 5500 XT OpenGL Engine (Compat)) 4.0 (Compatibility Profile) Mesa 22.3.1 wezterm version: 20221119-145034-49b9839f
12:28:38.707  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.708  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.709  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.709  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.709  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.709  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.709  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.712  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.712  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.712  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.713  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.713  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.724  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.724  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.724  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.724  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.724  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:38.808  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.808  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.808  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:38.825  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:39.585  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:39.585  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:39.585  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.461  DEBUG  wezterm_gui::termwindow           > RawKeyEvent(RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) })
12:28:40.461  TRACE  wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) } 
12:28:40.461  DEBUG  wezterm_gui::termwindow           > KeyEvent(KeyEvent { key: Alt, modifiers: NONE, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
12:28:40.461  TRACE  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Alt, modifiers: NONE, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: NONE, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: true, handled: Handled(false) }) } 
12:28:40.469  DEBUG  wezterm_gui::termwindow           > RawKeyEvent(RawKeyEvent { key: Physical(LeftControl), modifiers: ALT, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) })
12:28:40.469  TRACE  wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: ALT, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) } 
12:28:40.469  DEBUG  wezterm_gui::termwindow           > KeyEvent(KeyEvent { key: Control, modifiers: ALT, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: ALT, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) })
12:28:40.469  TRACE  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Control, modifiers: ALT, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: ALT, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: true, handled: Handled(false) }) } 
12:28:40.469  DEBUG  wezterm_gui::termwindow           > FocusChanged(false)
12:28:40.469  TRACE  wezterm_gui::termwindow           > Setting focus to false
12:28:40.469  DEBUG  wezterm_gui::termwindow           > MouseLeave
12:28:40.471  DEBUG  wezterm_gui::termwindow           > Resized { dimensions: Dimensions { pixel_width: 2552, pixel_height: 1347, dpi: 96 }, window_state: (empty), live_resizing: true }
12:28:40.471  TRACE  wezterm_gui::termwindow::resize   > resize event, live=true current cells: RowsAndCols { rows: 24, cols: 80 }, current dims: Dimensions { pixel_width: 1148, pixel_height: 774, dpi: 144 }, new dims: Dimensions { pixel_width: 2552, pixel_height: 1347, dpi: 96 } window_state:(empty)
12:28:40.471  TRACE  wezterm_gui::termwindow::resize   > dpi_changed=true, font_scale_changed=false scale_changed=true simple_dpi_change=false
12:28:40.479  TRACE  wezterm_gui::termwindow::resize   > scaling_changed, follow with applying dimensions. scale_changed_cells=None
12:28:40.479  TRACE  wezterm_gui::termwindow::resize   > apply_dimensions Dimensions { pixel_width: 2552, pixel_height: 1347, dpi: 96 } scale_changed_cells None. window_state (empty)
12:28:40.484  TRACE  wezterm_gui::termwindow::resize   > apply_dimensions computed size TerminalSize { rows: 64, cols: 253, pixel_width: 2530, pixel_height: 1280, dpi: 96 }, dims Dimensions { pixel_width: 2552, pixel_height: 1347, dpi: 96 }
12:28:40.485  DEBUG  wezterm_gui::termwindow           > FocusChanged(true)
12:28:40.485  TRACE  wezterm_gui::termwindow           > Setting focus to true
12:28:40.485  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:40.495  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.495  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.510  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.512  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:40.526  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:41.001  DEBUG  wezterm_gui::termwindow           > KeyEvent(KeyEvent { key: Control, modifiers: ALT | CTRL, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: ALT | CTRL, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: false, handled: Handled(false) }) })
12:28:41.001  TRACE  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Control, modifiers: ALT | CTRL, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: ALT | CTRL, phys_code: Some(LeftControl), raw_code: 37, repeat_count: 1, key_is_down: false, handled: Handled(false) }) } 
12:28:41.016  DEBUG  wezterm_gui::termwindow           > KeyEvent(KeyEvent { key: Alt, modifiers: ALT, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: false, handled: Handled(false) }) })
12:28:41.016  TRACE  wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Alt, modifiers: ALT, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftAlt), modifiers: ALT, phys_code: Some(LeftAlt), raw_code: 64, repeat_count: 1, key_is_down: false, handled: Handled(false) }) } 
12:28:41.470  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.470  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.470  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.768  DEBUG  wezterm_gui::termwindow           > FocusChanged(false)
12:28:41.769  TRACE  wezterm_gui::termwindow           > Setting focus to false
12:28:41.769  DEBUG  wezterm_gui::termwindow           > NeedRepaint
12:28:41.770  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.770  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.770  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:41.770  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:42.769  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:42.769  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })
12:28:42.769  DEBUG  wezterm_gui::termwindow           > Notification(Any { .. })


### Anything else?

_No response_


Discussion / hints:
I can confirm this on Ubuntu 22.10 using wayland

Fix patch:
diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rs
index 6142facc3e1..c9c40266c23 100644
--- a/wezterm-gui/src/termwindow/resize.rs
+++ b/wezterm-gui/src/termwindow/resize.rs
@@ -1,6 +1,6 @@
 use crate::utilsprites::RenderMetrics;
 use ::window::{Dimensions, Window, WindowOps, WindowState};
-use config::{ConfigHandle, DimensionContext};
+use config::{configuration, ConfigHandle, DimensionContext};
 use mux::Mux;
 use std::rc::Rc;
 use wezterm_font::FontConfiguration;
@@ -15,11 +15,15 @@ pub struct RowsAndCols {
 impl super::TermWindow {
     pub fn resize(
         &mut self,
-        dimensions: Dimensions,
+        mut dimensions: Dimensions,
         window_state: WindowState,
         window: &Window,
         live_resizing: bool,
     ) {
+        // ignore dpi changes if there is a fixed dpi set in configuration
+        if let Some(dpi) = configuration().dpi {
+            dimensions.dpi = dpi as usize;
+        }
         log::trace!(
             "resize event, live={} current cells: {:?}, current dims: {:?}, new dims: {:?} window_state:{:?}",
             live_resizing,


Test patch: