Commit graph

20231 commits

Author SHA1 Message Date
Vlad Zahorodnii
b90975b7a2 Replace AbstractClient::adjustedSize() with a simpler alternative
Currently, adjustedSize() does two things - it computes and constrains
the natural size of the window.

In many places where adjustedSize() is used, the natural size doesn't
need to be constrained and in some it's actually undesired because
AbstractClient::constrainClientSize() doesn't allow the client size to
be 0x0, which can happen when dealing with a client that has no buffer
committed yet.

This change replaces adjustedSize() with implicitSize(), which simply
calculates the natural frame size based on the current client size.

If the frame size needs to be constrained, for example during
interactive move-resize, use constrainFrameSize() or if you need to
constrain the client size - constrainClientSize().
2021-10-15 17:16:11 +00:00
Vlad Zahorodnii
a195290600 Simplify AbstractClient::applyWindowRules()
Trying to reconstrain the geometry after applying rules is unnecessary
because if the geometry is forced using a rule, resizeWithChecks()
should not change it; if the window is maximized or has entered fullscreen
mode, window gravity is irrelevant. If the window is shaded, this
resizeWithChecks() is not needed.

This change simplifies AbstractClient::applyWindowRules(), which allows
to split adjustedSize() to further simplify geometry handling.
2021-10-15 17:16:11 +00:00
Aleix Pol
3e77907d21 inputmethod: Use touch events to decide if the panel is shown not the state
Prefer hiding/showing the panel (i.e. the window) when not a touch event
than stopping to make the inputmethod active.
This way we remain compatible with non-virtualkeyboard inputmethods.
2021-10-15 15:41:35 +00:00
Xaver Hugl
5b9deafa14 InputMethod: only activate virtual keyboard when used with touch 2021-10-15 15:41:35 +00:00
Vlad Zahorodnii
f1e99e971f scripting: Guard against nullptr m_client in WindowThumbnailItem
BUG: 443765
2021-10-15 07:59:55 +00:00
Vlad Zahorodnii
59a4a908f9 Properly update parent item's bounding rect when moving item
The bounding rect of an item is in the item-local coordinate space. If
the item is moved, its bounding rect won't change, but the parent's
bounding rect, may change.

BUG: 443756
2021-10-15 10:30:49 +03:00
Vlad Zahorodnii
ff3465a80e Fix AbstractClient::adjustedSize() for wayland windows with no committed buffer
AbstractClient::constrainClientSize() forces the minimum client size of
1x1.

If AbstractClient::adjustedSize() is called before the XdgToplevelClient
is mapped, it will return 1x1 rather than 0x0 as expected, which will
confuse

    QSize s = adjustedSize();
    if (s != size() && s.isValid())
        resizeWithChecks(s);

in AbstractClient::applyWindowRules(). Since 1x1 is different from 0x0,
the xdg-toplevel surface is going to be resized to 1x1.

BUG: 443705
2021-10-15 05:38:54 +00:00
Vlad Zahorodnii
d4dd370cf3 autotests: Fix ASAN issues
Currently, InputRedirection is not destroyed before waylandServer(),
unlike in kwin_wayland, which causes some null dereferencing.
2021-10-14 22:03:39 +03:00
Vlad Zahorodnii
b4a4e8a45d Drop WaylandServer::terminateClientConnections()
Display will destroy all client connections before getting destroyed.
2021-10-14 10:02:50 +00:00
Vlad Zahorodnii
e550480c43 Rework input method teardown logic
Explicitly destroy input method rather than wait for the input method
connection to be destroyed by WaylandServer, it's less error prone.

BUG: 443603
2021-10-14 10:02:50 +00:00
Vlad Zahorodnii
4f46da46fc wayland: Move relative pointer extension instantiation to WaylandServer
Whether relative pointers are supported doesn't depend on the input
backend. This change moves the instantiation of the extension to the
WaylandServer class to make code more consistent.
2021-10-14 06:41:01 +00:00
Aleix Pol
3da0725404 Fix build
We forgot to remove the subdirectory when moving builtin plugins into
separate targets.
2021-10-14 02:44:29 +02:00
Vlad Zahorodnii
6b015d1e6e libinput: Drop mm position in Connection::pointerMotionAbsolute()
The position in millimeters is unused and it can't be applied to virtual
input devices.
2021-10-13 20:52:45 +03:00
Vlad Zahorodnii
bf620fbe04 Move Xkb::LEDs enum to KWin namespace
With the LEDs enum being defined in kwinglobals.h, wayland_server.h
won't need to include keyboard_input.h, which is good for compilation
times and wayland_server.h will drag less stuff, e.g. QtWidgets (input.h
includes QAction)
2021-10-13 17:49:19 +00:00
Vlad Zahorodnii
9cdd363fa1 effects: Pass full name to kwin4_add_effect
This way, it's more clear what target name is.
2021-10-13 17:05:06 +00:00
Vlad Zahorodnii
10b56bd43d effects: Modularize builtin effects build
Currently, cpp source files are included partially in effect sub-folders
and src/effects/CMakeLists.txt, which is really confusing and hard to
follow.

With this change, effect targets will be defined in their own subfolders.
This makes build files more straightforward.

Effect sub-targets are eventually merged into a monolithic
kwin4_effect_builtins target.

Another reason for modularizing builtin effects is that no two effects
can generate moc files with the same name atm even though they are in
different sub-folders. This can be potentially useful in the future, e.g.
making effects static plugins in order to decouple builtin effects from
libkwin (every effect subfolder would need a main.cpp or plugin.cpp file,
which will include the associated moc file).
2021-10-13 17:05:06 +00:00
Vlad Zahorodnii
ec6e6fa63c effects/showfps: Add destructor
The GLTexture class is forward declared and the ShowFpsEffect class has
a QScopedPointer<GLTexture> field. We either need to include the
kwinglutils.h header file or add a destructor that does nothing and
define it in the cpp file, where kwinglutils.h is included.
2021-10-13 17:05:06 +00:00
Aleix Pol
c07182490d pipewire: Fix downloading software-rotated textures
At the moment we'll be setting the YInverted setting, but in practice
that won't have any effect as it only changes the render matrix and
we'll end up streaming inverted textures.
This change addresses it by rendering it into another texture first to
resolve this situation and then download that new texture instead.
2021-10-13 17:16:15 +02:00
Aleix Pol
67ec16c335 pipewire: No need to create a QRect when we just need its size 2021-10-13 17:14:53 +02:00
Nate Graham
c1fb405b8d Rename "pack" actions for clarity
The English word "pack" is not really the correct word for these
actions, and does not succeed in communicating what they will do. Since
the actions simply move the active window as far as it will go in the
specified direction, the actions can be renamed to say that instead.

Also rename the action names in the code to match their new UI text for
clarity.
2021-10-13 14:28:23 +00:00
Méven Car
cc5b47ee30 abstract_client: convert some Q_FOREACH 2021-10-13 15:44:39 +02:00
Andrey Butirsky
59143eeef9 [wayland] fix crash on startup with lv3:ralt_alt XKB option
With lv3:ralt_alt ("Right Alt never chooses 3rd level") option set, we
get more layouts from libxkbcommon than it was configured, see:
https://github.com/xkbcommon/libxkbcommon/issues/262
It might be correct lib's behavior, still.

The extra layouts are redundant, so we strip them out from usual usage.

BUG: 440027
2021-10-12 15:41:54 +00:00
Vlad Zahorodnii
e29997bda8 plugins/nightcolor: Remove unused options 2021-10-12 06:38:23 +00:00
Vlad Zahorodnii
d0fd2224bf autotests: Use EffectLoader to list all available effects
EffectLoader is a more generic way to list all available effects.
2021-10-12 06:33:30 +00:00
Vlad Zahorodnii
d6f02abad0 cmake: Make KF5Wayland required again
wayland platform plugin uses KF::Wayland.
2021-10-12 06:32:55 +00:00
Vlad Zahorodnii
260b224d3b Drop WaylandServer::dispatch()
There's no any good reason to dispatch events at shutdown.
2021-10-12 06:32:55 +00:00
Vlad Zahorodnii
65e8c0c737 Simplify WaylandServer::initWorkspace()
If kscreenlocker integration is on, the initialized() signal can be
still emitted in WaylandServer::initWorkspace().
2021-10-12 06:32:55 +00:00
Vlad Zahorodnii
d941c97d8e Remove unused includes 2021-10-12 06:32:55 +00:00
l10n daemon script
16e38fe07b SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-10-12 01:19:47 +00:00
Nicolas Fella
310684f1a7 Fix build by lowering KDE_COMPILERSETTINGS_LEVEL
It doesn't build against the stricter 5.85 level
2021-10-11 21:59:39 +02:00
Jonathan Riddell
57c06d0e00 Update kf5 version requirement to 5.86
GIT_SILENT
2021-10-11 20:48:20 +01:00
Rodney Dawes
886a86ab2b Pass correct argument to Q_UNUSED for disabled features 2021-10-08 13:19:35 -04:00
Martin Flöser
68589fe937 compositor: Merge the OpenGL 2 and 3 backends
This change merges the two OpenGL backends into one making the current
default of GLCore the overall default. It becomes the first context to
try to create. If it fails, it will automatically fall back to the
(previous) OpenGL 2 backend.

Reasoning: the differentiation of OpenGL 2 and 3 is a very technical one
and hard to understand for users. It is not obvious which one is better
or should be used. This results in many user discussions like "Which
backend to use?"

Back when the OpenGL 3 backend was introduced the dedicated feature made
sense. It was a new code base using new driver features. Nowadays the
code base in KWin is robust and mature and so are the drivers. A driver
advertising support for OpenGL 3 will support OpenGL 3. We don't have to
plan for driver breakage in this area any more.

Also our code evolved through the context attribute builder which gives
us the possibility to more easily fall back in case we cannot create the
context. Thus the need to select the backend is not so important as it
used to be when the feature got introduced.

If a user still wants to force OpenGL2, it is still possible by setting
the appropriate environment variables like MESA_GL_VERSION_OVERRIDE.

This change brings the improvement that the backend selection is now
completely removed from the compositing KCM.
2021-10-08 15:26:25 +00:00
Vlad Zahorodnii
bc8c7a5fce autotests: Make testXdgShellClientRules more robust to CI being heavily loaded
FAIL!  : TestXdgShellClientRules::testSizeApply() 'surfaceConfigureRequestedSpy->wait(10)' returned FALSE. ()
   Loc: [/home/jenkins/workspace/Plasma/kwin/kf5-qt5 SUSEQt5.15/autotests/integration/xdgshellclient_rules_test.cpp(731)]

If CI is moderately loaded, 10ms may not be enough. I don't remember why
10ms timeout was added.
2021-10-07 20:17:37 +00:00
Vlad Zahorodnii
dee97068fb autotests: Stabilize testXdgShellClient
Currently, testXdgWindowReactive() is a bit flaky because the parent
window and the popup window are created together. The popup can be
configured again if its global position changes after the parent window
has been placed.

In order to stabilize the test, create the parent window, then the popup
window.
2021-10-07 23:16:41 +03:00
Vlad Zahorodnii
4ba7aa62b9 Reset WaylandServer::s_self in destructor
When using KWIN_SINGLETON macros, you still need to reset s_self
manually in the destructor.
2021-10-07 18:26:43 +03:00
Vlad Zahorodnii
5be593d4e4 wayland: Drop internal connection
It's practically unused now.
2021-10-07 13:28:08 +00:00
Benjamin Port
9c4f358a64 NightColor: use config watcher to update state when configs are changed 2021-10-07 13:12:30 +00:00
Alex Richardson
722f092b7a Fix a -Wformat warning on FreeBSD
On FreeBSD we get a long long result so %ld triggers a warning. Cast to
long long and use %lld to make it work on all platforms (including 32-bit).
2021-10-07 08:24:01 +00:00
Alex Richardson
8ab41804f0 Increase minimum KDecoration2 version
I just got a build failure because I hadn't updated KDecoration to
include 195bcf36df.
Bump the minimum version to trigger a CMake error instead of a
compilation failure. Since we expect to be using the same version of
KDecoration as KWin, this change uses ${PROJECT_VERSION} as the minimum
version.
2021-10-07 07:40:16 +00:00
Xaver Hugl
9f69d4c9c2 platforms/drm: set DPMS property properly 2021-10-07 07:02:50 +00:00
Vlad Zahorodnii
4f3ff4fbb0 wayland: Improve default placement of pointer
Currently, the pointer is moved to the center of the workspace. However,
on a multi-monitor setup, the workspace center may not be the same as
the center of the output it's on. That's the case with my setup -
1920x1080, 1920x1080, 1080x1920 (the monitors are laid out in a row from
left to right).

This change improves the default placement of the pointer by actually
moving it to the center of the screen that contains the workspace center
so the pointer doesn't end up at some "random" position from the user's
point of view.
2021-10-07 05:49:42 +00:00
Andrey Butirsky
c9b41a1682 fix wrong approach geometry of screen edge's effect
Edge geometry has width and height, so we need the correction for
approach geometry of bottom and right corners.
The other edges are fixed as well.

BUG: 442973
2021-10-06 22:57:33 +00:00
Vlad Zahorodnii
e6c77a1ddc Clear should_get_focus in Workspace::focusToNull()
On X11, there are four input models. With some input models, it's okay
if the window manager calls XSetInputFocus(), with others, the wm has to
ask the client to make a XSetInputFocus() request.

If kwin wants a client to take input focus, kwin will add the client
to the should_get_focus list, which contains all the windows that
are about to get input focus. Clients are popped from the list upon
receiving FOCUS_IN events.

A client will be added to the should_get_focus list even if kwin thinks
that the client already has input focus because communication between
the wm and xorg is async, anything can happen with input focus in meanwhile.

On the other hand, the wm may sometimes focus the null window if no
window should contain the input focus. The issue is that the
should_get_focus list is not cleaned up in that case, which can lead to
Workspace::mostRecentlyActivatedClient() returning wrong client and
possibly other async related issues.

We don't have such madness on Wayland as the compositor is in charge of
handling input focus.

This change makes Workspace::focusToNull() clear the should_get_focus,
which is reasonable. We need to deactivate "in-flight" focus requests.

This also fixes the bug where fullscreen Wayland windows don't go above
docks and panels due to Workspace::mostRecentlyActivatedClient() returning
bad client.

BUG: 439405
BUG: 395919
2021-10-05 14:53:20 +00:00
Nicolas Fella
2314867945 Add kde-ci.yml
List of deps is based on CMakeLists.txt
2021-10-05 13:11:38 +00:00
Xaver Hugl
ef894f34eb xdgshellclient: fix initial placement with maximize
BUG: 439986
2021-10-04 09:39:58 +00:00
Xaver Hugl
6a68caef7b Only emit outputDisabled if the output is enabled
CCBUG: 440322
2021-10-04 09:38:40 +00:00
Xaver Hugl
178e69b39b platforms/drm: handle hotplugs with disabled outputs better
If the last enabled output gets removed but we have disabled outputs
still connected, enable the first disabled output to prevent a crash.

BUG: 442990
2021-10-04 09:37:52 +00:00
Méven Car
85fb0e7c43 IdleTimePoller: Fix a crash at shutdown
Currently, kwin crashes at shutdown because the idle poller plugin is unloaded when exit handlers are run, after the waylandServer() is destroyed. This results in null dereferencing.

BUG: 443268
2021-10-04 10:24:23 +02:00
Vlad Zahorodnii
8ac93a59ff scene: Handle Xwayland windows changing surfaces
Xwayland can re-create the wl_surface if the window has been previously
unmapped.

BUG: 442936
BUG: 426069
2021-10-04 05:56:27 +00:00