Bug 407843 - Rectangle Region Selection doesn't get focused if a right click menu is opened during the delay
Summary: Rectangle Region Selection doesn't get focused if a right click menu is opene...
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 19.04.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
: 421491 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-05-22 20:08 UTC by nyanpasu64
Modified: 2022-12-07 11:46 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 23.04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nyanpasu64 2019-05-22 20:08:56 UTC
SUMMARY
If I tell Spectacle to capture "Rectangular Region" with a delay, but open a Qt menu (eg. right-click a window title bar), I cannot press Enter or Esc to escape the full-screen capture.

STEPS TO REPRODUCE
1. Open Spectacle, select Area: "Rectangular Region", with Delay: "1 second" or so.
2. Click "Take a New Screenshot".
3. Right-click a window title bar during the countdown.

OBSERVED RESULT
- The full-screen region takes 1 click to focus, before it allows dragging to select a region. 
- Even after dragging, Enter/Esc do not work to exit the region.
- Double-clicking works, but I didn't know that at the time, instead resorting to alt+tabbing to a terminal and `killall spectacle`.

EXPECTED RESULT
The full-screen region allows drag-select-a-region without clicking once to focus.
- Enter or Esc close the full-screen mode as usual.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Manjaro
(available in About System)
KDE Plasma Version: 5.15.5
KDE Frameworks Version: 5.57.0
Qt Version: 5.12.3
spectacle 19.04.1 - A Dearth of Dank Memes [what is this name even]

ADDITIONAL INFORMATION

This is the same issue as an old KSnapshot bug https://bugs.kde.org/show_bug.cgi?id=210916 (closed as UNMAINTAINED).
Unlike https://bugs.kde.org/show_bug.cgi?id=374009#c3 , this bug has not been fixed.
Comment 1 Nate Graham 2019-05-24 20:36:51 UTC
Aaargh, seems like Bug 374009 is back again...
Comment 2 David Redondo 2019-06-05 14:42:21 UTC
Hmm this is weird. It seems that showing the QuickEditor closes the right click menu (maybe because it itself is another popup?) and focus goes back to the app the right click menu belonged to but does not go to the quickeditor. Clicking gets us the mouse focus but not the keyboard focus.
 Steps to see this:
1. Open a text file
2. Take a screenshot with delay  
3. Right click into the text editor or on it's titlebar or taskmanager entry
4. When the QuickEditor shows press some keys
5. Close the QuickEditor (by killing spetcacle or double clicking with a region selected)
Comment 3 David Redondo 2019-06-05 14:51:40 UTC
Seems I was wrong and pressed some keys that closed the overlay. In fact if the right click menu has multiple levels you can still use it.
Comment 4 David Redondo 2019-06-05 15:30:23 UTC
Well, I have a hack to fix this. If we grab the keyboard when we regain the mouse focus we successfully get it otherwise not. To see this https://phabricator.kde.org/P399. If you click before the mask turns yellow we get the keyboard focus otherwise not.
So the hack I propose would be to add grabKeyboard() to QuickEditor::mousePressEvent inside case MouseState::Outside: since this is always the first mouseState.
Comment 5 Nate Graham 2019-06-21 14:29:44 UTC
FWIW git bisect says that this broke with https://phabricator.kde.org/D12626.
Comment 6 David Redondo 2019-06-21 14:35:19 UTC
Git commit ab896620463be15bc575c833f5abfcdb63178a36 by David Redondo.
Committed on 21/06/2019 at 14:35.
Pushed by davidre into branch 'master'.

Grab the Keyboard on the first user click

Summary:
If we enter the region selection when a right click menu is opened we lose focus.
Which is bad because not every user knows about double click to take the
screenshot and can't exit anymore. We get the mouse back when the user clicks
and only can grab the keyboard if we have the mouse already. So just grab it
unconditionally if we get a mouse event. The user still has to do one more click
than normal but can now exit/take the picture via keyboard.

Test Plan:
- Open Rectangular Region Mode with a delay
- Right click during the delay
- Press escape to exit Spectacle

Reviewers: #spectacle, davidedmundson, ngraham

Reviewed By: #spectacle, ngraham

Subscribers: ngraham

Tags: #spectacle

Differential Revision: https://phabricator.kde.org/D21964

M  +6    -0    src/QuickEditor/QuickEditor.cpp

https://commits.kde.org/spectacle/ab896620463be15bc575c833f5abfcdb63178a36
Comment 7 signupemail 2019-11-04 22:12:33 UTC
I think I have this problem, occasionally, on Spectacle 17.12.3, on Linux Mint 19.2.

At any rate, sometimes the program get stuck in the rectangle drawing mode and, in order to regain control of the computer I need to open a tty and kill Spectacle. Cf. perhaps #394499.
Comment 8 David Redondo 2019-11-05 09:15:56 UTC
(In reply to signupemail from comment #7)
> I think I have this problem, occasionally, on Spectacle 17.12.3, on Linux
> Mint 19.2.
> 
> At any rate, sometimes the program get stuck in the rectangle drawing mode
> and, in order to regain control of the computer I need to open a tty and
> kill Spectacle. Cf. perhaps #394499.
The issue that you're experiencing is probably not related to this bug. Please note that you are using an almost two year old version that will not get bugfixes anymore. In fact this bug was bisected to a commit that happened after 17.12.3 was released!
Comment 9 signupemail 2019-11-05 09:18:07 UTC
Thank you. Is there any way I get a newer build, aside from (1) awaiting the next big release of my OS (Mint) - for then the repositories will get updated or (2) compiling from source? I suppose I might consider 2.
Comment 10 David Redondo 2019-11-05 09:32:31 UTC
Aside from compiling you could try to install the nightly flatpak (see https://community.kde.org/Guidelines_and_HOWTOs/Flatpak). It isn't super well tested but it should work in priniciple.
Comment 11 signupemail 2019-11-05 09:53:39 UTC
Well, that seemed rather wonderful (and thank you for your time) but the program will not run.

I installed as follows.

$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
~ $ flatpak remote-add --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo
~ $ flatpak install kdeapps org.kde.spectacle
Required runtime for org.kde.spectacle/x86_64/master (runtime/org.kde.Platform/x86_64/5.12) found in remote flathub
Do you want to install it? [y/n]:     
Do you want to install it? [y/n]: y
Installing in system:
org.kde.Platform/x86_64/5.12           flathub 5539ccd35690
org.kde.Platform.Locale/x86_64/5.12    flathub b4cd61e0b3cc
org.kde.spectacle/x86_64/master        kdeapps f97bf4e91c56
  permissions: ipc, wayland, x11
  file access: xdg-config/kdeglobals:ro, xdg-run/dconf, ~/.config/dconf:ro
  dbus access: com.canonical.AppMenu.Registrar, org.kde.KWin, org.kde.kglobalaccel
  tags: nightly
org.kde.spectacle.Locale/x86_64/master kdeapps 959c071d29e8
Is this ok [y/n]: y
Installing: org.kde.Platform/x86_64/5.12 from flathub
[####################] 717 metadata, 15773 content objects fetched; 147856 KiB transferred in 39 secon
Now at 5539ccd35690.
Installing: org.kde.Platform.Locale/x86_64/5.12 from flathub
[####################] 3 metadata, 1 content objects fetched; 16 KiB transferred in 0 seconds
Now at b4cd61e0b3cc.
Installing: org.kde.spectacle/x86_64/master from kdeapps
[####################] 70 metadata, 97 content objects fetched; 690 KiB transferred in 1 seconds
Now at f97bf4e91c56.
Installing: org.kde.spectacle.Locale/x86_64/master from kdeapps
[####################] 3 metadata, 1 content objects fetched; 2 KiB transferred in 0 seconds
Now at 959c071d29e8.


Then I tried to run spectacle via GUI and nothing happened. So I found the relevant command and this is what happened:
$ /usr/bin/flatpak run --branch=master --arch=x86_64 --command=qdbus org.kde.spectacle org.kde.Spectacle / 
Service 'org.kde.Spectacle' does not exist.

Perhaps I should have added only one of those repositories.
Comment 12 David Redondo 2019-11-05 10:01:14 UTC
$ flatpak run org.kde.spectacle
works here
Comment 13 signupemail 2019-11-05 10:10:37 UTC
That commmand works for me (though it does spew a few lines of errors onto the terminal). It's a shame that the launcher (or whatever it is called) got set up with the wrong command. Thank you for your help.

One more thing though, if I may: I don't want this nightly updating all the time, and I read that there was a 'flatpak mask' command. But there appears not to be. And I don't want to globally disable flatpak updates.
Comment 14 David Redondo 2019-11-05 10:12:44 UTC
Sorry I'm not that well versed in flatpak. I just made sure that it could talk to KWin for screenshots and kglobalaccel for shortcuts.
Comment 15 David Redondo 2020-05-14 07:28:01 UTC
*** Bug 421491 has been marked as a duplicate of this bug. ***
Comment 16 Antonio Prcela 2021-02-09 22:04:22 UTC
Enter or Esc do work
Only this can be reproduced:

- The full-screen region takes 1 click to focus, before it allows dragging to select a region.
Comment 17 Noah Davis 2022-12-07 11:46:13 UTC
Git commit 9d4ffdf70e5a29fa9105cbf8c4f7e1ddca9e377a by Noah Davis.
Committed on 07/12/2022 at 11:46.
Pushed by ndavis into branch 'master'.

Port and rework UI for Qt Quick/QML

There are still some parts that use Qt Widgets, such as the settings dialog, font dialog, color dialog, print dialog and popup menus. The Qt Quick port is needed for a future patch where screen recording will be added and it also allows more animations to be used. The UI was redesigned, partly because the old UI couldn't be ported nicely to QML and partly to improve the appearance of the UI.

There are 2 window classes for the main UIs. CaptureWindow is used for the rectangle capture mode and ViewerWindow is used for the other modes and viewing accepted regions from the rectangle capture mode. Both UIs support adding annotations.

Fullscreen Capture UI:

The UI is a lot like the old UI, but there are floating toolbars that expose more functionality.

- Annotations, saving, copying and taking a new snapshot can be done directly.
- Export, Options and Help menus can be accessed directly.
- Info box no longer covers or overlaps with selection handles.
- Antialiasing for selection handles is fixed.
- Each screen now has its own fullscreen window, which fixes some issues on Wayland and X11.

Image Viewer UI (appears after a screenshot has been taken):

- Main controls are consolidated into a single top toolbar: Save, Save As, Copy, Export (opens popup menu), Show Annotation Tools, Configure (opens settings dialog), Help (opens popup menu)
- There is a right sidebar for selecting capture modes and related options that were in the old UI.
- The whole UI doesn't completely transform when annotation controls are shown anymore. Instead, a vertical left side toolbar (tools) and a bottom toolbar (tool options) are added and the right sidebar slides away. Undo and Redo are added to the top toolbar.
- It should be easier to understand the annotation UI now.
- Annotations done in the Fullscreen Capture UI can still be undone/redone in the Image Viewer UI.

No screenshot taken UI (appears when configured to start without taking a screenshot):

- Has buttons for each capture mode on the left
- Has all the other options that were in the Image Viewer UI sidebar and the old UI on the right
- Has buttons for opening the settings dialog and showing the help menu below the options.
- The heading can be used to drag the window just to make moving the dialog around a bit more convenient.

The kImageAnnotator library was replaced by a custom annotation system because kImageAnnotator only worked with Qt Widgets and can't work in the rectangle capture mode since it has its own UI.

There is some unused code in this patch that is meant for the upcoming video recording feature.
Related: bug 425311, bug 425853, bug 427117, bug 429141, bug 431278, bug 437495, bug 451838, bug 456399, bug 458956, bug 460689, bug 462521
FIXED-IN: 23.04

---

| Fullscreen Capture UI |
|-----------------------|
| ![Screenshot_20221207_052432](/uploads/0a1a94987c80f831ef8ce65e29258797/Screenshot_20221207_052432.png) |

| Image Viewer UI |
|-----------------|
| ![Screenshot_20221207_052647](/uploads/05b9e19702c030228c21fb816af08ee4/Screenshot_20221207_052647.png) |

| No Screenshot UI |
|-----------------|
| ![Screenshot_20221207_053432](/uploads/9d97d6642d050ad84a14bf39f5a914db/Screenshot_20221207_053432.png) |

| Image Viewer Annotations |
|--------------------------|
| ![Screenshot_20221207_052825](/uploads/a8a7ffb4844fa0556eeeee4a979e85dd/Screenshot_20221207_052825.png) |

| Export Menu |
|-------------|
| ![Screenshot_20220823_141330](/uploads/3117057d424b66ae84f84648030912a8/Screenshot_20220823_141330.png) |

| Options Menu |
|--------------|
| ![Screenshot_20220823_141058](/uploads/05f0589b01ae61a90540d1dd6ba154ae/Screenshot_20220823_141058.png) |

| Help Menu |
|-----------|
| ![Screenshot_20220823_141353](/uploads/2f8173dd31cc0ef5c6c598ae6f5bb088/Screenshot_20220823_141353.png) |

| Annotation Options (sections are hidden based on what the active tool can use) |
|--------------------|
| ![Screenshot_20221207_053046](/uploads/ded7a02e8f68d659377abb5d9dc43b11/Screenshot_20221207_053046.png)![Screenshot_20221207_053136](/uploads/c11b21ce6762a7d287ae3e421762bb10/Screenshot_20221207_053136.png) |

M  +5    -18   CMakeLists.txt
A  +33   -0    resources.qrc
M  +20   -31   src/CMakeLists.txt
A  +139  -0    src/CaptureModeModel.cpp     [License: LGPL(v2.0+)]
A  +60   -0    src/CaptureModeModel.h     [License: LGPL(v2.0+)]
M  +10   -10   src/ExportManager.cpp
M  +6    -5    src/ExportManager.h
A  +38   -0    src/Gui/AnimatedLoader.qml     [License: LGPL(v2.0+)]
A  +287  -0    src/Gui/AnnotationOptionsToolBarContents.qml     [License: LGPL(v2.0+)]
A  +1406 -0    src/Gui/Annotations/AnnotationDocument.cpp     [License: LGPL(v2.0+)]
A  +288  -0    src/Gui/Annotations/AnnotationDocument.h     [License: LGPL(v2.0+)]
A  +43   -0    src/Gui/Annotations/AnnotationEditor.qml     [License: LGPL(v2.0+)]
A  +254  -0    src/Gui/Annotations/AnnotationViewport.cpp     [License: LGPL(v2.0+)]
A  +66   -0    src/Gui/Annotations/AnnotationViewport.h     [License: LGPL(v2.0+)]
A  +919  -0    src/Gui/Annotations/EditAction.cpp     [License: LGPL(v2.0+)]
A  +256  -0    src/Gui/Annotations/EditAction.h     [License: LGPL(v2.0+)]
A  +282  -0    src/Gui/Annotations/ResizeHandles.qml     [License: LGPL(v2.0+)]
A  +45   -0    src/Gui/Annotations/SelectionBackground.qml     [License: LGPL(v2.0+)]
A  +207  -0    src/Gui/Annotations/TextTool.qml     [License: LGPL(v2.0+)]
A  +86   -0    src/Gui/Annotations/Utils.cpp     [License: LGPL(v2.0+)]
A  +13   -0    src/Gui/Annotations/Utils.h     [License: LGPL(v2.0+)]
A  +152  -0    src/Gui/AnnotationsToolBarContents.qml     [License: LGPL(v2.0+)]
A  +101  -0    src/Gui/ButtonGrid.qml     [License: LGPL(v2.0+)]
D  +0    -176  src/Gui/CaptureAreaComboBox.cpp
D  +0    -55   src/Gui/CaptureAreaComboBox.h
A  +133  -0    src/Gui/CaptureOptionsSidebarContents.qml     [License: LGPL(v2.0+)]
A  +236  -0    src/Gui/CaptureWindow.cpp     [License: LGPL(v2.0+)]
A  +58   -0    src/Gui/CaptureWindow.h     [License: LGPL(v2.0+)]
A  +27   -0    src/Gui/CopiedMessage.qml     [License: LGPL(v2.0+)]
A  +138  -0    src/Gui/DelaySpinBox.qml     [License: LGPL(v2.0+)]
A  +232  -0    src/Gui/DialogPage.qml     [License: LGPL(v2.0+)]
A  +23   -0    src/Gui/EmptyPage.qml     [License: LGPL(v2.0+)]
M  +84   -16   src/Gui/ExportMenu.cpp
M  +7    -9    src/Gui/ExportMenu.h
A  +13   -0    src/Gui/FloatingBackground.qml     [License: LGPL(v2.0+)]
A  +40   -0    src/Gui/FloatingToolBar.qml     [License: LGPL(v2.0+)]
A  +72   -0    src/Gui/HelpMenu.cpp     [License: LGPL(v2.0+)]
A  +25   -0    src/Gui/HelpMenu.h     [License: LGPL(v2.0+)]
A  +420  -0    src/Gui/ImageCaptureOverlay.qml     [License: LGPL(v2.0+)]
A  +495  -0    src/Gui/ImageView.qml     [License: LGPL(v2.0+)]
A  +21   -0    src/Gui/InlineMessage.qml     [License: LGPL(v2.0+)]
D  +0    -86   src/Gui/KSImageWidget.cpp
D  +0    -44   src/Gui/KSImageWidget.h
D  +0    -714  src/Gui/KSMainWindow.cpp
D  +0    -116  src/Gui/KSMainWindow.h
D  +0    -363  src/Gui/KSWidget.cpp
D  +0    -105  src/Gui/KSWidget.h
A  +67   -0    src/Gui/Magnifier.qml     [License: LGPL(v2.0+)]
A  +158  -0    src/Gui/MainToolBarContents.qml     [License: LGPL(v2.0+)]
A  +269  -0    src/Gui/OptionsMenu.cpp     [License: LGPL(v2.0+)]
A  +62   -0    src/Gui/OptionsMenu.h     [License: LGPL(v2.0+)]
D  +0    -61   src/Gui/ProgressButton.cpp
D  +0    -29   src/Gui/ProgressButton.h
A  +10   -0    src/Gui/SavedAndCopiedMessage.qml     [License: LGPL(v2.0+)]
A  +10   -0    src/Gui/SavedAndLocationCopied.qml     [License: LGPL(v2.0+)]
A  +31   -0    src/Gui/SavedMessage.qml     [License: LGPL(v2.0+)]
A  +21   -0    src/Gui/ScreenshotFailedMessage.qml     [License: LGPL(v2.0+)]
A  +303  -0    src/Gui/Selection.cpp     [License: LGPL(v2.0+)]
A  +134  -0    src/Gui/Selection.h     [License: LGPL(v2.0+)]
A  +918  -0    src/Gui/SelectionEditor.cpp     [License: LGPL(v2.0+)]
A  +131  -0    src/Gui/SelectionEditor.h     [License: LGPL(v2.0+)]
M  +2    -2    src/Gui/SettingsDialog/GeneralOptions.ui
M  +5    -5    src/Gui/SettingsDialog/SaveOptionsPage.cpp
M  +9    -0    src/Gui/SettingsDialog/SettingsDialog.cpp
M  +1    -0    src/Gui/SettingsDialog/SettingsDialog.h
M  +3    -3    src/Gui/SettingsDialog/settings.kcfgc
M  +108  -22   src/Gui/SettingsDialog/spectacle.kcfg
A  +22   -0    src/Gui/ShareErrorMessage.qml     [License: LGPL(v2.0+)]
A  +29   -0    src/Gui/SharedMessage.qml     [License: LGPL(v2.0+)]
A  +99   -0    src/Gui/ShortcutsTextBox.qml     [License: LGPL(v2.0+)]
A  +29   -0    src/Gui/SizeLabel.qml     [License: LGPL(v2.0+)]
A  +70   -0    src/Gui/SpectacleImageProvider.cpp     [License: LGPL(v2.0+)]
A  +18   -0    src/Gui/SpectacleImageProvider.h     [License: LGPL(v2.0+)]
A  +42   -0    src/Gui/SpectacleMenu.cpp     [License: LGPL(v2.0+)]
A  +32   -0    src/Gui/SpectacleMenu.h     [License: LGPL(v2.0+)]
A  +499  -0    src/Gui/SpectacleWindow.cpp     [License: LGPL(v2.0+)]
A  +121  -0    src/Gui/SpectacleWindow.h     [License: LGPL(v2.0+)]
A  +57   -0    src/Gui/UndoRedoGroup.qml     [License: LGPL(v2.0+)]
A  +204  -0    src/Gui/ViewerWindow.cpp     [License: LGPL(v2.0+)]
A  +65   -0    src/Gui/ViewerWindow.h     [License: LGPL(v2.0+)]
M  +5    -5    src/Main.cpp
M  +14   -9    src/Platforms/Platform.h
M  +38   -13   src/Platforms/PlatformKWinWayland.cpp
M  +5    -0    src/Platforms/PlatformKWinWayland.h
M  +28   -7    src/Platforms/PlatformKWinWayland2.cpp
M  +4    -0    src/Platforms/PlatformKWinWayland2.h
M  +28   -13   src/Platforms/PlatformXcb.cpp
M  +4    -3    src/Platforms/PlatformXcb.h
D  +0    -29   src/QuickEditor/ComparableQPoint.h
D  +0    -1042 src/QuickEditor/QuickEditor.cpp
D  +0    -140  src/QuickEditor/QuickEditor.h
A  +15   -0    src/ScreenImage.h     [License: LGPL(v2.0+)]
D  +0    -20   src/SpectacleCommon.h
M  +541  -303  src/SpectacleCore.cpp
M  +93   -41   src/SpectacleCore.h
M  +5    -6    src/SpectacleDBusAdapter.cpp
M  +3    -1    tests/CMakeLists.txt
M  +5    -5    tests/FilenameTest.cpp

https://invent.kde.org/graphics/spectacle/commit/9d4ffdf70e5a29fa9105cbf8c4f7e1ddca9e377a