Commit graph

1611 commits

Author SHA1 Message Date
Xaver Hugl
1c18d11206 backends/drm: replace drmModeAtomicCommit with a custom implementation
drmModeAtomicCommit does additional allocations and sorting that KWin doesn't
use or need
2023-08-30 10:46:58 +00:00
Vlad Zahorodnii
dee8a3b3a7 Clear decoration focus when window closes
If the window closes, we need to reset the focused decoration object.

BUG: 473244
2023-08-30 09:28:03 +00:00
David Edmundson
10ed34bc9d Avoid painting unchanged scene layers
Currently when we move the mouse the one render loop triggers a repaint.
When the cursor layer needs a new update we end up in the compositor
repainting the main content.

Even though painting should mostly no-op it still goes through all
existing items and effects to collect damage, still potentially making
the GL context current which could stall. A waste when we know we
haven't got anything to do. It's enough to cause noticable mouse lag on
some hardware.

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-08-28 11:38:18 +00:00
Alexander Lohnau
40be656eed Adjust to changed signature of kcoreaddons_target_static_plugins
Depends on https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/360
2023-08-27 12:09:56 +02:00
Vlad Zahorodnii
d25574e7c6 Merge Window::userCanSetFullscreen() with Window::isFullscreenable() 2023-08-24 07:29:02 +00:00
Vlad Zahorodnii
346d4413a1 Remove boolean trap in Window::setFullScreen()
In most cases, it doesn't matter because a window is made fullscreen by
user. In a few places, the user arg is incorrectly set to false.
2023-08-24 07:29:02 +00:00
Xaver Hugl
44937136cd backends: record GPU render time
This should make it much less likely for KWin to miss frames
2023-08-23 10:51:19 +00:00
Xaver Hugl
02b996cf9c platformsupport/scenes/opengl: add opengl render query class 2023-08-23 10:51:19 +00:00
Xaver Hugl
0ab928c9ac backends/libinput: enable tap to click and tap-and-drag by default 2023-08-22 14:17:23 +00:00
Kai Uwe Broulik
410ca44e6e XdgPopupWindow: Reposition for non-reactive positioners
Ensures that e.g. context menus move about with their parents when they
get moved around.

However, as per spec don't re-constrain the window when its positioner
is non-reactive. This change calculates the offset from its parent window
once initially and places the window relative to that whenever the parent
moves.

Only when the positioner is reactive, will it recalculate the placement fully.

BUG: 461994
2023-08-21 11:17:18 +00:00
Xaver Hugl
74f10d0cdf port most uses of the reset(new ...) pattern to std::make_unique 2023-08-11 15:58:15 +02:00
Antonio Russo
5502ce9a9c placeSmart: Properly track width and height
`Placements::placeSmart` searches for an optimal position for windows, attempting to minimize overlap.  The core of this algorithm tracks the
client's height and width in `ch` and `cw`, which have been adjusted by -1. This simplifies logic determining the bottom and right points of a
window when you are starting at the top and left points.

However, this decision requires adjusting that number by +1 when doing the opposite: determining the top and left points when you start with
the bottom and right points.

placeSmart cycles through window locations, searching for acceptable nooks and crannies to fit a window in, nicely.  It begins by checking
for places to put the top left corner of the window which abut another constraint.  If that fails, it then tries to place the bottom right
abutting a constraining feature.

After finding a suitable bottom (or right) location, the top (or left) location must be determined, requiring the -1 adjustment to be undone.

This patch adds that +1 back in.

# The bug it solves

This error can be seen by opening a bunch of windows that are placed using the "Minimal Overlapping" rule.  The open space on the screen will be tiled from left to right, and then top to bottom in the windows.  Once no more windows can be placed like that, the next window will be placed at the extreme bottom-right corner.  However, it will be one pixel too low and one pixel too far to the right---if you try to move the window, it will "snap" to the correct spot.

This single pixel may seem minor or even irrelevant, but when you use the "Present Windows" desktop effect on a multiple-monitor setup, this one pixel will cause the window to show up on both monitors.
2023-08-07 07:14:18 +00:00
Xaver Hugl
7d02bc17d6 backends/drm: rework how atomic commits are tracked
Pending buffers for drm planes and crtcs are no longer tracked in the planes
and crtcs themselves, but instead in a DrmCommit object that is used as
the user data for the pageflip handler. This way multiple commits can be
pending at the same time without causing conflicts, and the handling of
pending buffers is simplified as well.
2023-07-27 12:30:19 +02:00
Xaver Hugl
87444f6ce3 backends/drm: offload atomic commits to a separate thread
This separate thread submits commits as late as possible, so that until
immediately before vblank the cursor position can still be updated, reducing
its latency and opening the door for more optimizations.
2023-07-26 13:44:36 +02:00
Laurent Montel
b823747c3b Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-15 08:40:49 +00:00
Vlad Zahorodnii
6cd56d5192 wayland: Implement cursor-shape-v1
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/194
2023-07-12 11:22:11 +03:00
Laurent Montel
86c6238cfa Don't use QtTest => use QTest + missing include 2023-07-04 10:38:21 +00:00
Aleix Pol Gonzalez
49a76ea772 Install KWaylandServer headers
There are use cases for the headers to be used, e.g. when implementing
wayland-specific workflows from an Effect.
In order to be able to use these, we also need to expose libkwin to be
imported as it carries the interfaces' symbols.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2023-07-04 08:22:43 +00:00
Vlad Zahorodnii
88ade3a409 Extract reusable egl swapchain bits
EGL rendering has some duplicated bits, so this change extracts
them to reduce code duplication.
2023-07-01 12:22:28 +00:00
Vlad Zahorodnii
3bd5e91226 Extract reusable qpainter swapchain bits
QPainter rendering has some duplicated bits, so this change extracts
them to reduce code duplication.
2023-07-01 12:22:28 +00:00
Vlad Zahorodnii
16cc0f5ebb autotests: Make test framework a static lib again
Static plugins being linked with shared libraries doesn't work smoothly.
POSITION_INDEPENDENT_CODE target property needs to be set for
every such plugin. However, there can be targets that we have no control
over, which need POSITION_INDEPENDENT_CODE to be set too. Asking such
projects to add this property and them refusing to do so would be
reasonable because kwin's entire static plugin pipeline is weird.

The test framework was made a shared library because kwin build
directory used to get really big (in 10s of gigabytes).

Due to the -fPIC issues, this change makes the test framework a static
lib again. Obviously, this brings back the big build directory problem.
But, it's not as terrible as it used to be. With this change, kwin build
directory is a couple of gigabytes in debug build, which is a lot but
not as bad as it used to be before.
2023-06-23 08:01:03 +00:00
Vlad Zahorodnii
3698127bc6 Drop InputConfig
The InputConfig was introduced to handle tests that don't have valid
kwinApp object. Those tests have been either reworked or dropped, so
let's drop the InputConfig to tidy the config stuff.
2023-06-21 10:48:50 +00:00
Vlad Zahorodnii
84c7d3cf4b autotests: Remove cursor.cpp from test framework sources
It's included because of InputConfig, but we don't need to include
cursor.cpp for this purpose.
2023-06-21 10:48:50 +00:00
Xaver Hugl
480f857d29 outputconfigurationstore: don't handle laptop lid closing yet
Interactions with KScreen cause settings to be reset to the default when the lid
gets closed, so handling lid closing in KWin needs to wait until KScreen no longer
writes configs

BUG: 471282
2023-06-21 11:05:42 +02:00
Vlad Zahorodnii
d6a384627b autotests: Let drm test use host primary node to allocate buffers 2023-06-19 22:43:01 +03:00
Vlad Zahorodnii
082301920e backends/drm: Port to GraphicsBuffer
This change ports the drm backend to the GraphicsBuffer and
GraphicsBufferAllocator.

The main motivation is to unify graphics buffer abstractions across
various backends and to prepare it for output layers, which could be
nicer if we could have direct control over the buffers.
2023-06-19 22:42:58 +03:00
Vlad Zahorodnii
712fd3396c Sync EffectsHandler::windowAdded with Workspace::windowAdded
This change makes the EffectsHandler emit the windowAdded signal as soon
as the Workspace::windowAdded signal is received and minimize the
difference between the states observed in kwin core and effects.
2023-06-16 06:41:12 +00:00
Vlad Zahorodnii
23f533aa52 autotests: Skip ScreencastingTest::testOutputCasting when running in ci
The test is flaky. We work around it by passing --repeat until-pass, but
lately even it doesn't help us with this issue.

So skip the test when running it inside KDE CI for a few months until
it gets a newer kernel.
2023-06-14 11:01:03 +00:00
Aleix Pol
fbbaab3eaf kcm/decoration: Allow specifying the kcm separately from the decoration
It makes decorations lighter as they don't need to bundle its
configuration logic.
Deprecates the kcmodule property in favour of kcmoduleName which instead
of assuming that the kcm is local to the plugin, it provides the plugin
name to find and load.
2023-06-13 12:20:21 +02:00
Vlad Zahorodnii
b90ae2f8fc Move window hiding logic to Window
The window hiding logic is mostly the same both in X11 and Wayland
windows, so let's move it in Window to share the same code.
2023-06-06 13:58:44 +00:00
David Edmundson
3ea701743e screen edge: Emit cleanup signals if needed on teardown
The Effects API has one signal screenEdgeApproaching with effects
monitoring the last signal to stay in sync.

If an Edge is destroyed whilst visible, effects currently do not get
notified and it can stay there forever.

This patch emits screenEdgeApproaching if appropriate with a factor of 0
when an edge is destroyed.

BUG: 403354
2023-05-25 09:59:00 +00:00
Vlad Zahorodnii
ebf6bd3a33 autotests: Move plasmashell bits from testMoveResizeWindow to testPlasmaSurface
Move the plasmashell specific bits to testPlasmaSurface so it's all
encapsulated and easy to drop in the future.
2023-05-23 18:00:50 +00:00
Vlad Zahorodnii
1c87a804f0 autotests: Port testShowingDesktop to layer-shell 2023-05-23 18:00:50 +00:00
Vlad Zahorodnii
05695d7f1b autotests: Avoid binding plasmashell global in tests that don't use it 2023-05-23 18:00:50 +00:00
Vlad Zahorodnii
2aba3deca4 wayland: Drop screen edge support in XdgToplevelWindow
Use kde_screen_edge_v1 + layer surface instead.
2023-05-23 13:02:14 +00:00
Vlad Zahorodnii
cdb8887a15 wayland: Drop strut support in XdgToplevelWindow
Use layer_surface.set_exclusive_zone instead.
2023-05-23 13:02:14 +00:00
Vlad Zahorodnii
9d0bb1bff7 autotests: Remove incorrect test
StrutsTest::testLeftScreenSmallerBottomAligned() used to pass because
one of the previous tests changes the maximize policy to maximize.

A window will be maximized only if it's larger than the maximize area
but smaller than the screen area. That's not the case and the test makes
an incorrect assumption about how X11Windows are placed.
2023-05-23 13:02:14 +00:00
Vlad Zahorodnii
6b2f46ca1f autotests: Remove unused outputbackend.h includes 2023-05-23 11:42:32 +03:00
Vlad Zahorodnii
cab0765947 autotests: Use layer-shell based panels 2023-05-23 10:48:31 +03:00
Vlad Zahorodnii
83261fc82a wayland: Implement kde-screen-edge-v1
It's needed to port the plasma panel to the layer shell protocol.
2023-05-19 13:36:38 +00:00
Ismael Asensio
2449b58974 tiles: Adjust padding between windows
Make the total padding between windows equal to the padding against the
screen borders by applying just half of it on the common borders.

Adjust tests accordingly.

BUG: 469720
FIXED-IN: 5.27.6
2023-05-17 23:18:59 +02:00
Aleix Pol
d6b07b313f libkwineffects: Stop including xcb/xcb.h everywhere
Provide a kwinxcb.h header file instead that offers the xcb-specific bits
from that API. It helps keep kwin effects disconnected from XCB.
2023-05-15 18:59:46 +00:00
Vlad Zahorodnii
223b01f9e7 wayland: Reevaluate layer shell window layer
Currently, if the layer shell surface's layer changes, the Window's
layer is not synchronized with it.
2023-05-15 08:32:37 +00:00
Xaver Hugl
8229573e63 autotests/drm: add a test for doing modesets
And fix an issue preventing it from working
2023-05-10 16:29:54 +00:00
Vlad Zahorodnii
dbce106031 wayland: Grab the contents of cursor scene 2023-05-10 15:40:59 +03:00
Vlad Zahorodnii
3d5b5844d0 Drop Cursor::image()
Use CursorSource::image() instead.

Cursor caching in the ScreenCastStream has been changed so
QImage::cacheKey() is not being used. This is rather a preparation for
making kwin grab the contents of the cursor scene.
2023-05-10 11:56:20 +00:00
Xaver Hugl
f60bcfb646 handle laptop lid closing in KWin
Instead of KScreen turning the display off, do that in KWin directly
2023-05-09 15:18:33 +00:00
Xaver Hugl
6e9d5c2cc3 autotests: directly call setVirtualOutputs 2023-05-09 15:18:33 +00:00
Vlad Zahorodnii
1d1ccc3770 autotests: Rework _KDE_NET_WM_SCREEN_EDGE_SHOW test 2023-05-09 08:16:53 +00:00
Vlad Zahorodnii
e6b5cf283e core: Batch pointer input device events
This change introduces InputDevice::pointerFrame(). The main motivation
behind it is to allow batching multiple pointer events within a single
event frame.

BUG: 454428
2023-05-05 10:27:08 +00:00