Tab key doesn't switch to source panel while LS-plugin is loading in QV

Please report only one bug per message!

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
DrShark
Power Member
Power Member
Posts: 1400
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *DrShark » 2019-05-02, 17:43 UTC

This issue discovered during tests for *.ts files viewing bugreport.

To reproduce:
1. Install CudaLister 1.6.7.
2. Download this TS sample file (already mentioned here).
3. If CudaLister isn't loaded for that sample, either apply a workaround with adding a MULTIMEDIA detect string for CudaLister in wincmd.ini, or just change sample file extrension from .ts to .js
4. Open a sample file in Total Commander's Quick View (using Ctrl+Q):
after CudaLister is loaded but before lexer will be fully applied (so text will be highlighted with colors and file folding will appear), a focus switches from source panel to nowhere, so pressing the Tab key will neither activate target panel (QuickView) nor return focus to source panel. Ctrl+Q doesn't work during file loading too.
5. After a file will be fully loaded (folding lines will appear,) Tab key (and Ctrl+Q) will work again.

I consider it as a bug because between opening QuickView and a moment when the file is fully loaded by a plugin it's possible to switch a focus to a source panel using a mouse click, then Tab key immediately starts working again. So I think either in step 4 Total Commander should switch a focus to a target (QuickView) panel immediately, or, if it's not possible, it should allow to return a focus to a source panel using a keyboard (by a single or double click on Tab key.)
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
petermad
Power Member
Power Member
Posts: 8983
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *petermad » 2019-05-02, 22:17 UTC

I can confirm this.
If I in the left panel have the sample file parser.ts and I enable QuickView and click on the file and immediately thereafter press Tab, then the Tab key thereafter doesn't seem to work. I can revive it by running the cm_FocusTrg from the command line (or by clicking on the left file panel).

Since I in my Main menu have the commands cm_FocusLeft, cm_FocusRight, cm_FocusSrc and cm_FocusTrg I can actually reveal that TC still recognizes the Tab key:
After the first Tab press, my Focus menu shows this (which is expected): http://madsenworld.dk/tcmd/focuslost1.png
After a second Tab press, my Focus menu shows that the focus is in the right panel (when it should have been in the left panel): http://madsenworld.dk/tcmd/focuslost2.png
If I continue pressing Tab then the focus is either missing or percieved by TC to be in the left panel at every second keypress.

Under normal conditions (where I let CudaListers lexer finish its formatting before I press Tab) it looks like this at every second keypress:
http://madsenworld.dk/tcmd/focuslost3.png and like this at every other keypress: http://madsenworld.dk/tcmd/focuslost1.png (as expected)
License #524 (1994)
Danish Total Commander Translator
TC 9.5b8 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38438
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *ghisler(Author) » 2019-05-06, 08:13 UTC

This cannot be avoided - it happens because Delphi handles the TAB key in its message loop. When a plugin is busy, the Delphi message loop isn't running because the plugin is running its own message loop, so the tab key isn't handled.
Author of Total Commander
http://www.ghisler.com

User avatar
DrShark
Power Member
Power Member
Posts: 1400
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *DrShark » 2019-05-06, 10:50 UTC

ghisler(Author) wrote:
2019-05-06, 08:13 UTC
When a plugin is busy, the Delphi message loop isn't running because the plugin is running its own message loop, so the tab key isn't handled.
I'm not a programmer, but maybe it's possible to avoid going to plugin's message loop while it's busy opening file, so it will be possible to fix "Open ... Quick View (using Ctrl+Q): ... focus switches from source panel to nowhere" issue while plugin is busy? If can you detect this, maybe you can make the focus (cursor) on file to stay active in source panel while plugin will be busy opening a file in opposite panel's QuickView, and after plugin will fully open a file, you can activate target (QuickView) panel.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38438
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *ghisler(Author) » 2019-05-06, 19:25 UTC

I could call the plugin from a background thread, but not all plugins are thread safe...
Author of Total Commander
http://www.ghisler.com

User avatar
DrShark
Power Member
Power Member
Posts: 1400
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *DrShark » 2019-05-07, 10:55 UTC

ghisler(Author) wrote:
2019-05-06, 19:25 UTC
I could call the plugin from a background thread, but not all plugins are thread safe...
In my above suggestion I meant to leave file cursor active in source panel while plugin is busy opening file (currently we press Ctrl+Q -> cursor immediately disappears from source panel and will appear there again only after plugin will fully load a file). Is calling a plugin in background thread can only be a solution to this? As petermad wrote, cm_FocusSrc works while plugin is loading a file: a menu or a button with cm_FocusSrc makes cursor to appear in source panel while plugin is busy, so maybe TC can just execute this command internally after user pressed Ctrl+Q and cursor disappeared?
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
DrShark
Power Member
Power Member
Posts: 1400
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *DrShark » 2019-11-16, 18:53 UTC

It seems nothing is changed here. What about suggested solution from above post:
DrShark wrote:
2019-05-07, 10:55 UTC
cm_FocusSrc works while plugin is loading a file: a menu or a button with cm_FocusSrc makes cursor to appear in source panel while plugin is busy, so maybe TC can just execute this command internally after user pressed Ctrl+Q and cursor disappeared?
?
Basically, the point of suggestion is to move file cursor back to source panel immediately after user opened QuickView no matter whether plugin is busy at this moment.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38438
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *ghisler(Author) » 2019-11-18, 13:29 UTC

Sorry, it's too risky to call plugins from a background thread while it's not clear which will work and which will crash.
Author of Total Commander
http://www.ghisler.com

User avatar
DrShark
Power Member
Power Member
Posts: 1400
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *DrShark » 2019-11-19, 10:13 UTC

ghisler(Author) wrote:
2019-11-18, 13:29 UTC
Sorry, it's too risky to call plugins from a background thread while it's not clear which will work and which will crash.
I'm not a programmer, but why do you see calling a plugin from background thread as the only possible solution?

I mean, here's what happens:
1. Focus is on source panel, then user presses Ctrl+Q.

2. Following actions are happening, but I'm not sure about their order:

a) QuickView window is opened in target panel;
b) file cursor focus moves away from source panel;
c) plugin takes message loop for a while from TC, so TC doesn't catch keyboard input for that time.

3. Plugin's own message loop ends, file cursor focus is auto-restored to source panel.

The question: when exactly file cursor moves to QuickView window?

I'm trying to understand why it's impossible for TC detect plugin's message loop and then to get the file cursor back to source panel (because it was there before) at the time when plugin is starting own message loop, even though user during such loop still can get it there by sending to TC a command cm_FocusSrc from a button.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38438
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Tab key doesn't switch to source panel while LS-plugin is loading in QV

Post by *ghisler(Author) » 2019-11-19, 15:18 UTC

The problem is that some plugins set the focus to an inner window. This is perfectly OK when viewing files with F3, but a problem with Ctrl+Q. This can happen even after the call to the plugin has returned.
Author of Total Commander
http://www.ghisler.com

Post Reply