OldUnreal / UnrealTournamentPatches

Other
1k stars 29 forks source link

[v469d] System Console may lose focus and skip one keypress event after "Alt+Tab"... #1498

Open an-eternity opened 10 months ago

an-eternity commented 10 months ago

This issue randomly occurs in a few seconds after focus of UT main window (with previously opened System Console inside) has been restored (for example, UT main window was minimized or was in a windowed background state before).

Way to reproduce:

  1. Run practice session in UT.
  2. Open System Console.
  3. Press "Alt+Tab" to minimize UT from full screen, or to switch to another window if in windowed mode.
  4. Few seconds later, bring back UT main window to full screen or to foreground windowed state (as it previously was) and immediately start to type in System Console that was already opened there before.

Expected behavior: System Console works properly when UT main window focus restored, you can type in console with no any issues. Actual behavior: System Console will automatically lose focus itself (becomes gray) and in this moment one keypress event will be ignored (means, whatever you have typed in console will have missed symbol), and then you can still continue typing in this System Console with lost focus, issue won't happen until the next focus switch for UT main window.

If reproduce it from the initial main menu state, then, once System Console has lost its focus due to this issue, you can't proceed typing anymore until focus of System Console window restored.

This old issue presents in all versions from v436 to v469d. I have been waiting since v469a for it to be fixed by occasion, but it is still there... I guess, it is so either because it's too little and too insignificant issue, or because solution is not practically doable... I couldn't find any related issue opened, and since now it is time to deal with small issues, as all serious ones were already fixed in past builds, so i opened this one...

an-eternity commented 7 months ago

Anybody else out there can reproduce this issue with System Console? It is reproduceable in all of my test systems, so i wonder why nobody reported it so far...

SeriousBuggie commented 7 months ago

Can't reproduce. Possible related to your keybinding? Like something on Alt or Tab? Can you reproduce it on clean setup with default ini files?

an-eternity commented 7 months ago

Very interesting... Must be something common that triggers it in all my systems then. I think i already tested it with default ini files, but i'll do it again to make sure. By the way, did you try to reproduce it with specific symbols? For example, these: "g", "m", "o", "t", "h"...

SeriousBuggie commented 7 months ago

Console window not gray. It active and work for any keys, what i push. Include yours. img

SeriousBuggie commented 7 months ago

You can use utrace for find out, what exactly make console window inactive.

an-eternity commented 7 months ago

Still can reproduce it with default ini files. And here i think is utrace log of that point where it happens, i used "h" (calls Help menu pull down) button here, if use button of another GUI items then utrace log looks a bit different of course:


UTrace: BEGIN UTConsole0 UTMenu.UTConsole.UWindow.KeyEvent
UTrace:   BEGIN UTConsole0 UWindow.WindowConsole.UWindow.KeyEvent
UTrace:     BEGIN UMenuRootWindow0 UWindow.UWindowRootWindow.WindowEvent
UTrace:       BEGIN UMenuRootWindow0 UWindow.UWindowRootWindow.HotKeyDown
UTrace:         BEGIN UMenuMenuBar0 UWindow.UWindowMenuBar.HotKeyDown
UTrace:           BEGIN UWindowMenuBarItem6 UWindow.UWindowMenuBarItem.Select
UTrace:             BEGIN UMenuBlueLookAndFeel0 UMenu.UMenuGoldLookAndFeel.PlayMenuSound
UTrace:               BEGIN UMenuMenuBar0 UWindow.UWindowWindow.GetPlayerOwner
UTrace:               END   UMenuMenuBar0 UWindow.UWindowWindow.GetPlayerOwner
UTrace:               BEGIN TFemale10 Engine.Pawn.ClientHearSound
UTrace:               END   TFemale10 Engine.Pawn.ClientHearSound
UTrace:             END   UMenuBlueLookAndFeel0 UMenu.UMenuGoldLookAndFeel.PlayMenuSound
UTrace:             BEGIN UMenuHelpMenu0 UWindow.UWindowPulldownMenu.ShowWindow
UTrace:               BEGIN UMenuHelpMenu0 UWindow.UWindowWindow.ShowWindow
UTrace:                 BEGIN UMenuRootWindow0 UWindow.UWindowWindow.ShowChildWindow
UTrace:                 END   UMenuRootWindow0 UWindow.UWindowWindow.ShowChildWindow
UTrace:                 BEGIN UMenuHelpMenu0 UWindow.UWindowWindow.WindowShown
UTrace:                 END   UMenuHelpMenu0 UWindow.UWindowWindow.WindowShown
UTrace:               END   UMenuHelpMenu0 UWindow.UWindowWindow.ShowWindow
UTrace:               BEGIN UMenuHelpMenu0 UWindow.UWindowPulldownMenu.PerformSelect
UTrace:               END   UMenuHelpMenu0 UWindow.UWindowPulldownMenu.PerformSelect
UTrace:               BEGIN UMenuHelpMenu0 UWindow.UWindowWindow.FocusWindow
UTrace:                 BEGIN UWindowEditControl13 UWindow.UWindowWindow.FocusOtherWindow
UTrace:                 END   UWindowEditControl13 UWindow.UWindowWindow.FocusOtherWindow
UTrace:               END   UMenuHelpMenu0 UWindow.UWindowWindow.FocusWindow
UTrace:             END   UMenuHelpMenu0 UWindow.UWindowPulldownMenu.ShowWindow
UTrace:           END   UWindowMenuBarItem6 UWindow.UWindowMenuBarItem.Select
UTrace:           BEGIN UMenuMenuBar0 UMenu.UMenuMenuBar.Select
UTrace:             BEGIN UMenuMenuBar0 UWindow.UWindowMenuBar.Select
UTrace:             END   UMenuMenuBar0 UWindow.UWindowMenuBar.Select
UTrace:             BEGIN UMenuMenuBar0 UMenu.UMenuMenuBar.ShowHelpItem
UTrace:               BEGIN UMenuMenuBar0 UMenu.UMenuMenuBar.SetHelp
UTrace:                 BEGIN UMenuStatusBar0 UMenu.UMenuStatusBar.SetHelp
UTrace:                 END   UMenuStatusBar0 UMenu.UMenuStatusBar.SetHelp
UTrace:               END   UMenuMenuBar0 UMenu.UMenuMenuBar.SetHelp
UTrace:             END   UMenuMenuBar0 UMenu.UMenuMenuBar.ShowHelpItem
UTrace:             BEGIN UMenuMenuBar0 UWindow.UWindowMenuBar.Select
UTrace:             END   UMenuMenuBar0 UWindow.UWindowMenuBar.Select
UTrace:           END   UMenuMenuBar0 UMenu.UMenuMenuBar.Select
UTrace:         END   UMenuMenuBar0 UWindow.UWindowMenuBar.HotKeyDown
UTrace:       END   UMenuRootWindow0 UWindow.UWindowRootWindow.HotKeyDown
UTrace:     END   UMenuRootWindow0 UWindow.UWindowRootWindow.WindowEvent
UTrace:   END   UTConsole0 UWindow.WindowConsole.UWindow.KeyEvent
UTrace: END   UTConsole0 UTMenu.UTConsole.UWindow.KeyEvent
an-eternity commented 7 months ago

It looks like if Alt button for some reason would appear always pressed after switch UT window back to foreground.

an-eternity commented 7 months ago

Now, if i switch Engine.Engine.Language in UT ini to some other than int, this issue won't happen since those GUI hotkey events can't be called from keyboard then.

an-eternity commented 6 months ago

This issue happens because bAltDown in UWindowMenuBar / UMenuMenuBar remains True after using Alt+Tab combination. When Alt+Tab combination is pressed in focused UT window, bAltDown gets switcheed from False to True. When Alt+Tab combination is released, UT window is no longer focused and for this reason bAltDown remains set to True. Then, when UT window is returned back from background to foreground state by using Alt+Tab combination, bAltDown still remains set to True, because window gets focused by Alt+Tab release event, not by press event. So, at that moment when UT window is back to foreground state, Alt key is already in released state and HotKeyUp() function with key code 0x12 that would set bAltDown back to False is not called.

Now, question is - why this issue is not reproduceable in some systems?

SeriousBuggie commented 6 months ago

On my experience all hold button released only window loose focus. At least for Windows 7. In MH I often use trick, like press button, call console, release button, close console. This leave pressed state on key or mouse button. However this need focus on window. if I try alt-tab, all such magic stop work, and all key unpressed.

an-eternity commented 6 months ago

I added simple client side actor for test - it sets bAltDown in UMenuMenuBar to False if it was True longer than couple of second. Now this issue doesn't happen if this actor is running.

The trick with key pressed state when console open/close is also working in my test systems, and also stops working if main window has lost focus. But it is unrelated to this problem with bAltDown in UMenuMenuBar. UWindowMenuBar / UMenuMenuBar needs a fix to handle this case properly. For example, native part has a corresponding event on window restore focus and can call 0x12 key event for UScript to unset bAltDown. Maybe UScript has some way to detect window restore event somehow, but i couldn't find anything related yet.