Commit graph

1853 commits

Author SHA1 Message Date
Xaver Hugl
eaf7e9a3a2 core/colorspace: be more robust about edge cases
xyz -> xy and xy -> xyz conversions have divisions in them, so we need to
handle the edge cases of the divisor being zero. This can happen if an ICC
profile is invalid, or if the XYZ color space is used.
2024-08-23 10:45:46 +00:00
David Edmundson
99f2cd2f51 Revert "wayland: Revert send pointer leave on drag"
Now we have server-side cursor icons, we can send the pointer leave.

This reverts commit 9302e84b95.
2024-08-23 09:42:05 +00:00
Vlad Zahorodnii
4258797402 Port Workspace::cascadeOffset() away from Window::frameGeometry()
Workspace::cascadeOffset() can be called by placement code before the
frame geometry has a valid position. That is wrong. In order to avoid
that, use the placement area that we are given.
2024-08-23 09:01:56 +00:00
Xaver Hugl
d0c4aeeb08 options: enable separate screen focus by default
When the user closes the active window, with separate screen focus disabled, a
window on the other screen might get activated, which also switches the active
screen to the other one. As this is quite unintuitive, and in my testing having
separate screen focus enabled didn't have any other unintuitive side effects,
this commit enables separate screen focus by default
2024-08-23 00:33:01 +02:00
Vlad Zahorodnii
36c447a35a autotests: Add X11 stack tests 2024-08-20 12:42:49 +00:00
Xaver Hugl
f9e6ecd298 core/colorpipeline: improve optimization with differing reference luminances
This is done by
- fixing isFuzzyScalingOnly to not check the [3, 3] component, which is always 1
- making the comparison between transfer functions fuzzy, so small floating point
  errors don't prevent two practically identical functions to be optimized out
- switching manual optimizations to use addMatrix instead, which removes the
  matrix or replaces it with a multiplier

and the autotest is expanded to test transformations between color descriptions with
transfer functions and reference luminances that are just scaled versions of each
other
2024-08-19 16:39:11 +02:00
Xaver Hugl
e2c7cf2bb3 autotest/colorspaces: test identity transformations with bpc 2024-08-19 16:38:54 +02:00
David Redondo
9e2326d3ac Generate wayland code with PRIVATE_CODE 2024-08-15 14:16:11 +00:00
Xaver Hugl
aa93f6ac55 autotests/colorspaces: add some test cases for black point compensation 2024-08-15 01:23:00 +00:00
Xaver Hugl
6f79597f13 core/colorspace: match default luminances with the Wayland protocol
It wasn't feasible to do it before, because it made SDR black far too bright, but
with black point compensation the result looks as users expect it
2024-08-15 01:23:00 +00:00
Xaver Hugl
6b3f211ef7 wayland: remove workaround for xdg-dialog base name with wayland-protocols <= 1.35
We require 1.36 now, so the workaround is no longer necessary
2024-08-14 14:50:14 +02:00
Xaver Hugl
370c9c8953 window: make setQuickTileMode more sane
...by removing the keyboard flag, moving keyboard shortcut handling into a separate
method and making the position to tile the window at explicit

This also means KWin doesn't do as many intermediary changes to window geometry on output
hotplugs, which may work around some clients not always reacting to no-op changes.

CCBUG: 479694
2024-08-14 11:38:07 +00:00
Vlad Zahorodnii
298486d47a wayland: Pass private-code to waylandscanner
The main goal is to avoid leaking our private xyz_interface objects.
2024-08-13 19:59:11 +00:00
Xaver Hugl
2a5716e782 effects/animationeffect: port to stl containers
We need to attach non-copyable data to animations, and Qt containers don't work for that
2024-08-12 12:13:31 +00:00
Xaver Hugl
18f1092728 scene/item: add ItemEffect
Right now it's just a helper to mark items as being affected by some effect,
to prevent direct scanout of the relevant item without needing to block direct
scanout for the whole screen
2024-08-12 12:13:31 +00:00
Xaver Hugl
418143a45b core/colorspace: move Colorimetry::toOther to ColorDescription
With some rendering intents we need to apply behavior based on brightness levels
or the SDR colorimetry
2024-08-12 11:46:32 +00:00
Xaver Hugl
833476a111 core/colorspace: add rendering intents
Rendering intents describe how to handle mapping between different colorspaces,
what to do with out of gamut values and what to do if the whitepoint doesn't match.
This way, clients can choose which behavior their content should get.
2024-08-12 11:46:32 +00:00
Xaver Hugl
6bd07ad6b3 backends/drm: remove the shadow buffer when possible, and reduce it to 10bpc when not
Using the custom values for min. and max. luminance in transfer functions, we can reduce the
ranges of values in the shadow buffer to be limited to [0, 1], and with that we can switch
from a floating point buffer back to a normalized format. As gamma 2.2 encoding is much more
efficient at storing color values, this also drops the buffer from 16bpc down to 10bpc.

Furthermore, this offloads the gamma 2.2 -> PQ conversion to KMS when possible, and then uses
the scanout buffer with gamma 2.2 encoding directly. This way the shadow buffer gets completely
skipped and performance and efficiency get improved a lot.

BUG: 491452
CCBUG: 477223
2024-08-09 15:18:43 +02:00
Xaver Hugl
2cbf4543fa autotests: add very basic color pipeline test
It just tests rec.709 <-> rec.2020 at 0%, 50% and 100% rec.709 luminance, to have
a very simple indicator for when something's gone really wrong while working on
color pipeline changes
2024-08-09 15:10:45 +02:00
Xaver Hugl
bea4d1064c core: add transfer function minimum and maximum luminance values
This redefines the transfer functions to have a custom luminance at encoded
value zero, and a custom luminance at encoded value 1, neither of which are
tied to the reference luminance, even for relative transfer functions.

The goal of that is that we can use a gamma 2.2 transfer function for the shadow
buffer, with the reference luminance being much lower than the maximum luminance.
For example, on an HDR screen you might have the reference luminance of 600 nits,
while the maximum luminance is 1000 nits. By representing this in gamma 2.2, we
can use a much smaller amount of bits per color to store the values than if we
used a linear transfer function. An additional benefit is that this way the values
in the buffer can be scaled by arbitrary amounts, for example to limit the range of
values to [0, 1], which can be represented in a normalized buffer
2024-08-09 15:10:45 +02:00
Vlad Zahorodnii
68a621f95a utils: Rename KXcursorTheme to CursorTheme
The KXcursorTheme type no longer with Xcursor only cursors, so rename it
to maintain more reasonable naming conventions.
2024-08-07 11:57:39 +03:00
David Redondo
31018c000b wayland: Check serial instead of focus for changing selections
Clients can have valid reasons to change the selection when the
same user action that also caused the selection request
to lose keyboard focus. This is notbaly the case for menus
created from a Plasma panel which itself will not take focus
but when clicking on action it only triggers after the menu
is closed.
This also matches what weston and sway do.
BUG:490803
2024-08-06 12:54:00 +00:00
Xaver Hugl
ab8f05a57f activation: fix X11 windows being stuck in should_get_focus more properly
amends d01e20b6a9, and adds an autotest for the bug
2024-08-05 23:25:53 +02:00
Yifan Zhu
1240ac1dfe plugins/buttonrebinds: correctly handle level 1 keys
Level 1 keys (e.g., !=Shift+1) need to have shift added.

BUG: 484367
2024-08-05 16:37:32 +00:00
David Edmundson
8fd4476ff1 wayland: Move XWayland key forwarding into a filter
We optionally send some keys to xwayland through the filter when no x11
client has focus. This allows shortcut handling in X11 apps to work.

When kwin is grabbing keys we don't necessarily want X11 to sniff these
keys as things can get out of sync. A key place is the tabbox. The X11
client sill has focus, but xwayland is not active. This means we pass
tab keys to X which then go to application incorrectly.

Part of this patch changes the tabbox filter to not intercept the alt
key release event. This ensures xwayland's concept of pressed modifiers
stays in sync.

BUG: 484992
2024-08-02 09:31:40 +00:00
David Edmundson
6675eccf6d inputmethod: Send pre-defined commit message to client on user interaction
In some IM backends pre-edit text should be submitted on user interaction, in some it should be discarded. 

In TextInputV1 and V2 this was a flag sent to the client along with
the commit string ahead of time.

TextInputV3 does not have a flag for this, so we handle it compositor side.

We flush the text to be committed :
 - when we change keyboard focus, before the current client gets wl_keyboard.leave
 
 - when a mouse is pressed in the relevant surface
 
 - when a key is pressed and the InputMethod doesn't have a grab
 
 - when the InputMethod forwards a key to the client
 (which includes the InputMethod passing on grabbed keys)
2024-08-02 09:07:46 +00:00
Vlad Zahorodnii
1e9b961761 tabbox: Reset keyboard focus when grabbing input
When the tabbox grabs input, the key events won't be sent to the client.
It's not good for a couple of reasons: first, it can fool the client into
repeating a previously pressed key; and the server side and the client
side can be out of sync after the task switcher is dismissed.

In order to handle that properly, this change makes the tabbox reset the
keyboard focus when it's shown or hidden. When the task switcher is
dismissed, an enter event will be sent with the current state of the pressed
keys.

Ideally, the same needs to be done with the pointer focus but it's
challenging to achieve with the current input pipeline design. An input
grab abstraction is needed to handle pointer focus when the task switcher
is active.
2024-08-02 06:10:15 +00:00
Xaver Hugl
e351d9dca1 backends/libinput: don't apply pointer acceleration to touchpad gestures
It's unexpected that increasing pointer "speed" would also change the distance
required to activate gestures
2024-08-01 09:52:12 +00:00
Joshua Goins
34c2a36000 ButtonRebindsFilter: Support keyboard modifiers with mouse buttons
This is needed to better support emitting mouse button events when
pressing tablet buttons. It's common in many art programs that an action
is tied to a mouse button + a modifier, such as panning the canvas. So
being able to send keyboard modifiers in tandem with mouse buttons is
very useful when rebinding.

Tests are added for this new feature.

CCBUG: 469232
2024-07-29 15:46:44 +00:00
Nicolas Fella
e3ad1fa04f plugins/stickykeys: Disable when two keys are pressed
BUG: 464453
2024-07-25 14:22:17 +02:00
David Edmundson
374d859493 xwayland: Only update keyboard modifers for XWayland's keys
KeyboardInterface is a multiplexer, it has a global state to kwin
that forwards events the single focussed window.

XWayland also forwards events to clients, but uses the keyboard interface.
It has some overloads that take a specific client, this was used for key events
but not modifiers.

The end result was not only that XWayland could miss a modifier update, but
also that wayland clients would get modifier updates out of order.
Key events must come first.

BUG: 490270
2024-07-24 15:57:21 +00:00
Xaver Hugl
b0a8294b05 autotests: test placement to always put the titlebar on the screen
CCBUG: 489500
2024-07-23 16:16:25 +02:00
Vlad Zahorodnii
02fbeeae78 Make Workspace::desktopResized() reassign outputs of uninitialized windows
If an output is deleted, the Workspace::desktopResized() is going to
re-assign windows to the new outputs. It is done so so the workspace
re-arrangement procedure is deterministic and has concrete order.

However, with the current Window lifecycle management, it's possible
to encounter the follwing case:

- xdg_toplevel gets created on output A
- xdg_toplevel initial state is committed
- output A is removed
- a wl_buffer is attached to the xdg_toplevel, which results in a
  geometry change and an output change
- Window::setMoveResizeOutput() is called, but the previous output
  is a dangling pointer

CCBUG: 489632
2024-07-23 13:46:06 +00:00
Joshua Goins
59699402ad ButtonRebindsFilter: Set cursor position when rebinding tablet events
Since the tablet cursor and the mouse cursor is tracked separately,
rebinding a tablet button to a mouse click is sort of wonky. For
example, if you assign it to Right Click and attempt to open a context
menu it will appear to open in the wrong place.

So before we send the mouse button event, set the mouse position to
the tablet cursor position. A test is added to ensure this functionality
works as intended and doesn't regress.
2024-07-23 01:36:33 +00:00
Joshua Goins
fd670453e5 ButtonRebindsFilter: Modify testBindingTabletTool to use proximity
This is to not destroy the tablet state for the next test (which is
added in the next commit.) We could also explicitly do a tablet tool
up/down dance here, but all we need is the tablet tool to be in
proximity for the tablet button event to fire.
2024-07-23 01:36:33 +00:00
Joshua Goins
abc6dae6df ButtonsRebindFilter: Add tests for the tablet binding types
This adds autotests for binding to tablet pad and tool buttons, which
was previously untested. Of note is that we don't explicitly test mouse
buttons, which is already tested in the other functions.
2024-07-22 20:39:19 -04:00
Joshua Goins
b89f85f46d Add testing infrastructure for virtual tablet pad and tools
This is for the ButtonRebindFilter tests, but this could be useful
in other places too.
2024-07-23 00:38:36 +00:00
Joshua Goins
0ea1bcfe89 ButtonRebindsFilter: Add test for disabled bindings
This was missed when it was first implemented, but now there's tests for
checking if bindings can be disabled in the buttons rebind plugin.
2024-07-23 00:38:36 +00:00
Joshua Goins
47a538e61c ButtonRebindsFilter: Add test for mouse button binding
This was missed when it was first implemented, but now there's tests for
checking the mouse binding functionality in the buttons rebind plugin.
2024-07-23 00:38:36 +00:00
Vlad Zahorodnii
53b61ce5d7 autotests: Fix a race condition in X11WindowTest
NETWinInfo queries the window state and setState() will do nothing if the
proposed new state matches the cached server side state.

On the other hand, given how the test is structured, there can be pending
fullscreen changes on the kwin side that are yet to be sent to the X server
when the NETWinInfo object is created.

This change fixes that race condition by adding an explicit Xcb::sync().
2024-07-18 12:17:18 +00:00
Vlad Zahorodnii
ddfb26fc8e utils: Provide size hints in native pixels
This is mainly to make the Xcb utils api consistent.
2024-07-18 13:39:11 +03:00
Nicolas Fella
19bf66c42a plugins/stickykeys: Unlatch modifiers when locking
The state should be either latched or locked, not both
2024-07-17 13:13:40 +02:00
Nicolas Fella
85b5048e72 Test locking sticky keys for all modifiers 2024-07-17 10:58:49 +00:00
Nicolas Fella
65405c128e Release key in sticky key test
Otherwise it's pressed the whole time, breaking subsequent tests
2024-07-17 10:58:49 +00:00
Nicolas Fella
6f750f0aa5 Fix typo in comments 2024-07-16 16:08:14 +02:00
Vlad Zahorodnii
7575de4b02 Port Window::updateInteractiveMoveResize() away from input()->keyboardModifiers()
Since 12c12b3af1, input()->keyboardModifiers()
doesn't work on X. Modifiers need to be pulled from input events.
2024-07-15 15:08:11 +00:00
Vlad Zahorodnii
09e0345ccc wayland: Dismiss XdgPopupWindow when the parent window is closed
XdgPopupWindow can't exist on its own.

BUG: 472013
2024-07-15 07:41:43 +00:00
Xaver Hugl
de8bd8f126 plugins/fadingpopups: don't block direct scanout
The effect only modifies the opacity of individual windows that
WorkspaceScene::scanoutCandidate will reject anyways, so there's no reason
for it to block direct scanout.
Once a more proper solution for blocking direct scanout on individual items
is in place, this can be removed again

BUG: 487780
2024-07-11 16:54:25 +02:00
Vlad Zahorodnii
abd790c4b5 autotests: Skip testScreencasting in CI
pipewire 1.2 has a known regression where the client's process callback
will not be triggered if the producer has sent only one buffer.

The issue has already been fixed upstream
525360d70a

Until our CI picks up that change, temporarily disable the test to unblock
merging patches.
2024-07-11 09:34:34 +00:00
Nicolas Fella
e14e4a1f8e Fix comment in test
The intent is that the key is *not* locked
2024-07-10 09:35:31 +00:00