Review Request 123542: [runtime] Move platform specific code into plugins

Alex Richardson arichardson.kde at gmail.com
Tue Apr 28 17:31:17 UTC 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/123542/#review79637
-----------------------------------------------------------



src/runtime/globalshortcutsregistry.cpp (line 40)
<https://git.reviewboard.kde.org/r/123542/#comment54448>

    You could use `KPluginLoader::forEachPlugin("org.kde.kglobalaccel5.platforms", [&](const QString& lib) { ret << lib; });` here.



src/runtime/globalshortcutsregistry.cpp (line 58)
<https://git.reviewboard.kde.org/r/123542/#comment54449>

    Actually, since all plugins have JSON metadata this can actually be further simplified by using something like this:
    
    ```
    auto candidates = KPluginLoader::findPlugins("org.kde.kglobalaccel5.platforms");
    foreach (const auto& candidate, candidates) {
       const auto platforms = candidate.rawData().value("platforms").toArray();
       foreach (const auto& platform, platforms) {
           if (QString::compare(QGuiApplication::platformName(), platform.toString(), Qt::CaseInsensitive) == 0) {
                KGlobalAccelInterface *interface = qobject_cast< KGlobalAccelInterface* >(candidate.instatiate());
                if (interface) {
                    qCDebug(KGLOBALACCELD) << "Loaded plugin" << candidate << "for platform" << QGuiApplication::platformName();
                    interface->setRegistry(parent);
                    return interface;
                }
            }
        }
    }
    
    ```


- Alex Richardson


On April 28, 2015, 3:13 p.m., Martin Gräßlin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/123542/
> -----------------------------------------------------------
> 
> (Updated April 28, 2015, 3:13 p.m.)
> 
> 
> Review request for KDE Frameworks, kdewin and Martin Klapetek.
> 
> 
> Repository: kglobalaccel
> 
> 
> Description
> -------
> 
> The current architecture of the runtime component was to have compile
> time destinctions between various platforms. This approach does not
> allow to include Wayland support on Linux as both xcb and Wayland are
> possible platforms which are selected at runtime and not at compile
> time. Thus a change of the architecture is required.
> 
> The solution taken in this patch is to move the platform specific code
> into plugins and to load the plugin specific to the currently used
> platform. Therefore a new interface class is introduced which the
> plugins have to implement. In addition most of the runtime is turned
> into a library, so that the plugin can link it.
> 
> To properly support Wayland more changes will be required. The security
> provided by the Wayland windowing system does not work well with the
> architecture of kglobalacceld. Kglobalacceld is a kind of glorified
> key logger. Wayland makes it impossible to be a key logger. Thus the
> support for global shortcuts needs to be in the compositor. In the case
> of KDE Plasma that is KWin. On that architecture we can make kglobalaccel
> to still work by allowing KWin to link the new library and provide it's
> own plugin. In order to support this the new private library must be
> cleaned up and prepared for at least allowing a somewhat stable API/ABI.
> 
> Please note that this change also disables build for all platforms
> except xcb (OSX and Windows) due to lack of a build environment.
> 
> 
> Diffs
> -----
> 
>   src/runtime/CMakeLists.txt 8c7c7610843040fa60ab095114e7b74707f75c30 
>   src/runtime/component.cpp 663d0ade5ffe03254cc7886b76c7850d4b4317ab 
>   src/runtime/globalshortcutsregistry.h ca12db09f4b56b0a0f0b6304da1cd1292ef65042 
>   src/runtime/globalshortcutsregistry.cpp 446e766deb96ae3a83baabaca726d5460b597b88 
>   src/runtime/kglobalaccel_interface.h PRE-CREATION 
>   src/runtime/kglobalaccel_interface.cpp PRE-CREATION 
>   src/runtime/kglobalaccel_mac.h  
>   src/runtime/kglobalaccel_mac.cpp  
>   src/runtime/kglobalaccel_win.h  
>   src/runtime/kglobalaccel_win.cpp  
>   src/runtime/kglobalaccel_x11.h b398e1cfcf9496b58f6b05893a002c112c7cf986 
>   src/runtime/kglobalaccel_x11.cpp 2600220c255641304d4f67aad74582b01b8f799c 
>   src/runtime/kglobalacceld.h b2fc27223ea1d11ca5a75f2ad58a8d745fb17191 
>   src/runtime/plugins/CMakeLists.txt PRE-CREATION 
>   src/runtime/plugins/xcb/CMakeLists.txt PRE-CREATION 
>   src/runtime/plugins/xcb/xcb.json PRE-CREATION 
> 
> Diff: https://git.reviewboard.kde.org/r/123542/diff/
> 
> 
> Testing
> -------
> 
> kglobalaccel5 still working on platform xcb (running here right now)
> 
> 
> Thanks,
> 
> Martin Gräßlin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20150428/a87942b7/attachment.html>


More information about the Kde-frameworks-devel mailing list