1
0
Fork 0
Commit graph

9234 commits

Author SHA1 Message Date
Jonas Dreßler
988da215c8 wayland/keyboard: Use MetaAnonymousFile to share keymap files
Since protocol version 7 clients must use MAP_PRIVATE to map the keymap
fd, that means we can use memfd_create() to create the fd by using
meta_anonymous_file_open_fd() with META_ANONYMOUS_FILE_MAPMODE_PRIVATE,
for older versions we use META_ANONYMOUS_FILE_MAPMODE_SHARED to be
compatibile with MAP_SHARED.

Pretty much all of this code was written for Weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1734

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Jonas Dreßler
551a57ed7f Add read-only anonymous file abstraction MetaAnonymousFile
Add MetaAnonymousFile, an abstraction around anonymous read-only files.
Files can be created by calling meta_anonymous_file_new(), passing the
data of the file. Subsequent calls to meta_anonymous_file_open_fd()
return a fd that's ready to be sent over the socket.

When mapmode is META_ANONYMOUS_FILE_MAPMODE_PRIVATE the fd is only
guaranteed to be mmap-able readonly with MAP_PRIVATE but does not
require duplicating the file for each resource when memfd_create is
available. META_ANONYMOUS_FILE_MAPMODE_SHARED may be used when the
client must be able to map the file with MAP_SHARED but it also means
that the file has to be duplicated even when memfd_create is available.

Pretty much all of this code was written for weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Carlos Garnacho
b7366b5b53 wayland: Drop unused struct variable
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:51:00 +02:00
Carlos Garnacho
5e8d8b9ade wayland: Move the primary data device manager to its own file
Instead of having everything clumped at MetaWaylandDataManager,
split the primary selection to its own struct. This manager is
handled separately from wl_data_device_manager and other selection
managers, so they would be able to interoperate between them, even.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:50:57 +02:00
Carlos Garnacho
4726f3d5d3 wayland: Move primary data offers to their own file
Following the MetaWaylandDataOffer split.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
91ef7515de wayland: Move MetaWaylandDataOffer to its own file
This is still an openly defined struct, as we will need accessed
by "subclasses". Same principle applies than with the
MetaWaylandDataSource refactor, this is not meant to introduce
functional changes, so just go with it.

On the bright side, the interactions are now clearer, so it could
be made saner in the future.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
317f6c0910 wayland: Move MetaWaylandDataSourcePrimary to its own file
Following the MetaWaylandDataSource split, this goes next.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
6a3d521466 wayland: Split MetaWaylandDataSource into a separate file
The split wasn't 100% clean, and some extra private API had to be
added for it (but well, looking at the API, it's already evident
there's a cleanup/streamlining task due). This is meant to be a
refactor with no functional changes, so just go with it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:21 +02:00
Carlos Garnacho
1363246d44 wayland: Rely on MetaSelection::owner-changed for .selection event emission
We already have a signal callback that translates selection ownership changes to
data_device/primary .selection events. Given both will be run when a data source
is being replaced, and this event emission being deleted is kinda short sighted
in that in only knows about Wayland, rely entirely on MetaSelection::owner-changed
emission.

Fixes spurious .selection(null) events being sent when a compositor-local source
takes over the selection without the focus changing (eg. screenshot to clipboard).

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1160

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1204
2020-04-16 22:25:00 +00:00
Carlos Garnacho
0b6560fac4 wayland: Do not cancel old data source when setting new selection
This is taken care already by the MetaSelection machinery, by
deactivating the previous selection source when setting a new one.
That works across X11 and internal selection sources. This
only works when replacing one wayland source with another, and
actually results in doubly .cancelled events due to the other
paths.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1177

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1203
2020-04-16 19:27:51 +00:00
Carlos Garnacho
d4c3870286 wayland: Shuffle wl_data_source.cancelled version checks on DnD
We are meant to send a .cancelled event after the drop is performed
in certain situations, but only for version>3 clients. Since this is
all version 3 business, only set the drop_performed flag for v3
clients. This drops the need to perform version checks at the time
of cancelling (which is present for other usecases in v1).

Fixes emission of wl_data_source.cancelled for v1 clients.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1177

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1203
2020-04-16 19:27:51 +00:00
Carlos Garnacho
4bdf9a1e70 core: Cater for reading selection in chunks
For the cases where we read a fixed size from the selection (eg. imposing
limits for the clipboard manager), g_input_stream_read_bytes_async() might
not read up to this given size if the other side is spoonfeeding it content.

Cater for multiple read/write cycles here, until (maximum) transfer size is
reached.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
1909977a67 x11: Do not trust there is task in error paths
Flushing the X11 selection output stream may happen synchronously or
implicitly, in which case there is not a task to complete. Check there
is actually a task before returning errors. We additionally set the
pipe_error flag, so future operations will fail with an error, albeit
with a more generic message.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
655a783891 x11: Don't stall on write_async()
If a write_async() comes up while we are flushing on the background,
the task will be queued, but not deemed a reason on itself to keep
flushing (and finish the task) after a property delete event.

To fix this, do not ever queue up write_async tasks (this leaves
priv->pending_task only used for flush(), so the "flush to end"
behavior in the background is consistent). We only start a
background flush if there's reasons to do it, but the tasks are
immediately finished.

All data will still be ensured to be transfered on flush/close,
this makes the caller in this situation still able to reach to it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
a4596becc4 x11: Fix iterative INCR property checks
It does not make sense to check for the stream not being closed,
this might happen multiple times during the lifetime of the stream
for a single transfer. We want to notify the INCR transfer just
once.

Check for the explicit conditions that we want, that the remaining
data is bigger than we can transfer at once, and that we are not
yet within the INCR transfer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
7015bb3efd x11: Don't exceed transfer size in INCR chunks
The stream automatically flushes after data size exceeds the
size we deem for INCR chunks, but we still try to copy it all.
Actually limit the data we copy, and leave the rest for future
INCR chunks.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
d2c762cc66 x11: Don't invariably queue a pending delete request
We don't need doing this roundtrip for non-INCR transfers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
04d429b743 x11: Finish INCR transfers properly
INCR transfers are mandated to finish with a final 0-size XChangeProperty
roundtrip after the final data chunk. Actually honor this and ensure we
iterate just once more for this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
0b21dcfe08 x11: Wait till data is flushed before notifying on the pending task
It does not make sense to notify flushes mid-transfer. We should wait
till the data is actually finished before notifying on the pending
task.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
7c939d78c2 x11: Only send SelectionNotify on first INCR chunk
This should only be sent if the selection can be sent at once, or
if we are right about to notify on the first chunk of an INCR
transfer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
8a2b82897d x11: Ensure flush() Flushes all output stream data
This seemed to work under the assumption that a flush() call can
only result in one INCR roundtrip. This is evidently not true, so
we should hold things off until all pending data is actually flushed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
e95c365cf0 x11: Unset pending flush flag right before notifying on task
Together with some other state. We can do this altogether on task
notification, instead of lost somewhere in this function flow.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
a32cb7133b x11: Intern INCR atom
We want to use it, despite it not existing previously.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
967966cdee x11: Flag flushes despite having less than the element size
If say we want 32bit data, but have 2 bytes stored, we would simply
ignore flush requests. Allow (and don't clear) the needs_flush flag
if we have less than the element size accumulated.

Instead handle this in can_flush(), so it's triggered whenever we
have enough data to fill 1 element, or if the stream is closing
(seems a broken situation, but triggered by the caller).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
06d67b6abf x11: XMaxRequestSize returns 4-byte units
XMaxRequestSize/XMaxExtendedRequestSize are documented to return
the maximum size in 4-byte units, whereas we are comparing this
to byte lenghts. We can afford 4x the data here.

Since I don't know the payload size of the XChangeProperty request,
be generous and allot 400 bytes for it, we have some to spare.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Marco Trevisan (Treviño)
f15ce01e2b monitor-unit-tests: Ensure configuration is preserved in laptop with closed lid
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1200
2020-04-16 15:14:03 +00:00
Marco Trevisan (Treviño)
e48516679c monitor-config-manager: Fallback to closed laptop lid configuration
When closing the lid of a laptop, we reconfigure all the monitors in order
to update the CRTCs and (if enabled) the global UI scaling factor.

To do this, we try first to reuse the current configuration for the usable
monitors, but if we have only monitor enabled and this one is on the laptop
lid we just end up creating a new configuration where the primary monitor is
the laptop one (as per find_primary_monitor() in MetaMonitorConfigManager),
but ignoring the user parameters.

In case the user selected a different resolution / scaling compared to the
default one, while the laptop lid is closed we might change the monitors
layout, causing applications to rescale or reposition.

To avoid this, when creating the monitors configuration from the current
current state, in case we have only one monitor available and that one is
the laptop panel, let's just reuse this configuration.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1200
2020-04-16 15:14:03 +00:00
Jonas Ådahl
65a6c4c361 compositor: Add support for direct scanout of Wayland surfaces
Try to bypass compositing if there is a fullscreen toplevel window with
a buffer compatible with the primary plane of the monitor it is
fullscreen on. Only non-mirrored is currently supported; as well as
fullscreened on a single monitor. It should be possible to extend with
more cases, but this starts small.

It does this by introducing a new MetaCompositor sub type
MetaCompositorNative specific to the native backend, which derives from
MetaCompositorServer, containing functionality only relevant for when
running on top of the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
b51c468c0f later: Listen to MetaCompositor signal instead of clutter
We need to coordinate with MetaCompositor during pre-paint so that we
have control over whether MetaLater callbacks happen first, or the
MetaCompositor pre-paint logic.

In order to do so, make MetaLater listen to a new signal "pre-paint" on
MetaCompositor, that is called MetaCompositors own pre-paint handling.

This fixes an issue where the top window actor was calculated after the
MetaCompositor pre-paint handling, meaning the top actor being painted
was out-of-date.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
2e7d02f1ce later: Make MetaCompositor the owner of the MetaLaters state
Since the order of destruction during MetaDisplay tear down is a bit
unordered, there are pieces that try to destruct its compositing
dependent pieces (i.e. queued MetaLater callbacks) after MetaCompositor
has been cleaned up, meaning we need to put some slightly awkward NULL
checks to avoid crashing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
dc4fe780f7 display: Initialize MetaCompositor in two steps
MetaCompositor is the place in mutter that manages the higher level
state of compositing, such as handling what happens before and after
paint. In order for other units that depend on having a compositor
instance active, but should be initialized before the X11 implementation
of MetaCompositor registers as a X11 compositing manager, split the
initialization of compositing into two steps:

 1) Instantiate the object - only construct the instance, making it
    possible for users to start listening to signals etc
 2) Manage - this e.g. establishes the compositor as the X11 compositing
    manager and similar things.

This will enable us to put compositing dependent scattered global
variables into a MetaCompositor owned object.

For now, compositor management is internally done by calling a new
`meta_compositor_do_manage()`, as right now we can't change the API of
`meta_compositor_manage()` as it is public. For the next version, manual
management of compositing will removed from the public API, and only
managed internally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
d682cdb078 util: Move MetaLater to its own file
While at it, fix some style inconsistencies, for now use a single
singleton struct instead of multiple static variables, and
other non-functional cleanups. Semantically, there is no changes
introduced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
ff7a42b8bc wayland: Add API to acquire a CoglScanout from a surface
This will check whether the current backing buffer is compatible with
the primary plane of the passed CoglOnscreen. Since this will extend the
time before a buffer is released, the MetaWaylandBufferRef is swapped
and orphaned if a new buffer is committed before the previous one was
released. It'll eventually be released, usually by the next page flip
callback.

Currently implemented for EGLImage and DMA-BUF buffer types.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
4b1805c306 wayland/dma-buf: Handle getting dma-buf from detached buffer handle
We might still have a MetaWaylandBuffer for a wl_buffer that was
destroyed. Handle trying to fetch the MetaWaylandDmaBufBuffer from such
a buffer gracefully.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
03c00e4944 wayland/dma-buf: Minor style fix
Indentation was off.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
cb05b16414 wayland/dma-buf: Don't advertise modifier support by default
Advertising support for modifiers means we will most likely not not be
able to scan out client buffers directly, meaning it just as likely that
we won't be able to scan out even fullscreen windows without atomic KMS.

When we have atomic support, we should advertise support for modifiers
if atomic is used to drive the CRTCs, as we by then can check whether we
can scan out directly, place in an overlay plane, etc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
b9fe9c736a onscreen/native: Add API to check whether buffer is scanout compatible
While this is fairly incomplete, as to check things fully we need to use
TEST_ONLY in atomic to try out a complete assignment on the device, but
this works well enough for legacy non-modifier cases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
3dd8861fbf renderer/native: Add API to get primary GPU
Will be used when acquiring scanouts from Wayland buffers.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
3da8c1bfdc cogl/onscreen: Add API to scanout a buffer directly
Instead of always swapping buffers and flipping the back buffer, make it
possible to scan out a provided buffer directly without swapping any EGL
buffers.

A buffer is passed as an object implementing the empty CoglScanout
interface. It is only possible to do this in the native backend; and the
interface is implemented by MetaDrmBufferGbm. When directly scanned out,
instead of calling gbm_surface_lock_front_buffer() to get the gbm_bo and
fbid, get it directly from the MetaDrmBufferGbm, and use that to create
the page flip KMS update.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:15 +02:00
Jonas Ådahl
f8ee974628 wayland/buffer-ref: Add helpers for use count tracking
https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
f36120757f wayland: Make MetaWaylandBufferRef reference counted
So that we can have a more dynamic ownership.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
5dad87cfb9 surface-actor-x11: Move window related unredirect logic to MetaWindowX11
Better to have the relevant object figure out whether it is a good
position to be unredirectable other than the actor, which should be
responsible for being composited.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
0f8f607e4c window/x11: Use G_DECLARE_DERIVABLE_TYPE()
This removes the MetaWindowX11::priv pointer. It is replaced with a
meta_window_x11_get_private() helper function, and another method to get
the client rect without going through MetaWindowX11Private.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
282aada13a drm-buffer/gbm: Support both surface and standalone buffers
Surface buffers are created with meta_drm_buffer_new_acquire(), taking a
gbm_surface acquiring the gbm itself, and meta_drm_buffer_new_take()
that takes over ownership of a passed gbm_bo.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
47002bf0cd wayland/surface: Put buffer reference on heap
Currently a buffer use count always reaches zero before it is replaced.
This is due to the fact that at the point a new buffer is attached, the
last potential user releases it (the stage) since the currently
displayed frame has a composited copy of the buffer.

This may however change, if a buffer is scanned out directly, meaning it
should not be released until the page flip callback is invoked.

Prepare for this by making the buffer reference a heap allocated struct,
enabling us to keep a pointer to it longer than the buffer is attached.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 10:43:34 +02:00
Jonas Ådahl
3d47c7edc1 cursor-renderer-native: Take CRTC transform into account
The CRTC level transform (not necessarily the hw transform) must be
taken into account when calculating the position of the CRTC in the
stage coordinate space, when placing the hw cursor, otherwise we'll
place the cursor as if the monitor was not rotated.

This wasn't a problem in the past, as with rotation, we always used the
OpenGL cursor, so the issue newer showed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
bc350f37f5 renderer-native: Use CRTC layout in stage view
The port to per CRTC views was incomplete; we still used the logical
monitor layout as the stage view layout, while still using one view per
CRTC.

This worked fine for most cases, e.g. regular monitors, tiled or
non-tiled, transformed or non-transformed. Where it broke, however, was
when a monitor consists of multiple CRTCs. We already have the layout a
CRTC corresponds to on the stage kept with the CRTC metadata, so use
this directly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1170

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199`
2020-04-15 15:29:55 +00:00
Jonas Ådahl
b55e2e1df9 tests/monitor-unit-tests: Test non-hw-transform rotated tiled monitors
Should affect the assigned transform, but not the layout, as that is the
layout on the stage, not the coordinates in any buffer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
43baf643d4 monitor-config-manager: Only use crtc transform for assignment
The CRTC level transform (i.e. not necessarily the one set on the
hardware) is what is relevant for calculating the layout the CRTC will
have on the stage, so only use the one that can be handled by the
hardware for the CRTC assignment.

This makes the CRTC layout valid for tiled monitors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
21b8ae10b8 monitor: Fix tile coordinate calculation
Previously the tile coordinate was used to offset a CRTC scanout
coordinate within a larger framebuffer. Since 3.36 we're always
scanning out from (0, 0) as we always have one framebuffer per CRTC; we
instead use the tile coordinate to calculate the coordinate the tile has
in the stage view. Adapt calculation to fulfil this promise instead of
the old one.

This also corrects the tiled custom monitor test case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Thomas Hindoe Paaboel Andersen
d0ef660ff6 clutter: fix memleak in test error path
If clutter_init fails then we will not free state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Marco Trevisan (Treviño)
506e06589b test-utils: Only initialize client when we're returning it
test_client_new might return early if conditions are not met, leaving some
allocated data around without freeing it.

Since we're not using the client before, there's no need to initialize it early
and just initialize it when it's going to be returned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Marco Trevisan (Treviño)
1d75d5aa2f group: Free group if returning early
If we get an error when fetching the window attributes, the group isn't ever
free'd, so use an autopointer instead, releasing the stolen one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Phillip Wood
3e967d731a input-settings: fix device list iteration
Dereference the loop variable rather than the original list head. This
fixes a regression introduced in 4413b86a3 ("backends: Replace
ClutterDeviceManager usage in favor of ClutterSeat", 2019-10-04) which
broke button scrolling with trackballs.

Closes:https://gitlab.gnome.org/GNOME/mutter/-/issues/1120
2020-04-11 18:59:14 +01:00
Carlos Garnacho
167fd07e01 x11: Forward current selection state when initializing X11 selections
Most visible with xwayland-on-demand, at the time of setting things up
for X11 selections, we don't forward the current state. This makes the
first started X11 app oblivious to eg. the current clipboard.

Syncing selections up at the time of initializing the X11 selection
stuff ensures that doesn't happen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
2020-04-09 21:30:05 +00:00
Carlos Garnacho
fbd6366edd core: Add private function to get the current selection owner
This is a bit untidy to expose, however may be necessary internally.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
2020-04-09 21:30:05 +00:00
Jonas Dreßler
eb6e1f694a clutter: Remove drag and drop actions
We aren't using those actions in the shell or anywhere in Mutter, our
DnD support is implemented on the shell side.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/789
2020-04-08 20:21:31 +00:00
Olivier Fourdan
5b30a52bbd wayland: preserve xkb_state on VT switch
On VT switch, the devices are removed, which means for Wayland disabling
the keyboard.

When the keyboard is disabled, the associated `xkb_state` is freed and
recreated whenever the keyboard is re-enabled when switching back to the
compositor VT.

That means the `xkb_state` for Wayland is lost whereas the same for
clutter is kept, which causes to a discrepancy with locked modifiers on
VT switch.

To avoid that issue, preserve the XKB info only to dispose it when the
keyboard is eventually finalized.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/344
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1185
2020-04-08 13:16:25 +00:00
Carlos Garnacho
a5294ce55f cogl: Remove CoglPath and the tesselator
This was barely used, and doesn't represent the way we want to
do 2D rendering.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:38:48 +02:00
Carlos Garnacho
ba3417667f wayland/xdnd: Add error traps around Xdnd* IPC
Make all of them spew criticals, except for XdndLeave as it's feasible
to expect the window we are sending the event to did disappear in the
way (eg. if the window is destroyed while the DnD operation is ongoing
and the pointer is over the window).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2590

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1184
2020-04-07 18:08:03 +00:00
Jonas Troeger
50fa002a19 backends/native: Translate coordinates of absolute motion events
The motion events of tablets for example need to be mapped on the
selected screen area if the input device is configured to use only a
part of the active logical monitor.
To achieve this behavior each motion event is transformed using the
transformation matrix set for the input device.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1118
2020-04-07 17:50:11 +00:00
Carlos Garnacho
f0718c7d95 backends/x11: Fix access to WacomDevice
At some point we crossed the streams... In a short timespan we had
1f00aba92c merged, pushing WacomDevice to a common parent object,
and dcaa45fc0c implementing device grouping for X11.

The latter did not rely on the former, and just happened to
merge/compile without issues, but would promptly trigger a crash
whenever the API would be used.

Drop all traces of the WacomDevice internal to MetaInputDeviceX11.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1183
2020-04-07 17:36:13 +00:00
Jonas Ådahl
8df3b21a51 window: Check aliveness a bit less aggressively
Currently we check whether a window is alive everytime it's focused.
This means that an application that doesn't respond to the check-alive
event during startup always showing the "application froze" dialog,
without the user ever trying to interact with it.

An example where this tends to to happen is with games, and for this
particular scenario, it's purely an annoyance, as I never tried to
interact with the game window in the first place, so I don't care that
it's not responding - it's loading.

To avoid these unnecessary particular "app-is-frozen" popups, remove the
alive check from the focus function, and instead move it back to the
"meta_window_activate_full()" call. To also trigger it slightly more
often, also add it to the path that triggers the window focus when a
user actively clicks on the window.

This means that we currently check whether a window is alive on:

  * Any time the window is activated. This means e.g. alt-tab or
    selecting the window in the overview.
  * The user clicks on the window.

Note that the second only works for an already focused window on
Wayland, as on X11, we don't refocus it. This particular case isn't
changed with this commit, as we didn't call meta_window_focus() to begin
with here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1182
2020-04-07 10:46:01 +02:00
Jonas Ådahl
6f0e5b0b56 clutter/stage: Remove 'accept-focus' property
Also unused, only valid on X11. Meant for applications. Lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
fe27a6ea3b clutter/stage: Remove hide/show cursor API
This removes it from the stage window API too. It's managed by the
mutter backends, so we don't need the stage window to do it as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
1301770dcb clutter/stage: Remove 'alpha' property
Was unused except for in a test, lets remove it. Half transparent
monitors will probably have to be dealt with some other way anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
a6f94696e2 window-actor: Set viewport when blitting to screencast fb
This fixes an issue where a non-maximized screen casted window would be
stretched to fill the whole screen cast stream, instead of just the crop
that corresponds to the current window size.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1174
2020-04-03 16:14:02 +00:00
Christian Rauch
a8f6cada88 x11: fix compilation if 'libwacom=false'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1168
2020-04-01 15:23:43 +01:00
Georges Basile Stavracas Neto
7f488e3e1d tests/actor-pick: Allocate actor before picking
Picking now only happens on allocated actors, but the
callback in the actor-pick test is not waiting for the
stage to run an allocation cycle. Ideally, we'd wait
for this cycle, but for now, forcing an allocation works
as well.

Allocate the overlay actor in the actor-pick test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:55 -03:00
Georges Basile Stavracas Neto
059d2144b2 tests/actor-pick: Remove tabs
They're evil.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:10 -03:00
Robert Mader
09a6031c69 window-actor: Force full actor geometry sync when mapping
Normally we bail out in `sync_actor_geometry()`. The comment there
states:
```
Normally we want freezing a window to also freeze its position; this allows
windows to atomically move and resize together, either under app control,
or because the user is resizing from the left/top. But on initial placement
we need to assign a position, since immediately after the window
is shown, the map effect will go into effect and prevent further geometry
updates.
```

The signal for the initial sync originates in `MetaWindow` though and predates
`xdg_toplevel_set_maximized`, which again calls `meta_window_force_placement`,
triggering the signal too early. As a result, Wayland clients that start up
maximized have a wrong map animation, starting in the top-left corner.

In order to fix this without changing big parts of the geometry logic and risking
regressions, force the initial sync again before mapping.

Solution suggested by Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1164
2020-03-30 15:59:48 +00:00
Robert Mader
dbe919ef92 wayland/surface: Check for surface role in meta_wayland_surface_get_window()
The function can get called without valid surface role, e.g. from
`zwp_xwayland_keyboard_grab_manager_grab()`.

Debugged by @piegamesde

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1147
2020-03-30 16:08:13 +02:00
Christian Rauch
2907ee93cc wayland/pointer-constraints: Fix typo
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1163
2020-03-29 19:48:33 +01:00
Carlos Garnacho
bb5ea0580f wayland: Translate delete-surrounding properly to protocols
IBusInputContext/ClutterInputFocus/GtkIMContext all go for offset+len
for their ::delete-surrounding signals, with offset being a signed int
(neg. to delete towards left of selection, pos. to delete towards right
of selection) and len being an unsigned int from the offset (and
presumably, skipping the current selection).

The text-input protocols however pass in this event two unsigned integers,
one being the length of text to delete towards the left of the selection,
and another the length of text to delete towards the right of the selection.

To translate properly these semantics, positive offsets shouldn't account
for before_length, and negative offset+len shouldn't account for after_length.
The offset/length approach may of course represent deletions that are
detached from the current cursor/selection, we simply delete the whole range
from the cursor/selection positions then.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/517
2020-03-29 11:37:27 +00:00
Takao Fujiwara
2cfdbbd730 clutter: Enable negative offsets in delete surrounding text
The input method can assign a negative value to
clutter_input_method_delete_surrounding() to move the cursor to the left.
But Wayland protocol accepts positive values in delete_surrounding() and
GTK converts the values to the negative ones in
text_input_delete_surrounding_text_apply().

https://gitlab.gnome.org/GNOME/mutter/issues/539
2020-03-29 11:37:27 +00:00
Jonas Dreßler
9f31e7252c backends/native: Release virtual buttons on dispose instead of finalize
GObject recommends to break references to other objects on dispose
instead of finalize, also we want to release the pressed virtual buttons
as early as possible if we know the object is getting destroyed.

So release the pressed buttons and unref our virtual
MetaInputDeviceNative when the dispose vfunc is called, which also
allows us to release the buttons immediately from javascript instead of
waiting for the garbage collector by calling run_dispose() on the
object.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1157
2020-03-28 16:55:59 +00:00
Georges Basile Stavracas Neto
fed5f4d9aa window-actor: Inhibit culling when blitting to screencast
This allows us to screencast any window continuously, even
without it being visible. Because it's still being painted,
clients continue to receive frame callbacks, and people
are happy again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
f6700f19a7 window-stream-src: Finish framebuffer after blitting
Just like what's done for monitor screencasting. Unfortunately, there's
no mechanism to share fences with PipeWire clients yet, which forces
us to guarantee that a frame is completed after blitting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
ea34915df3 window-stream-src: Implement cursor blitting
A regression compared to the old code, we're not drawing the cursor
when on EMBEDDED mode.

Blit the cursor to the screencast framebuffer when on EMBEDDED mode.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
37742c5cde window-stream-src: Ensure initial frame is recorded
MetaScreenCastWindowStreamSrc connects to the "damaged" signal of
MetaWindowActor. This signal is not exactly tied to the paint cycle
of the stage, and a damage may take quite a while to arrive when
a client doesn't want to draw anything. For that reason, the window
screencast can start empty, waiting for a damage to arrive.

Ensure at least one frame is recorded when enabling the window stream.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1097

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Georges Basile Stavracas Neto
cdd27d0e53 window-actor: Clip before translate when blitting
cogl_framebuffer_push_rectangle_clip() acts on the current modelview
matrix. That means the result of clipping then translating will be
different of the result of translating then clipping.

What we want for window screencasting is the former, not the latter.
Move the translation code (and associated) to after clipping.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1097

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Georges Basile Stavracas Neto
82778f72a4 window-actor: Shuffle some lines around
Move the CoglColor assignment right above the cogl_framebuffer_clear() call,
and let these wonderful partners together to delight us with an easier to
read code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Hans de Goede
da600b8400 cursor-renderer-native: Take panel-orientation into account for sprite transform
When calculating the transform we should apply to the cursor sprite
before uploading it to the cursor plane, we must also take into
account non upright mounted LCD panels.

Otherwise the cursor ends up 90 degrees rotated on devices where the
LCD panel is mounted 90 degrees rotated in its enclosure.

This commit fixes this by calling meta_monitor_logical_to_crtc_transform
in get_common_crtc_sprite_transform_for_logical_monitors to adjust the
transform for each Monitor in the LogicalMonitor.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1123

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1153
2020-03-27 15:10:35 +00:00
Robert Mader
6aa546145f core: Demote tiff and bmp image formats in the clipboard manager
Support for them appears to be way less common than e.g. png, which is
currently the preferred format from Firefox, Chromium, Libreoffice and others.
Adopt to that fact.

As a side effect, this works around a bug observed when copying images in
Firefox on Wayland.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1141
2020-03-27 14:37:29 +00:00
Jonas Ådahl
ac01e69a67 window-wayland: Don't use grab op for some other window when resizing
When resizing a window interactively, we'll set a grab operation and a
grab window, among other things. If we're resizing (including setting
initial size, i.e. mapping) another window, that didn't change position,
don't use the gravity of the grab operation when resizing our own
window.

This fixes an issue with jumpy popup position when moving a previously
mapped gtk popover.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/999
2020-03-26 17:44:09 +01:00
Jonas Ådahl
a68e6972a2 cursor-renderer-native: Set cursor hotspot metadata on plane assignment
This triggers the paths in the legacy KMS backend to use
drmModeSetCursor2(), making virtual machines using "seamless mouse mode"
behave correctly again.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1094

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
55cf1c1496 kms/plane-assignment: Add API to set cursor hotspot metadata
The transactional KMS API has been modelled after atomic KMS. Atomic KMS
currently doesn't support forwarding cursor hotspot metadata, thus it
was left out of the transactional KMS API having the user set the simply
create a plane assigment with the cursor sprite assigned to a cursor
plane using regular coordinates.

This, however, proved to be inadequate for virtual machines using
"seamless mouse mode" where they rely on the cursor position to
correspond to the actual cursor position of the virtual machine, not the
cursor plane. In effect, this caused cursor positions to look "shifted".

Fix this by adding back the hotspot metadata, right now as a optional
field to the plane assignment. In the legacy KMS implementation, this is
translated into drmModeSetCursor2() just as before, while still falling
back to drmModeSetCursor() with the plane coordinates, if either there
was no hotspot set, or if drmModeSetCursor2() failed.

Eventually, the atomic KMS API will learn about hotspots, but when
adding our own atomic KMS backend to the transacitonal KMS API, we must
until then still fall back to legacy KMS for virtual machines.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
343de21af5 monitor-transform: Add API to transform point
Transforms a point in a rectangle with the origin (0, 0). To be used to
transform cursor hotspots within a cursor sprite.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
3c157242fa cursor-sprite: Add API to get dimension
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
32c99513c8 clutter/actor: Inherit cloned painting when calculating resource scale
When calculating the resource scale of a clone source, we might end up
in situations where we fail to do so, even though we're in a paint. A
real world example when this may happen if this happens:

 * A client creates a toplevel window
 * A client creates a modal dialog for said toplevel window
 * Said client commits a buffer to the modal before the toplevel

If GNOME Shell is in overview mode, the window group is hidden, and the
toplevel window actor is hidden. When the clone tries to paint, it fails
to calculate the resource scale, as the parent of the parent (window
group) is not currently mapped. It would have succeeded if only the
clone source was unmapped, as it deals with the unmapped actor painting
by setting intermediate state while painting, but this does not work
when the *parent* of the source is unmapped as well.

Fix this by inheriting the unmapped clone paint even when calculating
the resource scale.

This also adds a test case that mimics the sequence of events otherwise
triggered by a client. We can't add a Wayland client to test this, where
we actually crash is in the offscreen redirect effect used by the window
dimming feature in GNOME Shell.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/808

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1147
2020-03-26 11:42:23 +01:00
Jonas Ådahl
40c345d6f3 cursor-sprite-xcursor: Emulate Wayland hotspot limitations
For HiDPI pointer cursors backed by Wayland surfaces, the hotspot must
be placed using integers on the logical pixel grid. In practice what
this means is that if the client loads a cursor sprite with the buffer
scale 2, and it's hotspot is not dividable by 2, it will be rounded
down to an integer that can. E.g. a wl_surface with buffer scale 2 and a
cursor image with hotspot coordinate (7, 7) will have the coordinate
(3.5, 3.5) in surface coordinate space, and will in practice be rounded
down to (3, 3) as the hotspot position in wl_pointer only takes
integers.

To not potentially shift by 1 pixel on HiDPI monitors when switching
between wl_surface backend cursor sprites and built-in ones, make the
built in one emulate the restrictions put up by the Wayland protocol.

This also initializes the theme scale of the xcursor sprite instances to
1, as they may not have been set prior to being used, it'll only happen
in response to "prepare-at" signals being emitted prior to rendering.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1092

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1107
2020-03-26 08:47:37 +00:00
Jonas Ådahl
8beef8ccd0 shaped-texture: Fix use-nearest check when viewports are scaled
We checked that the content size was appropriately painted in the stage,
but didn't take into account that the size of the sampled texture
region, meaning that when stage views were scaled, we'd think that we
would draw a texture scaled, as e.g. a 200x200 sized texture with buffer
scale 2 would have the size 100x100. When stage views were not scaled,
we'd apply a geometry scale meaning it'd end up as 200x200 anyway, thus
pass the check, but when stage views are scaled, it'd still be painted
as a 100x100 shaped texture on the stage, thus failing the
are-we-unscaled test.

Fix this by comparing the transformed paint size with the sampled size,
instead of the paint size again, when checking whether we are being
painted scaled or not. For example, when stage views are scaled, our
200x200 buffer with buffer scale 2, thus content size 100x100 will
transform to a 200x200 paint command, thus passing the test. For
non-scaled stage views, our 200x200 buffer with buffer scale 2 thus
content size 100x100 will also transform into a 200x200 paint command,
and will also pass the check, as the texture sample region is still
200x200.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/804

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1124
2020-03-26 08:32:46 +00:00
Jonas Ådahl
62d0dd907b clutter-utils: Fix a couple of coding style issues
Multiple assignments on the same line were split up, so was a super long
line.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1124
2020-03-26 08:32:46 +00:00
Jonas Ådahl
0462208d4e crtc-xrandr: Respect configured RANDR panning
A user may have configured an output to be panning, e.g. using xrandr
--output <output> --mode <mode> --panning <size>. Respect this by making
the logical monitor use the panning size, instead of the mode. This
makes e.g. makes the background cover the whole panning size, and panels
etc will cover the whole top of the panned area, instead of just the top
left part covering the monitor if having panned to (0, 0).

No support is added to configuring panning, i.e. a panned monitor
configuration cannot be stored in monitors.xml.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1085
2020-03-26 09:24:25 +01:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Carlos Garnacho
8699482475 backends: Check both input settings and mapper for tablet monitors
The upper layers (OSDs basically) want to know the monitor that a
tablet is currently assigned to, not the monitor just as configured
through settings.

This broke proper OSD positioning for display-attached tablets since
commit 87858a4e01, as the MetaInputMapper kicks in precisely when
there is no configured monitor for the given device.

Consulting both about the assigned output will make OSDs pop up
again in the right place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
2020-03-25 19:09:32 +00:00
Carlos Garnacho
dcaa45fc0c backends/x11: Implement is_grouped for X11
If the devices have a wacom description, compare those. Otherwise,
look up the devices' VID:PID, if they match they should also be
grouped.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
2020-03-25 19:09:32 +00:00
Carlos Garnacho
3c4f5ddcb4 core: Let pad mode switch events always go through MetaInputSettings
We used to inhibit all pad actions while the OSD is shown, but one we
would actually want to handle are mode switches while the OSD is open.
So it has an opportunity to catch up to the mode switch.

This lets MetaInputSettings reflect the mode switch (eg. when querying
action labels), so the OSD has an opportunity to update the current
actions.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/975
2020-03-25 19:56:09 +01:00
Florian Müllner
d4c070da88 window: Really propagate effective on-all-workspaces setting to transients
Commit cda9579034 fixed a corner case when setting the initial workspace
state of transient windows, but it still missed a case:

should_be_on_all_workspaces() returns whether the window should be on all
workspaces according to its properties/placement, but it doesn't take
transient relations into account.

That means in case of nested transients, we can still fail the assert:

 1. on-all-workspaces toplevel
 2. should_be_on_all_workspaces() is TRUE for the first transient's parent,
    as the window from (1) has on_all_workspaces_requested == TRUE
 3. should_be_on_all_workspaces() is FALSE for the second transient's
    parent, as the window from (2) is only on-all-workspace because
    of its parent

We can fix this by either using the state from the root ancestor
instead of the direct transient parent, or by using the parent's
on_all_workspaces_state.

The latter is simpler, so go with that.

https://gitlab.gnome.org/GNOME/mutter/issues/1083
2020-03-24 18:15:33 +00:00
Carlos Garnacho
d052f9c070 backends: Drop internal WacomDevice in MetaInputSettings
Use the one from MetaInputDevice instead. Since we no longer try
to ask for WacomDevices that weren't first retrieved:

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1086

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
3b88af94e3 backends/x11: Drop internal WacomDevice lookups
Just use the ones from MetaInputDevice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
1f00aba92c backends: Add MetaInputDevice derivable class
This class sits between ClutterInputDevice and the backend implementations,
it will be the despositary of features we need across both backends, but
don't need to offer through Clutter's API.

As a first thing to have there, add a getter for a WacomDevice. This is
something scattered across and somewhat inconsistent (eg. different places
of the code create wacom devices for different device types). Just make it
here for all devices, so users can pick.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
ec1195e3ff backends: Fix configuration changes to tap[-and-drag]
Most people just see a harmless warning when applying this setting to
all touchpads (which this patch fixes). But tap[-and-drag] is supposed
to remain enabled for display-less Wacom tablets, despite configuration
changes.

Fix this by using the mapping function, so the setting is forced on for
wacom devices. This happens on a per-device basis, so the warning is
gone too.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1145
2020-03-24 17:05:12 +00:00
Carlos Garnacho
18b661cc93 backends: Add mapping function arg to settings_set_bool_setting()
This will be useful to actually determine on a per-device basis the
setting being applied, while still doing changes on a per-device-type
basis.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1145
2020-03-24 17:05:12 +00:00
Carlos Garnacho
8592a8591b wayland: Handle NULL preedit text
The preedit text may be NULL (eg. when unsetting it). This started
causing crashes since commit db9b60cc63, duh.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1132
2020-03-24 16:07:44 +00:00
Peter Hutterer
7fa7c2aeb7 backends: use the enum name instead of a literal 0
No functional change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1144
2020-03-24 15:46:43 +10:00
Robert Mader
41130b08eb surface-actor: Add culling offset for geometry scale
This fixes a case that was overlooked in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1036 - when we
have a geometry scale > 1 and Wayland subsurfaces that have an offset
to their parent surface (which is often the case when the toplevel surface
includes decoration/shadows etc.), we have to add extra offset to their
opaque regions so they match their 'visible' location.

This is necessary as `meta_cullable_cull_out_children` moves the coordinate
system during culling, but does not know about geometry scale.

Also, remove the redundant check for `window_actor` - we only hit this code
path if a `window_actor` culls out its children.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1108
2020-03-23 20:28:59 +01:00
Robert Mader
1d20045247 surface-actor: Fix memory leak
When we create a new region for an opaque texture we need to free it.
While on it, simplify the check slightly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1108
2020-03-23 18:10:28 +00:00
Carlos Garnacho
c131a9b7fa backends/x11: Observe multiple pad mode switch buttons in a group
Some tablets like the Cintiq 24HDT have several mode switch buttons
per group. Those are meant to jump straight to a given mode, however
we just handle cycling across modes (as most other tablets have a
single mode switch button per group).

So spice up the mode switch handling so we handle multiple mode
switch buttons, assigning each of them a mode. If the device only
has one mode switch button, we do the old-fashioned cycling.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/970
2020-03-20 21:30:30 +01:00
Carlos Garnacho
2ecbf6d746 x11: Handle windowing errors while writing selection INCR data
This error was just logged but not raised. Do as the code comment said
and raise a pipe error at that moment, and for subsequent operations
on the output stream (although none besides close() should be expected
after propagating the error properly).

Related: https://gitlab.gnome.org/GNOME/mutter/issues/1065
2020-03-20 16:14:07 +01:00
Jonas Ådahl
0a6034ef3a monitor-manager: Remove 'mirror' capability
With per-CRTC views, there is nothing stopping NVIDA EGLStream based
rendering to not support monitor mirroring, so lets remove that
restriction.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1098
2020-03-18 00:46:20 +00:00
Jonas Ådahl
c9a5b2b22f kms-impl-simple: Handle lack of cached mode set in flip fallback
When a page flip fails with a certain error code, we've treated this as
a hint that page flipping is broken and we should try to use mode
setting instead.

On some drivers, it seems that this error is also reported when there
was no mode set, which means we'll have no cached mode set to use in the
fallback. The lack of prior mode set tends to happen when we hit a race
when the DRM objects change before we have the time to process a hotplug
event.

Handle the lack a missing mode set in the flip fallback path, with the
assumption that we'll get a hotplug event that'll fix things up for us
eventually.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/917
2020-03-18 00:33:03 +00:00
Carlos Garnacho
db9b60cc63 wayland: Represent preedit string cursor offset in bytes
Both IBus and ClutterInputFocus work in character offsets for the cursor
position in the preedit string. However the zwp_text_input protocol does
define the preedit string cursor offset to be in bytes.

Fixes client bugs in representing the caret within the preedit string,
as we were clearly giving the wrong offset.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2517

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1132
2020-03-17 22:15:52 +00:00
Jonas Ådahl
fa74da0039 wayland/window: Ignore state changes for popups
We send configure events for state changes e.g. for `appears-focused`,
etc. What we don't want to do is to do this for popup windows, as in
Wayland don't care about this state.

When the focus mode was configured to "sloppy focus" we'd get
`appears-focused` state changes for the popup window only by moving the
mouse cursor around, and while a popup may care about focus, it does not
care about related appearance, as there is no such state in xdg_popup.

What these state changes instead resulted in was absolute window
configuration events, intended for toplevel (xdg_toplevel) windows. In
the end this caused the popup to be positioned aginst at (0, 0) of the
parent window, as the assumptions when the configuration of the popup
was acknowledged is that it had received a relative position window
configuration.

Fix this by simply ignoring any state changes of the window if it is a
popup, meaning we won't send any configuration events intended for
toplevels for state changes. Currently we don't have any way to know
this other than checking whether it has a placement rule. Cleaning up
MetaWindow creation is left to be dealt with another day.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1103

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1122
2020-03-17 21:59:02 +00:00
Robert Mader
4133b73632 cursor-renderer/native: Skip hw cursor upload if we can't use it
If the CRTCs the cursor is visible on do not share a common scale
and transform, we can't use the cursor hardware plane as we only have one.
We therefore fall back to software / gl cursor.

The check for that currently happens after we tried to upload the cursor image
to the hardware plane though.
This is made worse by the fact that in the scaling step, where we scale the
cursor image to the desired size, until now we expected a valid common scale -
otherwise scaling the image by an uninitialized float.

Make sure we bail out early during the scale/upload step if we don't have common
scales and transforms - to avoid that bug and save some unnecessary work.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1125
2020-03-16 21:51:30 +01:00
Daniel van Vugt
074f4974dd input-settings: Specify middle-click-emulation key
Which exists, unlike `emulate-middle`.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1124
2020-03-16 15:09:00 +08:00
Andrew Gaul
0700f3749f input-settings/x11: Fix typo in has_udev_property
https://gitlab.gnome.org/GNOME/mutter/merge_requests/256
2020-03-15 13:04:32 +09:00
Andrew Gaul
0487e6f11f input-settings: Wire up middle-emulation
This allows emulating middle click via simultaneous left and right
click.  Fixes #238.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/256
2020-03-15 13:04:32 +09:00
Carlos Garnacho
23da6c2426 keybindings: Check the special modifiers specifically
Make sure it is only the special modifier (hardcoded to 1 currently)
which is being pressed (not counting locked modifiers) before notifying
that the special modifier is pressed, as we are interested in it being
pressed alone and not in combination with other modifier keys.

This helps in two ways:
- Pressing alt, then ctrl, then releasing both won't trigger the locate
  pointer action.
- Pressing alt, then ctrl, then down/up to switch workspace won't interpret
  the last up/down keypress as an additional key on top of the special ctrl
  modifier, thus won't be forwarded down to the focused client in the last
  second.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/812

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:37:32 +01:00
Carlos Garnacho
67dd0b4fec keybindings: Avoid double calls to process_event() on the same event
If you first press a key that triggers the "special modifier key" paths
(ctrl, super), and then press another key that doesn't match (yet?) any
keybindings (eg. ctrl+alt, super+x), the second key press goes twice
through process_event(), once in the processing of this so far special
combination and another while we let the event through.

In order to keep things consistent, handle it differently depending on
whether we are a wayland compositor or not. For X11, consider the event
handled after the call to process_event() in process_special_modifier_key().
For Wayland, as XIAllowEvents is not the mechanism that allows clients see
the key event, we can just fall through the regular paths, without this
special handling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:22:28 +01:00
Jonas Ådahl
5319949a45 kms-impl-device: Clean up state if drm resources disappear
It may happen that drmModeGetResources() starts returning NULL. Handle
this gracefully by removing all connectors, CRTCs and planes making the
device in practice defunct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1121
2020-03-12 13:08:46 +00:00
Alynx Zhou
aba0b9ef64 keybindings: Move common window grab code out of X-only if statement
`3c8d4171` moved some common codes into X11-only code blocks by mistake,
and it prevents keyboard window resize/move mode under Wayland because
those variables are unset. This commit fixed it via moving such common
codes out of X11-only code blocks.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/949

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/997
2020-03-12 08:42:04 +00:00
Jonas Ådahl
512bb7d1cd wayland: Don't crash when trying to fullscreen on inert wl_output
There is a race where an output can be used as a fullscreen target, but
it has already been removed due to a hotplug. Handle this gracefully by
ignoring said output in such situations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1120
2020-03-11 14:37:09 +00:00
Jonas Ådahl
d2a12ee0fa crtc-xrandr: Compare right coordinate when checking assignment
Compare x with x, and y with y, not y with x.

Fixes an issue where only changing the scale doesn't actually apply the
new scale.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1119
2020-03-11 13:02:50 +00:00
Jonas Ådahl
531a195cf1 monitor-config-manager: Respect layout mode when calculating CRTC layout
The scale used when calculating the CRTC layout should only come from
the logical monitor scale if the layout mode of the corresponding
configuration is 'logical'.

This fixes an issue where the X11 screen size accidentally got set to a
size scaled down by the configured global UI scale.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1107
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1109

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1118
2020-03-11 12:55:03 +00:00
Sebastian Keller
509e9ca5a0 xwayland: Fix mime type atom list leak on DnD with more than 3 types
Found using the clang static analyzer

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1117
2020-03-11 03:21:36 +01:00
Olivier Fourdan
0743381573 window/x11: Rename meta_window_x11_buffer_rect_to_frame_rect
To keep consistent and avoid confusion, rename the function:
    `meta_window_x11_buffer_rect_to_frame_rect()`
to:
    `meta_window_x11_surface_rect_to_frame_rect()`

As this function doesn't deal with the `window->buffer_rect` at all.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
267f712068 window-actor/x11: Use the new MetaShapedTexture API
The code in `build_and_scan_frame_mask` predates the introduction of the
`MetaShapedTexture` API to get the texture width hand height.

Use the new `meta_shaped_texture_get_width/height` API instead of using
the CoGL paint texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
0b102afb53 xwayland: Update regions on texture updates
For X11 clients running on Wayland, the actual texture is set by
Xwayland.

The shape, input and opaque regions, however are driven by X11
properties meaning that those may come at a different time than the
actual update of the content.

This results in black areas being visible at times on resize with
Xwayland clients.

To make sure we update all the regions at the same time the buffer is
updated, update the shape, input and opaque regions when the texture is
committed from when the Xwayland surface state is synchronized.

That fixes the remaining black areas being sometimes visible when
resizing client-side decorations windows on Xwayland.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1007
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
304a103659 window-actor: Add API to update regions
For X11 clients running on Xwayland, the opaque, input and shape regions
are processed from different properties and may occur at a different
time, before the actual buffer is eventually committed by Xwayland.

Add a new API `update_regions` to window actor to trigger the update of
those regions when needed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
2d09e95934 window-actor/x11: Compute client area from surface size
Commit 7dbb4bc3 cached the client area when the client was frozen.

This is not sufficient though, because the buffer size might still be
lagging waiting for the buffer from Xwayland to be committed.

So instead of caching the client size from the expected size, deduce the
client area rectangle from the surface size, like we did for the frame
bounds in commit 1ce933e2.

This partly reverts commit 7dbb4bc3 - "window-actor/x11: Cache the
client area"

https://gitlab.gnome.org/GNOME/mutter/issues/1007
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
be11525b28 window/x11: Add function to convert the surface to client area
Add a convenient function to get the client area rectangle from a given
surface rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Robert Mader
adc38f902a window-actor/X11: Update shape, input and opaque region in order
As they depend on each other to be correct, we should set all of them
in the correct order. As we do already have a function for that, use it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Pekka Paalanen
8abdf16a39 cursor-renderer/native: Handle GPU hotplug
Listen for GPU hotplug events to initialize their cursor support.

This fixes one reason for why DisplayLink devices may not be using a hardware
cursor. Particularly, when a DisplayLink device is hotplugged for the first
time such that EVDI creates a new DRM device node after gnome-shell has already
started, we used to forget to initialize the cursor support.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1097
2020-03-10 08:26:17 +00:00
Pekka Paalanen
4cc29cfb61 cursor-renderer/native: Refactor init to per-gpu
Extract the code to initialize a single GPU cursor support into its own
function. The new function will be used by GPU hotplug in the future.

This is a pure refactoring without any behavioral changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1097
2020-03-10 08:26:17 +00:00
Olivier Fourdan
50ff30bf2b xwayland: Log actual error message if available
If X11 initialization fails, print the actual error message if the error
is set, to help with debugging.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1102
2020-03-09 17:49:51 +00:00
Jonas Ådahl
26e1e495a0 screen-cast-stream-src: Don't leak GSource
For every stream src, we created and attached a GSource. Upon stream
src destruction, we g_source_destroy():ed the GSource. What
g_source_destroy() does, hawever, is not really "destroy" it but only
detaches it from the main context removing the reference the context had
added for it via g_source_attach(). This caused the GSource to leak,
although in a detached state, as the reference taken on creation was
still held.

Fix this by also removing our own reference to it when finalizing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1106
2020-03-09 17:31:23 +00:00
Jonas Ådahl
480e7d44be screen-cast-stream-src: Don't complain when we can't dequeue buffer
PipeWire will be unable to dequeue a buffer if all are already busy.
This can happen for valid reasons, e.g. the stream consumer not being
fast enough, so don't complain in the journal if it happens.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1115
2020-03-09 17:46:54 +01:00
Jonas Ådahl
6e966e47f2 cursor-renderer-native: Handle lack of cursor planes gracefully
While we will always have cursor planes, as we'll currently create fake
ones when real ones are missing (See #1058), eventually we will run into
situations where we can't create fake ones, for example for atomic KMS
drivers that don't advertise any cursor planes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1079
2020-03-07 21:40:50 +00:00
Jonas Ådahl
227eea1e31 kms-impl-simple: Add fake cursor planes if no real ones
Non-atomic drivers may support drmModeSetCursor() even if no cursor
plane is advertised. To deal with this, add a fake cursor plane for
every CRTC when using MetaKmsImplSimple. This will eventually be
translated to drmModeSetCursor() calls without any explicit cursor plane
usage.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1058

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1079
2020-03-07 21:40:50 +00:00
Jonas Ådahl
6cd0aa429f window: Force placement for first placement rule
If we don't force the placement, we enter the constrain machinery with
the position (0, 0), meaning we always get the "current work area" setup
to correspond to whatever logical monitor was at that position.

Avoid this by doing the same as "meta_window_force_placement()" and set
"window->calc_placement" to TRUE while move-resizing, causing the
move-resize to first calculate the initial position.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1098

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1110
2020-03-06 17:28:09 +01:00
Jonas Ådahl
f97804f4f4 wayland/xdg-shell: Add support for explicit popup repositioning
This commit completes the implementation of `xdg_wm_base` version 3,
which introduces support for synchronized implicit and explicit popup
repositioning.

Explicit repositioning works by the client providing a new
`xdg_positioner` object via a new request `xdg_popup.reposition`. If the
repositioning is done in combination with the parent itself being
reconfigured, the to be committed state of the parent is provided by the
client via the `xdg_positioner` object, using
`xdg_positioner.set__parent_configure`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
5c37f5104e wayland/xdg-shell: Add support implicit popup moving
This sets the `is_reactive` flag on the window placement rules, causing
the popups to be reconfigured as they are affected by environmental
changes, such as the parent moving in a way making the popup partially
offscreen.

As with synchronization, the implementation is dormant, as the
version of the advertised global isn't bumped yet, as the new protocol
version is not yet fully implemented.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
d08a8de265 window: Implement asynchronous popup moving
This commits adds support on the MetaWindow and constraints engine side
for asynchronously repositioning a window with a placement rule, either
due to environmental changes (e.g. parent moved) or explicitly done so
via `meta_window_update_placement_rule()`.

This is so far unused, as placement rules where this functionality is
triggered are not yet constructed by the xdg-shell implementation, and
no users of `meta_window_update_placement_rule()` exists yet.

To summarize, it works by making it possible to produce placement rules
with the parent rectangle a window should be placed against, while
creating a pending configuration that is not applied until acknowledged
by the client using the xdg-shell configure/ack_configure mechanisms.

An "temporary" constrain result is added to deal with situations
where the client window *must* move immediately even though it has not yet
acknowledged a new configuration that was sent. This happens for example
when the parent window is moved, causing the popup window to change its
relative position e.g. because it ended up partially off-screen. In this
situation, the temporary position corresponds to the result of the
movement of the parent, while the pending (asynchronously configured)
position is the relative one given the new constraining result.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
6c82feb1b8 wayland/window-configuration: Track resize flags and gravity too
Will later be used to determine in what way a pending configuration will
resize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
0dac91cffc Add MetaGravity and replace X11 equivalent with it
MetaGravity is an enum, where the values match the X11 macros used for
gravity, with the exception that `ForgetGravity` was renamed
`META_GRAVITY_NONE` to have less of a obscure name.

The motivation for this is to rely less on libX11 data types and macros
in generic code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
ff381d1d52 constraints: Pass constrained relative coordinates to window impl
A placement rule placed window positions itself relative to its parent,
thus converting between relative coordinates to absolute coordinates,
then back to relative coordinates implies unwanted restrictions for
example when the absolute coordinate should not be calculated againts
the current parent window position.

Deal with this by keeping track of the relative position all the way
from the constraining engine to the move-resize window implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
05e9d6ab9e window: Put placement related fields in a anynomous struct
To organize things a bit better, put the fields related to the placement
rule state in its own anonymous struct inside MetaWindow. While at it,
rename the somewhat oddly named variable that in practice means the
current relative window position.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
d22f947bf5 wayland/window: Pass popup configuration using relative coordinates
After popup placement rules have gone through the constraints engine has
ended up resulting in an actual move, pass the window configuration down
the path using relative coordinates, as that is what the next layer
(xdg-shell implementation) actually cares about.

In the future, this will also be helpful when the configured position is
not against the current state of the parent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
9b97e5ed58 place: Make placement rule processing provide relative coordinates
A placement rule is always about placing a window relative to its
parent. In order to eventually place it against predicted future parent
positions, make the placement rule processing output relative
coordinates, having the caller deal with turning them into absolute.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
7f9fac2ba2 window/wayland: Don't inhibit finishing moves if any window is resized
meta_window_wayland_finish_move_resize() inhibited window moves to be
finished if there was a resize grab active at the time, in order to
handle window resizing. Change this to only affect the grabbed window
itself, so that e.g. a popup can be positioned according to a pending
configuration while there is an active resize grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Carlos Garnacho
64eaf70279 xwayland: Allow setting up maintenance processes
This is made a signal, so the upper layers (read: gnome-shell) may
decide what services to spawn. The signal argument contains a task
that will resume MetaX11Display startup after it is returned upon.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
e3149e6021 wayland: Pass private X connection on GNOME_SETUP_DISPLAY
This envvar will be picked up by the services spawned together with Xwayland
startup, and used instead of the regular DISPLAY meant for regular clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
166a464515 wayland: Set up initialization X11 socket
This is used by GDK and the X11 bits, but may also be used for
other initialization services we might need to run along with
Xwayland initialization.

However, as the -initfd argument in Xwayland is a fairly new
feature, add some meson build-time checks so that the feature
is handled transparently while allowing to explicitly set/unset
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
38e58b837b core: Use DISPLAY envvar to forward in the launch context
The meta_x11_get_display_name() will return our private connection, which
is not what we want to transfer to clients being launched.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Robert Mader
39a8c047d1 background-actor: Do not copy empty clip/unobscured regions
Clip and unobscured regions stricly shrink during culling. If they
are already empty, simply reference the empty region to reduce allocations.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
c979cd95aa surface-actor: Do not copy empty clip/unobscured regions
Clip and unobscured regions stricly shrink during culling. If they
are already empty, simply reference the empty region to reduce allocations.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
6831f2edb4 window-actor/x11: Disable culling on window actor level
This shape region culling was wrongly implemented in f5a28aa9, as it
does not take frame offsets into account, and is also redundant, as
we already set the opaque region of the underlying surface accordingly.

The other parts were implemented in ac7aa114, the reason given in
the commit message:
```
Wayland clients do this through the opaque region in the surface
actor. However X11 clients were considered fully transparent for
culling purposes, which may result in mutter painting other bits
of the background or other windows that will be painted over in
reality.
```

is wrong though - culling on X11 actors works just fine and did only
not work in Wayland sessions because of a bug that got fixed in
19814497.

In conclusion the whole part appears to be redundand and some testing
done suggests the same. Drop it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
372d73e275 surface-actor: Cull out surfaces without alpha channel
If a opaque region is explicitly set we should not consider the surface
opaque, as that implies e.g. a shape region is set.

If no opque region is set but the texture does not have an alpha channel,
we can savely cull it out.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
0ada90024f wayland/actor-surface: Check for MetaXwaylandSurface instead of window type
The previous check would not ignore subsurfaces. Use the chance to directly
check for the surface role instead - it's much cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
worldofpeace
8a6673bb55 build: ensure absolute path to sysprof dbus interface dir
We want sysprof's exact datadir for compatability with
platforms where software is installed into their own
individual immutable prefix's. Such that, mutter's prefix will
never equate to sysprof's. This depends on a MR in sysprof [0]
which adds datadir to its pkgconfig files, as these files will always
have the proper path we want.

This adds version a constraint on sysprof_dep, as datadir was added to
the .pc in this version.

[0]: https://gitlab.gnome.org/GNOME/sysprof/merge_requests/19

https://gitlab.gnome.org/GNOME/mutter/merge_requests/957
2020-02-29 13:17:40 +01:00
Jonas Ådahl
390fd7ddcf cursor-renderer-native: Fix hw cursor for non-square sprites
wl_shm_buffer_get_width() was used where wl_shm_buffer_get_height()
should have used, resulting in only square cursors working. Make
rectangular cursors work again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1099
2020-02-28 21:49:58 +00:00
Carlos Garnacho
4b513a31ae compositor: Shuffle x11 compositing bits in MetaCompositor
Given that on Wayland we are pretty much guaranteed to finish MetaX11Display
setup after the MetaCompositor is enabled, we may drop the
meta_compositor_manage() x11 initialization bits, and move them into the
MetaX11Compositor subclass where it's actually needed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
25c9e66c73 xwayland: Do not block on Xwayland initialization
We artificially made Xwayland initialization synchronous, as we used
to rely on MetaX11Display and other bits during meta_display_open().
With support for Xwayland on demand and --no-x11, this is certainly
not the case.

So drop the main loop surrounding Xwayland initialization, and turn
it into an async operation called from meta_display_init_x11(). This
function is turned then into the high-level entry point that will
get you from no X server to having a MetaX11Display.

The role of meta_init() in Xwayland initialization is thus reduced
to setting up the sockets. Notably no processes are spawned from here,
deferring that till there is a MetaDisplay to poke.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
649911b6b3 core: Make meta_display_init_x11() an async function
This ATM completes the task right away, but we will want to do
further things here that are asynchronous in nature, so prepare
for this operation being async.

Since the X11 backend doesn't really need this, make it go on
the fast lane and open the MetaX11Display right away, the case
of mandatory Xwayland on a wayland session is now handled
separately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
8c332a4704 tests: Set fatal log handler on clutter tests
With Xwayland initialization going async, these errors will seep
into the parts controlled by g_test*(), resulting in the harmless
errors about DBus names not acquired turned fatal.

Set an error log handler, and specifically ignore those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
21994bb00d tests: Ensure MetaX11Display is initialized before running tests
It might not be available right on initialization time if X11 is started
asynchronously. As this is a requirement for our tests, ensure it is there
before proceeding with the test.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
87a06c63ad x11: Set up the compositing manager selection on meta_display_init_x11()
This used to be set on meta_compositor_manage(), but only if there is a
MetaX11Display. Given meta_display_init_x11() is Wayland only, and we can
always assume compositing to be enabled, just have it invariably set after
the X server is up.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Georges Basile Stavracas Neto
09026e5f0e monitor-stream-src: Use cogl_framebuffer_finish()
Even though cogl_framebuffer_flush() was supposed to be enough,
it ends up creating streams with odd visual glitches that look
very much like unfinished frames.

Switch back to cogl_framebuffer_finish(), which is admittedly
an overkill, but it's what works for now. There is anedoctal
evidence showing it doesn't incur in worse performance.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
1f190a7cfe screen-cast-stream-src: Remove unused parameter
The 'data' parameter is not used in maybe_record_cursor(), so remove
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
86168b945c window-stream-source: Draw into DMA buffer image
Much like monitor streaming, implement window streaming by
making the window actor draw itself with a paint context
that used the passed framebuffer.

Now that all MetaScreenCastStreamSrc subclasses implement
blit_to_framebuffer, remove the conditional check from
meta_screen_cast_stream_src_blit_to_framebuffer().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
680a54aff6 monitor-stream-src: Implement blitting view framebuffers
Add the vfunc override that actually consume the new Cogl API. Every
view that fits into the logical monitor is rendered.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/639

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:03 -03:00
Georges Basile Stavracas Neto
548073ec27 screen-cast-stream-src: Support DMA buffer sharing
Implement PipeWire's add_buffer and remove buffer, try and export
a DMA buffer first and, on failure, fallback to memfd.

When DMA buffers are successfully created and shared, blit the
framebuffer contents when drawing instead of downloading the pixels.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:29:03 -03:00
Georges Basile Stavracas Neto
d366fb335d renderer-native: Implement DMA buffer creation
Create a new gbm_bo using the same given geometry, and export the new
bo's DMA buffer fd. The new bo lives as long as necessary to be used,
and reused, by PipeWire.

Unfortunately, PipeWire doesn't support modifiers properly, so use the
linear format for now. For now, a hardcoded format of DRM_FORMAT_XRGB8888
is set, so we don't need to negotiate the format with PipeWire early.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:29:02 -03:00
Georges Basile Stavracas Neto
7fbb47b2bb renderer-native: Move DMA buffer creation to an auxiliary function
This will be reused by the DMA buffer exporting function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:28:22 -03:00
Robert Mader
969ad54feb cursor-renderer/native: Remove unnecessary endian check
Both cases have the same content.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
987ce5bec0 cursor-renderer/native: Implement scaled/transformed hardware cursors
If the cursor sprite does not match the scale factor or transformation
of the monintor, we currently fall back to a software cursor, causing
redraws of the shell. This commit implements scaling and transforming
of the cursor sprite, so we can use it with hardware planes, too.

This commit does the following steps:

1. Make sure we reupload the cursor image if the cursor is over
a logical monitor not matching the scale or transform from the previous
update.
2. Before upload to the hardware plane, scale and transform the cursor
image if possible and necessary.
3. Make sure we always use the hardware cursor if possible (only fall
back to software/OGL cursor if it is visible on multiple logical monitors
with differet scales/transforms).
4. Transform or scale the cursor coordinates if necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
d600cd9aee monitor-transform: Add generic function to get relative transform
It takes transforms A and B and returns the transform to get from
A to B.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
1fc7935858 backends/cursor: Add API to set and get the texture buffer transform
In Wayland clients can commit transformed surfaces, so the compositor
can directly use them on hardware planes. We already support that
for other surfaces, this is the first step to also support it on
cursor sprites.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Jonas Ådahl
01aaced129 crtc: Don't leak MetaCrtcConfig
We never freed it except when CRTC disabled during runtime.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1095
2020-02-27 20:35:07 +00:00
Jonas Ådahl
ff59b5d041 monitor: Move logical <-> CRTC transform helpers to MetaOutput
So that we avoid leaking the internal guts of MetaOutput into
MetaMonitor, while also making it possible to use it without a
MetaMonitor at hand.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:47:22 +01:00
Jonas Ådahl
92f0eb9d14 monitor: Use transform helper when dealing with panel orientation
Replace the open coded monitor transform math with the new helper.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:47:08 +01:00
Jonas Ådahl
e6913d1471 monitor-transform: Add meta_monitor_transform_transform() helper
Intended to replace various manual monitor transform enum math here and
there. Tests added as well, to test some hand picked transforms.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:07:25 +01:00
Carlos Garnacho
88bb24f66e backends/native: Shuffle udev client initialization in MetaSeatNative
This may be used indirectly before creation as we dispatch libinput events
right after creation (to let input devices be known), so those device
additions would trigger the touch-mode checks.

Creating it in advance results in checks being correctly performed, although
redundantly.

Spotted by Bastien Nocera.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1067
2020-02-26 18:32:05 +00:00
Arun Raghavan
6e7316ef11 build: Use dbus interface dir from pkg-config
Using 'datadir' breaks prefixed builds (as we look for interface files
in the prefix we are going to install to).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1094
2020-02-26 15:37:00 +00:00
Jonas Ådahl
9fa56176fd monitor-manager-xrandr: Don't try to disable disabled CRTC
When applying a configuration to XRANDR, we first disable CRTCs that
happen to extend outside of the to-be X11 screen size. While doing so,
we fail to actually check whether the CRTC is active or not, meaning
we'll try to query the content of the CRTC configuration even though it
has none, leading to a NULL pointer dereference.

Fix this by simply ignoring non-configured CRTCs.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1093
2020-02-26 16:14:04 +01:00
Jonas Ådahl
fe1ccea1e1 clutter: Pass redraw clip via paint context
Instead of users fetching it via `clutter_stage_get_redraw_clip()`, pass
it via the paint context. This is helpful as it is only valid during a
paint, making it more obvious that it needs to be handled differently
when there is no redraw clip (i.e. we're painting off-screen).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
c483b52d24 clutter/stage: Pass redraw clip instead of extents when painting view
That's the struct we have ready, the callee can just call
cairo_region_get_extents() if it only cares about the extents rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
2d6665950c crtc: Move logical monitor pointer to MetaMonitor
Since the last code fetching the logical monitor state directly from the
CRTC has been removed, we can move the logical monitor pointer to a more
natural place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1c98f01a65 renderer-native: Draw stage separately per CRTC
Prior to this commit the stage was drawn separately for each logical
monitor. This allowed to draw different parts of the stage with
different transformations, e.g. with a different viewport to implement
HiDPI support.

Go even further and have one view per CRTC. This causes the stage to
e.g. draw two mirrored monitors twice, instead of using the same
framebuffer on both. This enables us to do two things: one is to support
tiled monitors and monitor mirroring using the EGLStreams backend; the
other is that it'll enable us to tie rendering directly to the CRTC it
will render for. It is also a requirement for rendering being affected
by CRTC state, such as gamma.

It'll be possible to still inhibit re-drawing of the same content
twice, but it should be implemented differently, so that it will still
be possible to implement features requiring the CRTC split.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
e3f30371aa renderer-native: Fix a couple of style misses
Removed stray newline, and fixed an incorrect indentation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1a14c4d3c9 renderer-x11-nested: Remove stray newline
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
fe42d56db3 crtc: Move configured state to separate struct
To make it more reliable to distinguish between values that are read
from the backend implementation (which is likely to be irrelevant for
anything but the backend implementation), split out those values (e.g.
layout).

This changes the meaning of what was MetaCrtc::rect, to a
MetaCrtcConfig::layout which is the layout the CRTC has in the global
coordinate space.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
a11f9bd513 boxes: Add 'round' rounding strategy
It just calls roundf(), and is intended to be used when the graphene
rectangle is approximately integer aligned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
7f6cafa847 logical-monitor: Pass monitor in the for each CRTC helper callback
Will be used in later commits.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1b67f49f7f monitor: Move logical to CRTC transform helper to MetaOutput
So that it can be used on a per output basis in the future.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Dreßler
b98ebe60b2 clutter/x11: Stop tracking stage changes on crossing events
On x11 we emulate pointer events from touch events as long as there's
only one touchpoint on screen, this obviously leads to x11 sending us
crossing events triggered by the emulated pointer. Now if we get a leave
event and set the stage of the ClutterInputDevice to NULL, new touch
events will be discarded by clutters backend because the core pointer
doesn't have a stage associated. This means Mutter completely loses
state of a touchpoint as soon as it crosses a shell actor.

An easy reproducer for this issue is to start the four-finger-workspace
gesture above a window and to move the pointer emulating touch outside
of the window, this will freeze the gesture as the gesture no longer
receives touch events.

To fix this, stop tracking stage changes on crossing events and simply
leave the ClutterInputDevice stage as-is. In our case there is only one
stage anyway and that won't change in the future.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/423
2020-02-24 10:54:56 +00:00
Jonas Dreßler
ad8ba69423 wayland/pointer: Use g_signal_connect_swapped for one signal
Remove the rather useless callback function that's currently used for
handling the "visibility-changed" signal and instead connect to the
signal using `g_signal_connect_swapped()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Dreßler
bf24b816c2 wayland/pointer: Add support for the new ClutterSeat inhibit-unfocus API
The last commit added a new API to ClutterSeat to inhibit setting the
focus-surface of the MetaWaylandPointer to NULL, let's do that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Ådahl
2da27720ca display: Make check-alive timeout configureable
The check-alive feature is there for the user to be able to terminate
frozen applications more easily. However, sometimes applications are
implemented in a way where they fail to be reply to ping requests in a
timely manner, resulting in that, to the compositor, they are
indistinguishable from clients that have frozen indefinitely.

When using an application that has these issues, the GUI showed in
response to the failure to respond to ping requests can become annoying,
as it disrupts the visual presentation of the application.

To allow users to work-around these issues, add a setting allowing them
to configure the timeout waited until an application is considered
frozen, or disabling the check completely.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1080
2020-02-23 17:28:57 +00:00
Olivier Fourdan
f9326cfa3d wayland/data-device: Fix crash with offer from X11 client
If a data offer comes from an X11 client, the Wayland resource would be
NULL, causing a crash in `data_offer_choose_action()` trying to get the
resource version.

So instead of doing the version check in `data_offer_choose_action()`,
do it early when creating the data source.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1057
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:16 +00:00
Olivier Fourdan
963108a9a6 wayland/data-device: Check resource version on cancel
For clarity, check the resource version needs the "cancelled" message in
the actual vmethod rather than from the caller function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:15 +00:00
Olivier Fourdan
b8355a6686 xwayland: Not all xwayland surface have a window
`meta_xwayland_surface_get_relative_coordinates()` may cause a crash if
the Xwayland surface has no window associated.

That can be observed when using drag and drop from an X11 window to a
Wayland native window:

```
    at src/core/window.c:4503
    at src/wayland/meta-xwayland-surface.c:200
    at src/wayland/meta-wayland-surface.c:1517
    at src/wayland/meta-wayland-pointer.c:1048
    at src/wayland/meta-wayland-pointer.c:840
    at src/wayland/meta-wayland-pointer.c:865
    at src/wayland/meta-wayland-pointer.c:954
    at src/wayland/meta-wayland-pointer.c:456
    at src/wayland/meta-wayland-pointer.c:993
    at src/wayland/meta-wayland-data-device.c:1004
    at src/wayland/meta-wayland-data-device.c:1278
    at src/wayland/meta-xwayland-dnd.c:326
```

Check if the xwayland surface has an associated MetaWindow prior to get
its buffer rect.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:15 +00:00
Christian Hergert
4c421959dc clutter: fix hole in ClutterPaintNode
Fixing the missalignment takes the structure from 80 bytes down to 72.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1081
2020-02-21 22:36:31 +00:00
Sebastian Keller
aedcfcd010 sound-player: Fix invalid write after playback is cancelled early
The cancellable of a request might already be cancelled by the time
the cancelled_cb is connected resulting in finish_cb being called via
ca_context_cancel before g_cancellable_connect returns. In this case
the request that is written to has already been freed.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1060
2020-02-21 16:06:18 +00:00
Jonas Dreßler
41d72e86e0 backends/native: Also check touch-mode on object initialization
On a Surface Pro 2017, touch-mode is currently only detected correctly
after detaching and attaching the Type Cover (detachable keyboard) once,
it seems that `has_external_keyboard` is only set to the correct value
after MetaSeatNative is initialized.

So fix that and call `update_touch_mode()` once again when the object is
initialized and the `has_external_keyboard` and `has_touchscreen`
properties have been finally updated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1075
2020-02-21 15:24:58 +00:00
Daniel van Vugt
282b09c17e clutter/actor: Add CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE
Which offscreens actor rendering only in cases where it hasn't changed for
2 frames or more. This avoids the performance penalty of offscreening an
actor whose content is trying to animate at full frame rate. It will
switch automatically.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1069
2020-02-21 18:07:46 +08:00
Wim Taymans
c5d2fc856a screen-cast: Update to PipeWire 0.3 API
Update to 0.3 API

[jadahl: update Dockerfile to include new enough pipewire]

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1051

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1062
2020-02-20 18:45:31 +01:00
Robert Mader
f5a28aa9e4 window-actor: Make culling of opaque windows X11 only
It is only useful for clients that do not set an opaque region but
still can be detected as being opaque. This is helpful for X11 clients
as opaque regions only got introduced around 2012 and only as part of EWMH
and are thus not used in many cases.
On Wayland however opaque regions have been part of the core protocol from the
beginnig and we can assume they are used more commonly.

As the current implementation in `MetaWindowActor` does not handle Wayland
subsurfaces well, instead of adding more complexity just move it to
`MetaWindowActorX11`.

While on it, take the shape region into account that is set when clients
use the X Nonrectangular Window Shape Extension Protocol, so we have exact
culling with those clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1058
2020-02-20 15:57:51 +00:00
Jonas Ådahl
a209a14898 renderer-native: Use hardware acceleration check in generic layer
No need to duplicate it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
3e6a55aff0 renderer: Add API to check whether renderer is hardware accelerated
Also expose an introspected variant via the MetaBackend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
704fea6323 renderer-native: Move 'backend' field to MetaRenderer
So that it can be used by the generic MetaRenderer class, as well as
other sub types, as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
8c1e6ebde0 remote-access-handle: Expose disable-animations property
Set to TRUE if a screen cast session asked for animations to be
disabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
81512ad0dc screen-cast-session: Add 'disable-animations' property
Allow screen casters (e.g. VNC remote desktop services) to ask for
animations to be inhibited, in order to lower the number of frames sent
over the network.

Currently only sets a field on the screen cast session object. Later
it'll be exposed via the remote access handle and via D-Bus by
gnome-shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
44ae38599f wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.

With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.

Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
df642eb150 wayland: Move calc-showing window logic to roles having windows
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
722ae2b77a wayland/surface: Let roles set DND functions
The DND functions are role specific, with Xwayland surface being the
special one. Let the roles set it instead of having per role like logic
in MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
54194e67e3 wayland/surface: Move relative coordinate calculating to roles
The role determines how a relative coordinate is calculated. More
specifically, using clutters API to transform coordinates is only
accurate right after a clutter layout pass but this function is used
e.g. to deliver pointer motion events which can happen at any time. This
isn't a problem for Wayland clients since they don't control their
position, but X clients do and we'd be sending outdated coordinates if a
client is moving a window in response to motion events.

This was already done already, but now move the Xwayland specific logic
to the Xwayland surface role, keeping the generic transformation logic
in the generic actor surface role.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
c0c74484bc wayland: Don't access MetaWaylandSurface::window directly
It'll be moved to the role owning it, accessed via a helper function
implemented by the role. Currently it still just fetches the field in
MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
5149e1e43a wayland: Move tree updating to the shell surface role
The shell surface role is the one where subsurfaces may exist, and it
has direct relation to the MetaWindowActorWayland which currently has
the subsurface stacking logic.

Instead of directly finding the window actor when dealing with
subsurfaces, notify the parent surface that the subsurface state
changed, so that it can outsource the application of this information to
the role. For subsurface roles, this simply means forward upward to the
parent; for shell surface roles, this means regenerate the surface actor
layering.

This allows us to move away from accessing the window directly from the
surface, which in turn allows us to change the ownership structure of
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
ac2c870177 surface-actor: Remove get_window() API and vfunc
It was unused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
f21595687f xwayland: Move out surface role related logic
Does some needed naming cleanup while at it, to be more similar to other
role types.

In short, MetaWaylandSurfaceRoleXwayland was changed to
MetaXwaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Dreßler
e51279dcf0 display: Only send one ping to a window at a time
If a window already is being pinged, it doesn't make sense to send more
pings to the window, instead we should just wait for that answer or
timeout until we send a new one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
9b58033375 display: Make sure ping serials are never reused
Using a timestamp twice in a row (e.g. when activating two windows in
response to the same event or due to other bugs) will break the window
detection and show a close dialog on the wrong window. This is a grave
error that should never happen, so check every timestamp before sending
the ping for uniqueness and if the timestamp was already used and its
ping is still pending, log a warning message and don't send the ping.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
0bf9727a31 display: Fix intendation of an argument and add details to a warning
https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
d053ccfb18 window: Check window responsiveness on every window focus
Increase the number of checks whether a window is still responsive and
ping windows on every call to `meta_window_focus()` instead of
`meta_window_activate_full()`. This ensures the window is also pinged in
case normal interaction like clicks on the window happen and a close
dialog will eventually get shown.

Related https://gitlab.gnome.org/GNOME/mutter/issues/395

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
7cc02cf24e backends/native: Replace tabs with spaces
Replace the few remaining places where tabs are used for indentation
with spaces.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Jonas Dreßler
e07478f8bc virtual-input-device/native: Fix warning message
We want to log the evdev keycode here, not the Clutter one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Jonas Dreßler
efe1bc2e59 util: Add INPUT debug topic
Allow debugging input issues more easily by adding an INPUT debug topic.
Currently there are only debug messages for the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Sebastian Keller
b45b03b063 surface-actor-x11: Avoid flicker when (un)redirecting windows
Currently when a window is requested to be unredirected, the
corresponding pixmap and texture can get cleared before the window has
been unredirected by the X server. This can result in the windows behind
showing through which causes a short flicker after showing an OSD or
notification when a fullscreen application is running.
Fix this by ensuring the texture is only cleared after the window has
been unredirected by the server.

Similarly when the window is being redirected again, the pixmap of the
window can only be requested after the redirection has been completed by
the server. This currently can happen in a different frame than the next
redraw of the actor resulting in an empty texture until the next redraw.
Fix this by queuing a redraw immediately after redirecting.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/997
2020-02-18 22:49:01 +00:00
Jonas Ådahl
c06fae4741 window-actor: Don't show actor until meta_window_actor_show()
By default clutter will show an actor as it is added to a parent. This
means that after we create the window actor, when it's added to the
window group, we implicitly show it. What we really want is to not show
it until the window is supposed to be shown, which happens when
meta_window_actor_show() is called, as showing prior to that, could
cause issues.

Avoid the implicit show by setting the "show-on-set-parent" property on
the window actor to `FALSE` on window actor construction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1066
2020-02-18 23:04:49 +01:00
Olivier Fourdan
76e0d7293d window-actor/x11: Update opaque region
Now that the opaque region is not reset by the Wayland actor surface, we
need to update the opaque region just like we do for input region.

That fixes a regression with client-side decoration X11 windows running
in Xwayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1060
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1043
2020-02-17 23:37:18 +00:00
Jonas Ådahl
0e0afa240e settings: Improve logging of enabled experimental features
We didn't log what we enabled, just g_info():ed what failed to be
enabled. Change this to g_warning() what failed to be enabled, and
g_message() on what was enabled, so that both will be visible in the
logs.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1061
2020-02-17 17:08:21 +00:00
Robert Mader
aceadfe305 cullable: Check if effects are disabled
Currently we skip culling actors if they have any effects set. But
effects can be disabled, in which case we don't need to do that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1052
2020-02-14 01:17:42 +01:00
Carlos Garnacho
1ecfdb1748 backends: Drop meta_idle_monitor_get_for_device()
As far as public API is concerned, there's only one idletime monitor
from now on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Carlos Garnacho
f7646af810 core: Do not update idle times for slave devices
Those go nowhere, so just avoid doing this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Carlos Garnacho
586723eb44 backends: Drop per-device idle monitors
We preserve the core one, which represents the union of all input
devices. It might make sense to make this per-seat in the future,
but certainly the per-device granularity is unused (at last!) and
useless.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Adam Jackson
5c704e3f81 cogl: Remove no-op cogl_shader_compile and cogl_shader_get_info_log
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1024
2020-02-12 21:55:44 +00:00
Robert Mader
1981449776 wayland/actor-surface: Do not set opaque region for XWayland clients
XWayland clients get their opaque region set from their window, not the
surface. Doing both resulted in the surface constantly overwriting the
opaque region - effectively disabling culling of XWayland clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1049
2020-02-12 01:52:38 +01:00
Olivier Fourdan
98d7a542b0 wayland: Advertise MetaMonitor as wl_output
With the logical size of outputs being handled by xdg-output, we don't
need to "lie" to Wayland clients anymore about the output size, so
advertise the real mode size as wl_output regardless of the scale, as it
should be (and like other Wayland compositors do).

https://bugzilla.gnome.org/show_bug.cgi?id=787363
https://gitlab.gnome.org/GNOME/mutter/merge_requests/994
2020-02-11 18:56:13 +00:00
Jonas Ådahl
438f75e6b3 cursor-renderer-native: Get cursor size from MetaKmsDevice
It now provides this information, so don't get it ourself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
f3cdc9906c kms/device: Handle tracking capabilities
Devices have capabilities that other parts need to know about. Instead
of having them probe using drmMode* API, outsource this to
MetaKmsDevice. Currently the only capability tracked is HW cursor size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ae00f5653e cursor-renderer-native: Port to transactional KMS api
Turns the cursor setting and movement into cursor plane assignment
primitives. In the current simple implementation, this in turn
translates into legacy drmModeSetCursor() and drmModeMoveCursor() calls.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
7c3172a0af kms/impl-simple: Add cursor plane processing
A cursor plane can now be assigned, and for the simple KMS
implementation, it'll translate into drmModeSetCursor() and
drmModeMoveCursor() calls.

When assignments failed, the cursor planes that failed to be assigned
are communicated via the feedback object.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
73dcb9fa22 kms: Make update processing return direct feedback
The current API as all synchronous, so they can be made to return
feedback immediately. This will be needed for the cursor renderer which
needs to know whether it should fall back to OpenGL cursor rendering.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
3ace2b9a28 kms/update: Move auto-cleanup declaration to the bottom
It relies on visible function declarations, so move it to the bottom so
we can add more auto-cleanup declarations same without them being spread
out.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
01bab81727 kms/update: Add flags to plane assignment
Currently unused, but will used to let the implementation know when it
can avoid setting the plane content (i.e. not call drmModeSetCursor()).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
c1fc46e3db kms/device: Fix indentation mistake
https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
4abec2f8e7 kms: Assert that callbacks are outside of the impl context
https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ee854ed7ab kms: Fix function name
meta_kms_update_process_..() makes it sound like it's a MetaKmsUpdate
function called update_..() but in fact it's a MetaKms function that
calls the corresponding process-update impl function. Clear up this
naming confusion.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ec9d7145c8 kms: Return gpointer from impl tasks
Currently only used to return either TRUE or FALSE to communicate
success or failure. Will be used to return feedback objects.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
3a8c545b32 kms/device: Add getter for finding cursor planes
Works the same as the getter for the primary planes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
6c1e9b51f9 kms-impl-simple: Add helper to process update entries
This avoids some loop iteration boiler plate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Jonas Ådahl
851024f730 kms/update: Add unassign_plane() API
Meant to disable a plane.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Jonas Ådahl
b23fc99655 kms/plane: Move _new() function to private header
Code outside of the MetaKms namespace is not expected to create plane
objects, so move it to a private header. More things will be added to
this header later.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Olivier Fourdan
0f58c98386 screen-cast-window: Use buffer bounds in place of frame bounds
The frame bounds as returned by `meta_window_actor_get_frame_bounds()`
would be used as cropping values when streaming a window content.

But, as its name implies, it returns the actual frame bounds, whereas we
may want to include the whole buffer, to include client side shadows for
example.

Rename the `get_frame_bounds()` API to `get_buffer_bounds()` (which was
previously partly removed with commit 11bd84789) and return the actual
buffer bounds to use as the cropping area when streaming a window.

Fixes: 931934511 - "Implement MetaScreenCastWindow interface"
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1018
2020-02-11 12:59:57 +00:00
Olivier Fourdan
ebc07871eb shaped-texture: Add get_width()/get_height() API
Add an API to retrieve the content size of a shaped texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
2020-02-11 12:59:57 +00:00
Olivier Fourdan
840c50b00d window-actor: Ensure clipping in capture_into()
The clip bounds passed in `meta_window_actor_capture_into()` represent
the actual allocated buffer size where the window actor image will be
eventually copied.

As such, it is completely agnostic to the scaling factors that might
affect the different surface actors which compose the window actor.

So instead of trying to compute the scale factor by which the given
clipping bounds need to be adjusted, simply clip the resulting image
based on the given bounds to make sure we never overflow the destination
buffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
2020-02-11 12:59:57 +00:00
Carlos Garnacho
e76ff8530b backends/native: Override the right property name
Fixup to https://gitlab.gnome.org/GNOME/mutter/merge_requests/1044,
clearly it's not enough to compile check after "just a minor rename".
2020-02-11 12:02:04 +01:00
Carlos Garnacho
c273f74025 backends: Implement ClutterSeat::touch-mode on MetaSeatNative
This taps on:
1) Touchscreen availability
2) Availability of external keyboards
3) Tablet mode switch, if existent

So we get this property enabled whenever it makes sense to show touch
focused features (eg. the OSK).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1044
2020-02-10 22:04:53 +00:00
Sergio Costas
5b1620475e Fix incorrect 'is' in gen_default_modes
During compilation, gen_default_modes.py shows two warnings that
say that a comparison is using 'is' instead of '=='.

This patch fixes this bug.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/985
2020-02-10 20:35:05 +01:00
Olivier Fourdan
934a829a57 wayland/subsurface: Keep subsurface actors reactive
The actors of Wayland subsurfaces are set to be reactive on creation,
when receiving the `wl_subcompositor.get_subsurface` request.

However, if a client creates several subsurfaces and then creates the
xdg_toplevel object after, the previous subsurface actors are reset.

As a result, Clutter picking will skip and ignore those actors in
`clutter_actor_should_pick_paint()` because they aren't marked as
reactive anymore.

An example of such a client being affected by this issue is SCTK, the
Rust library implementing client side decorations for Wayland used
internally by winit and alacritty.

Move the `set_reactive()` call from `get_subsurface()` to the subsurface
`sync_actor_subsurface_state()` vfunc to make sure those remain reactive
even after `xdg_surface.get_toplevel` is invoked.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1024
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1040
2020-02-10 08:51:41 +00:00
Robert Mader
264f68858a surface-actor: Implement meta_cullable_is_untransformed interface
Its `cull_out()` method was already implemented with geometry scale
in mind. Add a corresponding `is_untransformed()` method so culling
succeeds with geometry scale > 1.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-08 19:20:41 +01:00
Robert Mader
56ce25360c cullable: Factor out untransformed check into a vfunc
Some cullable implementation may have extra information about their
expected size. The main example here are surface actors which can be scaled
by geometry scale.

Add an API to overwrite the default size / untransformed check for such cases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-08 19:20:41 +01:00
Robert Mader
d8b7905662 surface-actor: Scale unobscured and clip region by geometry scale
The local copy of the clip- and unobscured region are used to optimize
painting. To get correct results when the actor is scaled, thus "grows",
the corresponding regions have to "shrink", i.e. get scaled down.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 19:22:15 +01:00
Robert Mader
ae1768bf4f wayland/actor-surface: Do not use geometry scale to constrain regions
The regions and the surface size are all in surface coordinates, thus
don't use the geometry scale, otherwise we might not clip scaled actors
enough.

See also https://gitlab.gnome.org/GNOME/mutter/merge_requests/148

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 18:05:49 +01:00
Robert Mader
cbef49fd74 shaped-texture: Remove unused meta-cullable header
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 18:05:49 +01:00
Hans de Goede
bcbb44fdea monitor-config-manager: honor accelerometer value changes when there is more than 1 monitor
Modify create_for_builtin_display_rotation to lookup the
MetaLogicalMonitorConfig for the panel in the logical_monitor_configs
list instead of only working when there is only 1 monitor.

The goal of this change is to honor accelerometer value changes when there is
more than 1 monitor.

Note, since create_for_builtin_display_rotation is also used for handling the
"rotate-monitor" hotkey and this commit modifies the common path of
create_for_builtin_display_rotation this means that we will now also honor
"rotate-monitor" hotkey keypresses when there is more than 1 monitor and
update the builtin display rotation instead of ignoring "rotate-monitor"
hotkey keypresses when there is more than 1 monitor. If this is deemed
undesirable this is easy to fix, but I believe that doing things this way
is more consistent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:55:39 +01:00
Hans de Goede
0d185b21fd monitor-config-manager: Add clone_logical_monitor_config_list helper
Add a clone_logical_monitor_config_list helper function for making a deep
copy of MetaLogicalMonitorConfig lists.

This is a preparation patch for honoring accelerometer value changes when
there is more than 1 monitor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:50:51 +01:00
Hans de Goede
e4d5cb72ee monitor-config-manager: Take device orientation into account for new configs
When creating a new config because of a monitor being (un)plugged or
because of super+p being pressed, honor the orientation reported by
the accelerometer for the internal panel.

Before this commit we would always configure the internal panel with
a normal / upright transform when e.g. an external monitor gets plugged
in even if another transform was in use before plugging in the external
monitor. This is inconsistent and causes problems for several use-cases.
This commit fixes this by querying the accelerometer when creating a new
config for an internal panel.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/707
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/924

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:46:45 +01:00
Hans de Goede
c37e2523ac orientation-manager: Do not change current orientation when locked
Bail out of sync_state() immediately if the orientation is locked, before
calling read_iio_prox() which updates the curr_orientation value.

There are 2 reasons for this change:

1. Currently meta-monitor-config-manager.c always assumes normal / upright
orientation when generating a new config. This means that e.g. when an
external monitor gets plugged in the builtin panel's transform will be reset
to normal / upright even if the device is not in an upright orientation.

To fix this meta-monitor-config-manager.c needs to call
meta_orientation_manager_get_orientation() to get the current orientation
when generating a new config. Without this change locking the orientation
would stop the emitting of "orientation-changed" signals but we would
still update the curr_orientation value. So when a new config needs to
be generated the latest orientation would be used, effectively ignoring
the "orientation-lock" setting, not updating curr_orientation when
locked fixes this.

2. This ensures we properly emit an an "orientation-changed" signal when
the orientation has changed between when it was locked and it was
unlocked. Before this change if the user locked the orientation, changed it
and then unlocked it, no signal would be raised as we would already have
updated the curr_orientation value turning the sync_state() call in
orientation_lock_changed() into a no-op.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:46:45 +01:00
Daniel van Vugt
06dae3a8cc wayland-pointer: Bail unconditionally if without native backend
Using `-Dnative_backend=false` caused build failure due to a missing
(implicit) definition of `META_IS_BACKEND_X11`. But if we define it
properly then that just leaves some of the function's locals uninitialized
and it will never work anyway. Just return unconditionally if there's no
native backend to initialize the variables.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1025
2020-02-05 18:09:34 +08:00
Daniel van Vugt
76240e24f7 background: Scale monitor_area after texture creation
Scaling the `monitor_area` before texture creation was just wasting
megabytes of memory on resolution that the monitor can't display. This
was also hurting runtime performance.

Example:

  Monitor is natively 1920x1080 and scale set to 3.

  Before: The monitor texture allocated was 5760x3250x4 = 74.6 MB
  After:  The monitor texture allocated is  1920x1080x4 =  8.3 MB

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/2118

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1004
2020-02-04 19:48:01 +00:00
Olivier Fourdan
9b0392e988 backends/native: Emit signals for virtual devices
When creating a virtual device for the native backend, no "device-added"
is emitted.

Similarly, no "device-removed" signal is emitted either when the virtual
device is disposed.

However, the backend plugs into the "device-added" signal to set the
monitor device. Without the "device-added" signal being emitted, the
monitor associated with a virtual device remains NULL.

That later will cause a crash in `meta_idle_monitor_reset_idlettime()`
called from `handle_idletime_for_event()` when processing events from a
virtual device because the device monitor is NULL.

Make sure to emit the "device-added" signal when creating a virtual
device, and the "device-removed" when the virtual device is disposed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1037
2020-02-04 18:26:52 +01:00
Florian Müllner
aa0aa89a1e window: Ignore requests to be placed on non-existent workspaces
When an X11 window requests an initial workspace, we currently trust
it that the workspace actually exists. However dynamic workspaces
make this easy to get wrong for applications: They make it likely
for the number of workspaces to change between application starts,
and if the app blindly applies its saved state on startup, it will
trigger an assertion.

Make sure that we pass valid parameters to set_workspace_state(),
and simply let the workspace assignment fall through to the default
handling otherwise.

https://gitlab.gnome.org/GNOME/mutter/issues/1029
2020-02-04 00:07:54 +00:00
Robert Mader
b91d66bf98 core: Extend list of image formats to be stored in the clipboard manager
These types are probably common enough to support.

See also:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1034
2020-02-03 16:51:15 +01:00
Carlos Garnacho
832c0fb0ea core: Define specific image formats to be stored in the clipboard manager
And order those preferences in order of lossiness (jpeg < png < bmp). This
avoids us from prefering other formats that are not useful or widely
recognized.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/939
2020-02-03 13:19:00 +00:00
Carlos Garnacho
2fbbf657d5 core: Demote image formats' priority from preservation in clipboard manager
Most usually, applications either expose clipboard content either as text
or as images, so the prioritization here is pointless. However there's some
outliers like LibreOffice Calc which exports content as both image and text
formats (besides other internal ones).

In that mixed case, we probably prefer to keep text formats, rather than
image based ones.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/919
2020-02-03 13:19:00 +00:00
Sebastian Keller
81de2c2913 backends/x11: Fix use after free on device removal
The devices_by_id hash table is responsible for managing the reference
to the devices. In remove_device however, for non-core devices there are
additional calls to dispose/unref, after the last reference has
already been dropped by the hash table.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1032
2020-02-01 15:35:49 +00:00
Carlos Garnacho
ffad55c66f wayland: Handle dragging from/dropping to v1 data device users
Interoperation between wl_data_device_manager v1 and v3 got broken
at some point. Ensure that we resort to the "copy" action if either
the drop site or the drag source are from a client that requested v1.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/965
2020-02-01 15:14:52 +00:00
Sebastian Keller
98040e67a2 core: Fix task leak in meta_selection_source_memory_read_async
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
e7928ce6ee selection: Fix task leak in error case of source_read_cb
Fixes the last part of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
b41094ef5f x11-selection: Unref owners and cancellables on shutdown
Selection owners are set using g_set_object in source_new_cb, but that
reference is never removed on shutdown.

Similarly the cancellables created in handle_xfixes_selection_notify are
never freed on shutdown.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
d699c80ac2 display: Unref selection on shutdown
Otherwise it will be leaked and the dispose method added in the previous
commit would never be run.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
35316a034f selection: Unref selection owners on dispose
Selection owners are set using g_set_object, which adds a reference to
the owner, which then never was removed on shutdown.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
c05019e232 x11-selection: Don't store copies of strings that are not being used
MetaX11SelectionOutputStream was storing copies of strings only to use
them in init and then free them in finalize. This was also causing a
small leak, because one of these strings was not freed. Instead of doing
that just don't create these unnecessary copies in the first place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
861e5caf8c x11-selection: Plug potential GInputStream leak
The stream was not freed in the error case. I have never observed this
one in practice though.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
8e6821bc65 x11-selection: Plug MetaSelectionSourceX11 leak
meta_selection_source_x11_new_finish() transfers the ownership of the
selection source, but source_new_cb() was not freeing it.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/998
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
05301d280c clipboard-manager: Plug mimetypes list leak
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1005
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Robert Mader
15b46a6f88 wayland/data-device: Small style fixes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Robert Mader
c27fc3537b wayland/data-device: Guard against a potential crash
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Robert Mader
6cc748cce9 wayland/data-device: Cancel drag source when the drag finished unsuccessfully
When a drag was performed but did not finish successfully, e.g. because no
mimetype was accepted, we need to send the source cancel event so clients
know they can destroy the drag source (since version 3).

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/740

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Sebastian Keller
afd645193a backends/native: Use proper method for getting core idle monitor
e9fbbd5853 changed meta_backend_get_idle_monitor() to use
ClutterInputDevice pointers instead of device IDs, but did not adjust
the call in meta_backend_native_resume() which was still using 0 to get
the core idle monitor resulting in a NULL pointer dereference.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1029
2020-01-30 22:19:49 +00:00
Carlos Garnacho
5723bd8ec7 backends: Use latest pointer position if no pointer constrain exists
The meta_seat_native_constrain_pointer() function receives the current
pointer position, and the new pointer position as in/out parameters.
We were however calculating the new coordinates based on the last pointer
position if there was no pointer constrain in place.

Fortunately to us, this didn't use to happen often/ever, as a pointer
constrain function is set on MetaBackend initialization. This behavior
did also exist previously in MetaDeviceManagerNative.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1028
2020-01-30 18:57:18 +01:00
Carlos Garnacho
1e9682b417 backends: Move warp_pointer() to ClutterSeat
The onscreen pointer sprite is a per-seat element, so it makes sense
to move pointer warping over there too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:12:58 +01:00
Carlos Garnacho
9da275cf73 backends: Set pointer constrain/relative motion hooks before backend init
The backend being initialized triggers a pointer warp (and motion event)
where we want to observe the callbacks put in place. So ensure we set
up the hooks before that could happen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:12:58 +01:00
Carlos Garnacho
f1d4d687f3 backends: Drop get_relative_motion_deltas() vfunc
Just go ATM through backend checks, and looking up directly the
native event data, pretty much like the rest of the places do that...
Eventually would be nice to have this information in ClutterEvent,
but let's not have it clutter the MetaBackend class.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:37 +01:00
Carlos Garnacho
e9fbbd5853 backends: Do not use device IDs on idle monitors
Device IDs are somewhat x11 specific, seems better to avoid those
on public API. We can rely everywhere on ClutterInputDevice, so use
it instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
d3160d095d clutter: Drop ClutterDeviceManager
This is mostly replaced by ClutterSeat, which offers a per-seat instead
of a global device abstraction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
873449d0f9 tests: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
4413b86a30 backends: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
f55d4f33af backends: Make meta_backend_update_last_device() take a clutter device
Instead of a pretty x11 specific device ID. This also updates the argument
of the ::last-device-changed signal to be a ClutterInputDevice.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
4761c4ee1c backends: Move native keymap manipulation functions to MetaSeatNative
Since the ClutterKeymap is obtained through the ClutterSeat, it makes
sense to have these manipulation functions in the ClutterSeat impl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
7644ddeddc core: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
6dfd2ffcef wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
835f12043e clutter: Drop select_stage_events() device manager vfunc
This is specific to X11, so handle it within the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
7afbc01fe8 clutter: Move motion compression handling to ClutterSeat
Another responsibility taken away from ClutterDeviceManager

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:31 +01:00
Carlos Garnacho
1c689b83f9 clutter: Move virtual device management to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:14 +01:00
Carlos Garnacho
8d0527f674 clutter: Move pointer a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:01:53 +01:00
Carlos Garnacho
bc7ba8c875 clutter: Move keyboard a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:01:50 +01:00
Carlos Garnacho
34ce39f8dc clutter: Move platform event data management to ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:47 +01:00
Carlos Garnacho
9be4f98c73 clutter: Move keymap from ClutterBackend to ClutterSeat
Keymaps are a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:47 +01:00
Carlos Garnacho
1fc021c3c6 clutter: Move bell_notify() from ClutterBackend to ClutterSeat
Bells can be considered to be a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:46 +01:00
Carlos Garnacho
9aba37f70f clutter: Move keymap direction from ClutterBackend to ClutterKeymap
This makes more sense to have in the ClutterKeymap, since we have it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:46 +01:00
Carlos Garnacho
5bb3d86884 native: Implement ClutterSeat
We had the MetaSeatNative struct around, so use it as the base of
this Clutter object. A few responsibilities were drawn from
ClutterDeviceManager.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:41 +01:00
Carlos Garnacho
1611979fa8 x11: Implement ClutterSeat
The ClutterDeviceManager signaling becomes implemented on top of this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 16:28:51 +01:00
Carlos Garnacho
88fb003cdc x11: Drop subscription for input event from floating devices
This is unlikely to happen, and unlikely to be right (eg. we don't translate
input event coordinates, since those are not in display coordinate space, we
don't offer any feedback for those either).

This can simply be dropped, we listen to XIAllMasterDevices, which suffices
for what we want to do.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 16:28:51 +01:00
Olivier Fourdan
a382698acc wayland: Update input device before repick
When a Wayland window is mapped or unmapped, the Wayland compositor is
expected to send the coorespoindign `wl_pointer` enter/leave events to
the affected clients.

To do so, mutter calls `meta_wayland_compositor_repick()` which
eventually calls `meta_wayland_pointer_repick()` and
`repick_for_event()`.

If pointer input device has not been updated yet, the old clutter actor
is picked and no enter/leave event is emitted.

Make sure we update the pointer input device prior to do the repick to
get the actual `ClutterActor` under the pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1016
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Olivier Fourdan
5618e41cea window: Remove Wayland code from meta_window_show()
As we now call `meta_wayland_compositor_repick()` when the effects are
complete for Wayland surfaces, we can safely remove the Wayland specific
code to do the same from `meta_window_show()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Olivier Fourdan
f97930eaf5 wayland/surface: Repick when effects are complete
When mapping/unmapping windows, an animation may be played which can
change the actual actor size and location, hence defeating picking if
done too early.

Make sure we repick when the affects are completed, once the actor is
sized and placed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Alberts Muktupāvels
5e07478843 x11-display: add support for _GTK_WORKAREAS_Dn
In addition to existing _NET_WORKAREA property set also new
_GTK_WORKAREAS_Dn property where n is desktop number (between 0
and _NET_NUMBER_OF_DESKTOPS - 1).

https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22

https://gitlab.gnome.org/GNOME/mutter/merge_requests/370
2020-01-29 11:08:21 +00:00
Olivier Fourdan
1ce933e281 window-actor/x11: Get frame rect from the buffer size
When building the frame mask, the current reported frame size may not
match when is actually on screen if the buffer has not been updated
yet.

So instead of getting the frame size from the meta window, deduce it
from the texture size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
1000ebe203 window/x11: Add function to convert the buffer to frame rect
Add a convenient function to get the frame rectangle from a given
buffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
c0321c7b21 frame: Pass the frame area for get_mask()
Currently, `meta_frame_get_mask()` and `meta_ui_frame_get_mask()` will
return the frame mask applied to the current frame size, by querying the
frame themselves.

To be able to get the frame mask at an arbitrary size, change the API to
take a rectangle representing the size at which the frame mask should be
rendered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
7dbb4bc3f5 window-actor/x11: Cache the client area
With Xwayland, the shape region is recomputed and reapplied even when
the actor is frozen to prevent the black shadows effect.

However, while recomputing the shape region, the current client size is
taken into account, rather than the size when the client was frozen,
which is ahead of the actual client size using the NET_WM_SYNC protocol.

Keep the current client area and to reuse them when the X11 window actor
is frozen for rebuilding the client mask texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Corentin Noël
9d390ee49f meta: Add missing display.h to meta-workspace-manager.h
This is required because MetaDisplayCorner is only defined in display.h

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1025
2020-01-29 11:30:24 +01:00
Carlos Garnacho
403466c0db wayland: Implement dnd cancel on pressing Esc key
When this key is pressed the DnD operation should be cancelled,
and the "pop DnD icon back" animation to happen.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1020
2020-01-28 14:05:35 +00:00
Carlos Garnacho
30bf588a38 wayland: Do not check current offer on DnD button release
This check was added on commit 48639ac5 as a means to disregard
DnD drops where the offer would disappear beforehand. However since
that commit was all about wl_data_device_manager version < 3,
forgetting about the selected mimetype seems a behavior more inline
with those versions.

Since no current drop is something expected on X11 drop sites, fixes
DnD over those, while keeping the original bug fixed.

Found by Robert Mader (https://gitlab.gnome.org/GNOME/mutter/issues/974#note_688144)

https://gitlab.gnome.org/GNOME/mutter/issues/974
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
090a6ad409 xwayland: Set XDND source-side actions as per XDND
In XDND, we just get a hint on XdndPosition about what's the action
chosen by the user. Make the data source actions the full set on
XdndEnter (as we can't know better), and pass the hint in XdndPosition
as the user chosen action as it should be.

Makes Wayland drop sites aware of the user action as per XDND with X11
drag sources, and still makes modifiers during DnD work.

https://gitlab.gnome.org/GNOME/mutter/issues/974
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
a6c195b05c x11: Map x11 (UTF8_)STRING requests to text/plain mimetypes
Make the x11 selection proxy map UTF8_STRING and STRING to proper
mimetypes, as the selection source (wayland or memory) might not
offer those for backwards compatibility.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1355
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
c1df48befd wayland: Preserve XdndTypeList for future callers
This Xdnd property is owned by the drag source, we shouldn't delete
it when reading/proxying it to Wayland clients.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2347
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Sebastian Keller
abc58f7b9d kms: Fix drmModeEncoder leak
The result of drmModeGetEncoder() needs to be free'd by the caller.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
66fe6d85d0 backends/crtc: Fix leak of MetaCrtcMode name string
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
a63e80ec64 wayland: Avoid GVariant leak in set_gnome_env
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
9feda1c58b kms/crtc: Fix gamma state leak
The gamma value pointers of the current_state are overwritten by the
calls to memdup causing a small leak. while the leak itself is small, it
can be triggered quite often from things like night light.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
51733ca499 window/wayland: Plug window configuration leak
The acked configuration is removed from the pending configuration list
by acquire_acked_configuration(), but finish_move_resize() does not free
the data after applying the configuration.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
f0c92646eb wayland/surface: Plug leak in meta_wayland_surface_assign_role
The underlying data of the names array is not used anymore after this,
so it should be freed as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
f447a053bb renderer: Chain up parent class finalize
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1016
2020-01-22 20:56:34 +01:00
Adam Jackson
545fcb3dbf renderer-native: Fix memory leak in secondary GPU update
Leaking a texture object and a framebuffer object every time you update
the secondary GPU is perhaps not the best plan.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1011
2020-01-21 14:39:01 +00:00
Sebastian Keller
b30a29f830 shaped-texture: Plug region leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1002
2020-01-16 20:57:20 +00:00
Pekka Paalanen
b6c824dd16 renderer/native: Import primary buffer to 2nd GPU
Where possible, try to export the buffer rendered by the primary GPU as a
dmabuf and import it to the secondary GPU and turn it into a DRM FB for
scanout. If this works, we get a zero-copy path to secondary GPU outputs.

This is especially useful on virtual drivers like EVDI (used for DisplayLink
devices) which are not picky at all about what kind of FBs they can handle.

The zero-copy path is prioritised after the secondary GPU copy path, which
should avoid regressions for existing working systems. Attempting zero-copy
would have the risk of being less performant than doing the copy on the
secondary GPU. This does not affect the DisplayLink use case, because there is
no GPU in a DisplayLink device.

The zero-copy path is prioritised before the primary GPU and CPU copy paths. It
will be tried on the first frame of an output and the copy path is executed
too. If zero-copy fails, the result from the copy path will take over on that
frame. Furthermore, zero-copy will not be attemped again on that output. If
zero-copy succeeds, the copy path is de-initialized.

Zero-copy is assumed to be always preferable over the primary GPU and CPU copy
paths. Whether this is universally true remains to be seen.

This patch has one unhandled failure mode: if zero-copy path first succeeds and
then fails later, there is no fallback and the output is left frozen or black.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
03ac7b1821 backend/native: Share drmModeAddFB code
With all the three paths this is quite a handful of code, and it was mostly
duplicated in two places. A follow-up patch would need to introduce a third
copy of it. Therefore move the code into a helper function.

There are two behavioral changes:

- The format error now prints the string code as well, because it is easy to
  read.

- The g_debug() in init_dumb_fb() is removed. Did not seem useful.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
f409dddb54 renderer/native: Extract secondary_gpu_release_dumb
There will be another place where I need to release the dumb buffers but not
destroy the whole secondary_gpu_state, so extract this bit of code into a
helper.

The checks of fb_id are dropped as redundant with the check already in in
release_dumb_fb ().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
fe76e6a228 renderer/native: Reset all fields of MetaDumbBuffer
release_dumb_fb () checks 'map' to see if anything needs freeing. Other places
are checking fb_id instead. The checks maybe redundant, but let's reset all
fields here while at it, so that all the checks work as expected.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
40408150f0 renderer/native: Absorb free_next_secondary_bo
The function is trivial and only used once, so fold it into the caller.

Makes the code more readable by removing a little bit of boilerplate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
fea6abb4f0 renderer/native: Copy mode irrelevant for bo freeing
Simplify the bo freeing functions by not checking what the copy mode is. This
matches what swap_secondary_drm_fb () already does. g_clear_object () is safe
to call even if the value is already NULL.

The copy mode does not change mid-operation. If it did, this change would
ensure we still clean up everything. So this is more future-proof too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
94992ffff6 renderer/native: META_DRM_BUFFER is not NULL-safe
I could not find this in GObject documentation, but I hear the cast macro is
not safe to call with NULL.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
d7c9042c78 renderer/native: state consistency in copy_shared_framebuffer_gpu
To mirror what happens in meta_onscreen_native_swap_buffers_with_damage(), warn
here too if next_fb is not NULL. This makes it clear to the reader of what the
expectations are inside this function.

Ensuring next_fb is NULL as the first thing in the function will make all error
paths equal: no longer some failures reset next_fb while others don't. Removing
such special cases should reduce surprises.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Jonas Ådahl
ce3409b2b7 kms-impl-simple: Handle mode set race conditions gracefully
If we end up trying to do a mode set on a DRM state that has already
changed behind our back without us yet having seen the hotplug event we
may fail with `EINVAL`. Since the renderer layer doesn't handle mode set
failure, it'll still try to page flip later on, which will then also
fail. When failing, it'll try to look up the cached mode set in order to
retry the mode set later on, as is needed to handle other error
conditions. However, if the mode set prior to the page flip failed, we
won't cache the mode set, and the page flip error handling code will get
confused.

Instead of asserting that a page flip always has a valid cached mode set
ready to look up, handle it being missing more gracefully by failing to
mode set. It is expected that things will correct themself as there
should be a hotplug event waiting around the the corner, to reconfigure
the monitor configuration setting new modes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/917

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1007
2020-01-16 14:50:34 +00:00
Jonas Ådahl
7733f88168 kms-impl-simple: Include mode name in error message
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1007
2020-01-16 14:50:34 +00:00
Olivier Fourdan
c0038f6dac window-actor/x11: Update shape even when frozen
On Xwayland, freezing actor updates on sync requests means the
server-side frame and shadows repaint will be frozen as well, which
causes the shadow to show black at times when resizing X11 clients
which support NET_WM_SYNC.

Using freeze/thaw commits prevents the content from changing, yet the
shape window still needs to be updated when frozen otherwise the
difference in shape induced by the on-going resize operation will show
as well, even if the toplevel window has its commits frozen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=767212
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/858
2020-01-16 09:22:25 +01:00
Olivier Fourdan
4d5a86327a window/x11: Add always_update_shape() vfunc
To address the black shadows that sometimes show during resize with
Xwayland, we need to update the window shape regardless of the frozen
status of the window actor.

However, plain Xorg does not need this, as resized windows do not clear
to black, so add a new vfunc to window/x11 to indicate whether or not
the backing windowing system (either plain X11 or Xwayland) would
require the shape to be always updated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
d7a7af1ff2 window-actor/x11: Freeze/thaw commits on actor freeze/thaw
When using Xwayland, if the damage get posted before the X11 window
manager/compositor has finished repainting the actors, the intermediate
state will show.

Make sure to hint Xwayland as to when it can post pending damages and
commit the Wayland buffer using the `freeze_commits()/thaw_commits()`
API, based on window actor freeze/thaw.

See-also: https://gitlab.gnome.org/GNOME/mutter/merge_requests/855
See-also: https://gitlab.freedesktop.org/xorg/xserver/merge_requests/316

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
aa017383ac window-actor: Add set_frozen vfunc
Currently, the window actor freeze/thaw implementation sets the frozen
state of the surface actor using `meta_surface_actor_set_frozen()`.

If we want to expand that behavior to also freeze/thaw commits for X11
windows running on Xwayland, we need to have a specific vfunc to abstract
that in the window actor specific implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
c3c54e8ce6 surface-actor: Add meta_surface_actor_is_frozen()
Change the internal `is_frozen()` API to be available publicly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
53fce8e988 frames: Freeze Xwayland commits until repainted
To make sure the frame is painted before the commits are thawed, freeze
the commits when invalidating the GDK window, only to thaw to it after
the actual frame draw is performed or the frame is destroyed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
4ae9953607 window/x11: Freeze commits on resize
Make sure we freeze commits before resizing the window as this will
clear the frame to black.

Set the "thaw on paint" flag so that the post paint for window actor X11
can then thaw the freeze initiated prior to the resize and keep the
freeze/thaw balanced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
10796e6726 window/x11: Add flag to thaw commits after resize
To be able to thaw commits following a resize that might have frozen
commits, to keep freezes and thaws even, we need a way to tell whether
a repaint should also thaw commits.

Add a flag to `MetaWindowX11` and the appropriate functions to set and
query it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
845157c111 window/x11: Add freeze_commits()/thaw_commits()
Xwayland may post damages for an X11 window as soon as the frame
callback is triggered, while the X11 window manager/compositor has not
yet finished updating the windows.

If Xwayland becomes compliant enough to not permit updates after the
buffer has been committed (see [1]), then the partial redraw of the X11
window at the time it was posted will show on screen.

To avoid that issue, the X11 window manager can use the X11 property
`_XWAYLAND_ALLOW_COMMITS` to control when Xwayland should be allowed to
post the pending damages.

Add `freeze_commits()` and `thaw_commits()` methods to `MetaWindowX11`
which are a no-op on plain X11, but sets `_XWAYLAND_ALLOW_COMMITS` on
the toplevel X11 windows running on Xwayland.

[1] https://gitlab.freedesktop.org/xorg/xserver/merge_requests/316
See-also: https://gitlab.gnome.org/GNOME/mutter/merge_requests/855

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Ray Strode
bac188b568 window: Always disarm XSYNC watchdog when X client responds
At the moment we only disarm the watchdog timer set up for SYNC counter
requests if we're in the middle of a resize operation.

It's possible that the resize operation finished prematurely by the user
letting go of the mouse before the client responded.  If that happens, when the
client finally updates mutter will erroneously still have the watchdog timer
engaged from before until it times out, leading to resizes for the next second
or so to not get processed, and the client to get blacklisted from future sync
requests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Jonas Ådahl
6d15231f10 wayland/actor-surface: Always consider unmapped actors not on output
This avoids using bogus geometric values from an unmapped actor to
determine whether an actor is on a logical monitor or not. This would
happen when committing to a subsurface of a yet to be mapped toplevel.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
3e90070b88 tests/wayland: Test subsurface commits after parent was reset
Without 'wayland/surface-actor: Reset and sync subsurface state when
resetting' this test would fail.

This also adds a simple framework for testing lower level Wayland
semantics.

In contrast to the test-client and test-driver framework, which uses
gtk and tests mostly window management related things, this framework is
aimed to run Wayland clients made to test a particular protocol flow,
thus will likely consist of manual lower level Wayland mechanics.

A private protocol is added in order to help out clients do things they
cannot do by themself. The protocol currently only consists of a request
meant to be used for getting a callback when the actor of a given
surface is eventually destroyed. This is different from the wl_surface
being destroyed due to window destroy animations taking an arbitrary
amount of time. It'll be used by the first test added in the next
commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
f0df07cba3 wayland/surface: Move shaped-texture synchronization to actor surface
As with most other state that ends up being pushed to the actor and the
associated shaped texture, also push the texture and the corresponding
metadata from the actor surface. This fixes an issue when a toplevel
surface was reset, where before the subsurface content was not properly
re-initialized, as content state synchronization only happened on
commit, not when asked to synchronize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
fe7bece31e wayland/surface-actor: Reset and sync subsurface state when resetting
A actor surface may be reset by an xdg_toplevel if a NULL buffer is
attached. This should reset the actor state of the toplevel to an empty
state, while unmapping the previous actor. Subsurfaces, however, should
stay intact, including their relationship to the toplevel. They should
also not be yanked away from the actor of the actor surface prior to it
resetting, so that a window-destroy animation can include the subsurface
actor.

This fixes a potential crash when a subsurface tries to commit to its
wl_surface after the destroy animation of the toplevel has finished, as
the actor would at that point have been destroyed and cleared from the
actor surface struct, causing a segmentation fault.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
3969285e5c shaped-texture: Make setting the same texture a no-op
Will be helpful when pushing state to the shaped texture, letting the
one pushing not have to care about checking if anything changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
60ebf19c9e shaped-texture: Minor clean up
Use cogl_clear_object(), add reference to texture when setting, and
remove redundant runtime type check.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
fcfe90aa9f wayland: Replace manual GNode subsurface iteration with macro
Similar to wl_list_foreach(), add
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE() that iterates over all the
subsurfaces of a surface, without the caller needing to care about
implementation details, such as leaf nodes vs non-leaf nodes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Jonas Ådahl
76ee026caa wayland/egl-stream: Cache texture snippet
While it's not very relevant now, as we would rarely create it anyway
since the buffer nor texture never changes for a surface, it will be in
the future, as the actor state (including its content,
MetaShapedTexture) will be synchronized by the MetaWaylandActorSurface
at a later point in time, and not by MetaWaylandSurface, at state
application time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Jonas Ådahl
6e5ac0b585 Use G_GNUC_FALLTHROUGH instead of comments
Get the same task done in a bit more C:y way.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/998
2020-01-09 17:58:29 +01:00
Jonas Dreßler
c4fa30ac7d backends/native: Fix relative motion calculation if monitor isn't found
The method `relative_motion_across_outputs` is used to adjust the
distance/delta of a mouse movement across multiple monitors to take the
different scale factors of those monitors into account. This works by
getting the adjacent monitors that the movement-line/vector intersects
with and adjusting the final position (or end point of the
movement-line) by multiplying the parts of the line spanning across
different monitors with the scale factors of those monitors.

In the end of this calculation, we always want to set the new end
coordinates of the relative motion to the new end coordinates of the
adjusted movement-line. We currently only do that if all adjacent
monitors the line is crossing actually exist, because only then we end
up inside the "We reached the dest logical monitor" else-block and set
`x` and `y` to the correct values. Fix that and make sure the returned
values are also correct in case an adjacent monitor doesn't exist by
adding separate `target_x` and `target_y` variables which we update during
each pass of the while loop so we're always prepared for the while loop
exiting before the destination monitor was found.

Thanks to Axel Kittenberger for reporting the initial bug and tracking
the issue down to `relative_motion_across_outputs`.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/774
2020-01-07 20:18:46 +00:00
Sebastian Keller
802309caf9 x11-selection: Plug MetaX11SelectionOutputStream leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Sebastian Keller
468b09c01e theme: Plug GdkPixbuf leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Sebastian Keller
c13ea4f48d theme: Plug GtkIconInfo leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Carlos Garnacho
1e7285b2bb backends: Always enable tap-to-click/drag on opaque Wacom tablets
Touch-wise, those are essentially giant touchpads, but have no buttons
associated to the "touchpad" device (There may be pad buttons, but
those are not mouse buttons).

Without tap-to-click/drag, touch in those devices is somewhat useless
out of the box. Have them always enable these features, despite the
setting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/968
2020-01-06 13:52:55 +00:00
Robert Mader
a8cb84c711 window-actor: Also cull out clip_region
From `meta_cullable_cull_out`:
```
Actors that may have fully opaque parts should also subtract out a region
that is fully opaque from @unobscured_region and @clip_region.
```

As we do no check for the intersection of these two elsewhere in the code,
let's substract from the clip region, too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/985
2020-01-06 13:38:23 +00:00
Pascal Nowack
e89cea8e5a screen-cast: Fix window recording on HiDPI
Using the same scale for the window as the
logical monitor only works correctly when having
the experimental 'scale-monitor-framebuffer'
feature enabled.
Without this experimental feature, the stream
will contain a black screen, where the actual
window only takes a small part of it.

Therefore, use a scale of 1 for the non-
experimental case.

Patch is based on commit 3fa6a92cc5.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/976
2019-12-18 18:41:44 +01:00
Yariv Barkan
67d9995280 backends/native: Get the correct value for pinch dy
Fix a typo - use the correct libinput api.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/974
2019-12-13 21:57:33 +02:00
Jonas Ådahl
4fccc903b5 xwayland: Don't queue frame callbacks when role assigned
'xwayland: Do not queue frame callbacks unconditionally' changed the
frame callback behavior of Xwayland surfaces so that they behave the
same way as other actor surfaces (e.g. xdg-shell ones), except for the
case when they are initially assigned.

Remove this special casing as well including the now incorrect comment,
so that the Xwayland surfaces behave the same as the others in this
regard also when assigning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/964
2019-12-10 09:15:49 +00:00
Jonas Ådahl
132fbf49d7 wayland: Let MetaWaylandXdgPopup dismiss incorrectly placed popups
It's a xdg_popup detail, and not until the actual position is finalized
is the actual correctness known.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
d02c124e1d wayland/surface-role: Rename commit() vfunc apply_state()
The vfunc is not called when a surface commits its state, but when the
state is applied. Make this clearer by changing the name to
"apply_state" (and "pre_apply_state").

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
554644f9e0 wayland: Rework asynchronous window configuration
This changes how asynchronous window configuration works. Prior to this
commit, it worked by MetaWindowWayland remembering the last
configuration it sent, then when the Wayland client got back to it, it
tried to figure out whether it was a acknowledgment of the configuration
or not, and finish the move. This failed if the client had acknowledged
a configuration older than the last one sent, and it had hacks to
somewhat deal with wl_shell's lack of configuration serial numbers.

This commits scraps that and makes the MetaWindowWayland take ownership
of sent configurations, including generating serial numbers. The
wl_shell implementation is changed to emulate serial numbers (assuming
each commit acknowledges the last sent configure event). Each
configuration sent to the client is kept around until the client one. At
this point, the position used for that particular configuration is used
when applying the acknowledged state, meaning cases where we have
already sent a new configuration when the client acknowledges a previous
one, we'll still use the correct position for the window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
cc444d4991 window/wayland: Use G_DECLARE_FINAL_TYPE
https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
4bf5b7d78d window: Don't constrain an acked window geometry
In Wayland, window configuration is asynchronous. Window geometry is
constrained, the constrained geometry is sent to the client, and the
client will adapt its surface and acknowledge the configuration. When
acknowledged, we shouldn't reconstrain again, as that may invalidate the
constraint calculated for the configured size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
cb91f44ba4 wayland/wl-shell: Use input region as window geometry if set
Historically, wl_shell clients used to pretend the input region was
equivalent to the window geometry, so for "correctness" lets do that
here too. This makes wl_shell clients with drop shadow behave marginally
better than before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
f7e256e9a1 wayland/surface: Make cached subsurface state generic
This moves the cached subsurface surface state into the generic
MetaWaylandSurface namespace. Eventually it'll be used by other surface
roles which as well aim to implement synhcronization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
bbec8abb68 wayland/surface: Rename MetaWaylandPendingState to MetaWaylandSurfaceState
The name didn't communicate it was about surface state, and it somewhat
confusingly had the name "pending" in it, which could be confused with
the fact that while it's used to collect pending state, it's also used
to cache previously committed pending state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
d60d671fec wayland: Use helper to access pending state from the outside
With the eventual aim of exposing the internals of MetaWaylandSurface
outside of meta-wayland-surface.c, make users of the pending state use a
helper to fetch it. While at it, rename the struct field to something
more descriptive.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
8dc730e5ca wayland/surface: Move subsurface synchronization logic to role
It's an implementation detail of subsurfaces when to cache state
and when not to, so move that logic to the subsurface role
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
0cf98c5641 wayland/surface: Emit signal before applying state
Will be used to invalidate depending state that should be updated as
part of a surface state being applied.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
4bacb3621b window/wayland: Make .._wayland_move_resize() name more explanatory
The intention of meta_window_wayland_move_resize() is to finish a
move-resize requested previously, e.g. by a state change, or a
interactive resize. Make the function name carry this intention, by
renaming it to meta_window_wayland_finish_move_resize().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
aef865afc4 wayland/xdg-shell: Scope variable better
A window geometry rectangle was declared in the wrong scope. Both
xdg-shell and legacy xdg-shell had the same issue.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Tim Crawford
d70ddc65ea backends/native: Fix double free of error
error is an autoptr, so must not be explicitly freed.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1852
Fixes: 5c500ad402 ("backend: Move GPU ownership from the monitor manager to the backend")

https://gitlab.gnome.org/GNOME/mutter/merge_requests/960
2019-12-06 11:33:26 -07:00
Pekka Paalanen
832a522cce kms-impl/simple: Fix meta_set_fallback_feedback_idle
Presumably this function is supposed to be like
meta_kms_impl_simple_handle_page_flip_callback() but the condition in the
if-statement is inverted. Fix the inversion to make these two functions look
alike.

This is part 2 of 2 fixing a complete desktop freeze when drmModePageFlip()
fails with EINVAL and the fallback to drmModeSetCrtc() succeeds but the success
is not registered correctly as completed "flip". The freeze occurs under
wait_for_pending_flips() which calls down into meta_kms_impl_device_dispatch()
which ends up poll()'ing the DRM fd even though drmModeSetCrtc() will not
produce a DRM event, hence the poll() never returns. The freeze was observed
when hotplugging a DisplayLink dock for the first time on Ubuntu 19.10.

This patch makes meta_set_fallback_feedback_idle() actually end up calling into
notify_view_crtc_presented() which decrements
secondary_gpu_state->pending_flips so that wait_for_pending_flips() can finish.

CC stable: gnome-3-34

https://gitlab.gnome.org/GNOME/mutter/merge_requests/953
2019-12-06 15:55:35 +00:00
Pekka Paalanen
79491df2b8 kms: Process impl idle callbacks before pre dispatch flush
mode_set_fallback() schedules a call to mode_set_fallback_feedback_idle(), but
it is possible for Mutter to repaint before the idle callbacks are dispatched.
If that happens, mode_set_fallback_feedback_idle() does not get called before
Mutter enters wait_for_pending_flips(), leading to a deadlock.

Add the needed interfaces so that meta_kms_device_dispatch_sync() can flush all
the implementation idle callbacks before it checks if any "events" are
available. This prevents the deadlock by ensuring
mode_set_fallback_feedback_idle() does get called before potentially waiting
for actual DRM events.

Presumably this call would not be needed if the implementation was running in
its own thread, since it would eventually dispatch its idle callbacks before
going to sleep polling on the DRM fd. This call might even be unnecessary
overhead in that case, synchronizing with the implementation thread needlessly.
But the thread does not exist yet, so this is needed for now.

This is part 1 of 2 fixing a complete desktop freeze when drmModePageFlip()
fails with EINVAL and the fallback to drmModeSetCrtc() succeeds but the success
is not registered correctly as completed "flip". The freeze occurs under
wait_for_pending_flips() which calls down into meta_kms_impl_device_dispatch()
which ends up poll()'ing the DRM fd even though drmModeSetCrtc() will not
produce a DRM event, hence the poll() never returns. The freeze was observed
when hotplugging a DisplayLink dock for the first time on Ubuntu 19.10.

CC stable: gnome-3-34

https://gitlab.gnome.org/GNOME/mutter/merge_requests/953
2019-12-06 15:55:35 +00:00
Christian Rauch
9f50b2cef2 startup: Fix build with 'startup_notification=false'
https://gitlab.gnome.org/GNOME/mutter/merge_requests/958
2019-12-05 01:27:14 +00:00
Robert Mader
96e1883361 xwayland: Do not queue frame callbacks unconditionally
The removed comment is not longer true: XWayland schedules its VSYNC
from frame callbacks nowadays. Only sending callbacks when the surface
actor is unobscured makes XWayland throttle its VSYNC to 1/sec,
reducing repaints in many cases.

Follow up of https://gitlab.gnome.org/GNOME/mutter/merge_requests/918

https://gitlab.gnome.org/GNOME/mutter/merge_requests/956
2019-12-04 18:59:24 +01:00
Jonas Ådahl
4ede6ea8c5 cogl: Remove the framebuffer and source stacks
They have been deprecated for a long time, and all their uses in clutter
and mutter has been removed. This also removes some no longer needed
legacy state tracking, as they were only ever excercised in certain
circumstances when there was sources (pipelines or materials) on the now
removed source stack.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
3f65837e0d clutter, core: Stop using the Cogl framebuffer stack
The Cogl framebuffer stack is going away; replace all its uses by the
framebuffer stack carried by the paint context.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
549f60fe49 texture-tower: Don't use implicit framebuffer stack Cogl API
Replace it with the non-deprecated counterparts.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
26147afb08 shadow-factory: Don't set implicit Cogl material
We only draw with non-deprecated API already, so there is no reason to
set the source material.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
6f30cf0004 tests/clutter/cogl-tex-polygon: Port to CoglPrimitive
Instead of using cogl_polygon(), which uses deprecated API, implement
polygon drawing using the CoglPrimitive API family. While the test might
have been used to explicitly test cogl_polygon() it could still be
useful to test the non-deprecated way of rendering polygons.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
8c7ec44681 tests/clutter: Port to using non-implicit framebuffer Cogl API
Port tests to use API such as cogl_framebuffer_push_matrix() instead of
cogl_push_matrix() all over the Clutter tests, with one exception:
cogl_polygon(). It'll be ported over in a separate commit, as it is less
straight forward.

Implicitly set CoglMaterial properties are changed to explicitly created
and destructed CoglPipelines with the equivalent properties set.
cogl_push|pop_framebuffer() is replaced by explicitly passing the right
framebuffer, but tests still rely on cogl_get_draw_framebuffer() to get
the target framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
f11170fecb clutter/paint-node: Have caller of .._get_framebuffer() handle fallback
clutter_paint_node_get_framebuffer() fell back on
cogl_get_draw_framebuffer() when the root node didn't have a custom
get_framebuffer vfunc. As this relies on deprecated implicit Cogl stack
API, it needs to go away, so handle this in the caller that knows more
about the context.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
cb9d6b79ef clutter: Introduce pick contexts
Just as with painting, add a pick context that carries pick related
temporary state when doing actor picking. It is currently unused, and
will at least at first still carry around a framebuffer to deal track
view transforms etc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
3f2a6f58eb tests/clutter: Remove unneeded gitignore files
We're using meson, so everything built ends up in the build directory.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
98c0fe934b cogl: Remove CoglVertexBuffer
It was deprecated, relied on deprecated API (implicit framebuffers,
mateiarls etc), and was unused. Lets remove it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
49c8d42317 clutter: Introduce paint contexts
When painting, actors rely on semi global state tracked by the state to
get various things needed for painting, such as the current draw
framebuffer. Having state hidden in such ways can be very deceiving as
it's hard to follow changes spread out, and adding more and more state
that should be tracked during a paint gets annoying as they will not
change in isolation but one by one in their own places. To do this
better, introduce a paint context that is passed along in paint calls
that contains the necessary state needed during painting.

The paint context implements a framebuffer stack just as Cogl works,
which is currently needed for offscreen rendering used by clutter.

The same context is passed around for paint nodes, contents and effects
as well.

In this commit, the context is only introduced, but not used. It aims to
replace the Cogl framebuffer stack, and will allow actors to know what
view it is currently painted on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Niels De Graef
5c986060f0 wayland: Add documentation to wayland_shell_init
Especially preventing the confusion that it might only initalize the
wl_shell interface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Niels De Graef
404e713227 wayland: Add documentation to the WaylandBuffer object
https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Niels De Graef
542bad60ba wayland: Add documentation for dma-buf namespace
It's not always clear how the dma-buf functions work (e.g. where memory
is allocated) without actually going in-depth in the code. This just
adds a few commments to more quickly gain understanding.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Carlos Garnacho
6f4c7d66a4 x11: Check wacom button flags to determine whether button is mode switch
Checking the leds is not really accurate, since some devices have mode
switch buttons without leds. Check in the button flags whether they are
mode switch buttons for any of ring/ring2/strip/strip2, and return the
appropriate group.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/952
2019-11-29 18:10:14 +00:00
Florian Müllner
c843102eec stack: Delegate layer calculation to a window vfunc
While most of the code to compute a window's layer isn't explicitly
windowing backend specific, it is in practice: On wayland there are
no DESKTOP windows(*), docks(*) or groups.

Reflect that by introducing a calculate_layer() vfunc that computes
(and sets) a window's layer.

(*) they shall burn in hell, amen!

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
b753213f9b window: Add get_default_layer() helper
Most of the layer computation that the stack does actually depends
on the windowing backend, so we will move it to a vfunc.

However before we do that, split out the bit that will be shared.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
599d8e3287 stack: Move HAS_TRANSIENT_TYPE macro to window-private
We'll soon need it elsewhere, so move it to a shared location.
While at it, convert it to a function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
1c89fce30e stack: Allow promoting transient windows to their parent's layer
When a window that should be stacked above another one is placed in a lower
layer than the other window, we currently allow promoting it to the higher
layer when it has a "transient type". We should do the same when the window
is an actual transient of the other window.

This is particularly relevant for wayland windows, where types play a
much smaller role: Transient windows like non-modal dialogs (and since
commit 666bef7a, popup windows as well) currently end up underneath their
always-on-top parent.

https://gitlab.gnome.org/GNOME/mutter/issues/587
2019-11-28 21:10:47 +01:00
Robert Mader
0247d35e5a shaped-texture: Do not invalidate content on set_cogl_texture()
This was wrongly introduced in 75cffd0ec4. As the comment above explains, we
only want to queue redraws in response to surface/buffer damage.

This triggered a full redraw when using DMA buffers on Wayland as we currently
create a new texture on every buffer_attach(), breaking partial invalidation.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/947
2019-11-26 21:35:50 +01:00
Marco Trevisan (Treviño)
427670cc63 device-manager-x11: Ignore events if no source device is set
There might be some inconsistent event for which we don't have a known
source device.

In the current state we don't handle them and we could crash when getting
the current device tool.

So, add an utility function that retrieves the source device for an event
that warns if no device is found, and use this for Motion, Key and Button
events.

In case we don't have a valid source in such case, just return early instead
of trying to generate invalid clutter events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/823
2019-11-23 01:38:16 +00:00
Jonas Ådahl
4af4b79123 window: Assert we have an up to date monitor after they changed
Add an assert that we don't have a MetaWindow::monitor pointer that
points to an old MetaLogicalMonitor. After this, and the other
monitors-changed callbacks have been called, the old MetaLogicalMonitor
will be destoryed, thus if we didn't update the pointer here, we'll
point to freed memory, and will eventually crash later on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/929
2019-11-23 00:58:19 +00:00
Corentin Noël
5582d7b3be background: set_file accepts NULL files
https://gitlab.gnome.org/GNOME/mutter/merge_requests/941
2019-11-22 22:13:35 +00:00
Corentin Noël
4cccba5cac workspace-manager: get_workspace_by_index can return NULL
https://gitlab.gnome.org/GNOME/mutter/merge_requests/941
2019-11-22 22:13:35 +00:00
Carlos Garnacho
e44bd2edb4 compositor: Use redraw clip region to cull out children
This will avoid repainting too much of the background if the
bounding box turned out to be too large.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2019-11-22 21:07:05 +00:00
Robert Mader
8e172aeecb cleanup: Use g_clear_handle_id() for g_source_remove()
It makes sure we do not forget to zero the id and lets us avoid
zero checks before. We use it for all new code, lets clean up the
existing code base.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/947
2019-11-22 01:27:40 +01:00
Robert Mader
92375c75f8 cleanup: Use g_clear_signal_handler() where possible
This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 15:02:27 +00:00
Carlos Garnacho
e5af790acb wayland: Move "ownership" of the DnD selection source to the data device
On wl_data_source destruction we used to indirectly unset the DnD selection
owner via the wl_resource destructor triggering the destruction of the
MetaWaylandDataSource, which would be caught through the weak ref set by
the MetaWaylandDragGrab.

This works as long as the grab is held, however we have a window between
the button being released and the drop site replying with
wl_data_offer.finish that the MetaWaylandDataSource is alive, but its
destruction wouldn't result in the call chain above to unsetting the DnD
source.

In other selection sources, we let the MetaWaylandDataDevice hold the
"ownership" of the MetaWaylandDataSource, and its weak ref functions unset
the respective MetaSelection owners. Do the same here, so the
MetaWaylandDataSource destruction is listened for all its lifetime.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
48639ac5da wayland: Do not cancel data source on offer destruction
This is wrong for both clipboard and DnD, as the selection source
will still be able to focus another surface, and churn another
wl_offer.

We should just detach the data offer from the data source in this
case, and let the source live on. However, we should still check
that there is a source and an offer to finish DnD, do that when
handling the drop operation instead.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
e7b2f9603e wayland: Avoid redundant cancel() call
This is unnecessary as we are unsetting the DnD selection owner,
and will result in the related data source being cancelled already.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
46b3811e22 wayland: Drop unused wl_signal structs
Those were used to signal clipboard ownership around, but that got
replaced by MetaSelection and friends. These signals are no longer
listened on, so can be safely removed.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Adam Jackson
7adaaab2d6 clutter: Remove deprecated ClutterTableLayout
https://gitlab.gnome.org/GNOME/mutter/merge_requests/921
2019-11-19 21:50:27 +00:00
Jonas Ådahl
244f55df28 tests/clutter: Remove tests testing or relying on ClutterTexture
ClutterTexture is going to be removed, so remove interactive tests that
stand in the way for that. Some test texture features, while some makes
heavy use of ClutterTexture to implement their testing. Remove these
tests to prepare for the removal of ClutterTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
f7ad7e6c0f tests/clutter/touch-events: Use ClutterCanvas to draw touch
Change the interactive touch events test case to use ClutterCanvas to
draw touch points instead of using ClutterCairoTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
e0ebc4de60 tests/clutter/easing: Use ClutterCanvas
Remove the usage of ClutterCairoTexture and use a ClutterCanvas content
instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
14bb104ef0 tests/clutter: Replace ClutterTexture from image with custom helper
ClutterTexture is deprecated, lets remove the trivial usage with a
simple gdk-pixbuf using constructor putting pixel contents into a
ClutterImage then putting said image in a plain ClutterActor.

Tested partially, as the interactive tests cannot be properly run at the
moment.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
f3b9fc8159 tests/clutter/interactive: Init backend and mutter context
As was with the tests run via meson test, for the interactive tests we
too need to configure the mutter backend and initialize things in order
to be able to run any tests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Hans de Goede
8907a29912 cursor-renderer/native: Fix cursor drawing in combination with panel_orientation_transform
Properly take the panel_orientation_transform into account in
update_monitor_crtc_cursor. This fixes us sometimes drawing the cursor
on two monitors at the same time as we did not properly swap the crtc
width/height when a panel_orientation_transform is active.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/927
2019-11-13 10:54:37 +01:00
Hans de Goede
a5f986259f output-kms: Fix "panel orientation" kms-prop being ignored on native outputs
Actually store the panel_orientation_transform in the meta_output, so
that it gets honored by the core code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/927
2019-11-13 10:53:50 +01:00
Jonas Ådahl
7193938d27 compositor: Guard against untimely calls
It seems that sometimes these functions are called by Javascript in
GNOME Shell during tear down. This causes segfaults and crash reports,
but without any backtraces other than the entry and exit points into
gjs.

In order to get more useful information about where these calls come
from, validate the input passed gracefully, by complaining in the log
and returning NULL values.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/926
2019-11-11 13:09:20 +00:00
Hans de Goede
5afec87b96 input-settings/x11: Add missing clutter_x11_trap_x_errors around XIGetProperty
Add missing clutter_x11_[un]trap_x_errors around the XIGetProperty call
in meta-input-settings-x11.c's get_property helper function.

This fixes mutter crashing with the following error if the XInput device
goes away at an unconvenient time:

 X Error of failed request:  XI_BadDevice (invalid Device parameter)
   Major opcode of failed request:  131 (XInputExtension)
   Minor opcode of failed request:  59 ()
   Device id in failed request: 0x200011
   Serial number of failed request:  454
   Current serial number in output stream:  454

https://gitlab.gnome.org/GNOME/mutter/merge_requests/928
2019-11-10 19:45:08 +01:00
Robert Mader
a4f51da184 plugin-manager: Kill window effects on destroy
We do so for all other window effects already. Why this was left out
is unknown (9b3a0d1ad8), but we will need it for a fix in GS.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/655

https://gitlab.gnome.org/GNOME/mutter/merge_requests/924
2019-11-08 22:18:09 +00:00
Florian Müllner
0545b93232 plugins/default: Handle skipped animations
We currently assume that the actor_animate() helper function returns
a timeline. However Clutter may skip implicit animations and simple
set properties directly, for example when the actor is hidden.

The returned timeline will be NULL in that case, and we abort when
using it as instance parameter to g_signal_connect().

Fix this by only setting up a completed handler when we are actually
animating, and complete the effect directly otherwise.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/925
2019-11-08 22:49:31 +01:00
Marco Trevisan (Treviño)
6944839ab6 window-props: Read WM_TRANSIENT_FOR for override-redirect windows
As per the Extended Window Manager Hints standard version 1.3 [1] an
override-redirect window can set a transient-for window per compositing and
app-matching purposes.

So just read the WM_TRASIENT_FOR property also for such windows, adapting
the error in case they are transient for another O-R window and adding a
test to check such case.

[1] https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472512128

https://gitlab.gnome.org/GNOME/mutter/merge_requests/920
2019-11-07 18:43:16 +00:00
Xiang Fan
4a76f66a54 wayland/surface: Don't double scale when getting absolute coordinates
The actor is already in surface coordinate space, so we should not scale
with the buffer scale to transform surface coordinates to stage
coordinates.

This bug causes input method using wayland text-input protocol to
receive wrong cursor location. Reproduced in ibus (when candidate
window is open) with scaling factor other than 1.

This commit also fixes pointer confinement.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/915
2019-11-07 16:20:13 +00:00
Marco Trevisan (Treviño)
bacbbbd628 window-props: Don't set override redirect windows as top-level parent
Java applications might use override-redirect windows as parent windows for
top-level windows, although this is not following the standard [1].

In such case, the first non-override-redirect child window that is created
was marked as being on_all_workspaces since the call to
should_be_on_all_workspaces() returns TRUE for its parent, and this even
though the on_all_workspaces_requested bit is unset.
When a further child of this window was added, it was set as not having a
workspace and not being on_all_workspaces, since the call to
should_be_on_all_workspaces() for its parent would return FALSE (unless if
it is in a different monitor, and the multiple-monitors workspaces are
disabled).

Since per commit 09bab98b we don't recompute the workspace if the
on_all_workspaces bit is unset, we could end up in a case where a window can
be nor in all the workspaces or in a specific workspace.

So let's just ignore the transient_for bit for a window if that points to an
override-redirect, using the x11 root window instead.

Add a stacking test to verify this scenario (was failing before of this
commit).

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/885
https://gitlab.gnome.org/GNOME/mutter/merge_requests/895

[1] https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472512128
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
c85fb107c0 window-props: Don't look for parent multiple times
Once we set the transient_for, we look for parent MetaWindow, so instead
of overwriting this value for loops check, just use another function
and avoid to look for the xwindow again when setting the MetaWindow parent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
13f10e36e4 window: Assert we only set a NULL workspace when unmanaging
There might be cases in which a window might be marked as both not in all
workspaces and with NULL workspace.

So to avoid this to happen, let's just assert early instead of doing this at
later point where the context might not be clear.

Related to https://gitlab.gnome.org/GNOME/mutter/issues/885

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
2644e54c51 window: Warn if O-R window workspace state is used
Override-redirect windows have no workspace by default, and can't be parent
of a top-level window, so we must check that the parent window is not an
O-R one when setting the workspace state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Jonas Ådahl
0e5a5df5fe wayland/actor-surface: Always store away frame callbacks on commit
We're expected by MetaWaylandSurface to always pick the frame callbacks
out from the pending state when committing (applying) so that no frame
callbacks are unaccounted for. We failed to do this if our actor for
some reason (e.g. associated window was unmanaged) was destroyed. To
handle this situation better, store away the frame callbacks until we
some later point in time need to pass them on forward.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/893
2019-11-07 12:56:58 +00:00
Marco Trevisan (Treviño)
ffa0a24848 x11-display: Get next serial just before using it
We ask XLib the next request serial number before performing other actions
triggered by meta_x11_display_set_input_focus_internal() that doesn't use
the request serial anyways. So, just request it before updating the focus
window as that's the operation that needs it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/909
2019-11-06 17:32:29 +00:00
Marco Trevisan (Treviño)
efe5bed5b4 x11-display: Don't unset the X11 focused window after setting one
When using DesktopIcons extension and clicking in an icon, gnome-shell
starts an infinite loop caused by the first focus change that may trigger
on X11 a focus in/out event that leads to stage activation/deactivation
which never ends.

This happens because as part of meta_x11_display_set_input_focus_xwindow()
to focus the X11 stage window, we unset the display focus, but this also
causes to request the X11 display to unset the focus since we convolute by
calling meta_x11_display_set_input_focus() with no window, that leads to
focusing the no_focus_window and then a focus-in / focus-out dance that the
shell amplifies in order to give back the focus to the stage.

In order to fix this, mimic what meta_display_set_input_focus() does, but
without updating the X11 display, and so without implicitly calling
meta_x11_display_set_input_focus(), stopping the said convolution and
properly focusing the requested xwindow.
Also ensure that we're not doing this when using an older timestamp, since
this check isn't performed anymore.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/896
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/899

https://gitlab.gnome.org/GNOME/mutter/merge_requests/909
2019-11-06 17:32:29 +00:00
Carlos Garnacho
e865fcc460 wayland: Check focus surface client in wl_data_device.set_selection()
Similar to our handling in set_primary(), ignore set_selection() requests
that come from unfocused clients.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Carlos Garnacho
16eb461054 wayland: Clean up meta_wayland_data_device_set_primary()
This function is already checking for the focus surface client
matching the requestor. The type check was slightly bogus though
as it'd be an screwup in our code, make it an assert instead.

Also, move the check for the client having the focus into the
upper call, so this and wl_data_device.set_selection code can
get more in line.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Carlos Garnacho
c11ef6ef07 wayland: Flatten data source object hierarchy
We have an abstract MetaWaylandDataSource and 2 subclasses for
clipboard/primary data sources. Since the abstraction provided
by the additional sublevel is arguable, push the wl_resource
field up, and leave us with just 2 objects to think about, all
of them containing a wl_resource.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Thomas Hindoe Paaboel Andersen
95eda361c1 wayland: use correct enum type for tablet pad
Fixes a compile warning.  The two enums are identical, so no
functional change intended.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/863
2019-11-05 13:07:47 +00:00
Jonas Ådahl
662c76c4fc tests/monitor-unit-tests: Add another tiling window hot plug test
Checks that we handle hot plugs of a untiled window, that was previously
tiled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
ff799a1abe window: Reset tile monitor number when untiling
Otherwise we'll end up trying to access the out of date state later.

Fixes the following test failure backtrace:

    #0  _g_log_abort ()
    #1  g_logv ()
    #2  g_log ()
    #3  meta_monitor_manager_get_logical_monitor_from_number ()
    #4  meta_window_get_work_area_for_monitor ()
    #5  meta_window_get_tile_area ()
    #6  constrain_maximization ()
    #7  do_all_constraints ()
    #8  meta_window_constrain ()
    #9  meta_window_move_resize_internal ()
    #10 meta_window_tile ()

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
155b7bf569 tests/monitor-unit-tests: Add window tiling hot plug test
This test that we handle hot plugs correctly together with tiled
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
47155ed524 tests/runner: Move window shown synchronization to helper
https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
db91439bb0 tests/monitor-unit-tests: Move test client sanity check into helper
https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
77aad0869f window: Always update tile monitor number on hot plug
Otherwise we'll end up crashing if we had two connected monitors,
unplugged both, then replugged in a single one.

Avoids the following error:

    #0  _g_log_abort ()
    #1  g_logv ()
    #2  g_log ()
    #3  meta_monitor_manager_get_logical_monitor_from_number ()
    #4  meta_window_get_work_area_for_monitor ()
    #5  meta_window_get_tile_area ()
    #6  constrain_maximization ()
    #7  do_all_constraints ()
    #8  meta_window_constrain ()
    #9  meta_window_move_resize_internal ()
    #10 meta_window_move_resize_frame ()
    #11 meta_window_move_resize_now ()
    #12 idle_move_resize ()
    #13 call_idle_later ()

https://bugzilla.redhat.com/show_bug.cgi?id=1767703

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
dc1a28c42a plugins/default: Clean up tile preview when closing display
On finalize, the preview actor will have been destroyed behind our back;
avoid that by cleaning up before it's too late.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
955b27637c plugin/default: Init quark before using
Cut lines in pieces, and remove useless "optimizations" while at it

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
1f5b403524 display: Add 'closing' signal
Emitted when the MetaDisplay is closing. Meant for clean up that depends
on things that will be torn down during closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Robert Mader
5e87d67e5f surface-actor-wayland: Do not send frame callbacks if the actor is obscured
`meta_surface_actor_is_obscured` implies that the actor got successfully culled
out and nothing of it will get painted. This includes that there are no clones,
no effects etc. In this cases we don't want to send frame callbacks, thus avoiding
unnecessary client work.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/918
2019-11-04 16:06:37 +01:00
Olivier Fourdan
60800d2313 renderer-native: Separate offscreen and shadowfb
Create the intermediate shadow framebuffer for use exclusively when a
shadowfb is required.

Keep the previous offscreen framebuffer is as an intermediate
framebuffer for transformations only.

This way, we can apply transformations between in-memory framebuffers
prior to blit the result to screen, and achieve acceptable performance
even with software rendering on discrete GPU.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/877
2019-11-04 10:44:42 +01:00
Carlos Garnacho
2202c0d02e tests: Explicitly set a background color for offscreen actor tests
Those change opacity and read pixels, relying on an implicit stage color.
We won't do that anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/911
2019-11-01 15:02:09 +00:00
Hans de Goede
dbb95cbe5f window-xwayland: Add Xwayland fullscreen games workaround
This is a workaround for X11 games which use randr to change the resolution
in combination with NET_WM_STATE_FULLSCREEN when going fullscreen.

Newer versions of Xwayland support the randr part of this by supporting randr
resolution change emulation in combination with using WPviewport to scale the
app's window (at the emulated resolution) to fill the entire monitor.

Apps using randr in combination with NET_WM_STATE_FULLSCREEN expect the
fullscreen window to have the size of the emulated randr resolution since
when running on regular Xorg the resolution will actually be changed and
after that going fullscreen through NET_WM_STATE_FULLSCREEN will size
the window to be equal to the new resolution.

We need to emulate this behavior for these games to work correctly.

Xwayland's emulated resolution is a per X11 client setting and Xwayland
will set a special _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on the
toplevel windows of a client (and only those of that client), which has
changed the (emulated) resolution through a randr call.

This commit checks for that property and if it is set adjusts the fullscreen
monitor rect for this window to match the emulated resolution.

Here is a step-by-step of such an app going fullscreen:
1. App changes monitor resolution with randr.
2. Xwayland sets the _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on all the
   apps current and future windows. This property contains the origin of the
   monitor for which the emulated resolution is set and the emulated
   resolution.
3. App sets _NET_WM_FULLSCREEN.
4. We check the property and adjust the app's fullscreen size to match
   the emulated resolution.
5. Xwayland sees a Window at monitor origin fully covering the emulated
   monitor resolution. Xwayland sets a viewport making the emulated
   resolution sized window cover the full actual monitor resolution.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/739
2019-11-01 14:14:21 +01:00
Hans de Goede
ae238d1d4d window: Add adjust_fullscreen_monitor_rect virtual method
Add an adjust_fullscreen_monitor_rect virtual method to MetaWindowClass
and call this from setup_constraint_info() if the window is fullscreen.

This allows MetaWindowClass to adjust the monitor-rectangle used to size
the window when going fullscreen, which will be used in further commits
for a workaround related to fullscreen games under Xwayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/739
2019-11-01 14:12:17 +01:00
Christian Hergert
6051712919 profiler: track changes in GLib and Sysprof
This tracks the changes to gdbus-codegen in terms of how GUnixFDList is
done to use the UnixFD annotation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/908
2019-10-30 16:07:36 -07:00
Carlos Garnacho
f2b3dd318f wayland: Check stylus serials on meta_wayland_seat_can_popup()
This allows xdg_popup.grab() to work with styli. Without this check
we would bail out and emit xdg_popup.popup_done, leaving stylus users
unable to interact with popup menus, comboboxes, etc...

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/886
2019-10-28 19:10:01 +00:00
Jonas Ådahl
942883577e x11: Limit touch replay pointer events to when replaying
When a touch sequence was rejected, the emulated pointer events would be
replayed with old timestamps. This caused issues with grabs as they
would be ignored due to being too old. This was mitigated by making sure
device event timestamps never travelled back in time by tampering with
any event that had a timestamp seemingly in the past.

This failed when the most recent timestamp that had been received were
much older than the timestamp of the new event. This could for example
happen when a session was left not interacted with for 40+ days or so;
when interacted with again, as any new timestamp would according to
XSERVER_TIME_IS_BEFORE() still be in the past compared to the "most
recent" one. The effect is that we'd always use the `latest_evtime` for
all new device events without ever updating it.

The end result of this was that passive grabs would become active when
interacted with, but would then newer be released, as the timestamps to
XIAllowEvents() would out of date, resulting in the desktop effectively
freezing, as the Shell would have an active pointer grab.

To avoid the situation where we get stuck with an old `latest_evtime`
timestamp, limit the tampering with device event timestamp to 1) only
pointer events, and 2) only during the replay sequence. The second part
is implemented by sending an asynchronous message via the X server after
rejecting a touch sequence, only potentially tampering with the device
event timestamps until the reply. This should avoid the stuck timestamp
as in those situations, we'll always have a relatively up to date
`latest_evtime` meaning XSERVER_TIME_IS_BEFORE() will not get confused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/886
2019-10-28 18:40:44 +00:00
Jonas Ådahl
23fa59b77c display: Move finishing of touch sequence to the backend
We need to manipulate an X11 grab when a touch sequence ends; move that
logic to where it belongs - in the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/886
2019-10-28 18:40:43 +00:00
Georges Basile Stavracas Neto
563e7139b6 Allow changing Clutter debug flags at runtime
This way, we can simply pop up the Looking Glass and run:

 >>> Meta.add_clutter_debug_flags(Clutter.DebugFlag.PICK, 0, 0)

And measure specific actions or events on GNOME Shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/862
2019-10-25 19:12:34 +00:00
Adam Jackson
a60457c2d8 clutter: Remove behaviours
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
33d1bae03f clutter: Remove deprecated/clutter-behaviour-scale.c
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
096d78479b clutter: Remove tests/interactive/test-texture-quality.c
This is the last consumer of clutter_behaviour_depth_*, and is testing
clutter_texture_set_filter_quality which is also deprecated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
68fca552d7 clutter: Remove unused deprecated/clutter-behaviour-opacity.c
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
18e0a8f7bf clutter: Remove stray references to ClutterBehaviour{Path,Rotate}
These were removed back in cc077023 and df3d2389.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Carlos Garnacho
71c3f4af31 x11: Update X11 focus before updating MetaDisplay focus
In a similar vein to commit 8fd55fef85. This notably failed when setting
the focus on the stage (eg. to redirect key events to Clutter actors).
Deeper in MetaDisplay focus updating machinery, it would check
meta_stage_is_focused() which would still return FALSE at the time it's
called.

This would not typically have side effects, but our "App does not respond"
dialogs see the focus change under their feet, so they try to bring
themselves to focus again. This results in a feedback loop.

Changing the order results in later checks on the X11 POV of the focus
being correct, so focus is not mistakenly stolen from the close dialog,
and it actually succeeds in keeping the key focus.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1607

https://gitlab.gnome.org/GNOME/mutter/merge_requests/876
2019-10-22 14:51:36 +02:00
Adam Jackson
bd1630a12c cogl: Remove unused CoglFeatureFlags
https://gitlab.gnome.org/GNOME/mutter/merge_requests/866
2019-10-21 21:43:08 +00:00
Adam Jackson
cf107c89b8 cogl: Remove always-set COGL_FEATURE_OFFSCREEN
https://gitlab.gnome.org/GNOME/mutter/merge_requests/866
2019-10-21 21:43:08 +00:00
Carlos Garnacho
40e6aa7d94 compositor: Plug cairo_region_t leak
The MetaBackgroundActor uses a region to find out the areas that need
repainting, but forgot to free it, oops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/873
2019-10-21 19:01:37 +02:00
Carlos Garnacho
668be1f4bd backends: Plug MetaKmsPageFlipData leak
If the page flip is postponed, keep a ref to it, but still unref it
on the page flip callback anyways. Fix suggested by Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/873
2019-10-21 19:01:35 +02:00
Jan Alexander Steffens (heftig)
a444a4c5f5 EGL: Include EGL/eglmesaext.h
The eglext.h shipped by libglvnd does not include the Mesa extensions,
unlike the header shipped in Mesa.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/876
2019-10-21 14:04:30 +00:00
Georges Basile Stavracas Neto
179d5ba6a6 clutter: Split pick and paint
Add the corresponding clutter_actor_pick() and
clutter_actor_continue_pick() as public APIs,
and use them in pick overrides and ClutterEffect.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/865
2019-10-21 13:49:26 +00:00
Robert Mader
98892391d7 wayland/surface: Reset buffer_destroy_handler_id
Syncronized subsurfaces that call into `merge_pending_state` might
otherwise not create new destroy handlers, ending up with a invalid
handler ids, throwing errors and leaking.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/868
2019-10-21 12:54:36 +00:00
Carlos Garnacho
45a8806e65 x11: Iterate over selections in a safer manner for event handling
It might be the case that handling an event induces the stream to
trigger completion, hence removing itself from the list. In that
case we would operate on the no longer valid list element to fetch
the next one.

Keep a pointer to the next element beforehand, so we can tiptoe
over streams that did remove themselves.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
2019-10-21 13:19:48 +02:00
Carlos Garnacho
e1fa0734a9 x11: Detach selection streams on dispose
The streams were only detached from MetaX11Display (and its event handling)
on completion. This is too much to expect, and those might be in some
circumstances replaced while operating.

Make those streams detach themselves on dispose(), so we don't trip into
freed memory later on when trying to dispatch unrelated X11 selection events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
2019-10-21 11:47:40 +02:00
Cosimo Cecchi
8665084df1 monitor-manager: check for underscan setting validity upfront
Instead of doing a roundtrip to the X server before setting it, rely on
the previous value fetched before the configuration was sent over DBus.
This matches the argument check we already do elsewhere, and will allow
us to more easily add an additional condition to determine if underscan
is supported.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/673
2019-10-16 14:34:14 +00:00
Daniel van Vugt
e82a657cd9 clutter/actor: Remove color from the pick virtual function
It's unused since commit 14c706e51.

**ABI break**

https://gitlab.gnome.org/GNOME/mutter/merge_requests/851
2019-10-16 12:01:16 +00:00
Georges Basile Stavracas Neto
bdf5e3f357 Replace ClutterGeometry by graphene_rect_t
The last of the replacements. It is fine for now
to replace ClutterGeometry's integers by floats.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
94682e69aa Replace ClutterRect by graphene_rect_t
https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
160cc9182d Replace ClutterPoint by graphene_point_t
Remove the tests for ClutterPoint since it's
corresponding code moved to private ClutterStage
methods.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
a5d0cfe8fb Replace ClutterVertex by graphene_point3d_t
Pretty direct and straightforward port. This requires a
GNOME Shell counterpart. In addition to that, include a
progress function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
959a418cc3 Replace CoglEuler by graphene_euler_t
As the first step into removing Cogl types that are covered by
Graphene, remove CoglEuler and replace it by graphene_euler_t.

This is a mostly straightforward replacement, except that the
naming conventions changed a bit. Cogl uses "heading" for the
Y axis, "pitch" for the X axis, and "roll" for the Z axis, and
graphene uses the axis themselves. That means the 1st and 2nd
arguments need to be swapped.

Also adapt the matrix stack to store a graphene_euler_t in the
rotation node -- that simplifies the code a bit as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
3ecae81809 clutter/tests: Rename variable
Graphene uses C99 and includes stdbool.h, which adds a
new 'bool' type. Clutter has an a11y test that names a
variable as 'bool' too, and they do not play well together.

Rename this variable to boolean.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
b1a1d4e13d Remove fog support
Fog is explicitly deprecated in favour of CoglSnippet API,
and in nowhere we are using this deprecated feature, which
means we can simply drop it without any sort of replacement.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Jonas Ådahl
f7315c9a36 window-actor: Move shapes, shadows and unredirection to X11 sub types
Move out updating of various shapes (input, opaque, shape) indirectly
from X11 to the corresponding X11 sub types of MetaWindowActor and
MetaSurfaceActor.

Also move fullscreen window unredirection code with it. We want to
effectively do something similar for MetaCompositorServer, but it will
work differently enough not to share too much logic.

While it would have been nice to move things piece by piece, things were
too intertwined to make it feasible.

This has the side effect fixing accidentally and arbitrarily adding
server side shadow to Wayland surfaces.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/727

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:16:55 +02:00
Jonas Ådahl
9ac52f0340 compositor/x11: Move unredirect logic to helper
It makes it clearer what is required for unredirecting a window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Jonas Ådahl
f059466337 window-actor/x11: Use g_clear_signal_handler()
Also fixes type of handler ID.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Jonas Ådahl
dcd0f4322a shaped-texture: Add API to check opaqueness
It is opaque if the texture has no alpha channel, or if the opaque
region covers the whole content.

Internally uses a function that checks whether there is an alpha
channel. This API will be exposed at a later time as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Niels De Graef
8e204e036a cogl: Add a notion of pixel format planes
As we will start adding support for more pixel formats, we will need to
define a notion of planes. This commit doesn't make any functional
change, but starts adding the idea of pixel formats and how they (at
this point only theoretically) can have multple planes.

Since a lot of code in Mutter assumes we only get to deal with single
plane pixel formats, this commit also adds assertions and if-checks to
make sure we don't accidentally try something that doesn't make sense.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/858
2019-10-15 16:35:16 +00:00
Carlos Garnacho
97010ac64d meta: Move private defines to a private header
These defines are unused outside of mutter, and actually not
desirable to export. Move them to a private header.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/859
2019-10-15 11:03:56 +00:00
Marco Trevisan (Treviño)
2773e8adf8 clutter/actor: Remove deprecated internal child support
Clutter had support for internal children in its early revisions, but they
were deprecated for long time (commit f41061b8df, more than 7 years ago) and
no one is using them in both clutter and in gnome-shell.

So remove any alternative code path that uses internal children.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/816
2019-10-15 08:51:45 +00:00
Jonas Ådahl
e17d70a592 x11/window-controls: Pass around MetaX11Display directly
Instead of passing around an X11 Display pointer that is retrieved from
the default Gdk backend, then finding the MetaX11Display from said X11
Display, pass the MetaX11Display directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
da213febdc core/core: Rename and move to x11/meta-x11-window-control
The functionality core/core.c and core/core.h provides are helpers for
the window decorations. This was not possible to derive from the name
itself, thus rename it and put it in the right place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
7c2e926c44 core/core: Remove meta_retheme_all() helper
All it did was get the MetaDisplay and call a function on it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
c474ad6a53 Stop including core.h where it's not used
It provides glue for window frame controls and internal window
management, and that is only relevant for a couple of places in src/ui/.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
877ecc1bb4 core/core: Remove unused function
https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Niels De Graef
0d0286d59e cogl: Remove COGL_INVALID_HANDLE
Just use `NULL`, which is the normal C convention

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Niels De Graef
23f77a1b63 cogl: Remove cogl_handle_ref/unref
This is for all intents and purposes the same as
`cogl_object_ref/unref`, but still refers to handles rather than
objects (while we're trying to get rid of the former) so it's a bit of
unnecessary redundant API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Robert Mader
317ce05a27 window-actor: Add a missing NULL-check
We shouldn't crash on a NULL-clip.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/856
2019-10-14 18:23:32 +02:00
Robert Mader
a8155a0471 meta: Add META namespace to macros
To silence warnings during GIR generation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/822
2019-10-14 10:14:11 +00:00
Niels De Graef
5e7fa20f06 wayland-egl-stream: Add log message on sucessful dlopen
Right now, there is no feedback message that tells you whether the
nvidia-egl-wayland module was succesfully loaded.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/853
2019-10-14 10:53:38 +02:00
Niels De Graef
3a688988e0 dbus-session-watcher: Chain up to parent finalize()
https://gitlab.gnome.org/GNOME/mutter/merge_requests/847
2019-10-14 09:09:01 +02:00
Carlos Garnacho
5c1be2233d x11: Map mimetypes back to selection atoms
This may be seen as the missing half of
https://gitlab.gnome.org/GNOME/mutter/merge_requests/842. Now that we
translate some atoms to better known mimetypes, we should also translate
those mimetypes to the underlying atoms if we might have added them.

Fixes c&p from certain X11 clients.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/854
2019-10-12 19:18:19 +02:00
Carlos Garnacho
e1751ad9ee wayland: Figure out better the right selection source for a wl_data_offer
We were just looking at DnD actions which might still be unset at that
point. Instead of doing these heuristics, store the selection type on
the data offer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/845
2019-10-12 01:19:48 +02:00
Carlos Garnacho
84cc89e19a wayland: Set dummy selection source on .set_selection(null)
Requesting a selection with a NULL data source means "unset the clipboard",
but internally we use an unset clipboard as the indication that the
clipboard manager should take over.

Moreover, this unset request may go unheard if the current owner is someone
else than the MetaWaylandDataDevice.

Instead, set a dummy data source with no mimetypes nor data, this both
prevents the clipboard manager from taking over and ensures the selection
is replaced with it.

The MetaSelectionSourceMemory was also added some checks to allow for this
dummy mode.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/793
2019-10-11 23:04:01 +02:00
Carlos Garnacho
ea4665bf51 wayland: Simplify MetaSelectionSourceWayland
Instead of taking resource and send/cancel funcs, take a
MetaWaylandDataSource, which exposes all the vfuncs to do the same on the
internal resource.

This has the added side effect that only MetaWaylandDataSource has a
pointer to the wl_resource, which may be unset untimely.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/842
2019-10-11 23:04:01 +02:00
Carlos Garnacho
227d272049 wayland: Check resource before emitting cancelled event
If a data source is destroyed we first unset the resource, and then try to
unref the related selection source. At this point the only event that might
be emitted by the internal selection machinery is .cancelled, so make sure
we avoid it on destroyed sources.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/842
2019-10-11 23:01:44 +02:00
Carlos Garnacho
e53db92a7b wayland: Emit wl/primary offer after changing selection
We are still poking the mimetypes from the previous selection when creating
the new offer. This may come out wrong between changes of the copied
mimetypes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/789
2019-10-11 23:00:12 +02:00
Carlos Garnacho
dd2b1278a0 wayland: Chain up to the right finalize on MetaWaylandDataSourceWayland
This function was using the wrong parent class pointer, so it was mistakenly
skipping over MetaWaylandDataSource::finalize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Carlos Garnacho
f2e2fcf758 wayland: Drop field from MetaWaylandDataSourcePrimary
This is a subclass of MetaWaylandDataSourceWayland, so there's no need
for a duplicate wl_resource field. Make sure to reuse the parent struct
one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Carlos Garnacho
dfd44ff971 wayland: Plug MetaSelectionSourceWayland leaks
There was a dangling ref left on all of them, oops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Jonas Ådahl
69a0c1dc80 main: Warn instead of error in meta_test_init()
Otherwise we'll get the warning

../src/core/main.c: In function 'meta_test_init':
../src/core/main.c:755:1: error: function might be candidate for attribute 'noreturn' [-Werror=suggest-attribute=noreturn]
  755 | meta_test_init (void)
      | ^~~~~~~~~~~~~~

when building without Wayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/837
2019-10-10 22:51:00 +00:00
Jonas Ådahl
1b4709794e kms/crtc: Read gamma state when prediction failed
If we did a mode set, the gamma may have been changed by the kernel, and
if we didn't also update the gamma in the same transaction, we have no
way to predict the current gamma ramp state. In this case, read the
gamma state directly from KMS.

This should be relatively harmless regarding the race conditions the
state prediction was meant to solve, as the worst case is we get none or
out of date gamma ramps; and since this is for when gamma ramps are not
updated at mode setting time, we'd get intermediate gamma state to begin
with, so it's not worse than what we currently do anyway.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/851

https://gitlab.gnome.org/GNOME/mutter/merge_requests/840
2019-10-10 14:46:32 +00:00
Jonas Ådahl
1cc249fe18 kms: Always predict state after processing update
Not only mode sets have state that should be predicted; changing gamma
currently happens with its own update, so we missed predicting that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/840
2019-10-10 14:46:32 +00:00
Marco Trevisan (Treviño)
446bd04b6c clutter-backend-x11: Don't push keymap events to clutter
Xkb events should be handled by clutter backend but they are not translated
into an actual clutter event. However we're now handling them and also trying
to push an empty event to clutter queue, causing a critical error.

So in such case, just handle the native event but don't push the non-populated
clutter-event to the queue.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/750
https://gitlab.gnome.org/GNOME/mutter/merge_requests/764
2019-10-10 13:00:02 +00:00
Marco Trevisan (Treviño)
9234fcb624 event-x11: Use CLUTTER prefix for X11 filter docs
As per commit ad72fa46b clutter_x11_handle_event was renamed into
meta_x11_handle_event but the return type didn't change.

So, keep the doc-string to match the actual possible return values.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/764
2019-10-10 13:00:02 +00:00
Carlos Garnacho
59a697f773 x11: Translate well known selection atoms to mimetypes
Some antediluvian x11 clients only bother to set atoms like
UTF8_STRING/STRING/TEXT/... and no matching mimetypes. Cover for them
and add the well known mimetypes if they are missing.

Reported at https://bugzilla.redhat.com/show_bug.cgi?id=1758873

https://gitlab.gnome.org/GNOME/mutter/merge_requests/842
2019-10-10 12:13:46 +00:00
Jonas Ådahl
d49d10b14f wayland/actor-surface: Queue redraw for frame callback
A frame callback without damage is still expected to be responded to.
Implement this by simply queuing damage if there are any frame callbacks
requested and there is no damage yet. If there already is damage,
we'll be queued already, but with more correct damage. Without we simply
need to make sure we flush the callbacks if any area of surface is not
occluded.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/457

https://gitlab.gnome.org/GNOME/mutter/merge_requests/839
2019-10-10 10:01:05 +00:00
Jonas Ådahl
4c15d32b55 wayland/surface: Some minor coding style clean up
Some very long lines that were split up.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/839
2019-10-10 10:01:05 +00:00
Tim Klocke
81ee8886ce backends: Update inhibited state for the monitor and respect that state
The inhibited state of the monitor was after the initializiation never
updated. meta_idle_monitor_reset_idletime didn't respect the inhibited
state, so it set timeouts if it shouldn't have.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/573
2019-10-09 09:53:32 +00:00
Carlos Garnacho
d9597d2148 wayland: Ensure to forward numlock state to clients
This makes sure the numlock key lock state is forwarded to the wl_keyboard
internal state, notably on startup and after keymap changes.

https://gitlab.gnome.org/GNOME/mutter/issues/769
2019-10-07 22:28:45 +00:00
Carlos Garnacho
fc3831c797 backends: Fix thinko
We are meant to pass a flagset there, not a boolean. Fixes state querying
to the ClutterKeymap in the native backend.

https://gitlab.gnome.org/GNOME/mutter/issues/769
2019-10-07 22:28:45 +00:00
Carlos Garnacho
ce86f90efb Revert "backends/x11: Do not reload keymap on new keyboard notifications"
This reverts commit b01edc22f3.

It breaks keybindings on certain physical keyboard layouts.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/822
2019-10-07 22:15:02 +00:00
Jonas Ådahl
b5f50028f2 wayland: Untie MetaWindowXwayland lifetime from the wl_surface
For the most part, a MetaWindow is expected to live roughly as long as
the associated wl_surface, give or take asynchronous API discrepancies.

The exception to this rule is handling of reparenting when decorating or
undecorating a window, when a MetaWindow on X11 is made to survive the
unmap/map cycle. The fact that this didn't hold on Wayland caused
various issues, such as a feedback loop where the X11 window kept being
remapped. By making the MetaWindow lifetime for Xwayland windows being
the same as they are on plain X11, we remove the different semantics
here, which seem to lower the risk of hitting the race condition causing
the feedback loop mentioned above.

What this commit do is separate MetaWindow lifetime handling between
native Wayland windows and Xwayland windows. Wayland windows are handled
just as they were, i.e. unmanaged together as part of the wl_surface
destruction; while during the Xwayland wl_surface destruction, the
MetaWindow <-> MetaWaylandSurface association is simply broken.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/740
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/762

https://gitlab.gnome.org/GNOME/mutter/merge_requests/774
2019-10-07 20:25:20 +00:00
Jonas Ådahl
fb6e2743ec plugins/default: Hold reference on timelines while stopping
We get implicit, thus auto-removed, transitions, then manage them
manually by stopping them and emitting "completed" signals. This doesn't
work since they are removed and freed when stopped. To be able to emit
the "completed" signal, hold a reference while stopping, so that we
still can emit the signal as before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/828
2019-10-07 18:33:28 +00:00
Carlos Garnacho
107e521553 wayland: Unset pointer constraint in the backend before dropping the grab
Dropping the grab has the side effect that the pointer will be re-picked,
and it might find another surface with a pointer constraint. If that were
the case, the focus change would try to add the pointer constraint before
the now old focus surface released its own.

Just invert these operations, so the constraint is unset before the repick
that might enable another pointer constraint.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:37:13 +02:00
Carlos Garnacho
7735a919d1 wayland: Check pointer visibility on post-grab focus changes
Just like sync_focus_surface() does, we shouldn't set a focus surface while
the pointer is hidden, so the illusion that there is none remains.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:37:13 +02:00
Carlos Garnacho
9f617ae43d wayland: Warn if a surface is being set while the pointer is invisible
This is an unexpected condition, better not to fall in it without further
indications.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:30:09 +02:00
Jonas Ådahl
104bdde746 kms: Predict state changes when processing update
We can't just update the state of the connector and CRTC from KMS since
it might contain too new updates, e.g. from a from a future hot plug. In
order to not add ad-hoc hot plug detection everywhere, predict the state
changes by looking inside the MetaKmsUpdate object, and let the hot-plug
state changes happen after the actual hot-plug event.

This fixes issues where connectors were discovered as disconnected while
doing a mode-set, meaning assumptions about the connectedness of
monitors elsewhere were broken until the hot plug event was processed.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/782

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Jonas Ådahl
2a990cc140 kms/update: Add helper to turn fixed point rect into int rect
Currently unused, but will in the following commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Jonas Ådahl
3e41568074 kms/update: Add helper to get primary plane assignment
Replaces a private static function, with no functional changes made to
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Robert Mader
66ae09b670 wayland/subsurface: Check if actor exists before unparenting
When we call the subsurface destructor the actor might be gone already.
Check first, like we do in other places, to avoid warnings.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/829
2019-10-07 08:29:18 +00:00
Dorian Stoll
7b97c7b35e wayland/tablet-tool: Fix stylus input with HiDPI scaling
After commit 75cffd0e ("shaped-texture: Implement ClutterContent"), the
input to the meta_wayland_tablet_tool_get_relative_coordinates function
is already scaled correctly. By scaling it again, all stylus events are
getting mapped to the screen incorrectly (for anything != 100% scaling).

See also: d3f30d9e

https://gitlab.gnome.org/GNOME/mutter/merge_requests/830
2019-10-06 22:30:26 +02:00
Jonas Ådahl
ca318c1520 wayland/actor-surface: Pass actor surface to actor destroy handler
Correct silly mistake where the MetaWaylandSurface was passed as the
user_data of the surface actor destroy signal handler, instead of the
expected MetaWaylandActorSurface.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/844
2019-10-04 13:47:18 +02:00
Jonas Ådahl
cbb4f6c892 wayland/actor-surface: Handle surface actor destruction
A surface actor may be destroyed without the backing Wayland surface
being destroyed yet, e.g. by the window being unmanaged. Handle this by
listening on the "destroy" signal and making late requests (e.g.
wl_surface_commit()) resilient against the lack of a surface actor.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/838

https://gitlab.gnome.org/GNOME/mutter/merge_requests/825
2019-10-03 22:13:25 +00:00
Jonas Ådahl
092b3edb51 wayland/actor-surface: Add actor clear helper
No functional changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/825
2019-10-03 22:13:25 +00:00
Hans de Goede
fa461525ee window-x11: Refactor meta_prop_get_latin1_string() calls
Instead of storing the result of meta_prop_get_latin1_string() into
a temporary string value, g_strdup-ing that temp value storing the
g_strdup result into window->sm_client_id and then g_free-ing the
temporary string, we can pass window->sm_client_id as the place where
meta_prop_get_latin1_string() stores its result, since the result
from meta_prop_get_latin1_string() is itself a g_strdup-ed string,
so there is no need to g_strdup it again.

Note this drops the check to only issue the
"Window %s sets SM_CLIENT_ID on itself ..." warning once. This check is
not necessary as update_sm_hints() is only called once at window
creation time and is never called again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
8e510a07c4 xprops: Use g_new0 instead of malloc in size_hints_from_results()
Switch the memory allocation in size_hints_from_results from a malloc call
without error-checking to g_new0 and adjust the free path accordingly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
e153524748 xprops: Use g_strdup in class_hint_from_results()
Use g_strdup instead of malloc + strcpy, this also gets rid of a bunch
of error checking which is no longer necessary, also adjust the free
path accordingly.

Note that there was a malloc + XFree mismatch in the removed error-handling.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
eb8a1f42bc xprops: Use g_new0 instead of calloc in wm_hints_from_results()
Switch the memory allocation in wm_hints_from_results from a calloc call
without error-checking to g_new0 and just the free path accordingly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
89cd9d382d xprops: Use g_free instead of XFree in text_property_from_results()
results->prop is g_malloc memory so it should be free-ed with g_free not
XFree. The same applies to the return value of text_property_from_results
itself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
488991b0f6 xprops: Free counter_list_from_results() return value with g_free()
counter_list_from_results directly passes through the results->prop
pointer which is g_malloc memory, so we should free the buffer it
returns with g_free.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
e2330617ac xprops: Free latin1/utf8_string_from_results() return value with g_free()
latin1_string_from_results and utf8_string_from_results use g_strndup,
so the returned string should be freed with g_free, rather then with
free or XFree. This fixes all free-s of buffers returned by these 2
functions to properly use g_free.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
5e6d98e79f xprops: Use g_new0 instead of calloc in meta_prop_get_motif_hints()
Use g_new0 instead of calloc for motif_hints_from_results and adjust
its callers to use g_free.

Note that in the process_request_frame_extents function this replaces
the wrong original mismatch of calloc + XFree with a matching g_malloc +
g_free pair.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
5eaf655224 xprops: Free meta_prop_get_cardinal_list() return value with g_free()
meta_prop_get_cardinal_list directly passes through the results->prop
pointer which is g_malloc memory, so we should free the buffer it
returns with g_free.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
2c1553570f xprops: Free atom_list_from_results() return value with g_free()
atom_list_from_results directly passes through the results->prop
pointer which is g_malloc memory, so we should free the buffer it
returns with g_free.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Hans de Goede
c937dd5ba3 xprops: Use meta_XFree instead of XFree in validate_or_free_results()
Use meta_XFree instead of XFree, letting meta_XFree do the NULL
checks for us.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/786
2019-10-03 17:20:54 +00:00
Ting-Wei Lan
006eb6d81e build: Fix build when wayland is disabled
https://gitlab.gnome.org/GNOME/mutter/merge_requests/817
2019-10-03 08:52:44 +00:00
Marco Trevisan (Treviño)
105a3f757a clutter/actor: Don't emit property changes after ::destroy
Clutter actors might emit property changes in dispose, while unparenting.
However we assume that the ::destroy signal is the last one we emit for an
actor, and that starting from this moment the object is not valid anymore,
and so we don't expect any signal emission from it.

To avoid this, freeze the object notifications on an actor during its
disposition, just before the ::destroy signal emission.

Update the actor-destroy test to verify this behavior.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/769
2019-10-02 17:59:22 +00:00
Marco Trevisan (Treviño)
f376a318ba clutter/actor: Don't emit the parent-set signal on destruction
Clutter actors unset their parent on dispose, after emitting the ::destroy
signal, however this could cause ::parent-set signal emission. Since we
assume that after the destruction has been completed the actor isn't valid
anymore, and that during the destroy phase we do all the signal / source
disconnections, this might create unwanted behaviors, as in the signal
callbacks we always assume that the actor isn't in disposed yet.

To avoid this, don't emit ::parent-set signal if the actor is being
destroyed.

Update the actor-destroy test to verify this behavior.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/769
2019-10-02 17:59:22 +00:00
Olivier Fourdan
4b88c1832a events: Sync pending pointer events without a window
Mutter issues a synchronous grab on the pointer for unfocused client
windows to be able to catch the button events first and raise/focus
client windows accordingly.

When there is a synchronous grab in effect, all events are queued until
the grabbing client releases the event queue as it processes the events.

Mutter does release the events in its event handler function but does so
only if it is able to find the window matching the event. If the window
is a shell widget, that matching may fail and therefore Mutter will not
release the events, hence causing a freeze in pointer events delivery.

To avoid the issue, make sure we sync the pointer events in case we
can't find a matching window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/821
2019-10-02 17:13:16 +02:00
Jonas Ådahl
7049b2f274 Revert "renderer-native: Actually use shadow fb when using software rendering"
It was not the lack of forcing the shadow fb that caused slowness, but
rather due to the method the shadow fb content was copied onto the
scanout fb. With 'clutter: Use cogl_blit_framebuffer() for shadow FB'
we'll use a path that shouldn't be slow when copying onto the scanout
fb.

Also 437f6b3d59 accidentally enabled
shadow fb when using hw accelerated contexts, due to the cap being set
to 1 in majority of drivers. While the kernel documentation for the
related field says "hint to userspace to prefer shadow-fb rendering",
the name of the hint when exposed to userspace is
DRM_CAP_DUMB_PREFER_SHADOW, thus should only be taken into consideration
for dumb buffers, not rendering in general.

This reverts commit 437f6b3d59.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/818
2019-09-30 11:30:47 +02:00
Jonas Ådahl
437f6b3d59 renderer-native: Actually use shadow fb when using software rendering
The commit 'renderer/native: Use shadow fb on software GL if preferred'
attempted to force using a shadow fb when using llvmpipe in order to
speed up blending, but instead only did so when llvmpipe AND the drm
device explicityl asked for it.

Now instead always force it for llvmpipe and other software rendering
backends, and otherwise just query the drm device (i.e.
DRM_CAP_DUMB_PREFER_SHADOW).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/807
2019-09-27 21:18:59 +00:00
Robert Mader
25c1a85384 wayland/dnd-surface: Scale DnD-surface-actor content if necessary
Since the recent clutter-content work, legacy scaling (in contrast
to the new stage-view-scaling) only applies to surfaces that belong
to a window. This broke scaling of DnD surfaces.

As a workaround, apply the same scaling on DnD-surface-actors until
we use stage-view-scaling by default and can remove this again.

Also: small corrections of geometry calculation

https://gitlab.gnome.org/GNOME/mutter/merge_requests/780
2019-09-27 15:48:36 +00:00
Robert Mader
bba8f6c53e wayland/actor-surface: Turn get_geometry_scale() into a vfunc
This allows us to implement more sophisticated logic for the different
cases. For DnD surfaces, use the geometry scale of the monitor where
the pointer is, instead of incorrectly assuming '1' as it was before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/780
2019-09-27 15:48:36 +00:00
Jonas Ådahl
dbe9daeb76 main: Make process PR_SET_DUMPABLE
Otherwise we won't get core dumps if the launching binary has
capabilities set.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/811
2019-09-27 14:27:09 +00:00
Carlos Garnacho
8fd55fef85 x11: Update focus on the X11 display before the MetaDisplay
The meta_display_update_focus_window() call has indirect dependencies
on the X11 focus window, in order to determine the correct focus window
on the Wayland side (i.e. may turn out NULL with certain X windows).

In order to have the right x11_display->focus_xwindow there, we should
perform first the focus update on the X11 display.

Fixes focusing of Java applications, as those don't seem to go through
_NET_ACTIVE_WINDOW.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/819
2019-09-27 13:52:12 +00:00
Jonas Ådahl
f352c3d79d display: Handle late unredirect (un)inhibit calls
When tearing down, gnome-shell may call various methods a bit late,
specifically while MetaDisplay is closing, after MetaCompositor is
freed.

Handle calls to the fullscreen unredirect inhibitation counters
happening after MetaCompositor tear down by ignoring them. We're closing
anyway, so it's not a problem.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1710

https://gitlab.gnome.org/GNOME/mutter/merge_requests/808
2019-09-26 11:43:00 +02:00
Olivier Fourdan
76f2579e44 keybinding: Check for handler functions as well
With the addition of the locate-pointer special keybinding (defaults to
the [Control] key), we have now two separate special modifier keys which
can be triggered separately, one for the locate-pointer action and
another one for overlay.

When processing those special modifier keys, mutter must ensure that the
key was pressed alone, being a modifier, the key could otherwise be part
of another key combo.

As result, if both special modifiers keys are pressed simultaneously,
mutter will try to trigger the function for the second key being
pressed, and since those special modifier keys have no default handler
function set, that will crash mutter.

Check if the handler has a function associated and treat the keybinding
as not found if no handler function is set, as with the special modifier
keys.

https://gitlab.gnome.org/GNOME/mutter/issues/823
2019-09-24 17:08:20 +02:00
Olivier Fourdan
0706e021f5 keybindings: Check for a handler before using it
The `process_event()` would check for a existing keybinding handler and
abort if there is none, however the test is done after the handler had
been accessed, hence defeating the purpose of the check.

Move the check to verify there is an existing keybinding handler before
actually using it.

https://gitlab.gnome.org/GNOME/mutter/issues/823
2019-09-24 17:08:20 +02:00
Robert Mader
b5775e3d85 window-actor: Use surface coordinates for the fast path in get_image()
shaped_texture requires the clip to be in surface coordinates. Scale
it accordingly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/758
2019-09-20 16:42:55 +00:00
Robert Mader
cd70595b50 shaped-texture: Use surface coordinates in get_image()
There were multiple bugs present after the ClutterContent transition.
Refactor `get_image` to:

- always assume surface coordinates for the clip
- return a cairo_surface in buffer size
- make the offscreen path take size arguments, so we can
easily change the assumption in get_image
- fix some clipping bugs on the way

https://gitlab.gnome.org/GNOME/mutter/merge_requests/758
2019-09-20 16:42:55 +00:00
Marco Trevisan (Treviño)
1d2913d9b9 shaped-texture: Declare that we inherit from GObject
As per commit 75cffd0ec MetaShapedTexture is a GObject implementing the Clutter
Content interface.

Reflect this on the type declaration.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/796
2019-09-20 15:03:52 +00:00
Marco Trevisan (Treviño)
b8a49a682e window/surface-actor: Add docstrings
Redefine the docstring for functions using shaped texture, setting the clip
as nullable.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/79
2019-09-20 15:03:52 +00:00
Marco Trevisan (Treviño)
82901f89d5 shaped-texture: Mark set the clip and return value nullable
As per the code definition the clip can be a null rectangle, and we can also
return a null surface, so mark them as nullable in the introspection.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/796
2019-09-20 15:03:52 +00:00
Adam Jackson
031003a5dc wayland/dma-buf: Handle zero modifiers from eglQueryDmaBufModifiersEXT
Some drivers expose EGL_EXT_image_dma_buf_import_modifiers so you can
query supported formats, but don't support any modifiers. Handle this by
treating it like DRM_FORMAT_MOD_INVALID.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/782
2019-09-20 12:09:13 +00:00
Daniel van Vugt
7a0340c57d kms-impl-device: Use portable formatting for 64-bit integers
On 64-bit systems uint64_t is %lu but on 32-bit systems it is %llu.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/778
2019-09-20 11:55:49 +02:00
Daniel van Vugt
0863bd2408 output-kms: Use portable formatting for 64-bit integers
On 64-bit systems uint64_t is %lu but on 32-bit systems it is %llu.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/778
2019-09-20 11:55:42 +02:00
Daniel van Vugt
594cc7c7d6 input-settings: Use portable formatting for 64-bit integers
On 64-bit systems int64_t is %lx but on 32-bit systems it is %llx.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/778
2019-09-20 11:55:35 +02:00
Jonas Ådahl
0e69fe0781 idle-monitor: Reset timeout before firing watch
The watch might be removed during firing, meaning the source is
destroyed after returning. Avoid use-after-free by unsetting the timeout
before firing. Returning G_SOURCE_CONTINUE in that case is harmless, as
source is destroyed.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/796

https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
2019-09-16 18:08:18 +00:00
Jonas Ådahl
26b08d87a8 idle-monitor: Remove redundant type cast
No need to type cast a `MetaIdleMonitorWatch *` to a
`MetaIdleMonitorWatch *`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
2019-09-16 18:08:18 +00:00
Jonas Ådahl
321ab3b367 idle-monitor: Make helper function static
It wasn't used outside the file, so no reason to not have it static.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
2019-09-16 18:08:18 +00:00
Michal Lazo
4d0869e206 kms-device: Free path when finalizing
free path in finalize

https://gitlab.gnome.org/GNOME/mutter/merge_requests/775
2019-09-16 16:41:46 +00:00
Michal Lazo
d13cea6ccb kms-device: Handle impl device creation failure
Properly free kms-device in case of invalid initialization

https://gitlab.gnome.org/GNOME/mutter/merge_requests/772
2019-09-16 16:34:39 +00:00
Carlos Garnacho
6922f0e16a x11: Minor refactor of input focus handling code
Instead of open coding the X11 focus management in display.c, expose
it as a single function with similar arguments to its MetaDisplay
counterpart. This just means less X11 specifics in display.c.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/751
2019-09-13 20:55:57 +00:00
Carlos Garnacho
31df06d94e x11: Use the currently focused X window for _NET_ACTIVE_WINDOW
MetaDisplay and MetaX11Display focus windows are slightly decoupled,
we cannot rely here on the MetaDisplay focus to be updated yet. We
however know the X Window that got focused, so lookup the corresponding
MetaWindow (and client X window) from it.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/751
2019-09-13 20:55:56 +00:00
Georges Basile Stavracas Neto
7a22f6fd3f Fix a few tracing typos
They are missing the closing parenthesis. Add them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/795
2019-09-12 14:30:44 -03:00
Carlos Garnacho
850ef51879 core: Split x11-display initialization in 2 signals
We have a "setup" phase, used internally to initialize early the x11
side of things like the stack tracker, and an "opened" phase where
other upper parts may hook up to. This latter phase is delayed during
initialization so the upper parts have a change to connect to on
plugin creation.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/771
2019-09-11 22:30:13 +02:00
Jonas Ådahl
ef2e04a613 plugins/default: Get default keymap from localed
When starting standalone mutter and running using the native backend, we
always fall back on using the us pc105 keyboard layout. This can be very
frustrating if one is used to using some other keyboard layout, such as
dvorak, causing keyboard fumbling everytime when doing something with
standalone mutter.

Avoid this involuntary fumbling by having the default plugin query
localed what layout the user has actually configured the machine to
operate using. It doesn't add any keymap selection user interface, so
it'll always use the first one it encounters.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/787
2019-09-10 20:09:40 +00:00
Jonas Ådahl
5111e33948 monitor-manager/kms: Get hotplug events from MetaKms
This makes it clearer that MetaMonitorManagerKms keeps updated as
MetaKms updates its state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/743
2019-09-05 08:03:36 +00:00
Jonas Ådahl
4cf828323d kms/impl-device: Add and remove connectors on hot plug
Connectors may disappear and appear on hot plugs, e.g. when a docking
station is connected, so when processing a hot plug event, make sure we
remove connectors that are now gone, and add new ones that have appeared
since last time.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/728

https://gitlab.gnome.org/GNOME/mutter/merge_requests/743
2019-09-05 08:03:36 +00:00
Jonas Ådahl
35776c5d29 kms: Add assert to check that the main thread is blocked on impl task
This is so that we can have code in impl tasks that pokes at the main
context objects.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/743
2019-09-05 08:03:36 +00:00
Jonas Ådahl
2f27b8d5fa window-actor: Handle changing surface actor on window reparenting
The commit f2f4af0d50 missed one situation
where mutter does things differently, i.e. changes what surface actor is
associated with a given window actor: reparenting a Xwayland window when
changing whether it is decorated.

To summarize, there are three types of window actors:

X11 window actors - directly tied to the backing X11 window. The
corresponding surface actor is directly owned by the window actor and
will never change.

Wayland window actors - gets its surface actor from MetaWaylandSurface
at construction. A single MetaWaylandSurface may create and destroy
multiple window actors over time, but a single window actor will never
change surface actor.

Xwayland window actors - a mix between the above two types; the window
corresponds to the X11 window, and so does the window actor, but the
surface itself comes from the MetaWaylandSurface.

Normally when a X11 window is unmapped, the corresponding MetaWindow is
unmanaged. With Xwayland, this happens indirectly via the destruction of
the wl_surface. The exception to this is windows that are reparented
during changing their decoration state - in this case on plain X11, the
MetaWindow stays alive. With Xwayland however, there is a race
condition; since the MetaWindow is tied to the wl_surface, if we receive
the new surface ID atom before the destruction of the old wl_surface,
we'll try to associate the existing MetaWindow and MetaWindowActor with
the new wl_surface, hitting the assert. If the surface destruction
arrives first, the MetaWindow and MetaWindowActor will be disposed, and
the we wouldn't hit the assert.

To handle this race gracefully, reinstate handling of replacing the
surface actor of an existing window actor, to handle this race, as it
was handled before.

Eventually, it should be reconsidered whether the MetaWindow lifetime is
tied to the wl_surface or if it should be changed to be consistent with
plain X11, as this re-exposes another bug where the X11 client and
mutter will enter a feedback loop where the window is repeatedly
remapped. See https://gitlab.freedesktop.org/xorg/xserver/issues/740.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/709

https://gitlab.gnome.org/GNOME/mutter/merge_requests/773
2019-09-05 07:43:40 +00:00
Olivier Fourdan
be4131b3c4 wayland/xdg-output: Fix xdg-output v3 support
When using xdg-output v3 or later, the Wayland compositor does not send
xdg_output.done events which are deprecated.

Instead, it should send a wl_output.done event for the matching
wl_output.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/771
2019-09-05 07:29:10 +00:00
Jonas Ådahl
3c0067dc69 x11: Trace XEvent processing
https://gitlab.gnome.org/GNOME/mutter/merge_requests/765
2019-09-02 17:36:00 +00:00
Jonas Ådahl
a957c2f0c2 wayland: Trace wl_surface.commit
https://gitlab.gnome.org/GNOME/mutter/merge_requests/765
2019-09-02 17:36:00 +00:00
Jonas Ådahl
908203c735 core: Trace various window management actions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/765
2019-09-02 17:36:00 +00:00
Olivier Fourdan
2f072af02b clutter/input-pointer-a11y: Restore pointer a11y on resume
When suspending, the devices are removed and the virtual device
associated with the corresponding core pointer is disposed.

Add the pointer accessibility virtual device to the core pointer
on resume to restore pointer accessibility on resume if enabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/761
2019-09-02 17:27:17 +00:00
Olivier Fourdan
de98fb29da wayland/data-device: Restore keyboard focus on drag end
When starting a DnD operation, mutter would remove keyboard focus from
the client, only to restore it on the data offer destroy.

However, if the DnD fail, the keyboard focus is not restored, leaving
the user unable to type in the focused window, even after clicking in
the window.

That issue would show only on first attempt, as further DnD attempts
would destroy the previous data offer which would also restore the
keyboard focus.

Make sure we restore the keyboard focus on drag end as well.

https://gitlab.gnome.org/GNOME/mutter/issues/747
2019-09-02 17:06:06 +00:00
Olivier Fourdan
82c92177ff wayland/data-device: Do not unset focus on drag start
On drag start, `data_device_start_drag()` issues a keyboard grab, which
in turn will unset the current input focus.

There is not need to unset the input focus in `data_device_start_drag()`
as this is redone in `meta_wayland_keyboard_start_grab()`

https://gitlab.gnome.org/GNOME/mutter/issues/747
2019-09-02 17:06:06 +00:00
Daniel van Vugt
14c706e51b clutter: Introduce geometric picking
Currently, Clutter does picking by drawing with Cogl and reading
the pixel that's beneath the given point. Since Cogl has a journal
that records drawing operations, and has optimizations to read a
single pixel from a list of rectangle, it would be expected that
we would hit this fast path and not flush the journal while picking.

However, that's not the case: dithering, clipping with scissors, etc,
can all flush the journal, issuing commands to the GPU and making
picking slow. On NVidia-based systems, this glReadPixels() call is
extremely costly.

Introduce geometric picking, and avoid using the Cogl journal entirely.
Do this by introducing a stack of actors in ClutterStage. This stack
is cached, but for now, don't use the cache as much as possible.

The picking routines are still tied to painting.

When projecting the actor vertexes, do it manually and take the modelview
matrix of the framebuffer into account as well.

CPU usage on an Intel i7-7700, tested with two different GPUs/drivers:

  |         |     Intel | Nvidia |
  | ------: | --------: | -----: |
  | Moving the mouse:            |
  | Before  |       10% |    10% |
  | After   |        6% |     6% |
  | Moving a window:             |
  | Before  |       23% |    81% |
  | After   |       19% |    40% |

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/154,
        https://gitlab.gnome.org/GNOME/mutter/issues/691

Helps significantly with: https://gitlab.gnome.org/GNOME/mutter/issues/283,
                          https://gitlab.gnome.org/GNOME/mutter/issues/590,
                          https://gitlab.gnome.org/GNOME/mutter/issues/700

v2: Fix code style issues
    Simplify quadrilateral checks
    Remove the 0.5f hack
    Differentiate axis-aligned rectangles

https://gitlab.gnome.org/GNOME/mutter/merge_requests/189
2019-09-02 16:41:13 +00:00
Daniel van Vugt
a70823dd1c clutter/point: Add ClutterPoint quarilateral testing API
Add a function to check whether a point is inside a quadrilateral
by checking the cross product of vectors with the quadrilateral
points, and the point being checked.

If the passed quadrilateral is zero-sized, no point is ever reported
to be inside it.

This will be used by the next commit when comparing the transformed
actor vertices.

[feaneron: add a commit message and remove unecessary code]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/189
2019-09-02 16:41:13 +00:00
Rémi Bernon
fdda8adfcf
x11: Add window test before accessing reparents_pending field
https://gitlab.gnome.org/GNOME/mutter/merge_requests/768
2019-09-02 18:27:37 +02:00
Rémi Bernon
8f242f8bf0 core: Fix multiple reparent requests handling
If window decoration is modified within a short period of time, mutter
sometimes starts processing the second request before the first
UnmapNotify event has been received. In this situation, it considers
that the window is not mapped and does not expect another UnmapNotify /
MapNotify event sequence to happen.

This adds a separate counter to keep track of the pending reparents. The
input focus is then restored when MapNotify event is received iff all
the expected pending ReparentNotify events have been received.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/657
2019-09-02 15:50:37 +00:00
Daniel van Vugt
6ed5d2e2b4 cogl: Remove GLX "threaded swap wait" used on Nvidia
Threaded swap wait was added for using together with the Nvidia GLX
driver due to the lack of anything equivalent to the INTEL_swap_event
GLX extension. The purpose was to avoid inhibiting the invocation of
idle callbacks when constantly rendering, as the combination of
throttling on swap-interval 1 and glxSwapBuffers() and the frame clock
source having higher priority than the default idle callback sources
meant they would never be invoked.

This was solved in gbz#779039 by introducing a thread that took care of
the vsync waiting, pushing frame completion events to the main thread
meaning the main thread could go idle while waiting to draw the next
frame instead of blocking on glxSwapBuffers().

As of https://gitlab.gnome.org/GNOME/mutter/merge_requests/363, the
main thread will instead use prediction to estimate when the next frame
should be drawn. A side effect of this is that even without
INTEL_swap_event, we would not block as much, or at all, on
glxSwapBuffers(), as at the time it is called, we have likely already
hit the vblank, or will hit it soon.

After having introduced the swap waiting thread, it was observed that
the Nvidia driver used a considerable amount of CPU waiting for the
vblank, effectively wasting CPU time. The need to call glFinish() was
also problematic as it would wait for the frame to finish, before
continuing. Due to this, remove the threaded swap wait, and rely only on
the frame clock not scheduling frames too early.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=781835
Related: https://gitlab.gnome.org/GNOME/mutter/issues/700

[jadahl: Rewrote commit message]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/602
2019-09-02 18:12:10 +08:00
Jonas Ådahl
d4eb222644 later: Add tracing
https://gitlab.gnome.org/GNOME/mutter/merge_requests/757
2019-08-31 12:22:39 +00:00
Jonas Ådahl
a14fd1b955 compositor: Trace pre/post paint functions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/757
2019-08-31 12:22:39 +00:00
Jonas Ådahl
ab1107973b backends/native: Add various cogl traces
Trace the time spent finishing a frame, posting KMS updates and some
other things.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/757
2019-08-31 12:22:39 +00:00
Florian Müllner
dc9c5417bc main: Add test initialization function
Since Clutter's backend relies on MetaBackend now, initialzation has
to go through meta_init(), both in mutter and in gnome-shell.

However the compositor enum and backend gtype used to enforce the
environment used for tests are private, so instead expose a test
initialization function that can be used from both mutter and
gnome-shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/750
2019-08-27 16:34:01 +00:00
Ray Strode
556e7694de iconcache: Avoid xrender picture formats when creating cairo surface
If an application provides its window icon via wmhints, then mutter
loads the pixmap specified by the application into a cairo xlib surface. When
creating the surface it specifies the visual, indirectly, via an XRender
picture format.

This is suboptimal, since XRender picture formats don't have a way to specify
16bpp depth, which an application may be using.

In particular, applications are likely to use 16bpp depth pixmaps for their
icons, if the video card offers a 16bpp framebuffer/root window.

This commit drops the XRender middleman, and just tells cairo a visual to use
directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/715
2019-08-27 18:47:41 +03:00
Ray Strode
1a5cba5df5 Revert "iconcache: Support 16bit icons"
This reverts commit b95d7e8276.

It's poisoning cairo's GC cache with a GC that has the wrong
colordepth, leading to a crash in unrelated code later on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/715
2019-08-27 18:47:41 +03:00
Jonas Ådahl
cd0990c581 window-actor: Use new get_image() API to screen casting window content
This fixes screen casting of windows consisting of multiple surfaces to
work.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/752
2019-08-27 15:31:25 +00:00
Jonas Ådahl
96e831dd8a window-actor: Add API to get a cairo surface of the window
This currently uses a hack where it pushes a CoglFramebuffer backed by a
texture to the framebuffer stack, then calls clutter_actor_paint() on
the window actor causing it to render into the framebuffer. This has the
effect that all subsurfaces of a window will be drawn as part of the
window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/752
2019-08-27 15:31:25 +00:00
Jonas Ådahl
65fde269c6 screen-cast/window: Use window actor damaged signal instead of paint
We are really more interested in when a window is damaged, rather than
when it's painted, for screen casting windows. This also has the benefit
of not listening on the "paint" signal of the actor, meaning it'll open
doors for hacks currently necessary for taking a screenshot of a window
consisting of multiple surfaces.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/752
2019-08-27 15:31:25 +00:00
Jonas Ådahl
ad138210b3 window-actor: Add 'damaged' signal
Make it possible to listen for damage on a window actor. For X11, the
signal is emitted when damage is reported; for Wayland, it is emitted
when any of the surfaces associated with the window is damaged.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/752
2019-08-27 15:31:25 +00:00
Florian Müllner
6968f17f3f Revert "main: Add test initialization function"
This reverts commit 7e69d1400a.
2019-08-27 15:32:54 +03:00
Florian Müllner
7e69d1400a main: Add test initialization function
Since Clutter's backend relies on MetaBackend now, initialzation has
to go through meta_init(), both in mutter and in gnome-shell.

However the compositor enum and backend gtype used to enforce the
environment used for tests are private, so instead expose a test
initialization function that can be used from both mutter and
gnome-shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/750
2019-08-27 15:29:55 +03:00
Robert Mader
a3c97ee535 surface-actor-wayland: Handle stex being disposed
As the MetaShapedTexture might already got finalized, this can lead to a crash.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/755
2019-08-27 08:55:51 +00:00
Robert Mader
77229f99b8 wayland: Implement subsurface.place_below() for parents
Flatten the subsurface actor tree, making all surface actors children
of the window actor.
Save the subsurface state in a GNode tree in MetaWaylandSurface, where
each surface holds two nodes, one branch, which can be the tree root
or be attached to a parent surfaces branch, and a leaf, which is
used to save the position relative to child branch nodes.

Each time a surface is added or reordered in the tree, unparent all
surface actors from the window actor, traverse all leaves of the
tree and readd the corresponding surface actors back to the window
actor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/664
2019-08-27 11:31:00 +03:00
Carlos Garnacho
78232fa3eb core: Check X11 display availability before use in MetaStackTracker
This object can be generally triggered without a X11 display, so make sure
this is alright. For guard window checks, use our internal
meta_stack_tracker_is_guard_window() call, which is already no-x11 aware.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/730
2019-08-26 17:39:10 +00:00
Carlos Garnacho
433e1b388d core: Move Stack to StackTracker synchronization back to stack.c
We indirectly were relying on the MetaX11Stack for this. We strictly
need the _NET_CLIENT_LIST* property updates there, so move our own
internal synchronization to common code.

Fixes stacking changes of windows while there's no MetaX11Display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/730
2019-08-26 17:39:10 +00:00
Georges Basile Stavracas Neto
9b7d918537 surface-actor: Unref shaped texture on dispose
The MetaShapedTexture created by MetaSurfaceActor used to
be a ClutterActor, which means destruction was taken care
by Clutter.

Now that it's a plain GObject, we need to manually clean it
up.

Cleanup the shaped texture on disposal.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/753
2019-08-26 20:14:00 +03:00
Robert Mader
5cfea4fee3 wayland/dnd-surface: Apply surface offset
The surface offset allows an application to move itself in relative
coordinates to its previous position. It is rather ill defined and
partly incompatible with other functionality, which is why we ignore
it generally.

For dnd-surfaces though, it is the de-facto standard for applications
to properly position the dnd-icon below the cursor. Therefore apply
the offset on actor sync by setting the feedback actor anchor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/684
2019-08-26 11:57:49 +00:00
Robert Mader
7275cf60bd wayland/feedback-actor: Use float for position and anchor
To be correct with fractional scaling. Furthermore, we currently
use it only with ClutterPoint values, which are floats already.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/684
2019-08-26 11:57:49 +00:00
Hans de Goede
acbefa5263 wayland: pointer-confinement: Listen to "geometry-changed" on the surface, not the actor
Commit b12c92e206 ("wayland: Add MetaWaylandSurface::geometry-changed signal")
Added a "geometry-changed" signal on MetaWaylandSurface, but the matching
changes to src/wayland/meta-pointer-confinement-wayland.c made it listen
for geometry-changed on the surface-actor instead of on the surface itself,
leading to errors like these:

gnome-shell[37805]: ../gobject/gsignal.c:2429: signal 'geometry-changed' is invalid for instance '0x5653aa7cfe50' of type 'MetaSurfaceActorWayland'

This commit fixes this.

Fixes: b12c92e206 ("wayland: Add MetaWaylandSurface::geometry-changed signal")

https://gitlab.gnome.org/GNOME/mutter/merge_requests/751
2019-08-26 13:24:58 +02:00
Piotr Drąg
634c31d7cb backends: Don’t translate GLib properties
https://gitlab.gnome.org/GNOME/mutter/merge_requests/749
2019-08-24 17:10:32 +02:00
Carlos Garnacho
cc7e843c44 tests: Move clutter-test-utils.[ch] to src/tests
And add the necessary glue so those initialize a X11 clutter backend.
This should get Clutter tests that are dependent on windowing to work
again, thus they were enabled back again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
cfb8f18cef clutter: Move tests to src/tests
Clutter doesn't hold anymore backend implementations, move tests where
we have one that we may assign.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
c0a71720af backends: Don't use glib types in new native backend objects
https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
8b03d9ecc3 clutter: Move evdev input to src/backends/native
The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendNative, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
c710a56903 backends: Move nested stage to src/backends/x11/nested
We now have a MetaStageX11, so it's extra confusing to have both in
the same directory.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
96d5bde9b7 backends: Don't use glib types in new X11 backend objects
https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
ad72fa46b0 clutter: Move X11 input to src/backends/x11
The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendX11, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
ef93bb6471 clutter: Remove event retrieval toggle
This is x11-specific API that was added back when clutter was out
of tree. Just remove it and directly do what we want.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Carlos Garnacho
e56df455ae clutter: Drop ClutterEventTranslator interface
We don't need that much complexity when we have a fixed set of
translators, and only one of them wants a given event.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:07 +00:00
Olivier Fourdan
8e13292d62 keybindings: Code cleanup
The boolean `handled` is not needed, remove it.

https://gitlab.gnome.org/GNOME/mutter/issues/734
2019-08-23 14:54:20 +00:00
Olivier Fourdan
29ea5306eb keybindings: Restore inhibit shortcut for overlay key
After the introduction of locate-pointer (commit 851b7d063 -
 “keybindings: Trigger locate-pointer on key modifier”), inhibiting
shortcuts would no longer forward the overlay key to the client.

Restore the code that was inadvertently removed so that inhibiting
shortcuts works on the overlay key again.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/734
2019-08-23 14:54:20 +00:00
Georges Basile Stavracas Neto
fb9e8768a3 window-actor: Handle geometry scale
Geometry scale is applied to each surface individually, using
Clutter scales, and not only this breaks subsurfaces, it also
pollutes the toolkit and makes the actor tree slightly too
fragile. If GNOME Shell mistakenly tries to set the actor scale
of any of these surfaces, for example, various artifacts might
happen.

Move geometry scale handling to MetaWindowActor. It is applied
as a child transform operation, so that the Clutter-managed
scale properties are left untouched.

In the future where the entirety of the window is managed by a
ClutterContent itself, the geometry scale will be applied
directly into the transform matrix of MetaWindowActor. However,
doing that now would break the various ClutterClones used by
GNOME Shell, so the child transform is an acceptable compromise
during this transition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
c747be84d9 wayland: Don't scale input and opaque regions
Leave them at surface coordinates and let MetaSurfaceActor
and MetaShapedTexture handle the interactions between buffer
and geometry scale.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
2d7adb90c8 wayland/tablet-tool: Use meta_wayland_surface_get_relative_coordinates()
Instead of directly calling into clutter_actor_transform_stage_point().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
6b35a4901e shaped-texture: Move private function to private header
meta_shaped_texture_update_area() is a private function that
is exposed in the public headers. It is not used anywhere
outside Mutter, and should really be in the private header.

Move it to the private header.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
4c1fde9deb shaped-texture: Move MetaCullable helpers to MetaSurfaceActor
Now that MetaShapedTexture is not a ClutterActor anymore, it does
not make sense to make it a MetaCullable semi-implementation. This
is, naturally, a responsibility of MetaSurfaceActor, since now
MetaShapedTexture is a ClutterContent and as such, it only cares
about what to draw.

Move the MetaCullable implementation of MetaShapedTexture to
MetaSurfaceActor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
425e65049b shaped-texture: Draw pipeline relative to alloc
By implementing ClutterContent, it is expected that
MetaShapedTexture can draw on any actor. However,
right now this is not possible, since it assumes
that the drawing coordinates and sizes of the actor
are synchronized with its own reported width and
height.

It mistakenly draws, for example, when setting an
actor's content to it. There is no way to trigger
this wrong behavior right now, but it will become
a problem in the future where we can collect the
paint nodes of MetaShapedTexture as part of other
ClutterContent implementations.

Use the allocation box passed by the actor to draw
the pipelines of MetaShapedTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
d3f30d9ece wayland/actor-surface: Set geometry scale in surface actor
Now that MetaShapedTexture is a ClutterContent implemetation that
is aware of its own buffer scale, it is possible to simplify the
event translation routines.

Set the geometry scale in MetaSurfaceActor, and stop adjusting the
surface scale when translating points. Also remove the now obsoleted
meta_wayland_actor_surface_calculate_scale() function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
75cffd0ec4 shaped-texture: Implement ClutterContent
MetaWindowActor is the compositor-side representative of a
MetaWindow. Specifically it represents the geometry of the
window under Clutter scene graph. MetaWindowActors are backed
by MetaSurfaceActors, that represent the windowing system's
surfaces themselves. Naturally, these surfaces have textures
with the pixel content of the clients associated with them.
These textures are represented by MetaShapedTexture.

MetaShapedTextures are currently implemented as ClutterActor
subclasses that override the paint function to paint the
textures it holds.

Conceptually, however, Clutter has an abstraction layer for
contents of actors: ClutterContent. Which MetaShapedTexture
fits nicely, in fact.

Make MetaShapedTexture a ClutterContent implementation. This
forces a few changes in the stack:

 * MetaShapedTexture now handles buffer scale.

 * We now paint into ClutterPaintNode instead of the direct
   framebuffer.

 * Various pieces of Wayland code now use MetaSurfaceActor
   instead of MetaShapedTexture.

 * MetaSurfaceActorWayland doesn't override size negotiation
   vfuncs anymore

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Olivier Fourdan
13deb22223 wayland/xdg-output: Add xdg-output v3 support
xdg-output v3 marks `xdg_output.done` as deprecated, avoid sending that
event for clients using xdg-output v3.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/704
2019-08-21 15:47:14 +00:00
Olivier Fourdan
eac227a203 xwayland: Add local user to xhost
With the addition of xauth support (commit a8984a81c), Xwayland would
rely only on the provided cookies for authentication.

As a result, running an Xclient from another VT (hence without the
XAUTHORITY environment variable set) would result in an access denied.

The same on X11 is granted because the local user is automatically
granted access to Xserver by the startup scripts.

Add the local user to xhost at startup on Xwayland so that the user can
still run a client by setting the DISPLAY as long as it's the same user
on the same host.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Olivier Fourdan
bc166aa6b4 xwayland: Use given X11 display for DnD setup
Use the provided X11 display instead of poking into GDK to get the X11
display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Olivier Fourdan
5fa8b24b2b xwayland: pass the X11 display
Pass the X11 display to `meta_xwayland_complete_init()` so that it can
be used without poking into GDK.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Jonas Ådahl
0db38c4999 compositor: Let MetaDisplay choose the correct compositor type
A base type shouldn't know about sub types, so let MetaDisplay make
the correct choice of what type of MetaCompositor it should create. No
other semantical changes introduced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
8ee00cee60 compositor/x11: Move stage input region setting to MetaX11Display
It doesn't use anything specific to MetaCompositor, and
MetaCompositorX11 isn't exposed, so move it to MetaX11Display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
984aad4b86 compositor: Move out X11 compositing code into sub type
Introduce MetaCompositorX11, dealing with being a X11 compositor, and
MetaCompositorServer, being a compositor while also being the display
server itself, e.g. a Wayland display server.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
9af90bf9c1 compositor: Fix indentation mistake
https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
12ea2fcb51 compositor: Make type derivable
This is so that we can split it up properly into X11 compositor and
display server compositor sub types.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
55cd110c63 compositor: Use meta_window_actor_from_window() throughout
Instead of explicitly using meta_compositor_get_window_private() and
casting it to MetaWindowActor * each time.

With minor bonus style cleanups.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Olivier Fourdan
f37a172dc7 events: No UI frame button press events for Wayland
When double clicking to un-maximize an X11 window under Wayland, there
is a race between X11 and Wayland protocols and the X11 XConfigureWindow
may be processed by Xwayland before the button press event is forwarded
via the Wayland protocol.

As a result, the second click may reach another X11 window placed right
underneath in the X11 stack.

Make sure we do not forward the button press event to Wayland if it was
handled by the frame UI.

https://gitlab.gnome.org/GNOME/mutter/issues/88
2019-08-19 09:16:04 +02:00
Olivier Fourdan
ad62a659eb window: Move UI frame event handler to a separate function
In order to tell whether an event has been handled by the frame UI, move
the UI frame handler to a specific helper function.

https://gitlab.gnome.org/GNOME/mutter/issues/88
2019-08-19 09:16:04 +02:00
Albert Vaca Cintora
4d8190972d cursor-renderer/native: Fix compilation warning
Previous initialization triggered Wmissing-braces in Clang.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/731
2019-08-16 14:54:48 +02:00
Hans de Goede
f3660dc60e kms: Deal with GPUs being unplugged
Add meta-kms and meta-monitor-manager-kms listener for the udev
device-removed signal and on this signal update the device state /
re-enumerate the monitors, so that the monitors properly get updated
to disconnected state on GPU removal.

We really should also have meta-backend-native remove the GPU itself
from our list of GPU objects. But that is more involved, see:
https://gitlab.gnome.org/GNOME/mutter/issues/710

This commit at least gets us to a point where we properly update the
list of monitors when a GPU gets unplugged; and where we no longer
crash the first time the user changes the monitor configuration after
a GPU was unplugged.

Specifically before this commit we would hit the first g_error () in
meta_renderer_native_create_view () as soon as some monitor
(re)configuration is done after a GPU was unplugged.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
0eb355e29d kms: Fix drm_connector mem-leak in meta_kms_connector_update_state
https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
3ccb7cf4b2 kms: drmModeGetConnector may fail
drmModeGetConnector may fail and return NULL, this may happen when
a connector is removed underneath us (which can happen with e.g.
DP MST or GPU hot unplug).

Deal with this by skipping the connector when enumerating and by
assuming it is disconnected when checking its connection state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
578ff22464 kms: drmModeGetCrtc may fail
drmModeGetCrtc may fail and return NULL. This will trigger when
meta_kms_crtc_update_state gets called from meta_kms_update_states_sync
after a GPU has been unplugged leading to a NULL pointer deref causing
a crash.

This commit fixes this by checking for NULL and clearing the current_state
when NULL is returned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
73db35c53c kms: Fix meta_kms_crtc_read_state gamma table memory leak
Before this commit meta_kms_crtc_read_state was overwriting the
entire MetaKmsCrtcState struct stored in crtc->current_state including
the gamma (sub)struct.

This effectively zero-s the gamma struct each time before calling
read_gamma_state, setting the pointers where the previous gamma values
were stored to NULL without freeing the memory. Luckily this zero-ing
also sets gamma.size to 0, causing read_gamma_state to re-alloc the
arrays on each meta_kms_crtc_update_state call. But this does mean that
were leaking the old gamma arrays on each meta_kms_crtc_update_state call.

This commit fixes this by making meta_kms_crtc_read_state only overwrite
the other values in the MetaKmsCrtcState struct and leaving the gamma
sub-struct alone, this will make read_gamma_state correctly re-use the
gamma tables if the gamma table size is unchanged; or re-alloc them
(freeing the old ones) if the size has changed, fixing the memory leak.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
76445bcb97 kms: Remove unused fields from MetaKmsCrtcState struct
https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
6792903c4f udev: Add device-removed signal
Add a device-removed signal which gets emitted when a GPU is removed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
17c217848d udev: Fix wrong closure function usage for the "device-added" signal
The "device-added" signal should use g_cclosure_marshal_VOID__OBJECT not
g_cclosure_marshal_VOID__VOID.

Instead of fixing this manually, simply replace the closure function for
both signals with NULL, glib will then automatically set the correct
va_marshaller.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Carlos Garnacho
a0bdf44c2d core: Do not crash on untimely stack queries for X11 windows
Some meta_later operations may happen across XWayland being shutdown,
that trigger MetaStackTracker queries for X11 XIDs. This crashes as
the MetaX11Display is already NULL.

Return a NULL window in that case, as in "unknown stack ID".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:11:01 +02:00
Carlos Garnacho
3259c7e150 wayland: Start up the grace Xwayland period right after starting Xwayland
There may be cases where a X11 client does not spawn any X11 windows (eg.
simple clients like xinput --list, or xlsclients), in this case the Xwayland
server would remain running until X11 windows happen to come and go in the
future.

Firing the shutdown timeout on restart caters for this, and would be undone
if the client maps X11 windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:09:49 +02:00
Carlos Garnacho
e9e28baab7 wayland: Create XAuthority file once
Where the prepare_auth_file() call is, it does create a new one on every
respawn of Xwayland. This is not benefitial, as the XAUTHORITY envvar is
already fixed in the session.

Only create the XAuthority file once, and reuse it on future Xwayland
respawns.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:09:38 +02:00
Jonas Ådahl
d20f6c7969 compositor: Use g_clear_signal_handler to disconnect signal handlers
This also exposed wrong types used for the signal handler ids.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Marco Trevisan (Treviño)
93c7d571af display: Destroy compositor using g_clear_pointer
https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Marco Trevisan (Treviño)
d526283ab9 compositor: Make it a GObject
This means we can later use GObject features like signals, subclassing
etc.

Bump glib_req version as per g_clear_handle_id usage.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Hans de Goede
782056adab wayland/data-device: Use correct selection type to get mime types
When primary_offer_receive checks if the requested mime_type is supported,
it should check against the list of mime-types supported by the
primary-selection, instead of the list for the clipboard.

This fixes primary selection copy paste from X11 apps to Wayland apps
not working.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/702
2019-08-14 12:00:10 +02:00
Jonas Ådahl
0521706617 monitor: Always advertise modes similar to the preferred mode
Even if the preferred mode ends up being too small according to the area
size filter, it should still be advertised as it's still preferred.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/725

https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Jonas Ådahl
989a281b5f monitor: Check mode resolution area when determining advertisability
Explicitly checking the dimensions of a mode to determine whether it
should be advertised or not fails for portrait style modes. Avoid this
by checking the area instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Jonas Ådahl
18838bcefc monitor: Fix style issue
https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Carlos Garnacho
08c6b801d2 core: Exit early on keybindings if this is a wayland compositor
Fixes a thinko in commit 79b5ece2. It is meant to bail out early
on issuing X11 passive grabs if the compositor is a wayland one,
but this condition was inverted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/721
2019-08-09 11:36:45 +02:00
Carlos Garnacho
80c8a287ee wayland: Check the xwayland shutdown policy before listening for x11 windows
We only listen for those so we know there's no more X11 clients that we
should keep the Xwayland server alive for. Check first that we really did
request Xwayland to be handled on demand for this, otherwise the check is
superfluous, even harmful.

https://gitlab.gnome.org/GNOME/mutter/issues/719
2019-08-07 18:34:10 +02:00
Carlos Garnacho
141373f0ba wayland: Implement on-demand start of Xwayland
The Xwayland manager now has 4 distinct phases:
- Init and shutdown (Happening together with the compositor itself)
- Start and stop

In these last 2 phases, handle orderly initialization and shutdown
of Xwayland. On initialization We will simply find out what is a
proper display name, and set up the envvar and socket so that clients
think there is a X server.

Whenever we detect data on this socket, we enter the start phase
that will launch Xwayland, and plunge the socket directly to it.
In this phase we now also set up the MetaX11Display.

The stop phase is pretty much the opposite, we will shutdown the
MetaX11Display and all related data, terminate the Xwayland
process, and restore the listening sockets. This phase happens
on a timeout whenever the last known X11 MetaWindow is gone. If no
new X clients come back in this timeout, the X server will be
eventually terminated.

The shutdown phase happens on compositor shutdown and is completely
uninteresting. Some bits there moved into the stop phase as might
happen over and over.

This is all controlled by META_DISPLAY_POLICY_ON_DEMAND and
the "autostart-xwayland" experimental setting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
0c5866a9e1 core: Avoid queueing a stack operation on the frame when the X11 is closing
When rushing to unmanage X11 windows after the X11 connection is closed/ing,
this would succeed at creating a stack operation for no longer known windows.
Simply avoid to queue a stack operation if we know it's meaningless.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
879f5f0dbb x11: Add "closing" flag to MetaX11Display
So code not directly in dispose() can know to avoid certain things
when the X11 display is about to close.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
123b40105d x11: Shuffle x11-stack destruction in MetaX11Display dispose
Unmanaging the windows may trigger stack operations that we later try
to synchronize despite being in dispose() stage. This may trigger
MetaStackTracker warnings when trying to apply those operations.

Switching destruction order (First dispose the X11 stack representation,
then unmanage windows) won't trigger further stack changes on X11 windows
after having signaled MetaDisplay::x11-display-closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
7ef32f747b wayland: Add setting/api to check the policy to set up the X11 display
This replaces meta_should_autostart_x11_display(). The "on-demand" policy
is not honored yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
e8949292c1 wayland: Refactor code setting up the display socket
So it may be reused when we need to open those again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
f5a2694eba wayland: Add tracking of X11 windows
This is unused ATM, but will be used to check whether it is safe to
shut Xwayland down.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
319f7f5b63 compositor: Add explicit API call to redirect X11 windows
This is not useful yet, but will be when Xwayland may restart

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
9a10b8ff94 wayland: Disconnect signal when the display closes
It would be potentially left dangling if the display were closed, and
reconnected again when restarting the server.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
8b62f4884d wayland: Rename xwayland init/shutdown functions
The start/stop verbs will be reused later when we can start and
stop the X server. Rename these functions to init/shutdown, and
init_xserver() to start_xserver().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
500a692e3b core: Manage only X11 windows when (re)starting
What "restart" means is somewhat different between x11 and wayland
sessions. A X11 compositor may restart itself, thus having to manage
again all the client windows that were running. A wayland compositor
cannot restart itself, but might restart X11, in which case there's
possibly a number of wayland clients, plus some x11 app that is
being started.

For the latter case, the assert will break, so just make it
conditional. Also rename the function so it's more clear that it
only affects X11 windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
d3d1ff1aae x11: Do not queue stack operation for guard window
In the case mutter is a x11 compositor, it doesn't matter much
since the stack tracker will go away soon. In the case this is a
wayland compositor with mandatory Xwayland, it matters even less
since the session would be shutting down in those paths.

But if this a wayland compositor that can start Xwayland on demand,
this is even harmful, as the MetaStackTracker should be cleared of
x11 windows at this moment, and we actually did right before dispose
on ::x11-display-closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
ca51cd8488 core: Prepare MetaStackTracker for X11 display being closed
If the display is closed prematurely, go through all windows that
look X11-y and remove them for future calculations. This is not
strictly needed as Xwayland should shut down orderly (thus no client
windows be there), but doesn't hurt to prepare in advance for the
cases where it might not be the case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
9109fa0eb8 x11: Add meta_x11_get_display_name() function
Instead of poking the DISPLAY envvar at places.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
79b5ece241 core: Ensure passive key grabs are only set up on X11
We don't strictly need it for wayland compositors, yet there are
paths where we try to trigger those passive grabs there. Just
skip those on the high level code (where "is it x11" decisions
are taken) like we do with passive button grabs.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
cda9579034 core: propagate the effective on-all-workspaces setting to transient window
Commit 09bab98b1e tried to avoid several workspace changes while in
window construction, but it missed a case:

If we have a window on a secondary monitor with no workspaces enabled
(so it implicitly gets on_all_workspaces = TRUE without requesting it)
and trigger the creation of a second window that has the first as
transient-for, it would first try to set the first workspace than the
transient-for window and then fallback to all/current workspace.

After that commit we only try to set the same workspace than the
transient-for window, but it gets none as neither is on a single workspace,
nor did really request to be on all workspaces.

Fixes crashes when opening transient X11 dialogs in the secondary monitor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/714
2019-08-05 18:19:01 +00:00
Florian Müllner
56a5c5e4d1 cleanup: Stop using g_get_current_time ()
It has been deprecated because it isn't Y2k38 ready, so replace it
with g_get_real_time () which is.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/708
2019-08-03 16:12:32 +00:00
Ray Strode
b95d7e8276 iconcache: Support 16bit icons
Mutter current crashes if an application sets a 16-bit color depth
icon in its window manager hints.

This commit fixes the crash.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/710
2019-08-01 16:52:10 -04:00
Niels De Graef
5b98cc7a3a cursor-tracker: Document cursor-moved signal
It's a bit easier to track what's going on in a signal if you document
it (otherwise you have to check where it was emitted in the code).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Niels De Graef
4de892b02a cursor-tracker: Don't use g_cclosure_marshal_VOID__VOID
Similar to gtk commit f507a790, this ensures that the valist variant of
the marshaller is used. From that commit's message:

```
If we set c_marshaller manually, then g_signal_newv() will not setup a
va_marshaller for us. However, if we provide c_marshaller as NULL, it will
setup both the c_marshaller (to g_cclosure_marshal_VOID__VOID) and
va_marshaller (to g_cclosure_marshal_VOID__VOIDv) for us.
```

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Niels De Graef
efe6c13d93 cursor-tracker: Use our own marshal for cursor-moved
By putting `NULL` as the C marshaller in `g_signal_new`, you
automatically get `g_cclosure_marshaller_generic`, which will try to
process its arguments and return value with the help of libffi and
GValue.

Using `glib-genmarshal` and valist_marshallers, we can prevent this so
that we need less instructions for each signal emission.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Carlos Garnacho
aae9f3a3e6 window-actor: Fix rectangle coordinates in culling
The cull methods expect regions with 0,0 in the actor top-left corner,
whereas meta_window_get_frame_rect() returns a rectangle in workarea
coordinates.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/707
2019-07-31 00:27:33 +02:00
Carlos Garnacho
f501fdcc56 window-actor: Remove negation in function name
Double negations are the spawn of the devil, and is_non_opaque() is
used like that to find out if it's opaque most often, change the
function name to see the glass half full.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
90a5582a73 background-actor: Clip obscured background areas
The MetaBackgroundActor was ignoring the unobscured area altogether,
and just painted according to the clip area. Check the unobscured
area too, as it might well be covered by client windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
ac7aa11417 window-actor: Cull out areas covered by opaque windows
Wayland clients do this through the opaque region in the surface
actor. However X11 clients were considered fully transparent for
culling purposes, which may result in mutter painting other bits
of the background or other windows that will be painted over in
reality.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
cc5968109b window-actor: Fix check to clip beneath the window
We want to clip it away if 1) The window is fully opaque or
2) If it's translucent but has a frame (as explained in the comment
above). The code didn't quite match and we were only applying it on
case #2.

Case #1 is far more common, and saves us from pushing some drawing
that we know will be covered in the end.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:51 +02:00
Carlos Garnacho
0f6ab787ac window-actor: Check frame bounds region before use
It may be NULL when the window goes unmanaged. This was unnoticed
as we barely enter the clip_shadow_under_window() check.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:42 +02:00
Carlos Garnacho
2812338b7a shadow-factory: Optimize shadows entirely if clip region is empty
If the clip region is empty, we don't need to check the 9 slices
separately, nothing will be painted anyway.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:30 +02:00
Carlos Garnacho
09bab98b1e core: Avoid consecutive workspace changes in window construction
We first set the workspace to the transient-for parent's, and then
try to set on the current workspace. If both happen, we double the
work on adding/removing it from the workspace, and everything that
happens in result.

Should reduce some activity while typing on the Epiphany address
bar, as the animation results in a number of xdg_popup being created
and destroyed to handle the animation.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 21:06:50 +02:00
Carlos Garnacho
aee8bfce3f core: Only notify on MetaWindow::user-time on actual changes
If the timestamp is the same, it doesn't make sense to update and we
don't do so. So it doesn't make sense to notify on the property either.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 13:55:53 +02:00
Mark Blakeney
e9cc220c8e x11: Remove benign warning for older X clients
The default configuration of libinput-gestures utility invokes wmctrl to
switch between desktops. It uses wmctrl because this works on both Xorg
and Wayland (via XWayland). Unfortunately, this generates the following
warning message every time, in both Xorg and Wayland desktops:

"Received a NET_CURRENT_DESKTOP message from a broken (outdated) client
who sent a 0 timestamp"

The desktop switch still works fine. The tiny code change here removes
this specific warning because, as the prefacing code comment originally
said and still says, older clients can validly pass a 0 time value so
why complain about that?

I also refactored the "if (workspace)" code slightly to avoid the double
test of the workspace value.

This is submitted for MR
https://gitlab.gnome.org/GNOME/mutter/merge_requests/671.
2019-07-22 07:31:41 +00:00
Jonas Ådahl
61e51cdef6 dma-buf: Mark DMA-BUF textures as paint-only
Reading pixels directly from a texture imported from a DMA-BUF EGLImage
may result compressed textures to be transferred into non-compressed
texture. This may have side effects causing it to be rendered
incorrectly in subsequent paints.

Avoid this by passing the no-get-data flag to the texture creator
function, eventually causing mutter to use an intermediate offscreen
framebuffer when reading pixels from such textures.

https://bugs.freedesktop.org/show_bug.cgi?id=111140
https://gitlab.freedesktop.org/xorg/xserver/issues/545

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Jonas Ådahl
7868ab761f cogl/texture: Add EGLImage texture import flags
The flags are 'none', and 'no-get-data' meaning get_data() is not
supported.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Olivier Fourdan
ac5d9ec558 keybindings: Do not grab the locate-pointer key if unnecessary
On X11, mutter needs to keep a grab on the locate-pointer key to be able
to trigger the functionality time the corresponding key combo is
pressed.

However, doing so may have side effects on other X11 clients that would
want to have a grab on the same key.

Make sure we only actually grab the key combo for "locate-pointer" only
when the feature is actually enabled, so that having the locate pointer
feature turned off (the default) would not cause side effects on other
X11 clients that might want to use the same key for their own use.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/647
2019-07-18 13:10:32 +00:00
Olivier Fourdan
9c8ff5dbe8 keybindings: Mark "locate-pointer" key as "no-auto-grab"
Mark the keybinding for locate-pointer as "no-auto-grab" so we don't
automatically redo the grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
7738316dff keybindings: Mark the "overlay" key as "no-auto-grab"
Mark the keybinding for overlay as "no-auto-grab" to skip it in
`change_binding_keygrabs()` so we don't automatically redo the grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
1c3d8defb5 keybindings: Add "no-auto-grab" type
Some special modifiers (typically "Control_L" used for locate-pointer in
mutter/gnome-shell or "Super_L" for overlay) must be handled separately
from the rest of the key bindings.

Add a new flag `META_KEY_BINDING_NO_AUTO_GRAB` so we can tell when
dealing with that special keybinding which should not be grabbed
automatically like the rest of the keybindings, and skip those when
changing the grabs of all keybindings.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
b2ae03c428 keybindings: Fix indentation
Small cleanup of indentation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
456698c814 keybindings: Remove unneeded forward declaration
The functions `grab_key_bindings()` and `ungrab_key_bindings()` are not
used before their actual definition, there is no need to have a forward
declaration for those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Florian Müllner
4259cfd4c6 cleanup: Don't use G_TYPE_INSTANCE_GET_PRIVATE()
It has been deprecated in favor of the get_instance_private() function
generated by the G_ADD_PRIVATE() macro.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/689
2019-07-18 11:01:09 +02:00
Florian Müllner
4fdefb5b2e cleanup: Don't use g_memmove()
Glib stopped providing any fallback implementations on systems without
memmove() all the way back in 2013. Since then, the symbol is a simple
macro around memmove(); use that function directly now that glib added
a deprecation warning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/689
2019-07-18 11:01:09 +02:00
Marco Trevisan (Treviño)
5ca0ef078d window-x11: Focus a window in the active workspace as take-focus fallback
Starting with commit 2db94e2e we try to focus a fallback default focus window
if no take-focus window candidate gets the input focus when we request it and
we limit the focus candidates to the current window's workspace.

However, if the window is unmanaging, the workspace might be unset, and we could
end up in deferencing a NULL pointer causing a crash.

So, in case the window's workspace is unset, just use the currently active
workspace for the display.

Closes https://gitlab.gnome.org/GNOME/mutter/issues/687

https://gitlab.gnome.org/GNOME/mutter/merge_requests/688
2019-07-18 10:09:45 +02:00
Daniel van Vugt
a5265365dd background: Reload when GPU memory is invalidated
Fixes corrupt background wallpaper when resuming from suspend on the
Nvidia driver.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1084

https://gitlab.gnome.org/GNOME/mutter/merge_requests/600
2019-07-16 16:24:41 +08:00
Robert Mader
62f576e15b events: Use new API to get MetaWindow from ClutterActor
The new API supports Wayland subsurfaces and is probably better placed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/604
2019-07-13 15:32:19 +02:00
Robert Mader
73bc3c4426 window-actor: Add API to get a MetaWindowActor from a ClutterActor
Make it so it returns the closest ancestry MetaWindowActor if it
is a MetaSurfaceActor.
We need this for Wayland subsurfaces, so we can support actions like
Meta+Drag on them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/604
2019-07-13 15:32:01 +02:00
Robert Mader
57772e5850 workspace-manager: Fix a documentation warning
Pure comment should not start with two stars. Fixes a GIR creation warning
introduced in 8038eaa99f.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/683
2019-07-12 22:01:27 +02:00
Carlos Garnacho
7c8baf8ed9 compositor: Drop meta_get_overlay_window()
This is no longer necessary outside of mutter, nor used internally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/680
2019-07-11 10:56:53 +02:00
Carlos Garnacho
0e3c062406 dnd: Use composite_overlay_window directly
Saves us from using MetaCompositor API, at a point where it might not
be initialized yet. Use the same window directly, since we already
have it handy.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/672
2019-07-11 10:56:47 +02:00
Jonas Dreßler
4bc7425332 wayland/pointer: Remove duplicate include
https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Jonas Dreßler
a2a8f0cdaa wayland/pointer: Set focus to NULL when the cursor is hidden
This is important when using a touchscreen or stylus instead of a mouse
or touchpad. If the cursor only gets hidden and the focus stays the
same, the window will still send hover events to the UI element under
the cursor causing unexpected distractions while interacting with the
touchscreen.

Fix this by emitting a visibility-changed signal from the cursor tracker
which then triggers a focus surface sync and always set the focus
surface to NULL when it's synced while the cursor is hidden.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Jonas Dreßler
faa7b2d4e5 cursor-tracker: Add API to get whether the pointer is visible
Allow checking whether the pointer is visible without accessing the
trackers internal is_showing property. While we don't need this just yet
for reading the visibility inside meta-wayland-pointer, it's useful when
implementing the logic to remove Clutter's focus when the cursor goes
hidden later.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Pekka Paalanen
a95644dbdc renderer/native: Debug for primary copy mode
COPY_MODE_PRIMARY has two paths, automatically chosen. For debugging purposes,
e.g. why is my DisplayLink screen slowing down the whole desktop, it will be
useful to know which copy path is taken. Debug prints are added to both when
the primary GPU copy succeeds the first time and when it fails the first time.

This is not the full truth, because theoretically the success/failure could
change every frame, but we don't want to spam the logs (even in debug mode)
every frame. In practise, it should be rare for the success or failure to ever
change. Hence, saying what happened on the first time is enough. This does
indicate if it ever changes even once, too, so we know if that unexpected thing
happens.

The debug prints are per secondary GPU since there could be several.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
720f363241 renderer/native: Add tracing for 2nd GPU copies
These traces allow seeing how long the copy operations stall in libmutter, and
which copy operations actually get used.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
3794df608c renderer/native: Use primary GPU to copy
When the preferred path META_SHARED_FRAMEBUFFER_COPY_MODE_SECONDARY_GPU cannot
be used, as is the case for e.g. DisplayLink devices which do not actually have
a GPU, try to use the primary GPU for the copying before falling back to
read-pixels which is a CPU copy.

When the primary GPU copy works, it should be a significant performance win
over the CPU copy by avoiding stalling libmutter for the duration.

This also renames META_SHARED_FRAMEBUFFER_COPY_MODE_* because the new names are
more accurate. While the secondary GPU copy is always a GPU copy, the primary
copy might be either a CPU or a GPU copy.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
2c893beff1 renderer/native: Add meta_dumb_buffer_ensure_dmabuf_fd
Follow-up work will use this in an attempt to use the primary GPU to
copy into secondary GPU dumb buffers.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
a3c425ad89 wayland/dma-buf: Use meta_egl_create_dmabuf_image
Use the new helper instead of open-coding practically the same.

No behavioral changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
1d144486d1 wayland/dma-buf: Fix offset, stride types
These parameters are uint32_t in the Wayland protocol so make them uint32_t
here as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
9cd3b07472 egl: Introduce meta_egl_create_dmabuf_image
This bit of code was more or less duplicated in meta-renderer-native-gles3.c
and meta-wayland-dma-buf.c. Start consolidating the two implementations by
moving the *-gles3.c function into meta-egl.c and generalizing it so it could
also accommodate the meta-wayland-dma-buf.c usage.

The workaround in the *-gles3.c implementation is moved to the caller. It is
the caller's responsibility to check for the existence of the appropriate EGL
extensions.

Commit 6f59e4858e worked around the lack of
EGL_EXT_image_dma_buf_import_modifiers with the assumption that if the modifier
is linear, there is no need to pass it into EGL. The problem is that not
passing a modifier explicitly to EGL invokes implementation-defined behaviour,
so we should not have that workaround in meta-egl.c.

This patch intends to be pure refactoring, no behavioral changes. The one
change is the addition of g_assert to catch overwriting arbitrary memory.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Carlos Garnacho
78560b8426 core: Use source device on ::accelerator-activated
Using the master device, as we did, won't yield the expected result when
looking up the device node (it comes NULL as this is a virtual device).
Use the slave device, as the g-s-d machinery essentially expects.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/678
2019-07-08 16:30:16 +02:00
Carlos Garnacho
dd8c8e82f2 core: Emit ::accelerator-activated with a ClutterInputDevice argument
The device ID is kind of pointless on Wayland, so it might be better to
stick to something that works for both backends. Passing the device here
allows the higher layers to pick.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/676
2019-07-08 10:31:11 +00:00
Marco Trevisan (Treviño)
62f4e0501f stack: Style and introspection doc fixes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:46:52 +02:00
Marco Trevisan (Treviño)
6d8293a422 window-x11: Use any focusable window as fallback delayed focus window
As per commit f71151a5 we focus an input window if no take-focus-window accepts
it. This might lead to an infinite loop if there are various focusable but
non-input windows in the stack.

When the current focus window is unmanaging and we're trying to focus a
WM_TAKE_FOCUS window, we intent to give the focus to the first focusable input
window in the stack.

However, if an application (such as the Java ones) only uses non-input
WM_TAKE_FOCUS windows, are not requesting these ones to get the focus. This
might lead to a state where no window is focused, or a wrong one is.

So, instead of only focus the first eventually input window available, try to
request to all the take-focus windows that are in the stack between the
destroyed one and the first input one to acquire the input focus.
Use a queue to keep track of those windows, that is passed around stealing
ownership, while we protect for unmanaged queued windows.

Also, reduce the default timeout value, as the previous one might lead to an
excessive long wait.

Added metatests verifying these situations.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/660
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:46:52 +02:00
Marco Trevisan (Treviño)
b80250e483 tests: Add "accept_take_focus" command
When used it setups an X11 event monitor that replies to WM_TAKE_FOCUS
ClientMessage's with a XSetInputFocus request.

It can only be used by x11 clients on windows that have WM_TAKE_FOCUS atom set
and that does not accept input.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:21:17 +02:00
Marco Trevisan (Treviño)
bd0f1bd338 test-client: Add x11 events GSource handler
When using gtk under X11 some WM related events are always filtered and not
delivered when using the gdk Window filters.

So, add a new one with higher priority than the GTK events one so that we can
pick those events before than Gtk itself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:21:17 +02:00
Marco Trevisan (Treviño)
2439255f32 stack: Add a function to get a sorted list of focus candidates
Use a static function if a window can be the default focus window, and use such
function to return a filtered list of the stack.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:21:17 +02:00
Marco Trevisan (Treviño)
c327b2df95 window-x11: Accept any focusable window as fallback focus
As per commit f71151a5 we were ignoring WM_TAKE_FOCUS-only windows as focus
targets, however this might end-up in an infinite loop if there are multiple
non-input windows stacked.

So, accept any focusable window as fallback focus target even if it's a
take-focus one (that might not reply to the request).

Added a stacking test to verify this.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/660
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:21:17 +02:00
Marco Trevisan (Treviño)
9aee47daa9 window-x11: Don't double-check for unmanaging windows
When looking for the best fallback focus window, we ignore it if it is in the
unmanaging state, but meta_stack_get_default_focus_window() does this is check
for us already.

So, ignore the redundant test.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:21:17 +02:00
Marco Trevisan (Treviño)
ecf7e53206 metatest: Dispatch the destruction instead of sleeping after it
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669/
2019-07-08 11:21:17 +02:00
Adam Bieńkowski
8038eaa99f workspace-manager: Add API to reorder workspaces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/670
2019-07-08 08:25:54 +00:00
Georges Basile Stavracas Neto
4a184d74d5
monitor-manager: Don't notify unchanged power save mode
Since 4cae9b5b11, and indirectly before that as well, the
MetaMonitorManager::power-save-mode-changed is emitted even
when the power save mode didn't actually change.

On Wayland, this causes a mode set and therefore a stuttering.
It became more proeminent with the transactional KMS code.

Only emit 'power-save-mode-changed' when the power save mode
actually changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/674
2019-07-06 20:23:57 -03:00
Carlos Garnacho
1f133b3ed2 compositor: Add MetaDnD private function to initialize XDND
We need to set XdndAware and XdndProxy on the stage window if running
a X11 compositor, this is not necessary on wayland.

Takes over gnome-shell code doing this initialization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/667
2019-07-04 12:24:57 +00:00
Marco Trevisan (Treviño)
84616bef27 window: Allow grab if the display focus is unset
As per commit 040de396b, we don't try to grab when shortcuts are inhibited,

However, this uses the focus window assuming that it is always set, while this
might not be the case in some scenarios (like when unsetting the focus before
requesting take-focus-window to acquire the input).

So allow the button grab even if the focus window is not set for the display

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/663
https://gitlab.gnome.org/GNOME/mutter/merge_requests/668
2019-07-03 18:13:25 +02:00
Olivier Fourdan
040de396b2 window: Don't use button grab modifiers with inhibit shortcuts
On Wayland, if a client issues a inhibit-shortcut request, the Wayland
compositor will disable its own shortcuts.

We should also disable the default handler for the button grab modifier
so that button events with the window grab modifiers pressed are not
caught by the compositor but are forwarded to the client surface.

That also fixes the same issue with Xwayland applications issuing grabs,
as those end up being emulated like shortcut inhibition.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/642
2019-07-03 10:36:34 +02:00
Florian Müllner
5a4bc15d0b workspace-manager: Expose layout properties
gnome-shell hardcodes a vertical one-column workspace layout, and
while not supporting arbitrary grids is very much by design, it
currently doesn't have a choice: We simply don't expose the workspace
layout we use.

Change that to allow gnome-shell to be a bit more flexible with the
workspace layouts it supports.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/618
2019-07-02 20:31:57 +02:00
Daniel van Vugt
01e20a6ba9 compositor: Don't emit size-changed when only position changes
Waking up gnome-shell and triggering JavaScript listeners of
`size-changed` every time a window was only moved was wasting a lot
of CPU.

This cuts the CPU requirement for dragging windows by around 22%.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/568
2019-07-02 15:19:03 +08:00
Jonas Ådahl
5cb6286436 kms-impl-device: Fail up front if we can't retrieve DRM resources
If we can't retrieve the drm resources, instead of segfaulting later on,
treat it as an error, and let the error handler up the stack handle it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/665
2019-07-01 11:56:08 +02:00
Jonas Ådahl
1c25b75571 kms-impl-device: Fail if we can't enable universal planes
We currently don't handle the lack of DRM_CLIENT_CAP_UNIVERSAL_PLANES
KMS capability. Fail constructing a device that can't handle this up
front, so later made assumptions, such as presence of a primary plane,
are actually valid.

If we want to support lack of said capability, the required planes need
to be emulated by a dummy MetaKmsPlane object.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/665
2019-07-01 11:55:47 +02:00
Jonas Ådahl
f2f4af0d50 window-actor: Make it clearer that the surface actor doesn't change
The way code was structured made it easy to misunderstand things as the
surface actor of a window actor could change over time. So is not the
case, however, the intention of the corresponding "update" function was
so that a surface actor could be assigned to a window actor as soon as
the X11 window was associated with its corresponding wl_surface, if the
window in question came from Xwayland.

Restructure the code and internal API a bit to make it clear that a
window actor only once gets a surface actor assigned to it, and that it
after that point never changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/659
2019-06-28 21:08:23 +02:00
Jonas Ådahl
a8f8bc563e window-actor: Always chain up to parent's dispose vfunc
Our early out shouldn't mean we early out from the parents dispose
function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/659
2019-06-28 21:07:33 +02:00
Jonas Ådahl
46248748a9 window-actor/wayland: Don't set set_surface_actor vfunc
It's implemented by the parent class anyway, so we don't need our empty
call-parent implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/659
2019-06-28 21:07:33 +02:00
Jonas Ådahl
da7372a2fa window-actor/x11: Fix include macros
Was missing "config.h" and associated header was not on top.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/659
2019-06-28 21:07:33 +02:00
Marco Trevisan (Treviño)
de97b54595 surface-actor-x11: Bind the surface actor resources to window actor life
X11 actors need to release the server data (pixmap and damage) before the
display is closed.
During the close phase all the windows are unmanaged and this causes the window
actors to be removed from the compositor, unsetting their actor surface.

However, in case a window is animating the surface might not be destroyed until
the animation is completed and a reference to it kept around by gjs in the shell
case. By the way, per commit 7718e67f all window actors (even the animating
ones) are destroyed before the display is closed, but this is not true for the
child surface, because the parent window will just unref it, leaving it around
if reffed somewhere else. This is fine for wayland surfaces, but not for X11
ones which are bound to server-side pixmaps.

So, connect to the parent MetaWindowActor "destroy" signal, releasing the x11
resources that implies detaching the pixmap (unsetting the texture) and removing
the damages.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/629
https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:47 +02:00
Marco Trevisan (Treviño)
d7d97f2477 surface-actor-x11: Assign X11 Display only if we have resources
free_damage and detach_pixmap functions are called inside dispose and an object
can be disposed multiple times, even when the display is already closed.

So, don't try to deference a possibly null-pointer, assigning the xdisplay too
early, as if the X11 related resources have been unset, the server might not be
open anymore. In fact, we assume that if we have a damage or a pixmap set,
the display is still open.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:47 +02:00
Marco Trevisan (Treviño)
7776941b89 window-actor: Set actor as compositor private in window before the surface
In MetaWindowActor creation we're setting the compositor private (i.e. the
window actor itself) of a window before creating the surface actor, and so
passing to the it a window without its compositor side set.

Since the surface actor might use the parent actor, set this before updating
the surface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:46 +02:00
Marco Trevisan (Treviño)
4061c8384b window-actor: Use vfunc to set the surface actor
As per commit 80e3c1d set_surface_actor has been added, meant to do different
things depending on the backend, like connecting to signals under X11.

However, the vfunc isn't ever used, making the X11 surfaces not to react to
repaint-scheduled signal.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:46 +02:00
Marco Trevisan (Treviño)
b850f5a732 compositor: Use direct access to disconnect top window actor signal
Everytime the top window changes we connect/disconnect to the actor's destroy
signal, although as explained in commit ba8f5a11 this might be slower in case
the window actor has many other signal connections.

So, just track this using an ID.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:46 +02:00
Marco Trevisan (Treviño)
7645c51c54 compositor: Only disconnect/connect top-window signals if it changed
If the stack changed but the top window didn't, there's no need to disconnect
the signal and connect it again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:45 +02:00
Marco Trevisan (Treviño)
f1837b785b compositor: Replace tabs with spaces
Some old code was still using tabs instead of spaces, so replace the leftover
tabs with 8 spaces each.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
2019-06-28 19:36:45 +02:00
Georges Basile Stavracas Neto
1206879a20 kms-plane: Include <drm_fourcc.h>
Instead of including <drm/drm_fourcc.h>. This is the
only file that includes the drm_fourcc.h header like
this, and it happened to break the build locally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/663
2019-06-28 13:25:15 -03:00
Jonas Ådahl
dc5925b7d1 kms-plane: Restore adding format fallbacks
There were fallbacks in place in case IN_FORMATS didn't yield any usable
formats: the formats in the drmModePlane struct, and a hard coded array.
The lack of these fallbacks in place could result in a segfault as code
using the supported plane formats assumed there were at least something
in there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/662
2019-06-28 14:21:11 +00:00
Olivier Fourdan
b138006bb7 wayland/xdg-output: Add xdg-output v2 support
xdg-output v2 adds the output name and description events, add siupports
for these in mutter.

https://gitlab.gnome.org/GNOME/mutter/issues/645
2019-06-28 11:19:22 +02:00
Olivier Fourdan
bca08c2c4e monitor-manager: Use meta_monitor_get_display_name() API
Use the new monitor's `meta_monitor_get_display_name()` instead of
rebuilding the display name for each DBUS request.

https://gitlab.gnome.org/GNOME/mutter/issues/645
2019-06-28 11:19:22 +02:00
Olivier Fourdan
6541d49fe7 monitor: Add display name
The display name is being used by the monitor manager to expose to name
to the DBUS API.

It is being rebuilt each time, so instead build the displa yname once
for the monitor and keep it around, with an API to retrieve it, so that
we can reuse it in preparation of xdg-output v2 support.

https://gitlab.gnome.org/GNOME/mutter/issues/645
2019-06-28 11:19:22 +02:00
Olivier Fourdan
c3c6668343 monitor-manager: Add get_vendor_name API
The monitor manager keeps the list of PnP Ids, add a new API to get the
vendor name from a given PnP ID.

https://gitlab.gnome.org/GNOME/mutter/issues/645
2019-06-28 11:19:22 +02:00
Jonas Ådahl
70de90ebce renderer/native: Discard page flip retries when rebuilding views
Rebuilding views means we don't care to retry page flip attempts for
previous views, especially since connectors may have been disconnected,
making a page flip retry hit an assert a flipped CRTC has connectors
associated with it.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/619

https://gitlab.gnome.org/GNOME/mutter/merge_requests/630
2019-06-27 19:08:01 +02:00
Jonas Ådahl
0756fd4636 renderer/native: Queue mode reset from new rebuild_views vfunc
Simplify the call site a bit and make the native renderer know it should
queue mode reset itself when views have been rebuilt. This is done
partly due to more things needing to be dealt with after views have been
rebuilt.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/630
2019-06-27 19:08:01 +02:00
Jonas Ådahl
8c339dac3e renderer/native: Remove left-over function declarations
There are no callers and no definitions of these.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/630
2019-06-27 19:07:57 +02:00
Florian Müllner
ca88826ce9 remote-desktop-session: Remove unnecessary include
The class doesn't actually use the native backend, so remove it
to avoid build errors when the backend is disabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/637
2019-06-27 15:50:11 +00:00
Jonas Ådahl
7229a07b6c window-actor: Remove left-over parent field
The commit

commit 60f7ff3a69
Author: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date:   Fri Dec 21 18:12:49 2018 -0200

    window-actor: Turn into a derivable class

made the previous instance struct a instance private struct, but didn't
remove the parent field. Since it's unused, there is no point in keeping
it around, so lets drop it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/658
2019-06-27 15:07:47 +02:00
Olivier Fourdan
85f4772a4f backend/native: Fix compiler warning w/out EGL device
When building without EGL device support, the following compiler warning
is seen:

```
  src/backends/native/meta-renderer-native.c:2637:20: warning: unused
  variable ‘cogl_renderer_egl’ [-Wunused-variable]
```

Fix the warning by placing the relevant variable declarations within the
`#ifdef HAVE_EGL_DEVICE/#endif` statement.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/656
2019-06-27 10:21:26 +02:00
Robert Mader
f2fb3945d1 wayland/surface: Post error on invalid scale
To follow the spec and make faulty clients fail hard.

https://gitlab.freedesktop.org/wayland/wayland/blob/master/protocol/wayland.xml#L1618

https://gitlab.gnome.org/GNOME/mutter/merge_requests/647
2019-06-26 21:02:46 +02:00
Florian Müllner
feb9d129db window-x11: Fix typo 2019-06-24 19:33:30 +02:00
Carlos Garnacho
2b519cba36 backends: Move numlock persistence handling here
We used to have wayland-specific paths for this in src/wayland, now we
have ClutterKeymap that we can rely on in order to do state tracking,
and can do this all on src/backend domain.

This accomodates the feature in common code, so will work on both
Wayland and X11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/590
2019-06-24 18:24:57 +02:00
Carlos Garnacho
832fc798d5 backends: Add missing code to restore NumLock state on X11
It's not be called to any practical effect yet in this backend, but will
do soon.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/590
2019-06-24 17:12:14 +02:00
Jonas Ådahl
20731887f2 monitor-manager/dummy: Fix name of mode debug env var
It provides ways to configure the modes, not the actual monitors.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/529
2019-06-24 13:49:52 +00:00
Jonas Ådahl
980d9b1042 monitor-manager/dummy: Make modes env var override the defaults
So that one can effectively change the default resolution.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/529
2019-06-24 13:49:52 +00:00
Corentin Noël
bd7704f9e1 meta: Make MetaBackgroundGroup derivable
https://gitlab.gnome.org/GNOME/mutter/merge_requests/640
2019-06-24 13:49:31 +00:00
Jonas Ådahl
68f18f1fe9 monitor-manager/kms: Use KMS abstraction to get and set CRTC gamma
Still doesn't synchronize with frame drawing, but no point in doing that
until gamma is managed by mutter itself and not gnome-settings-daemon.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/634
2019-06-24 13:36:10 +00:00
Jonas Ådahl
c655166398 kms-impl/simple: Removing extra semi colon
https://gitlab.gnome.org/GNOME/mutter/merge_requests/634
2019-06-24 13:36:10 +00:00
Marco Trevisan (Treviño)
e14613e74e window: Warn if try to focus unmanaging windows
https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
f71151a5dd window-x11: Focus the default window with delay while waiting for take-focus
When requesting to a take-focus window to acquire the input, the client may or
may not respond with a SetInputFocus (this doesn't happen for no-input gtk
windows in fact [to be fixed there too]), in such case we were unsetting the
focus while waiting the reply.

In case the client won't respond, we wait for a small delay (set to 250 ms) for
the take-focus window to grab the input focus before setting it to the default
window.

Added a test for this behavior and for the case in which a window takes the
focus meanwhile we're waiting to focus the default window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
6022b23923 test-runner: Add 'dispatch' command
This will only wait for events to be dispatched and processed by the server
without waiting for client processing.

Reuse the code for the wait command too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
d08763c18c test-runner: Add 'sleep' command
This allows to sleep for a given timeout in milliseconds.

Rename test_case_before_redraw to test_case_loop_quit since it's a generic
function and use it for the timeout too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
fcb408ad5d tests: Verify focused window in closed-transient tests
Ensure that we have a focused window when closing transient windows with
no-focus or no-take-focus atoms

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
51f9e04ef1 test-runner: Add 'assert_focused' command
This allows to verify which window should have the focus, which might not
be the same as the top of the stack.

It's possible to assert the case where there's no focused window using
"NONE" as parameter.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
2fc7760cee tests, stacking: Add tests with no-input and no-take-focus windows
When a window with no frame, that doesn't accept focus and that has no
take-focus atom set is destroyed, we ended up in not changing the current_focus
window, causing a crash.

Added test cases that verify this situation.

Related to https://gitlab.gnome.org/GNOME/mutter/issues/308
https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
f2d2d473b7 tests: Add 'can_take_focus' command to runner and client
Allow to set/unset WM_TAKE_FOCUS from client window.
This is added by default by gtk, but this might not happen in other toolkits,
so add an ability to (un)set this.

So fetch the protocols with XGetWMProtocols and unset the atom.

test-client now needs to depend on Xlib directly in meson build.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
e1f839f48f tests: Add 'accept_focus' command to runner and client
Under the hood, calls gtk_window_set_accept_focus in the client

https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00:00
Marco Trevisan (Treviño)
eccc791f3b workspace: Focus only ancestors that are focusable
When destroying a window that has a parent, we initially try to focus one of
its ancestors. However if no ancestor can be focused, then we should instead
focus the default focus window instead of trying to request focus for a window
that can't get focus anyways.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/308
2019-06-24 09:42:07 +00:00
Ting-Wei Lan
6055f04814 display: Remove _XOPEN_SOURCE definition
There is no gethostname call in this file.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/638
2019-06-24 09:35:02 +00:00
Ting-Wei Lan
0185909ee3 window-x11: Fix _XOPEN_SOURCE usage for gethostname on FreeBSD
On FreeBSD, gethostname is guarded by '__POSIX_VISIBLE >= 200112', which
requires either '_POSIX_C_SOURCE >= 200112' or '_XOPEN_SOURCE >= 600'.
Defining _XOPEN_SOURCE to 500 does not break the build because of
implicit declaration, but it defeats the purpose of defining the macro.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/638
2019-06-24 09:35:02 +00:00
Ting-Wei Lan
c35e56196a xwayland: Use g_get_host_name instead of gethostname
Since the xauth file is never going to be changed after it is generated,
it is safe to use g_get_host_name here.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/626
https://gitlab.gnome.org/GNOME/mutter/merge_requests/638
2019-06-24 09:35:02 +00:00
Carlos Garnacho
181c7cab32 wayland: Use right sign for workspace ID
We get a signed integer (-1 meaning "no workspace specified"), store it in
an unsigned integer, check for >= 0 (of course it is!) and set as the window
workspace (signed integer, -1 meaning "show on all workspaces"). What could
possibly go wrong?

https://gitlab.gnome.org/GNOME/mutter/merge_requests/639
2019-06-24 09:21:49 +00:00
Ting-Wei Lan
740a62044e wayland/pointer-constraints: Fix build when native backend is disabled
https://gitlab.gnome.org/GNOME/mutter/merge_requests/636
2019-06-22 16:12:42 +00:00
Niels De Graef
70bacb9402 cogl: Remove CoglError wrapper
CoglError was added at a certain point to remove the hard dependency on
GLib, but since this can't be avoided inside mutter, let's remove this
whole abstraction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/631
2019-06-20 18:25:04 +02:00
Jonas Ådahl
57dfe4696d kms-update: Seal updates when posting them
This makes sure that we won't accidentally change KMS transaction
updates after they have been posted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
22a91f23ad backends/native: Add some KMS debug logging
Using the g_debug() macro. Set G_DEBUG_MESSAGES to "mutter" to activate
log.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
6aa1026600 kms: Add high level code documentation
Document the high level components of the KMS abstraction.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
75dff3e7c9 backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.

The API consists of various buliding blocks:

 * MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
 * MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.

This also means various high level changes:

State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.

From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.

EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.

Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.

While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
bea7600471 logical-monitor: Pass output when iterating over CRTCs
While not currently used by any users, it'll be useful in future
commits.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
8932388dda backend/native: Move some KMS utilities to its own file
They are not strictly related to any of the KMS objects, and should be
reusable without adding a dependency on the non-meta-kms-* files in
meta-kms-*.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
2238c9f180 kms: Add API to register impl file descriptors
To let the MetaKmsImpl implementation register file descriptor GSource
where the invoke function is ensured to be executed in the impl context.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
ca21ca6745 kms: Add API to add a GSource that'll be invoked in the impl context
The MetaKmsImpl implementation may need to add a GSource that should be
invoked in the right context; e.g. a idle callback, timeout etc. It
cannot just add it itself, since it's the responsibility of MetaKms to
determine what is the impl context and what is the main context, so add
API to MetaKms to ensure the callback is invoked correctly.

It's the responsibility of the caller to eventually remove and destroy
the GSource.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
2bbd2e5563 kms: Add API to post callbacks out of the impl context
While the current impl context is in the same thread as the main
context, the separation still exists, and to post callbacks from the
impl context, it must pass MetaKms to make sure the callback is invoked
in the right context.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
691d58e69b gpu/kms: Remove unused typedef
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
d84c7269b2 crtc/kms: Use MetaKmsPlane to check supported rotations and formats
Instead of manually retrieving supported transforms and formats from the
primary plane of the CRTC, use the MetaKmsPlane abstraction to find the
primary plane of the CRTC and check compatibility using the
MetaKmsPlane API. This removes the last user of direct KMS API usage
except for applying configuration.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
aba689312f gpu/kms: Init global mode list from MetaKmsConnectors
Instead of iterating over the available drmModeConnector objects to
construct a GPU wide mode list, use the state managed by
MetaKmsConnector. This also removes the last user of drmModeRes from
MetaGpuKms.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
f2d9a11013 output/kms: Outsource connector state fetching to MetaKmsConnector
As with CRTC state, variable connector state is now fetched via the
MetaKmsConnector. The existance of a connector state is equivalent of
the connector being connected. MetaOutputKms is changed to fetch
variable connector state via MetaKmsConnector intsead of KMS directly.
The drmModeConnector is still used for constructing the MetaOutputKms to
find properties used for applying configuration.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:56 +00:00
Jonas Ådahl
596376c408 crtc/kms: Outsource CRTC state fetching to MetaKmsCrtc
Move reading state into a struct for MetaCrtcKms to use instead of
querying KMS itself. The state is fetched in the impl context, but
consists of only simple data types, so is made accessible publicly. As
of this, MetaCrtcKms construction does not involve any manual KMS
interaction outside of the MetaKms abstraction.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
1f62a8dbd9 crtc/kms: Don't redefine META_MONITOR_N_TRANSFORMS
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
f59d62bc8f kms: Add connector representation
Represents drmModeConnector; both connected and disconnected. Currently
only provides non-changing meta data. MetaOutputKms is changed to use
MetaKmsConnector to get basic metadata, but variable metadata, those
changing depending on what is connected (e.g. physical dimension, EDID,
etc), are still manually retrieved by MetaOutputKms.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
5d5d296551 gpu/kms: Fix connector id type in helper
It's a uint32_t, not a long.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
065bf752f4 output/kms: Make drmModeEncoderPtr array local
It was only used within one function, where it was always created, but
still was kept around indefinitely for no reason. Lets get rid of it
from the MetaOutputKms struct.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
4d3e804391 kms: Add plane representation
A plane is one of three possible: primary, overlay and cursor. Each
plane can have various properties, such as possible rotations, formats
etc. Each plane can also be used with a set of CRTCs.

A primary plane is the "backdrop" of a CRTC, i.e. the primary output for
the composited frame that covers the whole CRTC. In general, mutter
composites to a stage view frame onto a framebuffer that is then put on
the primary plane.

An overlay plane is a rectangular area that can be displayed on top of
the primary plane. Eventually it will be used to place non-fullscreen
surfaces, potentially avoiding stage redraws.

A cursor plane is a plane placed on top of all the other planes, usually
used to put the mouse cursor sprite.

Initially, we only fetch the rotation properties, and we so far
blacklist all rotations except ones that ends up with the same
dimensions as with no rotations. This is because non-180° rotations
doesn't work yet due to incorrect buffer modifiers. To make it possible
to use non-180° rotations, changes necessary include among other things
finding compatible modifiers using atomic modesetting. Until then,
simply blacklist the ones we know doesn't work.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
15a2ccd21b kms: Add CRTC representation
Add MetaKmsCrtc to represent a CRTC on the associated device. Change
MetaCrtcKms to use the ones discovered by the KMS abstraction. It still
reads the resources handed over by MetaGpuKms, but eventually it will
use only MetaKmsCrtc.

MetaKmsCrtc is a type of object that is usable both from an impl task
and from outside. All the API exposed via the non-private header is
expected to be accessible from outside of the meta-kms namespace.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
fef5753a19 backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.

The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.

Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.

This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
f3fd7cf92b gpu/kms: Remove max buffer size getter
It was unused.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
5c500ad402 backend: Move GPU ownership from the monitor manager to the backend
Lets work towards making MetaMonitorManager about managing monitors, and
not about managing GPUs. This changes other units to keep a pointer to
the backend instead of a monitor manager, in case their ownership
changed, or their main usage of the monitor manager was to look up GPUs.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
e7fd068a78 monitor-manager/kms: Use 'hotplug' event from MetaUdev
Instead of dealing with udev details here, use the newly added 'hotplug'
event emitted from MetaUdev.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
171e5fc3c2 udev: Add 'hotplug' event
To be used my the monitor manager to handle hotplugs.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
7b7d881386 udev: Add helpers to list DRM devices
Will be used to move out some udev related logic when adding GPUs.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
44905d96da backends/native: Move some initialization from init() to initable_init()
This means we can report the errors properly, instead of logging a
warning and calling exit(1).

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
73e8127d5d backends/native: Add udev abstraction layer
To be used to signal devices added, hotplugs and other udev events.
Currently the only event emitted is when a device is added.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Jonas Ådahl
11e2005563 backends/native: Remove instance private
The object struct definition itself is private, so the object instance
private serves no purpose. Thus, move the fields into the object struct
and remove the instance private struct.

https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-06-20 13:31:55 +00:00
Olivier Fourdan
c63d0173b5 xwayland: Fix build without <sys/random.h>
The include <sys/random.h> was added to glibc-2.25, previously was
<linux/random.h>.

Adjust meson build and code to accomodate both.

Fixes: a8984a81c "xwayland: Generate a Xauth file and pass this to
                  Xwayland when starting it"

https://gitlab.gnome.org/GNOME/mutter/merge_requests/633
2019-06-20 12:37:18 +02:00
Hans de Goede
7fcdd60ac5 renderer-native: Fix compiler warning
Fix the following compiler warning:
../src/backends/native/meta-renderer-native.c: In function ‘meta_renderer_native_create_view’:
/usr/include/glib-2.0/glib/gmacros.h:523:17: warning: ‘formats’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  523 |     { if (_ptr) (cleanup) ((ParentName *) _ptr); }                                                              \
      |                 ^
../src/backends/native/meta-renderer-native.c:773:22: note: ‘formats’ was declared here
  773 |   g_autoptr (GArray) formats;
      |                      ^~~~~~~

https://gitlab.gnome.org/GNOME/mutter/merge_requests/632
2019-06-20 10:32:52 +02:00
Hans de Goede
a8984a81c2 xwayland: Generate a Xauth file and pass this to Xwayland when starting it
Before this commit, sudo x11-app, e.g. sudo gvim /etc/some-file, fails
when running a Wayland session. Where as doing this under a "GNOME on Xorg"
session works fine. For a user switching from the Xorg session to the
Wayland session, this is regression, which we want to avoid.

This commit fixes this by creating and passing an xauth file to Xwayland when
mutter starts it. Just like gdm or startx pass a xauth file to Xorg when they
start Xorg.

Fixes #643

https://gitlab.gnome.org/GNOME/mutter/issues/643
2019-06-20 10:16:21 +02:00
Niels De Graef
769a02b630 cogl: Drop _COGL_RETURN_VAL_IF_FAIL macro
This was introduced when the Cogl maintainers tried to move away from
GLib. Since we always require it, we can just use
`g_return_val_if_fail()` immediately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:46:22 +02:00
Georges Basile Stavracas Neto
2464f00902
screen-cast-monitor-stream-src: Watch monitors using MetaStageWatch
This uses the API introduced by the previous commit. By watching specific
monitors directly, and not whole stage views, we avoid showing artifacts
on multi-monitor setups.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/424

https://gitlab.gnome.org/GNOME/mutter/merge_requests/623
2019-06-19 13:12:18 -03:00
Georges Basile Stavracas Neto
9b5d9f3cb3
stage: Introduce MetaStageWatch and family
MetaStageWatch, watch modes and the watch function are part
of the new stage view watching API. It's design does not
rely on signals on purpose; the number of signals that would
be emitted would be too high, and would impact performance.

MetaStageWatch is an opaque structure outside of MetaStage.

This will be used by the screencast code to monitor a single
view, which has a one-to-one relatioship to logical monitors.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/623
2019-06-19 13:12:17 -03:00
Jonas Ådahl
b836e661cf wayland: Don't export non-public API not used by tests
https://gitlab.gnome.org/GNOME/mutter/merge_requests/628
2019-06-19 15:19:05 +00:00
Hans de Goede
446e82e86d test-utils: Fix compiler warning
This fixes the following compiler warning:

In file included from /usr/include/glib-2.0/glib.h:114,
                 from ../src/tests/test-utils.h:23,
                 from ../src/tests/test-utils.c:22:
../src/tests/test-utils.c: In function ‘test_init’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: warning: ‘basename’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   g_free (*pp);
      |   ^~~~~~~~~~~~
../src/tests/test-utils.c:73:24: note: ‘basename’ was declared here
   73 |       g_autofree char *basename;
      |                        ^~~~~~~~

https://gitlab.gnome.org/GNOME/mutter/merge_requests/627
2019-06-19 13:00:17 +02:00
Jonas Ådahl
d9fb11b043 renderer/native: Fix EGLSurface destruction order
Make sure to destroy the EGL surface after releasing held buffers,
otherwise we'll get the following valgrind warnings:

==24016== Invalid read of size 8
==24016==    at 0x1739943F: release_buffer (platform_drm.c:73)
==24016==    by 0x49AC355: meta_drm_buffer_gbm_finalize (meta-drm-buffer-gbm.c:213)
==24016==    by 0x4B75B61: g_object_unref (gobject.c:3346)
==24016==    by 0x49B4B41: free_current_bo (meta-renderer-native.c:991)
==24016==    by 0x49B816F: meta_renderer_native_release_onscreen (meta-renderer-native.c:2971)
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
==24016==    by 0x4B75AF2: g_object_unref (gobject.c:3309)
==24016==  Address 0x18e742a8 is 536 bytes inside a block of size 784 free'd
==24016==    at 0x4839A0C: free (vg_replace_malloc.c:540)
==24016==    by 0x17399764: dri2_drm_destroy_surface (platform_drm.c:231)
==24016==    by 0x1738550A: eglDestroySurface (eglapi.c:1145)
==24016==    by 0x5440286: eglDestroySurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
==24016==    by 0x49613A5: meta_egl_destroy_surface (meta-egl.c:432)
==24016==    by 0x49B80F9: meta_renderer_native_release_onscreen (meta-renderer-native.c:2954)
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
==24016==  Block was alloc'd at
==24016==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
==24016==    by 0x173997AE: dri2_drm_create_window_surface (platform_drm.c:145)
==24016==    by 0x17388906: _eglCreateWindowSurfaceCommon (eglapi.c:929)
==24016==    by 0x5440197: eglCreateWindowSurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
==24016==    by 0x49612FF: meta_egl_create_window_surface (meta-egl.c:396)
==24016==    by 0x49B752E: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2538)
==24016==    by 0x49B7E6C: meta_onscreen_native_allocate (meta-renderer-native.c:2870)
==24016==    by 0x49B8BCF: meta_renderer_native_create_view (meta-renderer-native.c:3387)
==24016==    by 0x48D274B: meta_renderer_create_view (meta-renderer.c:78)
==24016==    by 0x48D27DE: meta_renderer_rebuild_views (meta-renderer.c:111)
==24016==    by 0x49BB4FB: meta_stage_native_rebuild_views (meta-stage-native.c:142)
==24016==    by 0x49A733C: meta_backend_native_update_screen_size (meta-backend-native.c:517)

https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
2019-06-18 11:12:03 +02:00
Jonas Ådahl
56ddaaa380 renderer/native: Make sure we're not destroying an active EGLSurface
When making a new surface/context pair current, mesa may want to flush
the old context. Make sure we don't try to flush any freed memory by
unmaking a surface/context pair current before freeing it.

Not doing this results in the following valgrind warnings:

==15986== Invalid read of size 8
==15986==    at 0x69A6D80: dri_flush_front_buffer (gbm_dri.c:92)
==15986==    by 0x1750D458: intel_flush_front (brw_context.c:251)
==15986==    by 0x1750D4BB: intel_glFlush (brw_context.c:296)
==15986==    by 0x1739D8DD: dri2_make_current (egl_dri2.c:1461)
==15986==    by 0x17393A3A: eglMakeCurrent (eglapi.c:869)
==15986==    by 0x54381FB: InternalMakeCurrentVendor (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
==15986==    by 0x5438515: eglMakeCurrent (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
==15986==    by 0x522A782: _cogl_winsys_egl_make_current (cogl-winsys-egl.c:303)
==15986==    by 0x49B64C8: meta_renderer_native_create_view (meta-renderer-native.c:3076)
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
==15986==  Address 0x1b076600 is 0 bytes inside a block of size 48 free'd
==15986==    at 0x4839A0C: free (vg_replace_malloc.c:540)
==15986==    by 0x49B59F3: meta_renderer_native_release_onscreen (meta-renderer-native.c:2651)
==15986==    by 0x5211441: _cogl_onscreen_free (cogl-onscreen.c:167)
==15986==    by 0x5210D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
==15986==    by 0x51D0066: _cogl_object_default_unref (cogl-object.c:103)
==15986==    by 0x520F989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
==15986==    by 0x51D00B1: cogl_object_unref (cogl-object.c:115)
==15986==    by 0x536F3C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
==15986==    by 0x4B7DAF2: g_object_unref (gobject.c:3309)
==15986==    by 0x4A9596C: g_list_foreach (glist.c:1013)
==15986==    by 0x4A9599A: g_list_free_full (glist.c:223)
==15986==    by 0x48D2737: meta_renderer_rebuild_views (meta-renderer.c:100)
==15986==  Block was alloc'd at
==15986==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
==15986==    by 0x69A76B2: gbm_dri_surface_create (gbm_dri.c:1252)
==15986==    by 0x69A6BFE: gbm_surface_create (gbm.c:600)
==15986==    by 0x49B4E29: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2221)
==15986==    by 0x49B57DB: meta_onscreen_native_allocate (meta-renderer-native.c:2569)
==15986==    by 0x49B6423: meta_renderer_native_create_view (meta-renderer-native.c:3062)
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
==15986==    by 0x49A75B5: meta_backend_native_update_screen_size (meta-backend-native.c:520)
==15986==    by 0x48B01BB: meta_backend_sync_screen_size (meta-backend.c:224)
==15986==    by 0x48B09B7: meta_backend_real_post_init (meta-backend.c:501)

https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
2019-06-18 11:12:03 +02:00
Jonas Ådahl
1efb32d300 renderer/native: Use g_set_error() instead of _cogl_set_error()
It's even a GError, so lets use the proper API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
2019-06-18 11:12:03 +02:00
Niels De Graef
689c7f4107 clutter: Remove unused ClutterWaylandSurface
This allows for some further cleanups, since it is the sole consumer of
some functions in Cogl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/624
2019-06-18 09:54:00 +02:00
Jonas Ådahl
59bf1f4838 window/wayland: Don't always use constrained size when unfullscreening
When we're unfullscreening, we might be returning to a window state that
has its size either managed by constraints (tiled, maximized), or not
(floating). Lets just pass the configure size 0x0 when we're not using
constrained sizes (i.e. the window going from being fullscreen to not
maximized) and let the application decide how to size itself.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/638

https://gitlab.gnome.org/GNOME/mutter/merge_requests/621
2019-06-13 16:40:57 +00:00
Jonas Ådahl
db0f85ba5d window: Add tile mode getter
Lets avoid peeking in the MetaWindow struct itself and add a getter for
the relevant state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/621
2019-06-13 16:40:57 +00:00
Jonas Ådahl
425611eadf window/wayland: Use constrained size when unmaximizing while fullscreen
Otherwise we'll ask the client to use the size 0x0 with the fullscreen
state set.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/621
2019-06-13 16:40:57 +00:00
Emil Velikov
9213574870 renderer/native: add missing eglTerminate in EGLDevice error path
Currently the EGLDevice code gets the display and calls eglInitialize.
As a follow-up it checks the required EGL extensions - technically it
could check the EGL device extensions earlier.

In either case, eglTerminate is missing. Thus the connection to the
display was still bound.

This was highlighted with Mesa commit d6edccee8da ("egl: add
EGL_platform_device support") + amdgpu.

In that case, since the eglTerminate is missing, we end up reusing the
underlying amdgpu_device due to some caching in libdrm_amdgpu. The
latter in itself being a good solution since it allows buffer sharing
across primary and render node of the same device.

Note: we should really get this in branches all the way back to 3.30.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/619

Fixes: 934184e23 ("MetaRendererNative: Add EGLDevice based rendering support")
Cc: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-13 17:12:40 +01:00
Jonas Ådahl
4064d9a7a7 clutter: Remove ability to be user resizable
It's a functionality from the application centric clutter that we don't
need for compositors.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/616
2019-06-13 14:28:46 +00:00
Florian Müllner
8a06cfdd81 enum-types: Use @basename@ in header comment
@filename@ may contain arch-specific bits that introduce unnecessary
multi-lib issues.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/617
2019-06-12 18:01:36 +02:00
Jonas Ådahl
178b975d6a cursor-renderer: Align OpenGL cursor rect to physical pixel grid
When stage views are scaled with fractional scales, the cursor rectangle
won't be aligned with the physical pixel grid, making it potentially
blurry when positioned in between physical pixels. This can be avoided
by aligning the drawn rectangle to the physical pixel grid of the stage
view the cursor is located on.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/413

https://gitlab.gnome.org/GNOME/mutter/merge_requests/610
2019-06-07 19:11:34 +00:00
Jonas Ådahl
36b361617d wayland/cursor-surface: Update sprite when attaching NULL
Attaching a NULL buffer should hide the cursor sprite. In these cases,
we we'll have neither surface nor buffer damage, so also update when we
just attached a NULL buffer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/630
2019-06-07 16:06:47 +00:00
Jonas Ådahl
5eac1d696d wayland/surface: Clear texture when attaching NULL
When 252e64a0ea moved the texture
ownership to MetaWaylandSurface, it failed to handle the case when a
NULL-buffer is attached, leaving the texture reference in place. This
caused issues when the surface should have been hidden (e.g. attaching a
NULL buffer to a cursor surface for hiding the cursor sprite).

Related: https://gitlab.gnome.org/GNOME/mutter/issues/630
2019-06-07 16:06:47 +00:00
Marco Trevisan (Treviño)
0487d672ed x11-display: Handle mapped XIDs per type
Starting from commit 7713006f5, during X11 disposition we also unmanage the
windows using the xids hash table values list.
However, this is also populated by the X11 Meta barrier implementation and then
contains both Windows and Barriers.

So when going through the values list, check whether we're handling a window or
a barrier and based on that, unmanage or destroy it.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/624
https://gitlab.gnome.org/GNOME/mutter/merge_requests/605
2019-06-06 21:35:11 +00:00
Marco Trevisan (Treviño)
e94a0fced9 display: Dispose Stack after Compositor and X11
As per commit 7718e67f, destroying the compositor causes destroying window
actors and this leads to stack changes, but at this point the stack was already
disposed and cleared.

So, clear the stack when any component that could use it (compositor, and X11)
has already been destroyed.
As consequence, also the stamps should be destroyed at later point.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/623
https://gitlab.gnome.org/GNOME/mutter/merge_requests/605
2019-06-06 21:35:11 +00:00
Olivier Fourdan
a3b86447f7 backends: Add mouse accessibility settings
Add support for mouse accessibility settings to set the click assist
values.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/512
2019-06-06 13:04:50 +02:00
Olivier Fourdan
c33b330799 backends: Rename keyboard accessibility settings
Naming the keyboard accessibility settings `a11y_settings` wrongly
assumes there will never be any other type of accessibility settings.

Rename `a11y_settings` to `keyboard_a11y_settings` to avoid future
confusion.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/512
2019-06-06 13:04:50 +02:00
Marco Trevisan (Treviño)
a6fc656e91 window: Emit an error and return when trying to activate an unmanaged
If something (i.e. gnome-shell or an extension) tries to activate an unmanaged
window, we should warn about this and avoid to perform further actions as this
could lead to a crash of mutter, since the window has not valid flags (like
workspace) set anymore at this stage.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/580

https://gitlab.gnome.org/GNOME/mutter/merge_requests/564
2019-06-05 17:53:12 +00:00
Douglas R. Reno
a38bae259e
docs: Update tests instructions
The documentation still refers to autotools, update it to
use the corresponding meson commands.

https://gitlab.gnome.org/GNOME/mutter/issues/568
2019-06-05 14:49:35 -03:00
Olivier Fourdan
c53aa89098 keybindings: Small code cleanup
Reuse the name we just set to insert in the hash table, that avoids
duplicating the string.

Suggested-by: Carlos Garnacho <carlosg@gnome.org>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/453
2019-06-05 09:34:39 +00:00
Olivier Fourdan
851b7d0639 keybindings: Trigger locate-pointer on key modifier
We trigger the "locate-pointer" mechanism when a special key modifier
(defaults to Control_L) key is pressed and released.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/453
https://gitlab.gnome.org/GNOME/gnome-shell/issues/981
https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/merge_requests/19
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/merge_requests/86
2019-06-05 09:34:39 +00:00
Olivier Fourdan
b4c78726cf compositor: Add "locate_pointer" vmethod
This method is invoked to locate the pointer on screen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/453
https://gitlab.gnome.org/GNOME/gnome-shell/issues/981
https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/merge_requests/19
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/merge_requests/86
2019-06-05 09:34:39 +00:00
Olivier Fourdan
c9cc07fd3a settings: Slack off “xwayland-allow-grabs” setting
To emulate X11 grabs, mutter as a Wayland compositor would disable its
own keyboard shortcuts and when the X11 window is an override redirect
window (which never receives focus), it also forces keyboard focus onto
that X11 O-R window so that all keyboard events are routed to the
window, just like an X11 server would.

But that's a bit of a “all-or-nothing” approach which prevents
applications that would legitimately grab the keyboard under X11 (like
virtual machine viewers) to work by default.

Change “xwayland-allow-grabs” to control whether the keyboard focus
should be locked onto override redirect windows in case of an X11 grab.

For stringent needs, careful users can still use the blacklisting
feature (i.e. a list containing “!*”) to prevent grabs from any X11
applications to affect other Wayland native applications.

https://gitlab.gnome.org/GNOME/mutter/issues/597
2019-06-03 09:34:31 +02:00
Olivier Fourdan
f6eb2a8cf8 settings: Remove space characters
Small code style cleanup.

https://gitlab.gnome.org/GNOME/mutter/issues/597
2019-06-03 09:34:31 +02:00
Georges Basile Stavracas Neto
57945a730f
backend: Conditionally compile MetaProfiler
MetaProfiler is not built when -Dprofiler=false, and that
breaks the build since MetaBackend unconditionally imports
and uses it.

Fix that by wrapping MetaProfiler in compile-time checks.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/603
2019-05-31 12:54:13 -03:00
Georges Basile Stavracas Neto
7810f0e276
cogl/trace: Add user-visible group name
This way, it shows up as "Compositor" in Sysprof instead of
"t:XYZ".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:09 -03:00
Georges Basile Stavracas Neto
17c5436f6e
profile: Add a Sysprof-based profiler
This exposes the /org/gnome/Sysprof3/Profiler object
inside Mutter to allow initiating a Sysprof capture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:07 -03:00
Carlos Garnacho
1da0355528 wayland: Update tablet cursor outputs across cursor/proximity changes
Make sure those generic surface events are sent early on when setting a
cursor for any tablet tool, so clients can update to output characteristics.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/545
Related: https://gitlab.gnome.org/GNOME/gtk/issues/1675
2019-05-31 09:57:24 +00:00
Carlos Garnacho
e5881156f6 wayland: Handle NULL cursor renderer finding the outputs of a cursor role
Having a cursor role with a NULL renderer is valid state, and even desirable
on tablets (eg. after proximity out). In those cases it should be
interpreted as the cursor surface not being over any output.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/545
2019-05-31 09:57:24 +00:00
Marco Trevisan (Treviño)
60170cff70 compositor: Emit 'grab-op-end' signal after ungrab happened
We're currently emitting the 'grab-op-end' signal when the grab prerequisites
are met, but when display->grab_op is still set to a not-NONE value and thus
meta_display_get_grab_op() would return that in the signal callback.
And more importantly when this is emitted, devices are still grabbed.

Instead, emit this signal as soon as we've unset all the grab properties and
released the devices.

Helps with https://gitlab.gnome.org/GNOME/gnome-shell/issues/1326

https://gitlab.gnome.org/GNOME/mutter/merge_requests/596
2019-05-29 20:09:40 +00:00
Marco Trevisan (Treviño)
e2bea48073 display: Emit 'grab-op-end' signal after ungrab happened
We're currently emitting the 'grab-op-end' signal when the grab prerequisites
are met, but when display->grab_op is still set to a not-NONE value and thus
meta_display_get_grab_op() would return that in the signal callback.
And more importantly when this is emitted, devices are still grabbed.

Instead, emit this signal as soon as we've unset all the grab properties and
released the devices.

Helps with https://gitlab.gnome.org/GNOME/gnome-shell/issues/1326

https://gitlab.gnome.org/GNOME/mutter/merge_requests/596
2019-05-29 20:09:40 +00:00
Carlos Garnacho
bbfaf8204b wayland: Honor startup sequence workspace on .request_focus
We handle this in backend specific code for x11, so do the wayland
bits here. We can only honor this on applications that request focus
on a surface after a startup request, as we do need an explicit
surface to apply the workspace on (and we don't have additional clues
like WMCLASS on X11). Notably, gtk_shell1.notify_startup doesn't suffice.

Another gotcha is that the .request_focus happens when the surface is
already "mapped". Due to the way x11 and the GDK api currently work (first
reply on the startup id, then map a window, then request focus on that
window). This means the surface will ignore at this point
window->initial_workspace, so it must be actively changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/544
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/674
2019-05-29 16:21:15 +00:00
Carlos Garnacho
b3e19ee669 wayland: Unset DnD selection on wl_data_offer destruction
On a successful DnD operation we may expect the wl_data_source and
wl_data_offer to live long enough to finish the data transfer, despite the
grab operation (and other supporting data) being gone.

When that happens, the compositor expects a wl_data_offer.finish request to
notify that it finished. However the client may still chose not to send that
and destroy the wl_data_offer instead, resulting in the MetaSelectionSource
owner for the DnD selection not being unset.

When that happens, the DnD MetaSelectionSource still exists but it's
detached from any grab operation, so will not be unset if eg. the drag
source client destroys the wl_data_source. This may result in crashes when
the next drag operation tries to replace the owner DnD MetaSelectionSource.

Check explicitly for this case, in order to ensure the DnD owner is unset
after such operations.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-05-29 16:10:57 +00:00
Pekka Paalanen
2145333969
renderer/native: Refactor into secondary_gpu_get_next_dumb_buffer
Extract the next buffer -logic into a new function. This allows to
simplify copy_shared_framebuffer_cpu () making it more readable.

This change is a pure refactoring, no functional changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/593
2019-05-29 11:53:00 -03:00
Robert Mader
1b61b9cd73 boxes: Fix calculation of rounded rectangles
Since 68fba458 the function is used for more calculations, exposing
a bug when used with fractional scaling.

https://gitlab.gnome.org/GNOME/mutter/issues/609
2019-05-29 00:07:15 +02:00
Florian Müllner
a2c545c321 x11-display: Simplify bell handling
Since commit 956ab4bd made libcanberra mandatory, we never use
the system bell for handling the `audible-bell` setting. So
instead of reacting to settings changes with the exact same call
to XkbChangeEnabledControls(), just call it once when initializing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
Florian Müllner
3cd8f3b7dc workspace-manager: Remove unnecessary assignment
The initialization to -1 is never used, instead the variables are
re-initialized to 0 before the loop that uses them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
Florian Müllner
033ce2d956 input-mapper: Remove unnecessary return value
Since commit ae6d9e35bd, there is a fallback to META_MATCH_IS_BUILTIN,
so the condition for returning FALSE is never met.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
Florian Müllner
2b47e89405 renderer-x11-nested: Fix copy-and-paste error
The rounding added in commit c5471e5b8b mixed up some variables,
whoops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
Marco Trevisan (Treviño)
f869e4d54b headless-start-test: Ignore frame counter warnings
When running in slow or busy machines (hey CI!) or under valgrind headless
tests could fail because of a non fatal warning during initialization.

So define a fatal handler that ignores the frame counter warning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:26:30 -05:00
Marco Trevisan (Treviño)
c1059df7f9 test-runner: Always wait after creating a window
Creating a window could take some time, causing false-positive failures when
running in slower or busy hardware like:

  window 1/2 isn't known to Mutter

So before we proceed in doing any operation on it, wait for the client.
Do this in the test runner instead of repeating the same in every .metatest.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:23:55 -05:00
Marco Trevisan (Treviño)
0405786573 wayland-seat: Use g_free to cleanup MetaWaylandSeat
MetaWaylandSeat is allocated using g_new0(), and thus we should use g_free() to
destroy it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Marco Trevisan (Treviño)
b016ff29f6 cursor-renderer-native: Free MetaCursorNativePrivate struct
Fix a small leak in native renderer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Marco Trevisan (Treviño)
3f2e86f67c theme: Remove DEBUG_FILL_STRUCT
This debug statement is actually applied all the times, while it could be useful
for crashes analysis, these days the same can be done using `MALLOC_CHECK_` and
`MALLOC_PERTURB_` env variables.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Marco Trevisan (Treviño)
0aa4a526c6 boxes: Use G_DEFINE_BOXED_TYPE to define the type
https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Marco Trevisan (Treviño)
85c2aef4bc display: Cleanup Edges when display is closed
This could happen if closing the display when dragging a window, unlikely, but
better to use the cleanup function since we have it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Carlos Garnacho
b1ea768949 wayland: Drop -terminate argument to Xwayland
This argument instructs Xwayland to exit when there are no further
client connections. However we eventually want to handle restarts
ourselves (where, notably, mutter's will be at least the last client
connection).

This behavior could also induce race conditions on startup with clients
that quickly open and close a display, which is a more pressing issue.

Also, add -noreset back (which was also removed in commit 054c25f693 that
added -terminate). We don't want to reset the X server to a pristine state
in that situation either.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
ea9d8a895b wayland: Drop error trap
Code underneath seems to handle errors properly, or be x11-agnostic
entirely, this is apparently here to save a few XSync()s on X11. Just
drop this windowing dependent bit to make things cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
38432da328 compositor: Drop error trap
Code underneath seems to handle errors properly, and this is apparently
here to save a few XSync()s on X11. Just drop this windowing dependent
bit to make things cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
430f354cd9 wayland: Split Xwayland initialization in 2 steps
It is now separated into meta_xwayland_start(), which picks an unused
display and sets up the sockets, and meta_xwayland_init_xserver(), which
does the actual exec of Xwayland and MetaX11Display initialization.

This differentiation will be useful when Mutter is able to launch Xwayland
lazily, currently the former calls into the latter.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
1cf4279745 x11: Initialize GdkDisplay together with MetaX11Display
It's no longer a "singleton", since it might be closed and opened again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
7713006f5b x11: Unmanage X11 windows on MetaX11Display finalization
This used to be relied upon meta_display_close(), but MetaDisplay
and MetaX11Display lifetimes may be unrelated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
465e13128b core: Add explicit init/shutdown_x11() MetaDisplay calls
The lifetime of MetaX11Display is still tied to MetaDisplay, but these
calls will be useful when it's actually affordable to decouple those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
86de79cfc5 core: Untangle input focus management
In all places (including src/wayland) we tap into meta_x11_display* focus
API, which then calls meta_display* API. This relation is backwards, so
rework input focus management so it's the other way around.

We now have high-level meta_display_(un)set_input_focus functions, which
perform the backend-independent maintenance, and calls into the X11
functions where relevant. These functions are what callers should use.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
1d77641f0b x11: Separate X11 focus handling into MetaX11Display method
Updating the MetaWindow focus and the X Window focus is interrelated but
independent. Call one after the other in the places we handle window focus
changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
2f217109aa core: Relax requirement that MetaWindow shall have icon/mini-icon
We use a GtkIconTheme (thus icon-theme, thus xsettings, thus x11) just to
grab a "missing icon" icon to show in place. Relax this requirement that
surfaces for icon/mini-icon will be set, and just let it have NULL here.

It seems better to have the callers (presumably UI layers) aware of this
and set a proper icon by themselves, but AFAICS there is none in sight,
not even plain mutter seems to use MetaWindow::[mini-]icon. Probably
worth a future cleanup.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
5e0523cc8b x11: Move X11 calls to map/unmap a MetaWindow to MetaWindowX11
Add 2 vmethods so that MetaWindowX11 may handle the X11 calls itself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
dbe6e01e12 core: Separate checks for pointer barriers availability
If the check happens on --nested (X11 backend) while there is no X11
display we would get a crash. Since the barriers are non-effective on
nested, just take it out into a separate condition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
103c469cc9 core: Avoid grab transfer shenanigans with non-X11 backend
This explicit ungrab is made to ensure the other X11 display connection
is able to start an active grab immediately on the device without receiving
AlreadyGrabbed.

This is just relevant if there's two X11 display connections to transfer
grabs across, which may just happen on X11 windowing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
ef074ea510 x11: Add MetaX11Stack object
This object takes care of the X11 representation of the window stack,
namely the _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING root window
properties.

This code has been lifted from src/core/stack.c into src/x11 as it's
dependent on the X11 display availability. This also leaves MetaStack
squeaky clean of x11 specifics.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
39bac6eabd core: Turn MetaStack into a GObject
So we can have it emit signals and whatnot. Those are unused, yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
Carlos Garnacho
0200f4fcd9 x11: Move focus sentinel to MetaX11Display
This focus sentinel is a mechanism to avoid some X11-specific race
conditions in focus-follows-pointer, using X11 mechanisms. Move it to
MetaX11Display altogether.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
Jonas Ådahl
439afb3f19 window: Move all attached windows with parent
We'd break the loop for moving attached windows at the first window,
meaning we'd only ever move a single attached dialogs or popup if it was
the first window in the list. This doesn't work out well when there are
multiple popups open, so don't break out of the loop at all until all
windows are potentially moved.

This fixes an issue in gtk4 where one or more non-grabbing popups would
end up unattached if there were more than one and the parent window was
moved.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/592
2019-05-24 15:07:03 +00:00
Carlos Garnacho
b01edc22f3 backends/x11: Do not reload keymap on new keyboard notifications
XkbNewKeyboardNotify informs the client that there is a new keyboard
driving the VCK. It is essentially meant to notify that the keyboard
possibly has a different range of HW keycodes and/or a different
geometry.

But the translation of those keycodes remain the same, and we don't
do range checks or geometry checks (beyond using KEY_GRAVE as "key
under Esc", but that is hardly one). It seems we can avoid the
busywork that is releasing all our passive grabs, reloading the keymap
and regenerating the keycombos and restoring the passive grabs.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/398
2019-05-24 11:28:07 +02:00
Vasilis Liaskovitis
7719e33e68 wayland/pointer-constraints: Reject invalid lifetime
https://gitlab.gnome.org/GNOME/mutter/issues/425
2019-05-22 15:06:14 +00:00
Ignacio Casal Quinteiro
deef9960a4 Fix typo in RemoteDesktop dbus api
https://gitlab.gnome.org/GNOME/mutter/merge_requests/586
2019-05-22 16:21:57 +02:00
Jonas Ådahl
91ac64bb44 drm-buffer: Make the "types" actual types
There is no reason why we should have an internal type enum when we have
all the infrastructure to just use multiple GObject types. Also there
was no code sharing between the old "types", the only common API was
getting the framebuffer ID, so lets make that a vfunc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
Jonas Ådahl
ed56edc7ba drm-buffer: Remove useless soft-asserts
If triggered, many would result in crashes later anyway, so lets change
those to asserts. Some are simply useless, so remove those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
Jonas Ådahl
6eeba2434a drm-buffer: Clean up file descriptor variable naming
Nowhere else is it called 'drm_fd' so lets not get rid of this
inconsistency.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
Jonas Ådahl
7fb7b28cd6 kms-buffer: Rename to MetaDrmBuffer
MetaKms* will be a dedicated namespace, which MetaKmsBuffer doesn't fit
under.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
Jonas Ådahl
08aec58c22 kms-buffer: Clean up include order
https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
Benjamin Berg
52945f383d launcher: Explicitly look up object path for seat
If mutter is running as a systemd user service, then we cannot use the
magic "self" session for the ID lookup. For now we need to lookup the ID
explicitly. Eventually we can change to use the magic "auto" paths for
both the session and seat, but that will require systemd v243.

See also https://github.com/systemd/systemd/pull/12424#issuecomment-487962314

https://gitlab.gnome.org/GNOME/mutter/merge_requests/571
2019-05-21 16:43:09 +02:00
Daniel van Vugt
fecc57ddf0 renderer-native: Reference count front buffers
Start reference counting front buffers instead of assuming we know
their (scanout) lifetimes.

Functionally, this should not change anything.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/119
2019-05-21 15:49:42 +02:00
Marco Trevisan (Treviño)
358b67871f boxes: Assign input to output rect when there's no transformation
https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
Marco Trevisan (Treviño)
2b1acea1b0 place: Assign anchor rect using automatic copy
Set the offsets in different statements.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
Marco Trevisan (Treviño)
91aee3d5c4 monitor: Assign monitor layout directly by crtc rect
There's no need to repeat what gcc can do alone.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
Marco Trevisan (Treviño)
68fba458b3 boxes: Ensure we scale to a fully rounded rectangle
In order to scale a rectangle by a double value, we can reuse a ClutterRect
to do the scale computations in floating point math and then to convert it back
using the proper strategy that will take in account the subpixel compensation.

In this way we can be sure that the resulting rectangle can fully contain the
original scaled one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
Marco Trevisan (Treviño)
f7ecf3b618 meta: Remove meta_free_gslist_and_elements
This function was added for historic reasons, before that we had GSlist's
free_full function.

Since this can be now easily implemented with a function call and an explicit
GDestroyFunc, while no known dependency uses it let's move to use
g_slist_free_func instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/57
2019-05-15 14:49:56 -05:00
Marco Trevisan (Treviño)
7a17e236f7 Use free_full on GSList's instead of foreach + free
GList's used in legacy code were free'd using a g_slist_foreach + g_slist_free,
while we can just use g_slist_free_full as per GLib 2.28.

So replace code where we were using this legacy codepath.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/576
2019-05-15 14:49:56 -05:00
Marco Trevisan (Treviño)
df7d8e2cbf Use free_full on GList's instead of foreach + free
GList's used in legacy code were free'd using a g_list_foreach + g_list_free,
while we can just use g_list_free_full as per GLib 2.28.

So replace code where we were using this legacy codepath.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/576
2019-05-15 14:42:25 -05:00
Carlos Garnacho
9e82f9af25 x11: Do not warn on cancelled X11 selection sources
This shouldn't happen frequently, but is just a sign that the source is
being replaced by something else. Just keep the warning for other possible
error situations.

Also, plug the potential GError leak.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/598
2019-05-15 13:14:12 +00:00
Carlos Garnacho
dae2c1d420 backends/native: Add rt-scheduler experimental key to set RT scheduling
This is similar to a change in kwin:
https://blog.martin-graesslin.com/blog/2017/09/kwinwayland-goes-real-time/

If the experimental features key has "rt-scheduler", make it claim the lowest
of RT scheduler priorities, this will be both educated to other RT processes
and improves responsiveness wrt all other processes.

This can only work if mutter/gnome-shell process receives CAP_SYS_NICE
somehow, e.g.: "setcap CAP_SYS_NICE=+ep `which gnome-shell`"

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/921
https://gitlab.gnome.org/GNOME/mutter/merge_requests/460
2019-05-10 21:47:53 +00:00
Robert Mader
01d0316fd7 wayland/dnd-surface: Propagate commit to parent class
We need to call the underlying actor-surface so the actor
state is synced, otherwise surface state like the scale factor
does not get applied.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/550

https://gitlab.gnome.org/GNOME/mutter/merge_requests/537
2019-05-09 09:06:52 +00:00
Robert Mader
7e2a0ede16 wayland: Move check for present window out of the actor-surface class
All child classes of `MetaWaylandShellSurface` as well as
`MetaWaylandSurfaceRoleXWayland` should only sync their actor if
their toplevel surface has a window. Currently this check is done
in the actor-surface class, but not all surface classes have a
toplevel window, e.g. dnd-surfaces.
Move the check to the right places.

For subsurfaces this assumes that the subsurface is not the child of
a window-less surface (like, as stated above, e.g. a dnd-surface).
If we want to support subsurfaces of window-less surfaces in the future
we have to extend the check here.
But as this is not a regression, ignore this case for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/537
2019-05-09 09:06:52 +00:00
Daniel van Vugt
7738b5c00b core/window: Fix copy/paste error in size-changed docs
It appears it was copied from MetaWindow::position-changed and pasted
for MetaWindow::size-changed, without updating all the words.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/567
2019-05-08 09:28:16 +00:00
Carlos Garnacho
bf8bc65cc9 core: Check environment variables before giving to GAppLaunchContext
Depending on the type of session, one or the other might be NULL, which
is not meant to be handled by these functions. Check for both DISPLAY
envvars before setting them on the GAppLaunchContext.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/586
2019-05-06 17:27:56 +02:00
Carlos Garnacho
ae6d9e35bd backends: Fallback to builtin panel for devices where all heuristics fail
This is 1) relatively likely as not all touchscreens are nice enough to
report a device size that will help us here and 2) Better than nothing if
everything fails anyway, as it will break on multi-monitor and non-default
monitor rotations.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/581
2019-05-03 15:01:47 +00:00
Jonas Dreßler
0d50a37091 display: Fix a possible bug in meta_display_sync_wayland_focus
The check for the focus xwindow is called, but not used. Fix that by
renaming the variable to reflect better what it does and actually using
the return value of the check.

This was the original intention of the author in commit
05899596d1 and got broken in commit
8e7e1eeef5.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/535
2019-05-02 23:54:22 +00:00
Jonas Ådahl
1ca0fdc928 idle-monitor: Postpone dispatching of idle timeout if not ready
If we update the ready time while the source is already in the
to-dispatch list, changing the ready time doesn't have any effect, and
the source will still be dispatched. This could cause incorrect idle
watch firing causing the power management plugin in
gnome-settings-daemon to sometimes turn off monitors due to it believing
the user had been idle for some time, while in fact, they just logged
back in.

Fix this by not actually dispatching the idle timeout if the ready time
is in the future when actually dispatching.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/543
2019-05-02 23:46:43 +00:00
Jonas Ådahl
23a8ea2821 idle-monitor: Use G_SOURCE_CONTINUE instead of TRUE
Returning TRUE is confusing, as it doesn't carry any relevant meaning.
Use G_SOURCE_CONTINUE to make it clearer that the source is here to
stay.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/543
2019-05-02 23:46:43 +00:00
Marco Trevisan (Treviño)
ee4bb2240b workspace: Activate a window also if it's already in workspace
meta_workspace_activate_with_focus is supposed to focus the passed window after
switching the workspace.

However if the passed workspace is already the active one, we just return
without activating the window.
So fix this calling meta_window_activate on the foucs_this window if that is
valid.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/562
2019-05-02 17:33:17 -05:00
Marco Trevisan (Treviño)
63c40a9711 meson: Define srcdir and builddir using meson functions
No need to redefine paths starting from top src/build dirs, as meson can give us
this information for free using its functions.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
5d1a87d355 meson: Add option flags to control test suites building
Now the `tests` meson option controls weather we should build all the test suites
while `core_tests` controls mutter tests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
a934fa07b8 tests: Use suites for test cases
They allows to filter tests better and so we can just launch tests with:
  meson test --suite [core|cogl|clutter] [single-test-name]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
c6d1cf4af4 tests: Add single stacking tests with suite
Don't launch the stacking tests in one single shot, to allow better debugging
and being able to launch just one single test using meson test.

Those tests can now be all launched with:
  meson test --suite stacking [single-test-name]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
8dbe4210b4 tests: Add missing stacking tests
List all .metatest files that were added only to autotools while they are
missing since the meson port.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Carlos Garnacho
02c99524bf Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public
This exposes the base so that we can reimplement StClipboard on top. Some
gtk-docs have been added for documentation and introspection purposes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
Carlos Garnacho
17d00d49d4 wayland: Reduce MetaXWaylandSelection to just DnD
All the actual selection management functionality is superseded by
MetaSelection. Reduce it to just handling the XDND messaging and leave
selections to MetaSelection.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
Carlos Garnacho
634f512bb0 wayland: Integrate with MetaSelection
Make MetaWaylandDataDevice use MetaSelection and MetaSelectionSource to
handle primary/clipboard/dnd.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
Carlos Garnacho
5c009c20ab core: Add clipboard manager
This is a simple clipboard manager implementation on top of MetaSelection.
It will inspect the clipboard content for UTF-8 text and image data whenever
any other selection source claims ownership, and claim it for itself
whenever the clipboard goes unowned.

The stored text has a maximum size of 4MB and images 200MB, to prevent the
compositor from allocating indefinite amounts of memory.

This is not quite a X11 clipboard manager, but also works there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
Carlos Garnacho
535ce00abb core: Add memory-based selection source
This is a simple implementation of a MetaSelectionSource, able to hold a
single mimetype, provided as GBytes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
Carlos Garnacho
37144f0609 x11: Add X11 selection management
This code takes care of both setting up X11 selection sources whenever
X11 clients claim selection ownership, and claiming selection ownership
on a mutter X11 window whenever other selection sources claim ownership.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
Carlos Garnacho
ab76576340 core: Set up MetaSelection on MetaDisplay
https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
Carlos Garnacho
09aa82db49 wayland: Add wayland MetaSelectionSource implementation
This object represents a Wayland selection owner. In order to invert the
FD direction (we hand an output fd, but want an inpu fd), create an
intermediate pipe so we can then create a GInputStream on top of it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
Carlos Garnacho
c95db7c542 x11: Add X11 MetaSelectionSource implementation
This object represents the selection ownership from an X11 client. The
list of supported targets is queried upfront, so its initialization is
asynchronous. Requests to read contents from the selection will hand
a MetaX11SelectionInputStream.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
Carlos Garnacho
a984622cd1 core: Add MetaSelection and MetaSelectionSource
MetaSelectionSource represents a primary/clipboard/dnd selection owner,
it is an abstract type so wayland/x11/etc implementations can be provided.
These 3 selections are managed by the MetaSelection object, the current
selection owners will be set there, and signals will be emitted so the
previous selection owner can clean itself up.

The actual data transfer is done through the meta_selection_transfer_async()
call, which will take a GOutputStream and create a corresponding
GInputStream from the MetaSelectionSource in order to splice them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
Carlos Garnacho
156980eff9 x11: Add X11 selection input/output streams
These are rip off of GTK+ ones, with some adaptions to integrate them in
mutter event dispatching code and make them easier to use in future
commits.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 15:40:13 +02:00
Marco Trevisan (Treviño)
736cac43e9 compositor: Remove unused background_actor private reference
https://gitlab.gnome.org/GNOME/mutter/merge_requests/556
2019-04-30 16:15:42 -05:00
Marco Trevisan (Treviño)
3ba79961fe compositor: Disconnect from stage signals on destruction
From this point there's not any need for the compositor to listen to signals
so we can disconnect from the stage ones we are connected to.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/556
2019-04-30 16:15:42 -05:00
Marco Trevisan (Treviño)
7718e67f5c compositor: Destroy window actors list on destruction
When the compositor is destroyed we should cleanup the list of window actors we
created and destroy them.
Since all the actors are added to the window_group or top_window_group we can
just destroy these containers (together with the feedback_group), and simply
free the windows list.

This is particularly needed under X11 because before we destroy the display, we
might do some cleanups as detaching the surface pixmaps and freeing the damages
and if this happens at later point (for example when triggered by garbage
collector in gnome-shell), we might crash because the x11 dpy reference is
already gone.

Destroying the window actors instead, ensures we avoid any further call to X11
related functions and that we release the actors XServer resources.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/576
2019-04-30 16:15:42 -05:00
Ray Strode
502da973eb window: free close dialog before unmanaging window from compositor
When an application stops responding, the shell darkens its windows.

If a window from a not-responding application gets unmanaged
then the shell will currently throw an exception trying to retrieve
the now-dissociated window actor.

That leads to a "stuck window" ghost on screen and a traceback
in the log.

This commit addresses the problem by making sure the effect is cleaned
up before the actor is disocciated from its window.

https://gitlab.gnome.org/GNOME/mutter/issues/575
2019-04-29 14:06:12 -04:00
Olivier Fourdan
eccf7b105c input-settings: Use 0 initialized struct for kbd a11y
Make sure our keyboard accessibility settings structure is all zero
initialized, to avoid potential padding issues on some platform when
comparing settings.

Reported by Daniel van Vugt on IRC.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/552
2019-04-26 11:17:50 +02:00
Adam Jackson
1783ea5af1 cogl: Remove unused texture_type argument from cogl_pipeline_set_layer_null_texture
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:24 -04:00
Adam Jackson
2a15e5f16a compositor: Drop ARB_texture_rectangle awareness
The GL/GLES versions we require imply full NPOT texture support, so the
ARB_texture_rectangle path will never be hit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:10 -04:00
Adam Jackson
fc09fa50a5 cogl: NPOT textures are always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:07 -04:00
Robert Mader
22884b0b00 shaped-texture: Use draw_rectangle() for full paints
This reverts a change introduced in edfe5cc3 to use `paint_clipped_rectangle()`
instead of `cogl_framebuffer_draw_rectangle()` for full paints as it
contained logic necessary for viewport src-rects. This is not longer the case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:43 +00:00
Robert Mader
d2415da0d4 shaped-texture: Use CoglMatrix for viewport src-rect
This brings the viewport src-rect code in line with how we handle
transforms, by applying a `CoglMatrix` to the pipeline instead of
changing the paint logic.
It also fixes not-y-inverted textures in combination with
transforms.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:43 +00:00
Robert Mader
96f7bf28f1 shaped-texture: Add checks to viewport reset functions
The set and reset functions are unconditionally called on every
commit. Add missings checks to the reset functions to bail out if
nothing changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:42 +00:00
Olivier Fourdan
d2ca5cc26b display: Fix inconsistent behavior with demand attention
When focus stealing prevention kicks in, mutter would set the demand
attention flag on the window.

Focus stealing prevention would also prevent the window from being
raised and focused, which is expected as its precisely its purpose.

Yet, when that occurs, the user expects the window which has just been
prevented from being focused to be the next one in the MRU list, so
that pressing [Alt]-[Tab] would raise and give focus to that window.

This works fine when the window is placed on the primary monitor, but
not when placed on another monitor, in which case the window which has
been denied focus is placed ahead of the MRU list and pressing
[Alt]-[Tab] would leave the focus on the current window.

This is because of a mechanism in `meta_display_get_tab_list()` which
forces the windows with the demand attention flag set to be placed first
in the MRU list when they're placed on a workspace different from the
current one.

But because workspaces apply only to the primary monitor (by default),
the windows placed on other outputs have their workspace set to `NULL`
which forces them ahead of the MRU list by mistake.

Fix this by using the appropriate `meta_window_located_on_workspace()
function to check if the window is on another workspace.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/523
2019-04-17 18:53:04 +02:00
Carlos Garnacho
3de6f7ebfe core: Emit MetaStartupNotification::changed on sequence completion
This way handlers that want to know the get_complete() status will be able
to do so without further delays.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/541
2019-04-17 18:42:09 +02:00
Carlos Garnacho
38ff01d6d0 core: Add MetaStartupSequence::complete signal
It was a vfunc so far, but we want things subscribing to it.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/541
2019-04-17 18:42:04 +02:00
Carlos Garnacho
40103d6f41 core: Account for completed sequences in feedback updates
The sequences may stay completed in the list (eg. pending a focus request),
it's then confusing to show the "wait" cursor icon until they are really
gone.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/541
2019-04-17 18:42:00 +02:00
Carlos Garnacho
ab7ef5f8bf core: Fix differing sequence timestamp precision expectations
Calculations were being done at places accounting on usec precision,
however those are still treated as having msec precision at places. Let's
consolidate for the latter since it requires less changes across the board
and usec precision doesn't buy us anything here.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/541
2019-04-17 18:41:13 +02:00
Olivier Fourdan
2c1a951b6e wayland/output: Set user data of xdg_output resource
mutter would randomly crash in `send_xdg_output_events()` when changing
the fractional scaling:

  wl_resource_post_event ()
  zxdg_output_v1_send_logical_size ()
  send_xdg_output_events ()
  wayland_output_update_for_output ()
  meta_wayland_compositor_update_outputs ()
  on_monitors_changed ()
  g_closure_invoke ()
  signal_emit_unlocked_R ()
  g_signal_emit_valist ()
  _signal_emit ()
  meta_monitor_manager_notify_monitors_changed ()
  meta_monitor_manager_rebuild ()

This is because the xdg-output resource got freed but wasn't removed
from the list of resources.

Fix this by setting the user data of the xdg-output resource to the
corresponding `MetaWaylandOutput` so that the xdg-output resource
destructor can remove it from the list of resources.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/538
2019-04-15 15:41:47 +02:00
Jonas Dreßler
6ec330ccfa keybindings: Stop keybinding if a touch happens while Super is pressed
We use the combination of pressing Super and clicking+moving the mouse
to drag windows around and we also support pressing Super and using the
touchscreen to drag windows.

Since we don't want to show the overview when the Super key was used to
initiate a window drag, prevent showing the overview in case a
TOUCH_BEGIN or TOUCH_END event happened during the key was pressed.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/228

https://gitlab.gnome.org/GNOME/mutter/merge_requests/495
2019-04-15 11:10:47 +00:00
Pekka Paalanen
28419cdedf renderer/native: Check primary GPU supports EGL
Since "renderer/native: make EGL initialization failure not fatal" it is
possible, under specific failure conditions, to end up with a primary GPU whose
EGL initialization failed. That cannot work.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/521
2019-04-11 15:11:41 +03:00
Pekka Paalanen
3b46a8cd70 renderer/native: Make EGL initialization failure not fatal
The failure to initialize EGL does not necessarily mean the KMS device cannot
be used. The device could still be used as a "secondary GPU" with the CPU copy
mode.

If meta_renderer_native_create_renderer_gpu_data () fails,
meta_renderer_native_get_gpu_data () will return NULL, which may cause crashes.
This patch removes most of the failures, but does not fix the NULL dereferences
that will still happen if creating gpu data fails.

This patch reorders create_renderer_gpu_data_gbm () so that it fails hard only
if GBM device cannot be created, and otherwise always returns an initialized
gpu data structure. Users of the gpu data structure are responsible for
checking egl_display validity.

The GBM device creation failure is a hard failure because presumably GBM is
necessary for cursors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/542
https://gitlab.gnome.org/GNOME/mutter/merge_requests/521
2019-04-11 15:11:41 +03:00
Jonas Ådahl
b2d0184c6e renderer-native: Freeze frames while retrying to page flip
We're currently always waiting for unfinished page flips before flipping
again. This is awkward when we are in an asynchronous retry-page-flip
loop, as we can synchronously wait for any KMS page flip event.

To avoid ending up with such situations, just freeze the frame clock
while we're retrying, then thaw it when we succeded.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:50:00 +00:00
Jonas Ådahl
808a75b231 renderer-native: Add helper to get backend from renderer
https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
88e4ff7409 backend: Add API to freeze/thaw frame clock
It's just a thin wrapper around the ClutterStage API, with the intention
to hide the awkward nest of interdependent backends.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
3cc3b7526c renderer-native: Fake page flipping slower when power saving
We rely on the frame clock to compress input events, thus if the frame
clock stops, input events are not dispatched. At the same time, there
is no reason to redraw at a full frame rate, as nothing will be
presented anyway, so slow down to 10Hz (compared to the most common
60Hz). Note that we'll only actually reach 10Hz if there is an active
animation being displayed, which won't happen e.g. if there is a screen
shield in the way.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
53b59d8bff renderer-native: Fake page flipped if power saving when retrying
When we're in a page-flip retry loop due to the FIFO being full
(drmModePageFlip() failing with EBUSY), we should not continue to try
when starting to power save, as that means we're blocking new frames,
which itself blocks input events due to them being compressed using the
frame clock.

We'd also hit an assert assuming we only try to page flip when not power
saving.

Thus, fake we flipped if we ended up reaching a power saving state while
retrying.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/509

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
40e7e5d356 renderer-native: Fix page flip retry timeout calculation
It tried to add a (implicitly casted) float to a uint64_t, and due to
floating point precision issues resulted in timestamps intended to be
in the future to actually be in the past. Fix this by first casting the
delay to an uint64_t, then add it to the time stamp.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
4cae9b5b11 monitor-manager: Clean up DPMS state tracking
DPMS is configured from a bit all over the place: via D-Bus, via X11 and
when reading the current KMS state. Each of these places did it slightly
differently, directly poking at the field in MetaMonitorManager.

To make things a bit more managable, move the field into a new
MetaMonitorManagerPrivate, and add helpers to get and set the current
value. Prior to this, there were for example situations where the DPMS
setting was changed, but without signal listeners being notified about
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
2019-04-02 13:49:59 +00:00
Jonas Ådahl
5199c7834d backends/native: Move underscan setting to MetaOutputKms
The 'underscan' property is a drm connector property, not a CRTC
property, so we would never find it. We also didn't advertise support
for the feature, meaning even if it was on the CRTC, Settings wouldn't
know about it.

Fix this by moving the property to where it belongs: in MetaOutputKms,
and properly advertise support for it if the property is found.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/507
2019-04-02 09:38:45 +00:00
Daniel van Vugt
9d49e8abd0 launch-context: Swap reversed timestamp/workspace
The parameters had been mixed up for X11 sessions.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/505
2019-04-01 10:34:51 +00:00
Jan Alexander Steffens (heftig)
28e0a7bfb5
wayland/xdg-shell: Correct window menu position in logical layout mode
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/527
2019-03-26 22:41:57 +01:00
Daniel van Vugt
d15e11bfe7 background: Shrink wallpaper using LINEAR_MIPMAP_LINEAR
Commit 8e9184b6 added filtering to avoid image jaggies when downscaling
but used `LINEAR_MIPMAP_NEAREST`. In some situations this could lead to
GL choosing a single lower resolution mipmap and then upscaling it, hence
slightly blurry.

We don't want to revert that change since it avoids aliasing jaggies, so
let's use `LINEAR_MIPMAP_LINEAR` instead. This provides the highest quality
filtering that GL can do and avoids the situation of GL using a single
mipmap that's lower resolution than the screen. Now it will blend that one
with the next mipmap which is higher resolution than the screen. This still
avoids jaggies but also maintains 1px resolution.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1105
https://gitlab.gnome.org/GNOME/mutter/merge_requests/505
2019-03-26 11:38:52 +08:00
Jonas Ådahl
1eabaf12da renderer/native: Make the EGLStreams operate in mailbox mode
This means eglSwapBuffers() wont dead lock if there is an old buffer pending
page flip. This could happen after e.g. mode changes or for other reasons.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/485
2019-03-25 17:29:25 +00:00
Jonas Ådahl
fe86694ddd renderer/native: Make EGLStream page flip errors non-fatal
Just continue rendering; we don't care if we were busy once, as it'll most
likely work when we flip the next time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/485
2019-03-25 17:29:25 +00:00
Carlos Garnacho
a1969c98cd wayland: Defer text_input.done on an idle
With the right priority so we hopefully group events properly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/499
https://gitlab.gnome.org/GNOME/gtk/issues/1365
2019-03-25 14:55:12 +00:00
Carlos Garnacho
9843e21fff backends: Use udev to determine absolute input devices' size
Use the ID_INPUT_WIDTH_MM/ID_INPUT_HEIGHT_MM udev properties to figure out
absolute input devices' physical size. This works across both backends, and
requires less moving pieces to have it get the right results.

Concretely, fixes size detection on X11/libinput, which makes touchscreen
mapping go wrong.

https://gitlab.gnome.org/GNOME/mutter/issues/514
2019-03-25 14:08:40 +01:00
Carlos Garnacho
f0b9654deb core: Remove startup sequences after timeout
The complete/remove semantics were split to cater for presenting windows,
so we must now separately do both here.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/501
2019-03-18 18:06:01 +00:00
Florian Müllner
a1e325f749 build: Don't use absolute paths with subdir keyword
Meson 0.50.0 made passing an absolute path to install_headers()'
subdir keyword a fatal error. This means we have to track both
relative (to includedir) paths for header subdirs and absolute
paths for generated headers now :-(

https://gitlab.gnome.org/GNOME/mutter/merge_requests/492
2019-03-18 12:37:14 +00:00
Jonas Ådahl
00b4556051 constraints: Don't use intersection when sliding with custom rule
If an intersection is empty, the (x, y) coordinates are undefined, so
just use the work area and in-progress constrained window rect when
sliding according to the SLIDE_X or SLIDE_Y custom placement rule.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
86b5247770 constraints: Only get parent rect once when placement rule constraining
We got it in a switch case, then again when finalizing. Only get it once
instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
23f31e518e constraints: Only readjust placement constraint when not checking
When check_only is TRUE, the constraint should not be applied, just
checked. We failed to comply here when a placed transient window was
to be moved together with its parent, updating the window position
directly even if check_only was TRUE.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
f580b28a27 window: Replace placement constrained bool with state
Using an actual state instead of a boolean makes it clearer it's a state
that changes. Eventually we might add more state too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
b4f1569640 window: Unmanage rule placed window if ending up outside of parent
If a client maps a persistent popup with a placement rule, then resizes
the parent window so that the popup ends up outside of the parent,
unmanage the popup and log a warning about the client being buggy.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
f2d7165a52 window: Don't try to move hidden attached windows
When a parent window is moved, attached windows (attached modal dialogs
or popups) is moved with it. This is problematic when such a window
hasn't been shown yet (e.g. a popup that has been configured but not
shown), as it'll mean we try to constrain an empty window. Avoid this
issue by not trying to auto-move empty windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
1bd3c13fe1 wayland/xdg-shell: Split out popup placement out of setup finish
Makes the function slightly more comprehensible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
5d1eccfb6f boxes: Fix spelling in API
Change adjecent to adjacent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Erik Kurzinger
056c45fe0c wayland/buffer: Try realizing EGLStream before EGLImage buffer
Currently, it is assumed that if querying the EGL_TEXTURE_FORMAT of a
Wayland buffer succeeds it is an EGLImage. However, this assumption will no
longer hold on upcoming versions of the NVIDIA EGL Wayland driver which
will include support for querying this attribute for EGLStream buffers as
well. Hence, we need to check if buffers are EGLStreams first.

Fixes #488
https://gitlab.gnome.org/GNOME/mutter/merge_requests/477
2019-03-14 14:39:52 -07:00
Pablo Barciela
318164779c boxes: Actually check for rectangle containment
Fixes condition duplicated:

          /* If a contains b, just remove b */
          if (meta_rectangle_contains_rect (a, b))
            {
              delete_me = other;
            }
          /* If b contains a, just remove a */
          else if (meta_rectangle_contains_rect (a, b))
            {
              delete_me = compare;
            }

Closes https://gitlab.gnome.org/GNOME/mutter/issues/480
2019-03-12 05:03:53 +01:00
Florian Müllner
7bd33e7b00 frame: Remove flashing support
It's now unused.

https://gitlab.gnome.org/GNOME/mutter/issues/491
2019-03-12 00:27:07 +00:00
Florian Müllner
f8d62da2dc bell: Always flash window instead of frame
Traditionally visual alerts were implemented by flashing the focus
window's frame. As that only works for windows that we decorate,
flashing the whole window was added as a fallback for client-decorated
windows.

However that introduces some confusing inconsistency, better to just
always flash the entire window.

https://gitlab.gnome.org/GNOME/mutter/issues/491
2019-03-12 00:27:07 +00:00
Marco Trevisan (Treviño)
303e02bdac monitor: Fix indentation style on foreach functions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/488
2019-03-12 00:15:43 +00:00
Marco Trevisan (Treviño)
e2525f286d monitor: Fix indentation style on calculate_crtc_pos and friends
https://gitlab.gnome.org/GNOME/mutter/merge_requests/488
2019-03-12 00:15:43 +00:00
Marco Trevisan (Treviño)
9b8510ac56 monitor: Fix indentation style on calculate_supported_scales and friends
https://gitlab.gnome.org/GNOME/mutter/merge_requests/488
2019-03-12 00:15:42 +00:00