[System Tray] Do not send ContextMenu signal twice
ClosedPublic

Authored by kmaterka on Jul 29 2019, 11:39 AM.

Details

Summary

System Tray sends two "ContextMenu" events which breaks focus.
One is send on mouse pressed, second on mouse clicked. As a result
right click on the system tray icon causes focus to lock on the icon.
If later user clicks somewhere else event is send to the first icon.

BUG: 376277
BUG: 409768
FIXED-IN: 5.17.0

Test Plan

The best to test with Skype for Linux with SNI bridge.

To reproduce:

  • Right click on the Skype icon, click on menu item (can be Show Skype)
  • Right click on any other icon in system tray (or even any other place on the panel)
  • Skype menu will appear

After fix:

  • Right click on the Skype icon, click on menu item (can be Show Skype)
  • Right click on any other icon in system tray (or even any other place on the panel)
  • Correct menu should show

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kmaterka created this revision.Jul 29 2019, 11:39 AM
Restricted Application edited projects, added Plasma; removed Plasma: Workspaces. · View Herald TranscriptJul 29 2019, 11:39 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
kmaterka requested review of this revision.Jul 29 2019, 11:39 AM
apol added a subscriber: apol.Jul 29 2019, 11:46 AM

How will non-plasmoids (e.g. SNI) get contextMenu calls then?

Maybe the behavior must be split between PlasmoidItem and StatusNotifierItem. Ideally, all menus opened on press but that has shown to be problematic for XembedSniProxy

@apol SNI applications (including XembedSniProxy) are using StatusNotifierItem.qml, which already has onClick handled for right button. That why we had ContextMenu event's duplicated.
@broulik Yes, probably onPressed should be handled in PasmoidItem, not in the AbstractItem to avoid this kind of problems. I would personally opt for consistency, though. As far as I know GTK is showing context menu on mouse click, not pressed. The same is for MS Windows (this does not mean we must follow this or reimplement Windows, no). What is your opinion?

Yes, probably onPressed should be handled in PasmoidItem, not in the AbstractItem to avoid this kind of problems.

Indeed, that would be the best solution.

I would personally opt for consistency, though. As far as I know GTK is showing context menu on mouse click, not pressed. The same is for MS Windows (this does not mean we must follow this or reimplement Windows, no). What is your opinion?

Gimp, Firefox, Chrome, Gedit, etc, they open it on press here, and so does Qt and the rest of KDE software, so this must be consistent to here, regardless of what someone else does.

Yes, probably onPressed should be handled in PasmoidItem, not in the AbstractItem to avoid this kind of problems.

Indeed, that would be the best solution.

Should this be done together with this change? I shouldn't be hard, I can move onPressed to PlasmoidItem, which will simplify the fix also?

I would personally opt for consistency, though. As far as I know GTK is showing context menu on mouse click, not pressed. The same is for MS Windows (this does not mean we must follow this or reimplement Windows, no). What is your opinion?

Gimp, Firefox, Chrome, Gedit, etc, they open it on press here, and so does Qt and the rest of KDE software, so this must be consistent to here, regardless of what someone else does.

Oh, right! I focused on tray icons only... That makes perfect sense.

kmaterka updated this revision to Diff 62738.Jul 29 2019, 2:11 PM

I simplified the patch. It moves handling of onPressed to PlasmoidItem. This way we can have context menu when mouse is pressed for plasmoids and on click for SNI.

ngraham edited the summary of this revision. (Show Details)
ngraham edited the summary of this revision. (Show Details)Aug 15 2019, 4:05 PM
davidedmundson accepted this revision.Aug 15 2019, 4:05 PM
This revision is now accepted and ready to land.Aug 15 2019, 4:05 PM
This revision was automatically updated to reflect the committed changes.