Review Request 115225: Add runtime platform support to KWindowInfo

Alexander Richardson arichardson.kde at googlemail.com
Thu Jan 23 14:47:02 UTC 2014


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


Wouldn't this be easier using methods with the subclass as a template parameter instead of the enum. I.e:


class KWindowSystemPrivate {
//....
template <class Impl>
inline unsigned long state() const
{
    // use a different name to prevent infinite recursion in case this is called with KWindowSystemPrivate as a template parameter
    return static_cast<Impl*>(this)->stateImpl();
}
//....
};

class KWindowSystemPrivateDummy : public KWindowSystemPrivate {
//....
inline unsigned long stateImpl() const {
    return 0;
} 
//...
};

class KWindowSystemPrivateX11 : public KWindowSystemPrivate {
//....
inline unsigned long stateImpl() const {
    return m_info->state();
} 
//...
}
Then there is no more need for #define X11 static_cast<const KWindowInfoPrivateX11*>(this) anymore.

DELEGATE would look like this then:
#define DELEGATE(name, args) \
    switch (d->platform()) { \
    case KWindowInfoPrivate::XcbPlatform: \
        return d->name<KWindowInfoPrivateX11>( args ); \
    default: \
        return d->name<KWindowInfoPrivateDummy>( args ); \
    }


This should also work, however I am just typing it from my head without having it compiled.

- Alexander Richardson


On Jan. 23, 2014, 9:09 a.m., Martin Gräßlin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/115225/
> -----------------------------------------------------------
> 
> (Updated Jan. 23, 2014, 9:09 a.m.)
> 
> 
> Review request for KDE Frameworks and kdewin.
> 
> 
> Repository: kwindowsystem
> 
> 
> Description
> -------
> 
> Add runtime platform support to KWindowInfo
> 
> Main idea of this change is to only pick the X11 implementation in case
> that the application is running on the X11 platform. So far it was a
> compile time switch which meant that if compiled with X11 support but
> not running on the X11 platform it would have caused runtime errors.
> 
> To make this possible a KWindowInfoPrivate class with a dummy
> implementation is provided. This is used as d-ptr for KWindowInfo.
> Thus there is one generic implementation and the implementation of
> KWindowInfo is no longer ifdefed for the supported platforms.
> 
> The platform specific code can inherit from KWindowInfoPrivate and
> overwrite the dummy method implementation. KWindowInfoPrivate provides
> a factory method where the platform specific implementation can be
> hooked into. There we can have both compile time and runtime checking.
> If there is no platfom specific implementation available the dummy
> implementation is used.
> 
> NOTE: THIS CHANGE BREAKS THE WINDOWS AND MAC BACKEND!
> 
> Windows and Mac is excluded from build. At the moment they get the
> dummy implementation. Unfortunately I don't have the possibility to
> compile the changes and thus don't dare to touch the code. Fixes from
> the teams are highly appreciated.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt e32a1150a2c190f23ad456ca8218b012c5d71507 
>   src/kwindowinfo.h 171f441ff329a5356ccf560341272199e20c837a 
>   src/kwindowinfo.cpp PRE-CREATION 
>   src/kwindowinfo_p.h PRE-CREATION 
>   src/kwindowinfo_p_x11.h PRE-CREATION 
>   src/kwindowinfo_x11.cpp 865d8bed085e987f97f479ea8aa0e6de8567586f 
> 
> Diff: https://git.reviewboard.kde.org/r/115225/diff/
> 
> 
> Testing
> -------
> 
> Unit test from https://git.reviewboard.kde.org/r/115190/ is still working. Now you can guess why I wrote that test ;-)
> 
> 
> Thanks,
> 
> Martin Gräßlin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-windows/attachments/20140123/7c38bd25/attachment.html>


More information about the Kde-windows mailing list