This restores the behavior on KWin4: if I set an X property that doesn't have any data on a window, it's still information, so this makes the Xcb wrapper return an empty QByteArray that is not null.
EffectWindow::readProperty() now returns an empty QByteArray constructed the same way as it was in KWin4.
REVIEW:118645
BUG:335446
xcbutils.h has quite a few inline only implementations such as Xcb::Atom,
the Wrappers, Xcb::Window and the convenient methods. Thus there is
nothing wrong with using it from the built-in Effects.
Xcb::Atom is used in Glide and Logout Effect to get the atom. To keep the
logic of the existing code it got extended by a bool isValid() which
gets the reply and returns true if the atom is set.
REVIEW: 117587
The Xcb::Property can wrap the xcb_get_property call and provides
convenient access methods to read the value of the reply with checks
applied. For this it provides a templated ::value method for reading a
single value or reading an array. There's also a ::toBool and
::toByteArray which performs the conversion directly with default values
for the type and format checks.
Xcb::TransientFor is changed to be derived from Property instead of
Wrapper directly, so that the reading of the property value can be
shared.
Xcb::StringProperty is a convenient wrapper derived from Property to
handle the reading of a string property providing a cast to QByteArray
operator. This replaces the ::getStringProperty from utils. Though the
separator functionality from ::getStringProperty is not provided as that
is only used in one function and handled there.
All the custom usages of xcb_get_property or getStringProperty are
replaced to use this new wrapper. That simplifies the code and ensures
that all properties are read in the same way.
REVIEW: 117574
So far the Wrapper class was not able to properly wrap all xcb calls and
there was the restriction that the request function needs to have an
xcb_window_t argument. The result was that wrapper functions were used
for calls with no arguments or for multiple arguments, but in a rather
limited way.
By using variadic template arguments this restriction is removed and the
Wrapper is able to wrap any xcb request/reply group. The main difference
is how the function pointers are defined. Those cannot be specified as
template arguments as the variadic arguments need to be the last in the
list.
The pointers are now defined by a WrapperData struct. For complete usage
please see the extensive documentation added to WrapperData on how it is
supposed to be used.
REVIEW: 117559
Qt doesn't print proper error messages for any errors caused by
extensions. As KWin is a heavy user of extensions not of interest to Qt
(e.g. damage or composite) we do our own error code mapping.
The Xcb::ExtensionData is extended by a vector of OpCodes and ErrorNames.
In ::workspaceEvent it's checked whether the event is an error and if
that is the case KWin tries to map the error to one of the extensions.
If that is successful it prints a warning looking like Qt's one:
XCB error: 151 (BadDamage), sequence: 12534, resource id: 127926362, \
major code: 143 (DAMAGE), minor code: 2 (Destroy)
and the event gets filtered out, so that the Qt error messages is not
printed in addition.
If the error is not from one of the extensions the error is not filtered
out and so the default Qt behavior gets applied.
REVIEW: 117421
Adding a const variant for ::data() to remove an unexpected copy.
To complete also the bool cast operator and isNull get a const
variant.
REVIEW: 117469
If the user actions menu is closed Qt looks for a QWidget at the mouse
position. If it finds one it tries to activate and raise it. If the
QWidget at the mouse position is a window decoration, it gets raised
above the Client. This makes the window unfortunately unusable.
To prevent this from happening we listen for the ZOrderChange event
in our event filter on the decoration widget and unconditionally lower
the decoration widget again - we never want the decoration widget to
be above our Client, so we can just always lower it. We have to use
the low level functionality and cannot use QWidget::lower as that would
result in a loop.
broke on interim Wrapper() constructor change
The Constructor needs to explicitly pass
XCB_WINDOW_NONE to the inherited Constructor to
trigger a request
Thanks to Alex Leach for finding this
CCBUG: 256242
FIXED-IN: 4.11.2
REVIEW: 112595
During startup we only create the request, the reply will be fetched
once the atom is needed.
To make proper use of this async behavior the creation of Atoms is
moved directly to the claim of the manager selection, so they can be
fetched while we wait for the previous manager selection to give up
on it.
We have windows which we don't want to destroy (e.g. the managed
clients) but still would like to be able to use the nicer API.
Therefore the not creating ctor and reset method have a second bool
arg to whether destroy the window or not. Default is to keep the
RAII functionality.
Wrapped in xcbutils.
In addition the check whether another WM is running in main.cpp is
improved by doing a checked request and directly checking for the
error. If there is an error, KWin puts out an error message and
quits.
This dependency is causing build problems on a number of systems,
and it doesn't make much sense to bring in a whole library for three
one-line convenience functions.
xcb/xcb_iccm.h isn't C++ safe (some versions) because it has
a variable called "class" in function signatures. The hack
is to define "class" to something else before that header is
included, and then undef "class" immediately afterwards.
CCMAIL: mgraesslin@kde.org, fredrik@kde.org
The type of the transient_for related variables are changed to
xcb_window_t. They cannot be Xcb::Window as we don't take ownership over
the transient for window.
Variables are renamed to m_camelCase to follow naming scheme.
A wrapper for retrieving the TransientFor hint is added to the Xcb
Wrappers.
KWin::Cursor can track changes to the cursor image. It supports a
start/stop tracking to not handle these events if nobody is interested in
them. When enabled and the cursor image changes a signal is emitted with
the serial number of the new cursor image.
To track cursor image changes xcb_xfixes_select_cursor_input is used (see
XFixes Version 5.0 protocol, section 7).
This could be useful for the zoom effect when it replaces the cursor.
REVIEW: 110519
With the removal of BoxSwitch all effects which want mouse events use the
fullscreen input window. The available functionality is too complex both
in EffectsHandler and in the Effects.
With this change only fullscreen input windows are supported and all
effects share the input window. This means there is at maximum one input
window. This simplifies the code in the Effects as they don't have to
keep track of the window they created any more. In EffectsHandler it
means that only one window needs to be created, destroyed and raised.
Also it means that we can properly react on screen size changes which had
been ignored in the past. Also quite some roundtrips to X are no longer
needed as we do not need to query the window geometry when creating the
input window.
REVIEW: 110156
It's only used from useractions.cpp which means that it's not the best
fit in utils. We can see the problems with it given that it was in an
ifdef and it included quite some headers into everything.
REVIEW: 110189
this broke re-embedding clients
XReparentWindow causes an unmap of mapped clients, currently leading into releaseClient()
This will (among other) eg. reparent the client to the root and this is (usually?) executed after the original XReparentWindow, so the client does not end up where it's supposed to be.
REVIEW: 109484
The Client::cursor property is changed from QCursor to Qt::CursorShape
and renamed to m_cursor (as all usages are adjusted).
This property is mostly used to define the cursor on e.g. the extended
deco border window. To make this easier a XDefineCursor replacement is
added to xcbutils.h both as a static method and as a member function to
Xcb::Window.
Using Xcb::Window to manage the xcb_window_t and simplify the code - no
longer need to check whether the input_window is valid before calling e.g.
map, as that's handled in Xcb::Window.
One XLib usage for setting cursor is still present. This will be ported
once all the QCursor::handle() get removed.
REVIEW: 108771
The idea behind this class is to relieve the developer from having to
call xcb_destroy_window once it is no longer needed. That is having a
RAII approach to windows.
In addition the class provides some simple method wrappers for the most
common use cases inside KWin:
* map
* unmap
* setGeometry - basically a moveResizeWindow
* ...
Use WindowAttributes and WindowGeometry everywhere where the xcb commands
had already been used.
Introduces another wrapper for overlay window and a subclass for query
tree which also wrapps the children command.
It's not really needed, the required functionality can be achieved in a
more implicit way. The reply pointer is managed by the Wrapper class as
long as the method take() is not invoked. This method follows the
semantics of QScopedPointer::take(). That is the pointer is set to null
and the responsibility to free the pointer is passed to the callee.
By this change we do not have the overhead of creating a QSharedPointer.
In addition the Wrapper provides a copy ctor and assignment operator also
using the semantics of take().