The define KWIN_SINGLETON adds to a class definition:
public:
static Foo *create(QObject *parent = 0);
static Foo *self() { return s_self; }
protected:
explicit Foo(QObject *parent = 0);
private:
static Foo *s_self;
There is an additional define KWIN_SINGLETON_VARIABLE to set a different
name than s_self.
The define KWIN_SINGLETON_FACTORY can be used to generate the create
method. It expands to:
Foo *Foo::s_self = 0;
Foo *Foo::create(QObject *parent)
{
Q_ASSERT(!s_self);
s_self = new Foo(parent);
return s_self;
}
In addition there are defines to again set a different variable name and
to create an object of another inheriting class.
All the classes currently using this pattern are adjusted to use these
new defines. In a few places the name was adjusted. E.g. in Compositor
the factory method was called createCompositor instead of create.
REVIEW: 109865
With Qt5 QCursor does no longer provide ::handle() which was used to
set a cursor on a native XWindow for which we do not have a QWidget.
Also KWin has had for quite some time an optimized version to get the
cursor position without doing XQueryPointer each time ::pos() is called.
These two features are merged into a new class Cursor providing more or
less the same API as QCursor.
In addition the new class provides a facility to perform mouse polling
replacing the implementations in Compositor and ScreenEdges.
For more information about the new class see the documentation for the
new class in cursor.h.