Commit Graph

1171 Commits (9995f984c3e43de7b1a6b327c592bff37f8b7c1a)

Author SHA1 Message Date
David Edmundson efc62941ee [wayland] Place all toplevels before the first configure
Summary:
Currently popups get positioned once at the initial configure, to set
the correct size and again when they are mapped.

Toplevels are currently only positioned when they are mapped. This works
for all cases where the the toplevel defines its own size, but not if
the window should have an initial size set by the placement strategy or
window rules. Most notably the maximised placement strategy used on
plasma mobile.

Being out of sync and resizing later currently causes a positioning bug
when plasma mobile is used with XdgShell.

This patch repositions all top levels that don't have a position set
through the plasma interface.

Test Plan: Relevant unit test

Reviewers: #kwin, bshah

Reviewed By: bshah

Subscribers: zzag, bshah, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20241
2019-04-09 11:15:02 +01:00
Vlad Zagorodniy f10760d8a9 [wayland] Finish active move-resize op when client is destroyed or unmapped
Summary:
It might happen that the moving client gets closed or crashes. In that
case, we have to manually reset Workspace::movingClient, otherwise KWin
will most likely crash later on.

BUG: 405379

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19708
2019-04-09 08:47:31 +03:00
Kai Uwe Broulik 68fca9a613 Merge branch 'Plasma/5.15' 2019-04-01 10:34:45 +02:00
Kai Uwe Broulik dc552ee2ae Force server-side decoration if no borders are forced by user
Otherwise the client will start drawing its own border now.

BUG: 405385
FIXED-IN: 5.15.4

Differential Revision: https://phabricator.kde.org/D19705
2019-04-01 10:29:45 +02:00
Marco Martin 6bc2ddd56a virtualkeyboard: resize the focused window to make room for the keyboard
Summary:
alternative approach: try to resize the winidow to make room for the keyboard.
the new input wayland protocol doesn't have anymore the overlap rectangle (and it would not be going to work with qwidget apps anyways)

in the future will probably be needed anextension to the input protocol v3 which partially gets back this, tough window resizing is needed regardless

what's missing: the resize should be "temporary" and the window should be restored to its previous geometry when the keyboard closes

Test Plan: tested with test QML code

Reviewers: #plasma, #kwin, bshah, graesslin, romangg, davidedmundson

Reviewed By: #plasma, #kwin, romangg, davidedmundson

Subscribers: nicolasfella, mart, kwin, davidedmundson, graesslin

Tags: #kwin

Maniphest Tasks: T9815

Differential Revision: https://phabricator.kde.org/D18818
2019-03-20 11:05:06 +01:00
David Edmundson 768e5fb7f4 [autotests] Fix race condition in ShellClient::testUnresponsiveWindow
Summary:
The test executable "kill" freezes itself after 1ms, supposedly after
showing a window.

However showing a window is not syncronous on wayland, it's illegal to
map a buffer before getting a configure event from the server.

This patch removes any potential for a race by having the server tell
our test executable when to freeze.

Test Plan: Test still passed

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19406
2019-02-28 02:09:33 +00:00
David Edmundson 6ddf50a77b [autotests] Fail faster on test which fails anyway
Summary:
The .wait() in this case isn't really time depdenent, we just need to
process the event loop.

Given we know this tests fails, there's no point me waiting 30s.

Test Plan: Test failed, but faster

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19351
2019-02-28 01:41:16 +00:00
David Edmundson 2bad2b48fe [wayland] Finish initialising ShellClient only when commited to the surface
Summary:
Everything on the wl_surface is double buffered.

When we create an XdgShell toplevel or popup we shouldn't treat it as
attached until it's committed to the surface.

A client should commit the surface after it's sent it's initial state of
the Xdg topLevel; minimumSize, title, app_id, etc.

By blocking sending configure events we will have flushed the correct
initial state before sending a single atomic correct event to the
client. It also adds a hook to re-evaluate rules now that all properties
are set.

Arguably this applies to WlShellSurface too, but I've left it unchanged
as it's deprecated and hard to verify real client behaviour.

Test Plan: Ran all unit tests

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18583
2019-02-26 13:51:28 +00:00
David Edmundson dc7ea09e8d [autotests] Check the configure request sent to popups
Summary:
We currently check the final position kwin knows about.
This patch also checks the position the popup is told that
it's in as well as acking configure requests correctly.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18955
2019-02-26 13:41:00 +00:00
Vlad Zagorodniy dffd9777c7 [libkwineffects] Make AnimationEffect::AniMap protected
Summary:
We need AniMap only for test purposes so it would be better to make the
typedef protected (and mark as internal as well).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17833
2019-02-26 11:37:44 +02:00
David Edmundson 5e9023948e [wayland] Keep application startup flow inside main_wayland
Summary:
In a recent patch the newly added xwayland class ended up being
responsible for continuing the startup, calling back into the main app
to spawn the workspace.

It moves the flow of startup about so it's not very readable or
following class structure.

This patch moves the code back into main_wayland and removes the
duplication between xwayland and non-xwayland modes.

There was also a misnaming of methods.

Previously:
continueStartupWithScreens was called after platform screens are created
continueStartupWithScene was called after the scene was created
continueStartupWithXwayland was called before xwayland is created

This was confusing, so the names have been shuffled around to follow a
consistent pattern of what has been done so far.

Test Plan:
Started kwin_wayland in normal and xwayland mode
Ran unit tests (though some failed due to a local unrelated and as yet unindentified bug)

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19232
2019-02-23 12:18:09 +00:00
Sebastian Krzyszkowiak 7bf2c1d73e [wayland] Fix window sizing when restoring a window that was initially fullscreen
Summary: When creating a surface and setting it as fullscreen before
attaching its buffer KWin does not know the original dimensions of the
surface and tries to use an invalid value when unsetting the fullscreen
flag. This patch fixes this by sending a configure with the size of 0,0
- which according to xdg-shell spec means that the client is requested
to set its size by itself.

Test Plan:
1. Create a fullscreen Wayland window.
2. Toggle fullscreen off.
3. KWin should send a configure event with size 0,0 instead of 1,1.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: zzag, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16710
2019-02-22 18:58:22 +00:00
Martin Flöser cbbe94d769 Restrict available supported compositors based on first initialized one
Summary:
On Wayland we cannot switch from OpenGL to QPainter compositor as this
would break any running OpenGL application. KWin registers it's
EGLDisplay to Wayland and without OpenGL this doesn't make sense any
more. We are not able to render OpenGL buffers in the QPainter
compositor.

While it's theoretically possible to switch from QPainter to OpenGL it
doesn't make any sense for the same reason. Any running OpenGL
application would be using llvmpipe and could not be switched to proper
OpenGL.

This change stores the selected compositing type in Platform and the
implementations can use it to restrict the supported compositors. On X11
we don't need this, all other Platforms implement the restriction. Thus
it's no longer possible to switch the backends at runtime.

Test Plan:
Adjusted tests run, no runtime test as gui doesn't support
switching to QPainter anyway.

Reviewers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19084
2019-02-22 16:59:08 +01:00
David Edmundson 47be4be020 [scripting] Make DBus invokable run method return result after execution
Summary:
In 403038 the user expected the DBus call to run to finish before
processing the next request. For a singleshot script that makes a lot of
sense, otherwise you have no idea when it finishes.

This also allows us to return errors.

CCBUG: 403038

Test Plan:
NUM=$(qdbus org.kde.KWin /Scripting org.kde.kwin.Scripting.loadScript /noFile.js Minimize)
qdbus org.kde.KWin /$NUM org.kde.kwin.Scripting.run
  Error: org.kde.kwin.Scripting.FileError
  Could not open /noFile.js

Running a real script behaved effectively the same as before.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18127
2019-02-22 14:40:15 +00:00
Roman Gilg d0422eb79f Remove unnecessary flushs in new buffer size change test 2019-02-21 23:42:47 +01:00
Roman Gilg 06f64d5e56 [autotests] Sub-surface resize test
Summary:
Adds an autotest to show that KWin fails an assertion when a client tries to
resize a sub-surface.

Since it is the first autotest dealing with sub-surfaces explicitly additional
autotest helpers are introduced to allow that.

We also add a new signal in Compositor to spy on to know when the buffer swap
has been completed.

Test Plan:
Test fails as expected:
```
QFATAL : KWin::BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface() ASSERT: "image.size() == m_size" in file /home/roman/dev/kde/src/kde/workspace/kwin/platformsupport/scenes/opengl/abstract_egl_backend.cpp, line 394
FAIL!  : KWin::BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 4 passed, 1 failed, 0 skipped, 0 blacklisted, 367ms
********* Finished testing of KWin::BufferSizeChangeTest *********
```

Reviewers: #kwin, zzag

Subscribers: zzag, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18452
2019-02-21 23:33:32 +01:00
Martin Flöser 9b922f8833 Split out a dedicated InternalClient class
Summary:
Most of the functionality which is special to internal clients is moved
from ShellClient to InternalClient. As KWin's qpa is still bound to the
Wayland protocol InternalClient inherits from ShellClient. Due to that
some aspects in ShellClient are "weird". ShellClient still detects
whether it's an internal client and uses the variable m_internal to
capture the state. This is required as we cannot use the isInternal
method. Most of m_internal usage is in init which is called from
constructor of ShellClient. Thus it's not possible to call into virtual
methods of InternalClient.

Also some of the code is duplicated and some methods are temporarily
marked as virtual.

The next step will be to remove ShmBuffer for internal windows which
should decouple the two implementations further with the long term goal
of having InternalClient inherit AbstractClient directly.

Test Plan:
Run nested KWin, triggered outline (OpenGL case) and debug console (shm case).
InternalWindow unit test still passes.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18569
2019-02-21 18:51:25 +01:00
David Edmundson 3cdea2f77c [wayland] Fix typo in method name
Test Plan: Compile + grep

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19177
2019-02-20 13:19:24 +00:00
Roman Gilg 2776f829ef Remove X clipboard sync helper and rename its autotest
Summary:
With the gneric X selections infrastructure and clipboard support the X
clipboard sync helper utility can be removed. Also rename its autotest as it
tests the inner workings of the new mechanism since this mechanism was
introduced.

Test Plan: Autotest still passes under new name.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15063
2019-02-19 12:30:43 +01:00
Roman Gilg 6e08fb2fa5 [xwl] Generic X selections translation mechanism with Clipboard support
Summary:
In this patch an infrastructure is created to represent generic X selections
in a Wayland session and use them for data transfers between Xwayland windows
and Wayland native clients.

The central manager is the DataBridge class, in which Selection objects can be
created. This is hard-coded and such a Selection object persists until the end
of the session, so no arbitrary selections can be created on the fly. For now
the X Clipboard selection is supported, whose corresponding mechanism in the
Wayland protocol is just called Selection.

A Selection object listens for selection owner changes on the X side and for
similar events into the Wayland server interfaces. If a data provider is
available a selection source object is created by the Selection object. In case
data is requested on the other side, a data transfer is initialized by creating
a Transfer object. A Selection keeps track of all transfers and makes sure that
they are destroyed when they are finished or in case they idle because of
misbehaving clients.

The Clipboard class translates the X Clipboard via a proxy window. Selection
changes on the Wayland side are listened to through a new signal on the active
KWayland seat interface.

The previously used X clipboard syncer helper is disabled. The clipboard sync
autotest is changed to the new mechanism.

BUG: 394765
BUG: 395313

Test Plan: Manually and clipboard sync autotest.

Reviewers: #kwin

Subscribers: zzag, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15061
2019-02-19 12:24:27 +01:00
Roman Gilg 608a89a85b [autotests] Use Xwayland class in WaylandTestApplication
Summary:
By using the new Xwayland class we can reduce code duplication.

An abstract parent class is introduced, that allows interfacing
with the Xwayland class from the test binaries.

Test Plan: Autotests still pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15022
2019-02-19 12:18:33 +01:00
David Edmundson 5fa18646b6 [autotests] Fix typo in autotest name 2019-02-12 12:38:35 +00:00
Vlad Zagorodniy 5ad797d5fe [autotests] Test maximize animation
Test Plan:
    dbus-run-session ctest -R testMaximizeAnimation

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18166
2019-02-01 13:50:40 +02:00
Vlad Zagorodniy 621370d729 [autotests] Test minimize animations
Test Plan:
    dbus-run-session ctest -R testMinimizeAnimation

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18162
2019-02-01 13:50:40 +02:00
Vlad Zagorodniy 872831fb15 [autotests] Test desktop switching animations
Summary:
The new test verifies some common things about desktop switching
animation effects, it doesn't verify what each of one them is doing
because it wouldn't be worth it.

Test Plan:
    dbus-run-session ctest -R testDesktopSwitchingAnimation

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18156
2019-02-01 13:50:40 +02:00
Vlad Zagorodniy 97cf32f916 Drop ShellClient::shellSurface method
Summary:
The only place where this method is used is testMaximize. Though that
usage is not justified. We're checking what KWayland already checks.

Test Plan: Compiles, all tests still pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18635
2019-02-01 12:54:27 +02:00
David Edmundson 18dd0327c2 [autotests] Untangle ShellClient::testMaximizedToFullscreen
Summary:
XdgShell and WlShell behave very differently when it comes to switching
from normal to maximised to fullscreen and back. Under XDGShell they are
2 properties, under WlShell it's a tristate enum.

This test was testing something very specific under WlShell and then
became a horrid mess of if statements doing different things and testing
different things, especially after XdgShell got proper configure
handling.

This patch splits it into two methods.

Test Plan:
Ran test
Passed

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18589
2019-01-29 12:31:06 +00:00
Martin Flöser 07e394fbb7 Fix unused param warning
Sorry for introducing them.
2019-01-27 14:03:53 +01:00
Martin Flöser 932ccb2ac3 Switch ThumbnailItem to internal uuid instead of WId
Summary:
So far the ThumbnailItem in TabBox mode used the window id for finding
the window it should render a thumbnail on. In the Wayland world this is
not unique. The window id could be either an X11 window or a wayland
window. We don't guarantee that there are no conflicting ids.

With the internal id we have a way to properly identify the windows, so
this element should use them.

To support this the property changed the type to QUuid and the
clientmodel also provides the QUuid. As in TabBox the way to get the
window is through the model this should be compatible for all themes.
It's tested and verified with the Breeze switcher.

For declarative KWin scripts the ThumbnailItem also provides the
AbstractClient as a property, so there should not be any script which
uses wid. If it does, this could break, but well the script should use
the intended API.

Test Plan: ctest passes, manual testing of Breeze alt-tab switcher

Reviewers: #kwin

Differential Revision: https://phabricator.kde.org/D18405
2019-01-27 09:52:15 +01:00
Martin Flöser 02a0561016 Add windowsystem plugin for KWin's qpa
Summary:
KWindowSystem provides a plugin interface to have platform specific
implementations. So far KWin relied on the implementation in
KWayland-integration repository.

This is something I find unsuited, for the following reasons:
 * any test in KWin for functionality set through the plugin would fail
 * it's not clear what's going on where
 * in worst case some code could deadlock
 * KWin shouldn't use KWindowSystem and only a small subset is allowed
to be used

The last point needs some further explanation. KWin internally does not
and cannot use KWindowSystem. KWindowSystem (especially KWindowInfo) is
exposing information which KWin sets. It's more than weird if KWin asks
KWindowSystem for the state of a window it set itself. On X11 it's just
slow, on Wayland it can result in roundtrips to KWin itself which is
dangerous.

But due to using Plasma components we have a few areas where we use
KWindowSystem. E.g. a Plasma::Dialog sets a window type, the slide in
direction, blur and background contrast. This we want to support and
need to support. Other API elements we do not want, like for examples
the available windows. KWin internal windows either have direct access
to KWin or a scripting interface exposed providing (limited) access -
there is just no need to have this in KWindowSystem.

To make it more clear what KWin supports as API of KWindowSystem for
internal windows this change implements a stripped down version of the
kwayland-integration plugin. The main difference is that it does not use
KWayland at all, but a QWindow internal side channel.

To support this EffectWindow provides an accessor for internalWindow and
the three already mentioned effects are adjusted to read from the
internal QWindow and it's dynamic properties.

This change is a first step for a further refactoring. I plan to split
the internal window out of ShellClient into a dedicated class. I think
there are nowadays too many special cases. If it moves out there is the
question whether we really want to use Wayland for the internal windows
or whether this is just historic ballast (after all we used to use
qwayland for that in the beginning).

As the change could introduce regressions I'm targetting 5.16.

Test Plan:
new test case for window type, manual testing using Alt+Tab
for the effects integration. Sliding popups, blur and contrast worked fine.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18228
2019-01-27 08:59:58 +01:00
Vlad Zagorodniy 6740db7a6c [autotests] Use unloadAllEffects
Test Plan: The tests still pass.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18383
2019-01-20 13:52:30 +02:00
Vlad Zagorodniy 8877dff715 [autotests] Update tests to use stable version of xdg-shell
Test Plan: All tests pass.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18292
2019-01-20 13:52:30 +02:00
David Edmundson 2df9d22a08 Add high DPI support to internal KWin windows
Summary:
So far we didn't try to do high DPI on kwin internal windows, such as
the user context menu and tab bars and whatever.

Due to wayland scaling they were the correct phyiscal size but upscaled.
This patch fixes our QPA to enable Qt's high-dpi support.

BUG: 402853

Note icons are still low res. This is because the global
QGuiApplication::devicePixelRatio which is the max of all connected
screens is static for the duration of the app. QIcon uses this when
determining the DPR to use. This will require a Qt change.

Test Plan:
Ran at 2x on my normal DPI screen (as that's easier to see anything)
* User action menu is high DPI
* Window deco tooltips are still fine
* Tab switcher is high DPI
* Overlay in present windows Desktop grid are still ok

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18042
2019-01-14 13:59:05 +00:00
Martin Flöser c2c92fab51 Ensure the Compositor does not start during termination
Summary:
The SceneOpenGLES test was starting to randomly crash on my system. On
investigation I observed that there was a graphics reset ("Attempting to
reset compositing.") which triggered a delayed restart of the
compositor. This even was only processed while waiting for XWayland to
terminate. Which resulted in a crash in KWin::getXServerVersion as the
xcb connection broke.

It makes no sense to setup the compositor again during application
shutdown. Thus the dtors set a flag that they are terminating the
application and Compositor::setup is checking for it.

Test Plan: Test no longer crashes, although it goes through the crashing path

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18015
2019-01-12 07:36:55 +01:00
Martin Flöser 99df3c82f3 [autotests] Don't check whether there is a /dev/dri/card0
Summary:
With EGL_MESA_platform_surfaceless we don't need a dri device anymore.
So we don't need to skip the tests if the device is missing. Instead the
tests verify that OpenGL compositing is used if requested.

Test Plan: ctest passes

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18014
2019-01-12 07:36:28 +01:00
David Edmundson 67bfad001d [autotests] Update virtual desktop layout after load
Summary: This matches the behaviour of workspace.cpp on initial load.

Test Plan: Test now passes

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18183
2019-01-11 14:19:09 +00:00
Vlad Zagorodniy 2e2a462733 [wayland] Don't honor the idle inhibitor object if the surface is not visible
Summary:
Currently, our implementation of zwp_idle_inhibitor_v1 is not fully
spec-compliant. If the associated surface is not visible, we still
honor the idle inhibitor object.

This change addresses those spec-compliance issues. If a surface is
minimized or it's not on the current virtual desktop, then the
associated inhibitor object won't be honored by KWin.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17343
2019-01-11 15:14:16 +02:00
Marco Martin e983319d0d Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes

Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed

Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin

Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin

Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin

Tags: #kwin

Maniphest Tasks: T4457

Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 10:10:39 +01:00
Vlad Zagorodniy 30b257be08 [autotests] Test popup open/close animations
Summary:
The new test is similar to testToplevelOpenCloseAnimation. The
main purpose of this test is to verify that the Fading Popups effect
animates all sorts of popups, e.g. popup menus, tooltips, etc.

testAnimateUserActionsPopup is skipped for now because stuff
that animates unmapped clients is broken.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17992
2019-01-08 15:48:22 +02:00
Vlad Zagorodniy ef7b553cb4 [libkwineffects] Port the remaining bits of API to dynamic dispatch
Summary:
7834bec52a missed to port minimize and
unminimize to dynamic dispatch. In addition to that, we don't benefit
from QMetaObject::invokeMethod so port addRepaint and addLayerRepaint
to dynamic dispatch as well.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18049
2019-01-07 21:40:45 +02:00
Vlad Zagorodniy 3f13a493c8 [autotests] Destroy main window in ToplevelOpenCloseAnimationTest::testDontAnimatePopups
Summary: Be nice and destroy all created windows in testDontAnimatePopups.

Test Plan: The test still passes.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18037
2019-01-07 15:09:22 +02:00
Vlad Zagorodniy 72b9a75cd7 [autotests] Avoid useless waits in testToplevelOpenCloseAnimation
Summary:
Use QTRY_VERIFY instead of qWait + QVERIFY to avoid useless waits.
Effects like scale or glide don't last longer than 200ms.

Test Plan:
Before:
    $ dbus-run-session ctest -R testToplevelOpenCloseAnimation
    Test project /home/vlad/Workspace/KDE/build/kde/workspace/kwin
        Start 123: kwin-testToplevelOpenCloseAnimation
    1/2 Test #123: kwin-testToplevelOpenCloseAnimation ...............   Passed    6.43 sec
        Start 124: kwin-testToplevelOpenCloseAnimation-waylandonly
    2/2 Test #124: kwin-testToplevelOpenCloseAnimation-waylandonly ...   Passed    6.33 sec

    100% tests passed, 0 tests failed out of 2

    Total Test time (real) =  12.76 sec

After:
    $ dbus-run-session ctest -R testToplevelOpenCloseAnimation
    Test project /home/vlad/Workspace/KDE/build/kde/workspace/kwin
        Start 123: kwin-testToplevelOpenCloseAnimation
    1/2 Test #123: kwin-testToplevelOpenCloseAnimation ...............   Passed    2.05 sec
        Start 124: kwin-testToplevelOpenCloseAnimation-waylandonly
    2/2 Test #124: kwin-testToplevelOpenCloseAnimation-waylandonly ...   Passed    2.00 sec

    100% tests passed, 0 tests failed out of 2

    Total Test time (real) =   4.05 sec

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17989
2019-01-05 18:32:14 +02:00
Martin Flöser 6b3e55d6f5 Implement isPopupWindow for internal windows
Summary:
Just accessing Qt::Popup WindowFlag.

BUG: 402852

Test Plan: Not tested for the described problematic case

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17981
2019-01-05 13:45:53 +01:00
David Edmundson ac45977e9e [wayland] XdgDecoration Support
Summary:
Does something similar to our existing ServerDecoration, but based
around XDG Shell patterns and with a few subtle differneces.

We'll probably still need both in kwin for the forseeable future as GTK3
won't ever change from using the KDE Server Decoration.

Test Plan:
Relevant unit test. It's a bit simpler as spec states
toolkits must follow what the compositor configures if they
bind the interface.

Modified plasma-integration to remove ServerIntegration
(as Qt5.12 has native support) all my windows look and act the same.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17756
2019-01-01 17:53:48 +00:00
Vlad Zagorodniy 48d13379c3 [autotests] Add tests for keep-above and keep-below states
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16252
2019-01-01 17:29:14 +02:00
Vlad Zagorodniy 1ca2aec77f [wayland] Don't use hardcoded move-resize cursor
Summary:
Currently, when resizing a window the cursor doesn't match the resize
direction. The reason for that is the move-resize cursor is hardcoded.

To fix that, CursorImage::updateMoveResize has to use AbstractClient::cursor.
Also, because the move-resize cursor is updated after calling startMoveResize,
we have to connect to AbstractClient::moveResizeCursorChanged.

BUG: 370339
FIXED-IN: 5.15

Reviewers: #kwin, davidedmundson, broulik, romangg, graesslin

Reviewed By: #kwin, graesslin

Subscribers: davidedmundson, romangg, graesslin, kwin

Tags: #kwin

Maniphest Tasks: T5714

Differential Revision: https://phabricator.kde.org/D3202
2018-12-31 12:35:01 +02:00
Martin Flöser 792d840455 Honor struts when placing Wayland transients
Summary:
So far transients were placed anywhere on the screen. This behavior was
inspired from X11 where context menus were able to overlap any other
window and use the complete screen area. On X11 context menus and
similar windows are override redirect and thus above all windows managed
by KWin.

On Wayland, though, context menus and similar and windows just like any
other window and thus follow stacking constraints like the parent
window. A context menu is stacked just above it's parent and is
(normally) below any panels. This resulted in problems that context menu
are stacked behind the panel with unreachable options.

This change changes the placement for transients to use the
PlacementArea instead of a screen geometry. Thus the transient does not
render behind the panel. Only in case of a fullscreen the struts are
ignored.

BUG: 389222
FIXED-IN: 5.15

Test Plan: New test case

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17826
2018-12-31 07:58:50 +01:00
Martin Flöser 0b28abeb01 Port window specific rules dialog to DBus
Summary:
The dialog invoked through user actions menu takes the internal uuid as
command line argument which allows to query the required information
from KWin instead of using X11.

This allows to enable the system for Wayland windows.

In order to replace the usage of ClientMachine in the rules dialog the
dbus interface is extended by a value whether the window is on the
localhost. This is exposed through a virtual method on toplevel which is
overridden in ShellClient and there always returning true.

Test Plan: Run a nested Wayland and opened the dialog on a wayland window

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17750
2018-12-31 07:58:12 +01:00
Martin Flöser feb1d443f1 Try to make TestShellClient::testUnresponsiveWindow more robust
Summary:
When looking at the test results on build.kde.org we see this is the
test which fails most often and it's always at the same line of code.

So I just had a look with the thought: "what's special about this code,
why could it fail?"

Looking at it we start an external process which is supposed to connect
to KWin. We wait for the process to start and then wait for the shell
client added. This assumes that at the time we handle the wait for
started the connection of the window has not happened yet.

Waiting for the process in a blocking way, might make the process fail
to connect to the Wayland session, so this is changed to not block and
instead use a signal.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17748
2018-12-31 07:57:41 +01:00
Atul Bisht c7154fc5b9 [libinput] Add support for clickfinger and button areas click method
Summary:
Added support for libinput clickfinger , areas method for touchpad KCM
Also added mock methods.

Included commits in branch libinputClickMethod:

         Added libinput mock methods
         Added : 1. setScrollMethod 2. added key value pair in QMap 3. added methods for Q_Props
         Added Q_Props for click method, signal
         Added variables and initialize in constructor

Reviewers: #kwin, graesslin, davidedmundson, zzag

Reviewed By: #kwin, graesslin, zzag

Subscribers: zzag, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17577
2018-12-22 17:29:49 +01:00
Vlad Zagorodniy 9b9d97db2b [libkwineffects] Detect modern Radeon GPUs
Summary:
Currently, KWin is not able to detect Radeon GPUs with GCN architecture.
This patch tries to address that.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17715
2018-12-21 13:43:13 +02:00
Martin Flöser 9993c6d674 Add a dbus method getWindowInfo returning same data as queryWindowInfo
Summary:
This dbus method is intended to be used by the kwin rules dialog. KWin
can pass the internal id to the rules dialog through a command line
argument (or similar way) and the dialog can query the information
through the dbus call for the provided id. Thus it's possible to
implement one way to query the information which works on both X11 and
Wayland without any windowing system specific functionality.

Test Plan: See new added integration test

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17433
2018-12-17 18:12:17 +01:00
Vlad Zagorodniy 7a28e0fe9a [wayland] Minimize transients together with parent
Summary:
If a parent window is minimized, then its transients have to be
minimized as well, so the minimize behavior is the same on both
X11 and Wayland.

BUG: 401950
FIXED-IN: 5.15.0

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17570
2018-12-14 21:15:58 +02:00
Vlad Zagorodniy e86d8461ed [autotests] Test window open/close animations
Summary:
The idea behind this autotest is to verify that different window
open/close animation effects behave similarly.

Currently, we just check whether Fade/Glide/Scale effect tries to animate
the appearing or the disappearing of toplevels. In the future, the
autotest will be extended to verify that there are no conflicts between
those three effects and the Login/Logout effect, etc.

Test Plan: Ran the test, found a bug in the Fade effect, fixed it.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17526
2018-12-14 21:11:42 +02:00
Martin Flöser c3e712e967 Fix the X11TimestampUpdateTest
Summary:
It also searches for the platform plugin, so we need to ensure it finds
it in the build directory.

This was a regression caused by building all platform plugins in the
correct location.

Test Plan: strace on the failing test, verified correct plugin is loaded

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17573
2018-12-14 17:11:15 +01:00
Martin Flöser 3e62f6aabe Remove no longer needed cast to Client in Workspace::sendClientToDesktop
Summary:
This change removes a small difference between X11 and Wayland clients.
It ensures that all transients are sent to the same desktop as the main
window. A similar check is already in AbstractClient::setDesktop, so in
general it already worked. This is just a special case for
sendClientToDesktop which supports sending to the same desktop so that
all transients are sent to that desktop.

Test Plan: New test case which fails without this change

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17546
2018-12-13 19:36:28 +01:00
Martin Flöser ba0cf19286 Fix dbus export of property Device::supportedButtons
Summary:
When launching the touchpad kcm we see the following warning:
    Error on d-bus read of "supportedButtons"

And the Gui shows "Error while loading values. See logs for more
information. Please restart this configuration module".

By extending the unit test for reading back the properties through DBus
I noticed that it's not trivially possible to export QFlags to DBus. As
the QFlags can be implicitly casted to int, the property is changed to
an int value.

Test Plan: Test case adjusted, did not pass prior to change, passes now.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17472
2018-12-13 19:36:28 +01:00
Martin Flöser c8ede9a5ff Build platform plugins in correct sub directory of build dir
Summary:
This brings KWin a step closer to be run from build dir without having
to install at all. The integration tests are adjusted so that the
virtual platform is still found which makes the code be closer to what
is used in normal kwin_wayland.

Test Plan: ctest passes, manually verified correct plugin is loaded

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17388
2018-12-13 19:36:28 +01:00
Martin Flöser a0b482cbab Introduce a command line option to disable any kind of global shortcuts
Summary:
This command line option is useful for KWin in embedded use case. That
is when KWin is just used as a compositor for one application instead of
a complete desktop environment. In such a setup global shortcuts are not
wanted and interfere with the application. E.g. one does not want Alt+F4
to close the window, that would render the system unusable.

This change introduces a command line option and disables the following
event filters and spies:
 * global shortcuts
 * modifier only shortcuts
 * terminate session
 * virtual terminal switching
 * screen edges

KGlobalAccel still gets inited, otherwise the (non-functional) binary
would be launched when KWin registers it's global shortcuts.

Test Plan:
New test added based on existing tests for the global
shortcuts, ctest passes

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17304
2018-12-13 19:36:28 +01:00
Martin Flöser 070b46f455 Hide mouse cursor when interacting with touch screen
Summary:
On touch events the mouse cursor gets hidden, on next mouse event the
mouse cursor is shown again. This IMHO significantly improves the system
interaction if touch is the primary user interface.

Test Plan: Test case added and ctest passes

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17280
2018-12-13 18:55:46 +01:00
Vlad Zagorodniy 3956d6ab4a [autotests] Fix failing of testDontCrashReinitializeCompositor
Summary:
Currently, testDontCrashReinitializeCompositor is unstable because it
doesn't take into account that effects can be loaded asynchronously.

In general, we don't need all default effects in this test, so let's
disable them.

Test Plan: This should fix ASan issues.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17386
2018-12-06 19:42:23 +02:00
Roman Gilg 2e29711323 Rework InputDeviceHandler focus tracking
Summary:
This patch aims at improving the Toplevel, internal window and decoration
focus tracking.

In detail the goals are:
* Clean tracking of beneath and focus Toplevel as well as decoration and
internal windows. Splitting this up in well defined sub routines.
* Minimal find Toplevel operations on window stack.
* Reduce code duplication in pointer and touch child classes.
* Reuse tracking in drag operations.
* Allow direct usage of Wayland input interfaces for decoration and internal
windows in the future.
* Update touch focus on external events like VD switches correctly.

Test Plan: Manually and existing autotests.

Reviewers: #kwin

Subscribers: kwin, zzag

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15595
2018-12-02 21:36:11 +01:00
Vlad Zagorodniy 295138145c Make sure that effect windows outlive effects
Summary:
Compositing is suspended/finished in a very hard way fashion, effect
windows are destroyed without notifying effects about it.

AnimationEffect tries gracefully release deleted windows, but because
in some cases(like when suspending compositing) a deleted window can
be already destroyed, a segmentation fault can happen.

This change adjusts the order in which effect windows and effects are
destroyed, so AnimationEffect (and other effects) cannot access dangling
pointers.

BUG: 400788
FIXED-IN: 5.15.0

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17311
2018-12-02 19:59:53 +02:00
Martin Flöser 3ad9ac7229 Introduce the concept of an internal window system independent id
Summary:
For supporting Wayland windows in the kwin_rules_dialog we need a way to
pass a window id for Wayland windows to the dialog. This id needs to be
sent to the dbus interface to query window information just like the
interactive query. For Wayland windows we don't really have a window id
and it would require to also pass the windowing system to
kwin_rules_dialog and back through the dbus interface.

To not complicate things this change introduces a windowing system
independent id based on UUID. This could in future also be used
internally for areas where it's window id based and used in both
windowing systems.

Test Plan: Adjusted test cases to verify the uuid is generated and passed to Deleted

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16986
2018-12-01 12:17:05 +01:00
Martin Flöser f8459a71cc Switch lockscreen test to OpenGL
Summary:
Main reason for using QPainter was the fact that build.kde.org did not
support OpenGL back when the test got introduced. As we have vgem
support nowadays we can switch back to OpenGL.

Test Plan:
100% tests passed, 0 tests failed out of 130,
but the test is flaky with and without this change

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16940
2018-12-01 12:14:40 +01:00
Martin Flöser 98ddb93dfe Unset all env variables related to KDE session in integration tests
Summary:
When running ctest in my session a few OpenGL/waylandonly tests crashed
on tear down. This does neither happen on build.kde.org nor when running
ctest in a tty. Comparing the env variables of tty and session pointed
to the session variables. Unsetting those makes the test not crash. This
makes sense as e.g. plasma-integration no longer gets loaded.

As our test suite is intended to test KWin and not plasma-integration or
gnome integration we should have a clean and reproducable environment,
so the variables are unset.

Test Plan: 100% tests passed, 0 tests failed out of 130

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16939
2018-12-01 12:14:10 +01:00
Martin Flöser 260646ed62 Delete kglobalshortcutsrc before executing a test
Summary:
When running the complete test suite the ScriptedEffectsTest::testShortcuts
registers the shortcut meta+shift+y. But GlobalShortcutsTest::testX11ClientShortcut
also tries to use this shortcut for a window shortcut which fails if it
is already registered. So when running the complete test suite it
depends on the order of execution whether the GlobalShortcutsTest passes
or not.

Test should be clean - also the globalshortcuts. As the config is read
from test directory anyway, we can delete the file prior to init of
kglobalaccel.

Test Plan: Run ctest, test did not fail anymore

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16932
2018-12-01 12:13:39 +01:00
David Edmundson 69c7146a73 [autotests] Stabilise colorcorrect test
Summary:
It crashes occasionally as the connection thread is still processing events
when the app is tearing down. These changes bring it in line with the
other tests using WAYLANDTEST_MAIN.

Test Plan:
Relevant test now passes.
Ran repeatedl without a crash

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17254
2018-11-30 11:37:41 +00:00
David Edmundson 7834bec52a [libkwineffects] Replace property name lookup with calling the virtual methods
Summary:
EffectWindow proxies its properties from the client/deleted's
properties.

QObject::property(char*) is a slow string search. It's a loop
of string comparisons not a hash lookup!

QML's use of properties is different, there's a property cache.

It's fetched multiple times for every window in every paint of some
effects (such as blur). Hotspot shows this as a significant amount of
the render pass (X11) with nothing in kwin animating.

This patch replaces the macro that does
parent()->property("propertyName")
with a macro calling the relevant function directly without metaobjects.

This also improves type safety for future changes.

Test Plan:
Existing unit tests
Ran it for a bit

Reviewers: #kwin, graesslin

Subscribers: graesslin, zzag, broulik, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16602
2018-11-30 11:22:20 +00:00
Vlad Zagorodniy 437d35eee2 [wayland] Check presence of the inhibitor object when a client is registered in IdleInhibition
Summary:
Some applications are not able to inhibit the idle behavior because
each of them creates an inhibitor object before the corresponding
ShellClient object becomes ready for painting.

BUG: 401499
FIXED-IN: 5.15.0

Test Plan: idle-inhibit client (from wlroots/examples) works.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17227
2018-11-29 18:17:34 +02:00
Vlad Zagorodniy e0eceed2e4 [autotests] Test all scripted effects
Summary:
TestPluginEffectLoader and TestScriptedEffectLoader don't check some
scripted effects (eye on screen, morphing popups, and window aperture).

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17072
2018-11-21 20:01:06 +02:00
David Edmundson 6c71403281 [autotests] Hopefully stabilise TestShellClient
Summary:
Apparently this test is flaky, based on the output I recieved we had
processed the un-fullscreen but not the un-maximise.

It seems possible the wayland thread could process when there's only one
request in the queue.

Test Plan:
Couldn't reproduce the original issue, it's a blind patch but the
current tests still pass.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16955
2018-11-17 12:50:32 +00:00
Vlad Zagorodniy ea1873f975 [effects/dimscreen] Port to JavaScript
Summary:
The ported effect looks quite similar to the C++ version except one
thing: it works correctly when user activates/deactivates a full
screen effect, for example the Desktop Cube effect.

Other than that, there are no behavioral or visual differences.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16452
2018-11-17 13:44:20 +02:00
Vlad Zagorodniy 396d528075 [scripting] Introduce complete function
Summary:
Effects that prefer to manipulate direction of animations sometimes need
to create animations in some particular state so later on they can be
played backward (swapping from and to is not enough and it would be wrong).

The proposed complete function lets such effects to fast-forward animations to
to the target position so they can be played backwards later on.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16450
2018-11-17 13:44:20 +02:00
Vlad Zagorodniy 5e104fbc12 [scripting] Introduce redirect function
Summary:
Consider current implementation of the Squash effect: if a window was
minimized, an animation will be started; if the window is unminimized
and the animation is still active (that can happen when user clicks on
app's icon really fast), the animation will be stopped and a new one will
be created. Such behavior can lead to rapid jumps in the observed
"animation".

A better approach would be first try to **reverse** the already active
animation, and if that attempt wasn't successful, start a new animation.

This patch introduces a new function to the scripted effects API that
lets JavaScript effects to control direction of animations. The
prototype of the function looks as follows:

    redirect(<animation id(s)>, <direction>, [<termination policy>])

the first argument is an animation id or a list of animation ids, the
second argument specifies the new direction of the animation or
animations if a list of ids was passed as the first argument. The
third argument specifies whether the animation(s) should be terminated
when it(they) reaches the source position, currently it's relevant only
for animations that are created with set() function. The termination
policy argument is optional, by default it's Effect.TerminateAtSource.

We can use this function to fix issues with rapid jumps in the Squash
effect. Also, redirect() lets us to write effects for simple animations
in slightly different style: first, we have to start the main animation
(e.g. for the Dialog Parent effect, it would be dimming of main windows)
and then change direction of the animation depending on external events,
e.g. when the Desktop Cube effect is activated.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16449
2018-11-17 13:44:16 +02:00
Vlad Zagorodniy ee72569647 [libkwineffects] Port AnimationEffect to TimeLine
Summary:
TimeLine has nice API for controlling its direction that can be re-used
later by AnimationEffect.

Test Plan: The existing tests for scripting effects still pass.

Reviewers: #kwin, davidedmundson, graesslin

Reviewed By: #kwin, davidedmundson, graesslin

Subscribers: davidedmundson, abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16448
2018-11-17 13:43:57 +02:00
Vlad Zagorodniy e02573263f [libkwineffects] Introduce timeline redirect modes
Summary:
The redirect modes control behavior of the timeline when its direction
is changed at the start or target position. For example, consider the
following piece of code:

    TimeLine timeLine(1000ms, TimeLine::Forward);
    timeLine.setDirection(TimeLine::Backward);

What should happen when the direction of the timeline was changed to go
backward? Should the current value of the timeline go from 1 to 0, or
should the timeline stop its "execution"?

In the relaxed mode, the timeline will go from 1 to 0.
In the strict mode, the timeline will stop its execution.

Different effects may prefer different modes for source and target
positions. For example, most C++ effect would prefer relaxed mode for
source position, and strict mode for target position. On the other side,
scripted effects(AnimationEffect) would prefer strict mode for source
position, and relaxed mode for target position(because of set).

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16447
2018-11-17 13:43:39 +02:00
David Edmundson 37fbb49bf0 [wayland] Fix maximised test
The existing test after the client was maximised sent a buffer with the
same size. Naturally correctly didn't generate a geometry change.
2018-11-16 12:28:38 +00:00
David Edmundson 1a2c90ea12 [wayland] Fix ShellClientTest
Summary:
When switching from maximised to full screen the geometry as kwin sees
it doesn't necessarily need to change, the test is wrong.

Also we can fix the XDGShell-deco tests.

wlshell-deco test still fails as before.

Test Plan: Tests pass \o/

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16922
2018-11-16 11:59:39 +00:00
Martin Flöser 841750438b Fix KeyboardLayoutTest::testNumLock
Summary:
The layout from previous test leaked into this test if all tests are run
together. This change ensures that a proper layout for this test is set.

Test Plan: Test passes alone and when run together

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16903
2018-11-15 19:01:51 +01:00
Vlad Zagorodniy c98e6cb876 [effects] Split the Fade effect
Summary:
Currently, we have three effects that can be used to animate the
appearing of toplevel windows(fade, glide, scale) and one can enable
all three of them, which seems to be wrong. It doesn't make sense to have
glide and scale effect enabled, for example.

We couldn't put all three effects into an exclusive group before because
the fade effect animates not only toplevel windows but also popups. So,
if all three effects are in an exclusive group and you enable glide effect,
for example, then tooltips and other popups won't be faded in/out.

This patch splits the fade effect into two: the first effect (called Fade)
animates toplevel windows and the other one (called Fading Popups) animates
popup windows.

Test Plan:
Have been using the Fading Popups effect in combination with the Scale
effect for a couple of days. Haven't noticed any significant differences between
the new combination (Fading Popups + Scale) and the old combination
(Fade + Scale).

Reviewers: #kwin, #plasma, #vdg, graesslin

Reviewed By: #kwin, #plasma, graesslin

Subscribers: graesslin, abetts, ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16836
2018-11-15 19:01:33 +02:00
Martin Flöser 3cee67f109 Temporarily skip XClipboardSyncTest
Summary:
The test fails for unknown reasons on build.kde.org, but passes when
run on a development setup. As the code is going to be changed with
D15063 anyway, it is better to just disable the test for the time being.

Test Plan: Test gets skipped

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16895
2018-11-15 14:31:38 +01:00
David Edmundson f521d4bbe1 [wayland] add enter/leave virtual desktop API
Summary:
As setDesktop was changed to "move" this left unSetDesktop non-symetric.

This replaces it with explicit API to enter/leave.

This also moves new API to the new object based API rather than still
using ints.

Where numbers are used it has been tidied up so that desktop IDs are
uint, which should be used when we have a list of desktops.
int is used only when we have either a desktop ID or NET::OnAllDesktops
(-1)

Effects API cleared up to use this and use a set of x11 IDs, which
avoids any potential complications of handling add and removes any
ambiguity with what happens if you leave all desktops and such.

Test Plan:
testVirtualDesktops passes (with pending kwayland patch)
Moving a window in the desktop grid on X11 behaves
Moving a window in the desktop grid on wayland behaves

Reviewers: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16704
2018-11-14 11:08:46 +00:00
Martin Flöser 9f6b0f98b5 Fix the way how we quit kactivitymanagerd from the unit test
Summary:
Kactivitymanagerd is a libexec executable now so we cannot just execute
it and cannot know it's path. We need to stop it as otherwise ctest does
not terminate the testActivities. This change uses dbus to quit the
kactivitymanagerd.

Test Plan: ctest did not timeout on testActivities

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16780
2018-11-09 17:27:07 +01:00
Vlad Zagorodniy abf6c6927c [autotests] Fix maximize test
Summary:
testMaximizedPassedToDeco was failing because it didn't handle async
maximization.

testBorderlessMaximizedWindow was failing because setNoBorder can modify
geometry, so we end up with a wrong restore geometry.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16755
2018-11-08 14:10:57 +02:00
Martin Flöser c19627b492 Copy plastik window decoration to build directory
Summary:
This ensures that DontCrashAuroraeDestroyDecoTest can load the plastik
window decoration when run from build directory as it happens on
build.kde.org.

Test Plan: Test passes now when manipulating XDG_DATA_DIRS to hide system install

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16745
2018-11-08 08:31:17 +01:00
David Edmundson 47d87cd94f [autotests] Handle async maximisation in quick tiling test
Summary:
KWin now correctly updates the client maximised state when we have a new
buffer in the new state. The quick tile unit test was unfortunately not
updated.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16739
2018-11-08 01:50:51 +00:00
Martin Flöser 0e839c4dda Unset XKB_DEFAULT_* in tests to make tests better reproducable
Summary:
On one of my systems XKB_DEFAULT_LAYOUT is set to "de". This makes a few
tests fail, e.g. pointer input and modifier only shortcuts.

The reason is that those tests assume the xkb default layout behavior,
that is how xkb functions without any layout being set. So having the
env variable around influences the layout generation.

To prevent this the environment variables are unset and thus a
reproducable environment is created.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16737
2018-11-07 20:10:58 +01:00
Martin Flöser e637d43211 Remove potential endless loop from XClipboardSyncTest
Summary:
We need to wait till the helper process created the datadevice. For this
we used a while loop. On build.kde.org the test gets stuck in this loop
and times out after 10 minutes.

This change introduces a dedicated signal and we just wait for it. So if
something fails we wait only 5 sec instead of endless. This should help
investigate why the test doesn't work on build.kde.org.

Test Plan: Test works locally

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16741
2018-11-07 20:10:32 +01:00
Martin Flöser f27f8a267f Fix slidingpopupstest when run without installtion
It tries to load scripted effects, so needs same adjustement.
2018-11-07 10:51:07 +01:00
Martin Flöser 43fc7f1bad Fix FadeTest and TranslucencyTest when started without install
Summary: Search in build dir for the effects.

Reviewers: #kwin

Differential Revision: https://phabricator.kde.org/D16683
2018-11-07 09:34:38 +01:00
Martin Flöser c36f9d2980 Fix test of scriptedeffectsloader when run from build directory without install
Summary:
On build.kde.org all tests loading scripted effects are failing. This
seems to be because the effects are not installed.

To make this work, this change introduces the following changes:
 * scripted effects are copied to ${build}/bin, like all binaries
 * the test sets XDG_DATA_DIRS env variable to point to ${build}/bin

This change also needs to be added to further tests once this is
accepted. Furthermore it could be considered whether KPackageLoader
should consider the QCoreApplication::applicationDirPath in addition to
the GenericDataLocation. This would make KPackageLoader work much better
in a build tree only setup.

Test Plan: Test passes locally, obviously not tried on build.kde.org

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16682
2018-11-07 09:34:18 +01:00
Martin Flöser a04b9da61e Re-evaluate the window rules when the window class of a Client changes
Summary:
So far KWin did not re-evaluate the window rules when the Client's
window class changes. Window class is the main (static) feature the rule
selection is based on. For dynamic changing mapping features like caption
KWin does re-evaluate the rules.

The reason for KWin to not evaluate when the class changes is that KWin
expects the class not to change. From ICCCM section 4.1.2.5:

 > This property must be present when the window leaves the Withdrawn
 > state and may be changed only while the window is in the Withdrawn
 > state. Window managers may examine the property only when they start
 > up and when the window leaves the Withdrawn state, but there should be
 > no need for a client to change its state dynamically.

Unfortunately there are prominent applications such as Spotify which
violate this rule and do change the window class dynamically. While this
is a clear ICCCM violation there is nothing which really forbids it (may
not != must not) and nothing which forbids KWin to react on changes.

As also libtaskmanager started to react on it, it makes sense to also
hook up the required bits for window rules. After all KWin detects
changes to the window class for some time already and has the
functionality to evaluate the rules. So all there is, is one connect
which improves the situation for our users, while at the same time it
should be rather risk free. If a setup window rule breaks after this
change it's due to the client not being ICCCM compliant.

Test Plan:
I don't use any of the affected applications, so it's only
tested with the new added unit test.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16670
2018-11-07 09:33:39 +01:00
Martin Flöser 7c3a851b04 Support enabling numlock on startup
Summary:
This change brings improved num lock support to KWin. The modifier state
is read and also mapped to Qt::KeyboardModifiers. Furthermore the input
config is read and the NumLock key is evaluated. If the requested state
does not match the current num lock state the state is swapped.

BUG: 375708
FIXED-IN: 5.15

Test Plan: New unit test added, no manual test due to lack of hardware

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16428
2018-11-01 17:49:58 +01: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
Vlad Zagorodniy 862bf0f153 [effects/scale] Port to JavaScript
Summary:
Now, when the scripting effects API has all required ingredients to port
the Scale effect to JavaScript we finally can do it.

The main rationale for porting this effect to JavaScript is that
scripted effects API lets us focus more on what we want instead of
"how".

Visually, the ported version doesn't deviate from the C++ version.

Test Plan:
* Enable the Scale effect;
* Open/close a window.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16478
2018-10-29 10:17:21 +02:00
Vlad Zagorodniy 8d0554e45a [scripting] Allow effects to grab windows
Summary:
Some JavaScript based effects need to grab particular windows in order
to avoid conflicts with other effects.

Example usage:

```lang=js
effects.windowAdded.connect(function (window) {
    if (effect.grab(window, Effect.WindowAddedGrabRole)) {
        window.coolWindowTypeAnimation = animate({
            ...
        });
    }
});
```

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: romangg, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13153
2018-10-29 10:17:21 +02:00
Vlad Zagorodniy eb78b1ca3a [effects] Re-implement the Minimize Animation effect in JavaScript
Summary:
There were several reasons to rewrite the Minimize Animation effect in
JavaScript: to simplify code and to get rid of full repaints. One could
say that nothing prevents us from calculating the dirty region in
postPaintScreen or postPaintWindow and it is correct, but with the
scripting effects API the dirty region will be calculated for us, so we
can focus more on "what we want" instead of "how".

Visually, the "old" effect and the rewritten one look quite the same.
Except one tiny bit: if a window doesn't have an icon in the task manager,
it won't be animated. The reason for that is the purpose of this effect is
to show where the window will be after it's minimized, if the window
doesn't have icon in the task manager, one can't click at the center of
the screen to unminimize the window.

There is one significant change, the name of the effect was changed to
"Squash". If we put this effect and the Magic lamp effect under "Window
Minimize Animation" category (or if we add some "heading" label), then
the old name and the name of the category would "conflict". The new name
was suggested by Nate Graham and it very closely describes what the
effect does. "Scale" doesn't fit this effect because while a window is
being animated, its aspect ratio is not preserved.

Reviewers: #kwin, #plasma, davidedmundson

Reviewed By: #kwin, #plasma, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16372
2018-10-23 16:57:07 +03:00
David Edmundson 8ef363cc21 [wayland] XdgPopup Positioning
Summary:
Support XDGShell Positioning. This gives a client a lot more control
over where the popup will be placed as well as control over how to
handle constraints. i.e what to do if the popup doesn't fit.

trasientOffset was replaced with a method on the client as semantically
it's the role of the client to handle constraints.

Both slide and flip constraint adjustments are implemented. Resize
constraint adjustment will be handled in a future patch.

WlShell is handled by treating it as 1x1 sized anchor with slide
constraint adjustment.

Test Plan:
Manual test of a client implementing xdgpopup exists in kwayland
Extensive unit test here

Existing WlShell test passes (after D16314 which fixes the original)
XdgPopup has a new unit test suite against manually calculated values

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16325
2018-10-20 17:17:59 +01:00
David Edmundson d70c3568e6 [wayland] Fix Placement::placeTransient keeping screens in bound.
Summary:
If a window flows off the left, we move left of the popup to the left
edge of the screen.

Currently if a window flows off the right, we move the window back by
it's own width, leaving it floating at a random point.
For consistency we should be setting it so the right edge of the popup is on the right
edge of the screen.

So in the auto test for the "right border" case:
The screen is 1280 wide, and we open a 10px popup at 1279  the final X
should be 1270.

Test Plan: Unit test

Reviewers: #kwin, zzag, graesslin

Reviewed By: #kwin, zzag, graesslin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16314
2018-10-20 17:17:58 +01:00
Vlad Zagorodniy fe4d69b653 Keep Deleted transients above old parents
Summary:
If a modal window is closed, usually, it will go behind its parent. The
reason for this is that Workspace::constrainedStackingOrder() puts only
AbstractClient transients above parents, not Deleted transients.

So, if fade/glide/scale effect animates the disappearing of a transient,
unfortunately, one can't see that animation.

BUG: 397448
FIXED-IN: 5.15.0

Test Plan:
=== Closing of a transient and parent window

Before:

https://www.youtube.com/watch?v=XiLq7EAVCp0

After:

https://www.youtube.com/watch?v=cH_Ki-sqY8M

=== Scale effect

Before:

https://www.youtube.com/watch?v=Eb2a3U7R10I

After:

https://www.youtube.com/watch?v=4AKu3fdrnYQ

=== Sheet effect

Before:

https://www.youtube.com/watch?v=xPPSnR5FUU0

After:

https://www.youtube.com/watch?v=o_hxTNT-5Hg

=== Popup menus on Wayland

Before:

https://www.youtube.com/watch?v=5DnrY8p3F5A

After:

https://www.youtube.com/watch?v=7XEo8n_CrCc

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: abetts, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14868
2018-10-16 18:58:17 +03:00
David Edmundson 9ca24efc07 [autotests] Hook up some missing tests for XDGShellStable
Summary: No kwin changes

Test Plan:
Compiles
More tests pass

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16148
2018-10-15 15:02:53 +01:00
Vlad Zagorodniy 3577e6907a Generalize constrainedStackingOrder for group transients and ordinary transients
Summary:
We don't really have to have two different code paths for group
transients and ordinary transients. For now, AbstractClient::hasTransient
is good enough to check the relationship between potential parent and
the transient.

In long term, we need to "invert" the relationship, instead of checking
whether given parent window has a transient, we should check whether
given transient is a transient for a given window so we can keep Deleted
transients above their old parents.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15893
2018-10-15 15:46:03 +03:00
Martin Flöser 77e3bbef7e Disable modifier window actions if global shortcuts are disabled
Summary:
Same is done on X11 (see Client::updateMouseGrab), so we should have this
on Wayland as well.

Also adding the pointer confinement restriction for modifier + wheel.

Test Plan: Run new and adjusted testcases with and without the change

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16025
2018-10-14 09:45:57 +02:00
Vlad Zagorodniy a281f2bce1 [effects/dialogparent] Fix flickering of parent windows
Summary:
If a modal window is closed and some alternative effect that animates
the disappearing of windows is enabled(e.g. the Glide effect, or the
Scale effect), the Dialog Parent effect can cause flickering of the
parent window because its animation duration doesn't match duration of
those alternative effects.

Also, if the Fade effect, the Glide effect, and the Scale effect are
disabled, the Dialog Parent will keep the parent window alive for no
good reason.

This change addresses that problem by adding keepAlive property to
`animate` function so scripted effects have more control over lifetime
of animated windows.

If both a modal window and its parent window are closed at the same time
(and there is no effect that animates the disappearing of windows), the
Dialog Parent will stop immediately(because windowDeleted will be
emitted right after windowClosed signal).

If both a modal window and its parent window are closed at the same time
(and there is effect that animates the disappearing of windows), the
Dialog Parent won't reference the latter window. Thus, it won't cause
flickering. I.e. it will "passively" animate parent windows.

BUG: 355036
FIXED-IN: 5.15.0

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14919
2018-10-10 18:34:12 +03:00
Vlad Zagorodniy b9653b4e95 [scripting] Propagate fullScreenEffect from global settings to local settings
Test Plan: Ran the test.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16097
2018-10-10 18:27:52 +03:00
Martin Flöser cefc15e573 Ignore modifier mouse actions when the pointer is constrained
Summary:
If the pointer is constrained all mouse events should go to the window.
Also our Alt+click. To use Alt+click nevertheless one can just unconfine
the window.

CCBUG: 399375

Test Plan: Run the adjusted autotest before and after change

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15982
2018-10-06 18:05:32 +02:00
David Edmundson e327cce4bc [wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.

This patch splits the requested, pending and current state, updating as
appropriate.

Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.

X code is untouched.

This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.

Test Plan:
Maximised a window with the button and double clicking title bar.

I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true

19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false

BUG: 382698

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 18:35:24 +03:00
David Edmundson 65b8ba1770 [wayland] Syncronise pending geometry with acked configure requests
Summary:
When we want to change a client's size and position together we have to
request the client becomes a new size and only then move the window to
the new location.

Currently we process the new position the next time the buffer updates,
but with no guarantee that it has actually tried to resize/whatever yet.
The client could be providing a new buffer just because the contents
have changed.

XDGShell has an acked serial designed to keep everything precisely in
sync. A surface represents the last configure that was acked.

This patch tracks the pending position for each configure and applies it
accordingly.

WL_shell does not have this mechanism, so behaviour is kept the same as
before.

----

This is a pre-requisite to syncing maximisedState/isFullScreen with the
configure request.

Potentially we could remove the isWaitingForResizeSync checks when
resizing and it will still resize smoothly.

Test Plan:
Relevant unit test still passes with the client responding
Resized a window from the left edge with WLShell and XDGShellV6

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15135
2018-10-05 17:35:23 +03:00
Vlad Zagorodniy 5181e999f8 [autotests] Extend test tables of SlidingPopupsTest
Summary:
Check that the Sliding Popups effect grabs windows no matter in what
order it and the Scale effect are loaded.

Test Plan: Ran the test.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15729
2018-10-04 21:38:54 +03:00
David Edmundson 99b33e7428 [libkwineffects] Expose getting/setting activeFullScript to scripted effects
Summary:
Getter is exposed as a property on scripted effect in a way that hides
pointers from the scripting side.

Setter is implicitly handled as a property of newly created animations
and holds the activeFullScreenEffect whilst any of them are active. Like
existing effects it remains up to the effect author to avoid the
problems of multiple full screen effects. The RAII lock pattern is
somewhat overkill currently, but it's the direction I hope we can take
EffectsHandler in next API break.

BUG: 396790

--

This patch is against the QJSEngine port, though it's not conceptually a
requirement.

Test Plan: Unit test

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14688
2018-10-04 00:57:44 +03:00
Vlad Zagorodniy 9ad3f1c672 [autotests] Register KWin::Deleted* in SlidingPopupsTest
Summary:
QSignalSpy is not happy about KWin::Deleted*:

    QWARN  : SlidingPopupsTest::testWithOtherEffectWayland(wobblywindows, slide)
    QSignalSpy: Unable to handle parameter 'deleted' of type 'KWin::Deleted*' of
    method 'windowClosed', use qRegisterMetaType to register it.

Test Plan: Ran the test, haven't noticed any warnings.

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15730
2018-09-24 18:09:28 +03:00
David Edmundson fcf9acfec5 Add XDG WmBase support
Test Plan:
Compiled latest GTK
Ran gtk4-demo and used WAYLAND_DEBUG to confirm it used the correct
shell
tested a top level and a popup

Reviewers: #plasma, romangg

Reviewed By: #plasma, romangg

Subscribers: romangg, mart, graesslin, zzag, kwin

Tags: #kwin
BUG: 398614
FIXED-IN: 5.15.0

Differential Revision: https://phabricator.kde.org/D13530
2018-09-14 12:18:47 +01:00
Roman Gilg 6072b0cd6c Remove breaking pointer constraints functionality
Summary:
With 2694839099, 0bd5eff862 and f0ba436c72 it is now possible to
unconstrain a pointer by killing the client or deactivating the window, for
example by switching the window via the TabBox.

A user should always be able to do it therefore without needing to explicitly
break the pointer constrain as in the past with the Esc key.

Therefore remove the functionality and also remove the OSD announcing it,
which was often shown at the wrong time.

Test Plan: Manually and auto test adapted.

Reviewers: #kwin, #vdg, hein

Reviewed By: hein

Subscribers: ngraham, hein, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D15234
2018-09-12 22:55:26 +02:00
Vlad Zagorodniy 624a453109 Clean up includes
Summary:
* effects.h includes client.h and forward declares Client, both at the
  same time. Thus, delete the include;

* the blur effect includes effects.h. That, most likely, is a leftover
  after 3f5bf65a9e.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15191
2018-08-31 22:58:11 +03:00
Vlad Zagorodniy dadcd51135 [scenes/opengl] Fix overlaps in shadow texture atlas
Summary:
If the corner shadow tiles(top-left, top-right, and so on) tiles are missing,
then the left/top/right/bottom shadow tiles will overlap.

This diff addresses that problem by changing how the shadow texture
atlas is rendered:
* corner tiles will be drawn in the corners of the atlas(buildQuads
  method expects them to be at the corners);
* top, right, bottom, and left tile will be aligned to the top-left
  corner of the inner shadow rect.

For majority of desktop themes, the shadow texture atlas looks the same.
For example, here's for Aether:

Before:
{F6190484, layout=center, size=full}

After:
{F6190488, layout=center, size=full}

Depends on D14783

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14784
2018-08-31 17:33:19 +03:00
Vlad Zagorodniy 5e55664de8 [scenes/opengl] Correctly draw shadows when corner tiles are missing
Summary:
Current implementation of buildQuads assumes that corner shadow tiles
are always present:

    const QRectF leftRect(
        topLeftRect.bottomLeft(),
        bottomLeftRect.topRight());

but that assumption is wrong. For example, if the default panel is on
the bottom screen edge, then the calendar popup won't have the
bottom-left shadow tile(at least on Wayland). Which means that the left
shadow tile won't be visible because
topLeftRect.left() == bottomLeftRect.right().

Corner rectangles only have to influence height of the left/right tile
and width of the top/bottom tile. Width of the left/right tile and
height of the top/bottom tile should not be controlled by corner tiles.

Overall, this is how shadow quads are computed:

* Compute the outer rectangle;
* Compute target rectangle for each corner tile. If some corner tile is
  missing, move the target rectangle to the corresponding corner of the
  inner shadow rect and set its width and height to 0. We need to do
  that to prevent top/right/bottom/left tiles from spanning over
  corners:

{F6190219, layout=center, size=full}

We would rather prefer something like this if the top-left tile is
missing:
{F6190233, layout=center, size=full}

* Fix overlaps between corner tiles;
* Compute target rectangles for top, right, bottom, and left tiles;
* Fix overlaps between left/right and top/bottom shadow tiles.

Test Plan:
* Ran tests;
* Resized Konsole to its minimimum size(on X11 and Wayland);
* Opened the calendar popup(on X11 and Wayland):

Before:
{F6190344, layout=center, size=full}

After:
{F6190346, layout=center, size=full}

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: abetts, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14783
2018-08-31 17:33:19 +03:00
Roman Gilg b22c362bd5 [platforms/virtual] Let VirtualOutput inherit Output
Summary:
Let VirtualOutput be a child class of the new generic class Output.
This allows code sharing and a very similar behavior of the Virtual backend
in comparision to the Drm backend.

Test Plan:
Autotests succesful with two exceptions: The decoration input test fails on
testDoubleTap, row topLeft. This is to be expected because now the
ScreenEdgeInputFilter captures the event at position (0,0) before the
DecorationEventFilter can capture it. The autotest was adapted to take this
special case into account.

Also the lockscreen test fails, because the virtual output is currently missing
the physical size yet.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11789
2018-08-31 11:56:39 +02:00
David Edmundson 7e7eadb44f [autotests] Make lifespan of EffectsHandler outlive Effect
Summary:
In loading tests. Effects are deleted in a deleteLater potentially
outside the scope of our test. Our MockEffectsHandler (which contains
the global static "effects") has the lifespan of the test.

Fixes failing unit test.

Test Plan: Ran test

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15167
2018-08-30 14:57:13 +01:00
Yuri Chornoivan bf58da3e9a Fix minor EBN issues 2018-08-29 21:02:16 +03:00
David Edmundson 1238c7bc47 [autotests] Test ScriptedEffects stackingOrder
stackingOrder is an interesting property which needed
special handling in the port. Add an explicit test.

Test Plan: #kwin

Reviewers: broulik

Reviewed By: broulik

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14533
2018-08-20 17:39:36 +01:00
Vlad Zagorodniy 4299b81f65 [effects] Drop the Scale in effect
Summary:
It's superseded by the new scale effect(D13461).

Existing users of this effect will be migrated to the new scale effect.

Depends on D13461

Reviewers: #kwin, #plasma, #vdg, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13462
2018-08-12 10:58:07 +03:00
Vlad Zagorodniy 9d197e8cb6 [effects] Add Scale effect
Summary:
The new effect scales windows as they appear and disappear.

As the the most of window animation effects, it is a monolithic effect,
i.e., if you enable scale effect, it will animate *both* the appearing and
disappearing.

The main difference between the Scale effect and the Scale in effect is
that the Scale in effect only animates windows as they appear. There is
no corresponding "the Scale out" effect, which is odd. Other points that
differentiate the Scale effect from the Scale in effect:

* it is more subtle;
* it doesn't animate the log out screen;
* it doesn't conflict with the Fade effect, etc.

... and overall, the Scale effect supersedes the Scale in effect.

{F5904947}

//Window open animation.//

{F5904948}

//Window close animation.//

{F5905283, layout=center, size=full}

//KCM.//

Test Plan:
* Enabled this effect
* Opened/closed System Settings

Reviewers: #kwin, #plasma, #vdg, davidedmundson

Reviewed By: #kwin, #plasma, #vdg, davidedmundson

Subscribers: ngraham, davidedmundson, fvogt, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13461
2018-08-12 10:57:41 +03:00
David Edmundson 3332b32101 [scripting] Fix effect.animate() curve argument being actually used
Summary:
One cannot use a non metatype frrom an external class inside an
invokable. https://bugreports.qt.io/browse/QTBUG-58454

End result is the script engine arguments wouldn't match up and MOC
would just use the default value.

As far as I can tell this has been broken for 6 years.
The global animate method that unboxes a QJSValue as an object is
unaffected.
No shipped kwin effect actually used it.

To some extent we didn't even actually want to enforce the enum as we
also accept custom value of ScriptedEffect::GuassianCurve, so it has
been switched for an int.

Test Plan: Unit test

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14669
2018-08-07 21:33:29 +01:00
David Edmundson 5d279a0ddd [autotests] Unit most scripted effects API
Summary:
Ready for QJSEngine port and upcoming other fixes.
Split as it makes it easier to do any before/after testing.

Test Plan:
All tests pass with the current QScriptEngine
Verified expected API against a wiki page and current code.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14482
2018-07-31 12:29:04 +01:00
Vlad Zagorodniy dc541452f1 Merge branch 'Plasma/5.13' 2018-07-15 23:05:30 +03:00
Vlad Zagorodniy 1e4703a719 [wayland] Confine pointer to screen geometry
Summary:
If the new pointer position is "off screen", PointerInputRedirection
just ignores that new position. So, pointer remains on its previous
position. In some particular cases, like reaching default panel, it
degrades desktop experience because one have to slowly move pointer in
order to reach what he/she wants.

This change addresses that problem by confining the new pointer position
to screen geometry.

BUG: 374867
FIXED-IN: 5.13.4

Test Plan: Ran tests

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14036
2018-07-15 23:05:11 +03:00
Vlad Zagorodniy ee88951b17 [libkwineffects] Add TimeLine helper
Summary:
Most effects use QTimeLine in the following manner

```lang=cpp
if (...) {
    m_timeline->setCurrentTime(m_timeline->currentTime() + time);
} else {
    m_timeline->setCurrentTime(m_timeline->currentTime() - time);
}
```

Because effects do not rely on a timer that QTimeLine has, they can't
toggle direction of the QTimeLine, which makes somewhat harder to write
effects. In some cases that's obvious what condition to use to figure
out whether to add or subtract `time`, but there are cases when it's
not. In addition to that, setCurrentTime allows to have negative
currentTime, which in some cases causes bugs.

And overall, the way effects use QTimeLine is really hack-ish. It makes
more sense just to use an integer accumulator(like the Fall Apart
effect is doing) than to use QTimeLine.

Another problem with QTimeLine is that it's a QObject and some effects
do

```lang=cpp
class WindowInfo
{
public:
    ~WindowInfo();

    QTimeLine *timeLine;
};

WindowInfo::~WindowInfo()
{
    delete timeLine;
}

// ...

QHash<EffectWindow*, WindowInfo> m_windows;
```

which is unsafe.

This change adds the TimeLine class. The TimeLine class is a timeline
helper that designed specifically for needs of effects.

Demo

```lang=cpp
TimeLine timeLine(1000, TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);

timeLine.value(); // 0.0
timeLine.running(); // false
timeLine.done(); // false

timeLine.update(420);
timeLine.value(); // 0.42
timeLine.running(); // true
timeLine.done(); // false

timeLine.toggleDirection();
timeLine.value(); // 0.42
timeLine.running(); // true
timeLine.done(); // false

timeLine.update(100);
timeLine.value(); // 0.32
timeLine.running(); // true
timeLine.done(); // false

timeLine.update(1000);
timeLine.value(); // 0.0
timeLine.running(); // false
timeLine.done(); // true
```

Test Plan: Ran tests.

Reviewers: #kwin, davidedmundson, graesslin

Reviewed By: #kwin, davidedmundson, graesslin

Subscribers: romangg, graesslin, anthonyfieroni, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13740
2018-06-30 09:58:11 +03:00
Roman Gilg 0bd5eff862 Make keyboard focus a pointer constraints necessity
Summary:
This patch changes KWin's pointer constraining behavior by only allowing
constraints if the surface has keyboard focus. In case the client activation
state changes, it rechecks it.

Test Plan:
Manually with the pointer constraints test application and opening the
launcher by pressing meta. Also amended autotest.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D13492
2018-06-26 16:45:39 +02:00
David Edmundson 1761b75b55 Set correct DPR on wayland cursors received from remote buffers
Summary:
It will then be renderered appropriately when painting to the output
buffer.

Test Plan: Updated unit test, plus used with other relevant patches

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13606
2018-06-23 18:17:51 +01:00
David Edmundson 9260b3c51e Revert "Disable unit test which fails to compile on the CI system."
This reverts commit e6cdf966ff.

[11:18] <bcooksley> it should be okay to restore
2018-06-14 11:31:24 +01:00
David Edmundson 3e2ff0e870 compare doubles to doubles
Summary:
Should resolve undefined reference to `bool QTest::qCompare<double, int>
error on 5.9

Test Plan:
Still compiles/passes
Not actually tested on 5.9

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13526
2018-06-14 09:21:07 +01:00
Ben Cooksley e6cdf966ff Disable unit test which fails to compile on the CI system.
This test is blocking the ability of the CI system to return to service for Extragear projects on some platforms.

This commit may not be reverted without the explicit consent of Sysadmin.

CCMAIL: plasma-devel@kde.org
CCMAIL: kwin@kde.org
2018-06-14 20:00:32 +12:00
Roman Gilg 2694839099 Remove pointer constraint on resource unbind
Summary:
A client might delete its pointer lock/confinement object. This is supposed to
directly remove the pointer lock/confinement in KWin, but did not explicitly
until now.

BUG: 388885

Test Plan:
Tested manually with Neverball, Nexuiz and the new pointer constraints test
application. The pointer constraints autotest is also appended.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, graesslin, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D13466
2018-06-11 22:46:06 +02:00
David Edmundson 5b4eb80c8f Set specific edge cursor shape when resizing
Summary:
Instead of seeing the cursor <--> on the left edge you now see an icon
that looks like |<-  .

This brings kwin decorations in line with GTK CSD icons.

In theory this is also useful to tell which window will resize in the
case of side-by-side windows (regardless of whether borders are on or
not). In practice with the adwaita icon theme I tested with it's not
very intuitive to realise which is which till you learn the icon.

Change is more involved than it should be as Qt::CursorShape doesn't
have these entries, and I don't want to shadow that enum internally or
have
to change kwin effect code.

Specifics depend on cursor icon theme if they are not present it will
fallback to the <--> icon. (Breeze does not have them currently)

Test Plan:
Resized some windows (on X and on Wayland)
Correct icon appeared on Adwaita
Existing icon appeared on Breeze

Reviewers: #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13396
2018-06-11 10:05:07 +01:00
Vlad Zagorodniy 2d01ba6450 [scenes/qpainter] Draw decoration shadows
Summary:
QPainter doesn't render decoration shadows. It renders only
shadows provided through ShadowInterface.

With this change, painting of shadows is done in similar way OpenGL backend is
currently doing.

Before

{F5734867, layout=center, size=full}

After

{F5734870, layout=center, size=full}

Depends on D10811 (dummy decoration with shadows in autotests)

Test Plan:
* start kwin with QPainter backend enabled:

```
KWIN_COMPOSE=Q kwin_wayland --xwayland --windowed
```

* open konsole and kate:

```
DISPLAY=:1 konsole
DISPLAY=:1 kate
```

Reviewers: #kwin, graesslin, davidedmundson

Reviewed By: davidedmundson

Subscribers: abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10943
2018-06-07 12:27:31 +03:00
Vlad Zagorodniy 7637cfc22b [scenes/opengl] Fix overlapping shadow tiles
Summary:
This problem appears if shadow corner tiles are too big and
some window has size smaller than 2 * shadowTileSize.

This change tries to address the problem above by exclusing
overlapping tile parts. If there are any two overlapping corners
then tile between them(top/right/bottom/left) is not rendered.

Also, because some corner tile parts can be excluded, corner tiles
are expected to be symmetrical(i.e. if we remove right half from
the top-left tile and left half from the top-right tile and
stick them together, they still look fine, there are no misalignments, etc).
Most shadows(e.g. shadows from Breeze) have such behaviour.

No tiles are overlapping

{F5728514, layout=center, size=full}

Overlapping tiles

{F5728516, layout=center, size=full}

And this is how it supposed to be

{F5728517, layout=center, size=full}

Test Plan:
* apply D11069 to Breeze
* in System Settings/Application Style/Window Decorations, choose "Very Large" shadow size
* open Konsole
* resize it to a minimum possible size

Reviewers: #kwin, graesslin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, ngraham, anemeth, abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D10811
2018-06-07 12:07:57 +03:00
David Edmundson a3cff85e7a Remove Qt module declarations in includes
Summary:
Test Plan: Compiles

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13359
2018-06-05 18:07:23 +01:00
Martin Flöser cf53957bd8 Merge branch 'Plasma/5.13' 2018-05-19 09:01:44 +02:00
Martin Flöser 08455f297d Ensure the QToolTip on the deocration does not steal key events
Summary:
BUG: 393253
FIXED-IN: 5.13.0

Test Plan: manual testing and new unit test

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12633
2018-05-19 09:01:11 +02:00
Martin Flöser 04dab3de1b Merge branch 'Plasma/5.12' into Plasma/5.13 2018-05-19 09:00:43 +02:00
Martin Flöser e3250460cc Do not unset cursor image when cursor enters a surface
Summary:
From Wayland documentation:
"When a seat's focus enters a surface, the pointer image is undefined and
a client should respond to this event by setting an appropriate pointer
image with the set_cursor request."

KWin's interpretation so far for the undefined pointer image was to
remove the pointer image when entering a surface waiting for the client
to set a cursor image. This can result in a short flicker as there might
be a frame without a cursor image.

This patch changes the behavior by keeping the previous image till the
application set a new one. This brings some advantages:
 * if the application is not responding a cursor is still shown
 * if the same cursor is used as in the previous window we don't have a
flicker

CCBUG: 393639

Test Plan: I cannot see the flicker, so only tested with the adjusted tests

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12631
2018-05-19 08:58:42 +02:00
David Edmundson 1403fcf316 Add XDG Output support
Test Plan:
Very minimal expansion of unit tests which uses WaylandScreens
Wrote mini app to debug actual output of xdg-output for testing the DRM code

Main relevant user of this is xwayland > 1.20 which I don't have, so that
part remains untested

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: romangg, graesslin, bshah, kwin

Tags: #kwin

Maniphest Tasks: T8501

Differential Revision: https://phabricator.kde.org/D12243
2018-05-18 14:16:13 +01:00
Aleix Pol bec8493459 Don't try to filter null key combinations
Summary:
When using composite key combinations, kwin would do random weird
actions when the first key was pressed (e.g. ` key). This makes sure we
are not trying to match.

BUG: 390110

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12416
2018-04-24 16:35:23 +02:00
Aleix Pol 4403e86acc Don't try to filter null key combinations
Summary:
When using composite key combinations, kwin would do random weird
actions when the first key was pressed (e.g. ` key). This makes sure we
are not trying to match.

BUG: 390110

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12416
2018-04-24 16:23:47 +02:00
Martin Flöser e54b0ef79a Merge branch 'Plasma/5.12' 2018-03-29 17:51:24 +02:00
Martin Flöser 4205496033 Ensure _NET_CURRENT_DESKTOP is set on startup
Summary:
Seems to have regressed in Plasma 5.12 due to code reordering. Now the
property is explicitly updated once the NETRootInfo is created.

BUG: 391034
FIXED-IN: 5.12.5

Test Plan:
Test case exposing the problem added. Fails without the patch,
succeeds with the patch.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10836
2018-03-29 17:50:07 +02:00
Eike Hein 2c26215d7e Request a high-priority EGL contexts
Summary:
This patch implements using EGL_IMG_context_priority to request
high-priority rendering contexts if the extension is available.

EGL_IMG_context_priority is currently used in this fashion by
e.g. Android's SurfaceFlinger (RenderEngine.cpp) and libweston
(gl-renderer.c) and seems promising given this widespread
acceptance.

Reviewers: #kwin, graesslin, romangg, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11572
2018-03-29 20:34:22 +09:00
Roman Gilg 8136c2722b [platforms/virtual] Add virtual output class
Summary:
This matches the DRM backend more closely and allows mid-test removal and
addition of virtual outputs with different properties in the future.

Test Plan: Before and after 93% tests passed.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11351
2018-03-19 22:12:22 +01:00
Martin Flöser d3aa33b51b Reevaluate window rules when the (xdg) shell surface's appId changes
Summary:
Especially when a window is first mapped it might be that the appId is
not yet set. So window rule matching doesn't happen. This change
evaluates the window rules again after the appId changes, so rules for
the appId match.

Test Plan: added test case

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11268
2018-03-18 09:16:04 +01:00
Martin Flöser d61eaa2d66 Add a new desktopfile name rule
Summary:
This allows to override the desktop file name.

CCBUG: 351055

Test Plan: Created a window rule for telegram-desktop to fix the icon

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11266
2018-03-18 09:15:15 +01:00
Martin Flöser ab18007d2a Better map ShellClient to resource name and class
Summary:
The window rules dialog did not properly detect the wayland windows. So
I investigated what ICCCM writes about the WM_CLASS property (which is
the base for window rule matching) and checked how ShellClient maps to
it. Basically name and class was swapped and the reason for the
detection not working properly. As we don't have a proper name, the code
is adjusted to generate a name by using the executable name. This is
also what WM_CLASS should be filled with, according to ICCCM.

Test Plan: Rules dialog detects the name and class correctly

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11023
2018-03-11 15:32:44 +01:00
Martin Flöser e71460b6fc Merge branch 'Plasma/5.12' 2018-03-05 19:32:48 +01:00
Martin Flöser e1afef3d45 Sanity check WindowQuad before trying to create a grid out of it
Summary:
When one uses:
 * breeze as of 5.12
 * wobbly windows
 * shaded window
 * a distribution building with assert enabled

and starts to move a shaded window, KWin asserts. The root cause for
this is that WindowQuad::makeSubQuad has an assert for y1 being smaller
than y2. With the combination listed above this is not guaranteed. For
the left shadow quad the y1 and y2 are identical and thus trying to
split it, results in the assert condition.

The problem of the shadow quad having an invalid size might be addressed
as well with D10811. Due to that the generation of the quads is not
touched. Instead a sanity check is introduced to not try to split
already invalid sized quads.

BUG: 390953
FIXED-IN: 5.12.3

Test Plan: Added unit test hit the assert, now doesn't hit it any more

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11015
2018-03-05 19:31:51 +01:00
Martin Flöser 88b9de04ed Merge branch 'Plasma/5.12' 2018-03-04 09:43:38 +01:00
Martin Flöser 2ea5153e1c Don't crash if the cursor theme fails to create
Summary:
If the cursor theme failed to create KWin crashed due to an endless
recursion. There are two reasons for this fault:
1) When the physical size does not exist we perform a division by 0
which results in an invalid size going into wl_cursor_theme_load
2) We emit the signal that the cursor theme changed even if it didn't
change thus creating an endless recursion

This change addresses both problems: it checks that the size is not 0
and changes the handling for theme update to only destroy the previous
theme if the new theme could be created and only emits the signal if
things change.

BUG: 390314
FIXED-IN: 5.12.3

Test Plan: Added a new test case which crashed with old code

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10549
2018-03-04 09:42:27 +01:00
Martin Flöser b554e54e87 Support modifier mouse/scroll action on internal decorated windows
Summary:
This fixes the problem that alt+lmb did not start unrestricted move
resize for the Debug Console.

BUG: 374880
FIXED-IN: 5.12.3

Test Plan: New test case and manual testing whether alt+lmb/rmb works

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10440
2018-03-04 09:41:38 +01:00
Martin Flöser 41d97e9caa Merge branch 'Plasma/5.12' 2018-02-27 19:32:58 +01:00
Martin Flöser e9c72e4e62 [autotests] Set breeze icon theme name in integration tests
This is an attempt to get some tests failing on the CI due to not
finding icons fixed. See T8082
2018-02-27 18:17:53 +01:00
Martin Flöser 119c64839d Merge branch 'Plasma/5.12' 2018-02-25 14:11:25 +01:00
Martin Flöser 911176a887 Send hoverLeave or hoverMotion after touch up on decoration
Summary:
On touch down a first hover motion is sent to the decoration. Thus e.g. a
button enters the hovered state. On touch release so far the decoration
did not get a leave event resulting in the button still being hovered.

This change ensures the leave event is sent or if the pointer is also on
the decoration a motion to the pointer position is sent.

BUG: 386231
FIXED-IN: 5.12.3

Test Plan:
New test case and manual testing to verify that the maximize
button is no longer hovered after touch down/up on it

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10308
2018-02-25 13:54:02 +01:00
Martin Flöser 5795fc8cc0 Init the icon in ShellClient::init
Summary:
If the window never provides the appId, we would not get an icon for
the window. This happens for example for KWin's internal windows which
don't set the app id as KWin also doesn't have a desktop file. With this
change the DebugConsole has a window icon in the decoration.

Test Plan: Extended tests and manual verification of DebugConsole

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10294
2018-02-25 13:15:17 +01:00
Martin Flöser a0c91c6e19 Merge branch 'Plasma/5.12' 2018-02-21 18:07:41 +01:00
Martin Flöser 338c7362c9 Properly handle move during touch events
Summary:
When a window was being moved the touch handling performed the wrong
interaction. Due to that it was possible to move the window, but KWin
did not enter the correct code paths, thus quick tiling was for example
not functional.

BUG: 390113
FIXED-IN: 5.12.3

Test Plan: New test case added and manual test in nested KWin

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10431
2018-02-21 18:06:00 +01:00
Martin Flöser 0886051622 [autotests] Add test case for decoration default mode
I incorrectly assumed we have a bug when no mode is requested. The test
case shows it works correctly.
2018-02-19 22:10:17 +01:00
Martin Flöser a0aef86a74 Add test case for force opacity rules on ShellClient
This is the first test for force rules. As those cannot be set through
the temporary rules message the rulesrc must be modified. To support this
RuleBook gained a setConfig method.

To my positive surprise the rules already work as intended.
2018-02-11 18:29:26 +01:00
Martin Flöser bbf00fdd98 Require libinput and udev
Summary:
The main reason for not having it as a mandatory dependency was that BSD
doesn't support it. But as I learned recently it is available on our CI
system. So BSDs have support now.

Even more it showed that the code doesn't compile if the dependency is
missing. And there's one thing I hate: broken build configuration
options.

So let's make UDEV and libinput a required dependency and get rid of the
problems.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10057
2018-02-04 15:00:42 +01:00
Martin Flöser 45bdd8a342 Merge branch 'Plasma/5.12' 2018-02-04 15:00:31 +01:00
Martin Flöser aefa11f11a Block geometry updates on move resize finish and don't configure xdg shell surfaces while blocked
Summary:
We send out too many configure requests when finishing move resize which
also triggers quick tiling. This change addresses the problem of the too
many configure requests by making the configure method check whether
geometry updates are blocked. And to make this work properly for the end
of finish move resize the complete method is wrapped in a geometry
update blocker.

BUG: 388072
FIXED-IN: 5.12.1

Test Plan:
Quick tiling test passes, both Wayland and X11 windows are
quick tiled correctly.

Reviewers: #kwin, #plasma, jgrulich

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10156
2018-02-04 14:59:56 +01:00
Martin Flöser 4cc1d7a245 Require libinput version 1.9
Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9930
2018-01-21 11:15:41 +01:00
Martin Flöser 68aef25934 Merge branch 'Plasma/5.12' 2018-01-21 11:15:32 +01:00
Martin Flöser 0d2a341723 [autotests/integration] Add test for broken quick tiling for xdg_shell
See also D9980.

CCBUG: 388072
2018-01-21 11:13:28 +01:00
Martin Flöser 87f0a119e1 Add support for apply initial shortcut window rule
Summary: Implements the shortcut window rule for ShellClient.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9876
2018-01-15 17:14:19 +01:00
Martin Flöser d7cc5eb3bd Add support for apply initial keep above/below window rules
Summary: This implements these set rules for ShellClient.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9870
2018-01-15 17:14:00 +01:00
Martin Flöser 42b099355c Add support for initial apply rules for skip (taskbar|pager|switcher)
Summary: This adds support for those set rules in ShellClient.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9866
2018-01-14 11:19:47 +01:00
Fabian Vogt e302f87598 Properly detect Gallium drivers with newer Mesa
Summary:
The renderer string does not contain "Gallium 0.4 on" anymore,
instead it directly contains the gallium driver's name.
So assume that every unknown renderer is a gallium driver.

Test Plan: Added a testcase, it succeeds only with this patch.

Reviewers: #plasma, graesslin

Subscribers: kwin, plasma-devel, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9495
2018-01-12 09:05:03 +01:00
Martin Flöser b7ad4bcf88 Keep fullscreen windows in active layer based on transients not the group
Summary:
So far a not-active fullscreen X11 window was kept in the active layer if
the newly activated window is in the same group (that is same client
leader). For example a fullscreen X11 kwrite window is in the active layer
if another kwrite window is active. The two kwrite windows obviously
don't have anything to do with each other, but are in the same group.

This creates problems as it's not possible to raise other windows above
the active not-fullscreen kwrite window. E.g. the panel is stacked below.

The idea behind the check makes sense: if a fullscreen window opens
another window (e.g. a configuration dialog) it should not be put back
to normal layer. Thus the check is adjusted whether the new active
window is a transient to the fullscreen window. Thus the intention is
still the same, but does not cause the problems.

As the code now does not need to differentiate between X11 and Wayland
windows (group only on X11) the Client specific implementation is
removed and the method unvirtual'ed.

BUG: 388310
FIXED-IN: 5.12.0

Test Plan: Test passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9699
2018-01-10 17:44:00 +01:00
Martin Flöser d2a9232ad3 Pass SwitchEvent from LibInput through KWin and add to DebugConsole
Summary:
This change introduces a new SwitchEvent and passes it through the
InputEventSpy and InputEventFilter. The DebugConsoleFilter implements it
so that the events can be monitored in the debug console.

Test Plan: Untested as my only device with such switches has too old libinput

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9521
2018-01-09 19:32:58 +01:00
Martin Flöser 87ebfd1517 [autotests] Add test case for fullscreen window with groups
When an X11 window is raised to fullscreen it gets set to active layer.
When another window gets activated then it goes back to normal layer.
But when a window of the same group gets activated the fullscreen window
stays in the active layer. Due to that it is not possible to raise other
windows above the fullscreen window.

This just adds a test case exposing the problematic area.

CCBUG: 388310
2018-01-06 10:45:44 +01:00
Martin Flöser ac2f41c86d [libinput] Add support for switch devices and events
Summary:
This change adds support for the switch devices introduces with libinput
1.7 (lid) and 1.9 (tablet mode). So far it's not yet used internally in
KWin, but only exposed through the Device and Events.

As KWin currently only requires libinput 1.5 and we are rather late in
the release cycle the new functionality is ifdef'ed. The requirement
will be raised once master is 5.13. It is already available on
build.kde.org, but e.g. Neon only has 1.6.

The switch events are interesting as they report whether the lid is
closed (might be interesting for e.g. powerdevil) and whether a
convertible is in tablet mode (supported for e.g. Lenovo Yogas with
recent kernel). This can be used by KWin internally to enable/disable
the virtual keyboard. And can be exposed globally to switch to Plasma
Mobile shell in future.

Test Plan:
Only through test case as my Lenovo Yoga uses Neon which has a
too old libinput

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9516
2018-01-04 18:05:44 +01:00
Martin Flöser e0b1a5715b Add DBus interface to OrientationSensor and a persistent configuration
Summary:
The initial state for user enabled is now read from config. In addition
a DBus interface is provided exporting this property. This allows
KScreen to determine whether automatic screen rotation is available and
whether the user has it enabled or not.

Furthermore KScreen can change the property and this gets stored into
the configuration. Thus KScreen can offer a user interface to
enable/disable automatic screen rotation as well as enabling/disabling
the manual rotation based on the current user settings.

Test Plan:
Not yet tested, coded on the system which doesn't have an
orientation sensor

Reviewers: #kwin, #plasma, sebas, davidedmundson

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8738
2017-12-26 22:02:47 +01:00
Martin Flöser 68698b4201 [libinput] Find screen for touch screen devices and calibrate accordingly
Summary:
This change finds the screen for a touch screen device based on:
 * number available screens
 * output name defined on the touch screen device
 * internal screen
 * and physical size

The id of the screen is stored in the Device allowing to adjust the
touch points accordingly. This means instead of transferring to the
combined display size the touch points are transferred into the output
space and the position of the output is added. Thus in a multi screen
system the touch points are properly mapped to the output.

Furthermore the screen orientation is passed to the Device and a
calibration matrix is set accordingly. Thus a transformed screen has the
touch screen transformed accordingly.

Please note that this only affects libinput on Wayland and not on X11!
The x11 standalone platform needs to gain similar code.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8748
2017-12-23 10:18:55 +01:00
David Edmundson 965c30f4d4 Register a fake appmenu UI for the appmenu test 2017-12-22 17:23:44 +00:00
David Edmundson 2f9d0bd626 Expliit QString use with QCOMPARE.
Fix builds on older Qt.
2017-12-22 15:47:43 +00:00
David Edmundson ee28104c7a Port to new AppMenu iface
Plus test

Test Plan:
Ran kwin with menus and patched QPT
Ran test

Reviewers: graesslin

Reviewed By: graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9262
2017-12-22 14:38:31 +00:00
Roman Gilg 82d2860469 [colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.

* Three modi:
** Automatic: The location and sun timings are determined automatically
   (location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
   in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
   minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
  phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
  on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
  gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
  the future
* The code is written in a way to make the classes later easily extendable to
  also provide normal color correction, as it's currently done by KGamma on X

Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.

BUG:371494

Reviewers: #kwin, graesslin

Subscribers: kwin, plasma-devel, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 10:58:40 +01:00
Martin Flöser 8a2796d280 Fix regression from KWin 5.9 regarding quick tiling
Summary:
The regression got introduced with 9934f5b575.
The order when setMaximize(false, false) was called changed in regard to
when the quick tiling mode was adjusted. But just changing the ordering
back was no solution as that would cause regressions in other areas
(unit tests fail).

This change builds up on the support for geometry update blocker on
Wayland to be able to better support this situation without causing
further regressions.

Also this change rethinks the code area. There is an idea behind
temporarily setting the quick tile mode to none and that is even
documented in a comment: it should not confuse maximize. So let's do
exactly that: call the maximize in the block where the quick tile
mode is temporarily wrong. As that is only one branch the else branch
performs the same steps.

BUG: 376104
FIXED-IN: 5.12.0

Test Plan: Confirmation in bug report that patch fixes issue

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9178
2017-12-04 17:25:40 +01:00
Martin Flöser ff2e883469 Add support for new IdleInhibition protocol
Summary:
A small helper class is added which manages inhibiting idle for the
ShellClients. So far only very basic functionality is added. That is
only the inhibition on the Surface is followed. It is not yet checked
whether the ShellClient is visible at all. That needs some changes in
ShellClient.

BUG: 385956
FIXED-IN: 5.12

Test Plan: New test case passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8856
2017-11-30 21:51:36 +01:00
Martin Flöser 1c61e61119 [autotests] Support new way to run the tests without need to install
Summary:
KWin was quite good in ensuring that you don't need to install by
passing paths to the tests. The new way is much nicer, so code is
adjusted for the new way. Also if we require a newer ECM in future we
need to support the new way.

No guarantee that the tests don't pick something up from the system env,
that needs more testing.

References: https://community.kde.org/Guidelines_and_HOWTOs/Making_apps_run_uninstalled

Test Plan: The tests which loaded helpers pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7543
2017-11-21 20:34:52 +01:00
Martin Flöser f8be3f746b [effects] Delay creation of EffectFrames in WindowGeometryEffect
Summary:
Without Xwayland KWin starts so fast that the creation of the EffectFrame
triggers a crash in the Wayland integration as the KWin internal
connection isn't fully setup.

To workaround this crash the creation of the EffectFrame is delayed till
the first usage. It doesn't make sense to try to fix the actual crash as
it would require to defer the creation of all Effects.

Test Plan: New test case added which crashes without this fix.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8821
2017-11-21 19:28:00 +01:00
Martin Flöser d4ba05a22f [autotests] Add tests for DRM platform plugin
Summary:
The addition of the test infrastructure is motivated by the regressions
caused by adding mode switching and transformation support.
A contributing factor to these regression is the fact that the DRM
platform does not have any tests. It is difficult to test this code as
it needs to work with hardware, thus we cannot use the real DRM library.
Instead we need to use mocking.

This change sets up some first basic tests with the help of a mockDrm
library. In order to better test the code as units the Drm classes are
slightly refactored. Most importantly the dependency to DrmBackend is
removed wherever possible and replaced by a simple int fd which is mostly
the only element used by the classes.

This first test introduces basic testing of a DrmObject. It is intended
to extend this to at least also test DrmPlane as a central piece of our
Drm platform plugin. This will also extend the tests of DrmObject.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8776
2017-11-21 19:27:33 +01:00
Aleix Pol af85ca6fe5 Merge branch 'Plasma/5.11' 2017-11-17 17:31:46 +01:00
Aleix Pol db6c7e17e6 Fix build with a KWindowSystem framework that doesn't pull QWidget
Summary: Fixes the build with D8705

Test Plan: Just adds includes, I wonder if it should go into Plasma/5.8 and /5.11 too

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: graesslin, plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8706
2017-11-17 17:30:58 +01:00
Martin Flöser f0f4e494fe Merge branch 'Plasma/5.11' 2017-11-16 20:34:52 +01:00
David Edmundson 68e4deb490 Don't use XDGv6 in stable 2017-11-15 11:27:25 +00:00
Martin Flöser 48f7331c4c Merge branch 'Plasma/5.11' 2017-11-14 18:04:29 +01:00
Martin Flöser 5313b85646 Support modifier+mouse button on window decoration
Summary:
On X11 modifier+mouse button on the window decoration triggers the
"special" handling thus as unrestricted move instead of passing the click
to the decoration. Of course on Wayland we want to have the same
functionality.

BUG: 386708
FIXED-IN: 5.11.4

Test Plan: New test case added. PointerInputTest still passes.

Reviewers: #kwin, #plasma, broulik

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8758
2017-11-14 18:03:36 +01:00
Martin Flöser 188491d392 Support user fullscreen for XdgShellSurfaces
Summary:
So far ShellClient did not support that the user can set a window to
fullscreen. This was omitted in the initial implementation as WlShell
doesn't support passing the state back to the surface.

With XdgShell this problem doesn't exist any more and we can implement
it. The implementation is mostly based on the one for Client and
adjusted for the Wayland world.

Test Plan:
New test cases and manual testing (send kate and kwrite to
fullscreen through alt+f3 menu)

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8169
2017-11-14 18:00:47 +01:00
Martin Flöser 9df1744830 Support automatic screen rotation based on orientation sensor
Summary:
This change introduces an OrientationSensor class which wraps a
QOrientationSensor. The OrientationSensor is hold by Screens and gets
enabled if Screens knows about an internal (e.g. LVDS) display which
supports rotation. In addition the OrientationSensor holds an KSni to
enable/disable the automatic rotation support.

The drm platform plugin is adjusted to make use of the OrientationSensor.
The API is defined in a way that this can also be implemented on other
platforms supporting rotation. Most important are hwcomposer and X11
standalone. The latter should be straight forward as rotation is provided
through XRandR. The former needs addition for rotation support first.

Test Plan: Rotated my Yoga 12

Reviewers: #kwin, #plasma, sebas

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8699
2017-11-08 17:44:38 +01:00
Martin Flöser abedb464d5 [QPA] Implement Screen on top of internal Screens API
Summary:
The test DontCrashUseractionsMenu (Waylandonly) found an issue in our
screen handling implementation in the QPA. The code exposed a short time
frame between the dummy screen getting destroyed and the first screen
being added. This could result in a crash of KWin.

There is actually no need to implement Screen on top of Wayland screen.
KWin has all the knowledge, so we can also base this on top of the
Screens API.

Advantages:
 * no delays due to Wayland roundtrips
 * handle screen getting removed (was a TODO)
 * handle resolution changes (was a TODO)

The new implementation has a disadvantage that it destroys and readds
all screens whenever something around the screen changes. This shouldn't
be an issue in practice as it's only for the internal QPA and thus only
affects KWin internal windows which is placed in global coordinates
anyway. If it turns out to be a problem we need to track better the
screen changes - so far those were not tracked at all.

Test Plan: Run a few unit tests which change screens

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8345
2017-10-19 18:03:10 +02:00
Martin Flöser c2d4cb8846 Support initial minimize rule in ShellClient
Summary: Honors the rules for minimizing a window on initial show.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8182
2017-10-19 18:00:42 +02:00
Martin Flöser d3eccada62 Implement Apply desktop rule for ShellClient
Summary:
This change sets up ShellClient for supporting window rules by reading
in the rules once it gets created. As a first rule the Apply initially
rule for desktop is implemented.

Currently it is not yet possible to set window rules through the
configuration menu. So far only injecting rules through the test
framework (temporary rules) is implemented. The idea is to first
implement all rules then to expose them to the UI.

Test Plan: New test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8177
2017-10-19 18:00:06 +02:00
Martin Flöser 8c2b2faf9d Add DBus protocol to virtual keyboard
Summary:
This change adds a DBus API to query whether the virtual keyboard is
currently enabled and provides DBus methods to request that the virtual
keyboard gets enabled/disabled. This is useful for e.g. providing a
Plasmoid or for convertables where the tablet mode needs to be enabled.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8166
2017-10-19 17:59:19 +02:00
Martin Flöser afe0a5c041 Fix placement of KSplash
Summary:
In a bug report there was a reference that on multi-screen KSplash is
not placed correctly. I investigated and noticed that it is an OSD which
sets an own position. In KWin the events were processed correctly but
the position was off.

The problem is that KWin has code to correct the position of an OSD when
it's size changes. This happens also on first damage and then the window
gets incorrectly placed when the position is set. So honor that the
position is set.

Test Plan: Restarted the session, ksplash positioned correctly now.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8268
2017-10-15 16:41:31 +02:00
David Edmundson 5bca058826 Fix DRM EGL crash regression
Summary:
In 47343fb we made GBM buffer shared.

What we wanted to do was:
Unbox the shared_pointer<GBMSurface> to give us a GBMSurface* object
Call the gbm_surface*() on that operator
Then cast that to a void* for eglCreatePlatformWindowSurfaceEXT

What we did:
Cast the std::shared_ptr<GBMSurface> to a gbm_surface*  then cast that
to void*.
This is just a garbage value and it crashes in Mesa when we do our first
paint.

I've replaced that with an explicit method then we can use shared_ptr's
-> operator rather than get() which does the right thing in a readable
way.

Test Plan:
It crashed after rebasing to master (for Aleix too)
No longer crashes

Reviewers: #plasma

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8251
2017-10-12 10:12:24 +02:00
David Edmundson 3d619c995b Fix DRM EGL crash regression
Summary:
In 47343fb we made GBM buffer shared.

What we wanted to do was:
Unbox the shared_pointer<GBMSurface> to give us a GBMSurface* object
Call the gbm_surface*() on that operator
Then cast that to a void* for eglCreatePlatformWindowSurfaceEXT

What we did:
Cast the std::shared_ptr<GBMSurface> to a gbm_surface*  then cast that
to void*.
This is just a garbage value and it crashes in Mesa when we do our first
paint.

I've replaced that with an explicit method then we can use shared_ptr's
-> operator rather than get() which does the right thing in a readable
way.

Test Plan:
It crashed after rebasing to master (for Aleix too)
No longer crashes

Reviewers: #plasma

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8251
2017-10-11 20:04:13 +02:00
Martin Flöser 031e1f323f Merge branch 'Plasma/5.11' 2017-10-11 18:32:32 +02:00
Martin Flöser d6a906da92 [autotests] Fix typo 2017-10-11 18:31:43 +02:00
Martin Flöser c2f5b3e5b1 Merge branch 'Plasma/5.11' 2017-10-09 21:04:41 +02:00
Martin Flöser 47343fb8f7 [platforms/drm] Use a shared pointer for gbm_surface
Summary:
The gbm_surface is owned by the EglGbmBackend, but it's not the only one
using it. The DrmSurfaceBuffer is also using it and needs it to destroy
the gbm_bo. Now this can become a problem in the following situation:

* a page flip is still pending
* the EglGbmBackend destroys the gbm_surface

-> when the page flip happens the DrmSurfaceBuffer will try to destroy
the gbm_bo and crash as the gbm_surface is no longer valid. This
situation can happen when switching screens or when switching compositing
backend (OpenGL 2 -> OpenGL 3).

To address this problem a class GbmSurface is added which wrapps the
gbm_surface pointer. The EglGbmBackend creates and holds a shared pointer
to the GbmSurface and passes that one to the DrmSurfaceBuffer. So when
cleaning up the gbm_surface only the shared pointer is reset and in case
the DrmSurfaceBuffer still needs it, it can access it without problems.

BUG: 385372
FIXED-IN: 5.11.0

Test Plan: Not yet

Reviewers: #kwin, #plasma, subdiff

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8152
2017-10-05 21:32:46 +02:00
David Edmundson 269ec5bbce Merge branch 'Plasma/5.11' 2017-10-04 10:13:37 +01:00
Hartmut Goebel 5e7b3c6c73 Fix: Missing dependencies for kwin autotests
guix (like nix) used a separate prefix for each package. Thus the header
files for
qtdeclarative are in /gnu/store/…-qtdeclarative-5.9.1/include/qt5/ while
the ones for
qtbase are in /gnu/store/…-base-5.9.1/include/qt5/. This means that
*each* dependency's include directory must be specified. This is in
contrast to a "normal" Unix-system, where all includes end up in
/usr/include/qt5 and missing to defined some include-dependencies does
often not raise an error.

Differential Revision: https://phabricator.kde.org/D8112
2017-10-04 10:12:06 +01:00
David Edmundson 7c538207f4 remove xdgv6 use from 5.11 branch 2017-10-02 08:49:37 +01:00
Martin Flöser 252980390d Merge branch 'Plasma/5.11' 2017-10-01 15:26:40 +02:00
Martin Flöser 0d96e60b79 Also send Wayland clients to a new desktop if their desktop was removed
Summary:
So far the method only operated on X11 clients. So when the last desktop
got removed Wayland clients were still on it. As the auto test showed:
this results in a crash.

Credits go to code coverage as it showed that area as red, which made me
look on it and realize this must be broken.

Test Plan: New test case added

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8082
2017-10-01 11:04:05 +02:00
Martin Flöser d75e5c63d4 Ensure Workspace is only started once in Wayland-only mode
The connect to Compositor::sceneCreated must be disconnected again,
otherwise a restart of the Compositor results in Workspace being created
again.

Thanks to our autotests for finding this problem!
2017-10-01 09:06:51 +02:00
Martin Flöser 2fb5a5fb9f [autotests] Support Wayland Only in addition to XWayland
The integrationTest function takes a new optional argument whether the
test supports a Wayland Only mode. If that's the case the test is
compiled twice, once (as always) as "foo" with XWayland support and
once as "foo_waylandonly" without XWayland support.

This way we can ensure that our code always supports both modes. The
tests found multiple issues. At the moment fast running tests are
sporadically crashing on tear down. This needs further investigation.
2017-09-30 16:35:52 +02:00
David Edmundson e492f9e298 XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.

Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.

But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.

Also integrate pinging clients

Test Plan: gtk3-demo  works nicely.

Reviewers: #plasma, graesslin, mart

Reviewed By: #plasma, graesslin

Subscribers: mart, graesslin, kwin, plasma-devel, #kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 16:47:30 +01:00
Martin Flöser 8f0f84d2b3 [autotests] Try to detect whether distro calls cursor theme DMZ-White or Vanilla-DMZ
Some distributions (e.g. Arch, FreeBSD) call the DMZ-White cursor theme
Vanilla-DMZ. Due to that our tests are failing even if the correct theme
is installed (see also T6623). This change tries to detect whether
DMZ-White is installed by looking into the GenericDataLocation. If not
found we set to Vanilla-DMZ. No guarantee that the check works for all
setups, but it's only tests...
2017-09-24 14:53:55 +02:00
Martin Flöser e74eacd279 [autotests] Try making StartTest more robust on FreeBSD
Use QTRY_COMPARE instead of QCOMPARE to wait longer.
2017-09-23 15:17:19 +02:00
Martin Flöser af20f1aa35 Merge branch 'Plasma/5.11' 2017-09-23 11:51:24 +02:00
Martin Flöser ab7b6757bf Properly update the visible (icon) name when the caption changes
Summary:
It was possible that we performed an early exit when the caption changes
and this results in the visible name being wrong. E.g if we have two
windows called foo, the second one has the visible name "foo <2>". After
changing that to "bar" the bug resulted in it still being the foo
variant instead of getting cleared.

BUG: 384760
FIXED-IN: 5.11.0

Test Plan: Created new test case exposing the problem

Reviewers: #kwin, #plasma, hein

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7871
2017-09-23 11:50:48 +02:00
Martin Flöser a17c85a9ea Support mapping QKeyEvent to xkb_keysym_t
Summary:
This is needed in virtual keyboard and also used KKeyServer so far. With
this change it is moved to new API provided in Xkb. The new translation
map is now also used for the direction from Qt::Key +
Qt::KeyboardModifier to xkb_keysym_t.

New implementation is supported by a new test case covering the same
combinations as in the existing direction.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7356
2017-09-19 19:09:17 +02:00
Jesse Pullinen 0eba3f3c18 Fix TouchEvent::id() returning -1, fixes a crash
Summary:
Libinput returns -1 when calling libinput_event_touch_get_slot on an event
from a single-touch touchscreen. The returned value is used in
DecorationEventFilter to determine the touch which is acting on it. The value -1
is used to signify that the decoration is not being acted on. Thus when
releasing the touch, it checks whether it was being dragged, and as it thinks
it isn't, it doesn't handle it and the decoration is still being dragged.
Clicking on the decoration then crashes kwin.

Test Plan: Move a window by dragging the decoration with a single-touch touchscreen.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7854
2017-09-19 07:11:40 +03:00
Martin Flöser 5256338772 [autotests] Force more tests to use evdev as XKB_DEFAULT_RULES
Should help fixing the tests on FreeBSD.
2017-09-18 21:05:34 +02:00
Martin Flöser e55e437d86 [autotests] Force XKB_DEFAULT_RULES to evdev in ModifierOnlyShortcutsTest
This is an idea to fix the failing test on FreeBSD (see T6624). For
Linux this does not change anything.
2017-09-17 20:54:32 +02:00
Martin Flöser 4fa41165d1 Move XRandR event filter into XRandRScreens
Summary:
The code in events.cpp was problematic as it was called in a Wayland
session. So KWin changed outputs, this gets mirrored to XWayland and
then KWin reacted on the XRandR event and might have even changed the
refresh rate due to that - bad idea.

This change moves the code into the already existing X11EventFilter for
XRandR events in XRandRScreens.

Test Plan: Run kwin_x11 in gdb on Xephyr, breakpoint in new code and triggered XRandR event

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7654
2017-09-12 18:53:08 +02:00
Martin Flöser 50470e97c6 [autotests] Drop cast to SceneOpenGL GenericSceneOpenGLTest
Not really needed, instead we can compare on the compositing type.
2017-09-08 16:06:33 +02:00
Martin Flöser e0f95fd913 Delay syncing internal window geometry to end of cycle
Summary:
The syncing of the window geometry to the internal geometry can
unfortunately cause a freeze in very special conditions:
1. create QML component
2. a Plasma::Dialog gets created
3. It creates the DialogShadows
4. This triggers QGlobalStatic creation which locks a non-recursive
mutex
5. The creation of DialogShadows creates a Registry and triggers a
roundtrip on the Wayland server
6. KWin processes all Wayland events
7. This triggers the creation of a ShellClient
8. The ShellClient has a PlasmaShellSurface which requested a position
9. The new geometry does not match the geometry of the Plasma::Dialog
10. ShellClient syncs the geometry to the Plasma::Dialog
11. Plasma::Dialog updates the theme because window geometry changed
12. This accesses the DialogShadows...

which is still in the non recursive mutex and we have a freeze.

By delaying the sync to the end of cycle we jump out of this deadly
sequence.

BUG: 384441

Test Plan:
The freeze doesn't hit any more. It's possible that some test
cases need adjustments.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7712
2017-09-07 19:06:54 +02:00
Martin Flöser c398db3c45 Provide a virtual Scene::qpainterRenderBuffer() -> QImage* method
Needed by testing of QPainter scene to access the back buffer. Exposed
as a virtual method in Scene, so that the test does not have to cast to
SceneQPainter.
2017-09-01 17:44:49 +02:00
Martin Flöser 546d603182 [autotests] Remove not needed includes for scene_qpainter.h 2017-09-01 17:44:49 +02:00
Martin Gräßlin 1e13deaa1d Port some displayWidth/displayHeight usages to Screens::size()
Summary:
KWin::displayWidth and KWin::displayHeight are bound to X11 which
doesn't make much sense on X11. In addition KWin internally knows
the overall display dimensions through the Screens singleton class.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D1798
2017-09-01 17:11:10 +02:00
Martin Flöser 6685288d48 Add <number> to Wayland captions if the caption is the same
Summary:
Bringing another caption feature from X11 to Wayland. If we have
multiple windows with the same caption, starting from the second window
a suffix <number> is added.

E.g. if we have three windows with caption "foo", the naming is:
 * foo
 * foo <2>
 * foo <3>

The change tries to use as much shared code between the X11 and Wayland
implementation. Unfortunately it's not possible to share completely as
the X11 implementation does X11 specific things like editing the visible
name.

By sharing the code the numbering also works cross windowing system.
That is if a window is called "foo" on X11, a new window on Wayland with
caption "foo" will get adjusted to "foo <2>" and vice versa.

The change also eliminates a duplicated signal for captionChanged in
ShellClient (found by test case).

By using the shared implementation on X11 side a bug gets fixed which
got introduced with the support of "unresponsive", this is no longer
considered and the numbering still works even if there is a window which
is unresponsive.

Test Plan: New test case and manual testing

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7425
2017-09-01 17:02:36 +02:00
Martin Flöser 833f933c5c Move X11 specific event filtering for ScreenEdges into x11 standalone platform
Summary:
This change splits out the X11 specific event filtering into a dedicated
X11EventFilter. It is created in the x11 standalone platform plugin when
the first Edge is being created.

Some of the X11 specific code is removed from ScreenEdges, though more
refactoring is possible in ScreenEdges to share more code between X11
specific and generic implementation.

Test Plan: Run KWin on Xephyr, screen edge approach effect still shows

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7406
2017-09-01 17:01:01 +02:00
David Edmundson b57a525ef7 ARGB buffers are premultiplied
D7460 in kwayland assumes all WL_SHM_FORMAT_ARGB8888 buffers have
opacity premultipied RGB values.

Kwin tests need updating to do the same.
Rendering code did not need changing.

Test Plan: Tests now pass

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7607
2017-08-30 10:02:29 +01:00
Martin Flöser 28534e3664 [autotests] Fix testX11TimestampUpdate after latest change
We need to init the X11 standalone platform plugin now.
2017-08-24 21:48:29 +02:00
David Edmundson f0971532c9 Send output enter/leave events to surfaces
Summary:
A surface has an API to know which screen(s) it's on, this is useful
especially for knowing the scale it should render at.

In practice Qt currently doesn't do anything with this information; but
that's set to change.

Test_helpers is changed as we need to create output objects in order for
wl_surface to map them.

Closes task T4467

Test Plan:
Attached unit test.
As mentioned above, it doesn't have any real world impact currently, so not a lot
to test.

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: johanhelsing, graesslin, plasma-devel, kwin, #kwin

Tags: #kwin

Maniphest Tasks: T4467

Differential Revision: https://phabricator.kde.org/D7359
2017-08-24 17:57:30 +01:00
Martin Flöser c87230c3a5 Use xcb-icccm to read the name property
Summary:
The KWindowSystem call which we used doesn't work on Wayland as it's only
implemented in the xcb variant and cannot be made available for Wayland
in an easy way as it is still XLib based.

This change turns the optional XCB-ICCCM dependency in a required one
and thus can use the functionality provided by said library to implement
what KWindowSystem provided.

BUG: 382789

Test Plan: New test case which failed with old code

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7046
2017-08-21 17:58:52 +02:00
Martin Flöser 70bc9524d9 Send QKeyEvent with Qt::Key as expected by Qt to internal windows
Summary:
KWin passes the current keysym converted to a Qt::Key in the QKeyEvent.
The current keysym does not always change when a key gets released, so
when pressing a shortcut the release carry a Qt::Key which could be
considered as wrong.

QtWayland transforms the actual pressed/released key into a keysym and
passes that through the QKeyEvent. This change does the same for the
internal windows. A new QKeyEvent is created and adjusted in a way that
it matches what Qt expects.

Why not change everything to how Qt expects it? The key is used at
various places and in KWin internally we expect the behavior how it is
currently implemented. So it's better to use Qt's expectation only when
interacting with Qt.

Also the change carries a workaround for a bug in QKeySequenceEdit
(see QTBUG-62102) and transforms Super to Meta. As this adjustment only
makes sense for the internal windows we need to send in an adjusted
QKeyEvent anyway, so another argument for using the Qt behavior only in
this place.

Test Plan:
Can set a shortcut on Wayland and it can be used to activate
the window.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6828
2017-08-19 11:37:08 +02:00
Martin Flöser f88c322a3b [platforms/x11] Use a GlxContextAttributeBuilder
Summary:
Based on the work of 3f4995fb9b this change
introduces a GlxContextAttributeBuilder to make the requesting of context
attributes cleaner, more verbose and less error prone copy and paste.

Test Plan:
Switched between Core and legacy and verified the output;
extended auto test

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6411
2017-08-19 11:34:51 +02:00
David Edmundson 34de2c2b5c Track outputs in kwin integration tests
Summary:
Split from the last review, as in order to track output's removed (in
any way that's useful) the registry needs to be on the heap and the change grew.

Test Plan:
Every test that previously passed on my system still does
Though currently that's not every test (for some reason) which was
my main motivation for splitting.

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7377
2017-08-18 15:15:19 +01:00
Martin Flöser 5d101ce297 Migrate Xkb::toQtKey away from KKeyServer
Summary:
Turn Xkb into a QObject

Reduced dependencies on other classes and allows to emit signal directly
instead of emitting a signal on another class.

Dependency inject KWayland::Server::SeatInterface into Xkb

No need to depend on WaylandServer from within Xkb.

[autotests] Add test case for Xkb::toQtKey

Tests all key codes KKeyServer is able to map to Qt.

Migrate Xkb::toQtKey away from KKeyServer

The regression in kwindowsystem in
32526718eae99ccb594360627586eebdf793372b showed once more that it's time
to migrate the xkb keysym to Qt::Key mapping away from KKeyServer. The
main problem with KKeyServer is that it's made for X11 and we don't have
X11 here. This causes warnings printed at runtime and the code only
works by accident at all because KKeyServer fails to initialise
modifiers. That is normally KKeyServer would include the modifiers, but
that is nothing we are interested in for mapping xkb keysyms to Qt::Key.

So to address this, KWin now implements the mapping itself. It's based
on the implementation in KKeyServer, but also improved by providing
faster xkb to Qt conversion (which matters for KWin more than the other
direction).

Long term plan is to extend this so that also on X11 it can be used.
Then it should be split out and be used in KKeyServer as a replacement
for the current implementation which could support both X11 and Wayland.

Test Plan:
New test case added which covers all keysyms supported by
existing KKeyserver mapping

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7336
2017-08-16 19:22:53 +02:00
Martin Flöser 801fe41013 [autotests] Add test case for Xkb::toQtKey
Tests all key codes KKeyServer is able to map to Qt.
2017-08-16 19:22:53 +02:00
Martin Gräßlin f50fbde1a9 Always emit Client::captionChanged when the caption changed
Summary:
With ddf3536f19 a regression got
introduced resulting in Client::captionChanged not being emitted if
Client::setCaption was called without the force parameter.

The regression is only in master branch.

BUG: 383444

Test Plan: Added test case passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7290
2017-08-13 19:23:10 +02:00
Martin Gräßlin f9e0e8a980 [autotests] Try making KWinBindingsTest::testSwitchWindowScript more robust
Another random failure on build.kde.org (see T6546). This tries to use
QTRY_COMPARE on the SignalSpy's count instead of a wait in the hope that
this can handle the multi-threaded situation better. Though it might
also be possible that the other thread just didn't run in the 5 sec we
waited.
2017-08-13 17:08:49 +02:00
Martin Gräßlin d0c2c1ed09 [autotests] Add test case for updating X11 client captions
CCBUG: 383444
2017-08-13 16:52:14 +02:00
Martin Flöser bbca8c6677 Implement the shortcut caption suffix for Wayland windows
Summary:
The generation of the shortcut caption part is moved from Client to
AbstractClient. The ShellClient also has a captionSuffix and implements
the full part in caption.

Overall this needs more refactoring to support more sharing between the
two implementations. But one step at a time.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7093
2017-08-12 11:31:33 +02:00
Martin Gräßlin 5118d9470c [autotests] Try making QuickTilingTest::testShortcut more robust
It failed on CI. A possibility is that the wait for the quick tile
changed took to long, so that the next wait already passed and thus
failed. Instead of wait a QTRY_COMPARE on the size of the signalspy.
2017-08-09 19:22:36 +02:00
Martin Gräßlin 5ff9aa7cf5 [autotests] Try making StrutsTest::testWindowMoveWithPanelBetweenScreens more robust
Flaky on build.kde.org. Let's add some more time between the movements.
2017-08-09 17:54:42 +02:00
Martin Flöser 8379030633 [autotests] Try to make translucencyTest more robust for CI
Changing a QVERIFY into QTRY_VERIFY in hope to make it more robust
on the highly flaky build.kde.org servers.
2017-08-08 20:48:40 +02:00
Martin Flöser af9f833a1d [autotests] Disable Outline in StrutsTest
The StrutsTest is constantly aborting on build.kde.org and lots of
OpenGL stuff in output. This could indicate a problem with the Outline
as the failing test could trigger the Outline. So let's try to disable
it.
2017-08-08 19:56:24 +02:00
Martin Flöser 20e314d151 Properly render XWayland windows in SceneQPainter
Summary:
The buffer for a XWayland window is larger than the actual size. Thus
we need to use the clientSize as reference, not the buffer size.

BUG: 382748

Test Plan: Test passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6952
2017-08-02 19:30:29 +02:00
Martin Gräßlin b3a52e3999 [autotests] Drop PlasmaSurfaceTest::m_connection
Credits to clang for finding unused private variable.
2017-07-31 18:02:00 +02:00
David Edmundson 0809a357c1 Improve testWindowScaled test
Summary:
Comparing a pure blue square isn't a very effective test as someone
cropping the image will still pass.

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6982
2017-07-31 15:12:37 +01:00
Martin Flöser 1447f4641c [autotests] Fix unused function warnings
The functions are defined in a common header but not used in all tests.
This creates needless warning noise, so hide them through an ifdef.
2017-07-29 18:47:58 +02:00
Martin Flöser 64da6c8d1e Replace Workspace::slotWindowQuickTileFoo by a quickTileWindow with argument
Summary:
Thanks to std::bind we don't need that many different slots to setup the
global shortcut connections. Instead we can have one shared
implementation which takes the argument and passes it to the window.

To support std::bind arguments in kwinbindings the initShortcut method
and dependencies are adjusted as well as a new macro is added.

As I don't want to include abstract_client.h in workspace.h a new enum
is created for the quick tiling flags used in Workspace. This caused a
larger refactoring as the change to an enum class also caused quite some
changes.

Test Plan: Affected test cases still pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6783
2017-07-29 17:40:03 +02:00
Martin Flöser e8a92361ae [autotests] Perform complete QImage comparison in SceneQPainterTest::testX11Window
As pixel comparison is failing, let's just compare the image against a
reference image.
2017-07-28 21:17:59 +02:00
Martin Flöser f6c964a32b [autotests] Another change for SceneQPainterTest::testX11Window to make it pass CI
Still missing ideas, theory is that rendering on Xwayland is too slow and
we have an invalid buffer or that reparenting took to long.
2017-07-28 06:50:00 +02:00
Martin Flöser a13ecb1cac [autotests] Try to make SceneQPainterTest::testX11Window more robust
Still failing on CI, let's try  to verify that the buffer is ready.
2017-07-27 21:34:48 +02:00
Martin Flöser d39fea1b67 [autotests] Try to make SceneQPainterTest::testX11Window more robust
It fails on build.kde.org which might be a side effect.
2017-07-27 20:36:52 +02:00
Martin Flöser 54ca2bba25 [autotests] Add test case for incorrect rendering of XWayland on SceneQPainter
CCBUG: 382748
2017-07-27 17:09:40 +02:00
Martin Flöser 1557f102f4 [autotests] Add test cases for verifying that Toplevel::window() is only set for X11
Also at the same time verifies that root info active client is only
set on X11.
2017-07-26 07:08:27 +02:00
Martin Flöser f5f14475b5 [autotests] Try to make PlasmaWindowTest::testCreateDestroyX11PlasmaWindow more robust
The test was racing on build.kde.org and failing due to that. We have
a condition there where we wait for some parts being transmitted through
X and some through Wayland. The test assumed X is faster and failed due
to that.
2017-07-25 21:19:11 +02:00
Martin Flöser c29d6093ba Implement support for window shortcuts for Wayland windows
Summary:
Moves most of the implementation from Client to AbstractClient, so that
it can be used for both Client and ShellClient. Only the X11 specific
code is kept in Client.

Not yet implemented is updating the window caption.

Unfortunately the testing of this feature showed that setting a window
shortcut is not working on Wayland at all (the Qt widget doesn't properly
catch the shortcut). So this feature is currently only of erm theoretical
use.

Test Plan: Added new test case. No testing in real world as explained.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6818
2017-07-25 07:12:42 +02:00
Martin Gräßlin a1af59e9dd [autotests] Extend X11ClientTest::testFullscreenLayerWithActiveWaylandWindow
Unfortunately still doesn't trigger the actual bug.
2017-07-23 20:02:57 +02:00
Martin Gräßlin bd158a6321 Reset last_active_client when a ShellClient is removed
Summary:
The last_active_client is set when an AbstractClient gets activated. For
the X11 case the last_active_client was getting reset to nullptr when
the last_active_client gets destroyed. But for the ShellClient that did
not yet happen. This could result in a crash.

This change addresses the problem and adds a test case which triggered
the crash. The condition of the crash are difficult to generate though -
it took me about an hour to write the test for the crash.

1. Wayland client must be active
2. Explicit focus to null (no active client)
3. destroy Wayland window
4. X11 client which sets focus on itself without interaction with window
  manager

Test Plan: test case no longer crashes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6852
2017-07-23 16:21:38 +02:00
Martin Flöser dcbfa0869b [autotest] Add a test case for X11 fullscreen windows when an Wayland window is there
KWin cannot handle the layering correctly when a Wayland window is active
and there is a fullscreen X11 window. This test tries to simulate the
situation, but it does not show it.

Nevertheless it's a good test, so let's add it.

CCBUG: 375759
2017-07-23 11:50:58 +02:00
Martin Flöser 8cd95b56e3 [autotests] Add test case for sending window to desktop shortcuts 2017-07-21 07:12:36 +02:00
Martin Flöser b1efdbaaf1 [autotest] Test opposite direction in switchWindow 2017-07-20 21:52:17 +02:00
Martin Flöser 84b0578a71 [autotests] Add test cases for switchWindow
A new test class for KWinBindings added which is intended to group the
testing of the various slots set up in kwinbindings.cpp. As the scripts
also delegate to the slots this is also tested.
2017-07-20 20:49:42 +02:00
Martin Flöser c9fa43e9db [autotests] Add test case for Client window shortcut
Registers a shortcut on a window and triggers it.
2017-07-20 19:00:01 +02:00
Martin Flöser 81c59a86dd [autotests] Try to make new QuickTilingTest addition more robust on CI
A wait on signalspy fails on CI and a TRY_COMPARE on the count of the
spy should be sufficient.
2017-07-18 21:29:50 +02:00
Martin Flöser bbbd2f6a24 [autotests/integration] Extend QuickTilingTest for keyboard shortcut and scripting 2017-07-18 21:11:06 +02:00
Martin Flöser 73fa7b21a1 [qpa] Use the new OpenGLContextAttributeBuilder to create Qt's OpenGL context
Summary:
Introduces a few more attributes needed for creating the OpenGL context
used by the QPA.

Test Plan:
Extended test and run KWin/Wayland and verified that OpenGL context
gets created correctly.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6734
2017-07-17 16:53:37 +02:00
Martin Flöser 8e2805ce9d Merge branch 'Plasma/5.10' 2017-07-17 16:53:08 +02:00
Martin Flöser 139b4dc82a Properly swap the quick tile side when pressing the shortcut again
Summary:
The quick tile shortcuts have a feature of moving the window to the next
screen if one presses the same shortcut again.
E.g. if a window is quick tiled to the left on the right most screen,
quick tile again to left should move it to the left screen and quick tile
right. Thus it swaps the borders.

This wasn't handled correctly, especially not for modes like top and
bottom. If a window is quick tiled to the top an impossible mode was
generated: Left | Right. Doesn't make sense.

This change fixes the mode swapping and extends our quick tile testing
to cover the situation.

BUG: 382313
FIXED-IN: 5.10.4

Test Plan: Extended test case

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6708
2017-07-17 16:51:31 +02:00
Martin Flöser 672cae9a7d Implement support for restricted move area on Wayland
Summary:
This change implements a missing TODO to generate the restricted move
area for windows with struts (aka panel) on Wayland.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6611
2017-07-11 17:52:01 +02:00
Martin Flöser 14c8440f11 Restrict move resize area only on the screen the strut window is on
Summary:
By allowing panels between screens in 5.8 to have a strut we created a
"regression" in KWin. KWin always was wrong, just we didn't notice as
neither Plasma nor previously Kicker set a strut on panels between shared
screen edges.

The strut is created from the edge of the overall screen setup. This
means a panel on the left edge of a screen on the right has the strut
starting from the left screen. KWin uses the strut to restrict the move
resize area: a window decoration is not allowed to go below a strut. Thus
it becomes impossible to move the window from the right to the left
screen.

This change tries to solve this problem by only restricting the move area
on the screen the window with the strut is on. E.g. if the window is on
the right screen, the left screen is not affected. Thus it's possible
again to move a window from one screen to the other as the added test
case shows.

Unfortunately there are still corner cases where this won't work
correctly. If the window is on both screens this won't work. It is also a
rather heavy change for KWin and thus it's targeted for master and not
for the 5.10 or the 5.8 branch. If we notice that the patch works well
and doesn't create further issues, it should be considered for
backporting.

BUG: 371199
CCBUG: 370510
FIXED-IN: 5.11

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6562
2017-07-11 17:51:39 +02:00
Martin Flöser aa4d12a906 [autotests] Ensure TestDontCrashUseractionsMenu uses breeze
The test introduced with 962a2e39ee is
meant to be used with the breeze widget style as that one triggered the
crashy code. Given the test coverage build.kde.org does not run with the
breeze widget style, so enforce this through manual loading.
2017-07-08 10:47:17 +02:00
Martin Flöser 0d941c6e27 Merge branch 'Plasma/5.10' 2017-07-06 21:18:18 +02:00
Martin Flöser 962a2e39ee [qpa] Prevent crash due to Surface getting null
Summary:
This is a regression due to changes in Breeze to support Qt 5.8+ behavior
change. KWin's own QPA operates like < Qt 5.7 and breeze was programmed
against that. Due to that it can happen now that Breeze hits code paths
in which KWin does not have a surface.

To trigger one only needed to open the user actions menu twice.

This change adds a test case which simulates the problem and fixes all
crashes happening in the code path.

Most likely shadows are now broken for KWin's own windows, this change is
only to prevent the crash and thus is for 5.10 branch, while shadow
fixing will go to master branch.

BUG: 382063
FIXED-IN: 5.10.4

Test Plan: New test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6533
2017-07-06 19:14:15 +02:00
Martin Flöser adceb9c0c9 Merge branch 'Plasma/5.10' 2017-07-01 08:21:16 +02:00
Martin Flöser 113be5fac8 Restore active client after ending showing desktop
Summary:
Showing desktop requests focus on the desktop window. This means the
active window is reset. When ending showing desktop the state was not
restored.

This change addresses this problem by requesting focus to the best
window.

BUG: 375993
FIXED-IN: 5.10.4

Test Plan: New autotest and manual testing

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6420
2017-07-01 08:20:01 +02:00
Martin Flöser 3f4995fb9b Refactor the specification of OpenGL context attributes
Summary:
The current way to specify the OpenGL context attributes does no longer
scale as can be seen in D6344. There are too many different context
attribute sets and with every addition we grow lots of copied code. The
chances to introduce errors in that code which is difficult to debug are
very high. As can be seen in the glx backend which defines major 1,
minor 2, but it should be major 2, minor 1.

This change reworks this code by creating a builder class which contains
only an abstract definition of what needs to be in the attributes.
E.g. the version, whether it's robust and so on.

Now we can just have a list of possible attributes in a well described
way:
    auto builder;
    builder.setVersion(3, 1);
    builder.setRobust(true);

All possible builders are added to a list and operated on in a for loop
which tries to creat a context. Once it succeeded it breaks the list.
In addition a debug statement is added which prints out the set of
options which went into the context.

So far this is only done for EGL, GLX can follow once D6344 is merged.

Test Plan: New unit test added, kwin_wayland OpenGL tests run and verified

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6396
2017-06-26 22:13:47 +02:00
Martin Flöser 004c0f3892 [autotests] Test creating core context profile
Extends OpenGL testRestart to once with GLCore and once with legacy.
2017-06-25 09:48:46 +02:00
Martin Flöser 66f0839925 [autotests] Introduce a SceneOpenGL ES test
The SceneOpenGLTest is transformed into a GenericSceneOpenGLTest which
can create either an OpenGL or an OpenGL ES scene based on env variable
which it sets in initTestCase. The env variable to set is passed as a
ctor argument from the SceneOpenGLTest and the new SceneOpenGLESTest.

This allows to easily run the same test code for both our OpenGL and
OpenGL ES compositor.
2017-06-24 21:05:49 +02:00
Martin Flöser e2682c8405 [autotests] Extend pointer constraints test for closing window of locked pointer 2017-06-24 20:31:50 +02:00
Martin Flöser 33ca5025e7 Merge branch 'Plasma/5.10' 2017-06-20 07:11:16 +02:00
Martin Flöser c45e165514 Fix switch desktop through edge when moving window
Summary:
There was a regression introduced in ScreenEdges when introducing the
activatesForPointer method. It considered the switch desktop on edge,
but not the special case of switch desktop when moving windows. Due to
that the edges did not activate when moving the window.

This change addresses the regression and extends the autotest to ensure
it's properly covered.

BUG: 380440
FIXED-IN: 5.10.3

Test Plan: Manual testing and extended auto test

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6257
2017-06-20 06:57:33 +02:00
Martin Flöser 56e681823b [autotest] Disable default TabBox on touch screen edge in ScreenEdgeClientShowTest
Not needed and the QML doesn't work well in tests.
2017-06-19 21:54:11 +02:00
Martin Flöser 0364fae4b9 [autotests] Fix ScreenEdgeClientShowTest::testScreenEdgeShowHideX11 on new CI
On the new CI system this test is failing. This might be a variation of
Qt 5.10 as I'm able to reproduce with Qt 5.10. From the investigation it
is not a bug in KWin. The test was failing due to a missing xcb_flush.
This happens when we go back to the event loop which seems not to happen
in proper timing. By adding a qWait we force to go to the event loop, the
flush is performed and the test passes.
2017-06-19 21:45:58 +02:00
Martin Flöser 0df09a8cbb Better handle cases when the xkb keymap fails to be created
Summary:
If the keymap cannot be created a few pointers in Xkb are null.
We should make sure to not call any xkbcommon functions on those
null pointers and instead use proper fallbacks.

This change introduces fixes for a few usages, but it's not unlikely
that there are more cases.

BUG: 381210
FIXED-IN: 5.10.3

Test Plan:
Autotest added for the condition of the bug, which does
not crash any more. Just starting the test found a few more crash
cases.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6260
2017-06-18 21:04:58 +02:00
Martin Flöser 6a4e9cbb58 Merge branch 'Plasma/5.9' into Plasma/5.10 2017-05-12 07:08:04 +02:00
Martin Gräßlin 229be65e40 Improve the escape key handling for breaking constrained pointers
Summary:
So far KWin started to filter out the escape key as soon as it gets
pressed. This was done by unsetting keyboard focus. The idea was to
reset keyboard focus when it is only a short press and that then the
keyboard state is correct for the application. But in practice this
does not work. The only application currently supporting pointer
constraints (Xwayland) does not do anything on a key which is pressed
when gaining keyboard focus. The result is escape not working in
pointer constrained Xwayland windows.

This change addresses this problem by changing the interaction to only
unset keyboard focus when our break constraints condition is met. This
should also result in the application not handling the key release, but
it means it gets the key press. Unfortunately I don't have a good way
to test.

BUG: 378452

Test Plan: None

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5488
2017-05-12 07:06:44 +02:00
Martin Gräßlin c3e2ea6c21 Merge branch 'Plasma/5.9' 2017-05-05 19:16:38 +02:00
Martin Gräßlin cacfdf3676 Merge branch 'Plasma/5.8' into Plasma/5.9 2017-05-05 19:14:10 +02:00
Martin Gräßlin 0bec9ad733 Improve the x11 timestamp handling
Summary:
So far KWin only updated the x11 timestamp if the new timestamp is larger
than the existing one. While this is a useful thing it creates problems
when the 32 bit msec based time stamp wraps around which happens after
running an X server for 49 days. After the timestamp wrapped around KWin
would not update the timestamp any more and thus some calls might fail.
Most prominent victims are keyboard and pointer grab which fails as the
timestamp is either larger than the server timestamp or smaller than the
last grab timestamp.

Another problem related to timestamp handling is KWin getting broken by
wrong timestamps sent by applications. A prominent example is clusterssh
which used to send a timestamp as unix time which is larger than the
x timestamp and thus our timestamp gets too large.

This change addresses these problems by allowing to reset the timestamp.
This is only used from updateXTime (which is normally invoked before we
do things like grabKeyboard). Thus we make QX11Info::getTimestamp the
ultimate trusted source for timestamps.

BUG: 377901
BUG: 348569
FIXED-IN: 5.8.7

Test Plan: As I cannot wait 50 days: unit tests for the two conditions added.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5704
2017-05-03 21:36:34 +02:00
Martin Gräßlin b221d529a2 [autotests] Fix touch screen edge test after setting a default
Changes the config mocking to not have an action on the left edge which
conflicts with the test condition.
2017-05-02 21:17:41 +02:00
Martin Gräßlin 207eb167e1 [autotests/integration] Fix SceneQPainter::testWindowScaled
A code of line was missing.
2017-05-01 17:10:42 +02:00
David Edmundson 80f21064f1 Merge branch 'scaling' 2017-04-29 14:11:13 +01:00
Martin Gräßlin 857d8a9c37 Add a KSharedConfigPtr for kcminputrc to KWin::Application
Summary:
There are a few places where KWin needs to read values from kcminputrc.
As I need to add yet another one it makes more sense to properly
structure it like in other cases and have only one kcminputrc hold in
the application. This also allows to better mock the config values in
the integration tests.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5540
2017-04-24 21:01:03 +02:00
Martin Gräßlin e9a44a275e Support blocking of screen edges on active fullscreen windows also for touch
Summary:
This change ensures that the blocking condition of screen edges is also
honored for touch screen swipe gestures.

Test Plan: Only the added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5403
2017-04-22 08:16:31 +02:00
Martin Gräßlin b132fe7c24 Add support for keyboard layout switching policy "winclass"
Summary:
This is quite similar to the policy "window" - the main difference is
that windows from the same application share the layout. So only
switching to a window from another application changes the layout.

This change is the last policy to add for support of all the policies we
have on X11.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5365
2017-04-22 08:15:59 +02:00
Martin Gräßlin c8274dbe57 Add support for keyboard layout switching policy "window"
Summary:
This policy stores the layout for each window which becomes active
and restores the layout once it gets activated again.

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5315
2017-04-22 08:15:45 +02:00
Martin Gräßlin bf99d9ffdd Introduce support for keyboard layout switching policies
Summary:
This change introduces the initial support for keyboard layout switching
policies like in the X11 session. This first change only adds support for
Global and Virtual Desktop policy. This means the current layout is
stored in context to the current virtual desktop. Whenever one changes
the virtual desktop the previous layout is restored. If the user has not
yet navigated to this virtual desktop a switch to default layout is
performed.

This is the first code interacting with the new Virtual Desktop API which
is not based on integer ids. To fully support this the API is slightly
extended.

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5301
2017-04-22 08:15:25 +02:00
Martin Gräßlin 9a13743c49 Don't update the focused pointer Surface if a button is pressed
Summary:
During pointer motion we already had the condition that an update of
focused pointer surface can only happen when no button is pressed. But
there are more conditions where we try to update the focused pointer even
if a button is pressed. E.g. if the stacking order changes.

This happens when trying to move one of Qt's dock widgets:
 1. Press inside a dock widget
 2. Qt opens another window, which is underneath the cursor
 3. KWin sends pointer leave to parent window
 4. dock widget movement breaks

This change ensures that also this sequence works as expected and the
pointer gets only updated when there are no buttons pressed, no matter
from where we go into the update code path.

BUG: 372876

Test Plan: Dock widgets in Dolphin can be moved now.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5461
2017-04-20 17:02:42 +02:00
Martin Gräßlin c3ecf55bf8 Do not handle ScreenEdges::check for Edges which don't activate for Pointer
Summary:
On X11 the edges reserved only for pointer started to show the approach
geometry. This problem is addressed by this change.

Touch screen events do not go through this method, neither is it used on
Wayland.

Test Plan: Tested on X11, problem fixed

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5421
2017-04-20 17:02:16 +02:00
Martin Gräßlin 2132b1e0c8 [effects] Use arg="true" in the kcfg files
Summary:
By changing all kcfg to have arg="true" we can pass in the same
KSharedConfigPtr into all effects. This allows to have fake config in
the tests and in the planned effect demo mode.

Also it means that we don't have to hardcode the name kwinrc into the
files. In the configs - where we cannot access the effectshandler - we
use the define KWIN_CONFIG which gets generated based on the compile
time arguments.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3571
2017-04-15 10:03:34 +02:00
Martin Gräßlin 259e373bfc [tabbox] Expose noModifierGrab to QtQuick
Summary:
There is a special mode in TabBox which is the noModifierGrab mode. This
is Alt+Tab active without a modifier being hold. This mode is entered
when being activated through screen edges (either pointer or touch). So
far this was not exposed to QtQuick and thus one could not end the mode
using pointer or touch. It is possible to select another window, but not
to activate it. That required the press of a keyboard key.

This setup is rather unfortunate. By exposing the mode to QtQuick we can
react from QtQuick side to it and invoke already exposed functionality to
select and item and directly activate it - existing left-over from the
Plasma Active window switcher.

Test Plan:
Tested on X11 and Wayland with an adjusted lnf package. It kind
of works, but there are additional issues on both X11 and Wayland.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5414
2017-04-12 19:46:48 +02:00
Martin Gräßlin 3259d5e113 Cancel popup if the user clicked window decoration of parent window
Summary:
So far the window decoration was not considered and e.g. right clicking
the window decoration resulted in two open popups - one by KWin and one
by the application. This change addresses the problem by ensuring the
popup gets cancelled if the decoration is clicked. It's considered not
being part of the window.

Test Plan: Added test case which fails without the change

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5388
2017-04-11 20:22:32 +02:00
Martin Gräßlin 2be1625822 Add support for new touch screen callbacks to KWin scripts and scripted effects
Summary:
Exposes two new global JS functions to register and unregister touch
screen edges.

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5277
2017-04-07 16:18:09 +02:00
Martin Gräßlin 63b1138307 Add support for new touch screen edge actions to declarative KWin scripts
Summary:
This change introduces a new property mode in ScreenEdgeItem to switch
between Pointer and Touch mode. The touch mode interacts with the new
touch screen edge gestures through a QAction.

Test Plan: New test case added

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5272
2017-04-07 16:17:48 +02:00
Martin Gräßlin e6aabf5b9f Add callback functionality for touch screen swipe gestures
Summary:
This is implemented through QActions following the general approach
inside KWin and not the older approach used by ScreenEdges for pointer
callback activation.

Test Plan: Extended auto test

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5263
2017-04-07 16:16:34 +02:00
Martin Gräßlin 64ce6259a9 Introduce dedicated actions for touch screen swipe gestures
Summary:
The new touch gestures activated for the same actions as configured for
mouse pointer actions. This has disadvantages as the only configured
default screen edge action cannot be triggered (corner) on touch. On the
other hand setting a default touch gesture would be rather annoying with
pointer as a default.

So overall it makes sense to split the actions and have dedicated pointer
and dedicated touch actions.

This change introduces the first part of it and splits the handling in
general. We now have:

Activates for pointer and touch:
 * client (auto-hiding panels)

Activates for pointer only:
 * the configured action
 * virtual desktop switching
 * callbacks

Activates for touch only:
 * the new touch action

The touch actions are implemented similar to the pointer actions which
slight improvements in the code which will be backported to the pointer
actions.

Introducing callbacks will be the next step. I plan to do it a little bit
different by using QActions as that's what KWin internally uses for
everything except screen edges.

Test Plan: Manual testing and improved auto tests

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5252
2017-04-07 16:16:18 +02:00
Martin Gräßlin 1193b0da77 Initial support for popup window handling
Summary:
So far KWin did not properly handle popup windows. That is when a popup
surface got created and a click outside the surface happened KWin did not
send out the popupDone Wayland event.

This change makes KWin aware of whether a surface is a popup and tracks
through a new PopupInputFilter whether there are popup windows. In case
there are popups the new filter waits for mouse press events and cancels
the popups if the press does not happen on any surface belonging to the
same client. To quote the relevant section of the Wayland documentation:

    The popup grab continues until the window is destroyed or a mouse
    button is pressed in any other client's window. A click in any of the
    client's surfaces is reported as normal, however, clicks in other
    clients' surfaces will be discarded and trigger the callback.

So far the support is still incomplete. Not yet implemented are:
 * support xdg_shell popup windows
 * verifying whether the popup is allowed to be a popup
 * cancel the popup on more global interactions like screen lock or
   kwin effect

BUG: 366609
FIXED-IN: 5.10

Test Plan: Auto test and manual testing with QtWayland client

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5177
2017-04-07 16:14:50 +02:00
Kai Uwe Broulik 1eb950a985 Desaturate non-responsive windows
When an application is not responding, its window is desaturated to communicate this.
Also "(Not Responding)" is added to the title bar.

Differential Revision: https://phabricator.kde.org/D5245
2017-04-05 11:16:23 +02:00
Martin Gräßlin 67295336e5 Add support for interactive selection through touch events
Summary:
This was forgotten during implementing the interactive window/point
selection. With this change it is also possible to perform the
interaction through touch events. In that case KWin takes over any
existing touch sequence.

This implements T5315.

Test Plan: Added auto test and took a screenshot through touch events

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5203
2017-03-31 07:44:38 +02:00
David Edmundson 59515b1681 Scale QPainter x11 windowed backend
Reviewers: #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3495
2017-03-29 20:53:22 +01:00
Martin Gräßlin dce674f3ae [autotests] Adjust ShellClientTest to changes in 634dfc09e4
The desktopPresenceChanged signal is no longer delayed by one cycle.
2017-03-29 06:49:12 +02:00
Martin Gräßlin 4adb2b65e8 [autotests] Add test case for showing auto-hiding panel through swipe gesture 2017-03-28 22:01:16 +02:00
Martin Gräßlin aa6c8f8116 Add support for activating screenedges through touch swipe gestures
Summary:
Each Edge creates a SwipeGesture for touch activation. The swipe needs to
be a single finger starting from the edge into the screen for at least
20 %. The SwipeGesture and GestureRecognizer is extended to support the
use cases of the touch screen edge swipe.

New features supported by the gesture system are:
 * minimum and maximum position
 * a minimum delta for the swipe
 * progress signal based on the minimum delta
 * starting a swipe with a start point

The Edge has the progress signal connected to its approach signal, thus
visual feedback is provided through the screen edge effect.

The screen edge system supports touch only for the edges (corners are
too difficult to activate on touch screens). At the moment the following
features are supported:
 * screen edge show/raise of windows (e.g. auto hidden panels)
 * trigger the configured action
 * trigger the configured callback function (e.g. script)

In future it might make sense to add a touch specific configuration
action to support different actions for screen edges activated by mouse
and touch.

BUG: 370323

Test Plan:
configured a screen edge and triggered through touch,
added an auto-hiding panel and triggered through touch

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5106
2017-03-27 17:44:02 +02:00
Martin Gräßlin 22c91df2ec Add support for global touchpad swipe gestures
Summary:
This change adds global touchpad swipe gestures to the
GlobalShortcutsManager and hooks up the swipe gestures as defined at the
Plasma Affenfels sprint:
 * swipe up: Desktop Grid
 * swipe down: Present Windows
 * swipe left: previous virtual desktop
 * swipe right: next virtual desktop

The main work is handled by two new classes: SwipeGesture and
GestureRecognizer. This is implemented in a way that it can be extended
to also recognize touch screen gestures and pinch gestures.

The SwipeGesture defines what is required for the gesture to trigger.
Currently this includes the minimum and maximum number of fingers
participating in the gesture and the direction. The gesture gets
registered in the GestureRecognizer.

The events for the gesture are fed into the GestureRecognizer. It
evaluates which gestures could trigger and tracks them for every update
of the gesture. In the process of the gesture tracking the
GestureRecognizer emits signals on the Gesture:
 * started: when the Gesture gets considered for a sequence
 * cancelled: the Gesture no longer matches the sequence
 * triggered: the sequence ended and the Gesture still matches

The remaining changes are related to hook up the existing shortcut
framework with the new touchpad gestures. The GlobalShortcutManager
gained support for it, InputRedirection and EffectsHandler offer methods
to register a QAction. VirtualDesktopManager, PresentWindows and
DesktopGrid are adjusted to support the gesture.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5097
2017-03-27 17:43:44 +02:00
Martin Gräßlin 0bb587dcb9 Ensure PointerInputRedirection::processMotion finishes prior to warping
Summary:
Consider the following situation: we have three InputEventFilter linked
in the sequence A - B - C.

The input filters are processing pointer motion events. The expected
behavior is that the new motion is processed in the sequence
   A -> B -> C

So far this did not work correctly if the pointer gets warped during the
processing. If e.g. filter B warps the pointer we get a motion sequence:
   A (1) -> B (1) -> A (2) -> B (2) -> C (2) -> C (1)

The filters following the one warping the pointer get first the newer
than the older position. This is obviously wrong. Unfortunately it is not
just a theoretical condition, but a condition happening when interacting
with the screenedges, which warp the pointer.

This change introduces a PositionUpdateBlocker in
PointerInputRedirection::processMotion to ensure that a processMotion
call finishes prior to the next update. If the PositionUpdateBlocker is
blocked the new position gets scheduled and processed once the
PositionUpdateBlocker gets destroyed.

With this we get the expected sequence for B warping pointer:
   A (1) -> B (1) -> C (1) -> A (2) -> B (2) -> C (2)

This should hopefully improve the interaction with screen edges on
Wayland.

CCBUG: 374867

Test Plan:
Added an auto test demonstrating the issue of incorrect
ordering caused by screenedges. Prior to the change the test is failing.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5182
2017-03-27 07:08:10 +02:00
Marco Martin a25a06b6fa remove offending test
in reference to discussion on
https://phabricator.kde.org/D4718
2017-03-16 18:30:39 +01:00
Marco Martin a7b7ce9ec0 new logout effect
Summary:
new logout effect: it's just a slow fade in of the logout
greeter (window is usable immediately tough

Test Plan: logout greeter now fades in without setting the window opacity manually

Reviewers: graesslin, #plasma

Reviewed By: graesslin, #plasma

Subscribers: broulik, plasma-devel, kwin, #kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5045
2017-03-15 17:47:22 +01:00
Marco Martin c0b207a2b5 support for auto-hidden windows to resize
Summary:
auto hidden windows were shown again when their geometry
changed, this was done for being as easy as possible as
the unhide zone changed, but the behavior looked very
annoying as autohide panels with an self resize taskbar
would unhide themselves every time any window gets open
or closed.
This makes the edge keep track of
windows that can resize/move themselves while auto hidden

Test Plan:
a self-resizing autohidden panel with a taskbar in it doesn't auto unhide
anymore when a window is opened or closed.
the unhide area gets properly updated

Reviewers: graesslin, #plasma

Reviewed By: graesslin, #plasma

Subscribers: luebking, plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4718
2017-03-08 23:55:20 +01:00
Martin Gräßlin cf79de5f36 Merge branch 'Plasma/5.9' 2017-02-14 07:37:00 +01:00
Martin Gräßlin 8b4f284249 [autotests] Add test case for quick tiling on X11
Exposes our regressions of X11 quick tiling when a window is vertically
maximized.

CCBUG: 376155
2017-02-14 07:29:38 +01:00
Martin Gräßlin 40de5fa75f Only export the org.kde.keyboard DBus service if there are at least two layouts
Summary:
It doesn't make much sense to export the DBus service if there is nothing
one can do with it.

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4562
2017-02-11 11:37:45 +01:00
Martin Gräßlin df76d83087 [autotests] Add test case for per-keyboard-layout global shortcut
This new test method verifies that the global shortcut functionality
to switch to a specific layout functions correctly.
2017-02-11 09:46:33 +01:00
Martin Gräßlin 94f8011914 Merge branch 'Plasma/5.9' 2017-02-07 22:06:57 +01:00
Martin Gräßlin 16647c3a3c Require Qt 5.7 and remove pre-5.7 code
Summary:
Increases minimum Qt version to 5.7. This allows to drop the pre-5.7
virtual keyboard and various ifdefs for now unsupported versions.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4485
2017-02-07 20:43:19 +01:00
Martin Gräßlin 8edd0336e6 Support creation of PlasmaShellSurface prior to ShellSurface
Summary:
So far KWin did not support the sequence:
1. Create wl_shell
2. Create PlasmaShellSurface
3. Create wl_shell_surface

KWin only supported the case that the PlasmaShellSurface is the last
thing to get created. This is rather limiting and can be considered a
bug. At least we had a QEXPECT_FAIL auto test for this situation. So
it was a known issue.

This change should make it easier to support the QtWayland changes in
Qt 5.8.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4482
2017-02-07 19:26:36 +01:00
Martin Gräßlin b16bd4147a Ensure the layoutChanged DBus signal gets emitted when changing layouts through DBus
Summary:
Unfortunately Xkb does not emit a signal when the keyboard layout
changes. Due to that we need to manually check in KeyboardLayout after
each action which could change the layout whether the layout changed.

This was not yet done for the case when the layout got changed through
the DBus interface. Resulting in the DBus signal not emitted.

This change addresses the issue by invoking the check for change after
changing the keyboard layout.

Test Plan: Added test case

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4387
2017-02-06 19:36:30 +01:00
Martin Gräßlin d33c96af5e [autotests] Add test case for changing keyboard layout through DBus
Calls setLayout of org.kde.KeyboardLayouts.
2017-01-31 19:42:55 +01:00
Martin Gräßlin 8d9c4acf4d Provide kxbk config through kwinApp
Summary:
So far KWin parsed the kxbkrc at multiple places (once in Xkb, once
in KeyboardLayout). This is now replaced by one KSharedConfigPtr hold
by kwinApp, just like the normal kwinrc. The KSharedConfigPtr is now
passed to Xkb.

As a nice side effect this makes it easier to test keyboard layout
changes as we can now properly mock the keyboard configuration. Thus
this change also comes with an autotest for loading keyboard layout
configuration. This is becoming more and more a need as we start
getting bug reports for layout specific issues like global shortcuts
not working with Greek layout.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4315
2017-01-30 17:04:03 +01:00
Martin Gräßlin c35aae2c4f Merge branch 'Plasma/5.9' 2017-01-30 17:03:46 +01:00
Martin Gräßlin 5083adb1b8 Call performMoveResize when we got a new geoemtry during resize
Summary:
So far on a geometry sync we did not call performMoveResize like we
do on X11 when getting the sync. This resulted in the
clientStepUserMovedResized not getting called during resize and the
geometry update effect to not function.

BUG: 374869
FIXED-IN: 5.9.1

Test Plan: Geometry hint updates

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4333
2017-01-30 17:02:13 +01:00
Martin Gräßlin 3088b50ad4 Merge branch 'Plasma/5.9' 2017-01-29 14:03:51 +01:00
Martin Gräßlin a67f4dfa65 [autotests] Add test case for resizing window manually
During resize the signal clientStepUserMovedResized signal is not emitted
for Wayland windows which causes the window geometry effect to not
function. This change adds a test case highlighting the problem.
2017-01-29 14:01:15 +01:00
Martin Gräßlin de444194ed Improve MoveResizeWindowTest::testMove expected fail cases
Instead of having an expect fail on every check for the count of signals
emitted for clientStepUserMovedResized we reset after the first one which
is the actual issue.

Thus we can properly check that in the other cases the signals are
emitted.
2017-01-26 20:41:58 +01:00
Martin Gräßlin 1173f190bc Merge branch 'Plasma/5.9' 2017-01-25 13:59:39 +01:00
Martin Gräßlin 7e89c51823 Add workaround for touch input offset for decorated windows
Summary:
If a Wayland window is decorated the decoration size was not considered
when passing touch points to the Wayland window. For pointer input this
is considered and implemented through the input transformation matrix
which KWayland::Server::SeatInterface accepts. This should also be done
for Touch. Unfortunately the frameworks version for Plasma 5.9 is already
tagged and done and we cannot depend on new API.

Thus this change tries to workaround by calculating the proper offset
through the input transformation matrix. It isn't nice but fixes the
problem for now.

BUG: 374778

Test Plan: Only in unit test, real test still missing

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4074
2017-01-25 13:58:28 +01:00
Martin Gräßlin d38bce776f Add support for skip close animation to OnScreenMessage
Summary:
This change adds support for marking the OnScreenMessage as it should
skip close animation. The screenshot effect is adjusted to use the
on screen message instead of the custom effect frame.

Test Plan: Message window is not captured when taking screenshot

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4091
2017-01-25 13:54:34 +01:00
Martin Gräßlin 31405ae10f Merge branch 'Plasma/5.8' into Plasma/5.9 2017-01-25 13:40:02 +01:00
Martin Gräßlin 5a87fa3f92 Support modifier-only-shortcuts when capslock is on
Summary:
So far we didn't trigger modifier-only-shortcuts when capslock was
enabled. In fact we even ensured that the shortcuts did not trigger.
This seems not to be what our users expect. Meta should still trigger
if capslock is on.

This change modifies the logic to determine which modifier is currently
pressed by using the modifiersRelevantForGlobalShortcuts. The difference
to the "normal" modifiers is that this excludes capslock from modifiers
and excludes consumed modifiers. The latter is not really relevant as
modifier-only-shortcuts do not trigger if multiple keys are pressed,
which is required to have a modifier consumed.

BUG: 375355
FIXED-IN: 5.8.6

Test Plan: Only with adjusted autotest

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4241
2017-01-25 13:39:04 +01:00
Martin Gräßlin f55b606065 Merge branch 'Plasma/5.9' 2017-01-22 16:53:57 +01:00
Martin Gräßlin 6d9f7a6f17 Merge branch 'Plasma/5.8' into Plasma/5.9 2017-01-22 16:44:37 +01:00
Martin Gräßlin 0acfebd96b [autotests] Add test case for modifier only trigger when capslock enabled
This extends the testCapsLock to ensure that modifier only shortcut
trigger when capslock is enabled. So far the test only ensured that
capslock doesn't trigger the shift modifier only shortcut.

As the test shows currently when capslock is on, the meta key doesn't
trigger any more.

CCBUG: 375355
2017-01-22 09:42:00 +01:00
Martin Gräßlin 5dc942ac5e [autotests] Add test case for modifier only trigger when capslock enabled
This extends the testCapsLock to ensure that modifier only shortcut
trigger when capslock is enabled. So far the test only ensured that
capslock doesn't trigger the shift modifier only shortcut.

As the test shows currently when capslock is on, the meta key doesn't
trigger any more.

This test case goes into Plasma/5.9 branch and not in Plasma/5.8 as a
fix will most likely need the new xkbcommon 0.7 code paths which we do
not have in Plasma/5.8.

CCBUG: 375355
2017-01-21 20:13:09 +01:00
Martin Gräßlin f2f9aea11e [autotests] Fix LockScreenTest::testKeyboardShortcut
32f4e115e2 broke the test. To my
surprise there was a test using the kwin internal shortcut handling
instead of using KGlobalAccel.

This change adjusts the test to go through KGlobalAccel for testing
the global shortcut.
2017-01-18 20:24:17 +01:00
Martin Gräßlin 2904d4a0be Move X11 specific KGlobalAccel handling into the x11-standalone platform
Summary:
InputRedirection has a workaround to add a connect on a QAction which
is used for a global shortcut. This is specific to the X11 platform as
the xtime needs to be updated.

This change adds a new virtual method to the Platform and moves the
implementation into the X11 standalone platform. Thus it does no longer
gets called on Wayland.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D4168
2017-01-17 17:01:32 +01:00
Martin Gräßlin 00c68891c7 Add support for skipCloseAnimation for internal windows
Summary:
We need this to use the new OnScreenNotification in the screenshot
effect.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4089
2017-01-13 19:50:50 +01:00
Martin Gräßlin e616925fb0 [autotests/integration] Add test case for touch and decoration
The test for touch points is extended for decorated windows and as
the test shows the client pos offset is not considered correctly.

CCBUG: 374778
2017-01-10 19:27:42 +01:00
Martin Gräßlin 80adfd0274 Fade out OnScreenNotification when moving with the mouse over it
Summary:
This change triggers a fade out animation when the mouse is moved over
the OnScreenNotification, thus revealing the windows underneath. When
moving the mouse out of the OnScreenNotification it gets faded in again.

This is useful for various cases, e.g. when picking a color and the pixel
one wants to pick is underneath the notification, or when trying to kill
a window...

Test Plan: Manual testing in nested setup

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3964
2017-01-04 18:04:15 +01:00
Martin Gräßlin 6a78bd45fe Fix syncing of geometry to internal window when using ::move
Summary:
The OnScreenNotification gets moved during its placement. This update
of the geometry did not get synced to the QWindow's geometry as it
should.

The reason for this is the rather special implementation of
AbstractClient::move. This just modifies the geom variable and does not
call into setGeometry at all. Instead a virtual doMove method is invoked
to inform the platform specific client implementation about the move of
the window. For a "normal" ShellClient that is fine - there is nothing
to do.

This change adds an implementation of doMove in ShellClient to sync the
geometry to the internal window. This is not yet enough to fix the
geometry of the OnScreenNotification. It gets placed with a
GeometryUpdatesBlocker in place causing the doMove never to be called.
Instead setGeometry is invoked again when the geometry updates get
unblocked. So far ShellClient did not do anything in this case. This
change ensures that at least the doSetGeometry method is performed again.

Test Plan: Added test case and manual testing of OnScreenNotification

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3963
2017-01-04 18:00:24 +01:00
Martin Gräßlin 0a042dad69 Sync opacity from an internal QWindow to its ShellClient
Summary:
This change adds support for opacity on a KWin internal QWindow.
Calling QWindow::setOpacity syncs the value to the ShellClient
representation of the QWindow.

This is needed for fading out the OnScreenNotification on mouse
over.

Test Plan: Added auto test and manual test

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3928
2017-01-03 07:35:54 +01:00
Martin Gräßlin ab45659677 Add support for on-screen-message to kwineffects
Summary:
This adds support for the new on-screen-message support to the
kwineffects API and makes use of it in the colorpicker effect.

Not yet added to screenshot effect as for that we need support for
skip close animation on the on-screen-message window.

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3803
2016-12-24 09:56:48 +01:00
Martin Gräßlin 2c3bbb9783 [autotests] Disable QtQuick in OnScreenNotificationTest
Unfortunately Qt triggers an ASAN error in it's opengl implementation.
As we don't really need the visible output in the test, disable QML.
While this is unfortunate, it's better than a false-positive failing
test.

Output from build.kde.org:
18:15:51 =================================================================
18:15:51 ==13802==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x614000027640 in thread T0:
18:15:51   object passed to delete has wrong type:
18:15:51   size of the allocated type:   400 bytes;
18:15:51   size of the deallocated type: 16 bytes.
18:15:51     #0 0x7fc1632614b2 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9a4b2)
18:15:51     #1 0x7fc1624f947d in QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() opengl/qopenglversionfunctions.cpp:81
18:15:51     #2 0x7fc1621c1315 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172315)
18:15:51     #3 0x7fc1621c1365 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172365)
18:15:51     #4 0x7fc161701e93 in QScopedPointerDeleter<QObjectData>::cleanup(QObjectData*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Core.so.5+0x363e93)
18:15:51     #5 0x7fc1617002c0 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer() ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:107
18:15:51     #6 0x7fc1616f4d20 in QObject::~QObject() kernel/qobject.cpp:900
18:15:51     #7 0x7fc1621beabf in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:689
18:15:51     #8 0x7fc1621beaf3 in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:696
18:15:51     #9 0x7fc162df817d in QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow*) scenegraph/qsgrenderloop.cpp:323
18:15:51     #10 0x7fc162e3ed8f in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1237
18:15:51     #11 0x7fc151a105c1 in PlasmaQuick::Dialog::~Dialog() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x1235c1)
18:15:51     #12 0x7fc151f4bce4 in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162ce4)
18:15:51     #13 0x7fc151f4bd6d in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162d6d)
18:15:51     #14 0x41f82f in QScopedPointerDeleter<QObject>::cleanup(QObject*) /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:60
18:15:51     #15 0x41e7a1 in QScopedPointer<QObject, QScopedPointerDeleter<QObject> >::~QScopedPointer() /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:107
18:15:51     #16 0x41c6b0 in KWin::OnScreenNotification::~OnScreenNotification() /home/jenkins/sources/kwin/kf5-qt5/onscreennotification.cpp:55
18:15:51     #17 0x410349 in OnScreenNotificationTest::show() /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:42
18:15:51     #18 0x42095f in OnScreenNotificationTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/sources/kwin/kf5-qt5/build/autotests/moc_onscreennotificationtest.cpp:80
18:15:51     #19 0x7fc1616c3bda in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const kernel/qmetaobject.cpp:2222
18:15:51     #20 0x7fc1642f776c in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Test.so.5+0x1c76c)
18:15:51     #21 0x7fc1642f0820 in QTest::TestMethods::invokeTestOnData(int) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:800
18:15:51     #22 0x7fc1642f1353 in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:981
18:15:51     #23 0x7fc1642f25d6 in QTest::TestMethods::invokeTests(QObject*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1314
18:15:51     #24 0x7fc1642f31f7 in QTest::qExec(QObject*, int, char**) /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1724
18:15:51     #25 0x40f5e4 in main /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:31
18:15:51     #26 0x7fc160a5babf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
18:15:51     #27 0x40d118 in _start (/home/jenkins/sources/kwin/kf5-qt5/build/autotests/testOnScreenNotification+0x40d118)
18:15:51
18:15:51 0x614000027640 is located 0 bytes inside of 400-byte region [0x614000027640,0x6140000277d0)
18:15:51 allocated by thread T0 here:
18:15:51     #0 0x7fc1632608b2 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x998b2)
18:15:51     #1 0x7fc1624f9563 in QOpenGLVersionFunctionsStorage::backend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:108
18:15:51     #2 0x7fc1624f9b10 in QAbstractOpenGLFunctionsPrivate::functionsBackend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:122
18:15:51     #3 0x7fc16251475d in QOpenGLFunctions_1_0::initializeOpenGLFunctions() opengl/qopenglfunctions_1_0.cpp:100
18:15:51     #4 0x7fc1621bee83 in QOpenGLContext::versionFunctions(QOpenGLVersionProfile const&) const kernel/qopenglcontext.cpp:862
18:15:51     #5 0x7fc1621c1dbe in QOpenGLFunctions_1_0* QOpenGLContext::versionFunctions<QOpenGLFunctions_1_0>() const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172dbe)
18:15:51     #6 0x7fc1621be166 in QOpenGLContextPrivate::maxTextureSize() kernel/qopenglcontext.cpp:382
18:15:51     #7 0x7fc1624df66a in QOpenGLTextureGlyphCache::maxTextureHeight() const opengl/qopengltextureglyphcache.cpp:459
18:15:51     #8 0x7fc162467acf in QTextureGlyphCache::populate(QFontEngine*, int, unsigned int const*, QFixedPoint const*) painting/qtextureglyphcache.cpp:208
18:15:51     #9 0x7fc162dddcfa in QSGTextMaskMaterial::populate(QPointF const&, QVector<unsigned int> const&, QVector<QPointF> const&, QSGGeometry*, QRectF*, QPointF*, QMargins const&) scenegraph/qsgdefaultglyphnode_p.cpp:456
18:15:51     #10 0x7fc162ddbc2b in QSGDefaultGlyphNode::update() scenegraph/qsgdefaultglyphnode.cpp:127
18:15:51     #11 0x7fc162ea3fb9 in QQuickTextNode::addGlyphs(QPointF const&, QGlyphRun const&, QColor const&, QQuickText::TextStyle, QColor const&, QSGNode*) items/qquicktextnode.cpp:115
18:15:51     #12 0x7fc162eaa7f6 in QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode*, QQuickText::TextStyle, QColor const&) items/qquicktextnodeengine.cpp:777
18:15:51     #13 0x7fc162ea4baa in QQuickTextNode::addTextLayout(QPointF const&, QTextLayout*, QColor const&, QQuickText::TextStyle, QColor const&, QColor const&, QColor const&, QColor const&, int, int, int, int) items/qquicktextnode.cpp:265
18:15:51     #14 0x7fc162ea02f9 in QQuickText::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) items/qquicktext.cpp:2304
18:15:51     #15 0x7fc162e48a5f in QQuickWindowPrivate::updateDirtyNode(QQuickItem*) items/qquickwindow.cpp:3104
18:15:51     #16 0x7fc162e476a5 in QQuickWindowPrivate::updateDirtyNodes() items/qquickwindow.cpp:2849
18:15:51     #17 0x7fc162e3a8d2 in QQuickWindowPrivate::syncSceneGraph() items/qquickwindow.cpp:419
18:15:51     #18 0x7fc162df86bc in QSGGuiThreadRenderLoop::renderWindow(QQuickWindow*) scenegraph/qsgrenderloop.cpp:391
18:15:51     #19 0x7fc162df8c95 in QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow*) scenegraph/qsgrenderloop.cpp:442
18:15:51     #20 0x7fc162e39e45 in QQuickWindow::exposeEvent(QExposeEvent*) items/qquickwindow.cpp:216
18:15:51     #21 0x7fc16217600d in QWindow::event(QEvent*) kernel/qwindow.cpp:2105
18:15:51     #22 0x7fc162e3f69e in QQuickWindow::event(QEvent*) items/qquickwindow.cpp:1537
18:15:51     #23 0x7fc151a17911 in PlasmaQuick::Dialog::event(QEvent*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x12a911)
18:15:51     #24 0x7fc1616b69a7 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) kernel/qcoreapplication.cpp:1122
18:15:51     #25 0x7fc1616b65d1 in doNotify kernel/qcoreapplication.cpp:1063
18:15:51     #26 0x7fc1616b6535 in QCoreApplication::notify(QObject*, QEvent*) kernel/qcoreapplication.cpp:1049
18:15:51     #27 0x7fc1621623ef in QGuiApplication::notify(QObject*, QEvent*) kernel/qguiapplication.cpp:1648
18:15:51     #28 0x7fc1616b64b2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) kernel/qcoreapplication.cpp:988
18:15:51     #29 0x7fc16216ac69 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
18:15:51
18:15:51 SUMMARY: AddressSanitizer: new-delete-type-mismatch ??:0 operator delete(void*, unsigned long)
18:15:51 ==13802==HINT: if you don't care about these warnings you may set ASAN_OPTIONS=new_delete_type_mismatch=0
18:15:51 ==13802==ABORTING
2016-12-22 19:25:12 +01:00
Martin Gräßlin 2baaf327d4 [autotests] Disable OnScreenNotification in PointerConstraintsTest
Using QtQuick in test environment fails due to no OpenGL.
2016-12-22 19:05:47 +01:00
Martin Gräßlin 07c6878ff0 Introduce a KWin internal on-screen-notification service
Summary:
Recently we noticed that there are multiple areas where KWin needs to
inform the user about how to operate. Examples are:
* Screenshot
* ColorPicker
* Pointer constraint enabled
* Pointer constraint about to be removed
* Kill Window

For Screenshot and ColorPicker we used an EffectFrame to render it. But
this is not an optimal solution as it's lacking many features we would
need. We cannot properly use it from within KWin core, we cannot
implement features like hide on mouse over, etc. etc.

This change introduces an OnScreenNotification which supports:
* showing an icon
* showing a message
* timeout

It is Qml styled, so that it can be easily adjusted. This is a big
improvement over the EffectFrame solution. The Qml file creates a Plasma
Dialog of type OSD. Thus KWin places it like the normal OSD windows and
also looks kind of similar. In the case of KWin the focus is more on the
message, than an icon, so the icon is placed left of the text.

While the OnScreenNotification is supposed to be used like a singleton,
it doesn't use the KWin singleton pattern. Instead a small wrapper
namespace OSD is introduced which provides a convenient API for KWin
internal areas to show/hide the notification. By not using the KWin
singleton pattern, the OnScreenNotification does not depend on any other
parts of KWin and can be easily unit-tested.

A few features are still missing and will be added in further commits:
* hide-out on mouse over
* optional skip close animation (needed for screenshot)
* X11 support (not that important as it's mostly for Wayland features)

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3723
2016-12-21 19:43:49 +01:00
Martin Gräßlin 6383f83047 Place OSD windows again on size changes
Summary:
The position of an OSD is based on the size of the window. If the
size of the OSD changed, it would not be positioned correctly any more.

With this change the OSD window gets placed again if the size changes.
Thus it's also placed correctly even if the window changed it's size.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3720
2016-12-21 19:24:57 +01:00
Martin Gräßlin eae9bdd50a [autotests/integration] Use socketpair for Wayland connection
Summary:
This is a preparation step for no longer creating a socket in the tests
and slightly simplifies the init test code.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3575
2016-12-15 21:31:27 +01:00
Martin Gräßlin 0c5ca405cc Implement support for pointer constraints
Summary:
There are two types of constraints supported:
1. Pointer confinement
2. Pointer locking

In the case of confinement the pointer is confined to a given region of
the surface. This is comparable to general operation where the pointer
is confined to the screen region.

In the second case the pointer gets locked. That means it cannot move at
all. No further position updates are provided, only relative motion
events can go to the application. There is a hint about cursor position
update on unlock which is not yet implemented in KWayland::Server, thus
also not in this change.

The implementation in KWin grants the requests for pointer constraints
when the pointer enters the constrained region, either by pointer
movement or by e.g. stacking order changes. There is no confirmation
from user required to enter that mode. But we want to show an OSD when
the pointer gets constrained, this is not yet implemented, though.

Breaking an active constraint is relatively easy. E.g. changing the
stacking order will break the constraint if another surface is under the
cursor. Also (in case of confinement) moving the pointer to an
overlapping window breaks the confinement. But as soon as one moves the
pointer back to the window a constraint might get honoured again.

To properly break there is a dedicated event filter. It listens for a
long press of the Escape key. If hold for 3sec the pointer constraint is
broken and not activated again till the pointer got moved out of the
window. Afterward when moving in the pointer might activate again.

The escape filter ensures that the key press is forwarded to the
application if it's a short press or if another key gets pressed during
the three seconds. If the three seconds way fires, the later escape
release is not sent to the application.

This basic interaction is also ensured through an added auto test.

This change implements T4605.

Test Plan: Added auto test and nested KWin Wayland with D3488

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3506
2016-12-08 19:50:24 +01:00
Roman Gilg fd07b1dc98 [libinput] Change unset of scroll method and acceleration profile
Go for a more intuitive unset behaviour of scroll method and acceleration
profile properties.

Summary:
Unsetting a scroll method should only work, if the scroll method is currently
active. For example when scroll-two-finger is active (i.e. scroll-edge,
scroll-on-button-down is not active):
* unsetting scroll-two-finger should deactivate it and activate no-scroll
* but unsetting for example scroll-edge should _not_ deactivate scroll-two-
  finger and _not_ activate no-scroll

Reworked setting scroll method auto test in order to test it.

Regarding acceleration profiles: Unsetting one, should always switch to the
other possible one as long as both are supported. In this case
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE is not a valid option in contrast to the
definition of the scroll method enums.

Reviewers: #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3590
2016-12-06 13:45:54 +01:00
Roman Gilg 7f16d83e04 [libinput] Add more support for pointer devices, in particular touchpads
This patch is made in preparation for the Touchpad KCM for Wayland.

Summary:
* KWin has a Libinput version requirement bump to 1.5
* new isTouchpad property to distinguish touchpads from mice
* new lmrTapButtonMap property
* new disableWhileTyping property
* new pointerAccelerationProfile property
* new defaultPointerAcceleration property
* save to config mechanism added for new propertys and pointerAcceleration
* new D-Bus interface org.kde.KWin.InputDeviceManager and method devicesSysNames
* removed unnecessary additional D-Bus service name org.kde.KWin.InputDevice
* changing acceleration in the Mouse KCM doesn't influence touchpads anymore

Reviewers: #kwin, #plasma, davidedmundson

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3479
2016-12-02 14:58:56 +01:00
Martin Gräßlin f32e655031 Implement borderlessMaximizedWindows for Wayland windows
Summary:
Maximize code was not yet adjusted to support decorations. Code is as
much as possible similar to the X11 Client implementation.

BUG: 370982

Test Plan: Added auto test and run a nested KWin/Wayland with the setting enabled

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3508
2016-11-29 12:36:31 +01:00
Martin Gräßlin 9934f5b575 Properly implement maximize of ShellClient
Summary:
This brings some more checks from Client to ShellClient. Thus the
states are better adjusted.

Unfortunately the X11 implementation is also slightly adjusted, so could
create regressions in worst case.

BUG: 368393

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3507
2016-11-29 12:35:59 +01:00
Martin Gräßlin 2cc55e4077 [effects] Add a colorpicker effect
Summary:
The effect exports itself to DBus as object "/ColorPicker" and provides
an own interface "org.kde.kwin.ColorPicker".

It has one exported method to DBus "pick" which returns a QColor. When
invoked an interactive position picking selection is started. If it ends
the effect reads the color value at the picked position from the OpenGL
color buffer.

This implements T4568.

Reviewers: #kwin, #plasma_on_wayland, broulik

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3480
2016-11-25 09:30:34 +01:00
Martin Gräßlin ce7a9476f9 [autotests] Wait longer in LockScreenTest
It timed out on build.kde.org, so let's try to wait longer.
2016-11-25 07:56:24 +01:00
Martin Gräßlin f9f7b84cb4 Add interactive position selection to screenshot screen under cursor
Summary:
A second interactive selection mode gets added to select a position on
the screen. This is handled by the same input event filter as for the
window selection. Just that instead of returning a window, it returns a
QPoint.

This allows to pick a point on the screen which we need to screenshot
the screen under the mouse cursor and in future for color picking.

The screenshot effect provides two new dbus methods to (interactively)
select a screen or fullscreen. This allows spectacle to screenshot the
(full) screen with still having the user in control.

Reviewers: #kwin, #plasma_on_wayland, bgupta

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3475
2016-11-25 07:38:37 +01:00
Martin Gräßlin 0b47b84816 Ignore non-relevant modifiers when evaluating mouse actions
Summary:
E.g. CapsLock should not prevent Alt+left click move.

BUG: 372809

Reviewers: #kwin, #plasma_on_wayland, broulik

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3467
2016-11-25 07:37:58 +01:00
Roman Gilg 87150816c7 [libinput] Rework device config writing and save enum of ScrollMode as integer
This is a larger patch rewriting some parts of the config saving functionality
in device.cpp in order to:

1. Make it possible to save ScrollMode as integer instead of using three booleans
2. Simplify the addition of new keys or types in the future

Changes in detail:
a) Adds new ConfigKey ScrollMethod and removed now unnecessary keys per method
b) Adds constructors to the ConfigData struct. This allows to create ConfigData
   entries for s_configData without the need of stating empty brackets and the
   useage of default values.
c) Use plain member function pointers instead of std::function, in order to
   compactify code and have better compile output in case something goes wrong.
c) Cleans up ScrollMethod functions and adds interface methods for transforming
   the saved integer into type enum libinput_config_scroll_method.
d) Adjusts auto test for loading the ScrollMethod value from the config file.

Reviewers: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3460
2016-11-22 19:18:15 +01:00
Roman Gilg ad0647688a [libinput] Query defaultLeftHanded, save leftHanded, fix ScrollMode config
Some small improvements / fixes to the libinput backend:
- Query libinput_device_config_left_handed_get_default
- Write leftHanded property to config file
- When saving the touchpad scroll mode, write false to all other ones.
  Otherwise it will always enable the last read entry after reboot.
- Use macro for setLeftHanded(bool) and setNaturalScroll(bool)

Reviewers: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3430
2016-11-22 14:49:01 +01:00
Martin Gräßlin 451bbb54dd [effects] Handle windowShown and windowHidden in fade effect
Summary:
For Wayland windows we can have a sequence of window unmapped
(windowHidden signal) followed by a windowClosed way later when the
application quits. This is for example the case with menus.

The result of this was that the fade out animation triggered when the
application quit showing all the already closed menus again.

This change implements a windowShown and windowHidden handler and
triggers the fadeIn/Out animation on it. If the window gets shown
again the existing fadeOut animation gets cancelled, so that it can run
again.

If a window gets closed for which a fade out animation has been run
already, it's not triggered again, thus ensuring that we don't see
zombie windows.

CCBUG: 372622

Reviewers: #kwin, #plasma_on_wayland, hein

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3419
2016-11-22 07:18:27 +01:00
Martin Gräßlin 2619ddf02e Merge branch 'Plasma/5.8' 2016-11-18 16:08:29 +01:00
Martin Gräßlin 16c7650d76 Fix AbstractClient::sizeForClientSize
Summary:
The method is supposed to return the AbstractClient's size for a given
client size. That is the size including the window decoration.

The default implementation returned the passed in client size without
adjusting for the decoration. This resulted in ShellClient getting a
wrong size especially when AbstractClient::adjustedClientSize (which
calls sizeForClientSize) was called.

The result of the incorrect size was for example a shrinking of the
window when starting to resize a window.

BUG: 370345
FIXED-IN: 5.8.4

Reviewers: #kwin, #plasma_on_wayland, broulik, subdiff

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3414
2016-11-18 12:36:08 +01:00
Martin Gräßlin 6bee7f4aac KillWindow support for Wayland windows
Summary:
AbstractClient gains a new pure virtual killWindow method and this gets
implemented in ShellClient.

ShellClient performs the killing by sending a term signal to the
process. This can only work if the client connected through the socket
and didn't get a socketpair fd passed. In that case the pid is KWin's
and KWin doesn't want to terminate. Thus this is special handled to
destroy the connection instead.

In case terminating the process has no effect, the connection gets
destroyed after five seconds.

The KillWindow is adjusted to operate on AbstractClient instead of
Client.

This implements T4463.

Test Plan: Killed windows and auto test

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3370
2016-11-17 14:06:42 +01:00
Martin Gräßlin 27376e39ef [effects] Add interactive window selection mode to ScreenshotEffect
Summary:
EffectsHandler gains a new method to startInteractiveWindowSelection
which just delegates to the one in Platform. That way a window can be
selected and returned to an Effect.

The screenshot effect makes use of this new functionality and provides
an interactive window screenshot mode which saves to a temporary file.
Note that this is not yet the variant intended for use in spectacle.

Test Plan: Took a screenshot on Wayland

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3367
2016-11-17 14:06:01 +01:00
Martin Gräßlin fd83366e31 Implement interactive window selection for Wayland platforms
Summary:
The interactive window selection is implemented in InputRedirection
through a dedicated InputEventFilter. The InputEventFilter so far takes
care of pointer input and keyboard input. In addition it ensures that
keyboard and pointer focus is reset on start and on end.

With this change KillWindow now also works on Wayland, but only for X11
windows, as the Wayland variant is not yet implemented.

Test Plan: Tested in nested setup, auto-tests still needed

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3365
2016-11-17 09:42:12 +01:00
Martin Gräßlin 346619aa36 Remove KWin::display from kwinglobals
Summary:
And finally nothing inside libkwineffects, libkwinglutils,
libkwinxrenderutils and kwineffect and kwin core uses KWin::display.
We are finally XLib free!

This change drops KWin::display and removes the include to QX11Info from
kwinglobals.h. And the libraries no longer need to link X11Extras.  Due
to that removal a few seeming unrelated changes are required to add the
include where needed and linkage to X11Extras.

The biggest change is to x11 platform plugin which still needs the
display and caches it in the Platform and passes it to various places in
a way that the code doesn't need to be adjusted.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3337
2016-11-16 18:00:00 +01:00
Martin Gräßlin 6184278bec Fix for failing testScriptedEffectsLoader
By changing the loading of scripted effect config to interact with
kwinApp we broke the tests which do not use a kwinApp.

This change turns the access to the KSharedConfigPtr go through the
property system, so that the tests can also install a dummy
KSharedConfigPtr. With that scripted effects loader test passes and no
longer crashes and the integration/effects tests also still pass.
2016-11-16 16:53:17 +01:00
Martin Gräßlin af83401b83 Use KWin's KSharedConfigPtr in ScriptedEffect
Summary:
So far ScriptedEffect used EffectsHandler::effectConfig to get the
KConfigGroup for the ScriptedEffect. This has the disadvantage that the
config file name is hardcoded to kwinrc in EffectsHandler::effectConfig.

Inside KWin a KSharedConfigPtr is used which can point to somwhere else
than kwinrc. If that was the case the ScriptedEffects were not able to
pick up this customized config and instead continued to read values from
kwinrc.

With this change the ScriptedEffects use the KSharedConfigPtr provided
by KWin. Thus in e.g. autotests we can use the general way to configure
the effects and don't need to write to the config.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3383
2016-11-16 15:31:14 +01:00
Martin Gräßlin 4783e45ab7 [libkwineffects] Remove EffectsHandler::registerPropertyType
Summary:
There is no effect using this method. As it's X11 specific it should be
removed.

Internally the EffectsHandlerImpl still requires the method. Thus it's
moved into the private part.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3297
2016-11-16 09:06:12 +01:00
Martin Gräßlin 9f976a4b8d Support multiple event types in X11EventFilter
Summary:
So far the X11EventFilter only supported one event type. But most
usecases for an X11EventFilter require to support multiple event types.
E.g. a filter listens for both key press and key release.

This change extends the internal X11EventFilter to support multiple
types and Workspace::workspaceEvent makes use of that.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3361
2016-11-16 07:48:19 +01:00
Martin Gräßlin 3041b871ea [libkwineffects] Delete EffectsHandler::deleteRootProperty
Summary:
The method is not used by any Effect and is X11 specific, thus better
remove it for good.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3298
2016-11-16 07:46:27 +01:00
Martin Gräßlin c0b2e5dc8b VirtualDesktopGrid operates on VirtualDesktop objects
Summary:
The VirtualDesktopGrid is ported to the new VirtualDesktop objects. The
grid consists now of QVector<VirtualDesktop*> rows and a QVector of
those rows.

This change requires to adjust the code using the VirtualDesktopGrid.
This mostly affects VirtualDesktopManger. The methods for toLeft, above,
next, etc are now all operating on VirtualDesktop with the uint variants
- if still present - only delegating to the new method. The Functor
objects are also adjusted, though mostly still providing the old API for
compatibility.

In KWin core only one now ambiguous call is adjusted (useractions) and
the desktop grid usage in EffectsHandlerImpl is adjusted. Other usages
are not yet adjusted and need porting to fully get rid of the old
uint-based API.

Test Plan: VD test still passes

Reviewers: #kwin, #plasma_on_wayland, hein

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3327
2016-11-15 07:20:23 +01:00
Martin Gräßlin 002d667436 Merge branch 'Plasma/5.8' 2016-11-07 13:46:13 +01:00
Martin Gräßlin de89176cd2 [libinput] Load/store device configuration
Summary:
Device gets a KConfigGroup injected and supports loading device-specific
settings. This is invoked from Libinput::Connection when adding a new
Device.

Whenever a Device option is changed successfully through the DBus
interface it gets synced into the KConfigGroup, thus on next loading of
the Device it gets restored.

The config group follows a pattern of:
[libinput][vendor][product][name]

Thus every device has a specific and persistent configuration.

Test Plan: So far only tested through autotests

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3264
2016-11-07 13:45:48 +01:00
Martin Gräßlin fb69b791a1 Ensure that all Effects honour the grab roles correctly
Summary:
When windows get added some effects grab the window and want to be the
only one animating this window. For this the grab roles exists. An
effect being notified later on evaluates the grab state and does not
start the animation.

This process failed due to being dependent on the order the effects are
loaded. Window Added/Closed are signals emitted by EffectsHandler, thus
first come, first serve. The requested effect order does not play into
it.

Due to that it could happen that an Effect which should not animate,
started to animate as the grab was still there.

This change adds the possibility to be notified whenever the window data
changes. A new signal is added to EffectsHandler which is emitted
whenever the windowData changes. The interested effects connect to it
and cancel their (just started) animation for the window.

Adjusted effects are:
* ScaleIn
* Fade
* WobblyWindows

In case of WobblyWindows an additional logical error was fixed that the
animations were only run when an effect grabbed instead of the other way
around.

BUG: 336866
FIXED-IN: 5.8.4

Reviewers: #kwin, #plasma, broulik

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3211
2016-11-07 11:45:09 +01:00
Martin Gräßlin d9612b327c Merge branch 'Plasma/5.8' 2016-11-07 11:41:30 +01:00
Martin Gräßlin ee7da425ce Unpolish QStyle on QApp prior to destroying internal Wayland connection
Summary:
The QStyle might interact with our internal Wayland connection. If the
cleanup happens after destroying our internal Wayland connection KWin
will crash at tear-down.

With this change the QStyle can perform cleanup already prior to the
deconstruction of the Wayland connection.

CCBUG: 372001

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3241
2016-11-07 11:28:06 +01:00
Martin Gräßlin 2a15592571 Simplify the window title passed in from the window system
Summary:
So far KWin used the window title provided from the window directly
without any sanitizing. This could result in broken window decorations
if the title included line breaks. Those were passed to the decoration
and depending on the way how the decoration renders the title, it could
result in visual breakage.

Having line breaks in a window title doesn't make sense. Given that KWin
now simplifies the title when copying it to it's own structure. This
also ensures that the title passed to e.g. task manager does not have
any line breaks on Wayland.

BUG: 323798
FIXED-IN: 5.8.4

Test Plan: Opened the web page in a nested KWin, properly rendered now.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3215
2016-11-07 11:26:48 +01:00
Martin Gräßlin f17d06ee7d Merge branch 'Plasma/5.8' 2016-11-04 10:03:10 +01:00
Martin Gräßlin db58c421eb Internal windows cannot be minimized
Summary:
This change ensures that the DebugConsole does not have a minimize
button.

BUG: 372000
FIXED-IN: 5.8.4

Reviewers: #kwin, #plasma_on_wayland, broulik

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3244
2016-11-04 08:59:43 +01:00
Martin Gräßlin fb4b0c40ef [autotests/libinput] Extend the Device test
Added tests for new functionality:
* scroll enabled by default properties
* scroll supported properties
* scroll on button down
2016-11-04 08:58:09 +01:00
Martin Gräßlin f1d17c1a56 [autotests/libinput] Extend device test for scrol methods
Covers the variants for scroll method.
2016-11-03 17:51:32 +01:00
Martin Gräßlin e9dfdbe6a8 [autotests/libinput] Extend Device test case
Tests the new functionality for:
* natural scroll
* middle emulation
2016-11-03 17:22:31 +01:00
David Strobach e4283543f6 [libinput] Add scroll method configuration support
Wraps libinput
libinput_device_config_scroll_get_methods
libinput_device_config_scroll_get_default_method
libinput_device_config_scroll_set_method
libinput_device_config_scroll_get_method
libinput_device_config_scroll_set_button
libinput_device_config_scroll_get_button
libinput_device_config_scroll_get_default_button

Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3194
BUG: 371803
FIXED-IN: 5.8.4
2016-11-03 14:03:17 +01:00
David Strobach b19341777a [libinput] Add natural scrolling support
Wraps libinput
libinput_device_config_has_natural_scroll
libinput_device_config_set_natural_scroll_enabled
libinput_device_config_get_natural_scroll_enabled
libinput_device_config_scroll_get_default_natural_scroll_enabled

Differential Revision: https://phabricator.kde.org/D3193
BUG: 371791
FIXED-IN: 5.8.4
2016-11-03 14:02:27 +01:00