1
0
Fork 0
Commit graph

1346 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Niels De Graef
0478c225b7 Add some gtk-doc comments. 2019-01-06 21:57:16 +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
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
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
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
Peter Hutterer
9f3d321bf2 input-settings: treat a serial of 1 as serial of 0
The Wacom Xorg driver assigns a serial number of 1 for any pad that doesn't
have a serial. libinput assigns 0. Just treat 1 as 0 here, there are no pens
with a real serial 1 anyway.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/414
2018-12-17 16:12:50 +10:00
Olivier Fourdan
c786b6c13c screen-cast-session: Add window-id support
Use the "window-id" property to select the window to cast using
RecordWindow.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Olivier Fourdan
ec25f3a6b7 screen-cast-session: Add support for RecordWindow
Add support for the RecordWindow screencast method, casting the
currently focused window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Olivier Fourdan
dbe7279c7f screen-cast-session: Add screen-cast window mode
Window mode will cast the content of a single window using the
`MetaScreenCastWindow` interface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Olivier Fourdan
20c9ca25c0 screen-cast: Add screen-cast-window interface
Typically, to stream the content of a window, we need a way to copy the
content of its window-actor into a buffer, transform relative input
coordinates to relative position within the window-actor and a mean to
get the window bounds within the buffer.

For this purpose, add a new GType interface `MetaScreenCastWindow` with
the methods needed for screen-cast window mode:

 * meta_screen_cast_window_get_buffer_bounds()
 * meta_screen_cast_window_get_frame_bounds()
 * meta_screen_cast_window_transform_relative_position()
 * meta_screen_cast_window_capture_into()

This interface is meant to be implemented by `MetaWindowActor` which has
access to all the necessary bits to implement them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Olivier Fourdan
f64eba57ce screen-cast-src: Add VideoCrop support
To be able to cast windows, which by definition can change in size
dynamically, we need a way to specify the video crop meta to adjust to
the window size whenever it changes.

Add VideoCrop support with a new optional hook `get_videocrop()` in the
`ScreenCastStreamSrcClass` which, if defined, can let the child specify
a rectangle for the video cropping area.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Jonas Ådahl
149e4d6934 monitor-manager: Don't use switch-config when ensuring configuration
Switch-configs are only to be used in certain circumstances (see
meta_monitor_manager_can_switch_config()) so when ensuring
configuration and attempting to create a linear configuration, use the
linear configuration constructor function directly without going via the
switch config method, otherwise we might incorrectly fall back to the
fallback configuration (only enable primary monitor).

This is a regression introduced by 6267732bec.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/342
2018-12-13 12:40:27 +00:00
Daniel van Vugt
8d514095cb cursor-renderer-native: Floor the cursor position instead of rounding
Which eliminates the 1px jitter that was visible when dragging windows,
and eliminates the flickering that was visible when pushing the cursor
against the right/bottom edges of the screen.
2018-12-13 17:12:28 +08:00
Carlos Garnacho
ffca9b999d backends: Update to new "output" setting for tablets/touchscreens 2018-12-06 14:44:46 +00:00
Carlos Garnacho
d30301c00a backends: Turn builtin touchscreen on/off together with DPMS
This takes over gsd-power code, that would disable touchscreens
on DPMS off.

https://bugzilla.gnome.org/show_bug.cgi?id=742598
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/issues/29
2018-12-06 14:44:46 +00:00
Carlos Garnacho
faf89ff35f backends: Add MetaInputMapper method to lookup devices from outputs
So we may know the device of a certain ClutterInputDeviceType that is
mapped to the given output.
2018-12-06 14:44:46 +00:00
Carlos Garnacho
87858a4e01 backends: Delegate on MetaInputMapper for unmapped display devices
If a display device (touchscreen, tablet with libwacom integration flags)
does not receive a monitor through settings. Delegate on the
MetaInputMapper so it receives a mapping through heuristics.
2018-12-06 14:44:46 +00:00
Carlos Garnacho
08a5e660d3 backends: Add MetaInputMapper
This object takes care of mapping absolute devices to monitors,
to do so it uses 3 heuristics, in this order of preference:
- If a device is known to be builtin, it's assigned to the
  builtin monitor.
- If input device and monitor match sizes (with an error margin
  of 5%)
- If input device name and monitor vendor/product in EDID match
  somehow (from "full", through "partial", to just "vendor")

The most favorable outputs are then assigned to each device, making
sure not to assign two devices of the same kind to the same output.

This object replaces (and is mostly 1:1 with) GsdDeviceMapper in
g-s-d. That object would perform these same heuristics, and let
mutter indirectly know through settings changes. This object allows
doing the same in-process.
2018-12-06 14:44:46 +00:00
Georges Basile Stavracas Neto
7d20101198 cogl-framebuffer: Remove swap_throttled config
Since now we don't set the swap throttled value based
on sync-to-vblank, we can effectively remove it from
Cogl. Throttling swap buffers in Cogl is as much a
historical artifact as sync-to-vblank. Furthermore,
it doesn't make sense to disable it on a compositor,
which is the case with the embedded Cogl.

In addition to that, the winsys vfunc for updating
whenever swap throttling changes could also be removed,
since swap throttling is always enabled now.

Removing it means less code, less branches when running,
and one less config option to deal with.

This also removes the micro-perf test, since it doesn't
make sense for the case where Cogl is embedded into the
compositor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/191
2018-12-06 14:29:34 +00:00
Georges Basile Stavracas Neto
ae4d3bc27d clutter: Remove ability to externally set sync-to-vblank
Externally setting the sync-to-vblank setting was a feature
added as a workaround to old Intel and ATI graphic cards, and
is not needed anymore. Furthermore, it doesn't make sense to
change it on a compositor whatsoever.

This commit removes all the ways to externally change this
setting, as well as the now unused API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/191
2018-12-06 14:29:34 +00:00
Marco Trevisan (Treviño)
c5471e5b8b renderer-x11-nested: Use rounded width/heights for fb size
https://bugzilla.gnome.org/show_bug.cgi?id=765011
2018-12-05 10:34:22 +00:00
Jonas Ådahl
eacf2f2187 backends/x11/nested: Draw the stage view CRTCs with the correct size
The nested stage tries to emulate how CRTCs are drawn, but fails to do
this when a stage view is scaled as it didn't adapt the viewport size
according to the stage view scale.

https://bugzilla.gnome.org/show_bug.cgi?id=786663
2018-12-05 10:34:22 +00:00
Marco Trevisan (Treviño)
7821256f5c monitor-manager-dummy: Allow to pass extra monitor specs via env
Add MUTTER_DEBUG_DUMMY_MONITORS_SPECS env variable support so that you can define
a ':' separated list of monitor specs in the form of WWWxHHH@RR that will be
available for configuring the nested mutter.
2018-12-05 10:34:22 +00:00
Jonas Ådahl
4786cc85bd monitor-config-manager: Round layout size after scaling
When calculating the logical monitor layout size given a scale, don't
risk precision loss by float to int casting, which could result in a too
small layout.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2018-12-05 10:34:22 +00:00
Jonas Ådahl
7226c5c7bf backend/native: Remove leftover stage view checks
We haven't supported disabling stage views in the native backend since

commit 70edc7dda4
Author: Jonas Ådahl <jadahl@gmail.com>
Date:   Mon Jul 24 12:31:32 2017 +0800

    backends/native: Stop supporting stage views being disabled

There were still some left over checks; lets remove them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/343
2018-12-04 15:04:50 +01:00
Daniel van Vugt
f6f188dad4 renderer-native: Advertise COGL_FEATURE_ID_PRESENTATION_TIME
Since it's now implemented (e9e4b2b72e). Fortunately forgetting to
advertise it didn't matter because there isn't any code yet that
checks for it.
2018-11-30 14:31:03 +00:00
Carlos Garnacho
262a3ecbd6 backends/x11: Flush connection after ungrab
Modal ungrabs may be followed by other clients trying to grab themselves,
flush the connection so we ensure the right order of events on the Xserver
side.

An example of this is js/ui/modalDialog.js in gnome-shell, as the alt-F2
dialog may launch X11 clients trying to grab themselves, commit a40daa3c22
in gnome-shell handled the case and added a gdk_display_sync() call to
ensure no grab existed at the time of executing.

This commit aims to achieve the same built in MetaBackend. A full sync
seems excessive though, as we just need to make sure the server got the
messages queued before the other side tries to grab, a XFlush seems
sufficient for this.
2018-11-30 13:58:36 +00:00
Jonas Ådahl
c8db8bbe22 backend/x11/nested: Always claim the lid is open
The nested backend used the value from udev, meaning that one couldn't
configure the fake monitor if the laptop panel of the host was closed.
Avoid this annoyance by always having the nested backend claiming the
lid is open.
2018-11-29 11:37:45 +01:00
Niels De Graef
49cb691bb5 monitor-manager: remove get_edid_file() vfunc
It wasn't implemented by any subclass, it's not provided by DRM either.
And even if a subclass were to have only a file available, it could read
it into a GBytes as well and just use `read_edid()`.

Found this while working on !269.
2018-11-26 14:37:54 +01:00
Daniel van Vugt
e8c27603dd renderer-native: Advertise _FEATURE_SWAP_THROTTLE
Because it is implemented and always on. By advertising this fact
the master clock is able to sync to the native refresh rate instead
of always using the fallback of 60.00Hz.

https://bugzilla.gnome.org/show_bug.cgi?id=781296
2018-11-23 11:01:30 +00:00
Daniel van Vugt
e9e4b2b72e renderer-native: Add hardware presentation timing
Add support for getting hardware presentation times from KMS (Wayland
sessions). Also implement cogl_get_clock_time which is required to compare
and judge the age of presentation timestamps.

For single monitor systems this is straightforward. For multi-monitor
systems though we have to choose a display to sync to. The compositor
already partially solves this for us in the case of only one display
updating because it will only use the subset of monitors that are
changing. In the case of multiple monitors consuming the same frame
concurrently however, we choose the fastest one (in use at the time).
Note however that we also need !73 to land in order to fully realize
multiple monitors running at full speed.
2018-11-23 11:01:30 +00:00
Emilio Pozuelo Monfort
ad7d6e4a37 backends/native: React to GPU hotplug
If a GPU is added at runtime, we should connect to it and manage
its outputs.
2018-11-21 14:33:00 +01:00
Emilio Pozuelo Monfort
a6178990cd monitor-manager/kms: Use non-pci secondary cards
We may have secondary non-PCI devices, and we should drive their
outputs.
2018-11-21 14:26:02 +01:00
Pekka Paalanen
1c044a8fa0 renderer/native: remove meta_renderer_native_gles3_read_pixels
It is unused.
2018-11-19 22:53:13 +00:00
Pekka Paalanen
d4bea60e1a renderer/native: use cogl for CPU copy path
Use cogl_framebuffer_read_pixels_into_bitmap () instead of
glReadPixels () for the CPU copy path in multi-GPU support.

The cogl function employs several tricks to make the read-pixels as fast
as possible and does the y-flip as necessary. This should make the copy
more performant over all kinds of hardware.

This is expected to be used on virtual outputs (e.g. DisplayLink USB
docks and monitors) foremost, where the dumb buffer memory is just
regular system memory. If the dumb buffer memory is somehow slow, like
residing in discrete VRAM or having an unexpected caching mode, it may
be possible for the cogl function perform worse because it might do the
y-flip in-place in the dumb buffer. Hopefully that does not happen in
any practical scenario.

Calling meta_renderer_native_gles3_read_pixels () here was conceptually
wrong to begin with because it was done with the Cogl GL context of the
primary GPU, not on the GL ES 3 context of a secondary GPU. However,
due eglBindAPI being a no-op in Mesa and the glReadPixels () arguments
being compatible, it worked.

This patch adds a pixel format conversion table between DRM and Cogl
formats. It contains more formats than absolutely necessary and the
texture components field which is currently unused for completeness. See
Mutter issue #323. Making the table more complete documents better how
the pixel formats actually map so that posterity should be less likely
to be confused. This table could be shared with
shm_buffer_get_cogl_pixel_format () as well, but not with
meta_wayland_dma_buf_buffer_attach ().

On HP ProBook 4520s laptop (Mesa DRI Intel(R) Ironlake Mobile, Mesa
18.0.5), without this patch copy_shared_framebuffer_cpu () for a
DisplayLink output takes 5 seconds with a 1080p frame.  Obviously that
makes Mutter and gnome-shell completely unusable.  With this patch, that
function takes 13-18 ms which makes it usable if not fluent.

On Intel i7-4790 (Mesa DRI Intel(R) Haswell Desktop) machine, this patch
makes no significant difference (the copy takes 4-5 ms).
2018-11-19 22:53:13 +00:00
Pekka Paalanen
8c4743ee2a renderer/native: store dumb FB format
The format will be needed in a following commit in the CPU copy path
which stops hardcoding another format and starts using the format the
dumb FB was created with.
2018-11-19 22:53:13 +00:00
Pekka Paalanen
cbbd6d71bf renderer/native: use DRM formats for dumb buffers
Change the callers of init_dumb_fb () to use DRM format codes. DRM and
GBM format codes are identical, but since this is about dumb buffers,
DRM formats fit better.

The header /usr/include/gbm.h installed by Mesa says:

 * The FourCC format codes are taken from the drm_fourcc.h definition, and
 * re-namespaced. New GBM formats must not be added, unless they are
 * identical ports from drm_fourcc.

That refers to the GBM_FORMAT_* codes.
2018-11-19 22:53:13 +00:00
Olivier Fourdan
4aa1e221e4 remote-desktop: Do not leak the virtual touchscreen
Virtual keyboard and pointer are freed on session close, but the
virtual touchscreen isn't.

Avoid a leak by freeing the virtual touchscreen along with the rest of
virtual devices.
2018-11-19 15:41:43 +00:00
Emilio Pozuelo Monfort
fb8dc91893 output/kms: Make winsys_id unique
We were using the connector_id for the winsys_id, but different
devices could have connectors with the same id. Since we use
winsys_id to uniquely identify outputs, use both the connector
id and the device id to avoid having outputs with the same id.
2018-11-19 14:58:48 +00:00
Emilio Pozuelo Monfort
5e005316ef output: Turn winsys_id into a uint64_t
We need a 64 bit field to combine the device id and connector
id into the output id (winsys_id).
2018-11-19 14:58:48 +00:00
Emilio Pozuelo Monfort
4bc6a64d47 backends/native: Use the connector_id rather than winsys_id
winsys_id needs to be a unique output identifier so it will have
to stop being the connector id.
2018-11-19 14:58:48 +00:00
Emilio Pozuelo Monfort
91d4f30ebd gpu/kms: Add identifier
We need a device unique id in order to uniquely identify an output,
which will use a (device, connector) pair.
2018-11-19 14:58:48 +00:00
Emilio Pozuelo Monfort
c585b214b8 gpu: Drop unused declaration 2018-11-19 14:58:48 +00:00
Ting-Wei Lan
740c2298c6 build: Don't hardcode the path of python3
Python is not guaranteed to be installed in /usr/bin. This is especially
true for *BSD systems which don't consider Python as an integral part of
their systems.
2018-11-18 14:25:35 +08:00
Jonas Ådahl
25c53b2fb2 backend: Freeze frame clock when headless
Don't schedule redraws when being headless; there is nothing to draw so
don't attempt to draw. This also makes a flaky test become non-flaky, as
it previously spuriously got warnings due to windows being "painted"
when headless but lacking frame timings, as nothing was actually
painted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/170
2018-11-09 11:16:30 +01:00
Jonas Ådahl
213ed80284 backends: Move clutter frame clock freeze/thaw API to ClutterSTage
It had nothing to do with EGL or the eglnative backend, and will be used
by non-native backends, so move it to a common place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/170
2018-11-09 11:16:30 +01:00
Jonas Ådahl
9adf8826d2 backends/stage: Remove unused function declaration
https://gitlab.gnome.org/GNOME/mutter/merge_requests/170
2018-11-09 11:16:30 +01:00
Jonas Ådahl
19930c6577 backends/stage: Remove MetaStagePrivate
The empty MetaStage was in meta-stage-private.h for no reason, so lets
move it to the C file. This makes it pointless to have a private
instance struct, so just move the fields to the private struct
_MetaStage.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/170
2018-11-09 11:16:30 +01:00
Jonas Ådahl
f139360569 Make it possible to build without GLX support 2018-11-06 17:17:36 +01:00
Jonas Ådahl
bf42b54faa Make it possible to build without EGL support
This will avoid building anything related to EGL. For meson, this will
mean that both the native backend an the Wayland support must also be
disabled.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
bc32655c28 Pass -D_GNU_SOURCE instead of defining it in source 2018-11-06 17:17:36 +01:00
Jonas Ådahl
176e6fcded x11: Require XInput 2.3 at build time
The needed libXi version was released 5 years ago, so should be fine.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
ecec99eedb x11: Require xrandr 1.5 at build time
While leaving the runtime checks in place, requiring xrandr 1.5 at build
time allows us to remove some seemingly unnecessary conditional
inclusion of functionality.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
8a03f1ad02 Always generate meta-default-modes.h
This adds a hard requirement on having cvt installed, which in the past
was soft, where the generated file was added to the repository.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
530861b24d cogl: Remove left-over WebGL paths 2018-11-06 17:17:36 +01:00
Jonas Ådahl
7b2eaa76a4 cogl: Remove support for GLESv1
We have no need for it in mutters cogl variant.
2018-11-06 17:17:36 +01:00
Pekka Paalanen
4282067e24 gpu-kms: assert on invalid flip attempts
drmModePageFlip() is guaranteed to fail for the invalid FB id 0.
Therefore it never makes sense to call this function with such argument.
Disabling a CRTC must be done with SetCrtc instead, for example.

Trying to flip to FB 0 not only fails, but it also causes Mutter to
never try page flip on this output again, using drmModeSetCrtc()
instead.
2018-10-25 09:57:39 +00:00
Pekka Paalanen
85e9784a22 renderer/native: fix next_fb_id race on CPU copy path
There was a race in setting next_fb_id when a secondary GPU was using
the CPU copy path. Losing this race caused the attempt to
drmModePageFlip () to FB ID 0 which is invalid and always fails. Failing
to flip causes Mutter to fall back to drmModeSetCrtc () permanently.

In meta_onscreen_native_swap_buffers_with_damage ():
- update_secondary_gpu_state_pre_swap_buffers ()
  - copy_shared_framebuffer_cpu () but only on the CPU copy path
    - secondary_gpu_state->gbm.next_fb_id is set
- wait_for_pending_flips ()
  - Waits for any remaining page flip events and executes and destroys
    the related page flip closures.
    - on_crtc_flipped ()
      - meta_onscreen_native_swap_drm_fb ()
        - swap_secondary_drm_fb ()
	  - secondary_gpu_state->gbm.next_fb_id = 0;
- meta_onscreen_native_flip_crtcs ()
  - meta_onscreen_native_flip_crtc ()
    - meta_gpu_kms_flip_crtc () gets called with fb_id = 0

This race was observed lost when running 'mutter --wayland' on a machine
with two outputs on Intel and one output on DisplayLink USB dock, and
wiggling around a weston-terminal window between the Intel and
DisplayLink outputs. It took from a second to a minute to trigger. For
testing with DisplayLink outputs Mutter also needed a patch to take the
DisplayLink output into use, as it would have otherwise been ignored
being a platform device rather than a PCI device.

Fix this race by first waiting for pending flips and only then
proceeding with the swap operations. This should be safe, because the
pending flips could have completed already before entering
meta_onscreen_native_swap_buffers_with_damage ().
2018-10-25 09:57:39 +00:00
Daniel Drake
6267732bec monitor-manager: use MonitorsConfig to track switch_config
When constructing MetaMonitorsConfig objects, store which type
of switch_config they are for (or UNKNOWN if it is not such
type of config).

Stop unconditionally setting current_switch_config to UNKNOWN when
handling monitors changed events. Instead, set it to the switch_config
type stored in the MonitorsConfig in the codepath that updates logical
state. In addition to being called in the hotplug case along the same
code flow that generates monitors changed events, this is also called
in the coldplug case where a secondary monitor was connected before
mutter was started.

When creating the default linear display config, create it as a
switch_config so that internal state gets updated to represent
linear mode when this config is used.

The previous behaviour of unconditionally resetting current_switch_config
to UNKNOWN was breaking the internal state machine for display config
switching, causing misbehaviour in gnome-shell's switchMonitor UI when
using display switch hotkeys. The lack of internal tracking when the
displays are already in the default "Join Displays" linear mode was
then causing the first display switch hotkey press to do nothing
(it would attempt to select "Join Displays" mode, but that was already
active).

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/281
https://gitlab.gnome.org/GNOME/mutter/merge_requests/213
2018-10-08 15:53:45 +08:00
Pekka Paalanen
a3d826c54b renderer/native: honour dumb buffer stride
meta_renderer_native_gles3_read_pixels() was assuming that the target
buffer stride == width * 4. This is not generally true. When a DRM
driver allocates a dumb buffer, it is free to choose a stride so that
the buffer can actually work on the hardware.

Record the driver chosen stride in MetaDumbBuffer, and use it in the CPU
copy path. This should fix any possible stride issues in
meta_renderer_native_gles3_read_pixels().
2018-10-04 11:57:35 +03:00
Pekka Paalanen
72e236106f renderer/native: assert dumb buffer size on CPU copy
Track the allocated dumb buffer size in MetaDumbBuffer. Assert that the
size is as expected in copy_shared_framebuffer_cpu().

This is just to ensure that Cogl and the real size match. The size from
Cogl was used in the copy, so getting that wrong might have written
beyond the allocation.

This is a safety measure and has not been observed to happen yet.
2018-10-04 11:57:35 +03:00
Pekka Paalanen
3e1ca62782 renderer/native: check format for drmModeAddFB fallback
If drmModeAddFB2() does not work, the fallback to drmModeAddFB() can
only handle a single specific format. Make sure the requested format is
that one format, and fail the operation otherwise.

This should at least makes the failure mode obvious on such old systems
where the kernel does not support AddFB2, rather than producing wrong
colors.
2018-10-04 11:57:35 +03:00
Tony Novak
8685de9607 input-settings: detect trackball using udev ID_INPUT_TRACKBALL
Previously, trackballs were detected based on the presence of the
substring "trackball" in the device name. This had the downside of
missing devices, such as the Kensington Expert Mouse, which don't have
"trackball" in their names.

Rather than depending on the device name, use the ID_INPUT_TRACKBALL
property from udev to determine whether or not to treat a device as a
trackball.

This adds a new function, `is_trackball_device`, to MetaInputEvents, and
eliminates the `meta_input_device_is_trackball` function.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/258
2018-09-19 08:48:27 +00:00
Florian Müllner
a3d9f987c8 input-settings-x11: Push error trap
Pops are lonely without push, so add one for a happy error trap.

https://gitlab.gnome.org/GNOME/mutter/issues/294
2018-09-07 19:42:37 +02:00
Jonas Ådahl
ebafc256a0 renderer/native: Check calculated transform when creating view
The "backends: Move MetaOutput::crtc field into private struct"
accidentally changed the view transform calculation code to assume that
"MetaCrtc::transform" corresponds to the transform of the CRTC; so is
not the case yet; one must calculate the transform from the logical
monitor, and check whether it is supported by the CRTC using
meta_monitor_manager_is_transform_handled(). This commit restores the
old behaviour that doesn't use MetaCrtc::transform when calculating the
view transform.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/216
2018-08-24 11:51:36 +00:00
Iain Lane
deb541ef5a monitor-manager-kms: Check if GPUs can have outputs
We need a way for mutter to exit if no available GPUs are going to work.
For example if gdm starts gnome-shell and we're using a DRM driver that
doesn't work with KMS then we should exit so that GDM can try with Xorg,
rather than operating in headless mode.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/223
2018-08-21 13:16:22 +00:00
Iain Lane
29cc526e2e gpu-kms: Handle drmModeGetResources() failing
Avoid dereferencing the NULL return value if it fails. We still create
the MetaGpu, but we treat it as if it has no outputs.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/223
2018-08-21 13:16:21 +00:00
Jonas Ådahl
7c06e21e5a idle-monitor: Store either 1 or 0 in the inhibited gboolean
Wrap the flag checking in !!(..) to make sure we always either store
TRUE or FALSE in the gboolean.
2018-08-14 15:14:05 +00:00
Jeff Smith
1bfa20929b backends/x11: Improve grab-device clock updates
meta_backend_x11_grab_device is performing X server clock comparison
using the MAX macro, which comes down to a simple greater-than.

Use XSERVER_TIME_IS_BEFORE, which is a better macro for X server
clock comparisons, as it accounts for 32-bit wrap-around.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/174
2018-08-13 21:00:33 +02:00
Jonas Ådahl
37eeda0320 Revert "gpu-kms: Handle drmModeGetResources() failing"
This reverts commit acf70a3561
2018-08-10 16:31:03 +00:00
Iain Lane
acf70a3561 gpu-kms: Handle drmModeGetResources() failing
Avoid dereferencing the NULL return value if it fails. We still create
the MetaGpu, but we treat it as if it has no outputs.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/223
2018-08-10 16:35:17 +01:00
Alex Villacís Lasso
f7af32a3ea renderer/native: Fallback to non-planar API if gbm_bo_get_handle_for_plane fails
Commit c0d9b08ef9 replaced the old GBM API calls
with the multi-plane GBM API. However, the call to gbm_bo_get_handle_for_plane
fails for some DRI drivers (in particular i915). Due to missing error checks,
the subsequent call to drmModeAddFB[2] fails and the screen output locks up.

This commit adds the missing error checks and falls back to the old GBM API
(non-planar) if necessary.

v5: test success of gbm_bo_get_handle_for_plane instead of errno

This commit adopts solution proposed by Daniel van Vugt to check the return
value of gbm_bo_get_handle_for_plane on plane 0 and fall back to old
non-planar method if the call fails. This removes the errno check (for
ENOSYS) that could abort if mesa ever sets a different value.

Related to: https://gitlab.gnome.org/GNOME/mutter/issues/127
2018-08-09 12:36:34 +00:00
Florian Müllner
7fdaf7721c Don't cast free function passed to g_clear_pointer
The function is intentionally provided as macro to not require a
cast. Recently the macro was improved to check that the passed in
pointer matches the free function, so the cast to GDestroyNotify
is now even harmful.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
2018-07-31 23:40:01 +02:00
Florian Müllner
c403785d36 Stop using g_type_class_add_private()
It is now deprecated in favor of the G_ADD_PRIVATE() macro (usually
called via G_DEFINE_WITH_PRIVATE()).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
2018-07-31 23:40:01 +02:00
Jonas Ådahl
4d465eac08 monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.

An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.

Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.

https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 13:37:03 +02:00
Andrea Azzarone
649c26e05a monitor-manager: Filter out low screen resolutions
Avoid exporting through org.gnome.Mutter.DisplayConfig.GetCurrentState
excessively-low screen resolutions setting both a minimum width and a minimum
height. GetCurrentState is e.g. used by Gnome Control Center to build a list of
selectable resolutions.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=793223
2018-07-30 15:57:31 +02:00
Jonas Ådahl
6e953e2725 native/gpu: Handle drmModeSetCrtc() failing gracefully
If drmModeSetCrtc() is called with no fb, mode or connectors for some
CRTC it may still fail, and we should handle that gracefully instead of
assuming it failed to set a non-disabled state.

Closes https://gitlab.gnome.org/GNOME/mutter/issues/70
2018-07-25 07:49:52 +00:00
Jonas Ådahl
5f37369adb Add remote access controller API
Add API to let GNOME Shell have the ability to get notified about remote
access sessions (remote desktop, remote control and screen cast), and
with a way to close them.

This is done by adding an abstraction above the remote desktop and
screen cast session objects, to avoid exposing their objects to outside
of mutter. Doing that would result in external parts holding references
to the objects, complicating their lifetimes. By using separate wrapper
objects, we avoid this issue all together.
2018-07-20 16:49:49 +02:00
Bastien Nocera
fa9e330f2c backend: Remove direct upower-glib usage
Monitor whether UPower is running ourselves. That allows us to keep the
same value for "lid-is-closed" throughout the process of UPower
restarting, preventing unwanted monitor re-configuration through the process.

Fixes another screen black out when UPower restarts and the laptop lid
is closed.
2018-07-18 10:17:37 +00:00
Bastien Nocera
951219650f backend: Move lid-is-closed handling to MetaBackend
Rather than handle UpClient in both MetaBackend (to reset the idletime
when the lid is opened), and in MetaMonitorManager and
MetaMonitorConfigManager (to turn the screen under the lid on/off
depending on its status), move the ability to get the lid status from
UPower or mock it in one place, in MetaBackend.
2018-07-18 10:17:36 +00:00