Bug 444605 - Default focus is put on button "Close": hitting ENTER closes the program
Summary: Default focus is put on button "Close": hitting ENTER closes the program
Status: RESOLVED FIXED
Alias: None
Product: Skanlite
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: Kåre Särs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-29 13:40 UTC by 0BADC0DE
Modified: 2022-04-23 14:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
PKGBUILD for Archlinux skanlite (1.06 KB, text/plain)
2022-01-24 13:46 UTC, 0BADC0DE
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 0BADC0DE 2021-10-29 13:40:09 UTC
SUMMARY
Default focus at startup is on the "Help" button. After the first mouse-driven operation it moves to the "Close" button. So, for example, hitting enter after having done a selection on a preview leads to a program close instead of an (expected?) scan.

STEPS TO REPRODUCE
1. Start skanlite (focus is visible on the "Help" button)
2. Click on the image preview area (focus goes to "Close")
3. Hit enter

OBSERVED RESULT
The program closes.

EXPECTED RESULT
Anything else.
Very likely either preview or scan.
Reasonable action could be:
- "preview" if you haven't done anything yet
- "Scan" if you have done a preview


SOFTWARE/OS VERSIONS
Windows: n/a
macOS: n/a
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: not stated
KDE Frameworks Version: 5.87.0
Qt Version: 5.12.2

ADDITIONAL INFORMATION
Comment 1 Alexander Stippich 2021-11-02 18:39:03 UTC
Which version are you using? The focus handling has been reworked in git master or the next release of Skanlite in KDE Gear 21.12
Comment 2 0BADC0DE 2021-11-02 18:46:39 UTC
Latest in Arch Linux: 21.08.2
Comment 3 Alexander Stippich 2022-01-10 20:36:03 UTC
Is this still occuring with Skanlite 21.12?
Comment 4 0BADC0DE 2022-01-10 21:15:05 UTC
Yes. In v21.12.1 (ArchLinux package is labelled as 21.12.1-1):

1. The focus starts on the "Close" button and
2. remains there once I click on the preview area.
3. It stays on the "Close" button even after I explicitly I do a "Preview".
Comment 5 0BADC0DE 2022-01-11 07:45:27 UTC
4. It stays on "Close" even after an explicit scan.

It looks like the default action for this program is to "Close" since its very startup.
It's not clear to me the objective of that "focus handling rework".

Maybe my original "suggestion" (https://bugs.kde.org/show_bug.cgi?id=444605#c0) isn't that great but I'd say the current default action isn't either.
Comment 6 Kåre Särs 2022-01-11 16:25:28 UTC
That is strange, I'm using the KDE Gear 21.12.0, KF5 5.89.0 and Qt 5.15.3 version on KDE Neon and I can't even get the focus to the close button (Esc closes the window so not a problem).
Comment 7 Alexander Stippich 2022-01-14 19:10:45 UTC
I cannot reproduce with 21.12. either.
Focus is on the Scan button for me after a scan has finished
Comment 8 0BADC0DE 2022-01-15 09:18:43 UTC
All is confirmed.
As soon as I open the application it has the focus on "Close" and it is kept there.
If I click on "Help" or "About" buttons the focus goes there but the it returns back to "Close".
Same goes for "Preview" and "Scan".
"Reselect scanner device" and "Settings" move the focus away but it goes back to "Close" as soon as I move the focus away from the application.

Skanlite: 21.12.1 (21.12.1-1)
KDE Frameworks: 5.90.0
(I don't know how to check Qt version for this program).
Comment 9 Eric Armbruster 2022-01-20 15:38:46 UTC
I can reproduce this bug in the 21.12.

https://invent.kde.org/graphics/skanlite/-/merge_requests/28 would partially fix this bug as well by removing the close button.

In my MR I have called setAutoDefault(false); on the other buttons to prevent them from getting the focus after removing the close button. Auto default seems to be enabled by default for these buttons, see https://doc.qt.io/qt-5/qpushbutton.html#autoDefault-prop.
I guess a separate MR for libksane would be required to make Scan the default button, if this is desired.
Comment 10 0BADC0DE 2022-01-24 10:48:10 UTC
Maybe I am wrong, but the "Close" button should stay there.
It simply should never get focus automatically: the user is the only one who knows whether the task is over or not.
And she/he can communicate this by explicitly clicking on the "Close" button.
IMHO, there should be no automatic focus or focus shift.
Comment 11 Kåre Särs 2022-01-24 11:21:34 UTC
This bug is really strange!

Me and Alexander, cannot reproduce... I have tested both on Wayland and X11

Are there any Archlinux specific patches?

The button removal is mainly to get it more in line with Spectacle's UI. Alt-F4 and Ctrl-Q quits the application  and you have the normal close button on the Window, so you might not really need the separate close-button.
Comment 12 0BADC0DE 2022-01-24 11:41:11 UTC
Window button can be removed and shortcuts redefined.
Explicit button is the only guaranteed way of closing it.
Comment 13 0BADC0DE 2022-01-24 13:42:19 UTC
Eric and myself have the same issue, though.
Comment 14 0BADC0DE 2022-01-24 13:44:28 UTC
It looks like there is no patch applied by Archlinux:

https://github.com/archlinux/svntogit-packages/blob/packages/skanlite/trunk/PKGBUILD
Comment 16 0BADC0DE 2022-04-21 16:28:07 UTC
As of version 21.12.3 focus starts on the "Close" button.
If I do a preview, the focus keeps staying there.
Same if I select an area.
Hitting "Enter" just closes the application.
Focus should not stay anywhere by default: the application needs to close only on explicit user request:
- "Close" button
- Window menu --> close
- ALT+F4
- CTRL+Q
Comment 17 Eric Armbruster 2022-04-21 16:36:03 UTC
This should be fixed in 22.04 which just got released today.
Comment 18 0BADC0DE 2022-04-22 14:38:51 UTC
Version 22.04 has no "CLOSE" button and the focus is not set to any specific element in the window.
So hitting ENTER won't close the application. Good.

But now I can make skanlite not closeable by the user if the window widgets are removed and the keyboard shortcut are redefined. Bad.

IMHO, you could close this bug by just leaving the focus unspecified and still keeping the "CLOSE" button.
Comment 19 Eric Armbruster 2022-04-23 12:21:32 UTC
The close button has been removed to be consistent with Spectacle.

I do not quite understand why you see the need for an additional close button. Even if you decide to remove the close action from the window titlebar or disable the titlebar completly and remove default close shortcut Ctrl+Q, you still have the option to close by pressing the window manager shortcut (Alt+F4).

That should be more than enough options to close an application. If you manage to remove all your close options and want to close your application, well then enable at least one of them again, which you could do without problems from the shortcuts menu.
Comment 20 0BADC0DE 2022-04-23 14:44:20 UTC
Some programs have the File menu with an explicit Quit action (konsole, okular, kgpg, kcalc).
Some programs also have the "hamburger" menu button that leads also to the File menu (falkon, dolphin).
Some other have nothing but the window decorations/widgets (system settings, spectacle and (now) skanlite).
So, unless I am missing something about general KDE UI guidelines, consistency is not there.

Also because, IMHO, it can make little sense depending upon the type of user interaction.
Those programs meant to rely on user text input often have a File menu (konsole, kate).
Those meant to work on mouse and gestures don't and would requires an explicit Quit button (skanlite, system settings). 
Those meant to automatically exit after a single use don't need either (spectacle).

Finally, all keyboard shortcut can be removed/redefined: ALT+F4 (KWin: close window), CTRL+Q (Navigation: quit), CTRL+W, CTRL+ESC (File: close).
And all window decorations/widgets can be removed.
Comment 21 0BADC0DE 2022-04-23 14:45:51 UTC
Latest version 22.04 removed the Quit button altogether thus making impossible to trigger the behavior.