1
0
Fork 0
Commit graph

8362 commits

Author SHA1 Message Date
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
Florian Müllner
8a87e87a05 shadow-factory: Update shadow of attached modals
When commit 91c6a144da synced shadows with Adwaita, it removed the
shadow completely from attached modal dialogs. However Adwaita uses
the same shadow for all dialogs (modal or not), so do the same here.

https://gitlab.gnome.org/GNOME/mutter/issues/490
2019-03-12 00:05:42 +00:00
Florian Müllner
32504ae917 meta-monitor: Remove useless variable
Since commit f76b3edf9c, the variable is never set to TRUE and
we can simply remove it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/475
2019-03-11 23:44:46 +00:00
Benjamin Berg
80ceeb2848 keybindings: Fix theoretical memory leak while ungrabbing
In the unlikely event that one tries to ungrab an action which does not
exist, a small leak could occur. Fix this by using g_autofree.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/478
2019-03-11 23:39:25 +00:00
Florian Müllner
1574099449 prefs: Change default of show-fallback-app-menu
The app menu always was a GNOME-only thing, so after it was removed this
cycle, assuming that it is not displayed by the environment is a better
default.

https://gitlab.gnome.org/GNOME/mutter/issues/493
2019-03-11 23:30:10 +00:00
Andrea Azzarone
8856a396fd sound-player: Don't deadlock in finish_cb
The function finish_cb can be called as a result of a call to ca_context_cancel
in cancelled_cb. This will result in a deadlock because, as per documentation,
g_cancellable_disconnect cannot be called inside the cancellable handler.

It is possible to detect if the call to finish_cb is caused by ca_context_cancel
checking if error_code == CA_ERROR_CANCELED. To avoid the deadlock we should
call g_signal_handler_disconnect instead g_cancellable_disconnect if this is the
case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/474
2019-03-05 12:07:41 +00:00
Florian Müllner
7abceb434d x11-display: Split out restoring of active workspace
Splitting out the X11 display initialization from display_open() broke
restoring the previously active workspace in two ways:

 - when dynamic workspaces are used, the old workspaces haven't
   been restored yet, so we stay on the first workspace

 - when static workspaces are used, the code tries to access
   the compositor that hasn't been initialized yet, resulting
   in a segfault

Fix both those issues by splitting out restoring of the active workspace.

https://gitlab.gnome.org/GNOME/mutter/issues/479
2019-03-04 19:42:00 +00:00
Carlos Garnacho
3e472faf5c wayland: Minor refactor
We use the input_method on both branches, but only check for its existence
when enabling the text_input. The case of focusing out shouldn't happen in
practice as we couldn't have focused in ever before, but still make the
check one level above so it's clearer that the text_input's IM focus cannot
be enabled without an IM implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/432
2019-03-04 18:17:08 +00:00
Carlos Garnacho
eabb789381 wayland: Only enable OSK if receiving .enable when already active
Enable the OSK if receiving .enable consecutively (i.e. the
ClutterInputFocus was already focused). We specifically want to avoid
enabling the panel just because of focus changes within a surface (where
the .disable request across focus change would previously unfocus the
ClutterInputFocus). Prior state should be preserved if possible in that
situation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/432
2019-03-04 18:17:08 +00:00
Carlos Garnacho
3fd0e23ed9 clutter: Make ClutterInputFocus API to set panel state explicit
Before we just had API to toggle the OSK panel state. Make this API
generic so the upper layers may set the state as they see fit.
All callers have been updated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/432
2019-03-04 18:17:08 +00:00
Marco Trevisan (Treviño)
8b09542fd9 boxes: Crop rectangle converting to integer with grow strategy
Reuse meta_rectangle_from_clutter_rect with growing strategy to properly cast
the clutter floating rectangle to integer MetaRectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 19:42:08 +01:00
Marco Trevisan (Treviño)
a8c972cd6b boxes: Add function to create a rectangle from floating clutter rect
Meta rectangles are integer based while clutter works in floating coordinates,
so when converting to integers we need a strategy.

Implement the shrink strategy by ceiling the coordinates and flooring the width,
and the grow strategy reusing clutter facility for this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 19:42:07 +01:00
Marco Trevisan (Treviño)
ceb4fe2151 wayland-tablet-tool: Downscale the sprite texture in FB mode
When using scaled framebuffer we need to downscale the texture size in order
to get the cursor properly drawn at its real size and in good quality.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 17:46:49 +00:00
Jonas Ådahl
ad5555bf42 clutter: Add API to get the resource scale of an actor
A clutter actor might be painted on a stage view with a view scale
other than 1. In this case, to show the content in full resolution, the
actor must use a higher resolution resource (e.g. texture), which will
be down scaled to the stage coordinate space, then scaled up again to
the stage view framebuffer scale.

Use a 'resource-scale' property to save information and notify when it
changes.

The resource scale is the ceiled value of the highest stage view scale a
actor is visible on. The value is ceiled because using a higher
resolution resource consistently results in better output quality. One
reason for this is that rendering is often not perfectly pixel aligned,
meaning even if we load a resource with a suitable size, due to us still
scaling ever so slightly, the quality is affected. Using a higher
resolution resource avoids this problem.

For situations inside clutter where the actual maximum view scale is
needed, a function _clutter_actor_get_real_resource_scale() is provided,
which returns the non-ceiled value.

Make sure we ignore resource scale computation requests during size
requests or allocation while ensure we've proper resource-scale on
pre-paint.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
3512647419 background: Use monitor scale to generate the texture at real monitor size
We need to use pixel size of the monitor in order to generate a valid
texture with full quality for current monitor

In spanned case the background should cover all the differently scaled monitors
thus we scale the texture up to the maximum scaling level and then we resample
it drawing only each side in the monitor it should occupy using the proper
scaling level.

In wallpaper mode (or color mode) for example we don't need to scale the area,
also the texture size we return should be unscaled, not to confuse
MetaBackgroundActor making it use more space than needed.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
42953a50bb stage: Queue redraw previous Rect only if it has changed
No need to queue redraw the same area multiple times, so we can avoid the
computation involved with it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
f4c2b69934 stage: Clamp to pixel the redraw clip taking care of the floored coords
When we floor the quad coordinates then we've also to enlarge the quad by the
difference between the floored value and the actual coordinate, otherwise
we'd end up in a smaller quad.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
d7ec5d3022 stage: Add utility function to queue draw a ClutterRect
Remove duplicated code to clamp to pixel

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
7442de81bb display: Add meta_display_get_monitor_scale
This will return the monitor scaling for the requested logical screen

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2019-03-01 17:46:49 +00:00
Marco Trevisan (Treviño)
f76b3edf9c monitor: Define scale_steps globally
No need to compute the scale steps multiple times, since
it's just a defined value, so let's use a define for this
avoiding to pass around.

https://bugzilla.gnome.org/show_bug.cgi?id=782742
2019-03-01 17:46:49 +00:00
Jonas Dreßler
8d9a5e3c7e wayland/touch: Remove undelivered touches earlier
When the touch_down event was not delivered to Wayland clients, there's
no point in keeping the touchpoint in our list, so remove it early
inside update() instead of removing it after the touch ended.

This fixes a crash inside touch_handle_surface_destroy() where the
assertion to make sure the surface is removed fails because the
touch_count of the surface never reached 0. This in turn happened
because a new sequence was added, while a (already ended one) wasn't
removed from the touch->touches list before. This caused the touch
counter to get incremented by 1 while no new sequence was added to the
list (because Clutter reuses sequence IDs, the old sequence is equal to
the new one, i.e. the new sequence already is present in the list).

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/426
2019-02-28 09:52:23 +00:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Niels De Graef
b67394dcd1 clutter: StageWindow: Use G_DECLARE_INTERFACE()
It cuts away a bit of the GObject boilerplate, gives us support for
`g_autoptr`, and removes the typedef hack inside clutter-stage-window.c.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/380
2019-02-27 16:44:24 +00:00
Jonas Ådahl
9e75ce2ad7 monitor-config-store: Read system wide config files
Before introducing the new config store, the old monitor configuration
system read system wide monitor configuration files. Add back that
feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/253
2019-02-26 21:04:27 +00:00
Jonas Ådahl
7c807c6e2a org.gnome.Mutter.ScreenCast: Document what was added in API version 2
RecordWindow and the cursor-mode property are only available if the
advertised version is at least 2.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
9a20271f90 screen-cast-window-stream: Add support for cursor modes
Make the RecordWindow method also understand the 'cursor-mode' property.
For 'embedded' the cursor is drawn onto the pixel buffer using cairo,
otherwise it works similarly to how RecordMonitor deals with it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
1760a6e560 screen-cast: Bump API version to 2
https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
8c2b805d88 screen-cast-src: Add helper to draw cursor sprite into pixel buffer
It makes sure the cursor sprite is correctly scaled and positioned in
stream coordinate space.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
2f01418d45 screen-cast-window: Add API to check if content has damage
https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
a76107a19f screen-cast-window: Add API to transform cursor state
To be used to translate absolute cursor positions to relative positions,
as well as to determine whether a cursor sprite is inside the stream or
not. It also helps calculating the scale the cursor sprite needs to be
scaled with to be in stream coordinate space.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
c80ba819e7 screen-cast-window-src: Keep a screen cast window instead of an actor
Practically it's the same object, but ideally, we should not deal
with "actors" anywhere here.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
14c6a347c1 screen-cast-window-src: Rename painted callback to after_paint
We'll add a before_paint soon, so better have the names somewhat match.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
11bd847896 screen-cast-window-stream: Don't set the position property
It was not meant to be set for window streams, and was set to (0, 0)
anyway. This removes the corresponding MetaScreenCastWindow API, as it's
not needed anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
870f38542d screen-cast-window-stream: Set the size property to the logical size
As the stream size is the logical monitor size multiplied with the ceil
of the logical monitor scale, the corresponding logical size, which is
what should be passed via the size property on the D-Bus object, should
be the logical monitor size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
c22edeff1f screen-cast-window-stream: Use initable to initialize
Move the initialization from _new() to an initable implementation. This
will allow us to initialize fields before MetaScreenCastStream
initializes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
183de60d91 screen-cast-src: Move back MetaSpaType to C file
It's not needed by the monitor source anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
176b508029 screen-cast-src: Change offscreen cursor helper to take a uint8_t *
Instead of a `uint32_t *`. Eventually we shouldn't assume pixels are
always 32 bit, and this gets rid of some casts while at it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
9be189daa7 screen-cast: Move cursor metadata setting to generic source
Make the monitor implementation do things strictly related to its own
source type, leaving the Spa related logic and cursor read back in the
generic layer, later to be reused by the window source type
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Carlos Garnacho
8a9a78ec8a wayland: Check whether Xwayland window had a prior surface in generic code
Since commit 8df2a1452c (As pointed out by Robert Mader) we just happened
do this check when doing the first lookup for a Wayland surface for a
XWayland window, when we are later notifying upon surface creation we just
set the relation with no further checks.

The cases pointed out in the comment (eg. window changing decoration) might
presumably happen in a quick enough sequence that we have two scheduled
associations on the fly, so move this check to the more generic
meta_xwayland_associate_window_with_surface() which is called on both
immediate and delayed paths.

https://gitlab.gnome.org/GNOME/mutter/issues/361
2019-02-25 17:53:52 +00:00
Robert Mader
803ffc19a4 shaped-texture: Clean-up deprecated NPOT check
There are most likely no GNOME users left still using hardware that
does not support NPOT textures. Further more, they would crash much
earlier and never hit this code-path. So remove the unnecessary check
here.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/447
2019-02-25 17:51:48 +01:00
Robert Mader
ddd2ce3a88 wayland/buffer: Fall back to CoglTexture2DSliced
XWayland creates buffers of the combined size of all connected displays.
This can, especially on older but still in use hardware, exceed the limits
of the GPU.

If that is the case, use `CoglTexture2DSliced` instead of `CoglTexture2D`

https://gitlab.gnome.org/GNOME/mutter/merge_requests/447
2019-02-25 17:51:44 +01:00
Jonas Ådahl
979e689278 renderer/native: Retry page flip after one vsync if EBUSY
We might fail to page flip a new buffer, often after resuming, due to
the FIFO being full. Prior to this commit, we handled this by switching
over to plain mode setting instead of page flipping. This is bad because
we won't be synchronized to the refresh rate anymore, but just the
clock.

Instead, deal with this by trying again until the FIFO is no longer
full. Do this on a v-sync based interval, until it works.

This also changes the error handling code for drivers not supporting
page flipping to rely on them returning -EINVAL. The handling is moved
from pretending a page flip working to explicit mode setting in
meta-renderer-native.c.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/460
2019-02-25 15:48:29 +00:00
Jonas Ådahl
2c1ab8b3cc renderer/native: Remove legacy non-stage-view code
A renderer view will, under the native backend, since long ago always
have a logical monitor associated with it, so remove the code handling
the legacy non-stage view case.

https://gitlab.gnome.org/GNOME/mutter/issues/460
2019-02-25 15:48:29 +00:00
Jonas Ådahl
252e64a0ea wayland: Move surface texture ownership to MetaWaylandSurface
Prior to this commit, MetaWaylandSurface held a reference to
MetaWaylandBuffer, who owned the texture drawn by the surface. When
switching buffer, the texture change with it.

This is problematic when dealing with SHM buffer damage management, as
when having one texture per buffer, damaged regions uploaded to one,
will not follow along to the next one attached. It also wasted GPU
memory as there would be one texture per buffer, instead of one one
texture per surface.

Instead, move the texture ownership to MetaWaylandSurface, and have the
SHM buffer damage management update the surface texture. This ensures
damage is processed properly, and that we won't end up with stale
texture content when doing partial texture uploads. If the same SHM
buffer is attached to multiple surfaces, each surface will get their own
copy, and damage is tracked and uploaded separately.

Non-SHM types of buffers still has their own texture reference, as the
texture is just a representation of the GPU memory associated with the
buffer. When such a buffer is attached to a surface, instead the surface
just gets a reference to that texture, instead of a separately allocated
one.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Jonas Ådahl
d2f1edd6c6 wayland/surface: Process damage also for non-actor surfaces
The texture still needs to be updated with damaged content.

https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Jonas Ådahl
944a4763f6 cursor-renderer/native: Clear active CRTC gbm_bo when destroyed
When we freed the cursor GPU state including the gbm_bo objects attached
to it, we didn't unset the cursor renderer private of the CRTCs of the
associated GPU. This means that HW cursor invalidation could potentially
break if a new gbm_bo happened to be allocated at the same memory
address as the previous one.

To avoid this, iterate through the CRTCs of the GPU of which the cursor
data is freed, and unset the cursor renderer private if it was the one
destroyed.

https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Jonas Ådahl
22a296f971 wayland/dma-buf: Don't use API meant for MetaWaylandSurface internally
What was actually done when calling meta_wayland_buffer_attach() was
that the texture was realized, so just call the function
`meta_wayland_dma_buf_realize_texture()` and call that.

This is in preparation to change how meta_wayland_buffer_attach() work.

https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Benjamin Berg
ef2153739c idle-monitor: Fix duplicate return value of ResetIdletime call
The signal handler must return TRUE as the invocation is already handled
by returning an error. Also update the error message a bit to clarify
that the API exists only for testing purposes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/457
2019-02-25 14:42:03 +00:00
Emilio Pozuelo Monfort
6975c8b424 monitor-config-manager: respect other outputs' CRTC
We should not only take the old CRTC for an output whenever
possible, but we should also assign one that is 'free', i.e.
one that another monitor (to be processed after this one)
isn't using, so that that monitor can use the same CRTC.

https://gitlab.gnome.org/GNOME/mutter/issues/373
2019-02-21 17:23:38 +02:00
Emilio Pozuelo Monfort
f4f823f238 monitor-config-manager: reuse old CRTC when possible
We shouldn't change an output's CRTC if we don't have to, as
that causes the output to go black.

This patch depends on
"monitor-unit-tests: initial crtcs in custom_lid_switch".

https://gitlab.gnome.org/GNOME/mutter/issues/373
2019-02-21 17:23:38 +02:00
Pekka Paalanen
1c67260bd4 monitor-unit-tests: initial crtcs in custom_lid_switch
This test forgot to specify the existing CRTC routings in the setup. For the
first output the default 0 was ok, now it is -1 to ensure that the code will
assign it correctly. For the second output the default 0 was incorrect, because
possible_crtcs does not include 0.  Now that CRTC is initialized to off
instead, because the second output is hotplugged later and running a CRTC
without an output does not make sense.

This fix will keep this test passing when a future patch attempts to preserve
existing CRTC routings. Assuming that any existing routing is valid, such
routing will be kept. In this test case the existing routing was illegal, it
should have been impossible, which then causes that future patch to fail the
test by assigning the wrong CRTC.

https://gitlab.gnome.org/GNOME/mutter/issues/373
2019-02-21 17:22:12 +02:00
Olivier Fourdan
79f90c147c MetaPluginManager: Don't return void value
The spec for `meta_plugin_manager_confirm_display_change()` is to return
`void`, no need to return a value there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/456
2019-02-21 09:31:15 +01:00
Andrea Azzarone
1c2e8fcf06 keybinding: Store flags in MetaKeyGrab
The external grab handler is shared across all external bindings and external
bindings have now different binding flags. For this reason, when rebuilding the
binding table there could be loss of information if we assign the bindings flags
of the external handler to all external bindings. Let's store the bindings flags
in MetaKeyGrab too and use this when rebuilding the binding table to avoid the
above issue.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/169
2019-02-20 14:36:24 +00:00
Andrea Azzarone
00ca387ec7 keybindings: Add flag param to grab_accelerator
Add a 'flags' parameters to meta_display_grab_accelerator. This will allow
e.g. gnome-settings-daemon (through the gnome-shell's GrabAccelerator API) to
create shorcuts that should descard auto-repeated key events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/169

Closes: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/issues/68
2019-02-20 14:36:24 +00:00
Olivier Fourdan
7bd668e6d0 window: Do not restore shortcuts on a NULL window
The "force restore shortcuts" being triggered by a key-combo, there is
no guarantee that the currently focused window is actually non-NULL in
which case we would crash.

Make sure there is a window currently focused before trying to restore
the shortcuts on that window.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/464
2019-02-18 11:23:59 +01:00
Olivier Fourdan
6fe46cac60 wayland/xdg-shell: Do not maximize if not possible
On X11, if a window cannot be maximized because its minimum size is
already larger than the output size, a request to maximize will be
ignored.

On Wayland, however, we would still honor the maximize request and
switch the window state to maximized, without actually moving the window
which leads to weird visual effects, as the window end up being
maximized in-place.

To avoid this, make sure the window has the maximize functionality
available prior to change its state in xdg-shell `set_maximized`
request.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/463
2019-02-15 09:40:44 +01:00
Niels De Graef
c3b9ef7bf5 gpu: Remove unimplemented ::get_kms_file_path()
https://gitlab.gnome.org/GNOME/mutter/merge_requests/444
2019-02-15 09:17:07 +01:00
Marco Trevisan (Treviño)
77fb0a0003 window-actor: Remove public declaration for get_x_window
meta_window_actor_get_x_window has been removed in commit 422648e2 but has not
been removed from the header for ages.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/439
2019-02-14 13:09:20 +00:00
Marco Trevisan (Treviño)
58d2a674c4 window: Return focusable ability looking at properties only
As per commit 43633d6b, we mark an unmanaging window as not focusable, while
this is true, it might cause not resetting the current focused window when
unmanaging it causing a crash.

Also this wouldn't allow to check if a window can be focused when unmanaging it,
so let's revert the previous behavior.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/462
2019-02-14 13:49:51 +01:00
Carlos Garnacho
9e2ed4104d wayland: Reset text-input state after commit
This was wrongly done just before enable, which is not right as
per the protocol. A side effect was that input purpose/hints were
eagerly reset before being applied, thus not properly honored,
noticed in the doing of emoji/numeric OSK panels.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/410
2019-02-14 11:23:07 +01:00
Marco Trevisan (Treviño)
f798912cbd window: Move can_ping to a function and implement in X11
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
3bf80a967c window-x11: Move delete_window to MetaWindowX11Private
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
6c3b0cfc36 window-x11: Move take_focus to MetaWindowX11Private
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
43633d6b2f window: Add is_focusable class method
Implement is_focusable for both x11 and wayland and just use this check
so that we can abstract things more and be less dependent on window backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Niels De Graef
b82fa2c610 meta-launcher: g_propagate_*_error takes ownership
This means we need to make sure we don't accidentally free the provided
source GError (which automatically happens with `g_autoptr`), so use
`g_steal_pointer()`.

This fixes an issue where, when launched in a bubblewrap environment
(such as the one provided by Buildstream), mutter would give the
following warning message:

```
mutter-WARNING **: 8:31:35:069: Can't initialize KMS backend: (null)
```

... which isn't that useful when trying to debug the actual issue.
2019-02-12 09:41:04 +01:00
Marco Trevisan (Treviño)
54fdd633fe input-mapper: Use g_auto to free a string array
https://gitlab.gnome.org/GNOME/mutter/merge_requests/435
2019-02-11 15:42:16 +01:00
Marco Trevisan (Treviño)
29ed84e921 input-mapper: Don't loop infinitely in EDID matching
Iterate over all the monitor product words to check for a partial matching on
EDID, otherwise we would hang inside an infinite while loop.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/459
2019-02-11 15:42:16 +01:00
Robert Mader
ba7af4f7d3 wayland/surface: Add support for wp_viewporter
This adds the required bits to wayland surfaces and ties them up
to the compositor parts.

It is based on and very similar in nature to buffer transforms.

From the specification:
> The global interface exposing surface cropping and scaling
> capabilities is used to instantiate an interface extension for a
> wl_surface object. This extended interface will then allow cropping
> and scaling the surface contents, effectively disconnecting the
> direct relationship between the buffer and the surface size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
2019-02-06 12:24:03 +00:00
Robert Mader
edfe5cc3b7 shaped-texture: Add support for viewports
This implements the viewporter protocol which offers a cropping and scaling
capabilities to wayland clients.

There are several use cases for this, for example video players and games,
both as a convenience function and as potential performance optimization when
paired with hardware overlays etc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
2019-02-06 12:24:02 +00:00
Robert Mader
07e65a6ef2 region-utils: Add API to crop and scale an integer region
https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
2019-02-06 12:24:02 +00:00
Robert Mader
d574cf59f1 boxes: Add API to crop and scale a MetaRectangle
https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
2019-02-06 12:24:02 +00:00
Jonas Ådahl
20c5e2525e monitor-manager: Provide proper contexts for translators
Two strings were both "%s %s", but with different meaning. Let
translators know the difference by providing context using C_().
2019-02-04 18:41:05 +01:00
Dariusz Gadomski
325fec31da monitor-manager: Add yet another wacky "physical dimension" 2019-02-04 17:41:36 +01:00
Dariusz Gadomski
cbb2a286f2 monitor-manager: Don't use wacky physical dimensions in display name 2019-02-04 17:41:36 +01:00
Dariusz Gadomski
e9eaa37401 monitor-manager: Use output name as display name in GetResources 2019-02-04 17:41:36 +01:00
Josh Triplett
b4ae6cdd62 Don't include potentially sensitive window titles in logs
For various error and warning messages, mutter includes a description of
the window, and that description includes a snippet of the title of the
window. Those snippets find their way into system logs, which then means
they can potentially find their way into bug reports and similar. Remove
the window title information to eliminate this potential privacy issue.
2019-02-03 06:32:14 +01:00
Florian Müllner
de76074336 ui: Remove fallback app menu
The app menu is in the process of being retired[0], and the shell
stopped displaying it while applications are in the process of
dropping it. It therefore doesn't make sense to always show a
fallback menu in server-side decorations, applications that still
set the menu can rely on GTK+'s own fallback instead.

[0] https://gitlab.gnome.org/GNOME/Initiatives/wikis/App-Menu-Retirement

https://gitlab.gnome.org/GNOME/gnome-shell/issues/624
2019-01-30 18:39:42 +00:00
Jonas Ådahl
2c5404532b screen-cast-stream: Don't broadcast PipeWireStreamAdded signal
The helper function from gdbus-codegen broadcasts the signal emission,
but we really only care about sending it to the specific peer that
created the session. Thus, only emit the signal to the particular peer
that owns the session.

https://bugzilla.gnome.org/show_bug.cgi?id=784199
2019-01-30 17:14:47 +00:00
Pekka Paalanen
6932b3cbb3 renderer/native: fix missing GPU copy egl ext error
If the extension is missing, the GPU copy path would not work. The code sets
the error, but forgets to return a failure. Fix this.

While adding the necessary return FALSE, also destroy the EGL context we just
created. Code refactoring shares the destroying code.

Found by reading code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/416
2019-01-30 15:57:30 +02:00
Emilio Pozuelo Monfort
b76bf20092 backends/native: Don't use software renderer for GPU copy
If the GPU copy path would use a software renderer, fall back to the CPU
copy path. The CPU copy path is possibly faster and avoids screen
corruption issues that were observed on an Intel Haswell desktop. The
corruption was likely due to texturing from an unfinished rendering or
memory caching issues.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/325
2019-01-30 15:12:57 +02:00
Pekka Paalanen
a62dbc6680 renderer/native: Debug print chosen secondary FB format
Print the pixel format chosen for an output on a secondary GPU for
debugging. Knowing the format can aid in debugging e.g. red/blue channel
swaps and CPU copy performance issues.

This adds a DRM format printing helper in meta-crtc-kms.h. This header
is included in most native backend files making it widely available,
while DRM formats are specific to the native backend. It could be shared
with Wayland bits, DRM format codes are used there too.

The helper makes the pixel format much more readable than a "%x".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
442dcc7855 renderer/native: Valid formats for secondary dumb buffers
When setting up an output on a secondary GPU with the CPU copy mode,
allocate the dumb buffers with a DRM format that is advertised supported
instead of hardcoding a format.

Particularly, DisplayLink devices do not quite yet support the hardcoded
DRM_FORMAT_XBGR8888. The proprietary driver stack actually ignores the
format assuming it is DRM_FORMAT_XRGB8888 which results the display
having red and blue channels swapped. This patch fixes the color swap
right now, while taking advantage if the driver adds support for XBGR
later.

The preferred_formats ordering is somewhat arbitrary. Here it is written
from glReadPixels point of view, based on my benchmarks on Intel Haswell
Desktop machine. This ordering prefers the format that was hardcoded
before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
23e7a0a099 crtc/kms: Add primary plane format list accessors
These functions allow inspecting which pixel formats a CRTC's primary
plane supports. Future patches will inspect the supported formats and
pick a framebuffer format accordingly instead of hardcoding a format.

The copy list function will be used to initialize a formats list, and
the supports format function will be used to intersect that list against
another CRTC's supported formats.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
7f2dbb6c44 crtc/kms: Document meta_crtc_kms_get_modifiers
It has some details that may not be obvious from the function signature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
8a0d0ce987 crtc/kms: Add fallback primary plane formats
This avoids having to hardcode the same fallbacks elsewhere multiple
times when determining what formats might be suitable for a set of
CRTCs. The formats_modifiers hash table is now guaranteed to be
populated with at least something, so future code will not need to
handle it being empty.

The hardcoded fallback formats are a minimal set probably supported by
most hardware. XRGB8888 is the format that, according to ancient lore,
all DRM devices should support, especially if they don't have the
capability to advertise otherwise. Mutter also hardcodes XRGB8888 as the
GBM surface format, so it is already required on primary GPUs.

XBGR8888 matches the most common OpenGL format, sans alpha channel since
scanout hardware has not traditionally supported alpha. XBGR8888 is here
also because Mutter hardcodes that format for secondary GPU outputs when
using the CPU copy path.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
0789c3fb9f crtc/kms: Use plane formats if no IN_FORMATS
If the IN_FORMATS property is not found, copy the formats from the DRM
plane instead. This is the fallback for getting a list of formats the
primary plane supports when DRM universal planes capability is enabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
31d99c51cb crtc/kms: Remove unused field formats_prop_id
It was set but never used.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Pekka Paalanen
30550ef688 crtc/kms: Parse and store IN_FORMATS in full
Rather than picking just one format, parse and store all the formats and
their modifiers.

This gives us a list of supported formats (and modifiers) on a CRTC
primary plane. Later I will be using this list to choose a framebuffer
format instead of hardcoding it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
2019-01-30 12:53:20 +00:00
Carlos Garnacho
177b4df217 wayland: Implement window activation and focus stealing prevention
This is done through gtk-shell ATM. If a window requests focus with
an invalid startup ID, just the demands-attention flag will be set.
The "did user interaction happen in between" checks are left to
meta_window_activate_full/meta_window_focus, by passing the timestamp
of the original launch request.
2019-01-26 18:07:03 +01:00
Carlos Garnacho
a08d7cf48a wayland: Update gtk-shell protocol to v3
This version has 2 new requests:
- gtk_shell1.notify_launch notifies the compositor that the requesting
  client shall launch another application. The given ID is expected to
  be unique.
- gtk_surface1.request_focus notifies the compositor that a surface
  requests focus due to it being activated. The given ID is passed to
  this process through undetermined means, if it corresponds with a
  current startup ID and there was no user interaction in between the
  surface will be focused, otherwise it will demand attention.
2019-01-26 18:07:03 +01:00
Jonas Ådahl
3fa6a92cc5 screen-cast: Fix monitor recording on HiDPI
It scaled the logical monitor rect with scale to get the stream
dimensions, but that is only valid when having
'scale-monitor-framebuffers' enabled. Even when it was, it didn't work
properly, as clutter_stage_capture_into() doesn't work properly with
scaled monitor framebuffers yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/415
2019-01-26 16:18:45 +00:00
Florian Müllner
d5a7bbd094 Fix builds with G_DISABLE_ASSERT
Commit 25f416c13d added additional compilation warnings, including
-Werror=return-type. There are several places where this results
in build failures if `g_assert_not_reached()` is disabled at compile
time and the compiler misses a return value.

https://gitlab.gnome.org/GNOME/mutter/issues/447
2019-01-25 09:43:06 +01:00
Iain Lane
2e53ce8e75
meta, startup-notification: Make type declarations public
Shell is using these, which was revealed by
1bbb5c8107 breaking its build when
generating its introspection due to meta_startup_notification_get_type()
not being found.

We keep the class structs private, so in practice MetaStartupSequence
and MetaBackend can't be derived from (the are semi-private).
2019-01-24 16:38:09 +00:00
Marco Trevisan (Treviño)
e02fef8e2f meta: Hide libmutter symbols by default and selectively export them
Make meson link libmutter using -fvisibility=hidden, and introduce META_EXPORT
and META_EXPORT_TEST defines to mark a symbols as visible.
The TEST version is meant to be used to flag symbols that are only used
internally by mutter tests, but that should not be considered public API.

This allows us to be more precise in selecting what is exported and what is
not, without the need of a version-script file that would be more complicated
to maintain.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/395
2019-01-23 14:18:13 +01:00
Marco Trevisan (Treviño)
e352011830 MonitorManager: Use composition instead of inheriting from dbus skeleton
MonitorManager was inheriting from MetaDBusDisplayConfigSkeleton, this was
causing introspection to see this like a GDBus skeleton object exposing to
clients methods that were not required.

Also, this required us to export meta_dbus_* symbols to the library, while
these should be actually private.

So, make MetaMonitorManager to be just a simple GObject holding a skeleton
instance, and connect to its signals reusing most of the code with just few
minor changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/395
2019-01-23 14:12:07 +01:00
Marco Trevisan (Treviño)
7f551ba776 meson: Don't list libraries private dependencies in pc files
pkg-config files for mutter are generated using *_pkg_deps as requires, but
programs linked with libmutter doesn't need most of these private dependencies
which are only needed for building and linking mutter and its subprojects.

So list packages needed only by mutter itself inside *_pkg_private_deps and
don't expose such packages to pkg-config, but only use them at build time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3955
2019-01-23 13:03:40 +00:00
Marco Trevisan (Treviño)
08130912f0 meson: Set proper soversion and version to libraries
Soname of the libraries should be the major version number, while the version
triplet is currently used:
  objdump -p libmutter-4.so.0.0.0 | grep SONAME
    SONAME               libmutter-4.so.0.0.0

While is expected to be only libmutter-4.so.0

Fix all shared libraries by setting valid version and soversion.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3955
2019-01-23 13:03:40 +00:00
Olivier Fourdan
562cf14258 core: Fix compiler warning
Fix compiler warning: ‘startup_id’ may be used uninitialized in
`meta_launch_context_get_startup_notify_id()`.

Also change `gchar` to plain `char` while at it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/406
2019-01-23 10:06:30 +01:00
Jonas Ådahl
8d91135926 wayland/xdg-shell: Fix buffer attach coordinate comparison
Only x was checked, but twice. Should check both x and y.
2019-01-22 18:32:28 +01:00
Jonas Ådahl
1bbb5c8107 meta: Only declare types when generating gir files
Some types were declared in the public headers so that g-ir-scanner
could resolve the types. This caused warnings when using
-Wredundant-decls, so only redeclare them for the gir scanner.
2019-01-22 18:32:28 +01:00
Jonas Ådahl
12a42a9295 wayland: Move DND surface role into its own file
This avoids a -Wredundand-decls warning about the get_type() function.
2019-01-22 18:32:28 +01:00
Jonas Ådahl
01cea0d9ef Fix const qualifier usage
As with the commits earlier, this also adds const qualifiers where
expected. However, the const variables are casted to non-const variants
so they can be passed to glib functions that take non-const variants but
expect const-like input.
2019-01-22 18:31:53 +01:00
Jonas Ådahl
f615eea7ee backend: Remove redundant function declarations 2019-01-22 18:31:52 +01:00
Olivier Fourdan
3738579dd3 window-actor: Use actual image size for capture
Previously, the clipping rectangle passed to
`meta_surface_actor_get_image()` was updated with the actual texture
size, but recent changes in `meta_shaped_texture_get_image()` now keep
the caller's clipping rectangle unchanged.

The implementation of `meta_window_actor_capture_into()` was relying on
the old behavior of updating the passed clipping rectangle, but now that
it's kept unchanged, the actual clipping rectangle used to copy the data
is wrong, which causes either a distorded image or worse, a crash of
mutter.

Use the resulting cairo image size to copy the data instead of the
clipping rectangle to avoid the issue and get the expected size.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/442
2019-01-22 10:30:04 +01:00
Antoine Jacoutot
1ca60f424a input-settings/x11: Only warn once about missing udev support
Otherwise we end up logging the same message everytime we enter this function,
flooding the logs and making it annoying to spot other entries.
2019-01-22 02:21:13 +01:00
Jonas Ådahl
ff507273d2 startup-notification: Silence warning
Warning in question:

../src/core/startup-notification.c:646:16: error: unused variable ‘display’ [-Werror=unused-variable]
2019-01-18 18:18:57 +01:00
Carlos Garnacho
f033d0e846 core: Add MetaLaunchContext
This is a GAppLaunchContext subclass meant to replace usage of
GdkAppLaunchContext in gnome-shell.

Launch contexts get created from the MetaStartupNotification as
they are closely related. The messaging underneath depends on
the availability of a X11 display, if there is one we go through
it (and libsn). If there is none, we still create startup sequences
manually for wayland clients.
2019-01-18 17:03:57 +00:00
Carlos Garnacho
ca67d52cac x11: Add method to launch applications, using SnLauncher
The method spawns a launch request that will get caught by the
SnMonitor we have in place to handle X11 startup notification
messages.
2019-01-18 17:03:57 +00:00
Carlos Garnacho
60d22b7cd0 wayland: Accept NULL primary data source
A NULL argument is expected here in order to unset the selection,
meta_wayland_data_device_set_primary() accepts a NULL source, but
gtk_primary_selection_device.set_selection was not handling a
NULL wl_resource.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/335
2019-01-18 13:52:05 +00:00
Jonas Ådahl
e9778eba18 build: Pass --quiet to glib-genmarshal
We don't need to know it read the input file really.
2019-01-17 20:42:10 +00:00
Jonas Ådahl
56d260cfb3 screen-cast-monitor-stream-src: Only send cursor bitmap when it changes
To avoid unnecessary pixel copying, only send the cursor bitmap when it
changes. This also allows the receiver to know when the cursor bitmap
actually changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
c45d5f53ff cursor-tracker: Emit cursor-changed after renderer was updated
Otherwise the cursor retrieved via meta_cursor_renderer_get_cursor() is
out of date.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
4e402b3972 screen-cast: Add 'cursor-mode' to allow decoupled cursor updates
The 'cursor-mode', which currently is limited to RecordMonitor(), allows
the user to either do screen casts where the cursor is hidden, embedded
in the framebuffer, or sent as PipeWire stream metadata.

The latter allows the user to get cursor updates sent, including the
cursor sprite, without requiring a stage paint each frame. Currently
this is done by using the cursor sprite texture, and either reading
directly from, or drawing to an offscreen framebuffer which is read from
instead, in case the texture is scaled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
79d99cbe3f cursor-renderer: Add API to allow inhibiting HW cursor
There may be reasons to temporarly inhibit the HW cursor under certain
circumstances. Allow adding such inhibitations by adding API to the
cursor renderer to allow API users to add generic inhibitors with
whatever logic is deemed necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
328eff7352 screen-cast/monitor-stream-src: Copy content before cursor is drawn
To get a consistent behaviour no matter whether HW cursors are in use or
not, make sure to copy the framebuffer content before the stage overlays
(cursor sprite textures) are painted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
ed5c1f433b backends/stage: Emit signal between painting actors and overlays
Will be used by screen casting for embedding the cursor separately, or
not including at all.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
7ac2083134 backends/stage: Fix minor style issue
https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
bd97b11414 renderer: Add API to get view from logical monitor
Will be used to get the view scale for a logical monitor, which is
necessary for passing cursor sprites via PipeWire.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
0da0207eed screen-cast: Add getters to fetch object owners
MetaBackend owns MetaScreenCast which owns MetaScreenCastSession which
owns MetaScreenCastStream. Make it possible to fetch objects in the
oppositev direction too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
08229a6f5d screen-cast-monitor-stream: Don't pass monitor manager when creating
It can be fetched indirectly from the monitor already.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
2b2d77dc3e cursor-tracker: Add 'cursor-moved' signal
https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Florian Müllner
a0909c3440 constraints: Fix titlebars going off the bottom
The "current" rect includes the frame, so in order to keep the
titlebar on screen, window movement must be restricted to at
most (height - titlebar_height) past the work area bottom.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/391
2019-01-16 01:19:32 +01:00
Pekka Paalanen
22f865122c renderer/native: Prefer hardware rendering for primary GPU
Mutter prefers platform devices over anything else as the primary GPU.
This will not work too well, when a platform device does not actually
have a rendering GPU but is a display-only device. An example of this
are DisplayLink devices with the proprietary driver stack, which exposes
a DRM KMS platform device but without any rendering driver.

Mutter cannot rely on EGL init failing on such devices either, because
nowadays Mesa supports software renderers on GBM, so the initialization
may well succeed.

The hardware rendering capability is recognized by matching the GL
renderer string to the known Mesa software renderers. At this time,
there is no better alternative to detecting this.

The secondary GPU data is abused for the GL renderer, as the Cogl
context may not have been created yet.  Also, the Cogl context would
only be created on the primary GPU, but at this point the primary GPU
has not been chosen yet. Hence, GPU copy path GL context is used as a
proxy and predictor of what the Cogl context might be if it was created.
Mind, that even the GL flavour are not the same between Cogl and
secondary contexts, so this is stretch but it should be just enough.

The logic to choose the primary GPU is changed to always prefer hardware
rendering devices while also maintaining the old order of preferring
platform over boot_vga devices.

Co-authored by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Emilio Pozuelo Monfort
60ac2838b5 renderer/native: Move primary GPU choosing later
Moves the primary GPU choosing to after all secondary gpu data has been
created.

This makes it possible for a future patch to start looking at secondary
gpu data in choose_primary_gpu () to determine if it is using a hardware
driver or a software renderer.

Co-authored by: Pekka Paalanen <pekka.paalanen@collabora.com>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Emilio Pozuelo Monfort
dfde2f59da renderer/native: Secondary gpu data for all
Initialize the secondary GPU data for all GPUs, even the primary one. By
not looking at the primary_gpu_kms member, a future patch is allowed to
postpone choosing the primary GPU.

A future patch will use the secondary GPU data to decide which GPU will
become the primary GPU.

Co-authored by: Pekka Paalanen <pekka.paalanen@collabora.com>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Pekka Paalanen
3d2ca9a67f renderer/native: Count devices on EGLDevice check
create_renderer_gpu_data_egl_device () relied on the primary GPU being
already chosen for the "EGLDevice currently only works with single GPU
systems" error message. A future patch will choose the primary GPU after
this, not before, so this check needs to be rewritten before the
initialization order is changed.

The new check is implemented exactly as the error message says: there
must be exactly one GPU, otherwise fail.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Pekka Paalanen
9182c8b801 backends/native: Move primary_gpu into MetaRendererNative
Make the choosing and identity of the primary GPU an internal detail to
the native renderer. MonitorManagerKms did not need it for anything.

The primary GPU logic remains unchanged.

This allows follow-up patches to change how the renderer chooses the
primary GPU. It will be easier for the renderer to use private
information for choosing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Emilio Pozuelo Monfort
1def099047 backends/native: Re-order primary GPU choosing logic
This is a step towards moving the primary GPU logic into the native
renderer exclusively. In the future the renderer will have one more
criterion on choosing the primary GPU than MetaMonitorManagerKms should
know about: does a GPU offer hardware rendering.

The choosing of primary GPU is separated from the discovery of GPUs.
When GPUs are discovered and added to the list, the MetaGpuKmsFlag is
now populated correctly and used in choosing.

Choosing the primary GPU is done after all GPUs have been found and is
slightly different from before:

- Skipping devices that do not belong to our seat now works instead of
becoming the primary GPU.

- Fall back to any non-platform, non-boot_vga device if neither kind is
found.

The old preference of platform over boot_vga device is kept.

The hotplug path will continue creating a gpu_kms without flags, because
at that point the primary GPU has already been chosen and the flags are
irrelevant.

Co-authored by: Pekka Paalanen <pekka.paalanen@collabora.com>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Pekka Paalanen
ddb0ef1e8d backends/native: Add flags to MetaGpuKms
Add a flags field to MetaGpuKms. In following commits, the flags defined
here will be set and used for choosing the primary GPU.

Co-authored by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
2019-01-13 10:30:44 +00:00
Georges Basile Stavracas Neto
fb38738fe9
Remove obsolete .cvsignore files
We moved to git 11 years ago, it's about time.
2019-01-10 11:50:54 -02:00
Georges Basile Stavracas Neto
763ae36cee
Drop Autotools
I saw Meson fade from the sky
On the wind I heard a sigh
As snowflakes cover fallen Makefiles
I will say this last goodbye

Meson is now coming
So ends Autotools days
Future is now coming
And we must away
Over Python and without Bashisms
Through lands where never Meson touched
By silver streams that run down to the Sea

Under parsers, beneath old legacy
Over snow one winter’s morn
I turned at last to paths that lead home
And though where the road then takes me
I cannot tell
We came all this way
But now comes the day
To bid you farewell

Many places I have been
Many sorrows I have seen
But I don’t regret
Nor will I forget
All Makefiles that took that road with me

I bid you all a very fond farewell.
2019-01-10 11:50:54 -02:00
Olivier Fourdan
582b67a2f1 window: Handle maximize when headless
When for some reason a window is maximized while the compositor is
headless, `window->monitor` will be NULL, so check for a NULL monitor
to avoid a NULL-pointer dereference.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/383
2019-01-09 15:19:20 +01:00
Robert Mader
f740e8ed79 core: Fix compiler warning in MetaSoundPlayer 2019-01-09 03:42:43 +00:00
Florian Müllner
d360b25b81 build: Install .pc files in correct location
If a library is provided in the positional arguments, then meson
defaults to installing the .pc file in a 'pkgconfig' subdirectory
in the library's install location. We want the files in the regular
$libdir/pkgconfig rather than $libdir/mutter-$api/pkgconfig, so
specify the location explicitly in the parameters.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/382
2019-01-08 22:36:20 +01:00
Carlos Garnacho
3693f6f630 build: Use plain libcanberra instead of libcanberra-gtk3
We no longer use the gtk-aware ca_context, the dependency can be lowered
now.
2019-01-08 16:14:17 +01:00
Carlos Garnacho
ebfc6184b2 workspace: Port to MetaSoundPlayer
Use MetaSoundPlayer to play workspace switch sounds, instead of using
libcanberra directly.
2019-01-08 16:14:17 +01:00
Carlos Garnacho
8715f7481b core: Make MetaBell use MetaSoundPlayer to play the bell sound
Instead of using libcanberra/gtk+.
2019-01-08 16:14:17 +01:00
Carlos Garnacho
12f8325cbc core: Add MetaSoundPlayer abstraction
This is a simple libcanberra abstraction object, so we are able
to play file/theme sounds without poking into GTK+/X11. Play
requests are delegated to a separate thread, so we don't block
UI on cards that are slow to wake up from power saving.
2019-01-08 16:14:17 +01:00
Carlos Garnacho
956ab4bd58 build: Make libcanberra no longer optional
This is not the case anymore with MetaSoundPlayer in place, and also
important to get keyboard bell right.
2019-01-08 15:58:11 +01:00
Jonas Ådahl
b448ced8e4 backends: Silence a couple of gtk-doc warnings
A lot of fancy gtk-doc documentation was added, but they had a couple of
issues: invalid return value annotations and wrong documented function
name.
2019-01-08 09:06:11 +01:00
Jonas Ådahl
73ddd7cd48 build: Pass library as first argument to pkg.generate()
Dependencies are added automatically, and we no longer get warnings
like:

clutter/clutter/meson.build:628: DEPRECATION: Library mutter-clutter-4
was passed to the "libraries" keyword argument of a previous call to
generate() method instead of first positional argument. Adding
mutter-clutter-4 to "Requires" field, but this is a deprecated behaviour
that will change in a future version of Meson. Please report the issue
if this warning cannot be avoided in your case.
2019-01-08 09:05:08 +01:00
Robert Mader
e7fb45364a compositor: Fix maybe-uninitialized warning
Introduced in 54febd1419

https://gitlab.gnome.org/GNOME/mutter/merge_requests/374
2019-01-07 16:13:32 +00:00
Niels De Graef
0478c225b7 Add some gtk-doc comments. 2019-01-06 21:57:16 +01:00
Robert Mader
51e4fe7fef shaped-texture: Indentation fix in update_area()
https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
2019-01-05 14:18:31 +01:00
Robert Mader
d52081bed4 shaped-texture: Invert transform of damage in update_area()
Transformed textures need to transform back the damage area, which
is given in buffer coordinates, with the inverted transform.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
2019-01-05 14:18:28 +01:00
Robert Mader
686b7f8baa boxes: Add API to transform a MetaRectangle
To be used if not a whole region needs to get transformed.
It also has an argument for reverse-transforms.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
2019-01-05 14:18:25 +01:00
Robert Mader
b7a9c7e7d3 monitor-transform: Add helper function transform_invert()
It returns the inverted transform, which is always the same as the
input, besides for TRANSFORM_90 and TRANSFORM_270.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
2019-01-05 14:18:02 +01:00
Robert Mader
676a8da005 monitor-transform: Move helper functions into their own file
The existing ones are statically inlined, so there is no .c file
right now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/366
2019-01-05 14:15:23 +01:00
Jonas Ådahl
490f27efcb shaped-texture: Use actual texture if tower returned NULL
The texture tower can return no texture e.g. if the calculated level is
negative. This was handled before, but regressed with
e1370ee209. This fixes a potential crash
observed occasionally when starting Firefox nightly using the Wayland
backend in overview mode.
2019-01-05 09:36:46 +00:00
Jonas Ådahl
173867c12b renderer/native: Use shadow fb on software GL if preferred
If a KMS device has the DRM_CAP_DUMB_PREFER_SHADOW and a software based
GL driver is used, always use a shadow fb. This will speed up read backs
in the llvmpipe OpenGL implementation, making blend operations faster.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/106
2019-01-04 20:59:00 +00:00
Georges Basile Stavracas Neto
df1384a856
window-actor: Turn into an abstract class
Now that everything is settled, from the initialization
process to the subclasses to moving code to the compositor,
MetaWindowActor can be a proper abstract class that cannot
be instantiated.

Thus, make MetaWindowActor an abstract class.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 11:58:03 -02:00
Georges Basile Stavracas Neto
5fbeecaac6
window-actor: Remove post_init() vfunc
This vfunc was added as a was to work around the convoluted
initialization process. Now that we figured it out and moved
the MetaWindowActor-specific initialization to constructed(),
we can override that.

Remove post_init() and use GObject.constructed() entirely.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 11:58:02 -02:00
Georges Basile Stavracas Neto
54febd1419
window-actor: Move window actor creation to MetaCompositor
MetaWindowActor breaks layering isolation by accessing
and injecting itself into compositor->windows. This is
a bad practice, and effecticely makes returning the
new actor useless, since we doesn't even use the return
value.

Move window actor creation to under MetaCompositor and
stop violating (too badly) the resposabilities of each
component. This moves meta_window_actor_new() into
meta_compositor_add_window().

Also, move the remaining initialization code to the
GObject.constructed vfunc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 11:58:02 -02:00
Georges Basile Stavracas Neto
7952808469
Document window and surface actors
Document the roles of MetaSurfaceActor and MetaWindowActor,
and when their subclasses are used.

(And this is actually the first real documentation under
src/compositor/README!)

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:58 -02:00
Georges Basile Stavracas Neto
0442fc8ddc
window-actor: Cleanup includes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:58 -02:00
Georges Basile Stavracas Neto
80e3c1de57
window-actor: Move X11-specific code to MetaWindowActorX11
MetaWindowActor handles sending _NET_WM_FRAME_* X atoms to
clients - even pure Wayland clients.

Now that we have Wayland- and X11-specific implementations of
MetaWindowActor, we can delegate this to MetaWindowActorX11,
and allow pure Wayland apps to not even connect to
MetaSurfaceActor:repaint-scheduled.

Do that by moving all the X11-specific code to the X11-specific
MetaWindowActorX11 class. Add vfuncs to MetaWindowActorClass
that are necessary for the move, namely:

 * pre_paint() and post_paint()
 * post_init()
 * frame_complete()
 * set_surface_actor()
 * queue_frame_drawn()

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:58 -02:00
Georges Basile Stavracas Neto
ac2f8cad0c
window-actor: Select X11 or Wayland actor based on client type
X11 clients now have a MetaWindowActorX11 on the surface. Next
commits will move the X11-specific code to MetaWindowActorX11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:51 -02:00
Georges Basile Stavracas Neto
7e8fc13504
Add MetaWindowActorX11 and MetaWindowActorWayland
Those are stub specialized classes for MetaWindowActor. This will
help ensuring that we do not execute X11-specific code paths on
pure Wayland clients.

The relationship between the window actor and the surface is the
following:

 * Wayland: MetaWindowActorWayland + MetaSurfaceActorWayland
 * X11: MetaWindowActorX11 + MetaSurfaceActorX11
 * Xwayland: MetaWindowActorX11 + MetaSurfaceActorWayland

It is not possible to have MetaWindowActorWayland backed by a
MetaSurfaceActorX11 surface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:51 -02:00
Georges Basile Stavracas Neto
60f7ff3a69
window-actor: Turn into a derivable class
We will introduce specialized MetaWindowActors for X11
and Wayland in the future, so it needs to be derivable.

Make it a derivable class, and introduce a private field.
The MetaWindowActorClass definition is in the private
header in order to prevent external consumers of Mutter
to create MetaWindowActor implementations of their own.
That is, MetaWindowActor is only internally derivable.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/368
2019-01-04 09:32:51 -02:00
Jonas Ådahl
2fe05d7c35 x11-display: Add back _GTK_EDGE_CONSTRAINTS as supported hints
It was dropped by accident in 1530f27513,
so lets add it back.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/423
2019-01-03 17:57:06 +01:00
Jonas Ådahl
012691bebf shaped-texture: Draw external textures via offscreen
EGLStream textures are imported as GL_TEXTURE_EXTERNAL_OES and reading
pixels directly from them is not supported. To make it possible to get
pixels, create an offscreen framebuffer and paint the actor to it, then
read pixels from the framebuffer instead of the texture directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
c84d7ebc6d shaped-texture: Get transformed textures pixels via offscreen
When a texture is transformed in any way (e.g. Wayland buffer
transforms), we cannot just fetch the pixels from the texture directly
and be done with it, as that will result in getting the untransformed
pixels.

To properly get the pixels in their right form, first draw to an
offscreen framebuffer, using the same method as when painting on the
stage, then read from the framebuffer into a cairo image surface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/408
2019-01-03 10:26:13 +00:00
Jonas Ådahl
f9118fb99b shaped-texture: Don't change the callers clip rect
We intersected the callers clip rect. That is probably not a good idea,
and easily avoided, so lets avoid it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
d3301d6b53 shaped-texture: Stop using gdk rect helper
We have our own version, just use that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
1755a8b8de shaped-texture: Fix include order
https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
36b46af92f boxes: Add helper to scale rectangles by a double
And change the similar region scaling helper to use this one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
e1370ee209 shaped-texture: Put actual texture painting in helper
This is so that it can be reused later by meta_shaped_texture_get_image() for
drawing via an offscreen framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
37e36e8208 compositor: Make meta_actor_painting_untransformed take a framebuffer
Stop using the cogl draw framebuffer implicitly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Daniel Stone
177d0c2d63 gpu/kms: Use correct DRM event context version
DRM_EVENT_CONTEXT_VERSION is the latest context version supported by
whatever version of libdrm is present. Mutter was blindly asserting it
supported whatever version that may be, even if it actually didn't.

With libdrm 2.4.78, setting a higher context version than 2 will attempt
to call the page_flip_handler2 vfunc if it was non-NULL, which being a
random chunk of stack memory, it might well have been.

Set the version as 2, which should be bumped only with the appropriate
version checks.

https://bugzilla.gnome.org/show_bug.cgi?id=781034
2019-01-02 15:44:52 +01:00
Jonas Ådahl
f7d4a727a8 build: Always pass --quiet to g-ir-scanner
This makes the build less verbose, as all .gir generation except for
clutters didn't pass --quiet to g-ir-scanner, making it output long
linking commands. Do this by adding a common introspection_args
variable.

While at it, put -U_GNU_SOURCE in there too, as it was always passed
everywhere as without it the scanner would log warnings.
2018-12-22 11:31:10 +01:00
Niels De Graef
d539fe28d5 Use G_DECLARE_DERIVABLE/FINAL_TYPE on some types
This is only for types in the `Meta` namespace.

* Clears up a lot of boilerplate
* We get `g_autoptr` support for free
2018-12-21 19:48:50 +00:00
Georges Basile Stavracas Neto
9bd427a74c
meta/tests: Remove commented lines
Leftovers from the initial landing of Meson files.
2018-12-20 13:52:35 -02:00
Georges Basile Stavracas Neto
ebb6c56f67
Add Meson support for installed tests
This is the last remaining feature necessary to achieve
parity with the Autotools build.

A few changes were made to the install locations of the
tests, in order to better acomodate them in Meson:

 * Tests are now installed under a versioned folder (e.g.
   /usr/share/installed-tests/mutter-4)

 * The mutter-cogl.test file is now generated from an .in
   file, instead of a series of $(echo)s from within Makefile.

Notice that those tests need very controlled environments
to run correctly. Mutter installed tests, for example, will
failed when running under a regular session due to D-Bus
failing to acquire the ScreenCast and/or RemoteScreen names.
2018-12-20 13:52:35 -02:00