Commit Graph

184 Commits (28d7b3c563e3e153ad41a8755503a605921c05ad)

Author SHA1 Message Date
Script Kiddy 2141dc821b SVN_SILENT made messages (.desktop file) 2012-10-16 18:43:37 +02:00
Script Kiddy 5b5f20581a SVN_SILENT made messages (.desktop file) 2012-09-24 11:20:52 +02:00
Reza Shah 211fdfde4a Merge branch 'KDE/4.9'
Conflicts:
	kcontrol/access/kcmaccess.desktop
	kcontrol/autostart/autostart.desktop
	kcontrol/colors/colors.desktop
	kcontrol/dateandtime/clock.desktop
	kcontrol/desktoppaths/desktoppath.desktop
	kcontrol/fonts/fonts.desktop
	kcontrol/hardware/joystick/joystick.desktop
	kcontrol/keys/keys.desktop
2012-09-23 20:06:44 +09:00
Script Kiddy a916d99ada SVN_SILENT made messages (.desktop file) 2012-09-22 17:37:32 +02:00
Thomas Lübking 24cf0e75f3 Merge branch 'KDE/4.9'
Conflicts:
	kwin/scene.cpp
	plasma/generic/applets/batterymonitor/metadata.desktop
	plasma/generic/applets/lock_logout/metadata.desktop
2012-09-19 20:21:18 +02:00
Thomas Lübking cb265d96fc Sync script loading, KConfGroup is not thread safe
REVIEW: 106377
BUG: 305361
FIXED-IN: 4.9.2
2012-09-19 20:16:34 +02:00
Martin Gräßlin 3aee94d798 Merge branch 'KDE/4.9'
Conflicts:
	ksysguard/gui/ksysguard.desktop
	kwin/effects/translucency/translucency.cpp
2012-09-07 07:59:10 +02:00
Martin Gräßlin 2764565f9d Allow Scripts to add menus to the UserActionsMenu
A script can register a callback through registerUserActionsMenu to be
informed when the UserActionsMenu is about to be shown. This menu calls
the Scripting component to gather actions to add to a Scripts submenu.

The Scripting component now asks all scripts for the actions, which will
invoke the registered callbacks with the Client for which the menu is to
be shown as argument.

The callback is supposed to return a JSON structure describing how the
menu should look like. The returned object can either be a menu item or
a complete menu. If multiple menu items or menus are supposed to be added
by the script it should just register multiple callbacks.

The structure for an item looks like the following:
{
    text: "My caption",
    checkable: true,
    checked: false,
    triggered: function (action) {
       print("The triggered action as parameter");
    }
}

The structure for a complete menu looks quite similar:
{
    text: "My menu caption",
    items: [
         {...}, {...} // items as described above
    ]
}

The C++ part of the script parses the returned object and generates
either QAction or QMenu from it. All objects become children of the
scripts QMenu provided by the UserActionsMenu.

Before the menu is shown again the existing menu is deleted to ensure
that no outdated values from no longer existing scripts are around. This
means the scripts are queried each time the menu is shown.

FEATURE: 303756
FIXED-IN: 4.10
REVIEW: 106285
2012-09-07 07:32:00 +02:00
Martin Gräßlin b92557a0af Return displayHeight for property displayHeight and not displayWidth
Typo in the scripting bindings.

BUG: 306225
FIXED-IN: 4.9.2
2012-09-04 06:26:39 +02:00
Script Kiddy 61d565885a SVN_SILENT made messages (.desktop file) 2012-08-11 12:40:05 +02:00
Script Kiddy 9c40152c03 SVN_SILENT made messages (.desktop file) 2012-08-10 17:29:15 +02:00
Thomas Lübking 498783c66b move KServiceTypeTrader::query() to main thread
KConfigGroup is not the least thread safe and unfortunately
the KServiceTypeTrader::self()->query() will in doubt create
one if the sycoca database was damaged.

BUG: 303713
REVIEW: 105608
(cherry picked from commit e3edcbcf66b324febcc2014ca4c1fbfa383d8972)
2012-07-21 19:59:36 +02:00
Script Kiddy b909bdc5c4 SVN_SILENT made messages (.desktop file) 2012-07-21 11:43:56 +02:00
Script Kiddy 88710b0f60 SVN_SILENT made messages (.desktop file) 2012-07-19 10:14:19 +02:00
Guy Maurel dcf33ff419 missing include
Cherry-Picked from cb90b1e6a1125d41b55a7a608b1d917f84306070
BUG: 303630
FIXED-IN: 4.9.0
REVIEW: 105522
2012-07-19 07:11:45 +02:00
Script Kiddy 6c572929d8 SVN_SILENT made messages (.desktop file) 2012-07-18 10:04:35 +02:00
Script Kiddy d79989b162 SVN_SILENT made messages (.desktop file) 2012-07-16 11:12:26 +02:00
Script Kiddy 825a9c4f6e SVN_SILENT made messages (.desktop file) 2012-07-09 11:17:38 +02:00
Martin Gräßlin 4423b961a5 Fix incorrect connects of Activities in WorkspaceWrapper
Remember: a compiling connect does not mean it is correct.

BUG: 303200
FIXED-IN: 4.9.0
REVIEW: 105480
2012-07-09 06:31:58 +02:00
Script Kiddy 11788e8b6f SVN_SILENT made messages (.desktop file) 2012-07-06 10:16:34 +02:00
Martin Gräßlin d2a9199cd9 Support for calling D-Bus methods from scripts
A new global method is exported to perform a remote method call
through D-Bus. The call is always performed async invoking a
callback once the call completed passing through the arguments
received from D-Bus.

Possible code looks like the following:
callDBus("org.kde.kwin", "/KWin", "org.kde.KWin", "currentDesktop", function (desktop) {
  print("Current Desktop through D-Bus: ", desktop);
});

REVIEW: 105396
2012-07-05 15:19:42 +02:00
Martin Gräßlin 30bb8be037 Add activity support to Workspace Script Wrapper and Effects
New properties for the current activity and the available
activities plus related signals in scripts. Signals added to
effects.

BUG: 302060
FIXED-IN: 4.9.0
2012-06-24 18:35:56 +02:00
Martin Gräßlin bc1b769d7f Export a getClient method to Scripting bindings
Finds a Client by windowId.

REVIEW: 105323
2012-06-24 18:32:41 +02:00
Script Kiddy f305f0eee4 SVN_SILENT made messages (.desktop file) 2012-06-18 10:12:23 +02:00
Script Kiddy 73c4b48c18 SVN_SILENT made messages (.desktop file) 2012-06-17 11:39:36 +02:00
Script Kiddy c1f8590216 SVN_SILENT made messages (.desktop file) 2012-06-15 12:12:07 +02:00
Script Kiddy 953d088b6a SVN_SILENT made messages (.desktop file) 2012-06-12 17:07:51 +02:00
Thomas Lübking a56a64125a fix private slot name in connect
BUG: 301365
FIXED-IN: 4.9b2
REVIEW: 105174
2012-06-07 18:22:09 +02:00
Andre Woebbeking 6cde471ec8 -pedantic 2012-06-07 00:38:13 +02:00
Thomas Lübking 3b6d52549d don't use kconfiggroup in threaded script loading at all
BUG: 300934
FIXED-IN: 4.9
REVIEW: 105128
2012-06-02 09:33:25 +02:00
Script Kiddy e999536c83 SVN_SILENT made messages (.desktop file) 2012-05-29 17:01:37 +02:00
Script Kiddy 62211420c7 SVN_SILENT made messages (.desktop file) 2012-05-28 11:08:19 +02:00
Martin Gräßlin 36932d3f2e Reload scripts after saving in scripts KCM
DBus call to start scripting again. This should adjust the
state of loaded scripts to the saved selection in the
KPluginSelector.

REVIEW: 104876
2012-05-17 21:28:10 +02:00
Script Kiddy 606e40f26b SVN_SILENT made messages (.desktop file) 2012-05-16 10:00:04 +02:00
Martin Gräßlin c9c4e020e2 Screen Edge bindings for Scripts and Scripted Effects
ScreenEdge is changed to emit a signal whenever a screen edge
got activated without an action or effect taking care of it.

A Script can reserve one to many callbacks for an edge and the
callback get's triggered whenever the signal is emitted. On
deconstruction of the Script the edge is unreserved again.

FEATURE: 299275
FIXED-IN: 4.9.0
REVIEW: 104904
2012-05-15 17:54:31 +02:00
Script Kiddy 7c8aa660d1 SVN_SILENT made messages (.desktop file) 2012-05-15 16:43:40 +02:00
Martin Gräßlin 895af61e47 Add missing Q_UNUSED
SVN_SILENT
2012-05-10 21:03:35 +02:00
Martin Gräßlin f3443a6b07 Add CMake variable to rename kwin binaries
A CMake variable is used to specify the name of the binary.
By default this is "kwin" but building for PA changes the
name to "kwinactive". The variable adjusts all names, e.g.
kwinnvidiahack becomes kwinactivenvidiahack.

The remaining usage of kwinrc in core and libs is replaced
by a cmakedefine for the configuration name and all data
installations are moved to the defined name. Dynamic loading
for scripts & co is adjusted for loading based on defined name.

This change allows the side-by-side installation of both kwin
for desktop and kwin for Plasma Desktop without the known
issues like conflicts in config files or missing build options
if kwin desktop is used for Plasma Active.

Likewise the KCMs are not adjusted as they are not intended to
be used for kwinactive.

REVIEW: 104299
BUG: 296084
FIXED-IN: 4.9.0
CCMAIL: active@kde.org
2012-05-10 10:25:15 +02:00
Martin Gräßlin 1f97345e35 Asserts for KWin scripts
Further debugging functionality for KWin scripts. Added assert
methods validate the to be tested parameter and throw a script
error if the value is not valid.

Following methods are available:
* assert(value)
* assertTrue(boolean)
* assertFalse(boolean)
* assertEquals(expected, actual)
* assertNull(nullValue)
* assertNotNull(notNullValue)

All methods take an additional optional parameter which is used
as the error message if provided.

Methods to validate the number of arguments and types of the
parameters are added and throw syntax or type errors.

REVIEW: 104870
2012-05-10 10:00:54 +02:00
Martin Gräßlin c3fce865ee Unload script on end execution and error
A ScriptEngineAgent is added to monitor the execution of a
script. If it ends it stops the script to free resources.

The same is done in case of an exception, just that in this
case the script takes care of unloading itself.

REVIEW: 104871
2012-05-10 09:58:59 +02:00
Martin Gräßlin 54ecbc6b6a Ensure declarative view gets deleted when script is unloaded
Using a scoped pointer to ensure that the view is deleted in
the DeclarativeScript's dtor.

REVIEW: 104846
2012-05-06 12:57:10 +02:00
Thomas Lübking e274c297b9 fix threaded queryScriptsToLoad()
REVIEW: 104866
2012-05-06 12:24:32 +02:00
Thomas Lübking a332bf183b add desktopChanged signal to effects that carries the optionally changing widget
CCBUG: 213847
FIXED-IN: 4.9
2012-05-03 22:56:27 +02:00
Script Kiddy 3dab9470e1 SVN_SILENT made messages (.desktop file) 2012-05-03 11:06:49 +02:00
Script Kiddy be7573445a SVN_SILENT made messages (.desktop file) 2012-05-01 17:26:20 +02:00
Martin Gräßlin abd3808574 Read KWin Script from file moved into thread
The I/O intensive reading of the complete KWin Script
file into a QByteArray is moved into a thread.

Evaluating and setting up the script engine is still
performed in the main thread.

REVIEW: 104782
2012-04-29 22:23:44 +02:00
Martin Gräßlin 6cbdfd3cd5 Move KServiceTypeTrader query for Scripts into a thread
Searching for the scripts to load is performed in an own
thread including unloading of already loaded scripts which
no longer should be loaded.

To ensure that two threads are not trying to load/unload
at the same time a mutex is added to protect the list of
loaded scripts.

REVIEW: 104768
2012-04-29 22:23:44 +02:00
Martin Gräßlin be55ac5c60 Introduce post Workspace init phase
Workspace emits a signal when the initialization finished and
interested parties can connect to this signal to perform post
init actions. That is everything that does not have to be
performed to have a completely working Window Manager.

As an example loading the scripts is moved into this post init
phase.

REVIEW: 104580
2012-04-27 19:02:21 +02:00
Mathias Gottschlag 1d2e3aa327 Let kwin scripts add dynamic properties to client objects.
This enables the script wrapper objects to automatically create new
dynamic properties for Client objects so that scripts can register custom
properties.

REVIEW: 104697
2012-04-24 17:42:16 +02:00
Martin Gräßlin 7073b0af40 Export workspace as global property on ScriptEngine in QML bindings
If workspace is exported as a context property there seem to be
issues with the signals which are not bound to a property of
WorkspaceWrapper.

This problems seems to be fixable by exporting the workspace
property as a global property on the script engine.

As a side-effect this also resolves the issue with the clientList,
so we can drop the hack again.

REVIEW: 104682
2012-04-21 15:34:37 +02:00
Martin Gräßlin 175668f2b3 Unexport TabGroup property on Client for scripts
TabGroup is not (and should not be) a QObject which
makes it rather useless in scripting. In order to use
window tabs in KWin scripts the methods to interact
with tabs from Client should be used.

REVIEW: 104685
2012-04-21 12:19:52 +02:00
Martin Gräßlin ca25da7089 Scripting binding to show/hide an outline
REVIEW: 104540
2012-04-16 17:45:49 +02:00
Martin Gräßlin e59a96b57c Documentation for global JavaScript methods/properties
The documentation is in an XML file which mimics the
XML output of doxygen, which can be converted to
MediaWiki syntax with the tools found in
kde:scratch/graesslin/kwin-scripting-api-generator git
repository.

BUG: 297640
FIXED-IN: 4.9.0
2012-04-10 20:41:57 +02:00
Martin Gräßlin ba6eece7ad Wrap QDesktopWidget::resized() signal in KWin scripting
Requested by mgottschlag.
2012-04-09 23:01:04 +02:00
Script Kiddy 8ced79739f SVN_SILENT made messages (.desktop file) 2012-04-02 10:09:26 +02:00
Martin Gräßlin cd8a18080f Add signal to Scripting when number of screens changes 2012-04-01 08:11:57 +02:00
Martin Gräßlin 42dfdb63b0 Global Shortcut support for KWin scripts and scripted Effects
A global method "registerShortcut" is exported to the scripts which
can be used to register a callback to be called when the global
shortcut is triggered.

The shared code between Scripts and Effects is moved into template
functions defined in a new file scriptingutils.h.

REVIEW: 104400
2012-03-30 08:20:10 +02:00
Martin Gräßlin e0f97946af Add QML specific export of ClientList
Sometimes Qt is surprising. Apparently QML has problems with a
QList<KWin::Client*> and wants to have a QList<QObject*> which
cannot be used in QtScript.

There ends my dream of having one API for both JavaScript and QML.
So with QtScript it is:
workspace.clientList()
and in QML it is:
workspace.getClientList()
2012-03-27 22:21:06 +02:00
Script Kiddy 8011e80652 SVN_SILENT made messages (.desktop file) 2012-03-26 09:55:50 +02:00
Script Kiddy 446ddcd134 SVN_SILENT made messages (.desktop file) 2012-03-24 11:23:48 +01:00
Martin Gräßlin dab146422a Make KWin::Client known to QML 2012-03-24 10:49:21 +01:00
Martin Gräßlin 98ce0cbc78 Add parameter names to signals in KWin Scripting
Apparently needed for QML bindings.
2012-03-21 18:55:32 +01:00
Martin Gräßlin 4e0ab36ae9 Add an AnimationData class for meta values
Objects of AnimationData can be instantiated by scripts and expose
all relevant data as properties, so that the ScriptedEffect can
construct the meta value out of it.

This is probably something that could be done a little bit better.
Still need to think about it, so API not yet final.

REVIEW: 103823
2012-03-12 21:37:47 +01:00
Martin Gräßlin 6baafd28cd Remove unused code 2012-03-12 21:37:42 +01:00
Martin Gräßlin 06b6ea1199 Export another enum 2012-03-12 21:37:42 +01:00
Martin Gräßlin fa66940966 Drop Plasma::ConfigLoader again
It doesn't make really any sense for the effects. Instead the
JS API allows to specify a default value for not present keys.
2012-03-12 21:37:42 +01:00
Martin Gräßlin 875df96143 Fix exporting of EffectWindowList to scripts 2012-03-12 21:37:42 +01:00
Martin Gräßlin 048540a7c5 Fix error in package structure of scripted effects
The Plasma package structure contains a subdirectory "contents".
Furthermore we have to use locate instead of locateLocal to find
system wide installed packages and adding some debug output for
the case that the script cannot be found.
2012-03-12 21:37:41 +01:00
Martin Gräßlin 8175278526 Make displayWidth/Height available to scripts 2012-03-12 21:37:41 +01:00
Martin Gräßlin 5246de285b Export animationTime to Scripted KWin effects 2012-03-12 21:37:41 +01:00
Martin Gräßlin 8996876044 Scripted effects become configurable
The scripted effects can define their configuration through a
KConfigXT file in the same way as a packaged Plasmoid. Because of
that the ScriptedEffect also uses the Plasma::ConfigLoader to load
and manage the configuration. The config group used for the scripted
effect is like any other effect the "Effect-name" group.

In difference to the Plasmoid JavaScript API effects are not allowed
to change their configuration.
2012-03-12 21:37:40 +01:00
Martin Gräßlin e363c6bb18 Adding a method to allow scripts to test whether a window is grabbed 2012-03-12 21:37:40 +01:00
Martin Gräßlin e824412535 Export FPx2 to scripted effects
Simplifies the API. An FPx2 can be defined as a single real value
or a complex object with two real values:
{
value1: 1.0,
value2: 2.0
}
For a default ctor a null value can be used.
2012-03-12 21:37:40 +01:00
Martin Gräßlin 5592dffb48 JavaScript bindings for KWin effects
Scripted effects follow the Plamsoid package structure and the effect
loader recognizes a scripted effect at the according line in the desktop
file. If it is a scripted effect a different loader is used which
instantiates an object of the ScriptedEffect class. This class inherits
the AnimationEffect and exports the animate method and the EffectsHandler.
2012-03-12 21:37:40 +01:00
Martin Gräßlin d4a919a9bf Demands Attention support for KWin Scripting
Client has a property for demands attention and Workspace
is emitting a signal whenever the demands attention state
of any Client changes.

REVIEW: 104204
2012-03-12 21:25:45 +01:00
Martin Gräßlin bfc406e073 QtScript wants namespaces params 2012-03-09 18:20:50 +01:00
Martin Gräßlin 214375f923 Query KWin for available debug output
This adds extensive support information about the running instance
by printing out all used options, the compositing information
including GL platform, loaded effects and active effects.

The debug output can be retrieved through D-Bus:

qdbus org.kde.kwin /KWin supportInformation

or through a KWin Script (use desktop console):

print(workspace.supportInformation())

REVIEW: 104142
2012-03-04 15:21:10 +01:00
Martin Gräßlin 3600fe5ed8 Support loading/unloading of scripts on config change
Whenever the KWin configuration is changed, scripting has to unload
scripts no longer loaded and load the scripts which have been added.
For this new methods are introduced to check whether the script is
loaded.

REVIEW: 104037
2012-03-02 09:10:21 +01:00
Martin Gräßlin b7d95a1b09 Fix global script methods
The callee is an AbstractScript and we should make sure that
the script is not already deleted.
2012-03-02 09:10:11 +01:00
Martin Gräßlin 95ac5fa2ce Service Type property to exclude KWin Scripts from listing in KCM
This is useful for scripts controlled from other KCMs, like e.g.
DesktopChangeOSD which is controlled by the virtual desktop KCM
and should not be listed in the scripts section.
2012-03-02 09:10:11 +01:00
Martin Gräßlin 87fede97a1 Configuration support for KWin scripts
New global method readConfig is exported to QtScript and declarative scripts.
Config is read from a config group stored in kwinrc called "Script-<pluginname>".
For this the ctors of the AbstractScript and derived classes are changed to also
take the pluginname.
2012-03-02 09:10:10 +01:00
Martin Gräßlin 3f1ef8bb8d Export KWin::Options to KWin scripts 2012-03-02 09:10:10 +01:00
Martin Gräßlin 6a8b79f699 Support declarative KWin scripts
For this the Script class is slightly refactored to have a common
base for JavaScript and QML based scripts.

Why QML bindings? This allows to use QML for example for the
desktop change OSD or for fullscreen effects like Present Windows.
2012-03-02 09:10:10 +01:00
Martin Gräßlin f9ad0621d5 Drop script dir variable
Not needed any more.
2012-03-02 09:10:10 +01:00
Script Kiddy 292ceee506 SVN_SILENT made messages (.desktop file) 2012-03-01 09:46:02 +01:00
Script Kiddy dd026bdd9f SVN_SILENT made messages (.desktop file) 2012-02-29 10:25:11 +01:00
Script Kiddy fc9dcf9e82 SVN_SILENT made messages (.desktop file) 2012-02-23 09:52:44 +01:00
Script Kiddy 7397a5dc6a SVN_SILENT made messages (.desktop file) 2012-02-20 09:55:34 +01:00
Martin Gräßlin c76317fa0f Export Desktop Name to scripts 2012-02-19 17:01:30 +01:00
Martin Gräßlin 356b406ae3 Export screen information to scripts 2012-02-19 17:01:22 +01:00
Martin Gräßlin db04ab7f36 KWin scripts use Plasma package structure
Scripts are found by the KServiceTypeTrader and can now be
enabled/disabled. Loading of config is currently disabled. Will
be made available again after scripted effects are merged.
2012-02-18 10:40:39 +01:00
Thomas Lübking 85635dd485 fix tabbing
BUG: 290959
BUG: 265160
BUG: 229292
BUG: 238279
BUG: 290758
BUG: 222831
BUG: 278275
BUG: 245747
BUG: 230000

BUG: 253697
BUG: 230570
BUG: 265977
BUG: 225337
BUG: 225339

REVIEW: 103855
2012-02-11 16:30:22 +01:00
Thomas Lübking bf88ec09ac Revert "fix tabbing"
pushed out of branch, not master - leading to absent revision, found hash collision??

This reverts commit 94b2ad7b85801e37e2df4671cdc4f26b6d7e5506.
2012-02-11 16:29:14 +01:00
Thomas Lübking d245035a17 fix tabbing
BUG: 290959
BUG: 265160
BUG: 229292
BUG: 238279
BUG: 290758
BUG: 222831
BUG: 278275
BUG: 245747
BUG: 230000

BUG: 253697
BUG: 230570
BUG: 265977
BUG: 225337
BUG: 225339

REVIEW: 103855
2012-02-11 16:01:41 +01:00
Martin Gräßlin 6185bf00d3 Export useraction slots to scripting
All slots not requiring to be triggered from a QAction are exported.
This means that switchToDesktop is not exported but also not required,
as we have this through the properties.

Needs documentation...
2012-01-27 07:35:40 +01:00
Martin Gräßlin 651a0cca47 Export clientArea methods to scripting
For this a new MetaObject "KWin" is exported to have the
enum ClientAreaOption available in scripts. Unfortunately this
requires duplicating the enum from kwinglobals.h.
2012-01-26 22:56:24 +01:00
Martin Gräßlin cf5b70bd2c Export displayWidth/height/size as properties of workspace 2012-01-26 16:53:07 +01:00
Martin Gräßlin 55088ba776 Remove repetitive code in WorkspaceWrapper 2012-01-26 08:37:38 +01:00
Martin Gräßlin 26d069981d Add property for number of desktops to scripting
Adding macros to define the wraping code.
2012-01-26 08:37:25 +01:00
Martin Gräßlin 0dbfdf4979 Simplify the Timer in scripting
Properties are already available thanks to QObject: no need to
export them again. Dropping the toString method allows to remove
the plasma-backportglobal.h file for which Krazy had many complains.
2012-01-22 13:02:34 +01:00