1
0
Fork 0
Commit graph

1266 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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)
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
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
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)
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
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
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 Å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
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
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
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
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
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
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
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
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)
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)
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
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
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
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
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
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
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
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
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