https://bugs.winehq.org/show_bug.cgi?id=53984
Bug ID: 53984 Summary: Broken minimize-restore logic in conhost.exe for all console apps Product: Wine Version: 7.21 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: x1917x@gmail.com Distribution: ---
Created attachment 73566 --> https://bugs.winehq.org/attachment.cgi?id=73566 Issue log for minimize-restore
There is an old bug in Wine's conhost.exe, introduced years ago. Whenever a console window is minimized and then restored, conhost.exe creates both vertical and horizontal scrollbars for that window, no matter that there were no changes to that window. Bad consequence is that both of them overlap parts of content of the console window, so now one have to actually scroll the window to see the lines/columns covered by scrollbars.
From what I see, the bug affects all console apps, the attached log file was taken for Wine's cmd.exe (wineconsole cmd.exe).
The root cause of the bug is that conhost.exe makes no distinction between WM_SIZE caused by regular resize and WM_SIZE caused by minimizing. Whenever the console window gets minimized, ShowWindow(SW_MINIMIZE) is being called for it. Internally, Wine's show_window() calls window_min_maximize() to retrieve the minimized window Rect. For a minimized window it fills that Rect with the size of "iconic" window, which is determined by get_system_metrics(SM_CXMINIMIZED) and get_system_metrics(SM_CYMINIMIZED). Not sure if it depends on the host, but on my system it is 160 x 31. So eventually WM_SIZE(<...>, 160, 31) is being sent to conhost.exe's window, among few other WM_-messages. As conhost.exe makes no distinction between the different states the console window can be, it assumes that the minimized window size (160x31) is the new real window size. Then it tries to apply the same sequence of actions like for any received WM_SIZE. One of them is checking if the newly resized console window is smaller than its content. If it was the case, it creates respective horizontal/vertical scrollbars in window.c/update_window(). So basically, conhost.exe treats every window minimizing as a resize.
Luckily, the fix is trivial - Wine's conhost.exe shouldn't try to resize its window when it is minimized. There is zero point to resize a minimized window, especially if it wasn't resized at all.
case WM_SIZE: if (console->window && console->window->update_state != UPDATE_BUSY) resize_window( console, --> case WM_SIZE: if (console->window && console->window->update_state != UPDATE_BUSY && !IsIconic(console->win)) resize_window( console,
(the patch is attached)
Please review and apply the proposed fix if it's ok (I am not a Wine contributor - don't know how to commit to Wine, not a member of the mail list etc).
https://bugs.winehq.org/show_bug.cgi?id=53984
Alex x1917x@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |x1917x@gmail.com
--- Comment #1 from Alex x1917x@gmail.com --- Created attachment 73567 --> https://bugs.winehq.org/attachment.cgi?id=73567 Bugfix
https://bugs.winehq.org/show_bug.cgi?id=53984
Alex x1917x@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |programs