Commit graph

69 commits

Author SHA1 Message Date
Martin Gräßlin
abc3c633f3 Fix regression in unit-test introduced with 62b6401175
I don't understand why, but this fixes the TestXcbWrapper::testTransientFor().

Failing code fragment in question:

Window transientWindow(createWindow());
transientWindow.changeProperty(XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, 1, &m_testWindow);
// let's get another transient object
TransientFor realTransient(transientWindow);
QVERIFY(realTransient.getTransientFor(&compareWindow));
QCOMPARE(compareWindow, (xcb_window_t)m_testWindow);

the QCOMPARE failed with one compareWindow being 0. It looks like the
cast from Xcb::Window to xcb_window_t in the changeProperty failed.

REVIEW: 124864
2015-08-21 11:14:20 +02:00
Thomas Lübking
62b6401175 store logic (what we think) geometry of XCB Window
This allows us to check and compare geometry of
system windows, no matter what the interim logic
client geometry (eg. shaded etc.) is

REVIEW: 124591
2015-08-15 01:34:41 +02:00
Thomas Lübking
2d6df416b6 add OutputInfo class to obtain output names 2015-05-15 23:55:27 +02:00
Thomas Lübking
0a3155972b forward resource modes next to crtcs
modes will be required for proper refreshrate detection
2015-05-15 23:55:27 +02:00
Martin Gräßlin
2220ae44c4 Create a plugin for each of the wayland backends
Each of the backends becomes a plugin. This allows kwin_wayland to load
the requested plugin and kwin itself doesn't need to link all the
libraries needed. E.g. libdrm is no longer linked if running kwin_x11.
Also this allows to create backends for the non-standard EGL platforms
(examples could be raspberrypi or Android devices).
2015-05-06 10:31:39 +02:00
Martin Gräßlin
c1ab92d8b4 Make it possible to use XCB::Atom with non-default xcb_connection_t
Preparation step for having an X11 backend in kwin_wayland which has
connection() point to Xwayland and another connection to the parent
X server.
2015-03-20 14:08:53 +01:00
Martin Gräßlin
7d797387d7 Add safety check for QueryTree
xcb_qeuery_tree should fail and we should not just assume that the
call succeeds.

Crash reported by Harald Sitter.
2015-03-20 12:39:33 +01:00
Martin Gräßlin
c383d6074c Replace QX11Info::appScreen() with KWin::Application::x11ScreenNumber()
No need to go through QX11Info for information we have.
2015-03-17 09:44:53 +01:00
Martin Gräßlin
2a29324294 [tabbox] Port keysym and modifier mapping to XCB
REVIEW: 122454
2015-02-09 09:12:57 +01:00
Martin Gräßlin
dfa89cc050 Port reading Motif hints to XCB
A wrapper class for MotifHints is added to xcbutils. This class manages
the information about the read Motif hints, so that Client doesn't need
to have a copy of the read states.

The class is designed in a way that during Client::manage we get rid of
another roundtrip.

REVIEW: 122378
2015-02-06 13:43:57 +01:00
Thomas Lübking
96628a698c use xcb_time_current_time as setinputfocus default
BUG: 343430
REVIEW: 122298
FIXED-IN: 5.2.1
2015-02-05 21:37:33 +01:00
Martin Gräßlin
48fcaa5656 Add Xcb::GeometryHints class
It's a convenient class to encapsulate the ICCCM WM_SIZE_HINT.
Instead of exposing just the properties it provides accessors for
the interesting parts and applies sanity checks.
2015-01-27 12:48:03 +01:00
Martin Gräßlin
2eb876743c [screens] Replace DesktopWidgetScreens by XRandRScreens
A new implementation of the Screens interface is added which uses XRandR
directly instead of relying on QDesktopWidget. The implementation is
provided in a new implementation file screens_xrandr.cpp.

XRandRScreens comes with a unit test. Unfortunately it's rather difficult
to provide a proper unit test against XRandR. Xvfb (which is obviously
used on the CI system) doesn't provide the XRandR extension. Also on a
"normal" developer system one would not want to just execute the test as
the results are not predictable (number of available outputs?) and the
test would mess up the setup resulting in nobody wanting to execute the
test.

As a solution to both problems the unit test starts Xephyr as a nested
X server. This allows to have at least some limited tests against XRandR.
Nevertheless there are a few things which I was not able to test:
* multiple outputs
* no output at all

The nested X Server approach makes the interaction rather complex. Qt
opens it's connection against the main X Server thus QX11Info provides
a wrong connection and also KWin::connection() which is heavily used by
xcbutils and thus all the RandR wrappers have the wrong connection. To
circumvent this problem the test is GUILESS. In case it would call into
any code using QX11Info, it would probably either runtime fail or crash.

REVIEW: 117614
2014-11-27 09:00:19 +01:00
Martin Gräßlin
6d64113ed4 Do not include utils.h in xcbutils.h
Only needed for ScopedCPointer which can be defined in both utils and
xcbutils.h.

Not having utils.h in xcbutils.h makes it easier to have unit tests use
xcbutils.h as it removes the dependencies.
2014-11-27 09:00:19 +01:00
Fredrik Höglund
29795f49e8 Add support for GLX in Xcb::Extensions 2014-09-18 20:21:20 +02:00
Marco Martin
490e733590 Distinguish empty and non existent properties
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
2014-06-11 11:08:02 +02:00
Martin Gräßlin
3204342809 Port XQueryPointer usage to XCB
Introduces new XCB::Pointer wrapper and is used in
Client::leaveNotifyEvent and in Cursor and KillWindow to simplify
the usage.

CCBUG: 333836
2014-05-05 08:09:09 +02:00
Martin Gräßlin
c1b4167598 [effects] Allow Built-In Effects using xcbutils.h
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
2014-04-28 14:14:20 +02:00
Martin Gräßlin
b45eeae352 [Xcb::Wrapper] Introduce a Property and StringProperty Wrapper subclass
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
2014-04-17 07:41:33 +02:00
Martin Gräßlin
8d3b12b928 [Xcb::Wrapper] Change the Wrapper to use variadic template arguments
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
2014-04-17 07:41:11 +02:00
Martin Gräßlin
9db9f172bc [Xcb::Wrapper] Add a unit test for Xcb::Tree
Based on the test Tree::children() is extended for a test case on no
children which used to return a garbage pointer.
2014-04-17 07:41:11 +02:00
Martin Gräßlin
d2d89653b2 Print better error messages for XCB errors from extensions
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
2014-04-16 13:30:31 +02:00
Martin Gräßlin
1c0d0211ca Add const method variants to Xcb::Wrapper
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
2014-04-11 07:36:18 +02:00
Martin Gräßlin
2cf7a4bad3 Provide pixmap format in XShm helper 2014-01-08 09:22:40 +01:00
Martin Gräßlin
f4ee319c6a Move XShm helper class to xcbutils
That way it can be used also in other parts of KWin.
2014-01-08 09:22:40 +01:00
Martin Gräßlin
4bd28e90af [kwin] Do not allow Qt to raise decoration widget above the Client
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.
2013-10-27 09:52:45 +01:00
Martin Gräßlin
969e6b85e7 Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/client.cpp
	kwin/effects/highlightwindow/highlightwindow.cpp
	kwin/libkwineffects/kwingltexture.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/scene_opengl.cpp
	kwin/workspace.cpp
	plasma/desktop/applets/kickoff/CMakeLists.txt
	plasma/desktop/applets/taskmanager/package/contents/code/tools.js
	plasma/desktop/applets/taskmanager/package/contents/ui/Task.qml
	plasma/desktop/applets/taskmanager/package/contents/ui/main.qml
	plasma/desktop/applets/taskmanager/package/metadata.desktop
	plasma/desktop/applets/taskmanager/plugin/textlabel.h
	plasma/desktop/applets/tasks/CMakeLists.txt
	plasma/desktop/applets/tasks/package/metadata.desktop
	plasma/desktop/applets/tasks/tasks.cpp
	plasma/desktop/toolboxes/plasma-toolbox-desktoptoolbox.desktop
	plasma/generic/applets/activitybar/activitybar.cpp
	plasma/generic/wallpapers/color/plasma-wallpaper-color.desktop
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-09-24 11:28:38 +02:00
Thomas Lübking
4fd554a2e2 fix xcb CurrentInput implementation
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
2013-09-24 00:50:55 +02:00
Martin Gräßlin
108252194a Use Xcb::Atom in KWin::Atoms to resolve all atoms
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.
2013-09-10 15:30:11 +02:00
Martin Gräßlin
c29a622be1 Introduce a wrapper class for InternAtom
Not extending Xcb::Wrapper as it does not operate on a window.
Instead it is a specified class for the specific usecase.
2013-09-10 15:30:11 +02:00
Martin Gräßlin
e687c91402 Add a changeProperty method to Xcb::Window
Used from Client to directly change properties on its client.
2013-09-10 15:30:11 +02:00
Martin Gräßlin
1fd857eecb And add the grabButton() to Xcb::Window
Again most of the arguments have a default value to ease the usage
inside KWin and remove the horrific long methods.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
f354b41680 Add ungrabButton to Xcb::Window
The order of attributes is reversed compared to xcb_ungrab_button
to better allow for default arguments.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
3ee886be2d Add setBorderWidth() method to Xcb::Window
Performs the configure window call.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
e3a1cc0b5d Add deleteProperty() method to Xcb::Window
Calls xcb_delete_property on the managed window with the passed in
xcb_atom_t.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
49da9a8fdb Add a reparent() method to Xcb::Window
Reparents the managed window to the passed in parent window.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
4215599e97 And add a lower() method to Xcb::Window
Just like ::raise().
2013-09-10 15:30:10 +02:00
Martin Gräßlin
070921f114 Add a kill() method to Xcb::Window 2013-09-10 15:30:10 +02:00
Martin Gräßlin
72c367cf2d Extend Xcb::Window wrapper to optionally not destroy window in dtor
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.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
b9e39f0d95 Use delete ctor in KWin::Xcb::Window
That's just nicer than not implementing the private ctor.
2013-09-10 15:30:10 +02:00
Martin Gräßlin
57905c0cc2 And we got rid of KDebug
Usages of kBacktrace got dropped.
2013-09-02 13:14:39 +02:00
Martin Gräßlin
d973194c36 Use an XCB replacement for XSelectInput
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.
2013-08-19 10:52:22 +02:00
Martin Gräßlin
9291b18cee Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/effects.cpp
	kwin/effects/logout/logout.cpp
	kwin/effects/presentwindows/main.qml
	kwin/effects/presentwindows/presentwindows.cpp
	kwin/effects/presentwindows/presentwindows.h
	kwin/effects/zoom/zoom_config.cpp
	kwin/libkwineffects/kwinglutils_funcs.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/nvidiahack.cpp
	kwin/xcbutils.h
	plasma/desktop/containments/desktop/plasma-containment-desktop.desktop
	plasma/generic/wallpapers/image/image.cpp
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-08-07 10:10:06 +02:00
Martin Gräßlin
c16c0c3753 Port invert screen from XLib xrandr to xcb randr
With this we can drop the linking to xrandr in KWin core.
2013-08-01 10:26:39 +02:00
Martin Gräßlin
becb5c2dc1 Port detection of screen rate to XCB
New wrapper class added to xcbutils in a new RandR namespace.
2013-08-01 08:38:05 +02:00
Martin Gräßlin
d164e16b56 Use own Xcb::sync() method in main.cpp
QApplication::syncX() is a no-op in Qt 5 so we need a replacement.
2013-07-31 07:28:15 +02:00
Fredrik Höglund
a87e8f5e8e kwin: Drop the xcb_icccm dependency
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.
2013-07-02 00:21:32 +02:00
Allen Winter
ecb9c1cf5a Add a hack for compiling xcb/xcb_icccm.h with C++.
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
2013-05-28 19:02:58 -04:00
Martin Gräßlin
5afe5f810e Port Client::transient_for handling to XCB
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.
2013-05-28 11:55:38 +02:00
Martin Gräßlin
8b2a5f9936 Support for cursor change tracking in KWin::Cursor
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
2013-05-28 08:02:59 +02:00