Commit graph

159 commits

Author SHA1 Message Date
Arjen Hiemstra
a4fe17653f Remove alignment requirements from data in vertex/index buffers
We now rely on auto-vectorisation to generate the appropriate SSE or
other instruction set code. We can also assume that takes care of
handling any alignment requirements and thus remove the need for manual
alignment things.
2022-07-13 09:25:12 +00:00
Arjen Hiemstra
5287422f46 Add unroll hint to inner loop in WindowQuads::makeInterleavedArrays
The inner loop here has a fixed size and unrolling it allows better
vectorization. Both GCC and clang recognise the `#pragma GCC unroll`
directive.
2022-07-13 09:25:12 +00:00
Arjen Hiemstra
a95b556868 Drop custom SSE code from WindowQuads::makeInterleavedArrays
Both GCC and Clang do auto vecrization these days and testing shows that
that actually produces faster code, so dropping the SSE stuff makes
things both simpler and faster.
2022-07-13 09:25:12 +00:00
Alexander Lohnau
e96b9ba499 Improve docs for creating KWin effects
- use kcoreaddons_add_plugin CMake macro, the other one is KWin internal
- reference embedded json metadata in section about macros
- Provide codesnippet to json metadata
- Do not explicitly define plugin id in metadata, instead we can derive it from the library name
2022-07-10 10:05:55 +00:00
Vlad Zahorodnii
fa78de6219 kwineffects: Strip ScreenPaintData of transforms
ScreenPaintData provides a way to transform the painted screen, e.g.
scale or translate. From API point of view, it's great. It allows
fullscreen effects to transform the workspace in various ways.

On the other hand, such effects end up fighting the default scene
painting algorithm. For example, just have a look at the slide effect!
With fullscreen effects, it's better to leave to them the decision how
the screen should be painted. For example, such approach is taken in
some wayland compositors, e.g. wayfire, and our qtquick effects already
operate in similar fashion.

Given that, strip the ScreenPaintData of all available transforms. The
main motivation behind this change is to improve encapsulation of item
painting code and simplify model-view-projection code in kwin. It will
also make the job of extracting item code for sharing purposes easier.
2022-07-06 11:10:54 +00:00
Marco Martin
56d3b2ddc4 Set all timestamps for all touch events
in order for qml pointerhandlers to work correctly, they need
timestamps in all events (to decide for instance when to emit a
tapped or doubletapped)

BUG:456133
2022-07-01 12:13:18 +00:00
Alexander Lohnau
1ee1e011a3 Bump KWIn effects API version after changes to smart pointers in public API
BUG: 456155
2022-06-30 20:25:14 +00:00
Xaver Hugl
84acb768ee effects: modernize some code
Mostly port away from manual memory management and clean up some headers
2022-06-29 10:34:50 +00:00
Vlad Zahorodnii
24dfdd70c0 effects: Drop WindowPaintData::modelViewMatrix()
It's unused and it conflicts in a way with PaintData::translation(),
PaintData::rotationAngle() and PaintData::scale().
2022-06-29 09:50:43 +00:00
Marco Martin
66a54d38d4 effects: Set timestamp for input events
Set the time for mouse and touch events. This is especially important
for the mouse is as the timestamp will be used to discriminate between
single and double click. Previously this was always sending the double
click event, making buttons work only every other click.

BUG: 454275
BUG: 449907
2022-06-24 17:54:55 +00:00
Marco Martin
66d1278794 Internal tracking for quick effect item focus
focus used to be always forced to the root item of the view in the
"active screen" (which behavior is configurable between mouse poosition
and screen of active window)
now set focus to that particular view only if nothing is focused, also when
the user explicitly sets focus to an item in another view
remove focus to the old one so the item properly focused would be there

BUG:455807
BUG:455783
CCBUG:455633
2022-06-24 15:56:08 +00:00
Vlad Zahorodnii
f9c20bb83e Rename DeformEffect to OffscreenEffect
Originally, DeformEffect was meant to be used in effect that deform
windows, but its usage has become wider than anticipated. This change
renames the DeformEffect to OffscreenEffect to accommodate for that.
2022-06-13 07:06:09 +00:00
Marco Martin
3d0beae828 Drag windows between screens in WindowHeap
Allow dragging windows between screens, using a placeholder thumbnail item to
render part of the thumbnail on the other screen.

BUG: 283333
BUG: 453996
BUG: 448566
2022-06-06 13:48:59 +00:00
Xaver Hugl
4874066423 port many Qt shared pointers to standard smart pointers
There are a few benefits to using smart pointers from the standard library:
- std::unique_ptr has move semantics. With move semantics, transfer of ownership
can be properly expressed
- std::shared_ptr is more efficient than QSharedPointer
- more developers are used to them, making contributions for newcomers easier

We're also already using a mix of both; because Qt shared pointers provide
no benefits, porting to standard smart pointers improves consistency in
the code base. Because of that, this commit ports most of the uses of QSharedPointer
to std::shared_ptr, and some uses of QScopedPointer to std::unique_ptr
2022-06-04 16:57:29 +00:00
David Edmundson
bc4d1cf129 [libkwineffects] Fix minor compiler warnings 2022-05-30 19:37:24 +01:00
Luca Carlon
da0dd1e367 Support new AppletPopup window type
See the discussion in https://invent.kde.org/frameworks/plasma-framework/-/merge_requests/500.

BUG: 411462
BUG: 332512
FIXED-IN: 5.25
2022-05-27 21:49:37 +00:00
Vlad Zahorodnii
97a82c97df effects: Fix QQuickItem::mapToGlobal() in qtquick effects on wayland
On Wayland, we create a dummy window to fix HiDPI issues. At the moment,
the QQuickRenderControl::renderWindow() returns a fixed offset 0,0.

As it turns out, QQuickItem::mapToGlobal() will poke the
QQuickRenderControl::renderWindow() function to map the specified point
to the global coordinate space.

Since the renderWindow() function returns hardcoded offset, the
mapToGlobal() function is sort of broken in fullscreen effects.

In order to fix mapToGlobal() on Wayland, this change makes the
EffectQuickRenderControl return the position of the associated
OffscreenQuickView.
2022-05-27 15:43:00 +00:00
Vlad Zahorodnii
f3b291bce0 Make TimeLine API ergonomic with presentation timestamps
Currently, if you want to use TimeLine, you need to track the last
presentation timestamp which boils down to carrying some boilerplate
code.

The current situation can be improved by making TimeLine work with
presentation timestamps.

Part-of: <https://invent.kde.org/plasma/kwin/-/merge_requests/2473>
2022-05-26 17:10:07 +00:00
Kai Uwe Broulik
a2c91f9434 backends/x11: Cleanup KWinXRenderUtils and move it to eglx11common
The XRender backend has been removed, leaving most of KWinXRenderUtils unused.

The few features that are still used, notable `XRenderPicture` and pict format
are moved into the x11/common directory.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2022-05-19 12:10:18 +00:00
Xaver Hugl
0b27ce4d34 Make touchscreen gestures realtime 2022-05-11 15:08:43 +00:00
Vlad Zahorodnii
ea1fadfe8d Remove Window::addRepaint() and Window::addLayerRepaint()
Conceptually, scheduling repainting in Window doesn't belong there. This
change rewires EffectWindow internals so it schedules repaints using the
associated WindowItem.

Window::addWorkspaceRepaint() has not been removed yet because
Window::elevate() uses it.
2022-05-11 15:13:45 +03:00
Vlad Zahorodnii
63a866d98c Make WindowItem handle opacity
This change makes the WindowItem track the opacity and schedule a
repaint. It further decouples the legacy scene from code window
abstractions.

It's an API breaking change. WindowPaintData no longer can make windows
more opaque. It only provides additional opacity factor.
2022-05-11 09:42:35 +00:00
Vlad Zahorodnii
313baa4b51 Remove QAction include in AnimationEffect
It builds fine without QAction include.

BUG: 453609
2022-05-10 10:14:11 +00:00
Vlad Zahorodnii
2983727871 effects: Make DeformEffect disable clipping if specified region is infinite
The Scene no longer clips window quads if the specified paint region is
infinite. The infinite region is defined as (INT_MIN/2, INT_MIN/2,
INT_MAX, INT_MAX). If you try to scale the infinite region, you will
easily hit integer overflow.

This change makes the DeformEffect disable geometry clipping if the given
paint region is infinite region in order to avoid hitting integer
overflow.
2022-05-10 07:56:43 +00:00
Kai Uwe Broulik
9cb5b38970 effects: Port EffectFrame to OffscreenQuickView
This allows to toss a large amount of custom rendering code.

Furthermore, it removes the build-time dependency on Plasma Framework
for FrameSvg and Theme from KWin core as it's pulled in through QML
imports now.

It also cleans up the API and removes functions that are effectively
unused or no-op after this change.

For instance, effects often destroy their effect frames
in pre/postPaintScreen, which would now destroy an `OffscreenQuickView`,
which changes GL context. This is alleviated by delaying detruction
of the internal view.

Support for the features of text cross-fade and selection frame,
which are not used by any of the built-in effects, is dropped.

Signed-off-by: Eike Hein <eike.hein@mbition.io>
2022-05-09 17:53:58 +00:00
Vlad Zahorodnii
683a222233 Drop lanczos filter
The lanczos filter depends on the effect system. It makes very difficult
changing painting code from SceneWindow to Item.

Given that the last big users of the laczos filter - present windows and
desktop grid effects were re-written in QML. The only remaining user of
the lanczos filter is the thumbnail aside effect. Given that it's a
really obscure usecase, switching to the linear filter won't be very
noticeable.

As a backup plan, one can reimplement the thumbnailaside effect using
QML. The lanczos filter is already implemented in plasma-framework.
2022-05-09 08:31:13 +00:00
Marco Martin
7a4cabf328 QML version of the Desktop Grid effect
Replace completely the old desktop grid effect with a QML version.
Aims to feature parity and be a change as transparent as possible for the user.

BUG: 433071
BUG: 452625
BUG: 443971
BUG: 437121
BUG: 452925
BUG: 437928
BUG: 452439
BUG: 288530
BUG: 450254
BUG: 450106
BUG: 447832
BUG: 449960
BUG: 416576
BUG: 441862
BUG: 444859
BUG: 445999
BUG: 422117
BUG: 404627
BUG: 435483
BUG: 420744
BUG: 435482
BUG: 427055
BUG: 333445
BUG: 429120
BUG: 427391
BUG: 409295
BUG: 294322
BUG: 356955
FIXED-IN: 5.25
2022-05-06 10:44:38 +00:00
Vlad Zahorodnii
def99b1a7c Update WindowItem's visibility
With this, the WindowItem will know whether it's actually visible. As
the result, if a native wayland window has been minimized, kwin won't
try to schedule a new frame if just a frame callback has been committed.

EffectWindow::enablePainting() and EffectWindow::disablePainting() act
as a stone in the shoe. They have the final say whether the given window
is visible and they are invoked too late in the rendering process.
WindowItem needs to know whether the window is visible in advance,
before compositing starts.

This change replaces EffectWindow::enablePainting() and
EffectWindow::disablePainting() with EffectWindow::refVisible() and
EffectWindow::unrefVisible(). If an effect calls the refVisible()
function, the window will be kept visible regardless of its state. It
should be called when a window is minimized or closed, etc. If an effect
doesn't want to paint a window, it should not call effects->paintWindow().

EffectWindow::refVisible() doesn't replace EffectWindow::refWindow() but
supplements it. refVisible() only ensures that a window will be kept
visible while refWindow() ensures that the window won't be destroyed
until the effect is done with it.
2022-05-05 12:21:26 +00:00
Vlad Zahorodnii
30076f297c effects: Introduce a helper for referencing deleted windows
If an effect is reloaded while it holds deleted references, it's
possible that the closed windows will get stuck in the "zombie" state.

This change introduces EffectWindowDeletedRef helper that can be
used to keep the closed window alive as long as the reference is valid.
2022-05-05 12:21:26 +00:00
Martin Flöser
47b330ea23 [libkwineffects] Add support for shaders in AnimationEffect
The animate and set calls are extended for an optional GLShader* to
allow specifying a custom shader to use during the animation.

To properly support rendering a complete window in the effect the
AnimationEffect gets based on the DeformEffect. If a shader is used
during the animation the window gets redirected.

For the animation with shaders two new enum values are added to the
AnimationType enum:
 * Shader
 * ShaderUniform

The Shader animation type is for specifying that the animation uses a
shader. During the animation a uniform "animationProgress" is set on the
shader.

The ShaderUniform animation type behaves exactly like the Shader type,
but also animates a user provided uniform. The meta data of the
animation is interpreted as a uniform location for a float uniform and
during the animation this uniform is updated with the interpolated
animation data.
2022-05-04 15:19:47 +00:00
Martin Flöser
7dddf3055b [libkwineffects] Support custom shaders in DeformEffect
For a redirected window a custom shader can be specified to draw the
redirected texture to screen. This is useful for inheriting effects to
customize the rendering.

Two new int uniforms TextureWidth and TextureHeight are added and set
from DeformEffect when rendering the texture.
2022-05-04 15:19:47 +00:00
Marco Martin
4cb3ab09ed Realtime screen edges gestures for scripted effects
Possibility to implement realtime screenedges gestures in scripted effects,
implement it in the windowsaperture show desktop effect.
* Expose registerRealtimeScreenEdge to JavaScript, the callback will be
a JS function.
* Add the concept of freezeInTime() in the animation js bindings,
it will either create an animation frozen at a given time or freeze a running animation
that can be restored and ran to completition at any time
* add an edges property only for showdesktop as it's not directly on the effect configuration
2022-05-03 13:43:38 +00:00
Nils Fenner
b491aeb9ae Rename AbstractClient to Window 2022-04-22 17:39:12 +00:00
Nils Fenner
aaa429ee0a Merge Toplevel into AbstractClient
References issue #81
2022-04-18 07:42:11 +00:00
Eric Edlund
26a4f75944 Implement desktopSwitching() interface for realtime animations
Added this interface to the VirtualDesktopManager. Realtime touchpad gestures update the interface to allow for mac os style desktop switching.
Also makes gestured switching use natural direction.

BUG: 185710
2022-04-15 00:09:52 +00:00
Vlad Zahorodnii
2ac1f9b7d3 kwineffects: Expose internalId 2022-04-13 19:06:11 +00:00
Vlad Zahorodnii
992753c24a Rename GLRenderTarget to GLFramebuffer
GLRenderTarget doesn't provide a generic abstraction for framebuffer
objects, so let's call GLRenderTarget what it is - a framebuffer.

Renaming the GLRenderTarget class allows us to use the term "render
target" which abstracts fbos or shm images without creating confusion.
2022-04-12 13:41:19 +03:00
Gustavo Silvera
41526bd8dd effects/showfps: add new options
- added option to remove the frametime graph
- added option to remove the "this is a benchmark" message
- location of the fps counter is now on the "active" monitor by default
- removed the hard-limit of 100 for the FPS counter
- added option to color the text based off the FPS value
2022-04-04 16:05:56 +00:00
David Edmundson
9de9b93325 Add new blend effect
When changing global settings like switching between light and dark
themes the result is currently quite messy. Apps update in a scattered
order and a jarring change.

The solution is heavily inspired from Gnome, we cache the window for X
milliseconds, then perform a crossfade between the cache and current
contents.

It does mean any video is paused for half a second, but pragmatically
it's not really bothersome.

On receipt of an explicit DBus method call we create a cache and start
animating. The explicit method call is needed so that we can guarantee
kwin has a fully copy before a client might change.

Use of an offscreen texture is used so that we include any window
decorations. The DeformEffect effect is repurposed as it has most the
relevnat logic if we remove the live updating.
2022-04-04 13:40:41 +00:00
Volker Krause
95505eb044 Adapt to OpenGL related Qt6 QQuickWindow API changes 2022-03-28 14:57:27 +00:00
Vlad Zahorodnii
e293972eaa Run clang-tidy with -checks=readability-braces-around-statements fixit
This fixes style issues in old code.
2022-03-28 10:54:11 +00:00
Kai Uwe Broulik
0d223742ab kwineffects: Add OffscreenQuickScene::setSource with initial properties
Signed-off-by: Eike Hein <eike.hein@mbition.io>
2022-03-28 09:47:48 +00:00
Xaver Hugl
8914a6c50e add global touchscreen gestures
Swipe with three fingers
- left to switch to the previous virtual desktop
- right to switch to the next virtual desktop
- up and down to toggle the overview

CCBUG: 439925
2022-03-27 19:09:04 +02:00
Vlad Zahorodnii
7096e3ead8 Run clang-format
The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
2022-03-25 13:25:15 +02:00
Volker Krause
2a171e5fa8 Adapt build system to also support building against Qt6 2022-03-25 08:26:49 +00:00
Volker Krause
8feeda5c86 Adapt touch event code to Qt6 API changes
This is uglier with Qt6, as the setter methods for touch points are only
available as private API now.
2022-03-23 16:15:09 +00:00
Marco Martin
2b6f8a3141 support realtime activation for screen edges gestures
support realtime activation for screenedges gestures, making it possible
for effects to show half-triggered states while dragging from
the edge with a finger, making them much more usable
2022-03-22 20:28:02 +05:30
Vlad Zahorodnii
6ea8463ce6 kwineffects: Rename WindowPrePaintData::clip to opaque
"opaque" is more readable than "clip" and it precisely communicates
what that region actually is.
2022-03-21 09:32:41 +02:00
Vlad Zahorodnii
3c945358fc Revert "Implement desktopSwitching() interface for realtime animations"
This reverts commit c7c1ac78ea.

This change was merged prematurely.
2022-03-19 18:30:41 +02:00
Eric Edlund
c7c1ac78ea Implement desktopSwitching() interface for realtime animations
Added this interface to the VirtualDesktopManager. Realtime touchpad gestures update the interface to allow for mac os style desktop switching.
2022-03-19 13:19:54 +00:00