Commit Graph

148 Commits (6826b9eb946c75b5c56122bee96f97199efc8f6c)

Author SHA1 Message Date
Martin Gräßlin b6f793090e Toplevel::setOpacity becomes virtual
It calls unconditionally into NETWinInfo.
2015-05-08 12:43:47 +02:00
Martin Gräßlin 8fad5830f1 Toplevel::windowRole becomes virtual and is copied to Deleted
Toplevel::windowRole accesses WinInfo unconditionally causing crashes
if we have a Toplevel subclass which doesn't use WinInfo. So let's
make it virtual and copy to Deleted.
2015-05-08 12:43:44 +02:00
Martin Gräßlin 92d06a8c4b Make Toplevel::opacity virtual and copy it to Deleted
Toplevel::opacity() accesses the WinInfo, but for a Wayland client
we won't have the opacity through the WinInfo, so let's have it as
a virtual method that a subclass can override. Also it needs to be
copied to Deleted to not have a Deleted of a Wayland client crash
because it accesses the not existing WinInfo.
2015-05-08 12:43:44 +02:00
Martin Gräßlin 9ca992a329 [wayland] Drop methods on Toplevel to send input events
No longer needed as InputRedirection sends input events directly
through the SeatInterface. In addition this drops the dependency on
xtest.
2015-03-17 10:20:20 +01:00
Martin Gräßlin 659c416879 [wayland] Handle damage events from SurfaceInterface
On Wayland we get the damage from the SurfaceInterface instead of
using a damage handle. This change ensures that the damage handle
interaction is only used on platform X11, while on Wayland we get
the damage from the SurfaceInterface directly.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 07c972b6d4 [wayland] Add a SurfaceInterface to Toplevel
Adds the SurfaceInterface identified by the surface id we get from
Xwayland. This allows in an easier way to map a Toplevel to a
Wayland surface and will also be useful for Wayland clients.
2015-03-17 10:08:27 +01:00
Martin Gräßlin e463905f04 Add Workspace::findToplevel
Like findClient and findUnmanaged, just a little bit more generic.
Toplevel::findInList got adjusted to support it.
2015-03-17 10:08:27 +01:00
Martin Gräßlin e7019d9545 [xwayland] Add support for WL_SURFACE_ID
When XWayland associates a Wayland surface with an X window it
sends a WL_SURFACE_ID client message to the window manager.

KWin listens for this client message in Toplevel and provides it
as a member in Toplevel.

This requires KWin to actually start a Wayland server (and XWayland)
to make proper use of the information.
2015-03-17 10:03:04 +01:00
Martin Gräßlin 770c723c61 Split Toplevel::getSkipCloseAnimation into two parts 2015-01-21 09:25:14 +01:00
Martin Gräßlin b27d3d20e7 Split Toplevel::getWmClientLeader in two parts
First part (fetch) just creates the Xcb::Property while the
second part (read) reads the property. This allows to better
schedule the commands in Client::manage to reduce the number of
roundtrips. This reduces the time spent for fetching the client
leader property by about half a millisecond on my system.
2015-01-21 09:25:14 +01:00
Kai Uwe Broulik 2153174dc0 Add OnScreenDisplayLayer which is placed even ontop of the active fullscreen window
It is to be used for volume change feedback and similar confirmation popups

REVIEW: 121300
2015-01-02 12:11:54 +01:00
Martin Gräßlin 1747fde18b Toplevel does not inherit from KDecorationDefines any more
As an intermediate step Client inherits from KDecorationDefines.
2014-12-02 11:31:07 +01:00
Martin Gräßlin 98a5c4e050 Allow Client to disable the rendering of DecorationShadow
For maximized and fullscreen windows we don't want the shadow to be
renderer at all.
2014-07-25 14:02:27 +02:00
Martin Gräßlin 0030eb7f84 Initial import of support for new KDecoration2 based decorations
NOTE: this is not working completely yet, lots of code is still ifdefed
other parts are still broken.

The main difference for the new decoration API is that it is neither
QWidget nor QWindow based. It's just a QObject which processes input
events and has a paint method to render the decoration. This means all
the workarounds for the QWidget interception are removed. Also the paint
redirector is removed. Instead each compositor has now its own renderer
which can be optimized for the specific case. E.g. the OpenGL compositor
renders to a scratch image which gets copied into the combined texture,
the XRender compositor copies into the XPixmaps.

Input events are also changed. The events are composed into QMouseEvents
and passed through the decoration, which might accept them. If they are
not accpted we assume that it's a press on the decoration area allowing
us to resize/move the window. Input events are not completely working
yet, e.g. wheel events are not yet processed and double click on deco
is not yet working.

Overall KDecoration2 is way more stateful and KWin core needs more
adjustments for it. E.g. borders are allowed to be disabled at any time.
2014-07-25 14:02:26 +02:00
Martin Gräßlin b039a07f4d Toplevel::vis becomes Toplevel::m_visual and is xcb_visualid_t
Only usage of the ::vis was the visualid, so have this as the member
instead of the XVisual*.
2014-05-05 08:09:10 +02:00
Martin Gräßlin b18c672e36 Fix compilation with gcc-4.9
Looks like one needs to include <functional> if one uses std::function.

Compilation verified with:
* gcc-4.8
* gcc-4.9
* clang-3.2
2014-04-29 07:49:54 +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 93e5ebac63 Try to wait for DESTROY_NOTIFY before releasing an Unmanaged
So far the Unmanaged got released after an XCB_UNMAP_NOTIFY. This event
gets created after xcb_unmap_window or after xcb_destroy_window. In the
latter case the window is already distroyed and any of KWin's cleanup
calls will cause a BadWindow (or similar) error.

The idea to circumvent these errors is to try to wait for the
DESTROY_NOTIFY event. To do so the processing of the release is slightly
delayed. If KWin gets the destroy notify before the delay times out the
Unamanged gets released immediately but with a Destroy flag. For this a
new enum ReleaseToplevel is introduced and Unmanage::release takes this
as an argument instead of the bool which indicated OnShutdown. Also this
enum is added to Toplevel::finishCompositing so that it can ignore the
destroyed case and not generate an error.

REVIEW: 117422
2014-04-16 13:32:11 +02:00
Martin Gräßlin c63e3533f4 Get Toplevel::resourceName() and ::resourceClass() from NETWinInfo
It's provided by the NETWinInfo, no need to keep an own implementation.
To keep compatibility with existing KWin code using the window class or
resource it's always converted to lower.

In addition a notify signal Toplevel::windowClassChanged is added and
emitted from the event handler whenever the WM2WindowClass property is
set.

REVIEW: 117496
2014-04-14 08:46:38 +02:00
Martin Gräßlin acdff6ea52 Drop static getStringProperty wrappers in Toplevel
The methods Toplevel::staticWmCommand and Toplevel::staticSessionId were
both only used from one method and just wrapping an invocation to
getStringProperty.

REVIEW: 117474
2014-04-10 18:10:58 +02:00
Martin Gräßlin f1f6d6eea8 Get windowRole from NETWinInfo instead doing it ourself
NETWinInfo provides windowRole if NET::WM2WindowRole is added to the
properties2. Thus KWin doesn't need to monitor and fetch itself, but
can just wrap the data provided by NETWinInfo.

In addition a signal is added to Toplevel whenever the window role
changes.

REVIEW: 117470
2014-04-10 15:57:00 +02:00
Martin Gräßlin bc0a9cb53a [kwin] Use std::find_if and lambda functions for Workspace::findClient
Instead of passing the macro based Predicate to findClient it now
expects a function which can be passed to std::find_if.

Existing code like:
xcb_window_t window; // our test window
Client *c = findClient(WindowMatchPredicated(window));

becomes:
Client *c = findClient([window](const Client *c) {
    return c->window() == window;
});

The advantage is that it is way more flexible and has the logic what
to check for directly with the code and not hidden in the macro
definition.

In addition there is a simplified overload for the very common case of
matching a window id against one of Client's windows. This overloaded
method takes a Predicate and the window id.

Above example becomes:
Client *c = findClient(Predicate::WindowMatch, w);

Existing code is migrated to use the simplified method taking
MatchPredicate and window id. The very few cases where a more complex
condition is tested the lambda function is used. As these are very
local tests only used in one function it's not worthwhile to add further
overloads to the findClient method in Workspace.

With this change all the Predicate macro definitions are removed from
utils.h as they are now completely unused.

REVIEW: 116916
2014-03-25 15:17:11 +01:00
Martin Gräßlin 12a4923959 [kwin] Use std::find_if and lambda functions for Workspace::findUnmanaged
Instead of passing the macro based Predicate to findUnmanaged it now
expects a function which can be passed to std::find_if.

Existing code like:
xcb_window_t window; // our test window
Unmanaged *u = findUnmanaged(WindowMatchPredicated(window));

becomes:
Unmanaged *u = findUnmanaged([window](const Unmanaged *u) {
    return u->window() == window;
});

In addition an overload is added which takes the window id to cover
the common case to search for an Unmanaged by its ID. The above example
becomes:
Unmanaged *u = findUnmanaged(window);

The advantage is that it is way more flexible and has the logic what
to check for directly with the code and not hidden in the macro
definition.
2014-03-25 15:17:10 +01:00
Martin Gräßlin ca6f3e329d [kwin] Fix includes of NETWM
Used kde4support variant.
2014-03-18 14:32:53 +01:00
Martin Gräßlin 6baf794f88 InputRedirection for keyboard events
Major new functionality is xkbcommon support. InputRedirection holds an
instance to a small wrapper class which has the xkb context, keymap and
state. The keymap is initialied from the file descriptor we get from the
Wayland backend.

InputRedirection uses this to translate the keycodes into keysymbols and
to QString and to track the modifiers as provided by the
Qt::KeybordModifiers flags.

This provides us enough information for internal usage (e.g. pass through
effects if they have "grabbed" the keyboard).

If KWin doesn't filter out the key events, it passes them on to the
currently active Client respectively an unmanaged on top of the stack.
This needs still some improvement (not each unmanaged should get the
event). The Client/Unmnaged still uses xtest extension to send the key
events to the window. So keylogging is still possible.
2014-03-18 09:00:50 +01:00
Martin Gräßlin 7d48b92e2b Redirect pointer events to the Toplevel
InputRedirection keeps track of the Toplevel which is currently the one
which should get pointer events. This is determined by checking whether
there is an Unmanaged or a Client at the pointer position. At the moment
this is still slightly incorrect, e.g. pointer grabs are ignored,
unmanaged are not checked whether they are output only and input shapes
are not yet tracked.

The pointer events are delivered to the Toplevel as:
* enter
* leave
* move
* button press
* axis event

Nevertheless move events are still generated in InputRedirection through
xcb test for simplicity. They are still send to the root window, so all
windows get mouse move.

Button press and axis are generated only in the implementations of the
event handlers and delivered directly to the window, so other windows
won't see it.
2014-03-18 09:00:50 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin 2fbc8414a7 Allow windows to specify that they should not get animated on window close
By setting the X property _KDE_NET_WM_SKIP_CLOSE_ANIMATION to 1 a window
can request to be excluded from any close animation. This property is
read in Toplevel, so that it is available to both Client and Unmanaged.

If the window has this property set the Scene suppresses the paintWindow
loop of the Deleted. Thus no effect needs to be adjusted. But an effect
using drawWindow directly would still be able to render the Deleted as
there is no suppression.

Furthermore the property is passed to the EffectWindow so that an
Effect can make use of this functionality and not start the animation
in the first place.

REVIEW: 115288
2014-01-28 07:43:35 +01:00
Martin Gräßlin ba66fd9ef6 [kwin] NETWinInfo2 becomes NETWinInfo
And takes a xcb_connection_t instead of Display. Also our own class
is adjusted to no longer need the connection being passed in.
2013-11-18 13:56:28 +01:00
Martin Gräßlin 4a4ec0decd [kwin] Add XLib includes where still needed
No longer included through netwm.
2013-11-18 13:52:38 +01:00
Martin Gräßlin cfd93246b3 Toplevel::frameId() becomes virtual
The frameId only makes sense for a Client, in case of Unmanaged the
same window id is used as for the window() handle. Client creates the
frame and destroys it.

Given that it makes sense to let Client manage the frame properly.
The ::frameId() is therefore virtual and as base implementation it
returns the client id. Client reimplements it and returns the proper
frame id.

Method is also implemented in Deleted as it used to be passed to
deleted.
2013-09-10 15:30:10 +02:00
Martin Gräßlin 577525c2bb Use Xcb::Window wraper for Toplevel::client
Uses the new API to not destroy the window in the dtor.

At the same time the variable is renamed to m_client to follow the
common naming scheme.
2013-09-10 15:30:10 +02:00
Martin Gräßlin 5ff8d2389e Port static get property wrappers to XCB in kwin/toplevel
Just replacing WId by xcb_window_id and using the XCB atom enum.
2013-09-09 06:03:36 +02:00
Martin Gräßlin bcfa76ef87 Remove not implemented static methods from kwin/toplevel.h 2013-09-09 06:03:36 +02:00
Martin Gräßlin 687e264387 Port staticWmClientLeader to XCB
Removes usage of kxerrorhandler in kwin/toplevel.cpp
2013-09-09 06:03:35 +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 df4b43ea78 Enable property notify event handling in Client and Unmanaged 2013-07-29 09:00:43 +02:00
Martin Gräßlin 1d2c2d5982 Use Q_SLOTS and Q_SIGNALS instead of slots and signals
Fixes compilation with Qt5/KF5 setup.
2013-07-24 09:46:54 +02:00
Thomas Lübking a3d502338d delay adding Unmanaged clients by 50ms
This provides some sort of synthetic XSYNC support
for unmanaged clients and allows them to do an initial
update after mapping and before being painted (prevent
flicker)
Also it helps with Unmanaged clients performing quick
map/unmap/map cycles what also seems to induce the black
window issue on the nvidia blob.

CCBUG: 284888
BUG: 319184
FIXED-IN: 4.11
REVIEW: 111292
2013-07-01 21:19:54 +02:00
Martin Gräßlin e7ab3adafd New class to encapsulate a Window's Pixmap
The behavior for creating a pixmap for a window is moved from Toplevel
into a dedicated class WindowPixmap. Scene::Window holds a reference to
this class and creates a new WindowPixmap whenever the pixmap needs to be
discarded. In addition it also keeps the old WindowPixmap around for the
case that creating the new pixmap fails. The compositor can in that case
use the previous pixmap which reduces possible flickering. Also this
referencing can be used to improve transition effects like the maximize
windows effect which would benefit from starting with the old pixmap.

For XRender and OpenGL a dedicated sub-class of the WindowPixmap is
created which provides the additional mapping to an XRender picture and
OpenGL texture respectively.

BUG: 319563
FIXED-IN: 4.11
REVIEW: 110577
2013-06-05 08:18:11 +02:00
Martin Gräßlin 76d96506dc Remove damage argument in Toplevel::resetDamage
We always reset with the complete window geometry, so the subtracting
doesn't make any sense. We can just always set the damage to an empty
region.

REVIEW: 110438
2013-05-17 10:07:45 +02:00
Martin Gräßlin d305185247 Remove Workspace pointer from Toplevel
Instead have a simple workspace() method returning the pointer.
2013-05-13 08:28:16 +02:00
Martin Gräßlin ce9ce6f94c Remove unused typedefs in utils.h
There is no Const(Toplevel|Unmanaged|Deleted|Group)List used anywhere.
For ConstToplevelList there was a debug helper which was also unused.

REVIEW: 110196
2013-05-02 09:21:02 +02:00
Martin Gräßlin db18c08dd0 Move RootInfo and WinInfo into an own header and impl file
Main motivation for this change is that it's unhandy to have the class
definition in workspace.h and client.h while the implementation is in
events.cpp although nothing in events.cpp uses it directly.

By getting it out of workspace.h we get the header a little bit smaller
which should improve compile time given that it's included almost
everywhere.

In events.cpp the enum usage is changed to NETWinInfo as that's the class
where they are defined.

RootInfo does no longer hold a workspace pointer. Where it's needed it
uses the singleton accessor of Workspace.

REVIEW: 110199
2013-04-30 08:06:12 +02:00
Martin Gräßlin 4351d6ce44 Cleanup and reorder includes in toplevel.h
REVIEW: 110202
2013-04-26 12:33:44 +02:00
Martin Gräßlin 67b59f693c Uninline Toplevel::pid()
It's only used from one method and requires to have NETWinInfo being
included in the header.
2013-04-26 12:32:09 +02:00
Martin Gräßlin 94470f1ea2 Change Toplevel::damage_handle to xcb_damage_damage_t
Damage handling has already been ported to XCB - no need to keep it on an
XLib datatype.
2013-04-26 12:32:08 +02:00
Martin Gräßlin eb6ce2b7c4 Remove XDamageNotifyEvent* argument from Toplevel::damageNotifyEvent
It's not used...

REVIEW: 110201
2013-04-26 12:31:07 +02:00
Martin Gräßlin 2e758ed6a7 Add an elevate() method to Toplevel
Shortcut to set an elevated window without the need to check whether
effects pointer is valid and retrieving EffectWindow etc.

REVIEW: 110147
2013-04-25 09:08:27 +02:00
Martin Gräßlin edb074cbc2 Split out screen handling from Workspace into own class Screens
Following the approaches of other split out functionality Screens is a
singleton class created by Workspace.

The class takes over the responsibility for:
* screenChanged signal delayed by timer
* number of screens
* geometry of given screen
* active screen
* config option for active screen follows mouse

The class contains a small abstraction layer and has a concrete subclass
wrapping around QDesktopWidget, but the idea is to go more low level and
interact with XRandR directly to get more detailed information.

All over KWin the usage from QDesktopWidget is ported over to the new
Screens class.

REVIEW: 109839
2013-04-15 10:25:10 +02:00