Commit Graph

9146 Commits

Author SHA1 Message Date
Jonas Ådahl
2cdb0414c2 remote-desktop/session: Maybe emit 'owner-changed' after clipboard enabled
If there is a clipboard owner when enabling the clipboard integration
without immediately overriding the owner, send an initial owner-changed
event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
5104a9b2ce remote-desktop/session: Add support for SelectionTransfer/Write
When a transfer request is done to the MetaSelectionSourceRemote source,
it's translated to a SelectionTransfer signal, which the remote desktop
server is supposed to respond to with SelectionWrite.

A timeout (set to 15 seconds) is added to handle too long timeouts,
which cancels the transfer request.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
d7c8535ac6 remote-desktop/session: Implement SelectionRead()
This makes it possible to retrieve the clipboard content from the
current selection clipboard source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
a220506bf7 remote-desktop: Add dummy remote selection source
It doesn't yet fetch data from the remote desktop session, but hooks up
correctly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
6398d5a109 remote-desktop/session: Forward MetaSelection::owner-changed
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
ac1a5366b1 remote-desktop/session: Added boiler plate for clipboard integration
Nothing is hooked up, it only does basic sanity checking i.e. whether
the clipboard was enabled when interacting with it. No actual clipboard
integration is hooked up yet.

This also syncs org.gnome.Mutter.RemoteDesktop.xml from
gnome-remote-desktop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
54b024465e util: Add 'remote-desktop' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Carlos Garnacho
b2b66aa8c6 backends/native: Disable touch-mode with pointer presence
The original implementation of ::touch-mode tested for keyboard
presence to know whether the OSK and other touch-only features were
enabled.

However that didn't pan out, every webcam, card reader and kitchen
sink like to live a second life as EV_KEY devices. This made the
detection of actual external keyboards a much harder task than it
sounds, and was thus removed in commit f8e2234ce5.

Try a different approach here, and test for pointer devices, it
doesn't matter if internal or external devices, the rationales:

- It is significantly easier to get this right, there's virtually
  no devices with abs/rel axes that don't try to be a real input
  device of some sorts.
- It's not as good as testing for keyboard presence, but it's the
  next best thing. These usually come in pairs, except in weird
  setups.
- It is better than not having anything for a number of situations:
  - Non-convertible laptops with a touchscreen will get touch-mode
    disabled due to touchpad presence (plus keyboard). There's
    been complains about OSK triggering with those.
  - Same for desktop machines with USB touchscreens, the mouse
    (and presumably keyboard) attached would make touch-mode
    get in the middle.
  - Convertible laptops with a broken tablet-mode switch get a
    chance to work on tablet modes that do disable input devices
    (e.g. detachable keyboards, or via firmware)
  - Kiosk machines, tablets, and other devices that have a
    touchscreen but will not regularly have a mouse/keyboard
    will get the touch-mode enabled.

All in all, this seems to cover more situations the way we expect it,
there's only one situation that the OSK would show where it might
not be desirable, and one that might not show when it better should:

- Tablets and kiosk machines that get one keyboard plugged, but not a
  mouse, will still show the OSK, despite being able to type right
  away.
- Convertible laptops with broken/unreliable tablet-mode switch (e.g.
  ignored by the kernel) rely entirely on the device/firmware
  characteristics to work. If after folding into tablet mode the
  touchpad remains active, touch-mode will not turn on.
  Fixing the tablet-mode switch on these devices should be preferred,
  as that'll also make libinput magically disable the touchpad.

The latter can be worked around with the a11y toggle. The former is
merely inconvenient, and nothing prevents the user from plugging a mouse
in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1710>
2021-02-05 16:07:55 +01:00
Robert Mader
7da34f154b compositor/dnd-actor: Take geometry scale into account on DnD-cancel
Technically this is still wrong if the source actor or dnd actor are
transformed in other ways. However geometry scale is the by far most
common case and we currently lack convenience API in Clutter to
easily compute the right values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Robert Mader
04eeeb78d1 wayland/dnd-surface: Use new API to set geometry scale of feedback actor
The removed parts are now all handled in MetaFeedbackActor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Robert Mader
dfa659b5b5 feedback-actor: Add API to set and get geometry scale
Analogous to MetaWindowActor. Also take it into account for positioning
when an anchor is set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Jonas Dreßler
04c6934363 screencast: Log a debug message when we can't get a buffer from pipewire
When recording the screen and real time encoding it using a gstreamer
pipeline, that pipeline can stall when the encoder is too slow. Log a
debug message using the new SCREEN_CAST debug topic in that case so we
know when framedrops are happening.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1709>
2021-02-05 09:27:38 +00:00
Jonas Dreßler
a869df1dd7 util: Add a SCREEN_CAST debug topic
This is going to be useful to log dropped frames and other more common
errors about screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1709>
2021-02-05 09:27:38 +00:00
Florian Müllner
ee3d26f228 keybindings: Reset modifier-only-pressed on scroll
Since commit c255031b6d, we allow some modifier+scroll events to
pass through to Clutter to enable gnome-shell to handle them. That
action shouldn't trigger a modifier-only action at the same time, so
reset the corresponding tracking just like we do for modifier+click.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
ac3d9a0641 events: Process modifier+scroll after keybindings
Allowing the keybindings code to see the event enables it to
process it for its internal modifier-only-pressed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
7901b98808 display: Expose window_grab_modifiers
Since commit c255031b6d we pass scroll-events through to
the compositor if the window_grab_modifiers are pressed;
in order to allow gnome-shell to check for those events,
expose the struct member as a MetaDisplay property.

Also take the opportunity to pick a more generic name, now
that the modifier is no longer used exclusively for mouse
clicks (unless we maintain the notion of scroll events as
button 4 and 5 "clicks").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Jonas Ådahl
30e1c51b33 Change all g_memdup() to g_memdup2()
Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
2021-02-04 19:16:28 +01:00
Sebastian Keller
a9d9aee6c0 kms/impl-device-atomic: Fix blob_ids array leak
release_blob_ids() only destroys the DRM property blobs, but does not
free the array they were stored in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1699>
2021-02-02 14:41:52 +00:00
Jonas Ådahl
ca22622517 screen-cast/src: Only allocate DMA buffers if other end supports it
The other end of the PipeWire stream can set the buffer data type to a
bitmask of supported buffer types. We should respect this, and not
attempt to allocate a DMA buffer if it isn't asked for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
ca95ccdef0 screen-cast/src: Always first set spa buffer data to NULL
We use that elsewhere for sanity checking, and it's not initialized to
anything, so might be pointing to invalid memory if buffer allocation
failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
08ad107df5 screen-cast/src: Handle failing to allocate shm buffers
Don't leak the file descriptors, and don't fall over when trying to
clean up buffers that failed to allocate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
70d9a7b4bf screen-cast/src: Pass dimension and stride when needed
Instead of getters, pass the width, height and stride around when
relevant. This also removes the redudant "stream_size" and
"stream_height" variables from the src struct, as they are already part
of the video format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Olivier Fourdan
a2e2cfe437 window/x11: Check before freezing commits
Now that we have a window actor API that can hint whether or not the
window actor would support freezing commits, use it to avoid freezing
Xwayland commit on actors that will not be thawed after paint.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1615
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Olivier Fourdan
df5a5d279d window-actor: Add a new can_freeze_commits() API
Mutter freezes Xwayland commits when resizing windows, and thaw them in
the window actors' after_paint() for X11.

Yet, after_paint() could be never called, as when a new window is mapped
while the overview is active in gnome-shell.

As a result, the content of the X11 window will remain invisible to the
overview.

Add a new window actor API to tell whether commits can be frozen. For
Wayland window actors, this always return FALSE, whereas for X11 window
actors, it checks whether the Clutter actor is mapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Jonas Ådahl
cda26b493e wayland: Only use async configured geometry if actually changed
When (un)maximizing, (un)fullscreening, the move/resize action is
flagged with 'ACTION_MOVE' and 'ACTION_RESIZE' , while e.g.
'appears-focus' does not.

When a client misbehaved and didn't immediately reply to a configure
request with a commit with the corresponding ack_configure, the
following commit would trigger a oddly timed move, making the window
appear to move back to a previous position.

Avoid this issue by only carrying over the target window position if the
configuration actually contained a new position.

We cannot only rely on the flags however, as e.g. a new position should
be respected during interactive resize, even though only 'ACTION_RESIZE'
is passed in such scenarios.

Do the same for the size, except if the window state dictates that the
size is fixed to a certain size, e.g. being fullscreen or maximized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1445>
2021-01-30 09:49:13 +00:00
Jonas Ådahl
b2482a2069 cogl: Add CoglX11Onscreen interface
Mutter needs to fetch the X11 Window ID from the onscreen and did that
by using an X11 specific API on the CoglOnscreen, where the X11 type was
"expanded" (Window -> uint32_t). Change this by introducing an interface
called CoglX11Onscreen, implemented by both the Xlib and GLX onscreen
implementations, that keeps the right type (Window), while avoiding X11
specific API for CoglOnscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0fdf6a6405 cogl/onscreen: Move direct scanout to CoglOnscreen class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
fe72876b20 cogl/onscreen: Make swap_buffer/region CoglOnscreen class vfuncs
No need to go via the "winsys" vtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
60e1516b1c cogl/gl-framebuffer: Split up into FBO and back drivers
One is for when we're painting to the back buffer (onscreen), and the
other when we're painting to an FBO (offscreen).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0936d7bd06 cogl/onscreen: Use CoglFramebufferClass::allocate() to init
Instead of calling "init_onscreen()" on two different separate vtables
from the allocate() funtion, just have the CoglOnscreen sub types
themself implement allocate() and initialize in there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0b568b68c6 Make all CoglOnscreen sub types inherit CoglOnscreen
Thins means that e.g. MetaOnscreenNative now inherits CoglOnscreenEgl,
which inherits CoglOnscreen which inherits CoglFramebuffer, all being
the same GObject instance.

This makes it necessary to the one creating the onscreen to know what it
wants to create. For the X11 backend, the type of renderer (Xlib EGL or
GLX) determines the type, and for the native backend, it's currently
always MetaOnscreenNative.

The "winsys" vfunc entries related to onscreens hasn't been moved yet,
that will come later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
73dc19fc58 onscreen/native: Remove uselses size check
The comment made no sense in the context it was in, and the size check
can never fail as we create views directly from mode dimenisons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
3e4ece50d3 renderer/native: Move out CoglOnscreen code to separate file
To get meta-renderer-native.c down to a bit more managable size, and to
isolate "onscreen" functionality from other (at least partly), move out
the things related to CoglOnscreen to meta-onscreen-native.[ch].

A couple of structs are moved to a new shared header file, as
abstracting those types (e.g. (primary, secondary) render devices) will
be dealt with later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
b5afa6db23 cogl/onscreen: Change to follow mutters naming convention
The mutter naming convention for types and their instance variables is:

Type name:
   [Namespace][BaseName][SubType]

Instance name:

   [base_name]_[sub_type]

This means that e.g. CoglOnscreenGLX is renamed CoglOnscreenGlx, and
glx_onscreen is renamed onscreen_glx. This is in preparation for
GObjectification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
a057432e3d cogl/glx: Move onscreen code to a separate file
Mostly in order to untangle it from the rest, preparing turning it into
a GObject.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
7cf24ccc34 cogl/onscreen/egl: Move struct to C file
In praparation for declaring the EGL onscreen part using G_DECLARE*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
d0831cbbcd cogl: Move CoglOnscreen struct to C file
That means all sub types need to use helper methods, so make them do
that too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:44 +00:00
Jonas Ådahl
b55b26661f workspace: Downgrade assert to warning when adding window
An extension can by accident cause us to end up in a state where we try
to add the same window to a workspace twice. When this happens we
shouldn't crash, but instead complain loudly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/992
Related: https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/157
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1692>
2021-01-29 17:14:08 +00:00
Thomas Mühlbacher
180e62519b tests/monitor-config: Improve debugging output
Make it easier to find out what went wrong with `migrated_data` by
having it included in the debug logs.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
88647ae23c monitor-config: Free meta_monitor_spec safely
`g_free()` alone can't help if the value it gets is `NULL` + the offset
of the struct members.

This prevents gnome-shell from segfaulting if `monitors.xml` contains
invalid XML.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
70cdd72040 monitor-config-store: Properly escape monitor spec
Makes sure that monitor specs which may be read from EDID data do not
contain characters that are invalid in XML. Makes it possible to restore
monitor configs of monitor models with characters such as '&' in them.

To make this change not break any tests, the sample monitor configs need
to be adjusted as well. Apostrophes don't strictly have to be escaped in
XML text elements. However, we now do escape the elements in
`<monitorspec>` specifically.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Sebastian Keller
c9aa43aa7a wayland/gtk-shell: Add an explicit gtk-shell surface release request
Previously the wl_resource and MetaWaylandGtkSurface corresponding to
any client gtk_surface have been kept around until the exit of the
client due to the client side destroy method not signaling the
destruction to the server. Ideally the protocol would have specified a
destroy request marked as destructor to handle this automatically,
however this is no longer possible due to the destroy method being
implicitly generated in the absence of an explicit request in the
protocol. Adding a destroy request marked as destructor now would
generate a new destroy method that unconditionally would send the
request to the server, which would break clients running on servers not
supporting that request.

So instead of modifying the destroy request add a new "release"
destructor, that indicates to the server that it can release the
resource. This can be optionally be used by clients depending on the
server protocol version.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Sebastian Keller
b41c4aec26 wayland/gtk-shell: Fix MetaWaylandGtkSurface leak on surface destroy
The MetaWaylandSurface corresponding to a MetaWaylandGtkSurface can be
destroyed before the MetaWaylandGtkSurface is destroyed. In its destroy
function MetaWaylandSurface however was unsetting the destructor of the
correspnding resource along with the gtk_surface1 interface
implementation. This was done to prevent further gtk_surface1 requests
on a NULLed MetaWaylandSurface, if it has been destroyed before the
MetaWaylandGtkSurface.

It would be enough to just unset the resource implementation, while
keeping the destructor to fix this leak. However the following commit
will rely on the implementation being available after the
MetaWaylandSurface has been destroyed. So instead introduce NULL checks
for all functions that can be called on the gtk_surface1 interface and
do not unset the implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Jonas Ådahl
893c0cd2f9 screen-cast/area-src: Handle monitors changes here too
Like with the monitor source, we need to reattach to the new views after
monitor changes, otherwise the screen cast will get stuck.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
e877b06fdd screen-cast/monitor-stream: Don't fall apart when monitor changes
If the monitor configuration changed, even though the streamed monitor
didn't change, we'd still fail to continue streaming, as we failed to
update the stage watchers, meaning we wouldn't be notified about when
the stage views were painted.

Fix this by reattaching the stage watches, i.e. update the painted
signalling listeners to listen to the right views, when monitor changes
happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
9f6a441665 screen-cast-stream: Add getter for stream src
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
036ce1f28e native/cogl-utils: Minor macro cleanup
We don't use 'pragma once' in mutter, and cogl/cogl.h isn't a system
include.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
caa798c672 native/cogl-utils: Fix license header
The intention was to add a license header the same as other files in the
mutter backend files, so make it so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
1d4e535e7a clutter/stage: Remove 'paint' argument in capture_into()
There are more suitable API when the stage needs to be actually painted
into something. Nothing actually used this anymore too, so remove this
functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
662e29990a input-mapper: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00