Bug 371704

Summary: LNF Scripting contextmenu config not always works
Product: [Plasma] plasmashell Reporter: Leszek Lesner <leszek.lesner>
Component: generalAssignee: David Edmundson <kde>
Status: RESOLVED FIXED    
Severity: normal CC: bshah, notmart, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.8.2   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Leszek Lesner 2016-10-26 09:45:29 UTC
The configuration of the contextmenu in scripting (used in LNF) does not always produce the correct contextmenu. 
This is the layout.js used by the LNF theme: https://github.com/maui-artwork/artwork-lookandfeel-maui/blob/master/org.kde.maui.desktop/contents/layouts/org.kde.plasma.desktop-layout.js

There seems to be a race condition. Some times the menu customization works just fine other times it just does not work at all. 

Plasma 5.8.2 on Qt 5.7.0
Comment 1 Marco Martin 2016-10-31 16:50:20 UTC
a still not pushed solution is at
https://phabricator.kde.org/D3166
Comment 2 David Edmundson 2016-11-01 10:38:20 UTC
and I will continue to block it. 
It fails to understand the problem, and fails to solve it.
Comment 3 Marco Martin 2016-11-01 12:26:33 UTC
tought about it, found an api that is maybe not too much invasive, but still think that for 5.8 a retrocompatible fix should be done, unless Leszek is ok to adapt the api on the fly.
(a fix for Maui is quite urgent i think)
An api that may make sense and not be too much invasive may be:
* to Containment (the scripting wrapper) add the property actionPluginsConfig, that is an instance of type ConfigGroup
* at that point, it's used exactly as the current script in maui
* but then we know it's exactly that group has been touched, so we know when to reload containment actions or not, instead of shooting blindly

the javascript would change from

var actionPlugins = ConfigFile("plasma-org.kde.plasma.desktop-appletsrc", "ActionPlugins");
var actionPluginsDesktop = ConfigFile(actionPlugins,"0");
actionPluginsDesktop.writeEntry("MidButton;NoModifier", "org.kde.paste");
actionPluginsDesktop.writeEntry("RightButton;NoModifier", "org.kde.contextmenu");
actionPluginsDesktop.writeEntry("wheel:Vertical;NoModifier", "org.kde.switchdesktop");
   
var rightButton = ConfigFile(actionPluginsDesktop,"RightButton;NoModifier");
rightButton.writeEntry("_add panel", "true");
...

to

var actionPluginsDesktop = containment.actionPluginsConfig
actionPluginsDesktop.writeEntry("MidButton;NoModifier", "org.kde.paste");
actionPluginsDesktop.writeEntry("RightButton;NoModifier", "org.kde.contextmenu");
actionPluginsDesktop.writeEntry("wheel:Vertical;NoModifier", "org.kde.switchdesktop");
   
var rightButton = ConfigFile(actionPluginsDesktop,"RightButton;NoModifier");
rightButton.writeEntry("_add panel", "true");
...
Comment 4 Marco Martin 2016-11-01 13:04:42 UTC
Another proposed way could be https://phabricator.kde.org/D3220

what should change is that the whole part about setting the containment actions should be moved in a different javascript file, org.kde.plasma.desktop-prelayout.js.
Leszek, would you be ok with that?
Comment 5 David Edmundson 2016-11-03 20:25:19 UTC
Git commit b9760e852042fb113caef8ad547967b98cfdd32a by David Edmundson.
Committed on 03/11/2016 at 20:24.
Pushed by davidedmundson into branch 'Plasma/5.8'.

Introduce new pre-layout script hook

Summary:
layout.js used to be run before any containments were added. This was
broken in a697d291 which creates desktop containments for that activity
first.

However, some scripts rely on being able to alter global configuration
before any containments are loaded.

In order to allow the same functionality we need to provide a new hook
for whatever these scripts may need to do.

Test Plan: Not done yet.

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: apol, mart, plasma-devel

Tags: #plasma

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

M  +25   -1    shell/shellcorona.cpp

http://commits.kde.org/plasma-workspace/b9760e852042fb113caef8ad547967b98cfdd32a