KWin/Frameworks: Difference between revisions

From KDE Community Wiki
No edit summary
Line 29: Line 29:


== Known Limitations ==
== Known Limitations ==
* Non-composited mode has broken window decorations
* Screen edges do not trigger
* Aurorae window decoration is not working
* Aurorae window decoration is not working
* Global shortcuts are not available
* Some user actions (Alt+F3 menu) might crash KWin
* No configuration dialogs


= Configuring =
= Configuring =

Revision as of 13:17, 5 November 2013

Compiling

In order to build KWin against KDE Frameworks 5, one needs to have a working frameworks setup. For this follow the steps outlined in Frameworks/Building.

Once frameworks is set up, kde-workspace can be compiled. At the time of this writing the development happens in branch frameworks-scratch of the kde-workspace git repository.

To get KWin working properly on Frameworks there are many tasks to be solved. These tasks can be found in the KWin/Frameworks Trello board. If you want to work on a task please contact Martin Gräßlin (mgraesslin on IRC, email mgraesslin at kde dot org) to be added to the board and assign a task to yourself.

Please see KWin/Hacking for further information about the structure of KWin.

Running

Xephyr

It is recommended to not replace the window manager which is running your session by KWin 5 at the current time. Instead best use a nested X-Server like Xephyr. Unfortunately this means that some features are not available. For example OpenGL based compositing is not availabe, though XRender based compositing is available. If you use Xephyr for testing specify environment variable KWIN_COMPOSE=X to enforce XRender compositing (see known limitations).

To start Xephyr:

Xephyr :99

To run an application on the nested X-Server just use the DISPLAY variable:

DISPLAY=:99 xterm

Starting

Follow the runtime instructions in Frameworks/Building - especially ensure that you started D-Bus. Otherwise KWin 5 and a running KWin 4 might conflict on the DBus. Apart from that there is nothing special to consider. KWin 5 can be started just like KWin 4. If a window manager is already running, use:

kwin --replace &

Known Limitations

  • Aurorae window decoration is not working

Configuring

Configuring KWin is at the moment rather difficult as the configuration dialogs are missing. The easiest way is to just edit the kwinrc configuration file. For example to change from default 1 virtual desktop to 4 do:

[Desktops]
Number=4

As an alternativ one can configure KWin with the help of scripts. The KWin scripting interface is already working and scripts can be loaded through the D-Bus interface:

qdbus org.kde.kwin.Scripting /Scripting loadDeclarativeScript /path/to/script/script.qml
qdbus org.kde.kwin.Scripting /Scripting start

or for QtScript based scripts:

qdbus org.kde.kwin.Scripting /Scripting loadScript /path/to/script/script.js
qdbus org.kde.kwin.Scripting /Scripting start

Activating Effects

As global shortcuts and screen edges are broken it's difficult to trigger effects like Present Windows or Desktop Grid. Due to missing global shortcuts it's also not possible to invoke them through the global shortcut D-Bus interface.

A possible solution is to patch the effects to provide a D-Bus interface:

diff --git a/kwin/effects/desktopgrid/desktopgrid.cpp b/kwin/effects/desktopgrid/desktopgrid.cpp
index 2fe3b6c..b070b44 100644
--- a/kwin/effects/desktopgrid/desktopgrid.cpp
+++ b/kwin/effects/desktopgrid/desktopgrid.cpp
@@ -41,6 +41,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <QQmlContext>
 #include <QQmlEngine>
 #include <QQuickItem>
+#include <QtDBus/QDBusConnection>
 
 namespace KWin
 {
@@ -81,6 +82,8 @@ DesktopGridEffect::DesktopGridEffect()
     connect(effects, SIGNAL(numberDesktopsChanged(uint)), this, SLOT(slotNumberDesktopsChanged(uint)));
     connect(effects, SIGNAL(windowGeometryShapeChanged(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(KWin::EffectWindow*,QRect)));
 
+    QDBusConnection::sessionBus().registerObject(QStringLiteral("/DesktopGrid"), this, QDBusConnection::ExportScriptableContents);
+    QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.DesktopGrid"));
     // Load all other configuration details
     reconfigure(ReconfigureAll);
 }
@@ -93,6 +96,8 @@ DesktopGridEffect::~DesktopGridEffect()
         i = m_desktopButtonsViews.erase(i);
         view->deleteLater();
     }
+    QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/DesktopGrid"));
+    QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.kwin.DesktopGrid"));
 }
 
 void DesktopGridEffect::reconfigure(ReconfigureFlags)
diff --git a/kwin/effects/desktopgrid/desktopgrid.h b/kwin/effects/desktopgrid/desktopgrid.h
index c3fc462..4a095d7 100644
--- a/kwin/effects/desktopgrid/desktopgrid.h
+++ b/kwin/effects/desktopgrid/desktopgrid.h
@@ -50,6 +50,7 @@ class DesktopGridEffect
     : public Effect
 {
     Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.DesktopGrid")
     Q_PROPERTY(int zoomDuration READ configuredZoomDuration)
     Q_PROPERTY(int border READ configuredBorder)
     Q_PROPERTY(Qt::Alignment desktopNameAlignment READ configuredDesktopNameAlignment)
@@ -92,8 +93,9 @@ public:
     bool isUsePresentWindows() const {
         return m_usePresentWindows;
     }
+public Q_SLOTS:
+    Q_SCRIPTABLE void toggle();
 private Q_SLOTS:
-    void toggle();
     // slots for global shortcut changed
     // needed to toggle the effect
     void globalShortcutChanged(const QKeySequence& seq);
diff --git a/kwin/effects/presentwindows/presentwindows.cpp b/kwin/effects/presentwindows/presentwindows.cpp
index fa21b36..6e179c3 100755
--- a/kwin/effects/presentwindows/presentwindows.cpp
+++ b/kwin/effects/presentwindows/presentwindows.cpp
@@ -44,6 +44,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <QQmlEngine>
 #include <QQuickItem>
 #include <QDesktopWidget>
+#include <QtDBus/QDBusConnection>
 #include <QGraphicsObject>
 #include <QTimer>
 #include <QVector2D>
@@ -102,12 +103,17 @@ PresentWindowsEffect::PresentWindowsEffect()
     connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long)));
 
     connect (qApp->desktop(), SIGNAL(screenCountChanged(int)), SLOT(screenCountChanged()));
+
+    QDBusConnection::sessionBus().registerObject(QStringLiteral("/PresentWindows"), this, QDBusConnection::ExportScriptableContents);
+    QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.PresentWindows"));
 }
 
 PresentWindowsEffect::~PresentWindowsEffect()
 {
     delete m_filterFrame;
     delete m_closeView;
+    QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/PresentWindows"));
+    QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.kwin.PresentWindows"));
 }
 
 void PresentWindowsEffect::reconfigure(ReconfigureFlags)
diff --git a/kwin/effects/presentwindows/presentwindows.h b/kwin/effects/presentwindows/presentwindows.h
index 4d31944..c3e2004 100644
--- a/kwin/effects/presentwindows/presentwindows.h
+++ b/kwin/effects/presentwindows/presentwindows.h
@@ -58,6 +58,7 @@ class PresentWindowsEffect
     : public Effect
 {
     Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.PresentWindows")
     Q_PROPERTY(int layoutMode READ layoutMode)
     Q_PROPERTY(bool showCaptions READ isShowCaptions)
     Q_PROPERTY(bool showIcons READ isShowIcons)
@@ -188,15 +189,15 @@ public:
     }
 public Q_SLOTS:
     void setActive(bool active);
-    void toggleActive()  {
+    Q_SCRIPTABLE void toggleActive()  {
         m_mode = ModeCurrentDesktop;
         setActive(!m_activated);
     }
-    void toggleActiveAllDesktops()  {
+    Q_SCRIPTABLE void toggleActiveAllDesktops()  {
         m_mode = ModeAllDesktops;
         setActive(!m_activated);
     }
-    void toggleActiveClass();
+    Q_SCRIPTABLE void toggleActiveClass();
 
     // slots for global shortcut changed
     // needed to toggle the effect