Commit graph

1051 commits

Author SHA1 Message Date
Vlad Zahorodnii
2b3e8d6775 Decouple activation feedback from plasma window management global 2021-08-25 09:21:20 +00:00
Aleix Pol
773995de56 plasma-window-management: Support new activation concepts 2021-08-19 18:08:06 +00:00
David Edmundson
aeaa480b0c Add API to record the socket name used by a given file descriptor 2021-08-16 17:37:15 +01:00
Vlad Zahorodnii
d0a0c70d9c Add aboutToBeDestroyed signal to various xdg-shell classes
With the aboutToBeDestroyed signal, the compositor will be able to
perform cleanup before the QObject::destroyed signal is emitted, which
saves us some nullptr checks.
2021-08-12 10:35:13 +00:00
David Redondo
6ba9856a29 Implement wlr-data-control v2
This adds primary clipboard support to data control.
2021-08-12 09:01:08 +02:00
Vlad Zahorodnii
1083e650d5 Avoid using bitfields
Unfortunately, bitfields can be initialized using default member
initializer only since C++20.
2021-08-06 12:59:07 +03:00
Manuel Stoeckl
3f6433b81d Add a few 30-bit wl_shm formats
Register WL_SHM_FORMAT_ARGB2101010 and its XRGB,ABGR, and XBGR variants.
These (little-endian) formats are only advertised on little endian
machines, where there exist matching (native-endian) QImage formats.
2021-08-03 21:18:26 -04:00
Vlad Zahorodnii
00f112f48a Allocate less memory for every wl_callback
wl_callback and wl_region are two kinds of objects that are frequently
allocated.

Currently, we make two extra heap allocations per each wl_callback
object. One for the wrapper object (FrameCallback) and the other one is
for its Resource.

With this change, no extra allocations will be made. Also, due to
relying on wl_resource linked lists, the destroy listener implementation
got much simpler.

This won't result in huge memory usage or performance improvements, but
still it's worth reducing the number of memory allocations where possible.
2021-07-29 10:21:13 +03:00
Vlad Zahorodnii
43cfd25d27 Search for Xwayland surfaces differently
Currently, we store all surfaces in a single list and use linear search
to find the SurfaceInterface by its object id and client connection.

With this, we first search for the wl_resource object by its id. Once we
have a wl_resource, SurfaceInterface::get(wl_resource) can be used.

The main advantage of the proposed solution is that we don't need to
maintain a static list with all SurfaceInterface objects.
2021-07-28 14:38:01 +03:00
Vlad Zahorodnii
ba3f587200 Drop ClientConnection::createResource()
It's leftover after now gone Global and Resource.
2021-07-28 14:21:11 +03:00
Vlad Zahorodnii
0ed5f6f096 Remove unused wl_event_loop forward declaration 2021-07-28 13:46:56 +03:00
Vlad Zahorodnii
f248dce3da Ignore dpms status in Display::outputsIntersecting()
Display::outputsIntersecting() is used to compute the list of outputs
where the given surface is. The problem is that it accounts for the dpms
mode.

This means that if an output is turned off, clients will receive a leave
event and they may potentially decide to change the buffer scale and
commit new buffers.

The dpms check was introduced to fix a crash, however since then, output
bits in kwin have changed drastically, in particular how wl_output
objects are destroyed. So, it should be safe to remove the dpms check.
2021-07-28 10:28:21 +00:00
David Redondo
8cffad3fe8 Query height instead of texture format
Texture queries do not seem to work on nvidia and QtQuick windows
will then no be rendered.
2021-07-27 17:30:16 +02:00
Vlad Zahorodnii
7335d54209 Fix mapped status tracking for subsurfaces
A subsurface should be considered mapped only if it has a buffer
attached and its parent is also mapped.

Currently, mapped status logic in SurfaceInterface is somewhat broken
for sub-surfaces. For example, the mapped() signal will be emitted even
if the sub-surface should be considered unmapped according to the spec.
2021-07-23 21:42:30 +03:00
Vlad Zahorodnii
0fcc4af42d Make SurfaceInterface::buffer() const 2021-07-23 19:58:42 +03:00
Vlad Zahorodnii
0045eaecfa Reference shm pool for destroyed buffers
Currently, if an application is closed, all of its shm buffers will be
destroyed. However, the compositor may want to access them to fade out
the window.

With this change, the underlying shm pool will be referenced when a shm
buffer is destroyed. So, the compositor can access buffer data even if
the buffer is destroyed.
2021-07-22 11:41:08 +03:00
Vlad Zahorodnii
e4bf7e0334 Drop Global and Resource classes
They're unused.
2021-07-22 11:41:08 +03:00
Vlad Zahorodnii
0d2879c62d Split BufferInterface
Currently, the BufferInterface encapsulates all the kinds of client
buffers. This has become a somewhat annoying issue as we want to
reference the shm pool if a shm buffer is destroyed, or have custom
buffer readiness logic for linux dma-buf client buffers.

Implementing all of that with the current abstractions will be
challenging as there's no good separation between different client
buffer types.

This change splits the BufferInterface class in three sub-classes -
DrmClientBuffer, LinuxDmaBufV1ClientBuffer, and ShmClientBuffer.

In addition to that, this change fixes the broken buffer ref'ing api.
2021-07-22 11:41:06 +03:00
Vlad Zahorodnii
a244769a3f Make layer-surface acknowledged configure serials double-buffered state
This will be needed to delay surface commits.
2021-07-21 17:26:12 +00:00
Vlad Zahorodnii
c5691ba4de Make xdg-surface acknowledged configure serials double-buffered state
This will be needed to delay applying surface state.
2021-07-21 17:26:12 +00:00
Vlad Zahorodnii
9210e25c52 Build surface-to-buffer matrix based on current state
This makes it more clear that the surface-to-buffer matrix is computed
based on the current surface state.
2021-07-21 06:18:38 +00:00
Vlad Zahorodnii
ce92ac7451 Merge SurfaceInterfacePrivate::commit() and SurfaceInterfacePrivate::surface_commit()
This removes an unnecessary layer of indirection.
2021-07-21 06:18:38 +00:00
Vlad Zahorodnii
c2f0db4a92 Split SurfaceInterfacePrivate::swapStates()
Currently, the swapStates() function does two things - (a) it merges one
state with another; (b) it applies the next state. This change splits the
swapStates() so it's simpler and the boolean trap can be removed.
2021-07-21 06:18:38 +00:00
Vlad Zahorodnii
6e734a1f90 Remove needless current state copy
If nothing has been committed to the cached state, no changes to the
current state will be done.

If a synchronized sub-surface has been committed, the pending state will
be merged with the cached state. The latter state will be applied when
the parent surface is committed.
2021-07-20 08:08:22 +00:00
Vlad Zahorodnii
c55de7b70b Emit the committed() signal after the state is applied
Currently, the committed signal is emitted after the client has called
wl_surface.commit. However, this breaks with synchronized subsurfaces.

Notably, Firefox splits a web page in a bunch of smaller layers, which
can be backed by wl_subsurface objects.

All the subsurfaces are in the sync mode. If a layer needs to be
repainted, Firefox will commit the corresponding subsurface with a frame
callback.

Since the committed signal is emitted when the wl_surface.commit request
is invoked, kwin will schedule a new frame immediately. Meaning, that it
is quite likely that firefox will have old contents.

The right thing to do would be to schedule a frame when all the ancestors
of the layer subsurface have been committed.

This change re-jitters the commit logic so the committed signal is
emitted when a new state is applied to the surface. It also slightly
cleans up how SubSurfaceInterface::parentCommit() is called.

It will be nice to cleanup the commit logic further by calling the
surface role's commit hook unconditionally, i.e. not check whether it's
a subsurface. But doing so may result in infinite recursions. How to
clean up that is still TBD.
2021-07-16 13:07:56 +03:00
Vlad Zahorodnii
17cccfa233 Allow placing subsurfaces below parent surface
According to the spec, if the parent surface is specified in the
wl_subsurface.place_below(), the subsurface has to be rendered below the
parent surface.

At the moment, kwaylandserver doesn't handle that case properly. It is
not possible for sub-surfaces to go below the parent surface.

Another issue is that we wrongly assume that the place_above request
will put the subsurface on top of the stack if the parent surface is
specified as sibling. It doesn't seem like that's the case, not
according to the spec.

This change splits the child sub-surface list in two lists - below and
above. The alternative solution is to store the parent surface in the
children list, but it's an error prone solution and it's conceptually
weird.
2021-07-08 05:33:14 +00:00
Emilio Cobos Álvarez
9d8b387d52 display: Add an outputsIntersecting helper.
This will be used to clean up https://invent.kde.org/plasma/kwin/-/merge_requests/1128.
2021-06-24 13:23:22 +02:00
Vlad Zahorodnii
4dd205ce4f Don't move keyboard focus on button press
Until the spec is clear about how the keyboard focus should be
transferred between sub-surfaces, it's better to remove this heuristic
and focus only the main surface.

For example, if an application window has sub-surfaces but user doesn't
press any pointer button, any sub-surface can have focus.

Effectively, this reverts 6fe14f73d2.
2021-06-21 16:56:01 +03:00
Vlad Zahorodnii
5c6b1f4e8d Remove explicit flush in DataDeviceInterface
This allows the compositor batch events better.

If the event loop is about to block, client connections will be flushed.
2021-06-19 14:17:03 +03:00
Vlad Zahorodnii
98477eabc1 Remove manual flush when sending buffer release event
This way we can batch more events before flushing the client connection.
2021-06-19 11:12:35 +03:00
Vlad Zahorodnii
ac60e35818 Don't flush client connection when sending frame callbacks
This way, the compositor can batch more frame callbacks before flushing
the client connection. We attempted this before, but it broke tests.

Now, it seems like the tests pass, so we can remove the manual flush.
2021-06-19 11:12:25 +03:00
Aleix Pol
669d7fd652 xdgactivation: allow sourcing a request's client without a given surface 2021-06-14 17:43:03 +02:00
Aleix Pol
7dd092e910 Implement zwp_input_method_context_v1::grab_keyboard
Offers a new InputKeyboardV1Interface instance that wraps the
wl_keyboard and allows the compositor to forward the keyboard events.
2021-06-03 19:12:12 +02:00
David Edmundson
ecda92e023 Introduce a new signal when a drag is dropped 2021-06-03 11:17:59 +01:00
Vlad Zahorodnii
398841363b Move viewport state into a struct
It makes it more clear what state belongs to the wp_viewport extension.
2021-05-26 21:21:34 +03:00
Vlad Zahorodnii
86d39af6a0 Move surface state struct in KWaylandServer namespace
This way, it's less characters to type. In order to support delayed
surface commits, compositor extensions need to piggyback their state on
the state of the wl_surface. In other words, SurfaceState is going to
be used not only by SurfaceInterface, but the viewporter extension, the
xdg-shell extension, etc.
2021-05-26 21:21:05 +03:00
Aleix Pol
dde500c3ff Implementation of xdg_activation_v1
Offers KWaylandServer::XdgActivationV1Interface
2021-05-24 17:18:44 +02:00
Aleix Pol
b7d733fd76 textinput_v2: Make sendEnter/sendLeave the ones who decide the current surface
Instead of enabled/disabled. This made it possible for non-focussed
processes to interact with our virtual keyboard. In practice, this meant
that sometimes when switching applications, the disabled from the former
application would arrive after the enabled of the latter, leaving kwin
in a broken state (that the user could address by tapping on the screen
just once).
2021-05-22 02:23:53 +02:00
Aleix Pol
a4a10865e4 textinput: translate normal to normal
Not to alpha, maliit considers alpha to just be letters and goes to such
a mode.
2021-05-22 02:09:14 +02:00
Aleix Pol
75ba7fdc90 inputmethod: Make sure to test AutoCompletion
We were doing AutoCapitalization twice, I imagine it was a copy&paste
situation.
2021-05-21 19:17:17 +02:00
Aleix Pol
7e80c54d5d textinput: prefer smart pointers 2021-05-21 19:17:17 +02:00
Aleix Pol
961debb513 textinput: Expose enums to moc
Allows us to pass them to qDebug easily.
2021-05-21 19:17:17 +02:00
Xaver Hugl
93a4104b1e output interface: mark bind and release methods as override 2021-05-20 14:23:20 +02:00
David Edmundson
4a505823d7 Send surface_leave events before announcing output removal
It's the more logical order from the POV of a client
2021-05-19 22:58:38 +01:00
Laurent Montel
0c49d302ce Use Q_EMIT to make it compile against kf5.82 2021-05-13 11:33:08 +02:00
Vlad Zahorodnii
d740a45469 Fix invalid iterator in SurfaceInterfacePrivate::raiseChild()
The append method will invalidate the iterator, so we cannot call the
erase() method with the old iterator.
2021-05-13 10:16:25 +03:00
Vlad Zahorodnii
89dc01ada8 Add a PlasmaShellSurfaceInterface getter
This allows to simplify some compositor code.
2021-05-13 09:17:56 +03:00
Vlad Zahorodnii
c2fc33872e Introduce ClientConnection::aboutToBeDestroyed
This signal is useful if the compositor wants to perform some cleanup
before the disconnected signal is emitted or while the connection object
still has valid wl_client native handle.
2021-05-12 22:39:07 +03:00
Vlad Zahorodnii
da3f4923f1 Scanner: Clean up display destroy listener in deferred global destroy func
We also need to clean up the display destroy listener in the deferred
global destroy func to avoid use-after-free bugs on the display tear down.
2021-05-12 13:52:59 +00:00
Vlad Zahorodnii
e4271a787f Scanner: Remove global version check
libwayland-server ensures that the requested version is less than or
equal to the global version.

This change removes the global version check to simplify the generated
code and reduce memory usage footprint, however the latter shouldn't be
that noticeable.
2021-05-12 14:41:15 +03:00