wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

When doing `wezterm start` with `--config-file`, window opens behind main window

Open gwww opened this issue 1 year ago • 3 comments

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

20240226-174525-22424c32

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

For the command: wezterm --config-file ~/wt-empty.lua start -- bash

The first time it is run, it works perfectly. The second time it is run two things happen. First the new window opens behind the main window (I only have one window open before running the command). Second, the wezterm command does not exit until the window closes.

To Reproduce

Run the command above two times. First time works as expected.

Configuration

The contents of ~/wt-empty.lua are:

return {}

Expected Behavior

The new window to always be the front most window and for the command to exit immediately after the window is created.

Logs

The follow log always appears in the current window where the above command is run:

2024-03-01 18:35:34.853 wezterm-gui[38297:1274659] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.

Anything else?

I originally opened the following bug, but have realized that the bug was incorrectly described. I have closed that bug. https://github.com/wez/wezterm/issues/5084

While I show recreating the bug by issuing a command in a current wezterm terminal window, the use case will be that the command is issued from another process (hammerspoon) and is not to run another bash instance but to run a terminal file manager (yazi is the one I'm trying).

gwww avatar Mar 01 '24 23:03 gwww

I've tried starting with WEZTERM_LOG=wezterm_gui=debug,warning wezterm.... There was nothing interesting in the logs. Would other logging params be more useful?

gwww avatar Mar 06 '24 21:03 gwww

echo, running wezterm start creates and focuses window, running weztern --config-file "wezterm.lua" start won't focus, and trying to focus via the gui-startup event trigger also seems to be not working:

wezterm.on('gui-startup', function(cmd)
  local _, _, window = mux.spawn_window(cmd or {})
  window:gui_window():focus()
  window:set_title("popup")
end)

Where as calling :maximize() instead of :focus() does seem to work as expected

tzhouhc avatar May 19 '24 22:05 tzhouhc

Seeing the same issue, with both wezterm-gui and wezterm. Tried various flags like --always-new-process to see if it's that, but can't get it to focus.

What's interesting is that via the built-in Terminal, open /Applications/WezTerm.app also doesn't show focus, but using Alfred 5 (launcher app) it does show focus.

WEZTERM_LOG=wezterm_gui=debug,warning /opt/homebrew/bin/wezterm-gui start --always-new-process

13:45:29.266  DEBUG  wezterm_gui::frontend > workspace is default, fixup windows
13:45:29.289  DEBUG  wezterm_gui::termwindow > Resized { dimensions: Dimensions { pixel_width: 1148, pixel_height: 874, dpi: 144 }, window_state: (empty), live_resizing: false }
13:45:29.304  DEBUG  wezterm_gui::termwindow > NeedRepaint
13:45:29.306  DEBUG  wezterm_gui::termwindow > OpenGL initialized! OpenGL: Apple M3 Pro 4.1 Metal - 88.1 wezterm version: 20240730-082727-56a27e93
13:45:29.306  DEBUG  wezterm_gui::frontend   > workspace is default, fixup windows
13:45:29.309  DEBUG  wezterm_gui::termwindow > Resized { dimensions: Dimensions { pixel_width: 1148, pixel_height: 874, dpi: 144 }, window_state: MAXIMIZED, live_resizing: false }
13:45:29.311  DEBUG  wezterm_gui::termwindow > Resized { dimensions: Dimensions { pixel_width: 1148, pixel_height: 874, dpi: 144 }, window_state: (empty), live_resizing: false }
13:45:29.318  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.319  DEBUG  wezterm_gui::termwindow > Notification(Any { .. })
13:45:29.324  DEBUG  wezterm_gui::termwindow > NeedRepaint
13:45:29.325  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl before call_draw elapsed=959.292µs
13:45:29.326  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl elapsed=2.175167ms, fps=0
13:45:29.344  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:29.351  DEBUG  wezterm_gui::termwindow                > NeedRepaint
13:45:29.351  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl before call_draw elapsed=166µs
13:45:29.352  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl elapsed=377.5µs, fps=0
13:45:30.310  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:30.311  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:30.311  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })

Command+Tabbing (aka alt tabbing) to the app works:

13:45:32.475  DEBUG  wezterm_gui::termwindow                > FocusChanged(true)
13:45:32.476  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.480  DEBUG  wezterm_gui::termwindow                > NeedRepaint
13:45:32.480  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl before call_draw elapsed=183.292µs
13:45:32.480  DEBUG  wezterm_gui::termwindow::render::paint > paint_impl elapsed=594.333µs, fps=0.9388015
13:45:32.501  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.501  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.501  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.714  DEBUG  wezterm_gui::termwindow                > AdviseModifiersLedStatus(NONE, (empty))
13:45:32.715  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.716  DEBUG  wezterm_gui::termwindow                > Notification(Any { .. })
13:45:32.717  DEBUG  wezterm_gui::termwindow                > NeedRepaint

Using osascript -e "tell application \"WezTerm\" to activate", when a single WezTerm application is open will sometimes work on the first attempt, but seems consistent on the second.

Infact, adding another window:gui_window():focus() shows Wezterm above everything else, but the current app is still in focus.

joshuataylor avatar Jul 31 '24 05:07 joshuataylor

For me, this also happen when launching with wezterm start --new-tab --cwd ~/dev, it doesn't bring the terminal window to focus.

guimas avatar Nov 15 '24 12:11 guimas