Commit Graph

656 Commits (c99d329125ac745d4c764c5262a8010e9b565fde)

Author SHA1 Message Date
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