Skip to content

Commit

Permalink
avoid interaction problem of tabbed/non-tabbed windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Sep 16, 2024
1 parent 6ff89d5 commit 66125b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ or hidden.
Use \fICLASS\fP as the window class name of the main window.
This allows window grouping or setup of different tab sets,
and it allows scripting tools to distinguish different mintty instances.
The default is "mintty".
The default is "mintty\fI_N\fP", including tabbed window sync level if > 1.

.TQ
\fB\-d\fP, \fB\-\-nodaemon\fP
Expand Down Expand Up @@ -2767,11 +2767,14 @@ Setting only one of X, Y is not supported.
See command-line option \fB\-p\fP for further positioning options.

.TQ
\fBWindow class name\fP (Class=mintty)
\fBWindow class name\fP (Class=mintty\fI_N\fP)
The \fBClass\fP setting determines the name of the window class of the terminal window.
It can be used to distinguish or group different mintty windows, or tab sets, e.g. for
the mintty session switcher, or for Windows scripting tools such as AutoHotKey.

The default setting appends the tabbed window sync level (>1) to avoid
interaction issues between tabbed and non-tabbed windows.

For a flexible grouping configuration, the Class option supports the
same \fB%s\fP placeholder parameters as the AppID option.

Expand Down
15 changes: 15 additions & 0 deletions src/winmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ win_hide_other_tabs(HWND to_top)
if (class_atom == curr_wnd_info.atomWindowType) {
//printf("[%p] hiding %p (unless top %p)\n", wnd, curr_wnd, to_top);
if (curr_wnd != to_top && !IsIconic(curr_wnd)) {
#ifdef debug_hiding
int len = GetWindowTextLengthW(curr_wnd);
wchar t[len + 1];
GetWindowTextW(curr_wnd, t, len + 1);
printf("hiding <%ls>\n", t);
#endif
// do not use either of
// ShowWindow(SW_HIDE) or SetWindowPos(SWP_HIDEWINDOW);
// it is hard to restore from those states and window handling
Expand Down Expand Up @@ -7089,6 +7095,15 @@ main(int argc, char *argv[])
wstring wclass = W(APPNAME);
if (*cfg.class)
wclass = group_id(cfg.class);
if (cfg.geom_sync > 1) {
char * class = cs__wcstoutf(wclass);
char * syncclass = asform("%s_%d", class, cfg.geom_sync);
free(class);
set_arg_option("Class", syncclass);
wclass = cs__utftowcs(syncclass);
free(syncclass);
}

#ifdef prevent_grouping_hidden_tabs
// should an explicitly hidden window not be grouped with a "class" of tabs?
if (!cfg.window)
Expand Down
1 change: 1 addition & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Mouse and menu handling
* Allow disabling of mouse menus by clearing Menu* (#1279).

Window handling
* Avoid interaction problem of tabbed/non-tabbed windows.
* Tweak initial window display, mitigate bright flash (#1284).

Configuration
Expand Down

0 comments on commit 66125b0

Please sign in to comment.