Commit Graph

392 Commits (8543033d59c5bfb2ae034bf39fa5cf61a626d2ed)

Author SHA1 Message Date
Martin Gräßlin 82e5b1a5cc Drop support for _KDE_WM_CHANGE_STATE
It was only used by KWindowSystem::minimizeWindow and ::unminimizeWindow
and got removed from there.

REVIEW: 118224
2014-05-26 09:06:34 +02:00
Martin Gräßlin 97726a4b1f [TabBox] Fix forcedGlobalMouseGrab
Was incompletely moved to TabBox after splitting out from Workspace.

REVIEW: 118259
2014-05-23 07:31:00 +02:00
Martin Gräßlin 165bab24f2 Use XCB enum values in Client::updateMouseGrab instead of XLib defines 2014-05-22 15:31:55 +02:00
Martin Gräßlin 9cce470c35 Turn Client::delayedMoveResize() into a lambda slot
Only used for the delayedMoveResizeTimer as timeout slot. Code is small
so a lambda makes more sense. At the same time the code is slightly
improved to ensure that startDelayedMoveResize is never called while
the timer is already active.

This means that mousePressEvents are now required to come from the
decoration.

REVIEW: 117843
2014-05-07 10:21:03 +02:00
Martin Gräßlin d2bbb42feb Install event filter for QWindow based decorations
Also with QWindow based decorations the event filter is needed to
properly react on mouse button release and mouse move. Those are not
passed through KDecoration unlike the button press.

The event filter is adjusted to handle both filters installed on QWidget
and QWindow while QWindow only gets to see a subset of the events.

This fixes mouse interaction in Aurorae.

REVIEW: 117879
2014-05-05 08:12:00 +02:00
Martin Gräßlin cd6ed49299 Port XCB_CONFIGURE_REQUEST handling to XCB
Uses xcb_configure_window instead of XLib variant.
2014-05-05 08:09:10 +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 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 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 fd0fd82ad6 Use NETWM to get updates on blocking compositing
Adds NET::WM2BlockCompositing to the Client's properties which allows to
read the state from the NETWinInfo object and get updates without having
to resolve the atom ourselve.

REVIEW: 117561
2014-04-14 15:34:39 +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 9075b5e2d6 [kwin] Remove cursorPos() from utils.h
Only delegated to Cursor::pos() anyway, so let's just use that directly.
Fixes the annoyances of having to mock it in the unit tests which include
utils.cpp.

REVIEW: 116900
2014-03-25 15:25:40 +01: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 970e8765f0 [kwin] Remove support for _NET_WM_TAKE_ACTIVITY protocol
As can be seen in [1] the patches to KWin were in CVS HEAD before the
protocol got standardized and it never got any adoption. It's neither in
the NETWM spec, nor implemented in Qt4 nor in Qt5. KWin did not even add
the protocol to the NET::Supported property.

Thus it doesn't make much sense to keep a protocol which nobody speaks.

Still the code around the protocol is kept and also the names are kept.
Only difference is that Client::takeActivity got removed and the code
moved to the only calling place in Workspace. Motivated by that change
the enum defined in utils.h is moved into Workspace, it's turned into
a proper QFlags class and used as a type in the method argument instead
of a generic long.

[1] https://mail.gnome.org/archives/wm-spec-list/2004-April/msg00013.html

REVIEW: 116922
2014-03-25 15:03:21 +01:00
Martin Gräßlin abecbf2369 [kwin] Port away from deprecated functionality in KWindowSystem
Less warnings and more type safety.
2014-03-17 10:22:20 +01:00
Martin Gräßlin ed4a0d0319 Screenedge show support for Clients
This provides a new protocol intended to be used by auto-hiding panels
to make use of the centralized screen edges. To use it a Client can
set an X11 property of type _KDE_NET_WM_SCREEN_EDGE_SHOW to KWin.
As value it takes:
* 0: top edge
* 1: right edge
* 2: bottom edge
* 3: left edge

KWin will hide the Client (hide because unmap or minimize would break
it) and create an Edge. If that Edge gets triggered the Client is shown
again and the property gets deleted. If the Client doesn't border the
specified screen edge the Client gets shown immediately so that we
never end in a situation that we cannot unhide the auto-hidden panel
again. The exact process is described in the documentation of
ScreenEdges. The Client can request to be shown again by deleting the
property.

If KWin gets restarted the state is read from the property and it is
tried to create the edge as described.

As this is a KWin specific extension we need to discuss what it means
for Clients using this feature with other WMs: it does nothing. As
the Client gets hidden by KWin and not by the Client, it just doesn't
get hidden if the WM doesn't provide the feature. In case of an
auto-hiding panel this seems like a good solution given that we don't
want to hide it if we cannot unhide it. Of course there's the option
for the Client to provide that feature itself and if that's wanted we
would need to announce the feature in the _NET_SUPPORTED atom. At the
moment that doesn't sound like being needed as Plasma doesn't want to
provide an own implementation.

The implementation comes with a small test application showing how
the feature is intended to be used.

REVIEW: 115910
2014-02-26 12:54:00 +01:00
Martin Gräßlin 0b32e5e57d [kwin] Listen to mouse motion events in the screenedge windows
Problem description: if a window decoration is in the screenedge
(not really unlikely for maximized windows) we either did not get
mouse events to the decoration or the screenedge window. E.g. the
enter event didn't reach the approach window which means it doesn't
get unmapped and thus the motion events in that area are not passed
to the decoration below. The same happened for the screenedge window,
the enter event was just not delivered if there is a window decoration
in the edge.

To solve this problem we listen for motion events in the approach and
the edge window and pass them from the event filter to the screen edges.
If one of our windows contains that the position of the motion event
we trigger the edge just in the same way as we do with the enter event.
2014-02-01 10:03:49 +01:00
Martin Gräßlin 7c7f137832 [kwin] Drop handling for mouse motion event compression
Not needed as Qt does it for us in the xcb plugin - see
QXcbConnection::processXcbEvents().
2014-02-01 09:34:40 +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 302271ce97 [kwin] Client supports an X property for color scheme
The X property _KDE_NET_WM_COLOR_SCHEME can be set on a window and
specifies the absolute path to a .color file describing the color
scheme of the managed client.

The Client reads this property and creates a QPalette from it. If
the property is not set or the value is incorrect, the Client uses
KWin's default palette.

The idea behind this property is to allow an application with a
custom color scheme to tell KWin which color scheme the window
decoration should use. So that the window looks as a solid pattern
again.
2013-11-25 09:41:24 +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 b6f9bd988b [kwin] Do not filter out button release events for moving clients
The QWidget of the window decoration is otherwise still thinking that
the button is pressed and waits for a release. Thus the next click on
the decoration doesn't trigger the move mode.
2013-11-13 14:40:57 +01:00
Bhushan Shah 935851a2b5 kDebug -> qDebug in kwin 2013-11-01 17:00:41 +05:30
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
Casian Andrei b0ba49cbdf Fix check for no button pressed in Client::buttonReleaseEvent()
There is a check in Client::buttonReleaseEvent() for the state of the
mouse buttons compared to the button masks for button 1, 2, 3 (X11
button indices).

The check was:
if ((state & (Button1Mask & Button2Mask & Button3Mask)) == 0) { ... }
<=> if (state & 0 == 0) <=> if (true)

This change assumes what the check was supposed to be and fixes the problem. The correct fix was proposed by Thomas.

REVIEW: 113359
2013-10-23 13:23:20 +03: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 67cb571f86 fix two damage artifact causes
1. when adding a full damange, that must not replace existing (larger) repaints
2. emit geometryChanged before invoking and to update shadowGeometry through addRepaintFull

BUG: 324560
FIXED-IN: 4.11.2
2013-09-24 00:50:54 +02:00
Martin Gräßlin 5eb69aba9c Switch to XCB_BUTTON_INDEX* for Pointer Button constants 2013-09-13 09:12:26 +02:00
Martin Gräßlin 85152773fc Fix wrong enum
Why do they have to sound so similar?
2013-09-13 09:11:10 +02:00
Martin Gräßlin a90072d753 Merge KDecorationUnstable into KDecoration
Also KCommonDecorationUnstable is merged into KCommonDecoration.
2013-09-12 09:27:38 +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 439122e2bc Use Xcb::CurrentInput in the focus in event handler 2013-09-10 15:30:11 +02:00
Martin Gräßlin 77edf8eb69 Port all XAllowEvents to xcb_allow_events in kwin 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 57905c0cc2 And we got rid of KDebug
Usages of kBacktrace got dropped.
2013-09-02 13:14:39 +02:00
Martin Gräßlin 16df417cc6 XCB variant for displayWidth/Height and update after RandR event
DisplayWidth and height provide proper values though internally
things are wrong as QDesktopWidget seems to not emit the signal.
2013-09-02 10:23:30 +02:00
Martin Gräßlin 7ed07e45c7 Do not pass events with no window to the findClient - windowEvent cascade
If the eventWindow is none the check for InputIdMatchPredicate will find
a matching Client and pass the even through the windowEvent filter which
returns true for all not handled events and thus filters out all events
processed later on in KWin.

This explains why some events were eaten...
2013-08-30 13:34:29 +02:00
Martin Gräßlin 37334f400a Drop no longer needed XLib includes from KWin 2013-08-20 10:29:20 +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 9c225200bf Fix typo 2013-08-13 11:24:07 +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 46f57221e4 Mouse motion event compression
Using a QTimer to move the resize/move related code to the end of the
event queue. In case there is another motion event in the queue it will
cancel the timer.
2013-08-06 11:20:27 +02:00
Martin Gräßlin 330003cdee Replacement for XEvent queue inspection in FocusOut event case
Instead of inspecting the XEvent queue we create a Timer with a
singleshot of 0 msec to move the setActive(false) call to the end of the
event handling. In case there is a matching FocusIn event this will be
handled before the timer fired and can cancel the timer.
2013-08-05 09:48:14 +02:00
Thomas Lübking 6c420f2b11 don't require geometry changes for quick max/tile
the present check can break quick everything depending
on screen snapping settings.
It so far. only worked for quick maximization due to horizontal
"judder" and failed whenever that judder was not possible
(due to screen snapping on left and/or right edge)

BUG: 322852
FIXED-IN: 4.11
REVIEW: 111740
2013-08-02 22:04:28 +02:00
Martin Gräßlin 4b97fb542e Enable passing xcb events through NETRootInfo and NETWinInfo
Requires ab8f4532f5f12db19bcc09c1f297f1b7d55efb48 from frameworks.
2013-08-02 13:53:21 +02:00
Martin Gräßlin 41bb797919 Fix Client unmapNotify event handling
We get the missing send event attribute from anding the event's
response type with 0x80.

This fixes the issue that all open windows got unmapped. The reason for
this was that the existing new Client got reparented to the wrapper which
caused the UnmapNotify event which we used to release the Client and by
that unmapping the window completely.
2013-08-02 10:30:25 +02:00