1
1
mirror of https://github.com/wez/wezterm.git synced 2024-10-04 10:17:40 +03:00

adjust_window_size_when_changing_font_size now considers tiling WMs

It's a little limited in the scope of its detection: we have a built-in
list of tiling WM environments and if the current one is on the list
then we set an appropriate value for this option.

The list currently has just a single entry.
This commit is contained in:
Wez Furlong 2023-04-17 21:58:08 -07:00
parent 51c8a20465
commit 87cd9c5f6c
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
6 changed files with 75 additions and 5 deletions

View File

@ -688,8 +688,11 @@ pub struct Config {
#[dynamic(default = "default_enq_answerback")]
pub enq_answerback: String,
#[dynamic(default = "default_true")]
pub adjust_window_size_when_changing_font_size: bool,
#[dynamic(default)]
pub adjust_window_size_when_changing_font_size: Option<bool>,
#[dynamic(default = "default_tiling_desktop_environments")]
pub tiling_desktop_environments: Vec<String>,
#[dynamic(default)]
pub use_resize_increments: bool,
@ -1673,6 +1676,10 @@ fn default_max_fps() -> u8 {
60
}
fn default_tiling_desktop_environments() -> Vec<String> {
["X11 bspwm"].iter().map(|s| s.to_string()).collect()
}
fn default_stateless_process_list() -> Vec<String> {
[
"bash",

View File

@ -24,6 +24,10 @@ As features stabilize some brief notes about them will accumulate here.
#### Changed
* The default for [front_end](config/lua/config/front_end.md) is now `WebGpu`.
* The default for
[adjust_window_size_when_changing_font_size](config/lua/config/adjust_window_size_when_changing_font_size.md)
now depends on the window environment and the contents of
[tiling_desktop_environments](config/lua/config/tiling_desktop_environments.md).
#### New

View File

@ -15,3 +15,12 @@ If you use a tiling window manager then you may wish to set this to `false`.
See also [IncreaseFontSize](../keyassignment/IncreaseFontSize.md),
[DecreaseFontSize](../keyassignment/DecreaseFontSize.md).
{{since('nightly')}}
The default value is now `nil` which causes wezterm to match the name of the
connected window environment (which you can see if you open the debug overlay)
against the list of known tiling environments configured by
[tiling_desktop_environments](tiling_desktop_environments.md). If the
environment is known to be tiling then the effective value of
`adjust_window_size_when_changing_font_size` is `false`, and `true` otherwise.

View File

@ -0,0 +1,32 @@
# `tiling_desktop_environments = {}`
{{since('nightly')}}
Contains a list of Window Environments that are known to be tiling
window managers. A tiling window manager is one that automatically
resizes windows according to some layout policy, rather than respecting
the window size set by an application.
The default value for this option is:
```lua
config.tiling_desktop_environments = {
'X11 bspwm',
}
```
The environment name can be found in the debug overlay which you can show via
the [ShowDebugOverlay](../keyassignment/ShowDebugOverlay.md) key assignment.
The default key binding for it is <kbd>Ctrl</kbd> + <kbd>Shift</kbd> +
<kbd>L</kbd>.
Look for the line beginning with `Window Environment:`. The text after the
colon is the name to add to `tiling_desktop_environments`.
If your window environment is a tiling environment and is not listed
here, please file an issue (or even a PR!) to add it to the default
list.
This contents of this list are used to determine a reasonable default for
[adjust_window_size_when_changing_font_size](adjust_window_size_when_changing_font_size.md).

View File

@ -444,6 +444,8 @@ pub struct TermWindow {
num_frames: usize,
pub fps: f32,
connection_name: String,
gl: Option<Rc<glium::backend::Context>>,
webgpu: Option<Rc<WebGpuState>>,
config_subscription: Option<config::ConfigSubscription>,
@ -659,8 +661,11 @@ impl TermWindow {
let render_state = None;
let connection_name = Connection::get().unwrap().name();
let myself = Self {
created: Instant::now(),
connection_name,
last_fps_check_time: Instant::now(),
num_frames: 0,
last_frame_duration: Duration::ZERO,
@ -1606,6 +1611,7 @@ impl TermWindow {
self.config_overrides
);
self.key_table_state.clear_stack();
self.connection_name = Connection::get().unwrap().name();
let config = match config::overridden_config(&self.config_overrides) {
Ok(config) => config,
Err(err) => {
@ -2205,7 +2211,7 @@ impl TermWindow {
let gui_win = GuiWin::new(self);
let opengl_info = self.opengl_info.as_deref().unwrap_or("Unknown").to_string();
let connection_info = Connection::get().unwrap().name();
let connection_info = self.connection_name.clone();
let (overlay, future) = start_overlay(self, &tab, move |_tab_id, term| {
crate::overlay::show_debug_overlay(term, gui_win, opengl_info, connection_info)

View File

@ -385,8 +385,20 @@ impl super::TermWindow {
/// the `adjust_window_size_when_changing_font_size` configuration and
/// revises the scaling/resize change accordingly
pub fn adjust_font_scale(&mut self, font_scale: f64, window: &Window) {
if self.window_state.can_resize() && self.config.adjust_window_size_when_changing_font_size
{
let adjust_window_size_when_changing_font_size =
match self.config.adjust_window_size_when_changing_font_size {
Some(value) => value,
None => {
let is_tiling = self
.config
.tiling_desktop_environments
.iter()
.any(|item| item.as_str() == self.connection_name.as_str());
!is_tiling
}
};
if self.window_state.can_resize() && adjust_window_size_when_changing_font_size {
self.scaling_changed(self.dimensions, font_scale, window);
} else {
let dimensions = self.dimensions;