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

Add config option to always open window in full screen/maximized #284

Closed
JoyceBabu opened this issue Sep 27, 2020 · 29 comments
Closed

Add config option to always open window in full screen/maximized #284

JoyceBabu opened this issue Sep 27, 2020 · 29 comments
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.

Comments

@JoyceBabu
Copy link

Is your feature request related to a problem? Please describe.
When using wezterm on laptop, the window size is too small and I have to maximize the window everytime.

Describe the solution you'd like
It would be really nice, if it there is a configuration option to always open the window in full screen/maximized.

Describe alternatives you've considered
Similar behaviour can be obtained by setting initial_rows and initial_cols, but needs to be configured per machine/monitor.

Additional context

#256 #177

@JoyceBabu JoyceBabu added the enhancement New feature or request label Sep 27, 2020
@FLX-0x00
Copy link

FLX-0x00 commented Jan 7, 2021

This would be nice. Just replaced my terminal with wezterm and this is the only thing i missed at this time.

@AlectronikForge
Copy link

These params initial_rows and initial_cols should be better visible in the config part of the website, at least I was just up to open a wish report for them when I stumbled upon this here and finally was able to have WezTerm open at a favourable size..

@wez wez mentioned this issue Apr 10, 2021
@gwww
Copy link
Contributor

gwww commented Apr 10, 2021

While a config option might be OK for some situations, I want window:perform_action("Maximize") then in something such as #674 I could then have logic for what deciding what to do. For example in the event code I could look at the DPI of the screen (as a hack to know which screen I'm on) and only maximize if I'm on my laptop screen. I could also in the event handler do things such at SplitHorizontal, etc.

@lucatrv
Copy link

lucatrv commented Mar 15, 2022

Just as a note, I can start Wezterm maximized by simply setting initial_cols and initial_rows to any values above the maximum ones possible on my screen (for instance initial_cols = 200 and initial_rows = 50).

@wez, maybe this behavior should be documented? I can send a PR if you wish.

@wez
Copy link
Owner

wez commented Mar 17, 2022

This issue serves as documentation for workaround(s) for now: I'd rather have a PR that focused on making the requested feature work :)

@chtenb
Copy link
Sponsor

chtenb commented Apr 15, 2022

Just as a note, I can start Wezterm maximized by simply setting initial_cols and initial_rows to any values above the maximum ones possible on my screen

That doesn't work for me on windows. The window will actually take those dimensions.

@agkitspersonal
Copy link

It actually extends to my second monitor. It's better for me to not set any values there.

wez added a commit that referenced this issue Jul 7, 2022
Implemented on macOS only for the moment.

refs: #284
wez added a commit that referenced this issue Jul 7, 2022
Doesn't do anything yet, but I always forget to add this until
after I've implemented one or the other and then wonder why
nothing happens.

refs: #284
wez added a commit that referenced this issue Jul 7, 2022
You can start a window in full screen mode using something like:

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():toggle_fullscreen()
end)

return {
}
```

refs: #177
refs: #284
@wez
Copy link
Owner

wez commented Jul 7, 2022

Current main allows you to add this to your config to maximize the initial window:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():maximize()
end)

return {}

Windows and Wayland nightly builds with this feature are currently building, but X11 and macOS builds already have it available.

@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Jul 7, 2022
@wez wez closed this as completed Jul 9, 2022
@chtenb
Copy link
Sponsor

chtenb commented Jul 10, 2022

It doesn't seem to work on windows. It does start in the topleft corner now, but not maximized. It has the same size as before.
It does think it's maximized though, because windows-up doesn't do anything. Only when I press windows-down windows-up it gets maximized.

wez added a commit that referenced this issue Jul 10, 2022
Since applying the maximized state is async, we hadn't fully applied
it before we got to the startup logic that resizes the window to fit
the initial terminal size.

This adds a final check to see if we are resizable before we try
to apply that size, and skips it.

refs: #284
@wez
Copy link
Owner

wez commented Jul 10, 2022

@chtenb: should be fixed now in main!

@gwww
Copy link
Contributor

gwww commented Jul 10, 2022

I just tested and it works as expected. I removed my lines/cols "hack" settings to try and the result was correct. Thank-you!

@chtenb
Copy link
Sponsor

chtenb commented Jul 11, 2022

Yes it works now @wez !

@jackos
Copy link

jackos commented Jul 13, 2022

Works great on Mac thanks @wez, but for anyone that this isn't working for, having this setting will not allow it to work:

return {
    window_decorations = "NONE"
}

To get rid of the title bar and still allow this to work you can do:

return {
    window_decorations = "RESIZE"
}

@JoyceBabu
Copy link
Author

Thank you. It is working great.   🎉

Is it possible to disable the resize animation when calling the maximize method?

@wez
Copy link
Owner

wez commented Jul 15, 2022

Is it possible to disable the resize animation when calling the maximize method?

assuming you mean macOS: as far as I can tell, no, there isn't a way for an application to use the standard NSWIndow::zoom method without it animating.

Instead of window:maximize() you may wish to use window:toggle_fullscreen() which, by default (unless you have changed native_macos_fullscreen_mode) will go fullscreen without the annoying animation.

@JoyceBabu
Copy link
Author

JoyceBabu commented Jul 17, 2022

Instead of window:maximize() you may wish to use window:toggle_fullscreen() which, by default (unless you have changed native_macos_fullscreen_mode) will go fullscreen without the annoying animation.

That worked perfectly. Thanks.

toggle_fullscreen hides the menu bar too on macOS. So I am going with maximize itself. Thank you for adding the maximize support.

@tgharib
Copy link

tgharib commented Jul 20, 2022

Current main allows you to add this to your config to maximize the initial window:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():maximize()
end)

return {}

Windows and Wayland nightly builds with this feature are currently building, but X11 and macOS builds already have it available.

This worked wonderfully on Windows but I seemed to have lost the ability to use wezterm-gui start. For example: wezterm-gui start -- nvim now takes me to a fresh prompt instead of launching neovim. Here is my full config on Windows if it's relevant. I have commented out the maximize code for now since launching nvim is important to me.

wez added a commit that referenced this issue Jul 20, 2022
This allows the hook to choose how to handle eg: `wezterm start -- top`.
Previously, if you had implemented this event you would essentially lose
the ability to specify a command that you wanted to launch.

refs: #284
@wez
Copy link
Owner

wez commented Jul 20, 2022

@tgharib ah, good catch. Yeah, that's a pain. I've pushed a commit that now encodes the wezterm start program arguments into a SpawnCommand object, so you can do:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on("gui-startup", function(cmd)
  local tab, pane, window = mux.spawn_window(cmd or {})
  window:gui_window():maximize()
end)

return {}

@wez
Copy link
Owner

wez commented Jul 20, 2022

That should show up in a nightly build for windows within about an hour from now.

@14Si
Copy link

14Si commented Aug 6, 2022

I don't think the solutions above apply to windows spawned by wezterm ssh <>@<>

wez added a commit that referenced this issue Aug 20, 2022
This is done by adjusting how `wezterm ssh` works; we now set up
the default domain and call into the main `wezterm start` logic.

refs: #284
@wez
Copy link
Owner

wez commented Aug 20, 2022

@14Si: 8b2ef50 makes gui-startup work for wezterm ssh

@stevenxxiu
Copy link

stevenxxiu commented Aug 23, 2022

Thanks for this feature. I tested your code @wez, but the terminal always flickers on startup. It starts out as a small window, as configured (or not) via initial_rows and initial_cols, then maximizes.

Is there a way to avoid this flickering?

@jfaz1
Copy link

jfaz1 commented Sep 7, 2022

@wez @stevenxxiu have the same issue, but also messes up Open WezTerm Here in Windows. Shell ends up defaulting to the user directory instead of the folder in which it was invoked.
Looks like:

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():maximize()
end)

@wez
Copy link
Owner

wez commented Sep 7, 2022

@jfaz1 check out the docs at https://wezfurlong.org/wezterm/config/lua/gui-events/gui-startup.html and you'll see that the cmd object passed to the event can be used to pass through other information from wezterm start:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on('gui-startup', function(cmd)
  local tab, pane, window = mux.spawn_window(cmd or {})
  window:gui_window():maximize()
end)

return {}

@jfaz1
Copy link

jfaz1 commented Sep 7, 2022

@wez Thanks for the reply! I tried that snippet earlier and it didn't work, but I moved up in the config and for some reason it worked this time. It's almost there, only thing missing besides what @stevenxxiu brought up is that the left side starts cut-off:
image
It's meant to read PS . If I un-maximize it and maximize it again it looks normal:
image

@wez
Copy link
Owner

wez commented Sep 7, 2022

Please open a separate issue for that!

@wez wez mentioned this issue Nov 3, 2022
@trymoto
Copy link

trymoto commented Jan 22, 2023

If you're on MacOS and want wezterm to natively maximize the window you can:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window(cmd or {})
  window:gui_window():toggle_fullscreen()
end)

return {
  native_macos_fullscreen_mode = true,
}

Also, animation to fullscreen might mess up sizes if you're immediately spawning stuff.
It's best to also call wezterm.sleep_ms(1) after that

@rbutoi
Copy link

rbutoi commented Feb 3, 2023

I can't tell why this was closed? AFAICT there's still no config option to do this -- enabling fullscreen interactively at runtime or with some kind of sleep seems hacky. I'd like to use wezterm for one-off fullscreen terminal dialogs that I currently still use kitty --start-as=fullscreen for.

@wez
Copy link
Owner

wez commented Feb 3, 2023

It's closed because this issue asked for a configuration option and there is a more powerful configuration option for this documented in:

a command line flag is a different thing; please file a separate issue for that if that is something you'd like to have considered as a future enhancement.

I'm going to lock this issue because tracking and responding effectively to comments on a closed issue is difficult.

Repository owner locked as resolved and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.
Projects
None yet
Development

No branches or pull requests