Commit Graph

94 Commits (master)

Author SHA1 Message Date
Vlad Zahorodnii 12e59f9af8 Schedule workspace repaint for destroyed clients
We need to schedule a workspace repaint in case no effect is going to
animate the window.

The workspace repaint is issued before creating a Deleted because the
latter takes the owner of the effect window, which means that after an
instance of Deleted has been created, visibleRect() returns the frame
geometry.

CCBUG: 425294
2020-09-29 13:53:30 +00:00
Vlad Zahorodnii 0c266e760b Replace remaining usages of old connect syntax with new connect syntax
This change replaces the remaining usages of the old connect syntax with
the new connect syntax.

Unfortunately, there are still places where we have to use SIGNAL() and
SLOT() macros, for example the stuff that deals with d-bus business.

Clazy was used to create this change. There were a few cases that needed
manual intervention, the majority of those cases were about resolving
ambiguity caused by overloaded signals.
2020-09-24 09:33:45 +00:00
Vlad Zahorodnii 90b53f416c Use universal helper for writing toplevels to QDebug streams
Toplevel::debug() is one of annoyances that you need to deal with when
implementing a new client type. It can be tempting to just write "this"
to the stream, but it will result in a crash.

In order to make implementing new client types easier, this change
introduces a debug stream insertion operator overload that works for all
kinds of the Toplevel class.
2020-08-21 11:42:53 +00:00
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 19ad172584 Survive Xwayland crashes
If the Xwayland process crashes, it will bring down the entire session
together with itself. Obviously, we don't want that. At least, Wayland
clients should survive the crash.

This change refactors relevant X11 parts to handle Xwayland crashes in a
less fatal way.

In order to handle Xwayland crashes better, a pair of start() and stop()
methods had been introduced in the Xwayland class to allow starting and
stopping the Xwayland process at any moment.

If we detect that the Xwayland process has crashed, we will immediately
stop the Xwayland server, which in its turn will deactivate the socket
notifier and destroy all connected X11 clients. Unfortunately, a couple
of subtle changes in X11Client::releaseWindow() and Unmanaged::release()
had to be made to ensure that we are left with a valid state after the
Xwayland server has been stopped.
2020-08-05 08:48:00 +00:00
David Edmundson 1b4c725d10 Update clientGeometry for Unmanaged windows
It was udpated when we received a configure event but not in the initial
track.

The symptom of this being missed out was that blur would not be applied
to the window.

BUG: 423405
CCBUG: 423297
2020-06-30 14:59:54 +01:00
Vlad Zahorodnii cc3eb54b32 Introduce the client geometry in Toplevel
In most cases, we don't need to react to client geometry changes, but in
code that deals with server-side window decorations, we need to react to
client geometry changes. The problem is that frame and client geometry
updates are not correlated even though there is a connection between the
frame geometry and the client geometry.

This change introduces the client geometry in the Toplevel class in order
to allow monitoring client geometry updates from DecoratedClientImpl.
2020-06-18 07:40:58 +00:00
Vlad Zahorodnii 15af09c70a Introduce Toplevel::frameGeometryChanged signal
Summary:
Currently we have two signals that are emitted when the Toplevel's geometry
changes - geometryShapeChanged() and geometryChanged(). The former signal
is used primarily to invalidate cached window quads and the latter is
sort of emitted when the frame geometry changes. But it's not that easy. We
have a bunch of connects that link those signals together...

The worst part about all of this is that the window quads cache gets
invalidated every time a geometry update occurs, for example when user
moves a window around on the screen.

This change introduces a new signal and deprecates the existing geometryChanged
signal. frameGeometryChanged is similar to geometryChanged except that it is
emitted when an _actual_ geometry change has occurred.

We do still emit geometryShapeChanged signal. However, in long term, we
need to get rid of this signal or come up with something that makes sense
and doesn't require us to waste computational resources.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26863
2020-02-12 10:52:26 +02:00
Vlad Zahorodnii d394855536 Rename Toplevel::geom to Toplevel::m_frameGeometry
Summary: The new name better reflects what Toplevel::geom is.

Test Plan: Compiles, tests still pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25738
2019-12-04 15:47:15 +02:00
Vlad Zahorodnii 9f7a856d23 [wayland] Implement window geometry more properly
Summary:
So far the window geometry from xdg-shell wasn't implemented as it should
be. A toplevel must have two geometries assigned to it - frame and buffer.
The frame geometry describes bounds of the client excluding server-side
and client-side drop-shadows. The buffer geometry specifies rectangle on
the screen occupied by the main surface.

State and geometry handling in XdgShellClient is still a bit broken. This
change doesn't intend to fix that, it must be done in another patch asap.

Test Plan: New tests pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Maniphest Tasks: T10867

Differential Revision: https://phabricator.kde.org/D24455
2019-11-27 14:12:30 +02:00
Sian Cao 1177ef3720 [x11] Check pending release when mapping
Summary:
 when unmap notify is followed by a map, the old Unmanaged will get released and never be managed again. by checking if there is a pending release operation, we can safely re-manage the window again.

BUG: 413350

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin, scao

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24878
2019-10-24 18:20:24 +08:00
Vlad Zahorodnii 64feafc10f Mark Toplevel as not ready for painting by default
Summary:
Get rid of some duplication as InternalClient, XdgShellClient, Unmanaged,
and Client initialize ready_for_painting to false.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24189
2019-09-24 17:05:43 +03:00
Vlad Zahorodnii 4c7dd52728 Delete pointless GRAB_SERVER_DURING_CONTEXT macro
Summary: One could just use XServerGrabber class directly.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24119
2019-09-20 22:44:12 +03:00
Vlad Zahorodnii 5e71c2a608 Move supported window type masks to matching cpp files
Summary:
SUPPORTED_MANAGED_WINDOW_TYPES_MASK and SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK
are used only in client.cpp and unmanaged.cpp, respectively. So, it doesn't
make sense to keep these two in a header file.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24120
2019-09-20 22:44:12 +03:00
Vlad Zahorodnii 62a7db7028 Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.

This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 17:48:21 +03:00
Vlad Zagorodniy a035401b55 Use XCB wherever possible
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23756
2019-09-07 19:54:45 +03:00
Vlad Zagorodniy 0db071c218 Move Unmanaged-specific hack away from Toplevel::setupCompositing
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20590
2019-04-16 10:12:30 +03:00
Vlad Zagorodniy 3d46801e5f [wayland] Make sure that only the fading popups effect animates outline
Summary:
Window open/close animation effects should not animate the outline
because the end result is a bit awkward.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19886
2019-04-09 14:21:22 +03:00
David Edmundson 62d334eb61 [wayland] Move AbstractClient::desktops from QList to QVector
Summary:
Doesn't have any meaningful impact. It's the same performance when T is a pointer,
but it'll bring it consistent with VirtualDesktopManager::desktops

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16736
2018-11-07 16:22:59 +00:00
David Edmundson 7e8facc3fd [wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)

Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)

Test Plan: used a bit a plasma session together with D12820, D13748 and D13746

Reviewers: #plasma, #kwin, graesslin, davidedmundson

Reviewed By: #plasma, #kwin, davidedmundson

Subscribers: hein, zzag, davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T4457

Differential Revision: https://phabricator.kde.org/D13887
2018-11-01 16:35:29 +01:00
Martin Gräßlin 5ea88effee Implement addDamage in Unmanaged
For Xwayland Unmanaged needs to override the addDamage method and
update the repaints_region accordingly, otherwise the repaint is not
triggered for the Unmanaged window.

Reviewed-By: bshah
2016-08-12 11:32:48 +02:00
Kevin Funk 8ea4f4dae7 Port to CMake AUTOMOC
Summary: Run convert-to-cmake-automoc.pl over all .cpp files

Differential Revision: https://phabricator.kde.org/D882
2016-02-01 21:05:36 +01: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 cef84cd8a5 Use NETWinInfo::opaqueRegion
REVIEW: 122199
2015-01-26 11:47:40 +01:00
Martin Gräßlin b36b242f12 Port Unmanaged::track to XCB
Uses Xcb::WindowAttributes and Xcb::WindowGeometry instead of XLib
variant. In addition it uses the XServerGrabber to ensure that the
xserver grab is removed in all code paths.

A new macro is added to utils.h to make the grabbing of XServer in
current context more obvious.
2014-05-05 08:09:10 +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 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 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 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
Martin Gräßlin b0c0e81661 Adjust kde-workspace to changes in NETWMClient
ctor changed to take NET::Properties and NET::Properties2.
2014-03-17 08:13:14 +01:00
Martin Gräßlin fdee4ea8c8 Adjust kde-workspace to introduction of flags in NET classes 2014-02-05 17:40:19 +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 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 e21225fa47 Use XCB Shape instead of XLib Shape in KWin core 2013-08-20 09:48:14 +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
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 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 4351d6ce44 Cleanup and reorder includes in toplevel.h
REVIEW: 110202
2013-04-26 12:33:44 +02:00
Martin Gräßlin 89c2fd5598 Remove YesIKnowWhatImDoing from internal API
No need to have Allowed everywhere.

REVIEW: 110197
2013-04-26 12:29:42 +02:00
Martin Gräßlin 6d6b013720 Introduce a proper screen property in Toplevel
Instead of calculating the screen number each time screen() is invoked,
the screen number gets stored in a private member variable and evaluated
whenever either the screen count changes or the Toplevel's geometry
changes. During move/resize the screen property doesn't get updated. The
update is delayed till the end of the move/resize operation.

REVIEW: 109715
2013-04-02 08:21:01 +02:00
Martin Gräßlin b967527db3 Use XCB to resolve the X11 Extensions
The extension handling is removed from kwinglobals and moved into the
xcbutils in KWin core in namespace KWin::Xcb. The motivation for this
change is that the Extensions are only used in KWin core and are marked
as internal. So there is no need to have them in the library.

What remains in Extensions are the non-native pixmaps. This will be
removed once we are on Qt 5 as QPixmap can no longer reference an XPixmap.

The remaining code in kwinglobals also still initialize the XLib versions
of extensions emitting events. It seems like there are no XEvents emitted
if not done so even if the extension is correctly initialized with xcb.
This needs to be removed once the event handling is ported over to xcb.

REVIEW: 107832
2013-01-22 07:50:03 +01:00
Thomas Lübking 24cf0e75f3 Merge branch 'KDE/4.9'
Conflicts:
	kwin/scene.cpp
	plasma/generic/applets/batterymonitor/metadata.desktop
	plasma/generic/applets/lock_logout/metadata.desktop
2012-09-19 20:21:18 +02:00
Thomas Lübking 42ad299d88 Do not unlist Unmanaged when released onShutdown
BUG: 303244
FIXED-IN: 4.9.2
REVIEW: 106382
2012-09-19 20:16:34 +02:00
Martin Gräßlin 62d5e8124c Toplevel::windowType becomes a pure virtual function
The method windowType needs actually two implementations:
* one for Clients
* one for Unmanaged

as for Clients also the window rules are checked and hacks are applied
which is both not needed for Unmanaged windows.

To have the Client specific behavior in windowType the function used to
perform two dynamic_casts which made this method one of the most
expensive during compositing, e.g. for ~1000 frames
* called ~43000 times
* ~85000 dynamic casts
* incl. cost of method: 0.24
* self cost of method: 0.05
* incl. cost of the casts: 0.12

After the change to remove the dynamic casts we have for ~1500 frames
in Client::windowType:
* called ~31000 times
* incl. cost of 0.06
* self cost of 0.02

Calls on Unmanaged and Deleted are so low that we do not need to consider
them.

BUG: 306384
FIXED-IN: 4.10
REVIEW: 106349
2012-09-07 08:03:05 +02:00
Martin Gräßlin 563dc7fb8e Do not create Deleted on Workspace Shutdown
When the Workspace is shutting down the compositor is torn down
before Clients and Unmanaged are released. This means that there
is no need to create the Deleted windows.

Furthermore creating the Deleted manipulates the stacking_order
while Workspace dtor loops over this list to release all clients.
This may cause crashes.

BUG: 282933
FIXED-IN: 4.9.0
REVIEW: 104690
2012-04-22 17:50:20 +02:00
Philipp Knechtges 2c08a14ff4 kwin: implement _KDE_NET_WM_OPAQUE_REGION
This patch implements an XProperty named _KDE_NET_WM_OPAQUE_REGION
which gives the compositor the information which part of a window
is opaque although it is an ARGB visual. The basic ideas are from
http://www.mail-archive.com/wm-spec-list@gnome.org/msg00715.html

Additionally the patch makes kwin  use this information to do a better
clipping in Scene::paintSimpleScreen which should result in a higher
performance.

REVIEW: 102933
2011-10-23 17:09:44 +02:00