realh / roxterm

A highly configurable terminal emulator
GNU General Public License v2.0
102 stars 12 forks source link

New Roxterm / New window opens in background #254

Open flohoff opened 11 months ago

flohoff commented 11 months ago

Hi, since upgrading to Bookworm and current git i have the issue that when starting a new roxterm the new terminal windows opens in background and inactive.

Debian/Bookworm Cinnamon X11

flo@p5:~/projects/roxterm/roxterm$ git describe --long
3.14.2-0-g92b3bc7

Its not in 100% of the cases but most of the time

win rox - enter -> first roxterm opens -> make it fullscreen with left-win up up win rox - enter -> new window opens inactive in background

I am a bit puzzled and tried to unterstand - So what i read gtk_windows_present is bringing the windows to front and activates it. So in case the new roxterm starts this should be done via DBUS and calls launch_roxterm which runs

^f3709af (Tony Houghton 2010-08-24 19:18:02 +0100 4224)             multi_tab_new(win, roxterm);
37bb4015 (Tony Houghton 2011-12-29 13:56:04 +0000 4225)             if (gtk_widget_get_visible(gwin))
25ee207f (Tony Houghton 2011-12-29 15:42:43 +0000 4226)                 gtk_window_present(GTK_WINDOW(gwin));
^f3709af (Tony Houghton 2010-08-24 19:18:02 +0100 4227)         }

Is my understanding correct? This code hasnt changed for a decade so something externally must have changed. My guess is that gtk_widget_get_visible returns false - some race condition?!?

I'd be happy to debug further

Flo

flohoff commented 11 months ago

Another datapoint - Using not "win rox enter" to open a new roxterm - but using ctrl-alt-n works as expected. Opens in front.

realh commented 11 months ago

What is "win rox enter"?

flohoff commented 11 months ago

I am sorry - starting from the Cinnamon Start Menu - pressing windows - typing rox to find roxterm and pressing enter ;)

realh commented 11 months ago

I think this is probably due to focus-stealing prevention in the window manager. When roxterm is already running and you launch a new window from Cinnamon's menu, the new instance sends a message to the existing one to open a new window. Most window managers won't allow the new window to be focused if another application's window was focused beforehand. It's to stop them from being annoying with pop-ups or trying to steal data by intercepting key-strokes. If there was no other window focused apart from Cinnamon's menu, then I think that's an issue in Cinnamon. It should either integrate better with the window manager, if possible, to make an exception in this sorrt of case, or close its menu, restoring focus to [roxterm], before running the command. If I've already got a terminal window open I always use its shortcut to open a new window instead of going back to the desktop system menu, so I don't encounter this problem.

This could be avoided if roxterm ran a separate process for each window, and that would also potentially prevent data loss from one window crashing taking out the others, but it would make it very difficult, if not impossible with current versions of vte and gtk, to implement the movement of tabs between windows.

flohoff commented 11 months ago

Interestingly this works with gnome-terminal which IMHO has the same process/windows structure. So it seems bringing windows to front and activating them must be possibly somehow.

The procedure of using the cinnamon application chooser is quicker than finding the last open ROXterm burried under a stack of windows and pressing shift-ctrl-n, this is why i use it.

typically i have a window per "subject" or "task" i am working on, and using tabs for subtasks of that matter. So whenever i start a new ticket/task/subject i open a new roxterm.

Flo