Compare commits

...

97 Commits

Author SHA1 Message Date
Ray Strode
625ea86672 MetaShapedTexture: save and restore textures on suspend
The proprietary nvidia driver garbles GPU memory on suspend.

In order to workaround that limitation, this commit copies all
textures to host memory on suspend and restores them on resume.

One complication comes from external textures (such as those
given to us by Xwayland for X clients).  We can't just restore
those textures, since they aren't writable.

This commit addresses that complication by keeping a local texture
around for those external textures, and using it instead for parts
of the window that haven't been redrawn since resume.
2019-01-15 11:54:58 -05:00
Ray Strode
395d463c08 background: purge all background textures on suspend
This commit makes sure all background textures get purged
on suspend, which is important for nvidia.
2019-01-15 11:37:54 -05:00
Ray Strode
2fc0652886 backends/native: update cursor on resume
As mentioned in a previous commit, the proprietary NVIDIA
driver garbles memory on suspend. That behavior, means that
the cursor gets corrupted on suspend.

This commit forces the cursor to redraw itself when the
logind session becomes active (on VT switch and resume).
2019-01-15 11:37:54 -05:00
Ray Strode
6ff42c2ab2 backends/native: update glyph cache on resume
As mentioned in a previous commit, the proprietary NVIDIA
driver garbles memory on suspend. That behavior, means that
clutter's glyph cache (which is stored in GPU memory) gets
corrupted on suspend.

This commit ensures the glyph cache is blown away when
the logind session becomes active (on VT switch and resume).
2019-01-15 11:37:53 -05:00
Ray Strode
f9907d1978 backends/native: emit gl-video-memory-purged when becoming active
The proprietary NVIDIA driver garbles memory on suspend.  In order
to work around that limitation, mutter needs to refresh all its
textures on resuem.

This commit lays the way toward doing that by emitting the
"gl-video-memory-purged" signal when the compositor becomes active
by logind (which happens on VT switch and on resume).
2019-01-15 11:37:39 -05:00
Ray Strode
45c5f557bd wayland: force X clients to redraw on resume
On nvidia, the textures backing Xwayland client window contents get
corrupted on suspend.  Xwayland currently doesn't handle this situation
itself.

For now, in order to work around this issue, send an empty output
change event to Xwayland.  This will cause it to force Expose events
to get sent to all clients and get them to redraw.
2019-01-15 11:37:08 -05:00
Ray Strode
53d63ea72b backend: add signals for reporting suspend and resume
This commit adds "suspending" and "resuming" signals
to MetaBackend.

It's preliminary work needed for tracking when to purge
and recreate all textures (needed by nvidia).
2019-01-15 11:35:08 -05:00
Ray Strode
f6e8e867b4 backend: switch to using generated logind proxy
Right now we listen to prepare-for-sleep using
raw gdbus calls.

This commit switches it over to use a generated
proxy, which will become useful in a future commit,
for adding suspending inhibitors.
2019-01-15 11:35:08 -05:00
Ray Strode
a566c6677c cogl: add new UNSTABLE_TEXTURES feature
The proprietary nvidia driver garbles texture memory on suspend.

Before we can address that, we need to be able to detect it.

This commit adds a new UNSTABLE_TEXTURES feature that gets set if
the proprietary nvidia driver is in use.
2019-01-15 11:35:08 -05:00
Ray Strode
cb06e1ef33 fixup! wayland: Don't crash if wl_output resource is destroyed after being removed 2019-01-14 15:44:18 -05:00
Ray Strode
a30c8fb83d Revert "window/wayland: Always update monitor for non-user ops"
This reverts commit e0db7d75c924a07da2b366c9c9e5075dd7bea6e6.
2019-01-14 10:08:04 -05:00
Ray Strode
e3a42dc873 screen-cast-cursor-side-channel.patch 2019-01-14 10:06:59 -05:00
Jonas Ådahl
efd7b8987f 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.
2019-01-14 10:06:58 -05:00
Jonas Ådahl
c96aacabf7 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.
2019-01-14 10:06:58 -05:00
Ray Strode
af61b66953 shaped-texture-get-image-via-offscreen.patch 2019-01-14 10:06:58 -05:00
Jonas Ådahl
baf11d2471 window: Fix introspection warnings
(transfer none) was added for fundamental types, which can't be
transfered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/356
(cherry picked from commit 781ec74fd2)
2019-01-14 10:06:57 -05:00
Olivier Fourdan
01c763470e window: Expose the client type in the API
We already have the enum exposed, but no accessor function.

Add `meta_window_get_client_type()` which returns the
`MetaWindowClientType` of a window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit 7a5e0c7824)
2019-01-14 10:06:56 -05:00
Olivier Fourdan
c9065da442 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
(cherry picked from commit c786b6c13c)
2019-01-14 10:06:56 -05:00
Olivier Fourdan
5f8a4f560f window: Add window id
Generate a unique 64bit window-id which is unrelated to any windowing
backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit bbcb66ddf4)
2019-01-14 10:06:56 -05:00
Olivier Fourdan
47577432e4 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
(cherry picked from commit ec25f3a6b7)
2019-01-14 10:06:56 -05:00
Olivier Fourdan
4ee9462fcd 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
(cherry picked from commit dbe7279c7f)
2019-01-14 10:06:55 -05:00
Olivier Fourdan
c275c1de52 window-actor: Implement MetaScreenCastWindow interface
Implements the `MetaScreenCastWindow` interface for screen-cast
`RecordWindow` mode.

`meta_window_actor_capture_into()` implementation is still pretty crude
and doesn't take into account subsurfaces and O-R windows so menus,
popups and other tooltips won't show in the capture.

This is left as a future improvement for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit 931934511c)
2019-01-14 10:06:55 -05:00
Olivier Fourdan
a9965bb57a 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
(cherry picked from commit 20c9ca25c0)
2019-01-14 10:06:55 -05:00
Olivier Fourdan
9cc2fa2526 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
(cherry picked from commit f64eba57ce)
2019-01-14 10:06:55 -05:00
Olivier Fourdan
f439b0432d 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.
2019-01-14 10:06:54 -05:00
Olivier Fourdan
ab39558506 clutter: Keep a device reference with events
If a device (virtual or real) is removed while there are remaining
events queued for that device, the event loop may try to access the
event freed memory.

To avoid the issue, add a reference to the device when the event is
created or copied, and remove the reference once the device is freed.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/393
2019-01-14 10:06:54 -05:00
Olivier Fourdan
9d72eeeb58 clutter/evdev: Use clutter_event_set_device()
Use the relevant clutter device API `clutter_event_set_device()` instead
of setting the device directly in the event field.
2019-01-14 10:06:54 -05:00
Jonas Ådahl
eea0a2b11d 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-14 10:06:53 -05:00
Jonas Ådahl
bcacaf4562 renderer/native: Also wrap flip closures for EGLStreams
When using the EGLStream backend, the MetaRendererNative passed a
GClosure to KMS when using EGLStreams, but KMS flip callback event
handler in meta-gpu-kms.c expected a closure wrapped in a closure
container, meaning it'd instead crash when using EGLStreams. Make the
flip handler get what it expects also when using EGLStreams by wrapping
the flip closure in the container before handing it over to EGL.

https://bugzilla.gnome.org/show_bug.cgi?id=790316
(cherry picked from commit 8ee14a7cb7)
2019-01-14 10:06:53 -05:00
Miguel A. Vico
5ae7a67b36 wayland: Create EGLStream-backed buffers through wl_eglstream_controller
One of the current limitations of EGLStreams is that there's no way to
resize a surface consumer without re-creating the entire stream.

Therefore, while resizing, clients will send wl_surface::attach requests
so the compositor can re-create its endpoint of the stream, but no
buffer will be available actually. If we proceed with the rest of the
attach operation we'll be presenting an empty buffer.

In order to fix this, a separate wl_eglstream_controller protocol has
been introduced that clients can use to request a stream re-creation
without overloading wl_surface::attach for that purpose.

This change adds the required logic to create the corresponding
wl_eglstream_controller global interface that clients can bind to.

Whenever a client requests a stream to be created, we just need to
create and realize the new EGLStream buffer. The same buffer resource
will be given at a later time to wl_surface::attach, whenever new
content is made available by the application, so we can proceed to
acquire the stream buffer and update the surface state.

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit 435b3c4bdb)
2019-01-14 10:06:53 -05:00
Miguel A. Vico
7d8ff61069 wayland: Realize dmabuf buffers before trying to attach them
Commit 22723ca37 moved buffer realization to
meta_wayland_surface_commit() so that it wouldn't be part of
meta_wayland_buffer_attach().

However, creation of dmabuf buffers would call into
meta_wayland_buffer_attach() directly without realizing the buffer
first. attach() would then fail and mutter would effectively shut down
any clients using the zwp_linux_dmabuf protocol (note that if such
client was Xwayland, mutter itself would shut down as well).

Add the missing bit in order to make zwp_linux_dmabuf protocol work
again.

(cherry picked from commit 54709c16b5)
2019-01-14 10:06:53 -05:00
Miguel A. Vico
79b3f56bd3 wayland: Always realize buffers at surface commit time
Clients using EGLStream-backed buffers will expect the stream to be
functional after wl_surface::attach(). That means the compositor-side
stream must be created and a consumer attached to it.

To resolve the above, this change realizes buffers even when the attach
operation is deferred (e.g. synchronized subsurfaces).

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit 22723ca371)
2019-01-14 10:06:52 -05:00
Miguel A. Vico
e371bacd7f wayland-buffer: Create EGLStream texture at buffer_realize time
When dealing with synchronized subsurfaces, we defer buffer attachments
until the parent surface state is applied.

That causes interaction issues with EGLStream backed buffers, as the
client expects the compositor-side stream to be functional after it
requests a wl_surface::attach.

By allowing the compositor to realize buffers without attaching them, we
could resolve the issue above if we define a realized EGLStream buffer
as a functional EGLStream (EGLStream + attached consumer).

This change moves the texture consumer creation part from the attach
function to the realize one.

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit edd3634bb5)
2019-01-14 10:06:52 -05:00
Miguel A. Vico
62fd182272 renderer/native: Choose first EGL config for non-GBM backends
Commit 712ec30cd9 added the logic to only
choose EGL configs that match the GBM_FORMAT_XRGB8888 pixel format.
However, there won't be any EGL config satisfying such criteria for
non-GBM backends, such as EGLDevice.

This change will let us choose the first EGL config for the EGLDevice
backend, while still forcing GBM_FORMAT_XRGB8888 configs for the GBM
one.

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

(cherry picked from commit 1bf2eb95b5)
2019-01-14 10:06:52 -05:00
Florian Müllner
f48c8c5824 xprops: Make sure text_property_to_utf8() returns UTF8
Commit 840378ae68 changed the code to use XmbTextPropertyToTextList()
instead of gdk_text_property_to_utf8_list_for_display(), but didn't
take into account that the replacement returns text in the current
locale's encoding, while any callers (rightfully) expect UTF8.

Fix this by converting the text if necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/227
2019-01-14 10:06:52 -05:00
Florian Müllner
e3d7b3828e x11/window-props: Do not convert WM_NAME
The WM_NAME property is of type TEXT_PROPERTY, which is supposed to be
returned as UTF-8. Commit 840378ae68 broke that assumption, resulting
in crashes with non-UTF8 locales; however the "fix" of converting from
LATIN1 to UTF8 is wrong as well, as the conversion will spit out garbage
when the input encoding isn't actually LATIN1.

Now that the original issue in text_property_to_utf8() has been fixed,
we can simply revert the relevant bits of commit d62491f46e.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/227
2019-01-14 10:06:51 -05:00
Jonas Ådahl
6e14403ac8 wayland/gtk-shell: Handle requests after toplevel was unmanaged
As with xdg-toplevel, a gtk-surface can be unmanaged by the compositor
without the client knowing about it, meaning the client may still send
updates and make requests. Handle this gracefully by ignoring them. The
client needs to reset all the state anyway, if it wants to remap the
same surface.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit ca5b27baf5)
2019-01-14 10:06:51 -05:00
Jonas Ådahl
ec2471a356 wayland/legacy-xdg-shell: Handle requests after toplevel was unmanaged
As with xdg-toplevel proper, a legacy xdg-toplevel can be unmanaged by
the compositor without the client knowing about it, meaning the client
may still send updates and make requests. Handle this gracefully by
ignoring them. The client needs to reassign the surface the legacy
xdg-toplevel role again, if it wants to remap the same surface, meaning
all state would be reset anyway.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit 64df627688)
2019-01-14 10:06:51 -05:00
Jonas Ådahl
30820ab19e wayland/legacy-xdg-shell: Cache frame callbacks if toplevel is unmanaged
A toplevel window can be unmanaged without the client knowing it (e.g. a
modal dialog being unmapped together with its parent. When this has
happened, take frame callbacks queued on a commit and cache them on the
generic surface queue. If the toplevel is to be remapped because the
surface was reassigned the toplevel role, the cached frame callbacks
will be queued on the surface actor and dispatched accordingly.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit a740f50cd7)
2019-01-14 10:06:51 -05:00
Jonas Ådahl
58cc091134 wayland/xdg-shell: Handle requests after toplevel was unmanaged
A window can be unmanaged without asking the client to do it, for
example as a side effect of a parent window being unmanaged, if the
child window was a attached dialog.

This means that the client might still make requests post updates to it
after that it was unmapped. Handle this gracefully by NULL-checking the
surface's MetaWindow pointer. We're not loosing any state due to this,
as if the client wants to map the same surface again, it needs to either
reassign it the toplevel role, or reset the xdg-toplevel, both resulting
in all state being lost anyway.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit 5fd0f62a62)
2019-01-14 10:06:50 -05:00
Jonas Ådahl
0105dca586 wayland/xdg-shell: Cache frame callbacks if toplevel is unmanaged
A toplevel window can be unmanaged without the client knowing it (e.g. a
modal dialog being unmapped together with its parent. When this has
happened, take frame callbacks queued on a commit and cache them on the
generic surface queue. If the toplevel is to be remapped, either because
the surface was reassigned the toplevel role, or if it was reset and
remapped, the cached frame callbacks will be queued on the surface actor
and dispatched accordingly.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit 80d420ff43)
2019-01-14 10:06:50 -05:00
Jonas Ådahl
17dd4d32da wayland/xdg-shell: Cache pending frame callbacks on popup reset
A popup can be reset, and when that happens, window and actor are
destroyed, and won't be created again unless it is reassigned the
popup role.

If a client queued frame callbacks when resetting a popup, the frame
callbacks would be left in the pending state, as they were not queued on
the actor, meaning we'd hit an assert about the frame callbacks not
being handled. Fix this by caching them on the MetaWaylandSurface, so
that they either are cleaned up on destruction, or queued on the actor
would the surface be re-assigned the popup role.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit 407d62943c)
2019-01-14 10:06:50 -05:00
Jonas Ådahl
5b95f809ca wayland/surface: Add API to cache frame callbacks
Sometimes it may be useful for roles to put callbacks in the generic
surface frame callback queue. The surface frame callback queue will
either eventually be processed on the next surface role assignment that
places the frame callbacks in a role specific queue, processed at some
other point in time by a role, or cleaned up on surface destruction.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit 0ace58d05f)
2019-01-14 10:06:49 -05:00
Jonas Ådahl
3934793255 wayland/xdg-shell: Queue frame callbacks on new actor after resetting
When a xdg-toplevel is reset, the window and actor are recreated, and
all state is cleared. When this happened, we earlied out from the
xdg-toplevel commit handler, which would mean that if the client had
queued frame callbacks when resetting, they'd be left in the pending
commit state, later hitting an assert as they were not handled.

Fix this by queuing the frame callbacks no the new actor, so that they
are emitted whenever the actor is eventually painted.

https://gitlab.gnome.org/GNOME/mutter/issues/240
(cherry picked from commit d791710197)
2019-01-14 10:06:49 -05:00
Olivier Fourdan
f3655737bc window: unmanage dialog when clearing transient_for
On Wayland, xdg-foreign would leave a modal dialog managed even after
the imported surface is destroyed.

This is sub-optimal and this breaks the atomic relationship one would
expect between the parent and its modal dialog.

Make sure we unmanage the dialog if transient_for is unset even for
Wayland native windows.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/174
Related: https://gitlab.gnome.org/GNOME/mutter/issues/221

(cherry picked from commit b443bd42ac)
2019-01-14 10:06:49 -05:00
Florian Müllner
728ed4fe38 idle-monitor: Don't try to auto-start SessionManager
The interface is provided by gnome-session and not activatable.

https://gitlab.gnome.org/GNOME/mutter/issues/134

(cherry picked from commit 2319cd9c40)
2019-01-14 10:06:49 -05:00
Sebastian Keller
bcba6571f0 backends/x11: Only free cursor if it was created successfully
XcursorLibraryLoadCursor can return 'None' if the current cursor theme
is missing the requested icon. If XFreeCursor is then called on this
cursor, it generates a BadCursor error causing gnome-shell to crash.

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

(cherry picked from commit 1bfa20929b)
2019-01-14 10:06:48 -05:00
Sam Spilsbury
4525a74e59 window: Return -1 if meta_window_get_monitor is called on an unmanaged window
As opposed to crashing. In this case, letting the caller deal with
it is the best policy, since this is public API.

https://bugzilla.gnome.org/show_bug.cgi?id=788834

(cherry picked from commit 8626c69c2f)
2019-01-14 10:06:48 -05:00
Jonas Ådahl
0dd58540b2 wayland/keyboard: Create a separate keymap shm file per resource
By using the shm file when sending the keymap to all clients, we
effectively allows any client to change the keymap, as any client has
the ability to change the content of the file. Sending a read-only file
descriptor, or making the file itself read-only before unlinking, can
be worked around by the client by using chmod(2) and open(2) on
/proc/<pid>/<fd>.

Using memfd could potentially solve this issue, but as the usage of
mmap with MAP_SHARED is wide spread among clients, such a change can
not be introduced without causing wide spread compatibility issues.

So, to avoid allowing clients to interfere with each other, create a
separate shm file for each wl_keyboard resource when sending the
keymap. We could eventually do this per client, but in most cases,
there will only be one wl_keyboard resource per client anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=784206
2019-01-14 10:06:48 -05:00
Alex Villacís Lasso
ac27fca3ef 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

(cherry picked from commit f7af32a3ea)
2019-01-14 10:06:48 -05:00
Iain Lane
99bbe001f5 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

(cherry picked from commit deb541ef5a)
2019-01-14 10:06:47 -05:00
Iain Lane
30c09c84c4 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

(cherry picked from commit 29cc526e2e)
2019-01-14 10:06:47 -05:00
Aaron Plattner
81c63df853 gpu-kms: Don't crash if drmModeGetResources returns NULL
DRM drivers can be opened by meta_launcher_open_restricted() even if they don't
implement modesetting. However, drmModeGetResources() will return NULL.

Check whether that happened in meta_gpu_kms_new() and return with an error
instead of crashing.

Fixes #223.
2019-01-14 10:06:47 -05:00
Jonas Ådahl
3104abba57 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

(cherry picked from commit 4d465eac08)
2019-01-14 10:06:47 -05:00
Florian Müllner
13eb4f51c7 tests: Add "closed-transient" test
When a transient window is destroyed, the expected behavior is that
focus is passed to the ancestor if possible. This was broken for
quite a while until the previous commit, so add a test case to make
sure it doesn't happen again.

https://gitlab.gnome.org/GNOME/mutter/issues/15

(cherry-picked from commit 137f22236c)
2019-01-14 10:06:46 -05:00
Florian Müllner
7969c473ac window: Explicitly exclude unmanaging window from focus again
Since commit b3b9d9e16 we no longer have to pass the unmanaging window
to make sure we don't try to focus it again, however the parameter also
influences the focus policy by giving ancestors preference over the normal
stack order.

https://gitlab.gnome.org/GNOME/mutter/issues/15

(cherry picked from commit d99442d6e6)
2019-01-14 10:06:46 -05:00
Florian Müllner
a83e72d7c1 window: Don't refuse to move focus to the grab window
We refuse to move focus while a grab operation is in place. While this
generally makes sense, there's no reason why the window that owns the
grab shouldn't be given the regular input focus as well - we pretty
much assume that the grab window is also the focus window anyway.

In fact there's a strong reason for allowing the focus change here:
If the grab window isn't the focus window, it probably has a modal
transient that is focused instead, and a likely reason for the focus
request is that the transient is being unmanaged and we must move
the focus elsewhere.

https://gitlab.gnome.org/GNOME/mutter/issues/15

(cherry picked from commit 148da24f95)
2019-01-14 10:06:46 -05:00
Jonas Ådahl
910c4e9fe7 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

(cherry picked from commit 6e953e2725)
2019-01-14 10:06:45 -05:00
Olivier Fourdan
2fb5b65e94 wayland: Clean up xwayland grabs even if surface is gone
If the surface is gone before `meta_xwayland_keyboard_grab_end()` is
called, we would bail out early leaving an empty grab, which will cause
a segfault as soon as a key is pressed later on.

Make sure we clean up the keyboard grab even if the surface is gone.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/255
(cherry picked from commit 252dd52439)
2019-01-14 10:06:45 -05:00
Olivier Fourdan
e00d6c6273 wayland: No xdg-output events without a logical monitor
To avoid a known race condition in the wl_output protocol documented in
https://phabricator.freedesktop.org/T7722, mutter delays the `wl_output`
destruction but nullify the `logical_monitor` associated with the
`wl_output` and the binding routine `bind_output()` makes sure not to
send wl_output events if the `logical_monitor` is `NULL` (see commit
1923db97).

The binding routine for `xdg_output` however does not check for such a
condition, hence if the output configuration changes while a client is
binding to xdg-output (typically Xwayland at startup), mutter would
crash while trying to access the `logical_monitor` which was nullified
by the change in configuration.

Just like `bind_output()` does for wl_output, do not send xdg-output
events if there is no `logical_monitor` yet.

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

(cherry picked from commit 68ec9ac017)
2019-01-14 10:06:45 -05:00
Olivier Fourdan
733ab3b2bc wayland: Nullify monitor resources when updating outputs
If a client asks for xdg-output before we have set the output's logical
monitor, we would end up crashing with a NULL pointer dereference.

Make sure we clear the resource's user data when marking an output as
inert on monitor change so that we don't end up with a Wayland output
without a logical monitor.

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

(cherry picked from commit 48eaa36d41)
2019-01-14 10:06:45 -05:00
Jonas Ådahl
a208d7c33e window/wayland: Don't recursive indefinitely when updating monitor
When we update the main monitor, there is a rule that makes it so that
popup windows use the same main monitor as their parent. In the commit
f4d07caa38 the call that updates and
fetches the main monitor of the toplevel accidentally changed to update
from itself, causing a indefinite recursion eventually resulting in a
crash.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/279
(cherry picked from commit e191c21e04)
2019-01-14 10:06:44 -05:00
Ray Strode
37bbea649b 0002-window-Force-update-monitor-on-hot-plugs.patch 2019-01-14 10:06:44 -05:00
Ray Strode
4035955fc0 0001-window-Pass-flag-to-meta_window_update_monitor-inste.patch 2019-01-14 10:06:44 -05:00
Olivier Fourdan
a8db59908f window/wayland: Always update monitor for non-user ops
meta_window_wayland_update_main_monitor() would skip the monitor update
if the difference in scale between the old and the new monitor would
cause another monitor change.

While this is suitable when the monitor change results from a user
interactively moving the surface between monitors of different scales,
this can leave dangling pointers to freed monitors when this is
triggered by a change of monitor configuration.

Make sure we update the monitor unconditionally if not from a user
operation.

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

(cherry picked from commit a3da4b8d5b)
2019-01-14 10:06:43 -05:00
Olivier Fourdan
a477c73a97 window/wayland: Always update monitor for non-user ops
meta_window_wayland_update_main_monitor() would skip the monitor update
if the difference in scale between the old and the new monitor would
cause another monitor change.

While this is suitable when the monitor change results from a user
interactively moving the surface between monitors of different scales,
this can leave dangling pointers to freed monitors when this is
triggered by a change of monitor configuration.

Make sure we update the monitor unconditionally if not from a user
operation.

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

(cherry picked from commit a3da4b8d5b)
2019-01-14 10:06:43 -05:00
Olivier Fourdan
ae228c0556 wayland: Allow Xwayland grabs on selected apps
Allow Xwayland grabs on a selected set of X11 applications.
2019-01-14 10:06:43 -05:00
Jonas Ådahl
978cb5b21c 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.
2019-01-14 10:06:43 -05:00
Jonas Ådahl
e792eca2f5 Make screen cast and remote desktop non-experimental
It's time to make this feature more accessible by not requiring editing
an array in gsettings.
2019-01-14 10:06:42 -05:00
Jonas Ådahl
b9614f0797 virtual-input/evdev: Translate from button codes internal to evdev
Sending button events to a ClutterVirtualInputDevice, the API expects
button codes to be of the internal clutter type. The evdev
implementation incorrectly assumed it was already prepared evdev event
codes, which was not the case. Fix the evdev implementation to translate
from the internal representation to evdev before passing it along to
ClutterSeatEvdev.
2019-01-14 10:06:42 -05:00
Ray Strode
6d7bbeddd7 mutter-pipewire-0_2-API.patch 2019-01-14 10:06:42 -05:00
Ray Strode
68570353fd mutter-search-for-libpipewire-0_2.patch 2019-01-14 10:06:42 -05:00
Jonas Ådahl
566cdcc94b 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
2019-01-14 10:04:23 -05:00
Ray Strode
37dc2e5b1b hw-cursor-on-demand-gnome-3-28.patch 2019-01-14 10:04:23 -05:00
Florian Müllner
66b9150771 gtk-shell: Work around non-working startup notifications
GNOME Shell relies on the MetaScreen::startup-sequence-changed signal,
which is tied to (lib)startup-notification and therefore X11. As a result,
when we remove the startup sequence of a wayland client, GNOME Shell will
not be notified about this until startup-notification's timeout is hit.
As a temporary stop-gap, go through XWayland even for wayland clients,
so that the signal is emitted when expected.

https://bugzilla.gnome.org/show_bug.cgi?id=768531
2019-01-14 10:04:01 -05:00
Florian Müllner
34f5bdeea3 Bump version to 3.28.3
Update NEWS.
2018-07-18 23:12:51 +02:00
Jonas Ådahl
ca71b0eb1a monitor-manager: Add back warning messages
For some reason "backends: Remove X11 idle-monitor backend" removed
unrelated warning messages for when generated monitor configurations
that should work didn't, which also made the unit tests fail.

This commit adds them back, which also makes the tests pass again.


(cherry picked from commit d9c18fd5bb)
2018-07-18 20:21:12 +00:00
Jonas Ådahl
ca4209d88a screen-cast-src: Allow negotiating the framerate
The framerate for screen cast sources was set to variable within 1 FPS
and the framerate of the monitor being screen casted. This meant that if
the sink didn't match the framerate (e.g. had a lower max framerate),
the formats would not match and a stream would not be established.

Allow letting the sink clamp the framerate range by setting it as
'unset', allowing it to be negotiated.
2018-07-13 14:39:43 +02:00
Olivier Fourdan
3288edf677 contraints: Do not constrain modals without parent
xdg-foreign clears the `transient_for` of a modal dialog when its
imported parent is destroyed, which would later cause a crash in
`constrain_modal_dialog()` because the transient `NULL`.

So in case a modal dialog has no parent, do not try to constrain it
against its parent.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/174
(cherry picked from commit 912a6f5e3f)
2018-07-10 17:03:20 +02:00
Jonas Ådahl
fe1616668e backends: Add logical monitor -> monitor -> output -> crtc ref chain
Make it so that each logical monitor has a reference to all the
monitors that are assigned to it.

All monitors has a reference to each output that belongs to it.

Each output has a reference to any CRTC it has been assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=786929


(cherry picked from commit 768ec15ea0)
2018-06-28 11:52:10 +00:00
Jonas Ådahl
7d01aec48d backends: Move MetaOutput::crtc field into private struct
No functional changes. This is only done so that changes to reference
counting can done more reliably.

https://bugzilla.gnome.org/show_bug.cgi?id=786929


(cherry picked from commit 1200182d70)
2018-06-28 11:50:37 +00:00
Marco Trevisan (Treviño)
a41d84db00 renderer-native: Don't crash if the FB surface can't be locked
(cherry picked from commit 0332b7394e)
2018-05-29 22:14:31 +00:00
Marco Trevisan (Treviño)
e73b321c2e device-manager-evdev: Add main seat to seats by default
Treat the main seat as other seats, so we don't have to handle it differently
in specific places. This was already the case before when a real device
was plugged before the startup, but not applied when hotplugging a device.


(cherry picked from commit 15f41c9f68)
2018-05-29 10:48:56 +00:00
Marco Trevisan (Treviño)
b6dc2052c3 device-manager-evdev: Free the main seat on finalize
(cherry picked from commit 2a38601b42)
2018-05-29 10:47:20 +00:00
Marco Trevisan (Treviño)
72965aaaf0 device-manager-evdev: Set and unset the stage for the main seat too
When no input devices are available on startup the device manager might be fast
enough to be constructed so that no default stage is set yet, and thus when
main seat virtual devices are created they won't have a proper stage set.
If then we plug a real device, the events that an input manager could generate
won't be associated to any stage and thus won't be processed.

We need then ensure that when we update the stage for the device manager we
(un)associate it also to the main seat devices.


(cherry picked from commit d7bdc1591f)
2018-05-29 10:46:03 +00:00
Marco Trevisan (Treviño)
2a6782dc10 clutter-device-evdev: Get devices from main seat if no real seat is set
In devices such as ARM boards there could be no input devices connected on
startup, leading to a crash when we try to process artificial events that
could be queued (as gnome-shell does when syncing pointer).

Those events still should refer to a device and, in case we don't have one
provided by libinput we should still return the core devices defined in the
main seat.


(cherry picked from commit 3e85ac8131)
2018-05-29 10:43:41 +00:00
Marco Trevisan (Treviño)
5142c8c7e7 clutter-seat-evdev: Add function to get device by id
(cherry picked from commit 5f83d9a5c8)
2018-05-29 10:43:17 +00:00
Changwoo Ryu
abc7ad8e9f wayland: Don't reset input focus on text commit
Preedit text can be active even after text commit. Resetting the input
focus will lead to unintended commit of the preedit text.

https://gitlab.gnome.org/GNOME/mutter/issues/152

Closes: #152
2018-05-26 15:26:09 +02:00
Olivier Fourdan
1a3f9a3323 frames: Allow for unknown mouse buttons
Commit 47131b1d ("frames: Handle touch events") introduced an assert to
make sure that all mouse button actions are handled in mutter.

However, mice can have a more than 5 buttons, so simply ignore the
"other" actions instead of aborting.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/160
(cherry picked from commit 473bf38753)
2018-05-25 11:35:45 +02:00
Olivier Fourdan
235c35182b wayland: update enter/leave output after effects
Compositor effects change the actor size and position, which can lead to
inconsistent output enter/leave notifications, leaving clients' surfaces
without any output set.

Update output enter/leave notifications after all compositor effects are
completed so that we give clients accurate output location.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/104
(cherry picked from commit 17a745bf81)
2018-05-22 13:01:13 +02:00
Olivier Fourdan
e4661d7870 window-actor: add new signal "effects-completed"
When using plugins, the effects will affect the MetaWindowActor size
and position.

Add a new signal "effects-completed" wired to the corresponding
MetaWindowActor which is emitted when all effects are completed so that
derived objects can be notified when all effects are completed and use
the actual size and position.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/104
(cherry picked from commit 85bbd82ae8)
2018-05-22 13:01:05 +02:00
Georges Basile Stavracas Neto
9d4c7e4e75 wayland: Compare geometries after chaining up
After 20176d03, the Wayland backend only synchronizes with the
compositor after a geometry was set, and it was different from
the current geometry.

That commit was mistakenly comparing the geometry before chaining
up, which would yield a false negative on the case where the
client didn't call set_geometry() before commit().

Fix that by caching the old geometry locally, chain up (and thus
apply the new geometry rectangle), then comparing the old and
current geometry rectangles.

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


(cherry picked from commit cf734999fb)
2018-05-18 13:53:20 +00:00
Carlos Garnacho
47131b1dad frames: Handle touch events
This is just done on wayland as it'll break horribly on X11, we let
this happen through pointer emulated events in XISelectEvents evmask
instead.

Some things had to be made slightly more generic to accomodate touch
events. The MetaFrames shall lock onto a single touch at a time, we
don't allow crazy stuff like multi-window drag nor multi-edge resizes.

https://bugzilla.gnome.org/show_bug.cgi?id=770185
2018-05-15 16:07:07 +01:00
Carlos Garnacho
51c0130645 frames: Make 1st button/motion handlers take generic events
This will ease handling of touch events through these same handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=770185
2018-05-15 16:06:59 +01:00
Olivier Fourdan
2dd9fc17c1 clutter/evdev: Don't ignore CAPS lock as modifier
Mark CAPS lock as a modifier (as it should) so that when using XKB
options to change the default behaviour of CAPS lock, the new assigned
key can by used as a sticky key as well.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/112
(cherry picked from commit 6df2b7af55)
2018-05-15 10:26:29 +02:00
Olivier Fourdan
c7a38c3139 clutter/evdev: ignore injected events from IM
Input method can inject key events, which leads to multiple reported key
press/release events for a single user action.

Ignore those events as this confuses keyboard accessibility.

(cherry picked from commit c01b099dbd)
2018-05-15 10:25:51 +02:00
Olivier Fourdan
7d52be0229 wayland: Use cursor position in logical monitor
When using two monitors size by side with different scales, once the
cursor moves from one output to another one, its size changes based on
the scale of the given output.

Changing the size of the cursor can cause the cursor area to change
output again if the hotspot is not exactly at the top left corner of the
area, causing the texture of the cursor to change, which will trigger
another output change, so on and so forth causing continuous surface
enter/leave event which flood the clients and eventually kill them.

Change the logic to use only the actual cursor position to determine if
its on the given logical monitor, so that it remains immune to scale
changes induced by output scale differences.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/83
(cherry picked from commit 67917db45f)
2018-05-14 16:08:16 +02:00
151 changed files with 5165 additions and 1789 deletions

13
NEWS
View File

@@ -1,3 +1,16 @@
3.28.3
======
* Handle touch events on server-side titlebars [Carlos; #770185]
* Fix crash with unhandled mouse buttons on titlebars [Olivier; #160]
* Fix Korean Hangul support on wayland [Changwoo; #152]
* Fix crash when taking up from suspend [Jonas; #786929]
* Fix crash with parent-less modal dialogs [Olivier; #174]
* Misc. bug fixes [Olivier, Georges; #83, #112, #150, #104,
Contributors:
Jonas Ådahl, Olivier Fourdan, Carlos Garnacho, Georges Basile Stavracas Neto,
Changwoo Ryu, Marco Trevisan (Treviño)
3.28.2
======
* Take inhibitors into account for monitoring idle [Bastien; #705942]

View File

@@ -1095,7 +1095,7 @@ clutter_event_set_device (ClutterEvent *event,
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
real_event->device = device;
g_set_object (&real_event->device, device);
}
switch (event->type)
@@ -1364,8 +1364,8 @@ clutter_event_copy (const ClutterEvent *event)
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
new_real_event->device = real_event->device;
new_real_event->source_device = real_event->source_device;
g_set_object (&new_real_event->device, real_event->device);
g_set_object (&new_real_event->source_device, real_event->source_device);
new_real_event->delta_x = real_event->delta_x;
new_real_event->delta_y = real_event->delta_y;
new_real_event->is_pointer_emulated = real_event->is_pointer_emulated;
@@ -1435,6 +1435,14 @@ clutter_event_free (ClutterEvent *event)
{
_clutter_backend_free_event_data (clutter_get_default_backend (), event);
if (is_event_allocated (event))
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
g_clear_object (&real_event->device);
g_clear_object (&real_event->source_device);
}
switch (event->type)
{
case CLUTTER_BUTTON_PRESS:
@@ -1689,7 +1697,7 @@ clutter_event_set_source_device (ClutterEvent *event,
return;
real_event = (ClutterEventPrivate *) event;
real_event->source_device = device;
g_set_object (&real_event->source_device, device);
}
/**

View File

@@ -3722,6 +3722,17 @@ clutter_stage_ensure_redraw (ClutterStage *stage)
_clutter_master_clock_start_running (master_clock);
}
/**
* clutter_stage_is_redraw_queued: (skip)
*/
gboolean
clutter_stage_is_redraw_queued (ClutterStage *stage)
{
ClutterStagePrivate *priv = stage->priv;
return priv->redraw_pending;
}
/**
* clutter_stage_queue_redraw:
* @stage: the #ClutterStage

View File

@@ -250,6 +250,9 @@ void clutter_stage_ensure_viewport (ClutterStage
CLUTTER_AVAILABLE_IN_ALL
void clutter_stage_ensure_redraw (ClutterStage *stage);
CLUTTER_AVAILABLE_IN_ALL
gboolean clutter_stage_is_redraw_queued (ClutterStage *stage);
#ifdef CLUTTER_ENABLE_EXPERIMENTAL_API
CLUTTER_AVAILABLE_IN_1_14
void clutter_stage_set_sync_delay (ClutterStage *stage,

View File

@@ -324,7 +324,6 @@ new_absolute_motion_event (ClutterInputDevice *input_device,
_clutter_evdev_event_set_time_usec (event, time_us);
event->motion.time = us2ms (time_us);
event->motion.stage = stage;
event->motion.device = seat->core_pointer;
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
event->motion.x = x;
event->motion.y = y;
@@ -332,6 +331,7 @@ new_absolute_motion_event (ClutterInputDevice *input_device,
&event->motion.x,
&event->motion.y);
event->motion.axes = axes;
clutter_event_set_device (event, seat->core_pointer);
clutter_event_set_source_device (event, input_device);
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
@@ -519,7 +519,6 @@ notify_proximity (ClutterInputDevice *input_device,
event->proximity.time = us2ms (time_us);
event->proximity.stage = CLUTTER_STAGE (stage);
event->proximity.device = seat->core_pointer;
clutter_event_set_device_tool (event, device_evdev->last_tool);
clutter_event_set_device (event, seat->core_pointer);
clutter_event_set_source_device (event, input_device);
@@ -793,10 +792,12 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev,
if (priv->main_seat->libinput_seat == NULL)
seat = priv->main_seat;
else
seat = clutter_seat_evdev_new (manager_evdev);
{
seat = clutter_seat_evdev_new (manager_evdev);
priv->seats = g_slist_append (priv->seats, seat);
}
clutter_seat_evdev_set_libinput_seat (seat, libinput_seat);
priv->seats = g_slist_append (priv->seats, seat);
}
device = _clutter_input_device_evdev_new (manager, seat, libinput_device);
@@ -919,7 +920,6 @@ clutter_device_manager_evdev_get_device (ClutterDeviceManager *manager,
ClutterDeviceManagerEvdev *manager_evdev;
ClutterDeviceManagerEvdevPrivate *priv;
GSList *l;
GSList *device_it;
manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (manager);
priv = manager_evdev->priv;
@@ -927,14 +927,10 @@ clutter_device_manager_evdev_get_device (ClutterDeviceManager *manager,
for (l = priv->seats; l; l = l->next)
{
ClutterSeatEvdev *seat = l->data;
ClutterInputDevice *device = clutter_seat_evdev_get_device (seat, id);
for (device_it = seat->devices; device_it; device_it = device_it->next)
{
ClutterInputDevice *device = device_it->data;
if (clutter_input_device_get_device_id (device) == id)
return device;
}
if (device)
return device;
}
return NULL;
@@ -1967,6 +1963,7 @@ clutter_device_manager_evdev_constructed (GObject *gobject)
xkb_context_unref (ctx);
priv->main_seat = clutter_seat_evdev_new (manager_evdev);
priv->seats = g_slist_append (priv->seats, priv->main_seat);
dispatch_libinput (manager_evdev);

View File

@@ -433,6 +433,8 @@ key_event_is_modifier (ClutterEvent *event)
case XKB_KEY_Super_R:
case XKB_KEY_Hyper_L:
case XKB_KEY_Hyper_R:
case XKB_KEY_Caps_Lock:
case XKB_KEY_Shift_Lock:
return TRUE;
default:
return FALSE;
@@ -584,6 +586,12 @@ handle_stickykeys_press (ClutterEvent *event,
}
depressed_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_DEPRESSED);
/* Ignore the lock modifier mask, that one cannot be sticky, yet the
* CAPS_LOCK key itself counts as a modifier as it might be remapped
* to some other modifier which can be sticky.
*/
depressed_mods &= ~CLUTTER_LOCK_MASK;
new_latched_mask = device->stickykeys_latched_mask;
new_locked_mask = device->stickykeys_locked_mask;
@@ -1122,6 +1130,10 @@ clutter_input_device_evdev_process_kbd_a11y_event (ClutterEvent *e
{
ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device);
/* Ignore key events injected from IM */
if (event->key.flags & CLUTTER_EVENT_FLAG_INPUT_METHOD)
goto emit_event;
if (!device_evdev->a11y_flags & CLUTTER_A11Y_KEYBOARD_ENABLED)
goto emit_event;

View File

@@ -385,7 +385,6 @@ new_absolute_motion_event (ClutterSeatEvdev *seat,
_clutter_evdev_event_set_time_usec (event, time_us);
event->motion.time = us2ms (time_us);
event->motion.stage = stage;
event->motion.device = seat->core_pointer;
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
event->motion.x = x;
event->motion.y = y;
@@ -631,7 +630,6 @@ notify_scroll (ClutterInputDevice *input_device,
_clutter_evdev_event_set_time_usec (event, time_us);
event->scroll.time = us2ms (time_us);
event->scroll.stage = CLUTTER_STAGE (stage);
event->scroll.device = seat->core_pointer;
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
/* libinput pointer axis events are in pointer motion coordinate space.
@@ -684,7 +682,6 @@ notify_discrete_scroll (ClutterInputDevice *input_device,
_clutter_evdev_event_set_time_usec (event, time_us);
event->scroll.time = us2ms (time_us);
event->scroll.stage = CLUTTER_STAGE (stage);
event->scroll.device = seat->core_pointer;
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
event->scroll.direction = direction;
@@ -813,7 +810,6 @@ clutter_seat_evdev_notify_touch_event (ClutterSeatEvdev *seat,
_clutter_evdev_event_set_time_usec (event, time_us);
event->touch.time = us2ms (time_us);
event->touch.stage = CLUTTER_STAGE (stage);
event->touch.device = seat->core_pointer;
event->touch.x = x;
event->touch.y = y;
clutter_input_device_evdev_translate_coordinates (input_device, stage,
@@ -858,6 +854,24 @@ clutter_seat_evdev_free (ClutterSeatEvdev *seat)
g_free (seat);
}
ClutterInputDevice *
clutter_seat_evdev_get_device (ClutterSeatEvdev *seat,
gint id)
{
ClutterInputDevice *device;
GSList *l;
for (l = seat->devices; l; l = l->next)
{
device = l->data;
if (clutter_input_device_get_device_id (device) == id)
return device;
}
return NULL;
}
void
clutter_seat_evdev_set_stage (ClutterSeatEvdev *seat,
ClutterStage *stage)

View File

@@ -139,6 +139,9 @@ void clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat,
void clutter_seat_evdev_sync_leds (ClutterSeatEvdev *seat);
ClutterInputDevice * clutter_seat_evdev_get_device (ClutterSeatEvdev *seat,
gint id);
ClutterTouchState * clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat,
int device_slot);

View File

@@ -185,6 +185,22 @@ clutter_virtual_input_device_evdev_notify_absolute_motion (ClutterVirtualInputDe
NULL);
}
static int
translate_to_evdev_button (int button)
{
switch (button)
{
case CLUTTER_BUTTON_PRIMARY:
return BTN_LEFT;
case CLUTTER_BUTTON_SECONDARY:
return BTN_RIGHT;
case CLUTTER_BUTTON_MIDDLE:
return BTN_MIDDLE;
default:
return button + (BTN_LEFT - 1) - 4;
}
}
static void
clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
@@ -194,30 +210,33 @@ clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *vir
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
int button_count;
int evdev_button;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
if (get_button_type (button) != EVDEV_BUTTON_TYPE_BUTTON)
evdev_button = translate_to_evdev_button (button);
if (get_button_type (evdev_button) != EVDEV_BUTTON_TYPE_BUTTON)
{
g_warning ("Unknown/invalid virtual device button 0x%x pressed",
button);
evdev_button);
return;
}
button_count = update_button_count (virtual_evdev, button, button_state);
button_count = update_button_count (virtual_evdev, evdev_button, button_state);
if (button_count < 0 || button_count > 1)
{
g_warning ("Received multiple virtual 0x%x button %s (ignoring)", button,
g_warning ("Received multiple virtual 0x%x button %s (ignoring)", evdev_button,
button_state == CLUTTER_BUTTON_STATE_PRESSED ? "presses" : "releases");
update_button_count (virtual_evdev, button, 1 - button_state);
update_button_count (virtual_evdev, evdev_button, 1 - button_state);
return;
}
clutter_seat_evdev_notify_button (virtual_evdev->seat,
virtual_evdev->device,
time_us,
button,
evdev_button,
button_state);
}

View File

@@ -76,12 +76,12 @@ _clutter_key_event_new_from_evdev (ClutterInputDevice *device,
else
sym = XKB_KEY_NoSymbol;
event->key.device = core_device;
event->key.stage = stage;
event->key.time = _time;
_clutter_xkb_translate_state (event, xkb_state, button_state);
event->key.hardware_keycode = key;
event->key.keyval = sym;
clutter_event_set_device (event, core_device);
clutter_event_set_source_device (event, device);
n = xkb_keysym_to_utf8 (sym, buffer, sizeof (buffer));

View File

@@ -92,9 +92,9 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
event2->crossing.source = stage;
event2->crossing.x = 10;
event2->crossing.y = 10;
event2->crossing.device = device;
event2->crossing.related = NULL;
clutter_event_set_device (event2, device);
clutter_input_device_update_from_event (device, event2, TRUE);
clutter_event_put (event2);
@@ -104,7 +104,7 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
clutter_actor_get_size (stage, &w, &h);
event->motion.stage = stage;
event->motion.device = device;
clutter_event_set_device (event, device);
/* called about every 60fps, and do 10 picks per stage */
for (i = 0; i < 10; i++)

View File

@@ -1043,5 +1043,6 @@ cogl_atlas_texture_vtable =
_cogl_atlas_texture_get_gl_format,
_cogl_atlas_texture_get_type,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
NULL, /* set_auto_mipmap */
NULL /* is_get_data_supported */
};

View File

@@ -263,6 +263,7 @@ typedef enum _CoglFeatureID
COGL_FEATURE_ID_TEXTURE_RG,
COGL_FEATURE_ID_BUFFER_AGE,
COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL,
COGL_FEATURE_ID_UNSTABLE_TEXTURES,
/*< private >*/
_COGL_N_FEATURE_IDS /*< skip >*/

View File

@@ -210,6 +210,9 @@ struct _CoglDriverVtable
int rowstride,
uint8_t *data);
CoglBool
(* texture_2d_is_get_data_supported) (CoglTexture2D *tex_2d);
/* Prepares for drawing by flushing the journal, framebuffer state,
* pipeline state and attribute state.
*/

View File

@@ -454,6 +454,14 @@ _cogl_sub_texture_get_type (CoglTexture *tex)
return _cogl_texture_get_type (sub_tex->full_texture);
}
static CoglBool
_cogl_sub_texture_is_get_data_supported (CoglTexture *tex)
{
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
return cogl_texture_is_get_data_supported (sub_tex->full_texture);
}
static const CoglTextureVtable
cogl_sub_texture_vtable =
{
@@ -476,5 +484,6 @@ cogl_sub_texture_vtable =
_cogl_sub_texture_get_gl_format,
_cogl_sub_texture_get_type,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
NULL, /* set_auto_mipmap */
_cogl_sub_texture_is_get_data_supported
};

View File

@@ -1542,5 +1542,6 @@ cogl_texture_2d_sliced_vtable =
_cogl_texture_2d_sliced_get_gl_format,
_cogl_texture_2d_sliced_get_type,
_cogl_texture_2d_sliced_is_foreign,
NULL /* set_auto_mipmap */
NULL, /* set_auto_mipmap */
NULL /* is_get_data_supported */
};

View File

@@ -94,6 +94,15 @@ _cogl_texture_2d_set_auto_mipmap (CoglTexture *tex,
tex_2d->auto_mipmap = value;
}
static CoglBool
_cogl_texture_2d_is_get_data_supported (CoglTexture *tex)
{
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
CoglContext *ctx = tex->context;
return ctx->driver_vtable->texture_2d_is_get_data_supported (tex_2d);
}
CoglTexture2D *
_cogl_texture_2d_create_base (CoglContext *ctx,
int width,
@@ -693,5 +702,6 @@ cogl_texture_2d_vtable =
_cogl_texture_2d_get_gl_format,
_cogl_texture_2d_get_type,
_cogl_texture_2d_is_foreign,
_cogl_texture_2d_set_auto_mipmap
_cogl_texture_2d_set_auto_mipmap,
_cogl_texture_2d_is_get_data_supported
};

View File

@@ -755,5 +755,6 @@ cogl_texture_3d_vtable =
_cogl_texture_3d_get_gl_format,
_cogl_texture_3d_get_type,
NULL, /* is_foreign */
_cogl_texture_3d_set_auto_mipmap
_cogl_texture_3d_set_auto_mipmap,
NULL /* is_get_data_supported */
};

View File

@@ -149,6 +149,8 @@ struct _CoglTextureVtable
/* Only needs to be implemented if is_primitive == TRUE */
void (* set_auto_mipmap) (CoglTexture *texture,
CoglBool value);
CoglBool (* is_get_data_supported) (CoglTexture *texture);
};
typedef enum _CoglTextureSoureType {

View File

@@ -773,5 +773,6 @@ cogl_texture_rectangle_vtable =
_cogl_texture_rectangle_get_gl_format,
_cogl_texture_rectangle_get_type,
_cogl_texture_rectangle_is_foreign,
_cogl_texture_rectangle_set_auto_mipmap
_cogl_texture_rectangle_set_auto_mipmap,
NULL /* is_get_data_supported */
};

View File

@@ -205,6 +205,15 @@ _cogl_texture_is_foreign (CoglTexture *texture)
return FALSE;
}
CoglBool
cogl_texture_is_get_data_supported (CoglTexture *texture)
{
if (texture->vtable->is_get_data_supported)
return texture->vtable->is_get_data_supported (texture);
else
return TRUE;
}
unsigned int
cogl_texture_get_width (CoglTexture *texture)
{

View File

@@ -511,6 +511,12 @@ CoglBool
cogl_texture_allocate (CoglTexture *texture,
CoglError **error);
/**
* cogl_texture_is_get_data_supported: (skip)
*/
CoglBool
cogl_texture_is_get_data_supported (CoglTexture *texture);
COGL_END_DECLS
#endif /* __COGL_TEXTURE_H__ */

View File

@@ -398,6 +398,8 @@ typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
* supported with CoglBufferAccess including write support.
* @COGL_FEATURE_DEPTH_TEXTURE: Whether #CoglFramebuffer support rendering the
* depth buffer to a texture.
* @COGL_FEATURE_UNSTABLE_TEXTURES: Whether textures require redrawing on
* resume or not.
*
* Flags for the supported features.
*
@@ -428,7 +430,8 @@ typedef enum
COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21),
COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22),
COGL_FEATURE_ONSCREEN_MULTIPLE = (1 << 23),
COGL_FEATURE_DEPTH_TEXTURE = (1 << 24)
COGL_FEATURE_DEPTH_TEXTURE = (1 << 24),
COGL_FEATURE_UNSTABLE_TEXTURES = (1 << 25)
} CoglFeatureFlags;
/**

View File

@@ -116,4 +116,7 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
int rowstride,
uint8_t *data);
CoglBool
_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d);
#endif /* _COGL_TEXTURE_2D_GL_PRIVATE_H_ */

View File

@@ -470,7 +470,12 @@ allocate_custom_egl_image_external (CoglTexture2D *tex_2d,
{
CoglTexture *tex = COGL_TEXTURE (tex_2d);
CoglContext *ctx = tex->context;
CoglPixelFormat internal_format = loader->src.egl_image_external.format;
CoglPixelFormat external_format;
CoglPixelFormat internal_format;
external_format = loader->src.egl_image_external.format;
internal_format = _cogl_texture_determine_internal_format (tex,
external_format);
_cogl_gl_util_clear_gl_errors (ctx);
@@ -854,13 +859,22 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
width,
bpp);
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
_cogl_bind_gl_texture_transient (tex_2d->gl_target,
tex_2d->gl_texture,
tex_2d->is_foreign);
ctx->texture_driver->gl_get_tex_image (ctx,
GL_TEXTURE_2D,
tex_2d->gl_target,
gl_format,
gl_type,
data);
}
CoglBool
_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d)
{
if (tex_2d->gl_target == GL_TEXTURE_EXTERNAL_OES)
return FALSE;
else
return TRUE;
}

View File

@@ -714,6 +714,7 @@ _cogl_driver_gl =
_cogl_texture_2d_gl_generate_mipmap,
_cogl_texture_2d_gl_copy_from_bitmap,
_cogl_texture_2d_gl_get_data,
_cogl_texture_2d_gl_is_get_data_supported,
_cogl_gl_flush_attributes_state,
_cogl_clip_stack_gl_flush,
_cogl_buffer_gl_create,

View File

@@ -493,6 +493,7 @@ _cogl_driver_gles =
_cogl_texture_2d_gl_generate_mipmap,
_cogl_texture_2d_gl_copy_from_bitmap,
NULL, /* texture_2d_get_data */
NULL, /* texture_2d_is_get_data_supported */
_cogl_gl_flush_attributes_state,
_cogl_clip_stack_gl_flush,
_cogl_buffer_gl_create,

View File

@@ -82,6 +82,7 @@ _cogl_driver_nop =
_cogl_texture_2d_nop_generate_mipmap,
_cogl_texture_2d_nop_copy_from_bitmap,
NULL, /* texture_2d_get_data */
NULL, /* texture_2d_is_get_data_supported */
_cogl_nop_flush_attributes_state,
_cogl_clip_stack_nop_flush,
};

View File

@@ -1180,5 +1180,6 @@ cogl_texture_pixmap_x11_vtable =
_cogl_texture_pixmap_x11_get_gl_format,
_cogl_texture_pixmap_x11_get_type,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
NULL, /* set_auto_mipmap */
NULL /* is_get_data_supported */
};

View File

@@ -502,6 +502,7 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
CoglRenderer *renderer = context->display->renderer;
CoglDisplayEGL *egl_display = context->display->winsys;
CoglRendererEGL *egl_renderer = renderer->winsys;
CoglGpuInfo *info;
context->winsys = g_new0 (CoglContextEGL, 1);
@@ -514,6 +515,16 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
if (!_cogl_context_update_features (context, error))
return FALSE;
info = &context->gpu;
if (info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
{
context->feature_flags |= COGL_FEATURE_UNSTABLE_TEXTURES;
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_UNSTABLE_TEXTURES,
TRUE);
}
if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_SWAP_REGION)
{
COGL_FLAGS_SET (context->winsys_features,

View File

@@ -832,12 +832,15 @@ update_winsys_features (CoglContext *context, CoglError **error)
{
CoglGLXDisplay *glx_display = context->display->winsys;
CoglGLXRenderer *glx_renderer = context->display->renderer->winsys;
CoglGpuInfo *info;
_COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context, FALSE);
if (!_cogl_context_update_features (context, error))
return FALSE;
info = &context->gpu;
memcpy (context->winsys_features,
glx_renderer->base_winsys_features,
sizeof (context->winsys_features));
@@ -850,7 +853,6 @@ update_winsys_features (CoglContext *context, CoglError **error)
if (glx_renderer->glXCopySubBuffer || context->glBlitFramebuffer)
{
CoglGpuInfo *info = &context->gpu;
CoglGpuInfoArchitecture arch = info->architecture;
COGL_FLAGS_SET (context->winsys_features, COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
@@ -899,7 +901,6 @@ update_winsys_features (CoglContext *context, CoglError **error)
}
else
{
CoglGpuInfo *info = &context->gpu;
if (glx_display->have_vblank_counter &&
context->display->renderer->xlib_enable_threaded_swap_wait &&
info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
@@ -921,6 +922,14 @@ update_winsys_features (CoglContext *context, CoglError **error)
}
}
if (info->vendor == COGL_GPU_INFO_VENDOR_NVIDIA)
{
context->feature_flags |= COGL_FEATURE_UNSTABLE_TEXTURES;
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_UNSTABLE_TEXTURES,
TRUE);
}
/* We'll manually handle queueing dirty events in response to
* Expose events from X */
COGL_FLAGS_SET (context->private_features,

View File

@@ -2,7 +2,7 @@ AC_PREREQ(2.62)
m4_define([mutter_major_version], [3])
m4_define([mutter_minor_version], [28])
m4_define([mutter_micro_version], [2])
m4_define([mutter_micro_version], [3])
m4_define([mutter_version],
[mutter_major_version.mutter_minor_version.mutter_micro_version])
@@ -245,7 +245,7 @@ AC_ARG_ENABLE(remote-desktop,
enable_remote_desktop=no
)
AS_IF([test "$enable_remote_desktop" = "yes"], [
MUTTER_PC_MODULES="$MUTTER_PC_MODULES libpipewire-0.1 >= 0.1.8"
MUTTER_PC_MODULES="$MUTTER_PC_MODULES libpipewire-0.2 >= 0.2.5"
AC_DEFINE([HAVE_REMOTE_DESKTOP],[1], [Defined if screen cast and remote desktop support is enabled])
])
AM_CONDITIONAL([HAVE_REMOTE_DESKTOP],[test "$enable_remote_desktop" = "yes"])
@@ -290,13 +290,24 @@ AS_IF([test "$have_native_backend" = "yes"], [
])
AM_CONDITIONAL([HAVE_NATIVE_BACKEND],[test "$have_native_backend" = "yes"])
MUTTER_WAYLAND_EGLSTREAM_MODULES="wayland-eglstream-protocols"
AC_ARG_ENABLE(egl-device,
AS_HELP_STRING([--enable-egl-device], [enable support for EGLDevice on top of KMS]),,
enable_egl_device=no
have_wayland_eglstream=no
)
AS_IF([test "$enable_egl_device" = "yes"], [
AC_DEFINE([HAVE_EGL_DEVICE],[1], [Defined if EGLDevice support is enabled])
PKG_CHECK_EXISTS([$MUTTER_WAYLAND_EGLSTREAM_MODULES], [have_wayland_eglstream=yes], [have_wayland_eglstream=no])
])
AS_IF([test "$have_wayland_eglstream" = "yes"], [
AC_DEFINE([HAVE_WAYLAND_EGLSTREAM],[1],[Defined if Wayland EGLStream protocols are available])
PKG_CHECK_MODULES(WAYLAND_EGLSTREAM, [$MUTTER_WAYLAND_EGLSTREAM_MODULES],
[ac_wayland_eglstream_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir $MUTTER_WAYLAND_EGLSTREAM_MODULES`])
AC_SUBST(WAYLAND_EGLSTREAM_DATADIR, $ac_wayland_eglstream_pkgdatadir)
])
AM_CONDITIONAL([HAVE_WAYLAND_EGLSTREAM],[test "$have_wayland_eglstream" = "yes"])
MUTTER_WAYLAND_MODULES="wayland-server >= 1.13.0"
@@ -549,6 +560,7 @@ mutter-$VERSION
Introspection: ${found_introspection}
Session management: ${found_sm}
Wayland: ${have_wayland}
Wayland EGLStream: ${have_wayland_eglstream}
Native (KMS) backend: ${have_native_backend}
EGLDevice: ${enable_egl_device}
Remote desktop: ${enable_remote_desktop}

View File

@@ -120,10 +120,6 @@
framebuffers instead of window content,
to manage HiDPI monitors. Does not
require a restart.
• “remote-desktop” — enables remote desktop support. To support
remote desktop with screen sharing,
“screen-cast” must also be enabled.
• “screen-cast” — enables screen cast support.
</description>
</key>

View File

@@ -60,7 +60,7 @@
gettext-domain="@GETTEXT_DOMAIN@">
<key name="xwayland-allow-grabs" type="b">
<default>false</default>
<default>true</default>
<summary>Allow grabs with Xwayland</summary>
<description>
Allow keyboard grabs issued by X11 applications running in Xwayland
@@ -73,7 +73,7 @@
</key>
<key name="xwayland-grab-access-rules" type="as">
<default>[]</default>
<default>['@XWAYLAND_GRAB_DEFAULT_ACCESS_RULES@']</default>
<summary>Xwayland applications allowed to issue keyboard grabs</summary>
<description>
List the resource names or resource class of X11 windows either

View File

@@ -14,6 +14,7 @@ stackingdir = $(pkgdatadir)/tests/stacking
dist_stacking_DATA = \
tests/stacking/basic-x11.metatest \
tests/stacking/basic-wayland.metatest \
tests/stacking/closed-transient.metatest \
tests/stacking/minimized.metatest \
tests/stacking/mixed-windows.metatest \
tests/stacking/set-parent.metatest \

View File

@@ -91,6 +91,12 @@ mutter_built_sources += \
gtk-text-input-protocol.c \
gtk-text-input-server-protocol.h \
$(NULL)
if HAVE_WAYLAND_EGLSTREAM
mutter_built_sources += \
wayland-eglstream-controller-server-protocol.h \
$(NULL)
endif
endif
wayland_protocols = \
@@ -114,6 +120,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES = \
backends/meta-cursor-tracker-private.h \
backends/meta-cursor-renderer.c \
backends/meta-cursor-renderer.h \
backends/meta-cursor-sprite-xcursor.c \
backends/meta-cursor-sprite-xcursor.h \
backends/meta-dnd-private.h \
backends/meta-egl.c \
backends/meta-egl.h \
@@ -151,6 +159,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES = \
backends/meta-output.h \
backends/meta-pointer-constraint.c \
backends/meta-pointer-constraint.h \
backends/meta-screen-cast-window.c \
backends/meta-screen-cast-window.h \
backends/meta-settings.c \
backends/meta-settings-private.h \
backends/meta-stage-private.h \
@@ -159,6 +169,9 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES = \
backends/meta-renderer.h \
backends/meta-renderer-view.c \
backends/meta-renderer-view.h \
backends/meta-remote-access-controller.c \
backends/meta-remote-access-controller-private.h \
meta/meta-remote-access-controller.h \
backends/edid-parse.c \
backends/edid.h \
backends/gsm-inhibitor-flag.h \
@@ -176,6 +189,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES = \
backends/x11/meta-gpu-xrandr.h \
backends/x11/cm/meta-backend-x11-cm.c \
backends/x11/cm/meta-backend-x11-cm.h \
backends/x11/cm/meta-cursor-sprite-xfixes.c \
backends/x11/cm/meta-cursor-sprite-xfixes.h \
backends/x11/cm/meta-renderer-x11-cm.c \
backends/x11/cm/meta-renderer-x11-cm.h \
backends/x11/nested/meta-backend-x11-nested.c \
@@ -357,6 +372,10 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
backends/meta-screen-cast-monitor-stream.h \
backends/meta-screen-cast-monitor-stream-src.c \
backends/meta-screen-cast-monitor-stream-src.h \
backends/meta-screen-cast-window-stream-src.c \
backends/meta-screen-cast-window-stream-src.h \
backends/meta-screen-cast-window-stream.c \
backends/meta-screen-cast-window-stream.h \
backends/meta-screen-cast-session.c \
backends/meta-screen-cast-session.h \
backends/meta-screen-cast-stream.c \
@@ -370,6 +389,8 @@ if HAVE_WAYLAND
libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
compositor/meta-surface-actor-wayland.c \
compositor/meta-surface-actor-wayland.h \
wayland/meta-cursor-sprite-wayland.c \
wayland/meta-cursor-sprite-wayland.h \
wayland/meta-wayland.c \
wayland/meta-wayland.h \
wayland/meta-wayland-private.h \
@@ -431,10 +452,10 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
wayland/meta-wayland-touch.h \
wayland/meta-wayland-surface.c \
wayland/meta-wayland-surface.h \
wayland/meta-wayland-surface-role-cursor.c \
wayland/meta-wayland-surface-role-cursor.h \
wayland/meta-wayland-surface-role-tablet-cursor.c \
wayland/meta-wayland-surface-role-tablet-cursor.h \
wayland/meta-wayland-cursor-surface.c \
wayland/meta-wayland-cursor-surface.h \
wayland/meta-wayland-tablet-cursor-surface.c \
wayland/meta-wayland-tablet-cursor-surface.h \
wayland/meta-wayland-actor-surface.c \
wayland/meta-wayland-actor-surface.h \
wayland/meta-wayland-subsurface.c \
@@ -540,6 +561,7 @@ libmutterinclude_headers = \
meta/meta-idle-monitor.h \
meta/meta-plugin.h \
meta/meta-monitor-manager.h \
meta/meta-remote-access-controller.h \
meta/meta-settings.h \
meta/meta-shaped-texture.h \
meta/meta-shadow-factory.h \
@@ -760,3 +782,5 @@ endef
$(AM_V_GEN)$(WAYLAND_SCANNER) code $< $@
%-server-protocol.h : $(srcdir)/wayland/protocol/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) server-header $< $@
%-server-protocol.h : $(WAYLAND_EGLSTREAM_DATADIR)/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) server-header $< $@

View File

@@ -35,10 +35,12 @@
#include "backends/x11/meta-backend-x11.h"
#include "meta-cursor-tracker-private.h"
#include "meta-stage-private.h"
#include "meta-dbus-login1.h"
#ifdef HAVE_REMOTE_DESKTOP
#include "backends/meta-dbus-session-watcher.h"
#include "backends/meta-screen-cast.h"
#include "backends/meta-remote-access-controller-private.h"
#include "backends/meta-remote-desktop.h"
#endif
@@ -58,7 +60,8 @@ enum
KEYMAP_CHANGED,
KEYMAP_LAYOUT_GROUP_CHANGED,
LAST_DEVICE_CHANGED,
SUSPENDING,
RESUMING,
N_SIGNALS
};
@@ -92,6 +95,7 @@ struct _MetaBackendPrivate
MetaEgl *egl;
MetaSettings *settings;
#ifdef HAVE_REMOTE_DESKTOP
MetaRemoteAccessController *remote_access_controller;
MetaDbusSessionWatcher *dbus_session_watcher;
MetaScreenCast *screen_cast;
MetaRemoteDesktop *remote_desktop;
@@ -112,15 +116,21 @@ struct _MetaBackendPrivate
MetaDnd *dnd;
UpClient *up_client;
guint sleep_signal_id;
GCancellable *cancellable;
GDBusConnection *system_bus;
Login1Manager *logind_proxy;
int inhibit_sleep_fd;
};
typedef struct _MetaBackendPrivate MetaBackendPrivate;
static void
initable_iface_init (GInitableIface *initable_iface);
static void prepare_for_sleep_cb (MetaBackend *backend,
gboolean suspending);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaBackend, meta_backend, G_TYPE_OBJECT,
G_ADD_PRIVATE (MetaBackend)
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
@@ -139,11 +149,10 @@ meta_backend_finalize (GObject *object)
g_clear_object (&priv->remote_desktop);
g_clear_object (&priv->screen_cast);
g_clear_object (&priv->dbus_session_watcher);
g_clear_object (&priv->remote_access_controller);
#endif
g_object_unref (priv->up_client);
if (priv->sleep_signal_id)
g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
g_cancellable_cancel (priv->cancellable);
g_clear_object (&priv->cancellable);
g_clear_object (&priv->system_bus);
@@ -418,28 +427,6 @@ meta_backend_create_input_settings (MetaBackend *backend)
return META_BACKEND_GET_CLASS (backend)->create_input_settings (backend);
}
#ifdef HAVE_REMOTE_DESKTOP
static gboolean
is_screen_cast_enabled (MetaBackend *backend)
{
MetaSettings *settings = meta_backend_get_settings (backend);
return meta_settings_is_experimental_feature_enabled (
settings,
META_EXPERIMENTAL_FEATURE_SCREEN_CAST);
}
static gboolean
is_remote_desktop_enabled (MetaBackend *backend)
{
MetaSettings *settings = meta_backend_get_settings (backend);
return meta_settings_is_experimental_feature_enabled (
settings,
META_EXPERIMENTAL_FEATURE_REMOTE_DESKTOP);
}
#endif /* HAVE_REMOTE_DESKTOP */
static void
meta_backend_real_post_init (MetaBackend *backend)
{
@@ -472,11 +459,12 @@ meta_backend_real_post_init (MetaBackend *backend)
priv->input_settings = meta_backend_create_input_settings (backend);
#ifdef HAVE_REMOTE_DESKTOP
priv->remote_access_controller =
g_object_new (META_TYPE_REMOTE_ACCESS_CONTROLLER, NULL);
priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL);
if (is_screen_cast_enabled (backend))
priv->screen_cast = meta_screen_cast_new (priv->dbus_session_watcher);
if (is_remote_desktop_enabled (backend))
priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher);
priv->screen_cast = meta_screen_cast_new (backend,
priv->dbus_session_watcher);
priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher);
#endif /* HAVE_REMOTE_DESKTOP */
if (!meta_monitor_manager_is_headless (priv->monitor_manager))
@@ -563,31 +551,25 @@ meta_backend_class_init (MetaBackendClass *klass)
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_INT);
signals[SUSPENDING] =
g_signal_new ("suspending",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[RESUMING] =
g_signal_new ("resuming",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
mutter_stage_views = g_getenv ("MUTTER_STAGE_VIEWS");
stage_views_disabled = g_strcmp0 (mutter_stage_views, "0") == 0;
}
static void
experimental_features_changed (MetaSettings *settings,
MetaExperimentalFeature old_experimental_features,
MetaBackend *backend)
{
#ifdef HAVE_REMOTE_DESKTOP
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
if (is_screen_cast_enabled (backend) && !priv->screen_cast)
priv->screen_cast = meta_screen_cast_new (priv->dbus_session_watcher);
else if (!is_screen_cast_enabled (backend))
g_clear_object (&priv->screen_cast);
if (is_remote_desktop_enabled (backend) && !priv->remote_desktop)
priv->remote_desktop = meta_remote_desktop_new (priv->dbus_session_watcher);
else if (!is_remote_desktop_enabled (backend))
g_clear_object (&priv->remote_desktop);
#endif /* HAVE_REMOTE_DESKTOP */
}
static MetaMonitorManager *
meta_backend_create_monitor_manager (MetaBackend *backend,
GError **error)
@@ -618,28 +600,81 @@ lid_is_closed_changed_cb (UpClient *client,
}
static void
prepare_for_sleep_cb (GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
const gchar *interface_name,
const gchar *signal_name,
GVariant *parameters,
gpointer user_data)
inhibit_sleep (MetaBackend *backend)
{
gboolean suspending;
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
g_autoptr (GVariant) fd_variant = NULL;
g_autoptr (GError) error = NULL;
g_variant_get (parameters, "(b)", &suspending);
if (suspending)
if (priv->inhibit_sleep_fd >= 0)
return;
if (!login1_manager_call_inhibit_sync (priv->logind_proxy,
"sleep",
"Display Server",
"Prepare for suspend",
"delay",
&fd_variant,
priv->cancellable,
&error))
{
g_warning ("Failed to inhibit sleep: %s", error->message);
return;
}
priv->inhibit_sleep_fd = g_variant_get_handle (fd_variant);
}
static void
uninhibit_sleep (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
close (priv->inhibit_sleep_fd);
priv->inhibit_sleep_fd = -1;
}
static void
prepare_for_sleep_cb (MetaBackend *backend,
gboolean suspending)
{
if (suspending) {
g_signal_emit (backend, signals[SUSPENDING], 0);
uninhibit_sleep (backend);
return;
}
inhibit_sleep (backend);
g_signal_emit (backend, signals[RESUMING], 0);
meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
}
static Login1Manager *
get_logind_proxy (GCancellable *cancellable,
GError **error)
{
Login1Manager *proxy;
proxy =
login1_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
"org.freedesktop.login1",
"/org/freedesktop/login1",
cancellable, error);
if (!proxy)
g_prefix_error (error, "Could not get logind proxy: ");
return proxy;
}
static void
system_bus_gotten_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
MetaBackend *backend = META_BACKEND (user_data);
MetaBackendPrivate *priv;
g_autoptr (GError) error = NULL;
GDBusConnection *bus;
bus = g_bus_get_finish (res, NULL);
@@ -648,17 +683,22 @@ system_bus_gotten_cb (GObject *object,
priv = meta_backend_get_instance_private (user_data);
priv->system_bus = bus;
priv->sleep_signal_id =
g_dbus_connection_signal_subscribe (priv->system_bus,
"org.freedesktop.login1",
"org.freedesktop.login1.Manager",
"PrepareForSleep",
"/org/freedesktop/login1",
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
prepare_for_sleep_cb,
NULL,
NULL);
priv->logind_proxy = get_logind_proxy (priv->cancellable, &error);
priv->inhibit_sleep_fd = -1;
if (!priv->logind_proxy)
{
g_warning ("Failed to get logind proxy: %s", error->message);
}
else
{
inhibit_sleep (backend);
g_signal_connect_object (priv->logind_proxy,
"prepare-for-sleep",
G_CALLBACK (prepare_for_sleep_cb),
user_data,
G_CONNECT_SWAPPED);
}
}
static gboolean
@@ -670,9 +710,6 @@ meta_backend_initable_init (GInitable *initable,
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->settings = meta_settings_new (backend);
g_signal_connect (priv->settings, "experimental-features-changed",
G_CALLBACK (experimental_features_changed),
backend);
priv->egl = g_object_new (META_TYPE_EGL, NULL);
@@ -824,6 +861,24 @@ meta_backend_get_remote_desktop (MetaBackend *backend)
}
#endif /* HAVE_REMOTE_DESKTOP */
/**
* meta_backend_get_remote_access_controller:
* @backend: A #MetaBackend
*
* Return Value: (transfer none): The #MetaRemoteAccessController
*/
MetaRemoteAccessController *
meta_backend_get_remote_access_controller (MetaBackend *backend)
{
#ifdef HAVE_REMOTE_DESKTOP
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return priv->remote_access_controller;
#else
return NULL;
#endif
}
/**
* meta_backend_grab_device: (skip)
*/

View File

@@ -35,6 +35,9 @@
#include "meta-stage-private.h"
G_DEFINE_INTERFACE (MetaHwCursorInhibitor, meta_hw_cursor_inhibitor,
G_TYPE_OBJECT)
struct _MetaCursorRendererPrivate
{
float current_x;
@@ -44,6 +47,8 @@ struct _MetaCursorRendererPrivate
MetaOverlay *stage_overlay;
gboolean handled_by_backend;
guint post_paint_func_id;
GList *hw_cursor_inhibitors;
};
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
@@ -55,6 +60,21 @@ static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRenderer, meta_cursor_renderer, G_TYPE_OBJECT);
static gboolean
meta_hw_cursor_inhibitor_is_cursor_sprite_inhibited (MetaHwCursorInhibitor *inhibitor,
MetaCursorSprite *cursor_sprite)
{
MetaHwCursorInhibitorInterface *iface =
META_HW_CURSOR_INHIBITOR_GET_IFACE (inhibitor);
return iface->is_cursor_sprite_inhibited (inhibitor, cursor_sprite);
}
static void
meta_hw_cursor_inhibitor_default_init (MetaHwCursorInhibitorInterface *iface)
{
}
void
meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
@@ -193,8 +213,8 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
}
static void
update_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
gboolean handled_by_backend;
@@ -237,7 +257,7 @@ meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
return;
priv->displayed_cursor = cursor_sprite;
update_cursor (renderer, cursor_sprite);
meta_cursor_renderer_update_cursor (renderer, cursor_sprite);
}
void
@@ -246,7 +266,7 @@ meta_cursor_renderer_force_update (MetaCursorRenderer *renderer)
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
update_cursor (renderer, priv->displayed_cursor);
meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
}
void
@@ -261,7 +281,19 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
priv->current_x = x;
priv->current_y = y;
update_cursor (renderer, priv->displayed_cursor);
meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
}
ClutterPoint
meta_cursor_renderer_get_position (MetaCursorRenderer *renderer)
{
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
return (ClutterPoint) {
.x = priv->current_x,
.y = priv->current_y
};
}
MetaCursorSprite *
@@ -272,27 +304,44 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
return priv->displayed_cursor;
}
#ifdef HAVE_WAYLAND
void
meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
struct wl_resource *buffer)
meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
MetaHwCursorInhibitor *inhibitor)
{
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
if (renderer_class->realize_cursor_from_wl_buffer)
renderer_class->realize_cursor_from_wl_buffer (renderer, cursor_sprite, buffer);
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
inhibitor);
}
#endif
void
meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image)
meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
MetaHwCursorInhibitor *inhibitor)
{
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
if (renderer_class->realize_cursor_from_xcursor)
renderer_class->realize_cursor_from_xcursor (renderer, cursor_sprite, xc_image);
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
inhibitor);
}
gboolean
meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
GList *l;
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
{
MetaHwCursorInhibitor *inhibitor = l->data;
if (meta_hw_cursor_inhibitor_is_cursor_sprite_inhibited (inhibitor,
cursor_sprite))
return TRUE;
}
return FALSE;
}

View File

@@ -26,14 +26,22 @@
#define META_CURSOR_RENDERER_H
#include <glib-object.h>
#include <X11/Xcursor/Xcursor.h>
#ifdef HAVE_WAYLAND
#include <wayland-server.h>
#endif
#include <meta/screen.h>
#include "meta-cursor.h"
#define META_TYPE_HW_CURSOR_INHIBITOR (meta_hw_cursor_inhibitor_get_type ())
G_DECLARE_INTERFACE (MetaHwCursorInhibitor, meta_hw_cursor_inhibitor,
META, HW_CURSOR_INHIBITOR, GObject)
struct _MetaHwCursorInhibitorInterface
{
GTypeInterface parent_iface;
gboolean (* is_cursor_sprite_inhibited) (MetaHwCursorInhibitor *inhibitor,
MetaCursorSprite *cursor_sprite);
};
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
META, CURSOR_RENDERER, GObject);
@@ -44,14 +52,6 @@ struct _MetaCursorRendererClass
gboolean (* update_cursor) (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
#ifdef HAVE_WAYLAND
void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
struct wl_resource *buffer);
#endif
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image);
};
MetaCursorRenderer * meta_cursor_renderer_new (void);
@@ -62,23 +62,23 @@ void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
float x,
float y);
ClutterPoint meta_cursor_renderer_get_position (MetaCursorRenderer *renderer);
void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer);
MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
void meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
MetaHwCursorInhibitor *inhibitor);
void meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
MetaHwCursorInhibitor *inhibitor);
gboolean meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
#ifdef HAVE_WAYLAND
void meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
struct wl_resource *buffer);
#endif
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image);
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);

View File

@@ -26,6 +26,7 @@
#include "meta-cursor.h"
#include "meta-cursor-renderer.h"
#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
struct _MetaCursorTracker {
GObject parent_instance;
@@ -46,7 +47,7 @@ struct _MetaCursorTracker {
MetaCursorSprite *root_cursor;
/* The cursor from the X11 server. */
MetaCursorSprite *xfixes_cursor;
MetaCursorSpriteXfixes *xfixes_cursor;
};
struct _MetaCursorTrackerClass {

View File

@@ -40,14 +40,15 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <X11/extensions/Xfixes.h>
#include "meta-backend-private.h"
#include "backends/x11/cm/meta-cursor-sprite-xfixes.h"
G_DEFINE_TYPE (MetaCursorTracker, meta_cursor_tracker, G_TYPE_OBJECT);
enum {
CURSOR_CHANGED,
CURSOR_MOVED,
LAST_SIGNAL
};
@@ -117,11 +118,15 @@ change_cursor_renderer (MetaCursorTracker *tracker)
static void
sync_cursor (MetaCursorTracker *tracker)
{
if (update_displayed_cursor (tracker))
g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
gboolean cursor_changed = FALSE;
cursor_changed = update_displayed_cursor (tracker);
if (update_effective_cursor (tracker))
change_cursor_renderer (tracker);
if (cursor_changed)
g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
}
static void
@@ -158,6 +163,15 @@ meta_cursor_tracker_class_init (MetaCursorTrackerClass *klass)
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[CURSOR_MOVED] = g_signal_new ("cursor-moved",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_FLOAT,
G_TYPE_FLOAT);
}
/**
@@ -218,75 +232,14 @@ static void
ensure_xfixes_cursor (MetaCursorTracker *tracker)
{
MetaDisplay *display = meta_get_display ();
XFixesCursorImage *cursor_image;
CoglTexture2D *sprite;
guint8 *cursor_data;
gboolean free_cursor_data;
CoglContext *ctx;
CoglError *error = NULL;
g_autoptr (GError) error = NULL;
if (tracker->xfixes_cursor)
return;
cursor_image = XFixesGetCursorImage (display->xdisplay);
if (!cursor_image)
return;
/* Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit
* quantities as arrays of long; we need to convert on 64 bit */
if (sizeof(long) == 4)
{
cursor_data = (guint8 *)cursor_image->pixels;
free_cursor_data = FALSE;
}
else
{
int i, j;
guint32 *cursor_words;
gulong *p;
guint32 *q;
cursor_words = g_new (guint32, cursor_image->width * cursor_image->height);
cursor_data = (guint8 *)cursor_words;
p = cursor_image->pixels;
q = cursor_words;
for (j = 0; j < cursor_image->height; j++)
for (i = 0; i < cursor_image->width; i++)
*(q++) = *(p++);
free_cursor_data = TRUE;
}
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
sprite = cogl_texture_2d_new_from_data (ctx,
cursor_image->width,
cursor_image->height,
CLUTTER_CAIRO_FORMAT_ARGB32,
cursor_image->width * 4, /* stride */
cursor_data,
&error);
if (free_cursor_data)
g_free (cursor_data);
if (error != NULL)
{
meta_warning ("Failed to allocate cursor sprite texture: %s\n", error->message);
cogl_error_free (error);
}
if (sprite != NULL)
{
MetaCursorSprite *cursor_sprite = meta_cursor_sprite_new ();
meta_cursor_sprite_set_texture (cursor_sprite,
COGL_TEXTURE (sprite),
cursor_image->xhot,
cursor_image->yhot);
cogl_object_unref (sprite);
tracker->xfixes_cursor = cursor_sprite;
}
XFree (cursor_image);
tracker->xfixes_cursor = meta_cursor_sprite_xfixes_new (display, &error);
if (!tracker->xfixes_cursor)
g_warning ("Failed to create XFIXES cursor: %s", error->message);
}
/**
@@ -308,7 +261,7 @@ meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
else
{
ensure_xfixes_cursor (tracker);
cursor_sprite = tracker->xfixes_cursor;
cursor_sprite = META_CURSOR_SPRITE (tracker->xfixes_cursor);
}
if (cursor_sprite)
@@ -345,7 +298,7 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
else
{
ensure_xfixes_cursor (tracker);
cursor_sprite = tracker->xfixes_cursor;
cursor_sprite = META_CURSOR_SPRITE (tracker->xfixes_cursor);
}
if (cursor_sprite)
@@ -395,6 +348,8 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
g_assert (meta_is_wayland_compositor ());
meta_cursor_renderer_set_position (cursor_renderer, new_x, new_y);
g_signal_emit (tracker, signals[CURSOR_MOVED], 0, new_x, new_y);
}
static void

View File

@@ -23,19 +23,12 @@
#include "meta-cursor.h"
#include <meta/errors.h>
#include "backends/meta-backend-private.h"
#include "cogl/cogl.h"
#include "meta/common.h"
#include "display-private.h"
#include "screen-private.h"
#include "meta-backend-private.h"
#include <string.h>
#include <X11/cursorfont.h>
#include <X11/extensions/Xfixes.h>
#include <X11/Xcursor/Xcursor.h>
enum {
enum
{
PREPARE_AT,
TEXTURE_CHANGED,
@@ -44,316 +37,148 @@ enum {
static guint signals[LAST_SIGNAL];
struct _MetaCursorSprite
typedef struct _MetaCursorSpritePrivate
{
GObject parent;
MetaCursor cursor;
CoglTexture2D *texture;
float texture_scale;
int hot_x, hot_y;
} MetaCursorSpritePrivate;
int current_frame;
XcursorImages *xcursor_images;
int theme_scale;
gboolean theme_dirty;
};
G_DEFINE_TYPE (MetaCursorSprite, meta_cursor_sprite, G_TYPE_OBJECT)
static const char *
translate_meta_cursor (MetaCursor cursor)
{
switch (cursor)
{
case META_CURSOR_DEFAULT:
return "left_ptr";
case META_CURSOR_NORTH_RESIZE:
return "top_side";
case META_CURSOR_SOUTH_RESIZE:
return "bottom_side";
case META_CURSOR_WEST_RESIZE:
return "left_side";
case META_CURSOR_EAST_RESIZE:
return "right_side";
case META_CURSOR_SE_RESIZE:
return "bottom_right_corner";
case META_CURSOR_SW_RESIZE:
return "bottom_left_corner";
case META_CURSOR_NE_RESIZE:
return "top_right_corner";
case META_CURSOR_NW_RESIZE:
return "top_left_corner";
case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
return "fleur";
case META_CURSOR_BUSY:
return "watch";
case META_CURSOR_DND_IN_DRAG:
return "dnd-none";
case META_CURSOR_DND_MOVE:
return "dnd-move";
case META_CURSOR_DND_COPY:
return "dnd-copy";
case META_CURSOR_DND_UNSUPPORTED_TARGET:
return "dnd-none";
case META_CURSOR_POINTING_HAND:
return "hand2";
case META_CURSOR_CROSSHAIR:
return "crosshair";
case META_CURSOR_IBEAM:
return "xterm";
default:
break;
}
g_assert_not_reached ();
}
Cursor
meta_cursor_create_x_cursor (Display *xdisplay,
MetaCursor cursor)
{
return XcursorLibraryLoadCursor (xdisplay, translate_meta_cursor (cursor));
}
static XcursorImages *
load_cursor_on_client (MetaCursor cursor, int scale)
{
return XcursorLibraryLoadImages (translate_meta_cursor (cursor),
meta_prefs_get_cursor_theme (),
meta_prefs_get_cursor_size () * scale);
}
static void
meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *self,
XcursorImage *xc_image)
{
MetaBackend *meta_backend = meta_get_backend ();
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
uint width, height, rowstride;
CoglPixelFormat cogl_format;
ClutterBackend *clutter_backend;
CoglContext *cogl_context;
CoglTexture2D *texture;
CoglError *error = NULL;
g_assert (self->texture == NULL);
width = xc_image->width;
height = xc_image->height;
rowstride = width * 4;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
#else
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
#endif
clutter_backend = clutter_get_default_backend ();
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
texture = cogl_texture_2d_new_from_data (cogl_context,
width, height,
cogl_format,
rowstride,
(uint8_t *) xc_image->pixels,
&error);
if (error)
{
meta_warning ("Failed to allocate cursor texture: %s\n", error->message);
cogl_error_free (error);
}
meta_cursor_sprite_set_texture (self, COGL_TEXTURE (texture),
xc_image->xhot, xc_image->yhot);
if (texture)
cogl_object_unref (texture);
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, self, xc_image);
}
static XcursorImage *
meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *self)
{
return self->xcursor_images->images[self->current_frame];
}
void
meta_cursor_sprite_tick_frame (MetaCursorSprite *self)
{
XcursorImage *image;
if (!meta_cursor_sprite_is_animated (self))
return;
self->current_frame++;
if (self->current_frame >= self->xcursor_images->nimage)
self->current_frame = 0;
image = meta_cursor_sprite_get_current_frame_image (self);
g_clear_pointer (&self->texture, cogl_object_unref);
meta_cursor_sprite_load_from_xcursor_image (self, image);
}
guint
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self)
{
if (!meta_cursor_sprite_is_animated (self))
return 0;
return self->xcursor_images->images[self->current_frame]->delay;
}
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
meta_cursor_sprite,
G_TYPE_OBJECT)
gboolean
meta_cursor_sprite_is_animated (MetaCursorSprite *self)
meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
{
return (self->xcursor_images &&
self->xcursor_images->nimage > 1);
}
MetaCursorSpriteClass *klass = META_CURSOR_SPRITE_GET_CLASS (sprite);
MetaCursorSprite *
meta_cursor_sprite_new (void)
{
return g_object_new (META_TYPE_CURSOR_SPRITE, NULL);
}
static void
meta_cursor_sprite_load_from_theme (MetaCursorSprite *self)
{
XcursorImage *image;
g_assert (self->cursor != META_CURSOR_NONE);
self->theme_dirty = FALSE;
/* We might be reloading with a different scale. If so clear the old data. */
if (self->xcursor_images)
{
g_clear_pointer (&self->texture, cogl_object_unref);
XcursorImagesDestroy (self->xcursor_images);
}
self->current_frame = 0;
self->xcursor_images = load_cursor_on_client (self->cursor,
self->theme_scale);
if (!self->xcursor_images)
meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
image = meta_cursor_sprite_get_current_frame_image (self);
meta_cursor_sprite_load_from_xcursor_image (self, image);
}
MetaCursorSprite *
meta_cursor_sprite_from_theme (MetaCursor cursor)
{
MetaCursorSprite *self;
self = meta_cursor_sprite_new ();
self->cursor = cursor;
self->theme_dirty = TRUE;
return self;
if (klass->is_animated)
return klass->is_animated (sprite);
else
return FALSE;
}
void
meta_cursor_sprite_set_texture (MetaCursorSprite *self,
meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite)
{
return META_CURSOR_SPRITE_GET_CLASS (sprite)->tick_frame (sprite);
}
unsigned int
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite)
{
return META_CURSOR_SPRITE_GET_CLASS (sprite)->get_current_frame_time (sprite);
}
void
meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
{
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
g_clear_pointer (&priv->texture, cogl_object_unref);
}
void
meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
CoglTexture *texture,
int hot_x,
int hot_y)
{
if (self->texture == COGL_TEXTURE_2D (texture) &&
self->hot_x == hot_x &&
self->hot_y == hot_y)
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
if (priv->texture == COGL_TEXTURE_2D (texture) &&
priv->hot_x == hot_x &&
priv->hot_y == hot_y)
return;
g_clear_pointer (&self->texture, cogl_object_unref);
g_clear_pointer (&priv->texture, cogl_object_unref);
if (texture)
self->texture = cogl_object_ref (texture);
self->hot_x = hot_x;
self->hot_y = hot_y;
priv->texture = cogl_object_ref (texture);
priv->hot_x = hot_x;
priv->hot_y = hot_y;
g_signal_emit (self, signals[TEXTURE_CHANGED], 0);
g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0);
}
void
meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
float scale)
{
self->texture_scale = scale;
}
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
void
meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
int theme_scale)
{
if (self->theme_scale != theme_scale)
self->theme_dirty = TRUE;
self->theme_scale = theme_scale;
priv->texture_scale = scale;
}
CoglTexture *
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self)
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite)
{
return COGL_TEXTURE (self->texture);
}
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
MetaCursor
meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self)
{
return self->cursor;
return COGL_TEXTURE (priv->texture);
}
void
meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
int *hot_x,
int *hot_y)
{
*hot_x = self->hot_x;
*hot_y = self->hot_y;
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
*hot_x = priv->hot_x;
*hot_y = priv->hot_y;
}
float
meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self)
meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite)
{
return self->texture_scale;
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
return priv->texture_scale;
}
void
meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
int x,
int y)
{
g_signal_emit (self, signals[PREPARE_AT], 0, x, y);
g_signal_emit (sprite, signals[PREPARE_AT], 0, x, y);
}
void
meta_cursor_sprite_realize_texture (MetaCursorSprite *self)
meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite)
{
if (self->theme_dirty)
meta_cursor_sprite_load_from_theme (self);
MetaCursorSpriteClass *klass = META_CURSOR_SPRITE_GET_CLASS (sprite);
if (klass->realize_texture)
klass->realize_texture (sprite);
}
static void
meta_cursor_sprite_init (MetaCursorSprite *self)
meta_cursor_sprite_init (MetaCursorSprite *sprite)
{
self->texture_scale = 1.0f;
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
priv->texture_scale = 1.0f;
}
static void
meta_cursor_sprite_finalize (GObject *object)
{
MetaCursorSprite *self = META_CURSOR_SPRITE (object);
MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
if (self->xcursor_images)
XcursorImagesDestroy (self->xcursor_images);
g_clear_pointer (&self->texture, cogl_object_unref);
g_clear_pointer (&priv->texture, cogl_object_unref);
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
}

View File

@@ -25,51 +25,50 @@
#include <meta/common.h>
#include <meta/boxes.h>
typedef struct _MetaCursorSprite MetaCursorSprite;
#define META_TYPE_CURSOR_SPRITE (meta_cursor_sprite_get_type ())
G_DECLARE_FINAL_TYPE (MetaCursorSprite,
meta_cursor_sprite,
META, CURSOR_SPRITE,
GObject);
G_DECLARE_DERIVABLE_TYPE (MetaCursorSprite,
meta_cursor_sprite,
META, CURSOR_SPRITE,
GObject)
MetaCursorSprite * meta_cursor_sprite_new (void);
struct _MetaCursorSpriteClass
{
GObjectClass parent_class;
MetaCursorSprite * meta_cursor_sprite_from_theme (MetaCursor cursor);
void (* realize_texture) (MetaCursorSprite *sprite);
gboolean (* is_animated) (MetaCursorSprite *sprite);
void (* tick_frame) (MetaCursorSprite *sprite);
unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
};
void meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
int scale);
MetaCursor meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self);
Cursor meta_cursor_create_x_cursor (Display *xdisplay,
MetaCursor cursor);
void meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
int x,
int y);
void meta_cursor_sprite_realize_texture (MetaCursorSprite *self);
void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
void meta_cursor_sprite_set_texture (MetaCursorSprite *self,
void meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite);
void meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
CoglTexture *texture,
int hot_x,
int hot_y);
void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
float scale);
CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self);
CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite);
void meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
void meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
int *hot_x,
int *hot_y);
float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self);
float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite);
gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *self);
void meta_cursor_sprite_tick_frame (MetaCursorSprite *self);
guint meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self);
gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *sprite);
void meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite);
unsigned int meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite);
#endif /* META_CURSOR_H */

View File

@@ -246,7 +246,8 @@ meta_idle_monitor_init (MetaIdleMonitor *monitor)
/* Monitor inhibitors */
monitor->session_proxy =
g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",

View File

@@ -100,11 +100,12 @@ static MetaMonitorTransform
derive_monitor_transform (MetaMonitor *monitor)
{
MetaOutput *main_output;
MetaMonitorTransform transform;
main_output = meta_monitor_get_main_output (monitor);
transform = meta_output_get_assigned_crtc (main_output)->transform;
return meta_monitor_crtc_to_logical_transform (monitor,
main_output->crtc->transform);
return meta_monitor_crtc_to_logical_transform (monitor, transform);
}
MetaLogicalMonitor *
@@ -145,7 +146,7 @@ meta_logical_monitor_add_monitor (MetaLogicalMonitor *logical_monitor,
is_presentation = logical_monitor->is_presentation;
logical_monitor->monitors = g_list_append (logical_monitor->monitors,
monitor);
g_object_ref (monitor));
for (l = logical_monitor->monitors; l; l = l->next)
{
@@ -157,10 +158,12 @@ meta_logical_monitor_add_monitor (MetaLogicalMonitor *logical_monitor,
for (l_output = outputs; l_output; l_output = l_output->next)
{
MetaOutput *output = l_output->data;
MetaCrtc *crtc;
is_presentation = is_presentation && output->is_presentation;
if (output->crtc)
output->crtc->logical_monitor = logical_monitor;
crtc = meta_output_get_assigned_crtc (output);
if (crtc)
crtc->logical_monitor = logical_monitor;
}
}
@@ -220,7 +223,7 @@ foreach_crtc (MetaMonitor *monitor,
ForeachCrtcData *data = user_data;
data->func (data->logical_monitor,
monitor_crtc_mode->output->crtc,
meta_output_get_assigned_crtc (monitor_crtc_mode->output),
data->user_data);
return TRUE;
@@ -254,13 +257,17 @@ meta_logical_monitor_init (MetaLogicalMonitor *logical_monitor)
}
static void
meta_logical_monitor_finalize (GObject *object)
meta_logical_monitor_dispose (GObject *object)
{
MetaLogicalMonitor *logical_monitor = META_LOGICAL_MONITOR (object);
g_list_free (logical_monitor->monitors);
if (logical_monitor->monitors)
{
g_list_free_full (logical_monitor->monitors, g_object_unref);
logical_monitor->monitors = NULL;
}
G_OBJECT_CLASS (meta_logical_monitor_parent_class)->finalize (object);
G_OBJECT_CLASS (meta_logical_monitor_parent_class)->dispose (object);
}
static void
@@ -268,7 +275,7 @@ meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_logical_monitor_finalize;
object_class->dispose = meta_logical_monitor_dispose;
}
gboolean

View File

@@ -486,7 +486,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
output = ((MetaOutput**)crtc_info->outputs->pdata)[j];
output->is_dirty = TRUE;
output->crtc = crtc;
meta_output_assign_crtc (output, crtc);
}
}
}
@@ -531,7 +531,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
continue;
}
output->crtc = NULL;
meta_output_unassign_crtc (output);
output->is_primary = FALSE;
}
}

View File

@@ -585,6 +585,8 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
&error))
{
g_clear_object (&config);
g_warning ("Failed to use linear monitor configuration: %s",
error->message);
g_clear_error (&error);
}
else
@@ -602,6 +604,8 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
&error))
{
g_clear_object (&config);
g_warning ("Failed to use fallback monitor configuration: %s",
error->message);
g_clear_error (&error);
}
else
@@ -1041,6 +1045,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
GVariantBuilder crtcs, modes, clones, properties;
GBytes *edid;
char *edid_file;
MetaCrtc *crtc;
int crtc_index;
g_variant_builder_init (&crtcs, G_VARIANT_TYPE ("au"));
@@ -1134,8 +1139,8 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
output->tile_info.tile_h));
}
crtc_index = output->crtc ? g_list_index (combined_crtcs, output->crtc)
: -1;
crtc = meta_output_get_assigned_crtc (output);
crtc_index = crtc ? g_list_index (combined_crtcs, crtc) : -1;
g_variant_builder_add (&output_builder, "(uxiausauaua{sv})",
i, /* ID */
(gint64)output->winsys_id,
@@ -2903,11 +2908,7 @@ meta_monitor_manager_get_monitor_for_connector (MetaMonitorManager *manager,
if (meta_monitor_is_active (monitor) &&
g_str_equal (connector, meta_monitor_get_connector (monitor)))
{
MetaOutput *main_output = meta_monitor_get_main_output (monitor);
return main_output->crtc->logical_monitor->number;
}
return meta_monitor_get_logical_monitor (monitor)->number;
}
return -1;

View File

@@ -203,11 +203,9 @@ meta_monitor_get_main_output (MetaMonitor *monitor)
gboolean
meta_monitor_is_active (MetaMonitor *monitor)
{
MetaOutput *output;
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
output = meta_monitor_get_main_output (monitor);
return output->crtc && output->crtc->current_mode;
return !!priv->current_mode;
}
gboolean
@@ -385,6 +383,21 @@ meta_monitor_crtc_to_logical_transform (MetaMonitor *monitor,
return new_transform;
}
static void
meta_monitor_dispose (GObject *object)
{
MetaMonitor *monitor = META_MONITOR (object);
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
if (priv->outputs)
{
g_list_free_full (priv->outputs, g_object_unref);
priv->outputs = NULL;
}
G_OBJECT_CLASS (meta_monitor_parent_class)->dispose (object);
}
static void
meta_monitor_finalize (GObject *object)
{
@@ -393,7 +406,6 @@ meta_monitor_finalize (GObject *object)
g_hash_table_destroy (priv->mode_ids);
g_list_free_full (priv->modes, (GDestroyNotify) meta_monitor_mode_free);
g_clear_pointer (&priv->outputs, g_list_free);
meta_monitor_spec_free (priv->spec);
G_OBJECT_CLASS (meta_monitor_parent_class)->finalize (object);
@@ -412,6 +424,7 @@ meta_monitor_class_init (MetaMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = meta_monitor_dispose;
object_class->finalize = meta_monitor_finalize;
}
@@ -493,6 +506,7 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
for (i = 0; i < output->n_modes; i++)
{
MetaCrtcMode *crtc_mode = output->modes[i];
MetaCrtc *crtc;
MetaMonitorMode *mode;
gboolean replace;
@@ -526,7 +540,9 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
if (crtc_mode == output->preferred_mode)
monitor_priv->preferred_mode = mode;
if (output->crtc && crtc_mode == output->crtc->current_mode)
crtc = meta_output_get_assigned_crtc (output);
if (crtc && crtc_mode == crtc->current_mode)
monitor_priv->current_mode = mode;
}
}
@@ -545,7 +561,7 @@ meta_monitor_normal_new (MetaGpu *gpu,
monitor_priv->gpu = gpu;
monitor_priv->outputs = g_list_append (NULL, output);
monitor_priv->outputs = g_list_append (NULL, g_object_ref (output));
monitor_priv->winsys_id = output->winsys_id;
meta_monitor_generate_spec (monitor);
@@ -568,13 +584,15 @@ meta_monitor_normal_derive_layout (MetaMonitor *monitor,
MetaRectangle *layout)
{
MetaOutput *output;
MetaCrtc *crtc;
output = meta_monitor_get_main_output (monitor);
crtc = meta_output_get_assigned_crtc (output);
*layout = (MetaRectangle) {
.x = output->crtc->rect.x,
.y = output->crtc->rect.y,
.width = output->crtc->rect.width,
.height = output->crtc->rect.height
.x = crtc->rect.x,
.y = crtc->rect.y,
.width = crtc->rect.width,
.height = crtc->rect.height
};
}
@@ -658,7 +676,8 @@ add_tiled_monitor_outputs (MetaGpu *gpu,
g_warn_if_fail (output->subpixel_order ==
monitor_tiled->origin_output->subpixel_order);
monitor_priv->outputs = g_list_append (monitor_priv->outputs, output);
monitor_priv->outputs = g_list_append (monitor_priv->outputs,
g_object_ref (output));
}
}
@@ -764,12 +783,13 @@ is_monitor_mode_assigned (MetaMonitor *monitor,
{
MetaOutput *output = l->data;
MetaMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
MetaCrtc *crtc;
crtc = meta_output_get_assigned_crtc (output);
if (monitor_crtc_mode->crtc_mode &&
(!output->crtc ||
output->crtc->current_mode != monitor_crtc_mode->crtc_mode))
(!crtc || crtc->current_mode != monitor_crtc_mode->crtc_mode))
return FALSE;
else if (!monitor_crtc_mode->crtc_mode && output->crtc)
else if (!monitor_crtc_mode->crtc_mode && crtc)
return FALSE;
}
@@ -1217,14 +1237,16 @@ meta_monitor_tiled_derive_layout (MetaMonitor *monitor,
for (l = monitor_priv->outputs; l; l = l->next)
{
MetaOutput *output = l->data;
MetaCrtc *crtc;
if (!output->crtc)
crtc = meta_output_get_assigned_crtc (output);
if (!crtc)
continue;
min_x = MIN (output->crtc->rect.x, min_x);
min_y = MIN (output->crtc->rect.y, min_y);
max_x = MAX (output->crtc->rect.x + output->crtc->rect.width, max_x);
max_y = MAX (output->crtc->rect.y + output->crtc->rect.height, max_y);
min_x = MIN (crtc->rect.x, min_x);
min_y = MIN (crtc->rect.y, min_y);
max_x = MAX (crtc->rect.x + crtc->rect.width, max_x);
max_y = MAX (crtc->rect.y + crtc->rect.height, max_y);
}
*layout = (MetaRectangle) {
@@ -1318,10 +1340,14 @@ meta_monitor_get_spec (MetaMonitor *monitor)
MetaLogicalMonitor *
meta_monitor_get_logical_monitor (MetaMonitor *monitor)
{
MetaOutput *output = meta_monitor_get_main_output (monitor);
MetaOutput *output;
MetaCrtc *crtc;
if (output->crtc)
return output->crtc->logical_monitor;
output = meta_monitor_get_main_output (monitor);
crtc = meta_output_get_assigned_crtc (output);
if (crtc)
return crtc->logical_monitor;
else
return NULL;
}
@@ -1381,6 +1407,18 @@ meta_monitor_get_current_mode (MetaMonitor *monitor)
return priv->current_mode;
}
static gboolean
is_current_mode_known (MetaMonitor *monitor)
{
MetaOutput *output;
MetaCrtc *crtc;
output = meta_monitor_get_main_output (monitor);
crtc = meta_output_get_assigned_crtc (output);
return meta_monitor_is_active (monitor) == (crtc && crtc->current_mode);
}
void
meta_monitor_derive_current_mode (MetaMonitor *monitor)
{
@@ -1400,6 +1438,8 @@ meta_monitor_derive_current_mode (MetaMonitor *monitor)
}
priv->current_mode = current_mode;
g_warn_if_fail (is_current_mode_known (monitor));
}
void

View File

@@ -21,7 +21,13 @@
#include "backends/meta-output.h"
G_DEFINE_TYPE (MetaOutput, meta_output, G_TYPE_OBJECT)
typedef struct _MetaOutputPrivate
{
/* The CRTC driving this output, NULL if the output is not enabled */
MetaCrtc *crtc;
} MetaOutputPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT)
MetaGpu *
meta_output_get_gpu (MetaOutput *output)
@@ -29,6 +35,44 @@ meta_output_get_gpu (MetaOutput *output)
return output->gpu;
}
void
meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
g_assert (crtc);
g_set_object (&priv->crtc, crtc);
}
void
meta_output_unassign_crtc (MetaOutput *output)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
g_clear_object (&priv->crtc);
}
MetaCrtc *
meta_output_get_assigned_crtc (MetaOutput *output)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
return priv->crtc;
}
static void
meta_output_dispose (GObject *object)
{
MetaOutput *output = META_OUTPUT (object);
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
g_clear_object (&priv->crtc);
G_OBJECT_CLASS (meta_output_parent_class)->dispose (object);
}
static void
meta_output_finalize (GObject *object)
{
@@ -58,5 +102,6 @@ meta_output_class_init (MetaOutputClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = meta_output_dispose;
object_class->finalize = meta_output_finalize;
}

View File

@@ -64,9 +64,6 @@ struct _MetaOutput
MetaGpu *gpu;
/* The CRTC driving this output, NULL if the output is not enabled */
MetaCrtc *crtc;
/* The low-level ID of this output, used to apply back configuration */
glong winsys_id;
char *name;
@@ -122,4 +119,11 @@ G_DECLARE_FINAL_TYPE (MetaOutput, meta_output, META, OUTPUT, GObject)
MetaGpu * meta_output_get_gpu (MetaOutput *output);
void meta_output_assign_crtc (MetaOutput *output,
MetaCrtc *crtc);
void meta_output_unassign_crtc (MetaOutput *output);
MetaCrtc * meta_output_get_assigned_crtc (MetaOutput *output);
#endif /* META_OUTPUT_H */

View File

@@ -1,7 +1,5 @@
/*
* Wayland Support
*
* Copyright (C) 2016 Red Hat, Inc.
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -17,26 +15,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "meta-wayland-surface-role-tablet-cursor.h"
#ifndef META_REMOTE_ACCESS_CONTROLLER_PRIVATE_H
#define META_REMOTE_ACCESS_CONTROLLER_PRIVATE_H
struct _MetaWaylandSurfaceRoleTabletCursor
{
MetaWaylandSurfaceRoleCursor parent;
};
#include "meta/meta-remote-access-controller.h"
G_DEFINE_TYPE (MetaWaylandSurfaceRoleTabletCursor,
meta_wayland_surface_role_tablet_cursor,
META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR)
void meta_remote_access_controller_notify_new_handle (MetaRemoteAccessController *controller,
MetaRemoteAccessHandle *handle);
static void
meta_wayland_surface_role_tablet_cursor_init (MetaWaylandSurfaceRoleTabletCursor *role)
{
}
void meta_remote_access_handle_notify_stopped (MetaRemoteAccessHandle *handle);
static void
meta_wayland_surface_role_tablet_cursor_class_init (MetaWaylandSurfaceRoleTabletCursorClass *klass)
{
}
#endif /* META_REMOTE_ACCESS_CONTROLLER_PRIVATE_H */

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "backends/meta-remote-access-controller-private.h"
enum
{
HANDLE_STOPPED,
N_HANDLE_SIGNALS
};
static int handle_signals[N_HANDLE_SIGNALS];
enum
{
CONTROLLER_NEW_HANDLE,
N_CONTROLLER_SIGNALS
};
static int controller_signals[N_CONTROLLER_SIGNALS];
typedef struct _MetaRemoteAccessHandlePrivate
{
gboolean has_stopped;
} MetaRemoteAccessHandlePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaRemoteAccessHandle,
meta_remote_access_handle,
G_TYPE_OBJECT)
struct _MetaRemoteAccessController
{
GObject parent;
};
G_DEFINE_TYPE (MetaRemoteAccessController,
meta_remote_access_controller,
G_TYPE_OBJECT)
/**
* meta_remote_access_handle_stop:
* @handle: A #MetaRemoteAccessHandle
*
* Stop the associated remote access session.
*/
void
meta_remote_access_handle_stop (MetaRemoteAccessHandle *handle)
{
MetaRemoteAccessHandlePrivate *priv =
meta_remote_access_handle_get_instance_private (handle);
if (priv->has_stopped)
return;
META_REMOTE_ACCESS_HANDLE_GET_CLASS (handle)->stop (handle);
}
void
meta_remote_access_handle_notify_stopped (MetaRemoteAccessHandle *handle)
{
MetaRemoteAccessHandlePrivate *priv =
meta_remote_access_handle_get_instance_private (handle);
priv->has_stopped = TRUE;
g_signal_emit (handle, handle_signals[HANDLE_STOPPED], 0);
}
void
meta_remote_access_controller_notify_new_handle (MetaRemoteAccessController *controller,
MetaRemoteAccessHandle *handle)
{
g_signal_emit (controller, controller_signals[CONTROLLER_NEW_HANDLE], 0,
handle);
}
static void
meta_remote_access_handle_init (MetaRemoteAccessHandle *handle)
{
}
static void
meta_remote_access_handle_class_init (MetaRemoteAccessHandleClass *klass)
{
handle_signals[HANDLE_STOPPED] =
g_signal_new ("stopped",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
}
static void
meta_remote_access_controller_init (MetaRemoteAccessController *controller)
{
}
static void
meta_remote_access_controller_class_init (MetaRemoteAccessControllerClass *klass)
{
controller_signals[CONTROLLER_NEW_HANDLE] =
g_signal_new ("new-handle",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
META_TYPE_REMOTE_ACCESS_HANDLE);
}

View File

@@ -30,6 +30,7 @@
#include "backends/meta-dbus-session-watcher.h"
#include "backends/meta-screen-cast-session.h"
#include "backends/meta-remote-access-controller-private.h"
#include "backends/native/meta-backend-native.h"
#include "backends/x11/meta-backend-x11.h"
#include "cogl/cogl.h"
@@ -59,6 +60,8 @@ struct _MetaRemoteDesktopSession
ClutterVirtualInputDevice *virtual_pointer;
ClutterVirtualInputDevice *virtual_keyboard;
ClutterVirtualInputDevice *virtual_touchscreen;
MetaRemoteDesktopSessionHandle *handle;
};
static void
@@ -75,12 +78,41 @@ G_DEFINE_TYPE_WITH_CODE (MetaRemoteDesktopSession,
G_IMPLEMENT_INTERFACE (META_TYPE_DBUS_SESSION,
meta_dbus_session_init_iface))
struct _MetaRemoteDesktopSessionHandle
{
MetaRemoteAccessHandle parent;
MetaRemoteDesktopSession *session;
};
G_DEFINE_TYPE (MetaRemoteDesktopSessionHandle,
meta_remote_desktop_session_handle,
META_TYPE_REMOTE_ACCESS_HANDLE)
static MetaRemoteDesktopSessionHandle *
meta_remote_desktop_session_handle_new (MetaRemoteDesktopSession *session);
static gboolean
meta_remote_desktop_session_is_running (MetaRemoteDesktopSession *session)
{
return !!session->virtual_pointer;
}
static void
init_remote_access_handle (MetaRemoteDesktopSession *session)
{
MetaBackend *backend = meta_get_backend ();
MetaRemoteAccessController *remote_access_controller;
MetaRemoteAccessHandle *remote_access_handle;
session->handle = meta_remote_desktop_session_handle_new (session);
remote_access_controller = meta_backend_get_remote_access_controller (backend);
remote_access_handle = META_REMOTE_ACCESS_HANDLE (session->handle);
meta_remote_access_controller_notify_new_handle (remote_access_controller,
remote_access_handle);
}
static gboolean
meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
GError **error)
@@ -107,6 +139,8 @@ meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
clutter_device_manager_create_virtual_device (device_manager,
CLUTTER_TOUCHSCREEN_DEVICE);
init_remote_access_handle (session);
return TRUE;
}
@@ -126,11 +160,20 @@ meta_remote_desktop_session_close (MetaRemoteDesktopSession *session)
g_clear_object (&session->virtual_pointer);
g_clear_object (&session->virtual_keyboard);
g_clear_object (&session->virtual_touchscreen);
meta_dbus_session_notify_closed (META_DBUS_SESSION (session));
meta_dbus_remote_desktop_session_emit_closed (skeleton);
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (session));
if (session->handle)
{
MetaRemoteAccessHandle *remote_access_handle =
META_REMOTE_ACCESS_HANDLE (session->handle);
meta_remote_access_handle_notify_stopped (remote_access_handle);
}
g_object_unref (session);
}
@@ -729,6 +772,7 @@ meta_remote_desktop_session_finalize (GObject *object)
g_assert (!meta_remote_desktop_session_is_running (session));
g_clear_object (&session->handle);
g_free (session->peer_name);
g_free (session->session_id);
g_free (session->object_path);
@@ -763,3 +807,40 @@ meta_remote_desktop_session_class_init (MetaRemoteDesktopSessionClass *klass)
object_class->finalize = meta_remote_desktop_session_finalize;
}
static MetaRemoteDesktopSessionHandle *
meta_remote_desktop_session_handle_new (MetaRemoteDesktopSession *session)
{
MetaRemoteDesktopSessionHandle *handle;
handle = g_object_new (META_TYPE_REMOTE_DESKTOP_SESSION_HANDLE, NULL);
handle->session = session;
return handle;
}
static void
meta_remote_desktop_session_handle_stop (MetaRemoteAccessHandle *handle)
{
MetaRemoteDesktopSession *session;
session = META_REMOTE_DESKTOP_SESSION_HANDLE (handle)->session;
if (!session)
return;
meta_remote_desktop_session_close (session);
}
static void
meta_remote_desktop_session_handle_init (MetaRemoteDesktopSessionHandle *handle)
{
}
static void
meta_remote_desktop_session_handle_class_init (MetaRemoteDesktopSessionHandleClass *klass)
{
MetaRemoteAccessHandleClass *remote_access_handle_class =
META_REMOTE_ACCESS_HANDLE_CLASS (klass);
remote_access_handle_class->stop = meta_remote_desktop_session_handle_stop;
}

View File

@@ -33,6 +33,12 @@ G_DECLARE_FINAL_TYPE (MetaRemoteDesktopSession, meta_remote_desktop_session,
META, REMOTE_DESKTOP_SESSION,
MetaDBusRemoteDesktopSessionSkeleton)
#define META_TYPE_REMOTE_DESKTOP_SESSION_HANDLE (meta_remote_desktop_session_handle_get_type ())
G_DECLARE_FINAL_TYPE (MetaRemoteDesktopSessionHandle,
meta_remote_desktop_session_handle,
META, REMOTE_DESKTOP_SESSION_HANDLE,
MetaRemoteAccessHandle)
char * meta_remote_desktop_session_get_object_path (MetaRemoteDesktopSession *session);
char * meta_remote_desktop_session_get_session_id (MetaRemoteDesktopSession *session);

View File

@@ -94,6 +94,24 @@ meta_renderer_get_views (MetaRenderer *renderer)
return priv->views;
}
MetaRendererView *
meta_renderer_get_view_from_logical_monitor (MetaRenderer *renderer,
MetaLogicalMonitor *logical_monitor)
{
GList *l;
for (l = meta_renderer_get_views (renderer); l; l = l->next)
{
MetaRendererView *view = l->data;
if (meta_renderer_view_get_logical_monitor (view) ==
logical_monitor)
return view;
}
return NULL;
}
static void
meta_renderer_finalize (GObject *object)
{

View File

@@ -53,4 +53,7 @@ void meta_renderer_set_legacy_view (MetaRenderer *renderer,
GList * meta_renderer_get_views (MetaRenderer *renderer);
MetaRendererView * meta_renderer_get_view_from_logical_monitor (MetaRenderer *renderer,
MetaLogicalMonitor *logical_monitor);
#endif /* META_RENDERER_H */

View File

@@ -24,23 +24,38 @@
#include "backends/meta-screen-cast-monitor-stream-src.h"
#include <spa/buffer/meta.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-screen-cast-monitor-stream.h"
#include "backends/meta-screen-cast-session.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor.h"
#include "clutter/clutter.h"
#include "clutter/clutter-mutter.h"
#include "core/boxes-private.h"
struct _MetaScreenCastMonitorStreamSrc
{
MetaScreenCastStreamSrc parent;
gulong stage_painted_handler_id;
gboolean cursor_bitmap_invalid;
gulong actors_painted_handler_id;
gulong paint_handler_id;
gulong cursor_moved_handler_id;
gulong cursor_changed_handler_id;
};
G_DEFINE_TYPE (MetaScreenCastMonitorStreamSrc,
meta_screen_cast_monitor_stream_src,
META_TYPE_SCREEN_CAST_STREAM_SRC)
static void
hw_cursor_inhibitor_iface_init (MetaHwCursorInhibitorInterface *iface);
G_DEFINE_TYPE_WITH_CODE (MetaScreenCastMonitorStreamSrc,
meta_screen_cast_monitor_stream_src,
META_TYPE_SCREEN_CAST_STREAM_SRC,
G_IMPLEMENT_INTERFACE (META_TYPE_HW_CURSOR_INHIBITOR,
hw_cursor_inhibitor_iface_init))
static ClutterStage *
get_stage (MetaScreenCastMonitorStreamSrc *monitor_src)
@@ -102,18 +117,164 @@ stage_painted (ClutterActor *actor,
meta_screen_cast_stream_src_maybe_record_frame (src);
}
static MetaBackend *
get_backend (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
return meta_screen_cast_get_backend (screen_cast);
}
static gboolean
is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaBackend *backend = get_backend (monitor_src);
MetaCursorRenderer *cursor_renderer =
meta_backend_get_cursor_renderer (backend);
MetaMonitor *monitor;
MetaLogicalMonitor *logical_monitor;
MetaRectangle logical_monitor_layout;
ClutterRect logical_monitor_rect;
MetaCursorSprite *cursor_sprite;
monitor = get_monitor (monitor_src);
logical_monitor = meta_monitor_get_logical_monitor (monitor);
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
logical_monitor_rect =
meta_rectangle_to_clutter_rect (&logical_monitor_layout);
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
if (cursor_sprite)
{
ClutterRect cursor_rect;
cursor_rect = meta_cursor_renderer_calculate_rect (cursor_renderer,
cursor_sprite);
return clutter_rect_intersection (&cursor_rect,
&logical_monitor_rect,
NULL);
}
else
{
ClutterPoint cursor_position;
cursor_position = meta_cursor_renderer_get_position (cursor_renderer);
return clutter_rect_contains_point (&logical_monitor_rect,
&cursor_position);
}
}
static void
sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
ClutterStage *stage = get_stage (monitor_src);
if (!is_cursor_in_stream (monitor_src))
return;
if (clutter_stage_is_redraw_queued (stage))
return;
meta_screen_cast_stream_src_maybe_record_frame (src);
}
static void
cursor_moved (MetaCursorTracker *cursor_tracker,
float x,
float y,
MetaScreenCastMonitorStreamSrc *monitor_src)
{
sync_cursor_state (monitor_src);
}
static void
cursor_changed (MetaCursorTracker *cursor_tracker,
MetaScreenCastMonitorStreamSrc *monitor_src)
{
monitor_src->cursor_bitmap_invalid = TRUE;
sync_cursor_state (monitor_src);
}
static MetaCursorRenderer *
get_cursor_renderer (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
return meta_backend_get_cursor_renderer (backend);
}
static void
inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaCursorRenderer *cursor_renderer;
MetaHwCursorInhibitor *inhibitor;
cursor_renderer = get_cursor_renderer (monitor_src);
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
meta_cursor_renderer_add_hw_cursor_inhibitor (cursor_renderer, inhibitor);
}
static void
uninhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
{
MetaCursorRenderer *cursor_renderer;
MetaHwCursorInhibitor *inhibitor;
cursor_renderer = get_cursor_renderer (monitor_src);
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
meta_cursor_renderer_remove_hw_cursor_inhibitor (cursor_renderer, inhibitor);
}
static void
meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src)
{
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaBackend *backend = get_backend (monitor_src);
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterStage *stage;
MetaScreenCastStream *stream;
stream = meta_screen_cast_stream_src_get_stream (src);
stage = get_stage (monitor_src);
monitor_src->stage_painted_handler_id =
g_signal_connect_after (stage, "paint",
G_CALLBACK (stage_painted),
monitor_src);
switch (meta_screen_cast_stream_get_cursor_mode (stream))
{
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
monitor_src->cursor_moved_handler_id =
g_signal_connect_after (cursor_tracker, "cursor-moved",
G_CALLBACK (cursor_moved),
monitor_src);
monitor_src->cursor_changed_handler_id =
g_signal_connect_after (cursor_tracker, "cursor-changed",
G_CALLBACK (cursor_changed),
monitor_src);
/* Intentional fall-through */
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
monitor_src->actors_painted_handler_id =
g_signal_connect (stage, "actors-painted",
G_CALLBACK (stage_painted),
monitor_src);
break;
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
inhibit_hw_cursor (monitor_src);
monitor_src->paint_handler_id =
g_signal_connect_after (stage, "paint",
G_CALLBACK (stage_painted),
monitor_src);
break;
}
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
}
@@ -122,14 +283,43 @@ meta_screen_cast_monitor_stream_src_disable (MetaScreenCastStreamSrc *src)
{
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaBackend *backend = get_backend (monitor_src);
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
ClutterStage *stage;
stage = get_stage (monitor_src);
g_signal_handler_disconnect (stage, monitor_src->stage_painted_handler_id);
monitor_src->stage_painted_handler_id = 0;
if (monitor_src->actors_painted_handler_id)
{
g_signal_handler_disconnect (stage,
monitor_src->actors_painted_handler_id);
monitor_src->actors_painted_handler_id = 0;
}
if (monitor_src->paint_handler_id)
{
g_signal_handler_disconnect (stage,
monitor_src->paint_handler_id);
monitor_src->paint_handler_id = 0;
uninhibit_hw_cursor (monitor_src);
}
if (monitor_src->cursor_moved_handler_id)
{
g_signal_handler_disconnect (cursor_tracker,
monitor_src->cursor_moved_handler_id);
monitor_src->cursor_moved_handler_id = 0;
}
if (monitor_src->cursor_changed_handler_id)
{
g_signal_handler_disconnect (cursor_tracker,
monitor_src->cursor_changed_handler_id);
monitor_src->cursor_changed_handler_id = 0;
}
}
static void
static gboolean
meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src,
uint8_t *data)
{
@@ -140,9 +330,226 @@ meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src,
MetaLogicalMonitor *logical_monitor;
stage = get_stage (monitor_src);
if (!clutter_stage_is_redraw_queued (stage))
return FALSE;
monitor = get_monitor (monitor_src);
logical_monitor = meta_monitor_get_logical_monitor (monitor);
clutter_stage_capture_into (stage, FALSE, &logical_monitor->rect, data);
return TRUE;
}
static gboolean
draw_cursor_sprite_via_offscreen (MetaScreenCastMonitorStreamSrc *monitor_src,
CoglTexture *cursor_texture,
int bitmap_width,
int bitmap_height,
uint32_t *bitmap_data,
GError **error)
{
MetaBackend *backend = get_backend (monitor_src);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
CoglTexture2D *bitmap_texture;
CoglOffscreen *offscreen;
CoglFramebuffer *fb;
CoglPipeline *pipeline;
CoglColor clear_color;
bitmap_texture = cogl_texture_2d_new_with_size (cogl_context,
bitmap_width, bitmap_height);
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (bitmap_texture),
FALSE);
if (!cogl_texture_allocate (COGL_TEXTURE (bitmap_texture), error))
{
cogl_object_unref (bitmap_texture);
return FALSE;
}
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (bitmap_texture));
fb = COGL_FRAMEBUFFER (offscreen);
cogl_object_unref (bitmap_texture);
if (!cogl_framebuffer_allocate (fb, error))
{
cogl_object_unref (fb);
return FALSE;
}
pipeline = cogl_pipeline_new (cogl_context);
cogl_pipeline_set_layer_texture (pipeline, 0, cursor_texture);
cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_LINEAR,
COGL_PIPELINE_FILTER_LINEAR);
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
cogl_framebuffer_draw_rectangle (fb, pipeline,
-1, 1, 1, -1);
cogl_object_unref (pipeline);
cogl_framebuffer_read_pixels (fb,
0, 0,
bitmap_width, bitmap_height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
(uint8_t *) bitmap_data);
cogl_object_unref (fb);
return TRUE;
}
static void
meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *src,
struct spa_meta_cursor *spa_meta_cursor)
{
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
MetaBackend *backend = get_backend (monitor_src);
MetaCursorRenderer *cursor_renderer =
meta_backend_get_cursor_renderer (backend);
MetaRenderer *renderer = meta_backend_get_renderer (backend);
MetaSpaType *spa_type = meta_screen_cast_stream_src_get_spa_type (src);
GError *error = NULL;
MetaCursorSprite *cursor_sprite;
CoglTexture *cursor_texture;
MetaMonitor *monitor;
MetaLogicalMonitor *logical_monitor;
MetaRectangle logical_monitor_layout;
ClutterRect logical_monitor_rect;
MetaRendererView *view;
float view_scale;
ClutterPoint cursor_position;
struct spa_meta_bitmap *spa_meta_bitmap;
cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer);
if (cursor_sprite)
cursor_texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
else
cursor_texture = NULL;
if (!is_cursor_in_stream (monitor_src))
{
spa_meta_cursor->id = 0;
return;
}
monitor = get_monitor (monitor_src);
logical_monitor = meta_monitor_get_logical_monitor (monitor);
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
logical_monitor_rect =
meta_rectangle_to_clutter_rect (&logical_monitor_layout);
view = meta_renderer_get_view_from_logical_monitor (renderer,
logical_monitor);
if (view)
view_scale = clutter_stage_view_get_scale (CLUTTER_STAGE_VIEW (view));
else
view_scale = 1.0;
cursor_position = meta_cursor_renderer_get_position (cursor_renderer);
cursor_position.x -= logical_monitor_rect.origin.x;
cursor_position.y -= logical_monitor_rect.origin.y;
cursor_position.x *= view_scale;
cursor_position.y *= view_scale;
spa_meta_cursor->id = 1;
spa_meta_cursor->position.x = (int32_t) roundf (cursor_position.x);
spa_meta_cursor->position.y = (int32_t) roundf (cursor_position.y);
if (!monitor_src->cursor_bitmap_invalid)
{
spa_meta_cursor->hotspot.x = 0;
spa_meta_cursor->hotspot.y = 0;
spa_meta_cursor->bitmap_offset = 0;
return;
}
monitor_src->cursor_bitmap_invalid = FALSE;
spa_meta_cursor->bitmap_offset = sizeof (struct spa_meta_cursor);
spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
spa_meta_cursor->bitmap_offset,
struct spa_meta_bitmap);
spa_meta_bitmap->format = spa_type->video_format.RGBA;
spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
if (cursor_texture)
{
float cursor_scale;
float bitmap_scale;
int hotspot_x, hotspot_y;
int texture_width, texture_height;
int bitmap_width, bitmap_height;
uint32_t *bitmap_data;
cursor_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
bitmap_scale = view_scale * cursor_scale;
meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
spa_meta_cursor->hotspot.x = (int32_t) roundf (hotspot_x * bitmap_scale);
spa_meta_cursor->hotspot.y = (int32_t) roundf (hotspot_y * bitmap_scale);
texture_width = cogl_texture_get_width (cursor_texture);
texture_height = cogl_texture_get_height (cursor_texture);
bitmap_width = texture_width * bitmap_scale;
bitmap_height = texture_height * bitmap_scale;
spa_meta_bitmap->size.width = bitmap_width;
spa_meta_bitmap->size.height = bitmap_height;
spa_meta_bitmap->stride = bitmap_width * 4;
bitmap_data = SPA_MEMBER (spa_meta_bitmap,
spa_meta_bitmap->offset,
uint32_t);
if (texture_width == bitmap_width &&
texture_height == bitmap_height)
{
cogl_texture_get_data (cursor_texture,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
texture_width * 4,
(uint8_t *) bitmap_data);
}
else
{
if (!draw_cursor_sprite_via_offscreen (monitor_src,
cursor_texture,
bitmap_width,
bitmap_height,
bitmap_data,
&error))
{
g_warning ("Failed to draw cursor via offscreen: %s",
error->message);
g_error_free (error);
spa_meta_cursor->id = 0;
}
}
}
else
{
spa_meta_cursor->hotspot.x = 0;
spa_meta_cursor->hotspot.y = 0;
*spa_meta_bitmap = (struct spa_meta_bitmap) { 0 };
}
}
static gboolean
meta_screen_cast_monitor_stream_src_is_cursor_sprite_inhibited (MetaHwCursorInhibitor *inhibitor,
MetaCursorSprite *cursor_sprite)
{
MetaScreenCastMonitorStreamSrc *monitor_src =
META_SCREEN_CAST_MONITOR_STREAM_SRC (inhibitor);
return is_cursor_in_stream (monitor_src);
}
static void
hw_cursor_inhibitor_iface_init (MetaHwCursorInhibitorInterface *iface)
{
iface->is_cursor_sprite_inhibited =
meta_screen_cast_monitor_stream_src_is_cursor_sprite_inhibited;
}
MetaScreenCastMonitorStreamSrc *
@@ -157,6 +564,7 @@ meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_s
static void
meta_screen_cast_monitor_stream_src_init (MetaScreenCastMonitorStreamSrc *monitor_src)
{
monitor_src->cursor_bitmap_invalid = TRUE;
}
static void
@@ -169,4 +577,6 @@ meta_screen_cast_monitor_stream_src_class_init (MetaScreenCastMonitorStreamSrcCl
src_class->enable = meta_screen_cast_monitor_stream_src_enable;
src_class->disable = meta_screen_cast_monitor_stream_src_disable;
src_class->record_frame = meta_screen_cast_monitor_stream_src_record_frame;
src_class->set_cursor_metadata =
meta_screen_cast_monitor_stream_src_set_cursor_metadata;
}

View File

@@ -105,12 +105,15 @@ meta_screen_cast_monitor_stream_get_monitor (MetaScreenCastMonitorStream *monito
}
MetaScreenCastMonitorStream *
meta_screen_cast_monitor_stream_new (GDBusConnection *connection,
MetaMonitorManager *monitor_manager,
MetaMonitor *monitor,
ClutterStage *stage,
GError **error)
meta_screen_cast_monitor_stream_new (MetaScreenCastSession *session,
GDBusConnection *connection,
MetaMonitor *monitor,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
GError **error)
{
MetaGpu *gpu = meta_monitor_get_gpu (monitor);
MetaMonitorManager *monitor_manager = meta_gpu_get_monitor_manager (gpu);
MetaScreenCastMonitorStream *monitor_stream;
if (!meta_monitor_is_active (monitor))
@@ -122,7 +125,9 @@ meta_screen_cast_monitor_stream_new (GDBusConnection *connection,
monitor_stream = g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM,
NULL,
error,
"session", session,
"connection", connection,
"cursor-mode", cursor_mode,
"monitor", monitor,
NULL);
if (!monitor_stream)

View File

@@ -27,6 +27,7 @@
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-screen-cast-stream.h"
#include "backends/meta-screen-cast.h"
#define META_TYPE_SCREEN_CAST_MONITOR_STREAM (meta_screen_cast_monitor_stream_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCastMonitorStream,
@@ -34,11 +35,12 @@ G_DECLARE_FINAL_TYPE (MetaScreenCastMonitorStream,
META, SCREEN_CAST_MONITOR_STREAM,
MetaScreenCastStream)
MetaScreenCastMonitorStream * meta_screen_cast_monitor_stream_new (GDBusConnection *connection,
MetaMonitorManager *monitor_manager,
MetaMonitor *monitor,
ClutterStage *stage,
GError **error);
MetaScreenCastMonitorStream * meta_screen_cast_monitor_stream_new (MetaScreenCastSession *session,
GDBusConnection *connection,
MetaMonitor *monitor,
ClutterStage *stage,
MetaScreenCastCursorMode cursor_mode,
GError **error);
ClutterStage * meta_screen_cast_monitor_stream_get_stage (MetaScreenCastMonitorStream *monitor_stream);

View File

@@ -26,8 +26,11 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-dbus-session-watcher.h"
#include "backends/meta-remote-access-controller-private.h"
#include "backends/meta-screen-cast-monitor-stream.h"
#include "backends/meta-screen-cast-stream.h"
#include "backends/meta-screen-cast-window-stream.h"
#include "core/display-private.h"
#define META_SCREEN_CAST_SESSION_DBUS_PATH "/org/gnome/Mutter/ScreenCast/Session"
@@ -35,12 +38,16 @@ struct _MetaScreenCastSession
{
MetaDBusScreenCastSessionSkeleton parent;
MetaScreenCast *screen_cast;
char *peer_name;
MetaScreenCastSessionType session_type;
char *object_path;
GList *streams;
MetaScreenCastSessionHandle *handle;
};
static void
@@ -57,6 +64,35 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastSession,
G_IMPLEMENT_INTERFACE (META_TYPE_DBUS_SESSION,
meta_dbus_session_init_iface))
struct _MetaScreenCastSessionHandle
{
MetaRemoteAccessHandle parent;
MetaScreenCastSession *session;
};
G_DEFINE_TYPE (MetaScreenCastSessionHandle,
meta_screen_cast_session_handle,
META_TYPE_REMOTE_ACCESS_HANDLE)
static MetaScreenCastSessionHandle *
meta_screen_cast_session_handle_new (MetaScreenCastSession *session);
static void
init_remote_access_handle (MetaScreenCastSession *session)
{
MetaBackend *backend = meta_get_backend ();
MetaRemoteAccessController *remote_access_controller;
MetaRemoteAccessHandle *remote_access_handle;
session->handle = meta_screen_cast_session_handle_new (session);
remote_access_controller = meta_backend_get_remote_access_controller (backend);
remote_access_handle = META_REMOTE_ACCESS_HANDLE (session->handle);
meta_remote_access_controller_notify_new_handle (remote_access_controller,
remote_access_handle);
}
gboolean
meta_screen_cast_session_start (MetaScreenCastSession *session,
GError **error)
@@ -71,6 +107,8 @@ meta_screen_cast_session_start (MetaScreenCastSession *session,
return FALSE;
}
init_remote_access_handle (session);
return TRUE;
}
@@ -94,6 +132,14 @@ meta_screen_cast_session_close (MetaScreenCastSession *session)
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (session));
if (session->handle)
{
MetaRemoteAccessHandle *remote_access_handle =
META_REMOTE_ACCESS_HANDLE (session->handle);
meta_remote_access_handle_notify_stopped (remote_access_handle);
}
g_object_unref (session);
}
@@ -115,6 +161,12 @@ meta_screen_cast_session_get_stream (MetaScreenCastSession *session,
return NULL;
}
MetaScreenCast *
meta_screen_cast_session_get_screen_cast (MetaScreenCastSession *session)
{
return session->screen_cast;
}
char *
meta_screen_cast_session_get_object_path (MetaScreenCastSession *session)
{
@@ -210,6 +262,20 @@ on_stream_closed (MetaScreenCastStream *stream,
meta_screen_cast_session_close (session);
}
static gboolean
is_valid_cursor_mode (MetaScreenCastCursorMode cursor_mode)
{
switch (cursor_mode)
{
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
return TRUE;
}
return FALSE;
}
static gboolean
handle_record_monitor (MetaDBusScreenCastSession *skeleton,
GDBusMethodInvocation *invocation,
@@ -223,6 +289,7 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitor *monitor;
MetaScreenCastCursorMode cursor_mode;
ClutterStage *stage;
GError *error = NULL;
MetaScreenCastMonitorStream *monitor_stream;
@@ -254,12 +321,28 @@ handle_record_monitor (MetaDBusScreenCastSession *skeleton,
return TRUE;
}
if (!g_variant_lookup (properties_variant, "cursor-mode", "u", &cursor_mode))
{
cursor_mode = META_SCREEN_CAST_CURSOR_MODE_HIDDEN;
}
else
{
if (!is_valid_cursor_mode (cursor_mode))
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Unknown cursor mode");
return TRUE;
}
}
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
monitor_stream = meta_screen_cast_monitor_stream_new (connection,
monitor_manager,
monitor_stream = meta_screen_cast_monitor_stream_new (session,
connection,
monitor,
stage,
cursor_mode,
&error);
if (!monitor_stream)
{
@@ -291,6 +374,15 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
GVariant *properties_variant)
{
MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton);
GDBusInterfaceSkeleton *interface_skeleton;
GDBusConnection *connection;
MetaWindow *window;
GError *error = NULL;
MetaDisplay *display;
GVariant *window_id_variant = NULL;
MetaScreenCastWindowStream *window_stream;
MetaScreenCastStream *stream;
char *stream_path;
if (!check_permission (session, invocation))
{
@@ -300,9 +392,60 @@ handle_record_window (MetaDBusScreenCastSession *skeleton,
return TRUE;
}
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Recording a window not yet supported");
if (properties_variant)
window_id_variant = g_variant_lookup_value (properties_variant,
"window-id",
G_VARIANT_TYPE ("t"));
display = meta_get_display ();
if (window_id_variant)
{
uint64_t window_id;
g_variant_get (window_id_variant, "t", &window_id);
window = meta_display_get_window_from_id (display, window_id);
}
else
{
window = meta_display_get_focus_window (display);
}
if (!window)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Window not found");
return TRUE;
}
interface_skeleton = G_DBUS_INTERFACE_SKELETON (skeleton);
connection = g_dbus_interface_skeleton_get_connection (interface_skeleton);
window_stream = meta_screen_cast_window_stream_new (session,
connection,
window,
&error);
if (!window_stream)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_FAILED,
"Failed to record window: %s",
error->message);
g_error_free (error);
return TRUE;
}
stream = META_SCREEN_CAST_STREAM (window_stream);
stream_path = meta_screen_cast_stream_get_object_path (stream);
session->streams = g_list_append (session->streams, stream);
g_signal_connect (stream, "closed", G_CALLBACK (on_stream_closed), session);
meta_dbus_screen_cast_session_complete_record_window (skeleton,
invocation,
stream_path);
return TRUE;
}
@@ -339,6 +482,7 @@ meta_screen_cast_session_new (MetaScreenCast *screen_cast,
static unsigned int global_session_number = 0;
session = g_object_new (META_TYPE_SCREEN_CAST_SESSION, NULL);
session->screen_cast = screen_cast;
session->session_type = session_type;
session->peer_name = g_strdup (peer_name);
session->object_path =
@@ -361,6 +505,7 @@ meta_screen_cast_session_finalize (GObject *object)
{
MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (object);
g_clear_object (&session->handle);
g_free (session->peer_name);
g_free (session->object_path);
@@ -379,3 +524,40 @@ meta_screen_cast_session_class_init (MetaScreenCastSessionClass *klass)
object_class->finalize = meta_screen_cast_session_finalize;
}
static MetaScreenCastSessionHandle *
meta_screen_cast_session_handle_new (MetaScreenCastSession *session)
{
MetaScreenCastSessionHandle *handle;
handle = g_object_new (META_TYPE_SCREEN_CAST_SESSION_HANDLE, NULL);
handle->session = session;
return handle;
}
static void
meta_screen_cast_session_handle_stop (MetaRemoteAccessHandle *handle)
{
MetaScreenCastSession *session;
session = META_SCREEN_CAST_SESSION_HANDLE (handle)->session;
if (!session)
return;
meta_screen_cast_session_close (session);
}
static void
meta_screen_cast_session_handle_init (MetaScreenCastSessionHandle *handle)
{
}
static void
meta_screen_cast_session_handle_class_init (MetaScreenCastSessionHandleClass *klass)
{
MetaRemoteAccessHandleClass *remote_access_handle_class =
META_REMOTE_ACCESS_HANDLE_CLASS (klass);
remote_access_handle_class->stop = meta_screen_cast_session_handle_stop;
}

View File

@@ -26,6 +26,7 @@
#include "backends/meta-screen-cast.h"
#include "backends/meta-screen-cast-stream.h"
#include "meta/meta-remote-access-controller.h"
typedef enum _MetaScreenCastSessionType
{
@@ -38,6 +39,12 @@ G_DECLARE_FINAL_TYPE (MetaScreenCastSession, meta_screen_cast_session,
META, SCREEN_CAST_SESSION,
MetaDBusScreenCastSessionSkeleton)
#define META_TYPE_SCREEN_CAST_SESSION_HANDLE (meta_screen_cast_session_handle_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCastSessionHandle,
meta_screen_cast_session_handle,
META, SCREEN_CAST_SESSION_HANDLE,
MetaRemoteAccessHandle)
char * meta_screen_cast_session_get_object_path (MetaScreenCastSession *session);
MetaScreenCastSession * meta_screen_cast_session_new (MetaScreenCast *screen_cast,
@@ -53,4 +60,6 @@ void meta_screen_cast_session_close (MetaScreenCastSession *session);
MetaScreenCastStream * meta_screen_cast_session_get_stream (MetaScreenCastSession *session,
const char *path);
MetaScreenCast * meta_screen_cast_session_get_screen_cast (MetaScreenCastSession *session);
#endif /* META_SCREEN_CAST_SESSION_H */

View File

@@ -40,6 +40,10 @@
#define PRIVATE_OWNER_FROM_FIELD(TypeName, field_ptr, field_name) \
(TypeName *)((guint8 *)(field_ptr) - G_PRIVATE_OFFSET (TypeName, field_name))
#define CURSOR_META_SIZE(width, height) \
(sizeof (struct spa_meta_cursor) + \
sizeof (struct spa_meta_bitmap) + width * height * 4)
enum
{
PROP_0,
@@ -57,14 +61,6 @@ enum
static guint signals[N_SIGNALS];
typedef struct _MetaSpaType
{
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
struct spa_type_format_video format_video;
struct spa_type_video_format video_format;
} MetaSpaType;
typedef struct _MetaPipeWireSource
{
GSource base;
@@ -91,6 +87,9 @@ typedef struct _MetaScreenCastStreamSrcPrivate
struct spa_video_info_raw video_format;
uint64_t last_frame_timestamp_us;
int stream_width;
int stream_height;
} MetaScreenCastStreamSrcPrivate;
static void
@@ -117,14 +116,81 @@ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
klass->get_specs (src, width, height, frame_rate);
}
static void
static gboolean
meta_screen_cast_stream_src_get_videocrop (MetaScreenCastStreamSrc *src,
MetaRectangle *crop_rect)
{
MetaScreenCastStreamSrcClass *klass =
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
if (klass->get_videocrop)
return klass->get_videocrop (src, crop_rect);
return FALSE;
}
static gboolean
meta_screen_cast_stream_src_record_frame (MetaScreenCastStreamSrc *src,
uint8_t *data)
{
MetaScreenCastStreamSrcClass *klass =
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
klass->record_frame (src, data);
return klass->record_frame (src, data);
}
static void
meta_screen_cast_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *src,
struct spa_meta_cursor *spa_meta_cursor)
{
MetaScreenCastStreamSrcClass *klass =
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
if (klass->set_cursor_metadata)
klass->set_cursor_metadata (src, spa_meta_cursor);
}
MetaSpaType *
meta_screen_cast_stream_src_get_spa_type (MetaScreenCastStreamSrc *src)
{
MetaScreenCastStreamSrcPrivate *priv =
meta_screen_cast_stream_src_get_instance_private (src);
return &priv->spa_type;
}
static void
add_cursor_metadata (MetaScreenCastStreamSrc *src,
struct spa_buffer *spa_buffer)
{
MetaScreenCastStreamSrcPrivate *priv =
meta_screen_cast_stream_src_get_instance_private (src);
MetaSpaType *spa_type = &priv->spa_type;
struct spa_meta_cursor *spa_meta_cursor;
spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
if (spa_meta_cursor)
meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
}
static void
maybe_record_cursor (MetaScreenCastStreamSrc *src,
struct spa_buffer *spa_buffer,
uint8_t *data)
{
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
switch (meta_screen_cast_stream_get_cursor_mode (stream))
{
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
return;
case META_SCREEN_CAST_CURSOR_MODE_METADATA:
add_cursor_metadata (src, spa_buffer);
return;
}
g_assert_not_reached ();
}
void
@@ -132,8 +198,9 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
{
MetaScreenCastStreamSrcPrivate *priv =
meta_screen_cast_stream_src_get_instance_private (src);
uint32_t buffer_id;
struct spa_buffer *buffer;
MetaRectangle crop_rect;
struct pw_buffer *buffer;
struct spa_buffer *spa_buffer;
uint8_t *map = NULL;
uint8_t *data;
uint64_t now_us;
@@ -148,22 +215,24 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
if (!priv->pipewire_stream)
return;
buffer_id = pw_stream_get_empty_buffer (priv->pipewire_stream);
if (buffer_id == SPA_ID_INVALID)
return;
buffer = pw_stream_peek_buffer (priv->pipewire_stream, buffer_id);
buffer = pw_stream_dequeue_buffer (priv->pipewire_stream);
if (!buffer)
{
g_warning ("Failed to peek at PipeWire buffer");
g_warning ("Failed to dequeue at PipeWire buffer");
return;
}
if (buffer->datas[0].type == priv->pipewire_type->data.MemFd)
spa_buffer = buffer->buffer;
if (spa_buffer->datas[0].data)
{
map = mmap (NULL, buffer->datas[0].maxsize + buffer->datas[0].mapoffset,
data = spa_buffer->datas[0].data;
}
else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
{
map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
PROT_READ | PROT_WRITE, MAP_SHARED,
buffer->datas[0].fd, 0);
spa_buffer->datas[0].fd, 0);
if (map == MAP_FAILED)
{
g_warning ("Failed to mmap pipewire stream buffer: %s\n",
@@ -171,26 +240,54 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
return;
}
data = SPA_MEMBER (map, buffer->datas[0].mapoffset, uint8_t);
}
else if (buffer->datas[0].type == priv->pipewire_type->data.MemPtr)
{
data = buffer->datas[0].data;
data = SPA_MEMBER (map, spa_buffer->datas[0].mapoffset, uint8_t);
}
else
{
g_warning ("Unhandled spa buffer type: %d", spa_buffer->datas[0].type);
return;
}
meta_screen_cast_stream_src_record_frame (src, data);
if (meta_screen_cast_stream_src_record_frame (src, data))
{
struct spa_meta_video_crop *spa_meta_video_crop;
spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
/* Update VideoCrop if needed */
spa_meta_video_crop =
spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
if (spa_meta_video_crop)
{
if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
{
spa_meta_video_crop->x = crop_rect.x;
spa_meta_video_crop->y = crop_rect.y;
spa_meta_video_crop->width = crop_rect.width;
spa_meta_video_crop->height = crop_rect.height;
}
else
{
spa_meta_video_crop->x = 0;
spa_meta_video_crop->y = 0;
spa_meta_video_crop->width = priv->stream_width;
spa_meta_video_crop->height = priv->stream_height;
}
}
}
else
{
spa_buffer->datas[0].chunk->size = 0;
}
maybe_record_cursor (src, spa_buffer, data);
priv->last_frame_timestamp_us = now_us;
if (map)
munmap (map, buffer->datas[0].maxsize + buffer->datas[0].mapoffset);
munmap (map, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset);
buffer->datas[0].chunk->size = buffer->datas[0].maxsize;
pw_stream_send_buffer (priv->pipewire_stream, buffer_id);
pw_stream_queue_buffer (priv->pipewire_stream, buffer);
}
static gboolean
@@ -266,8 +363,8 @@ on_stream_state_changed (void *data,
}
static void
on_stream_format_changed (void *data,
struct spa_pod *format)
on_stream_format_changed (void *data,
const struct spa_pod *format)
{
MetaScreenCastStreamSrc *src = data;
MetaScreenCastStreamSrcPrivate *priv =
@@ -276,7 +373,7 @@ on_stream_format_changed (void *data,
uint8_t params_buffer[1024];
int32_t width, height, stride, size;
struct spa_pod_builder pod_builder;
struct spa_pod *params[1];
const struct spa_pod *params[3];
const int bpp = 4;
if (!format)
@@ -304,6 +401,18 @@ on_stream_format_changed (void *data,
":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
":", pipewire_type->param_buffers.align, "i", 16);
params[1] = spa_pod_builder_object (
&pod_builder,
pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
params[2] = spa_pod_builder_object (
&pod_builder,
pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
pw_stream_finish_format (priv->pipewire_stream, 0,
params, G_N_ELEMENTS (params));
}
@@ -326,7 +435,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
MetaSpaType *spa_type = &priv->spa_type;
struct pw_type *pipewire_type = priv->pipewire_type;
int width, height;
float frame_rate;
MetaFraction frame_rate_fraction;
struct spa_fraction max_framerate;
@@ -345,7 +453,10 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
return NULL;
}
meta_screen_cast_stream_src_get_specs (src, &width, &height, &frame_rate);
meta_screen_cast_stream_src_get_specs (src,
&priv->stream_width,
&priv->stream_height,
&frame_rate);
frame_rate_fraction = meta_fraction_from_double (frame_rate);
min_framerate = SPA_FRACTION (1, 1);
@@ -358,11 +469,12 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
"I", spa_type->media_type.video,
"I", spa_type->media_subtype.raw,
":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
":", spa_type->format_video.size, "R", &SPA_RECTANGLE (width, height),
":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
priv->stream_height),
":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
":", spa_type->format_video.max_framerate, "Fr", &max_framerate,
PROP_RANGE (&min_framerate,
&max_framerate));
":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
PROP_RANGE (&min_framerate,
&max_framerate));
pw_stream_add_listener (pipewire_stream,
&priv->pipewire_stream_listener,
@@ -372,7 +484,8 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
result = pw_stream_connect (pipewire_stream,
PW_DIRECTION_OUTPUT,
NULL,
PW_STREAM_FLAG_NONE,
(PW_STREAM_FLAG_DRIVER |
PW_STREAM_FLAG_MAP_BUFFERS),
params, G_N_ELEMENTS (params));
if (result != 0)
{
@@ -469,6 +582,7 @@ init_spa_type (MetaSpaType *type,
spa_type_media_subtype_map (map, &type->media_subtype);
spa_type_format_video_map (map, &type->format_video);
spa_type_video_format_map (map, &type->video_format);
type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
}
static MetaPipeWireSource *

View File

@@ -24,8 +24,25 @@
#define META_SCREEN_CAST_STREAM_SRC_H
#include <glib-object.h>
#include <spa/param/video/format-utils.h>
#include <spa/buffer/meta.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-cursor-renderer.h"
#include "backends/meta-cursor.h"
#include "backends/meta-renderer.h"
#include "clutter/clutter.h"
#include "cogl/cogl.h"
#include "meta/boxes.h"
typedef struct _MetaSpaType
{
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
struct spa_type_format_video format_video;
struct spa_type_video_format video_format;
uint32_t meta_cursor;
} MetaSpaType;
typedef struct _MetaScreenCastStream MetaScreenCastStream;
@@ -45,12 +62,18 @@ struct _MetaScreenCastStreamSrcClass
float *frame_rate);
void (* enable) (MetaScreenCastStreamSrc *src);
void (* disable) (MetaScreenCastStreamSrc *src);
void (* record_frame) (MetaScreenCastStreamSrc *src,
uint8_t *data);
gboolean (* record_frame) (MetaScreenCastStreamSrc *src,
uint8_t *data);
gboolean (* get_videocrop) (MetaScreenCastStreamSrc *src,
MetaRectangle *crop_rect);
void (* set_cursor_metadata) (MetaScreenCastStreamSrc *src,
struct spa_meta_cursor *spa_meta_cursor);
};
void meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src);
MetaScreenCastStream * meta_screen_cast_stream_src_get_stream (MetaScreenCastStreamSrc *src);
MetaSpaType * meta_screen_cast_stream_src_get_spa_type (MetaScreenCastStreamSrc *src);
#endif /* META_SCREEN_CAST_STREAM_SRC_H */

View File

@@ -24,13 +24,17 @@
#include "backends/meta-screen-cast-stream.h"
#include "backends/meta-screen-cast-session.h"
#define META_SCREEN_CAST_STREAM_DBUS_PATH "/org/gnome/Mutter/ScreenCast/Stream"
enum
{
PROP_0,
PROP_SESSION,
PROP_CONNECTION,
PROP_CURSOR_MODE,
};
enum
@@ -44,9 +48,13 @@ static guint signals[N_SIGNALS];
typedef struct _MetaScreenCastStreamPrivate
{
MetaScreenCastSession *session;
GDBusConnection *connection;
char *object_path;
MetaScreenCastCursorMode cursor_mode;
MetaScreenCastStreamSrc *src;
} MetaScreenCastStreamPrivate;
@@ -97,6 +105,15 @@ on_stream_src_ready (MetaScreenCastStreamSrc *src,
meta_dbus_screen_cast_stream_emit_pipewire_stream_added (skeleton, node_id);
}
MetaScreenCastSession *
meta_screen_cast_stream_get_session (MetaScreenCastStream *stream)
{
MetaScreenCastStreamPrivate *priv =
meta_screen_cast_stream_get_instance_private (stream);
return priv->session;
}
gboolean
meta_screen_cast_stream_start (MetaScreenCastStream *stream,
GError **error)
@@ -150,6 +167,15 @@ meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
y);
}
MetaScreenCastCursorMode
meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream)
{
MetaScreenCastStreamPrivate *priv =
meta_screen_cast_stream_get_instance_private (stream);
return priv->cursor_mode;
}
static void
meta_screen_cast_stream_set_property (GObject *object,
guint prop_id,
@@ -162,9 +188,15 @@ meta_screen_cast_stream_set_property (GObject *object,
switch (prop_id)
{
case PROP_SESSION:
priv->session = g_value_get_object (value);
break;
case PROP_CONNECTION:
priv->connection = g_value_get_object (value);
break;
case PROP_CURSOR_MODE:
priv->cursor_mode = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -182,9 +214,15 @@ meta_screen_cast_stream_get_property (GObject *object,
switch (prop_id)
{
case PROP_SESSION:
g_value_set_object (value, priv->session);
break;
case PROP_CONNECTION:
g_value_set_object (value, priv->connection);
break;
case PROP_CURSOR_MODE:
g_value_set_uint (value, priv->cursor_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -256,6 +294,16 @@ meta_screen_cast_stream_class_init (MetaScreenCastStreamClass *klass)
object_class->set_property = meta_screen_cast_stream_set_property;
object_class->get_property = meta_screen_cast_stream_get_property;
g_object_class_install_property (object_class,
PROP_SESSION,
g_param_spec_object ("session",
"session",
"MetaScreenSession",
META_TYPE_SCREEN_CAST_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_CONNECTION,
g_param_spec_object ("connection",
@@ -266,6 +314,18 @@ meta_screen_cast_stream_class_init (MetaScreenCastStreamClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_CURSOR_MODE,
g_param_spec_uint ("cursor-mode",
"cursor-mode",
"Cursor mode",
META_SCREEN_CAST_CURSOR_MODE_HIDDEN,
META_SCREEN_CAST_CURSOR_MODE_METADATA,
META_SCREEN_CAST_CURSOR_MODE_HIDDEN,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
signals[CLOSED] = g_signal_new ("closed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,

View File

@@ -26,8 +26,12 @@
#include <glib-object.h>
#include "backends/meta-screen-cast-stream-src.h"
#include "backends/meta-screen-cast.h"
#include "meta-dbus-screen-cast.h"
typedef struct _MetaScreenCastSession MetaScreenCastSession;
#define META_TYPE_SCREEN_CAST_STREAM (meta_screen_cast_stream_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaScreenCastStream, meta_screen_cast_stream,
META, SCREEN_CAST_STREAM,
@@ -48,6 +52,8 @@ struct _MetaScreenCastStreamClass
double *y);
};
MetaScreenCastSession * meta_screen_cast_stream_get_session (MetaScreenCastStream *stream);
gboolean meta_screen_cast_stream_start (MetaScreenCastStream *stream,
GError **error);
@@ -61,4 +67,6 @@ void meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
double *x,
double *y);
MetaScreenCastCursorMode meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream);
#endif /* META_SCREEN_CAST_STREAM_H */

View File

@@ -0,0 +1,247 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "backends/meta-screen-cast-window-stream-src.h"
#include "backends/meta-backend-private.h"
#include "backends/meta-screen-cast-window.h"
#include "backends/meta-screen-cast-window-stream.h"
#include "compositor/meta-window-actor-private.h"
struct _MetaScreenCastWindowStreamSrc
{
MetaScreenCastStreamSrc parent;
MetaWindowActor *window_actor;
unsigned long actor_painted_handler_id;
unsigned long actor_destroyed_handler_id;
};
G_DEFINE_TYPE (MetaScreenCastWindowStreamSrc,
meta_screen_cast_window_stream_src,
META_TYPE_SCREEN_CAST_STREAM_SRC)
static MetaScreenCastWindowStream *
get_window_stream (MetaScreenCastWindowStreamSrc *window_src)
{
MetaScreenCastStreamSrc *src;
MetaScreenCastStream *stream;
src = META_SCREEN_CAST_STREAM_SRC (window_src);
stream = meta_screen_cast_stream_src_get_stream (src);
return META_SCREEN_CAST_WINDOW_STREAM (stream);
}
static MetaWindow *
get_window (MetaScreenCastWindowStreamSrc *window_src)
{
MetaScreenCastWindowStream *window_stream;
window_stream = get_window_stream (window_src);
return meta_screen_cast_window_stream_get_window (window_stream);
}
static int
get_stream_width (MetaScreenCastWindowStreamSrc *window_src)
{
MetaScreenCastWindowStream *window_stream;
window_stream = get_window_stream (window_src);
return meta_screen_cast_window_stream_get_width (window_stream);
}
static int
get_stream_height (MetaScreenCastWindowStreamSrc *window_src)
{
MetaScreenCastWindowStream *window_stream;
window_stream = get_window_stream (window_src);
return meta_screen_cast_window_stream_get_height (window_stream);
}
static gboolean
capture_into (MetaScreenCastWindowStreamSrc *window_src,
uint8_t *data)
{
MetaRectangle stream_rect;
MetaScreenCastWindow *screen_cast_window;
stream_rect.x = 0;
stream_rect.y = 0;
stream_rect.width = get_stream_width (window_src);
stream_rect.height = get_stream_height (window_src);
screen_cast_window = META_SCREEN_CAST_WINDOW (window_src->window_actor);
meta_screen_cast_window_capture_into (screen_cast_window, &stream_rect, data);
return TRUE;
}
static void
meta_screen_cast_window_stream_src_get_specs (MetaScreenCastStreamSrc *src,
int *width,
int *height,
float *frame_rate)
{
MetaScreenCastWindowStreamSrc *window_src =
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
*width = get_stream_width (window_src);
*height = get_stream_height (window_src);
*frame_rate = 60.0f;
}
static gboolean
meta_screen_cast_window_stream_src_get_videocrop (MetaScreenCastStreamSrc *src,
MetaRectangle *crop_rect)
{
MetaScreenCastWindowStreamSrc *window_src =
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
MetaScreenCastWindow *screen_cast_window;
MetaRectangle stream_rect;
screen_cast_window = META_SCREEN_CAST_WINDOW (window_src->window_actor);
meta_screen_cast_window_get_frame_bounds (screen_cast_window, crop_rect);
stream_rect.x = 0;
stream_rect.y = 0;
stream_rect.width = get_stream_width (window_src);
stream_rect.height = get_stream_height (window_src);
meta_rectangle_intersect (crop_rect, &stream_rect, crop_rect);
return TRUE;
}
static void
meta_screen_cast_window_stream_src_stop (MetaScreenCastWindowStreamSrc *window_src)
{
if (!window_src->window_actor)
return;
if (window_src->actor_painted_handler_id)
g_signal_handler_disconnect (window_src->window_actor,
window_src->actor_painted_handler_id);
window_src->actor_painted_handler_id = 0;
if (window_src->actor_destroyed_handler_id)
g_signal_handler_disconnect (window_src->window_actor,
window_src->actor_destroyed_handler_id);
window_src->actor_destroyed_handler_id = 0;
}
static void
window_actor_painted (MetaWindowActor *actor,
MetaScreenCastWindowStreamSrc *window_src)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (window_src);
meta_screen_cast_stream_src_maybe_record_frame (src);
}
static void
window_actor_destroyed (MetaWindowActor *actor,
MetaScreenCastWindowStreamSrc *window_src)
{
meta_screen_cast_window_stream_src_stop (window_src);
window_src->window_actor = NULL;
}
static void
meta_screen_cast_window_stream_src_enable (MetaScreenCastStreamSrc *src)
{
MetaScreenCastWindowStreamSrc *window_src =
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
MetaWindowActor *window_actor;
window_actor = meta_window_actor_from_window (get_window (window_src));
if (!window_actor)
return;
window_src->window_actor = window_actor;
window_src->actor_painted_handler_id =
g_signal_connect_after (window_src->window_actor,
"paint",
G_CALLBACK (window_actor_painted),
window_src);
window_src->actor_destroyed_handler_id =
g_signal_connect (window_src->window_actor,
"destroy",
G_CALLBACK (window_actor_destroyed),
window_src);
}
static void
meta_screen_cast_window_stream_src_disable (MetaScreenCastStreamSrc *src)
{
MetaScreenCastWindowStreamSrc *window_src =
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
meta_screen_cast_window_stream_src_stop (window_src);
}
static gboolean
meta_screen_cast_window_stream_src_record_frame (MetaScreenCastStreamSrc *src,
uint8_t *data)
{
MetaScreenCastWindowStreamSrc *window_src =
META_SCREEN_CAST_WINDOW_STREAM_SRC (src);
capture_into (window_src, data);
return TRUE;
}
MetaScreenCastWindowStreamSrc *
meta_screen_cast_window_stream_src_new (MetaScreenCastWindowStream *window_stream,
GError **error)
{
return g_initable_new (META_TYPE_SCREEN_CAST_WINDOW_STREAM_SRC, NULL, error,
"stream", window_stream,
NULL);
}
static void
meta_screen_cast_window_stream_src_init (MetaScreenCastWindowStreamSrc *window_src)
{
}
static void
meta_screen_cast_window_stream_src_class_init (MetaScreenCastWindowStreamSrcClass *klass)
{
MetaScreenCastStreamSrcClass *src_class =
META_SCREEN_CAST_STREAM_SRC_CLASS (klass);
src_class->get_specs = meta_screen_cast_window_stream_src_get_specs;
src_class->enable = meta_screen_cast_window_stream_src_enable;
src_class->disable = meta_screen_cast_window_stream_src_disable;
src_class->record_frame = meta_screen_cast_window_stream_src_record_frame;
src_class->get_videocrop = meta_screen_cast_window_stream_src_get_videocrop;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#ifndef META_SCREEN_CAST_WINDOW_STREAM_SRC_H
#define META_SCREEN_CAST_WINDOW_STREAM_SRC_H
#include "backends/meta-screen-cast-stream-src.h"
typedef struct _MetaScreenCastWindowStream MetaScreenCastWindowStream;
#define META_TYPE_SCREEN_CAST_WINDOW_STREAM_SRC (meta_screen_cast_window_stream_src_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCastWindowStreamSrc,
meta_screen_cast_window_stream_src,
META, SCREEN_CAST_WINDOW_STREAM_SRC,
MetaScreenCastStreamSrc)
MetaScreenCastWindowStreamSrc * meta_screen_cast_window_stream_src_new (MetaScreenCastWindowStream *window_stream,
GError **error);
#endif /* META_SCREEN_CAST_WINDOW_STREAM_SRC_H */

View File

@@ -0,0 +1,272 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "backends/meta-screen-cast-window-stream.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-screen-cast-window.h"
#include "backends/meta-screen-cast-window-stream-src.h"
#include "compositor/meta-window-actor-private.h"
#include "core/window-private.h"
enum
{
PROP_0,
PROP_WINDOW,
};
struct _MetaScreenCastWindowStream
{
MetaScreenCastStream parent;
MetaWindow *window;
int stream_width;
int stream_height;
unsigned long window_unmanaged_handler_id;
};
G_DEFINE_TYPE (MetaScreenCastWindowStream,
meta_screen_cast_window_stream,
META_TYPE_SCREEN_CAST_STREAM)
MetaWindow *
meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream)
{
return window_stream->window;
}
int
meta_screen_cast_window_stream_get_width (MetaScreenCastWindowStream *window_stream)
{
return window_stream->stream_width;
}
int
meta_screen_cast_window_stream_get_height (MetaScreenCastWindowStream *window_stream)
{
return window_stream->stream_height;
}
MetaScreenCastWindowStream *
meta_screen_cast_window_stream_new (MetaScreenCastSession *session,
GDBusConnection *connection,
MetaWindow *window,
GError **error)
{
MetaScreenCastWindowStream *window_stream;
MetaLogicalMonitor *logical_monitor;
int scale;
logical_monitor = meta_window_get_main_logical_monitor (window);
if (!logical_monitor)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Main logical monitor not found");
return NULL;
}
window_stream = g_initable_new (META_TYPE_SCREEN_CAST_WINDOW_STREAM,
NULL,
error,
"session", session,
"connection", connection,
"window", window,
NULL);
if (!window_stream)
return NULL;
window_stream->window = window;
/* We cannot set the stream size to the exact size of the window, because
* windows can be resized, whereas streams cannot.
* So we set a size equals to the size of the logical monitor for the window.
*/
scale = (int) ceil (meta_logical_monitor_get_scale (logical_monitor));
window_stream->stream_width = logical_monitor->rect.width * scale;
window_stream->stream_height = logical_monitor->rect.height * scale;
return window_stream;
}
static MetaScreenCastStreamSrc *
meta_screen_cast_window_stream_create_src (MetaScreenCastStream *stream,
GError **error)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (stream);
MetaScreenCastWindowStreamSrc *window_stream_src;
window_stream_src = meta_screen_cast_window_stream_src_new (window_stream,
error);
if (!window_stream_src)
return NULL;
return META_SCREEN_CAST_STREAM_SRC (window_stream_src);
}
static void
meta_screen_cast_window_stream_set_parameters (MetaScreenCastStream *stream,
GVariantBuilder *parameters_builder)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (stream);
MetaScreenCastWindow *screen_cast_window =
META_SCREEN_CAST_WINDOW (meta_window_actor_from_window (window_stream->window));
MetaRectangle bounds;
meta_screen_cast_window_get_buffer_bounds (screen_cast_window, &bounds);
g_variant_builder_add (parameters_builder, "{sv}",
"position",
g_variant_new ("(ii)",
bounds.x, bounds.y));
g_variant_builder_add (parameters_builder, "{sv}",
"size",
g_variant_new ("(ii)",
bounds.width,
bounds.height));
}
static void
meta_screen_cast_window_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (stream);
MetaScreenCastWindow *screen_cast_window =
META_SCREEN_CAST_WINDOW (meta_window_actor_from_window (window_stream->window));
meta_screen_cast_window_transform_relative_position (screen_cast_window,
stream_x,
stream_y,
x,
y);
}
static void
on_window_unmanaged (MetaScreenCastWindowStream *window_stream)
{
meta_screen_cast_stream_close (META_SCREEN_CAST_STREAM (window_stream));
}
static void
meta_screen_cast_window_stream_constructed (GObject *object)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
window_stream->window_unmanaged_handler_id =
g_signal_connect_swapped (window_stream->window, "unmanaged",
G_CALLBACK (on_window_unmanaged),
window_stream);
G_OBJECT_CLASS (meta_screen_cast_window_stream_parent_class)->constructed (object);
}
static void
meta_screen_cast_window_stream_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
switch (prop_id)
{
case PROP_WINDOW:
window_stream->window = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
meta_screen_cast_window_stream_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
switch (prop_id)
{
case PROP_WINDOW:
g_value_set_object (value, window_stream->window);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
meta_screen_cast_window_stream_finalize (GObject *object)
{
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
g_signal_handler_disconnect (window_stream->window,
window_stream->window_unmanaged_handler_id);
G_OBJECT_CLASS (meta_screen_cast_window_stream_parent_class)->finalize (object);
}
static void
meta_screen_cast_window_stream_init (MetaScreenCastWindowStream *window_stream)
{
}
static void
meta_screen_cast_window_stream_class_init (MetaScreenCastWindowStreamClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaScreenCastStreamClass *stream_class =
META_SCREEN_CAST_STREAM_CLASS (klass);
object_class->constructed = meta_screen_cast_window_stream_constructed;
object_class->set_property = meta_screen_cast_window_stream_set_property;
object_class->get_property = meta_screen_cast_window_stream_get_property;
object_class->finalize = meta_screen_cast_window_stream_finalize;
stream_class->create_src = meta_screen_cast_window_stream_create_src;
stream_class->set_parameters = meta_screen_cast_window_stream_set_parameters;
stream_class->transform_position = meta_screen_cast_window_stream_transform_position;
g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window",
"window",
"MetaWindow",
META_TYPE_WINDOW,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#ifndef META_SCREEN_CAST_WINDOW_STREAM_H
#define META_SCREEN_CAST_WINDOW_STREAM_H
#include <glib-object.h>
#include "backends/meta-screen-cast-stream.h"
#include "meta/window.h"
#define META_TYPE_SCREEN_CAST_WINDOW_STREAM (meta_screen_cast_window_stream_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCastWindowStream,
meta_screen_cast_window_stream,
META, SCREEN_CAST_WINDOW_STREAM,
MetaScreenCastStream)
MetaScreenCastWindowStream * meta_screen_cast_window_stream_new (MetaScreenCastSession *session,
GDBusConnection *connection,
MetaWindow *window,
GError **error);
MetaWindow * meta_screen_cast_window_stream_get_window (MetaScreenCastWindowStream *window_stream);
int meta_screen_cast_window_stream_get_width (MetaScreenCastWindowStream *window_stream);
int meta_screen_cast_window_stream_get_height (MetaScreenCastWindowStream *window_stream);
#endif /* META_SCREEN_CAST_WINDOW_STREAM_H */

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "backends/meta-screen-cast-window.h"
G_DEFINE_INTERFACE (MetaScreenCastWindow, meta_screen_cast_window, G_TYPE_OBJECT)
static void
meta_screen_cast_window_default_init (MetaScreenCastWindowInterface *iface)
{
}
void
meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_buffer_bounds (screen_cast_window,
bounds);
}
void
meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_frame_bounds (screen_cast_window,
bounds);
}
void
meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *screen_cast_window,
double x,
double y,
double *x_out,
double *y_out)
{
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->transform_relative_position (screen_cast_window,
x,
y,
x_out,
y_out);
}
void
meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds,
uint8_t *data)
{
META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->capture_into (screen_cast_window,
bounds,
data);
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2018 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#ifndef META_SCREEN_CAST_WINDOW_H
#define META_SCREEN_CAST_WINDOW_H
#include <stdint.h>
#include <glib-object.h>
#include "meta/boxes.h"
G_BEGIN_DECLS
#define META_TYPE_SCREEN_CAST_WINDOW (meta_screen_cast_window_get_type ())
G_DECLARE_INTERFACE (MetaScreenCastWindow, meta_screen_cast_window,
META, SCREEN_CAST_WINDOW, GObject)
struct _MetaScreenCastWindowInterface
{
GTypeInterface parent_iface;
void (*get_buffer_bounds) (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void (*get_frame_bounds) (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void (*transform_relative_position) (MetaScreenCastWindow *screen_cast_window,
double x,
double y,
double *x_out,
double *y_out);
void (*capture_into) (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds,
uint8_t *data);
};
void meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds);
void meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *screen_cast_window,
double x,
double y,
double *x_out,
double *y_out);
void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds,
uint8_t *data);
G_END_DECLS
#endif /* META_SCREEN_CAST_WINDOW_H */

View File

@@ -43,6 +43,7 @@ struct _MetaScreenCast
GList *sessions;
MetaDbusSessionWatcher *session_watcher;
MetaBackend *backend;
};
static void
@@ -62,12 +63,20 @@ meta_screen_cast_get_connection (MetaScreenCast *screen_cast)
return g_dbus_interface_skeleton_get_connection (interface_skeleton);
}
MetaBackend *
meta_screen_cast_get_backend (MetaScreenCast *screen_cast)
{
return screen_cast->backend;
}
static gboolean
register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
const char *remote_desktop_session_id,
GError **error)
{
MetaBackend *backend = meta_get_backend ();
MetaScreenCast *screen_cast =
meta_screen_cast_session_get_screen_cast (session);
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
MetaRemoteDesktop *remote_desktop = meta_backend_get_remote_desktop (backend);
MetaRemoteDesktopSession *remote_desktop_session;
@@ -244,11 +253,13 @@ meta_screen_cast_finalize (GObject *object)
}
MetaScreenCast *
meta_screen_cast_new (MetaDbusSessionWatcher *session_watcher)
meta_screen_cast_new (MetaBackend *backend,
MetaDbusSessionWatcher *session_watcher)
{
MetaScreenCast *screen_cast;
screen_cast = g_object_new (META_TYPE_SCREEN_CAST, NULL);
screen_cast->backend = backend;
screen_cast->session_watcher = session_watcher;
return screen_cast;

View File

@@ -25,9 +25,17 @@
#include <glib-object.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-dbus-session-watcher.h"
#include "meta-dbus-screen-cast.h"
typedef enum _MetaScreenCastCursorMode
{
META_SCREEN_CAST_CURSOR_MODE_HIDDEN = 0,
META_SCREEN_CAST_CURSOR_MODE_EMBEDDED = 1,
META_SCREEN_CAST_CURSOR_MODE_METADATA = 2,
} MetaScreenCastCursorMode;
#define META_TYPE_SCREEN_CAST (meta_screen_cast_get_type ())
G_DECLARE_FINAL_TYPE (MetaScreenCast, meta_screen_cast,
META, SCREEN_CAST,
@@ -35,6 +43,9 @@ G_DECLARE_FINAL_TYPE (MetaScreenCast, meta_screen_cast,
GDBusConnection * meta_screen_cast_get_connection (MetaScreenCast *screen_cast);
MetaScreenCast * meta_screen_cast_new (MetaDbusSessionWatcher *session_watcher);
MetaBackend * meta_screen_cast_get_backend (MetaScreenCast *screen_cast);
MetaScreenCast * meta_screen_cast_new (MetaBackend *backend,
MetaDbusSessionWatcher *session_watcher);
#endif /* META_SCREEN_CAST_H */

View File

@@ -31,9 +31,7 @@ typedef enum _MetaExperimentalFeature
{
META_EXPERIMENTAL_FEATURE_NONE = 0,
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER = (1 << 0),
META_EXPERIMENTAL_FEATURE_SCREEN_CAST = (1 << 1),
META_EXPERIMENTAL_FEATURE_REMOTE_DESKTOP = (1 << 2),
META_EXPERIMENTAL_FEATURE_KMS_MODIFIERS = (1 << 3),
META_EXPERIMENTAL_FEATURE_KMS_MODIFIERS = (1 << 1),
} MetaExperimentalFeature;
#define META_TYPE_SETTINGS (meta_settings_get_type ())

View File

@@ -263,10 +263,6 @@ experimental_features_handler (GVariant *features_variant,
/* So far no experimental features defined. */
if (g_str_equal (feature, "scale-monitor-framebuffer"))
features |= META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER;
else if (g_str_equal (feature, "screen-cast"))
features |= META_EXPERIMENTAL_FEATURE_SCREEN_CAST;
else if (g_str_equal (feature, "remote-desktop"))
features |= META_EXPERIMENTAL_FEATURE_REMOTE_DESKTOP;
else if (g_str_equal (feature, "kms-modifiers"))
features |= META_EXPERIMENTAL_FEATURE_KMS_MODIFIERS;
else

View File

@@ -30,7 +30,17 @@
#include "backends/meta-backend-private.h"
#include "clutter/clutter-mutter.h"
struct _MetaOverlay {
enum
{
ACTORS_PAINTED,
N_SIGNALS
};
static guint signals[N_SIGNALS];
struct _MetaOverlay
{
gboolean enabled;
CoglPipeline *pipeline;
@@ -140,6 +150,8 @@ meta_stage_paint (ClutterActor *actor)
CLUTTER_ACTOR_CLASS (meta_stage_parent_class)->paint (actor);
g_signal_emit (stage, signals[ACTORS_PAINTED], 0);
for (l = priv->overlays; l; l = l->next)
meta_overlay_paint (l->data);
}
@@ -179,6 +191,13 @@ meta_stage_class_init (MetaStageClass *klass)
stage_class->activate = meta_stage_activate;
stage_class->deactivate = meta_stage_deactivate;
signals[ACTORS_PAINTED] = g_signal_new ("actors-painted",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
}
static void

View File

@@ -645,11 +645,20 @@ void meta_backend_native_resume (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
MetaCursorRenderer *cursor_renderer;
MetaCursorRendererNative *cursor_renderer_native;
MetaDisplay *display = meta_get_display ();
ClutterBackend *clutter_backend = clutter_get_default_backend ();
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
ClutterActor *stage;
MetaIdleMonitor *idle_monitor;
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_UNSTABLE_TEXTURES))
{
clutter_clear_glyph_cache ();
meta_screen_update_cursor (display->screen);
g_signal_emit_by_name (display, "gl-video-memory-purged");
}
meta_monitor_manager_kms_resume (monitor_manager_kms);
clutter_evdev_reclaim_devices ();
@@ -658,10 +667,6 @@ void meta_backend_native_resume (MetaBackendNative *native)
stage = meta_backend_get_stage (backend);
clutter_actor_queue_redraw (stage);
cursor_renderer = meta_backend_get_cursor_renderer (backend);
cursor_renderer_native = META_CURSOR_RENDERER_NATIVE (cursor_renderer);
meta_cursor_renderer_native_force_update (cursor_renderer_native);
idle_monitor = meta_backend_get_idle_monitor (backend, 0);
meta_idle_monitor_reset_idletime (idle_monitor);
}

View File

@@ -35,6 +35,7 @@
#include <meta/meta-backend.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-cursor-sprite-xcursor.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor.h"
#include "backends/meta-monitor-manager-private.h"
@@ -43,6 +44,11 @@
#include "core/boxes-private.h"
#include "meta/boxes.h"
#ifdef HAVE_WAYLAND
#include "wayland/meta-cursor-sprite-wayland.h"
#include "wayland/meta-wayland-buffer.h"
#endif
#ifndef DRM_CAP_CURSOR_WIDTH
#define DRM_CAP_CURSOR_WIDTH 0x8
#endif
@@ -113,6 +119,11 @@ static GQuark quark_cursor_renderer_native_gpu_data = 0;
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRendererNative, meta_cursor_renderer_native, META_TYPE_CURSOR_RENDERER);
static void
realize_cursor_sprite (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
GList *gpus);
static MetaCursorNativeGpuState *
get_cursor_gpu_state (MetaCursorNativePrivate *cursor_priv,
MetaGpuKms *gpu_kms);
@@ -152,7 +163,8 @@ static void
meta_cursor_renderer_native_finalize (GObject *object)
{
MetaCursorRendererNative *renderer = META_CURSOR_RENDERER_NATIVE (object);
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (renderer);
if (priv->animation_timeout_id)
g_source_remove (priv->animation_timeout_id);
@@ -203,7 +215,8 @@ set_crtc_cursor (MetaCursorRendererNative *native,
MetaCrtc *crtc,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
MetaGpuKms *gpu_kms;
int kms_fd;
@@ -291,6 +304,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
data->in_cursor_renderer_native;
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
MetaCrtc *crtc;
MetaMonitorTransform transform;
ClutterRect scaled_crtc_rect;
float scale;
@@ -330,6 +344,8 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
},
};
crtc = meta_output_get_assigned_crtc (monitor_crtc_mode->output);
if (priv->has_hw_cursor &&
clutter_rect_intersection (&scaled_crtc_rect,
&data->in_local_cursor_rect,
@@ -340,7 +356,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
float crtc_cursor_x, crtc_cursor_y;
set_crtc_cursor (data->in_cursor_renderer_native,
monitor_crtc_mode->output->crtc,
crtc,
data->in_cursor_sprite);
gpu_kms = META_GPU_KMS (meta_monitor_get_gpu (monitor));
@@ -350,7 +366,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
crtc_cursor_y = (data->in_local_cursor_rect.origin.y -
scaled_crtc_rect.origin.y) * scale;
drmModeMoveCursor (kms_fd,
monitor_crtc_mode->output->crtc->crtc_id,
crtc->crtc_id,
roundf (crtc_cursor_x),
roundf (crtc_cursor_y));
@@ -358,8 +374,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor,
}
else
{
set_crtc_cursor (data->in_cursor_renderer_native,
monitor_crtc_mode->output->crtc, NULL);
set_crtc_cursor (data->in_cursor_renderer_native, crtc, NULL);
}
return TRUE;
@@ -369,7 +384,8 @@ static void
update_hw_cursor (MetaCursorRendererNative *native,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (native);
MetaMonitorManager *monitor_manager = priv->monitor_manager;
GList *logical_monitors;
@@ -562,18 +578,19 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer,
static gboolean
should_have_hw_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
MetaCursorSprite *cursor_sprite,
GList *gpus)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
GList *gpus;
GList *l;
CoglTexture *texture;
if (!cursor_sprite)
return FALSE;
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
if (meta_cursor_renderer_is_hw_cursors_inhibited (renderer,
cursor_sprite))
return FALSE;
for (l = gpus; l; l = l->next)
{
MetaGpuKms *gpu_kms = l->data;
@@ -607,7 +624,8 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
static gboolean
meta_cursor_renderer_native_update_animation (MetaCursorRendererNative *native)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (native);
MetaCursorSprite *cursor_sprite = meta_cursor_renderer_get_cursor (renderer);
@@ -619,10 +637,11 @@ meta_cursor_renderer_native_update_animation (MetaCursorRendererNative *native)
}
static void
meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native,
MetaCursorSprite *cursor_sprite)
maybe_schedule_cursor_sprite_animation_frame (MetaCursorRendererNative *native,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
gboolean cursor_change;
guint delay;
@@ -654,21 +673,78 @@ meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native,
}
}
static GList *
calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
MetaMonitorManager *monitor_manager = priv->monitor_manager;
GList *gpus = NULL;
GList *logical_monitors;
GList *l;
ClutterRect cursor_rect;
cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
logical_monitors =
meta_monitor_manager_get_logical_monitors (monitor_manager);
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
MetaRectangle logical_monitor_layout;
ClutterRect logical_monitor_rect;
GList *monitors, *l_mon;
logical_monitor_layout =
meta_logical_monitor_get_layout (logical_monitor);
logical_monitor_rect =
meta_rectangle_to_clutter_rect (&logical_monitor_layout);
if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect,
NULL))
continue;
monitors = meta_logical_monitor_get_monitors (logical_monitor);
for (l_mon = monitors; l_mon; l_mon = l_mon->next)
{
MetaMonitor *monitor = l_mon->data;
MetaGpu *gpu;
gpu = meta_monitor_get_gpu (monitor);
if (!g_list_find (gpus, gpu))
gpus = g_list_prepend (gpus, gpu);
}
}
return gpus;
}
static gboolean
meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
g_autoptr (GList) gpus = NULL;
if (cursor_sprite)
meta_cursor_sprite_realize_texture (cursor_sprite);
{
meta_cursor_sprite_realize_texture (cursor_sprite);
gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite);
realize_cursor_sprite (renderer, cursor_sprite, gpus);
}
meta_cursor_renderer_native_trigger_frame (native, cursor_sprite);
maybe_schedule_cursor_sprite_animation_frame (native, cursor_sprite);
priv->has_hw_cursor = should_have_hw_cursor (renderer, cursor_sprite);
priv->has_hw_cursor = should_have_hw_cursor (renderer, cursor_sprite, gpus);
update_hw_cursor (native, cursor_sprite);
return priv->has_hw_cursor;
return (priv->has_hw_cursor ||
!cursor_sprite ||
!meta_cursor_sprite_get_cogl_texture (cursor_sprite));
}
static void
@@ -704,6 +780,24 @@ ensure_cursor_gpu_state (MetaCursorNativePrivate *cursor_priv,
return cursor_gpu_state;
}
static void
on_cursor_sprite_texture_changed (MetaCursorSprite *cursor_sprite)
{
MetaCursorNativePrivate *cursor_priv = get_cursor_priv (cursor_sprite);
GHashTableIter iter;
MetaCursorNativeGpuState *cursor_gpu_state;
g_hash_table_iter_init (&iter, cursor_priv->gpu_states);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cursor_gpu_state))
{
guint pending_bo;
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
(GDestroyNotify) gbm_bo_destroy);
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
}
}
static void
cursor_priv_free (MetaCursorNativePrivate *cursor_priv)
{
@@ -736,6 +830,9 @@ ensure_cursor_priv (MetaCursorSprite *cursor_sprite)
cursor_priv,
(GDestroyNotify) cursor_priv_free);
g_signal_connect (cursor_sprite, "texture-changed",
G_CALLBACK (on_cursor_sprite_texture_changed), NULL);
return cursor_priv;
}
@@ -803,57 +900,71 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
}
}
static void
invalidate_pending_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
MetaGpuKms *gpu_kms)
static gboolean
is_cursor_hw_state_valid (MetaCursorSprite *cursor_sprite,
MetaGpuKms *gpu_kms)
{
MetaCursorNativePrivate *cursor_priv;
MetaCursorNativeGpuState *cursor_gpu_state;
guint pending_bo;
cursor_priv = get_cursor_priv (cursor_sprite);
if (!cursor_priv)
return;
return FALSE;
cursor_gpu_state = get_cursor_gpu_state (cursor_priv, gpu_kms);
if (!cursor_gpu_state)
return;
return FALSE;
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
(GDestroyNotify) gbm_bo_destroy);
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
switch (cursor_gpu_state->pending_bo_state)
{
case META_CURSOR_GBM_BO_STATE_SET:
case META_CURSOR_GBM_BO_STATE_NONE:
return TRUE;
case META_CURSOR_GBM_BO_STATE_INVALIDATED:
return FALSE;
}
g_assert_not_reached ();
}
#ifdef HAVE_WAYLAND
static void
meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
MetaGpuKms *gpu_kms,
MetaCursorSprite *cursor_sprite,
struct wl_resource *buffer)
realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
MetaGpuKms *gpu_kms,
MetaCursorSpriteWayland *sprite_wayland)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_wayland);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
uint32_t gbm_format;
uint64_t cursor_width, cursor_height;
CoglTexture *texture;
uint width, height;
MetaWaylandBuffer *buffer;
struct wl_resource *buffer_resource;
struct wl_shm_buffer *shm_buffer;
cursor_renderer_gpu_data =
meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
if (!cursor_renderer_gpu_data || cursor_renderer_gpu_data->hw_cursor_broken)
return;
/* Destroy any previous pending cursor buffer; we'll always either fail (which
* should unset, or succeed, which will set new buffer.
*/
invalidate_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms);
if (is_cursor_hw_state_valid (cursor_sprite, gpu_kms))
return;
texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
width = cogl_texture_get_width (texture);
height = cogl_texture_get_height (texture);
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (buffer);
buffer = meta_cursor_sprite_wayland_get_buffer (sprite_wayland);
if (!buffer)
return;
buffer_resource = meta_wayland_buffer_get_resource (buffer);
if (!buffer_resource)
return;
shm_buffer = wl_shm_buffer_get (buffer_resource);
if (shm_buffer)
{
int rowstride = wl_shm_buffer_get_stride (shm_buffer);
@@ -927,47 +1038,27 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (MetaCursorRen
set_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms, bo);
}
}
static void
meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
struct wl_resource *buffer)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
GList *gpus;
GList *l;
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
for (l = gpus; l; l = l->next)
{
MetaGpuKms *gpu_kms = l->data;
meta_cursor_renderer_native_realize_cursor_from_wl_buffer_for_gpu (
renderer,
gpu_kms,
cursor_sprite,
buffer);
}
}
#endif
static void
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
MetaGpuKms *gpu_kms,
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image)
realize_cursor_sprite_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
MetaGpuKms *gpu_kms,
MetaCursorSpriteXcursor *sprite_xcursor)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
XcursorImage *xc_image;
cursor_renderer_gpu_data =
meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
if (!cursor_renderer_gpu_data || cursor_renderer_gpu_data->hw_cursor_broken)
return;
invalidate_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms);
if (is_cursor_hw_state_valid (cursor_sprite, gpu_kms))
return;
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
load_cursor_sprite_gbm_buffer_for_gpu (native,
gpu_kms,
@@ -980,26 +1071,45 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRende
}
static void
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
XcursorImage *xc_image)
realize_cursor_sprite_for_gpu (MetaCursorRenderer *renderer,
MetaGpuKms *gpu_kms,
MetaCursorSprite *cursor_sprite)
{
#ifdef HAVE_WAYLAND
if (META_IS_CURSOR_SPRITE_WAYLAND (cursor_sprite))
{
MetaCursorSpriteWayland *sprite_wayland =
META_CURSOR_SPRITE_WAYLAND (cursor_sprite);
realize_cursor_sprite_from_wl_buffer_for_gpu (renderer,
gpu_kms,
sprite_wayland);
}
else
#endif
if (META_IS_CURSOR_SPRITE_XCURSOR (cursor_sprite))
{
MetaCursorSpriteXcursor *sprite_xcursor =
META_CURSOR_SPRITE_XCURSOR (cursor_sprite);
realize_cursor_sprite_from_xcursor_for_gpu (renderer,
gpu_kms,
sprite_xcursor);
}
}
static void
realize_cursor_sprite (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite,
GList *gpus)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
GList *gpus;
GList *l;
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
for (l = gpus; l; l = l->next)
{
MetaGpuKms *gpu_kms = l->data;
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (
renderer,
gpu_kms,
cursor_sprite,
xc_image);
realize_cursor_sprite_for_gpu (renderer, gpu_kms, cursor_sprite);
}
}
@@ -1011,12 +1121,6 @@ meta_cursor_renderer_native_class_init (MetaCursorRendererNativeClass *klass)
object_class->finalize = meta_cursor_renderer_native_finalize;
renderer_class->update_cursor = meta_cursor_renderer_native_update_cursor;
#ifdef HAVE_WAYLAND
renderer_class->realize_cursor_from_wl_buffer =
meta_cursor_renderer_native_realize_cursor_from_wl_buffer;
#endif
renderer_class->realize_cursor_from_xcursor =
meta_cursor_renderer_native_realize_cursor_from_xcursor;
quark_cursor_sprite = g_quark_from_static_string ("-meta-cursor-native");
quark_cursor_renderer_native_gpu_data =
@@ -1031,14 +1135,13 @@ force_update_hw_cursor (MetaCursorRendererNative *native)
meta_cursor_renderer_native_get_instance_private (native);
priv->hw_state_invalidated = TRUE;
update_hw_cursor (native, meta_cursor_renderer_get_cursor (renderer));
meta_cursor_renderer_force_update (renderer);
}
static void
on_monitors_changed (MetaMonitorManager *monitors,
MetaCursorRendererNative *native)
{
/* Our tracking is all messed up, so force an update. */
force_update_hw_cursor (native);
}
@@ -1110,9 +1213,3 @@ static void
meta_cursor_renderer_native_init (MetaCursorRendererNative *native)
{
}
void
meta_cursor_renderer_native_force_update (MetaCursorRendererNative *native)
{
force_update_hw_cursor (native);
}

View File

@@ -32,8 +32,6 @@ G_DECLARE_FINAL_TYPE (MetaCursorRendererNative, meta_cursor_renderer_native,
META, CURSOR_RENDERER_NATIVE,
MetaCursorRenderer)
void meta_cursor_renderer_native_force_update (MetaCursorRendererNative *renderer);
MetaCursorRendererNative * meta_cursor_renderer_native_new (MetaBackend *backend);
#endif /* META_CURSOR_RENDERER_NATIVE_H */

View File

@@ -47,6 +47,12 @@ typedef struct _MetaKmsSource
MetaGpuKms *gpu_kms;
} MetaKmsSource;
typedef struct _MetaGpuKmsFlipClosureContainer
{
GClosure *flip_closure;
MetaGpuKms *gpu_kms;
} MetaGpuKmsFlipClosureContainer;
struct _MetaGpuKms
{
MetaGpu parent;
@@ -62,6 +68,8 @@ struct _MetaGpuKms
int max_buffer_height;
gboolean page_flips_not_supported;
gboolean resources_init_failed_before;
};
G_DEFINE_QUARK (MetaGpuKmsError, meta_gpu_kms_error)
@@ -105,8 +113,10 @@ get_crtc_drm_connectors (MetaGpu *gpu,
for (l = meta_gpu_get_outputs (gpu); l; l = l->next)
{
MetaOutput *output = l->data;
MetaCrtc *assigned_crtc;
if (output->crtc == crtc)
assigned_crtc = meta_output_get_assigned_crtc (output);
if (assigned_crtc == crtc)
g_array_append_val (connectors_array, output->winsys_id);
}
@@ -141,7 +151,10 @@ meta_gpu_kms_apply_crtc_mode (MetaGpuKms *gpu_kms,
connectors, n_connectors,
mode) != 0)
{
g_warning ("Failed to set CRTC mode %s: %m", crtc->current_mode->name);
if (mode)
g_warning ("Failed to set CRTC mode %s: %m", crtc->current_mode->name);
else
g_warning ("Failed to disable CRTC");
g_free (connectors);
return FALSE;
}
@@ -186,8 +199,10 @@ meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
for (l = meta_gpu_get_outputs (gpu); l; l = l->next)
{
MetaOutput *output = l->data;
MetaCrtc *assigned_crtc;
if (output->crtc == crtc)
assigned_crtc = meta_output_get_assigned_crtc (output);
if (assigned_crtc == crtc)
{
connected_crtc_found = TRUE;
break;
@@ -200,11 +215,26 @@ meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
return TRUE;
}
typedef struct _GpuClosureContainer
MetaGpuKmsFlipClosureContainer *
meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
GClosure *flip_closure)
{
GClosure *flip_closure;
MetaGpuKms *gpu_kms;
} GpuClosureContainer;
MetaGpuKmsFlipClosureContainer *closure_container;
closure_container = g_new0 (MetaGpuKmsFlipClosureContainer, 1);
*closure_container = (MetaGpuKmsFlipClosureContainer) {
.flip_closure = flip_closure,
.gpu_kms = gpu_kms
};
return closure_container;
}
void
meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container)
{
g_free (closure_container);
}
gboolean
meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
@@ -230,14 +260,11 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
if (!gpu_kms->page_flips_not_supported)
{
GpuClosureContainer *closure_container;
MetaGpuKmsFlipClosureContainer *closure_container;
int kms_fd = meta_gpu_kms_get_fd (gpu_kms);
closure_container = g_new0 (GpuClosureContainer, 1);
*closure_container = (GpuClosureContainer) {
.flip_closure = flip_closure,
.gpu_kms = gpu_kms
};
closure_container = meta_gpu_kms_wrap_flip_closure (gpu_kms,
flip_closure);
ret = drmModePageFlip (kms_fd,
crtc->crtc_id,
@@ -246,7 +273,7 @@ meta_gpu_kms_flip_crtc (MetaGpuKms *gpu_kms,
closure_container);
if (ret != 0 && ret != -EACCES)
{
g_free (closure_container);
meta_gpu_kms_flip_closure_container_free (closure_container);
g_warning ("Failed to flip: %s", strerror (-ret));
gpu_kms->page_flips_not_supported = TRUE;
}
@@ -277,12 +304,12 @@ page_flip_handler (int fd,
unsigned int usec,
void *user_data)
{
GpuClosureContainer *closure_container = user_data;
MetaGpuKmsFlipClosureContainer *closure_container = user_data;
GClosure *flip_closure = closure_container->flip_closure;
MetaGpuKms *gpu_kms = closure_container->gpu_kms;
invoke_flip_closure (flip_closure, gpu_kms);
g_free (closure_container);
meta_gpu_kms_flip_closure_container_free (closure_container);
}
gboolean
@@ -702,20 +729,34 @@ init_outputs (MetaGpuKms *gpu_kms,
setup_output_clones (gpu);
}
static void
meta_kms_resources_init (MetaKmsResources *resources,
int fd)
static gboolean
meta_kms_resources_init (MetaKmsResources *resources,
int fd,
GError **error)
{
drmModeRes *drm_resources;
unsigned int i;
drm_resources = drmModeGetResources (fd);
if (!drm_resources)
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"Calling drmModeGetResources() failed");
return FALSE;
}
resources->resources = drm_resources;
resources->n_encoders = (unsigned int) drm_resources->count_encoders;
resources->encoders = g_new (drmModeEncoder *, resources->n_encoders);
for (i = 0; i < resources->n_encoders; i++)
resources->encoders[i] = drmModeGetEncoder (fd, drm_resources->encoders[i]);
return TRUE;
}
static void
@@ -727,7 +768,7 @@ meta_kms_resources_release (MetaKmsResources *resources)
drmModeFreeEncoder (resources->encoders[i]);
g_free (resources->encoders);
drmModeFreeResources (resources->resources);
g_clear_pointer (&resources->resources, drmModeFreeResources);
}
static gboolean
@@ -738,8 +779,18 @@ meta_gpu_kms_read_current (MetaGpu *gpu,
MetaMonitorManager *monitor_manager =
meta_gpu_get_monitor_manager (gpu);
MetaKmsResources resources;
g_autoptr (GError) local_error = NULL;
meta_kms_resources_init (&resources, gpu_kms->fd);
if (!meta_kms_resources_init (&resources, gpu_kms->fd, &local_error))
{
if (!gpu_kms->resources_init_failed_before)
{
g_warning ("meta_kms_resources_init failed: %s, assuming we have no outputs",
local_error->message);
gpu_kms->resources_init_failed_before = TRUE;
}
return TRUE;
}
gpu_kms->max_buffer_width = resources.resources->max_width;
gpu_kms->max_buffer_height = resources.resources->max_height;
@@ -764,6 +815,12 @@ meta_gpu_kms_read_current (MetaGpu *gpu,
return TRUE;
}
gboolean
meta_gpu_kms_can_have_outputs (MetaGpuKms *gpu_kms)
{
return gpu_kms->n_connectors > 0;
}
MetaGpuKms *
meta_gpu_kms_new (MetaMonitorManagerKms *monitor_manager_kms,
const char *kms_file_path,
@@ -797,6 +854,13 @@ meta_gpu_kms_new (MetaMonitorManagerKms *monitor_manager_kms,
*/
drm_resources = drmModeGetResources (kms_fd);
if (!drm_resources)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No resources");
meta_launcher_close_restricted (launcher, kms_fd);
return NULL;
}
n_connectors = drm_resources->count_connectors;
drmModeFreeResources (drm_resources);
@@ -820,6 +884,8 @@ meta_gpu_kms_new (MetaMonitorManagerKms *monitor_manager_kms,
drmSetClientCap (gpu_kms->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
meta_gpu_kms_read_current (META_GPU (gpu_kms), NULL);
source = g_source_new (&kms_event_funcs, sizeof (MetaKmsSource));
kms_source = (MetaKmsSource *) source;
kms_source->fd_tag = g_source_add_unix_fd (source,

View File

@@ -40,6 +40,8 @@ GQuark meta_gpu_kms_error_quark (void);
#define META_TYPE_GPU_KMS (meta_gpu_kms_get_type ())
G_DECLARE_FINAL_TYPE (MetaGpuKms, meta_gpu_kms, META, GPU_KMS, MetaGpu)
typedef struct _MetaGpuKmsFlipClosureContainer MetaGpuKmsFlipClosureContainer;
typedef struct _MetaKmsResources
{
drmModeRes *resources;
@@ -59,6 +61,8 @@ gboolean meta_gpu_kms_apply_crtc_mode (MetaGpuKms *gpu_kms,
int y,
uint32_t fb_id);
gboolean meta_gpu_kms_can_have_outputs (MetaGpuKms *gpu_kms);
gboolean meta_gpu_kms_is_crtc_active (MetaGpuKms *gpu_kms,
MetaCrtc *crtc);
@@ -92,4 +96,9 @@ gboolean meta_drm_mode_equal (const drmModeModeInfo *one,
float meta_calculate_drm_mode_refresh_rate (const drmModeModeInfo *mode);
MetaGpuKmsFlipClosureContainer * meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu_kms,
GClosure *flip_closure);
void meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container);
#endif /* META_GPU_KMS_H */

View File

@@ -34,6 +34,7 @@
#include "meta-crtc-kms.h"
#include "meta-gpu-kms.h"
#include "meta-output-kms.h"
#include "wayland/meta-wayland-outputs.h"
#include <string.h>
#include <stdlib.h>
@@ -188,7 +189,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
MetaOutput *output = g_ptr_array_index (crtc_info->outputs, j);
output->is_dirty = TRUE;
output->crtc = crtc;
meta_output_assign_crtc (output, crtc);
}
}
@@ -249,7 +250,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
continue;
}
output->crtc = NULL;
meta_output_unassign_crtc (output);
output->is_primary = FALSE;
}
}
@@ -415,9 +416,15 @@ void
meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms)
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
ClutterBackend *clutter_backend = clutter_get_default_backend ();
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
handle_hotplug_event (manager);
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_UNSTABLE_TEXTURES))
meta_wayland_outputs_redraw (meta_wayland_compositor_get_default ());
}
static gboolean
@@ -642,10 +649,12 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
GError **error)
{
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (initable);
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
const char *subsystems[2] = { "drm", NULL };
GList *gpu_paths;
g_autofree char *primary_gpu_path = NULL;
GList *l;
gboolean can_have_outputs;
manager_kms->udev = g_udev_client_new (subsystems);
@@ -694,6 +703,24 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
}
g_list_free_full (gpu_paths, g_free);
can_have_outputs = FALSE;
for (l = meta_monitor_manager_get_gpus (manager); l; l = l->next)
{
MetaGpuKms *gpu_kms = l->data;
if (meta_gpu_kms_can_have_outputs (gpu_kms))
{
can_have_outputs = TRUE;
break;
}
}
if (!can_have_outputs)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No GPUs with outputs found");
return FALSE;
}
return TRUE;
}

View File

@@ -64,11 +64,13 @@ typedef struct _MetaOutputKms
void
meta_output_kms_set_underscan (MetaOutput *output)
{
if (!output->crtc)
MetaCrtc *crtc;
crtc = meta_output_get_assigned_crtc (output);
if (!crtc)
return;
meta_crtc_kms_set_underscan (output->crtc,
output->is_underscanning);
meta_crtc_kms_set_underscan (crtc, output->is_underscanning);
}
void
@@ -600,14 +602,14 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
if (crtc->crtc_id == output_kms->current_encoder->crtc_id)
{
output->crtc = crtc;
meta_output_assign_crtc (output, crtc);
break;
}
}
}
else
{
output->crtc = NULL;
meta_output_unassign_crtc (output);
}
if (old_output)

View File

@@ -96,8 +96,6 @@ typedef struct _MetaRendererNativeGpuData
#ifdef HAVE_EGL_DEVICE
struct {
EGLDeviceEXT device;
gboolean no_egl_output_drm_flip_event;
} egl;
#endif
@@ -993,14 +991,29 @@ meta_renderer_native_choose_egl_config (CoglDisplay *cogl_display,
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaBackend *backend = meta_get_backend ();
MetaEgl *egl = meta_backend_get_egl (backend);
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
EGLDisplay egl_display = cogl_renderer_egl->edpy;
return choose_egl_config_from_gbm_format (egl,
egl_display,
attributes,
GBM_FORMAT_XRGB8888,
out_config,
error);
switch (renderer_gpu_data->mode)
{
case META_RENDERER_NATIVE_MODE_GBM:
return choose_egl_config_from_gbm_format (egl,
egl_display,
attributes,
GBM_FORMAT_XRGB8888,
out_config,
error);
#ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
return meta_egl_choose_first_config (egl,
egl_display,
attributes,
out_config,
error);
#endif
}
return FALSE;
}
static gboolean
@@ -1271,18 +1284,20 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
MetaRendererNativeGpuData *renderer_gpu_data;
EGLDisplay *egl_display;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
MetaGpuKmsFlipClosureContainer *closure_container;
EGLAttrib *acquire_attribs;
GError *error = NULL;
renderer_gpu_data =
meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
onscreen_native->render_gpu);
if (renderer_gpu_data->egl.no_egl_output_drm_flip_event)
return FALSE;
closure_container =
meta_gpu_kms_wrap_flip_closure (onscreen_native->render_gpu, flip_closure);
acquire_attribs = (EGLAttrib[]) {
EGL_DRM_FLIP_EVENT_DATA_NV,
(EGLAttrib) flip_closure,
(EGLAttrib) closure_container,
EGL_NONE
};
@@ -1296,11 +1311,10 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
if (error->domain != META_EGL_ERROR ||
error->code != EGL_RESOURCE_BUSY_EXT)
{
g_warning ("Failed to flip EGL stream (%s), relying on clock from "
"now on", error->message);
renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE;
g_warning ("Failed to flip EGL stream: %s", error->message);
}
g_error_free (error);
meta_gpu_kms_flip_closure_container_free (closure_container);
return FALSE;
}
@@ -1601,12 +1615,29 @@ gbm_get_next_fb_id (MetaGpuKms *gpu_kms,
/* Now we need to set the CRTC to whatever is the front buffer */
next_bo = gbm_surface_lock_front_buffer (gbm_surface);
for (i = 0; i < gbm_bo_get_plane_count (next_bo); i++)
if (!next_bo)
{
strides[i] = gbm_bo_get_stride_for_plane (next_bo, i);
handles[i] = gbm_bo_get_handle_for_plane (next_bo, i).u32;
offsets[i] = gbm_bo_get_offset (next_bo, i);
modifiers[i] = gbm_bo_get_modifier (next_bo);
g_error ("Impossible to lock surface front buffer: %m");
return FALSE;
}
if (gbm_bo_get_handle_for_plane (next_bo, 0).s32 == -1)
{
/* Failed to fetch handle to plane, falling back to old method */
strides[0] = gbm_bo_get_stride (next_bo);
handles[0] = gbm_bo_get_handle (next_bo).u32;
offsets[0] = 0;
modifiers[0] = DRM_FORMAT_MOD_INVALID;
}
else
{
for (i = 0; i < gbm_bo_get_plane_count (next_bo); i++)
{
strides[i] = gbm_bo_get_stride_for_plane (next_bo, i);
handles[i] = gbm_bo_get_handle_for_plane (next_bo, i).u32;
offsets[i] = gbm_bo_get_offset (next_bo, i);
modifiers[i] = gbm_bo_get_modifier (next_bo);
}
}
kms_fd = meta_gpu_kms_get_fd (gpu_kms);
@@ -2083,6 +2114,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
EGLDisplay egl_display = renderer_gpu_data->egl_display;
MetaMonitor *monitor;
MetaOutput *output;
MetaCrtc *crtc;
EGLConfig egl_config;
EGLStreamKHR egl_stream;
EGLSurface egl_surface;
@@ -2090,7 +2122,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
EGLOutputLayerEXT output_layer;
EGLAttrib output_attribs[3];
EGLint stream_attribs[] = {
EGL_STREAM_FIFO_LENGTH_KHR, 1,
EGL_STREAM_FIFO_LENGTH_KHR, 0,
EGL_CONSUMER_AUTO_ACQUIRE_EXT, EGL_FALSE,
EGL_NONE
};
@@ -2106,6 +2138,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
monitor = meta_logical_monitor_get_monitors (logical_monitor)->data;
output = meta_monitor_get_main_output (monitor);
crtc = meta_output_get_assigned_crtc (output);
/*
* An "logical_monitor" may have multiple outputs/crtcs in case its tiled,
@@ -2113,7 +2146,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
* lets pass the first one.
*/
output_attribs[0] = EGL_DRM_CRTC_EXT;
output_attribs[1] = output->crtc->crtc_id;
output_attribs[1] = crtc->crtc_id;
output_attribs[2] = EGL_NONE;
if (!meta_egl_get_output_layers (egl, egl_display,
@@ -2711,9 +2744,12 @@ calculate_view_transform (MetaMonitorManager *monitor_manager,
{
MetaMonitor *main_monitor;
MetaOutput *main_output;
MetaCrtc *crtc;
MetaMonitorTransform crtc_transform;
main_monitor = meta_logical_monitor_get_monitors (logical_monitor)->data;
main_output = meta_monitor_get_main_output (main_monitor);
crtc = meta_output_get_assigned_crtc (main_output);
crtc_transform =
meta_monitor_logical_to_crtc_transform (main_monitor,
logical_monitor->transform);
@@ -2724,13 +2760,67 @@ calculate_view_transform (MetaMonitorManager *monitor_manager,
*/
if (meta_monitor_manager_is_transform_handled (monitor_manager,
main_output->crtc,
crtc,
crtc_transform))
return META_MONITOR_TRANSFORM_NORMAL;
else
return crtc_transform;
}
static CoglContext *
cogl_context_from_renderer_native (MetaRendererNative *renderer_native)
{
MetaMonitorManager *monitor_manager =
META_MONITOR_MANAGER (renderer_native->monitor_manager_kms);
MetaBackend *backend = meta_monitor_manager_get_backend (monitor_manager);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
return clutter_backend_get_cogl_context (clutter_backend);
}
static gboolean
should_force_shadow_fb (MetaRendererNative *renderer_native,
MetaGpuKms *primary_gpu)
{
CoglContext *cogl_context =
cogl_context_from_renderer_native (renderer_native);
CoglGpuInfo *info = &cogl_context->gpu;
int kms_fd;
uint64_t prefer_shadow = 0;
switch (info->architecture)
{
case COGL_GPU_INFO_ARCHITECTURE_UNKNOWN:
case COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE:
case COGL_GPU_INFO_ARCHITECTURE_SGX:
case COGL_GPU_INFO_ARCHITECTURE_MALI:
return FALSE;
case COGL_GPU_INFO_ARCHITECTURE_LLVMPIPE:
case COGL_GPU_INFO_ARCHITECTURE_SOFTPIPE:
case COGL_GPU_INFO_ARCHITECTURE_SWRAST:
break;
}
kms_fd = meta_gpu_kms_get_fd (primary_gpu);
if (drmGetCap (kms_fd, DRM_CAP_DUMB_PREFER_SHADOW, &prefer_shadow) == 0)
{
if (prefer_shadow)
{
static gboolean logged_once = FALSE;
if (!logged_once)
{
g_message ("Forcing shadow framebuffer");
logged_once = TRUE;
}
return TRUE;
}
}
return FALSE;
}
static MetaRendererView *
meta_renderer_native_create_view (MetaRenderer *renderer,
MetaLogicalMonitor *logical_monitor)
@@ -2740,10 +2830,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
renderer_native->monitor_manager_kms;
MetaMonitorManager *monitor_manager =
META_MONITOR_MANAGER (monitor_manager_kms);
MetaBackend *backend = meta_monitor_manager_get_backend (monitor_manager);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
cogl_context_from_renderer_native (renderer_native);
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
MetaGpuKms *primary_gpu;
CoglDisplayEGL *cogl_display_egl;
@@ -2778,7 +2866,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
if (!onscreen)
g_error ("Failed to allocate onscreen framebuffer: %s", error->message);
if (view_transform != META_MONITOR_TRANSFORM_NORMAL)
if (view_transform != META_MONITOR_TRANSFORM_NORMAL ||
should_force_shadow_fb (renderer_native, primary_gpu))
{
offscreen = meta_renderer_native_create_offscreen (renderer_native,
cogl_context,
@@ -2901,10 +2990,11 @@ meta_renderer_native_set_property (GObject *object,
}
static gboolean
create_secondary_egl_config (MetaEgl *egl,
EGLDisplay egl_display,
EGLConfig *egl_config,
GError **error)
create_secondary_egl_config (MetaEgl *egl,
MetaRendererNativeMode mode,
EGLDisplay egl_display,
EGLConfig *egl_config,
GError **error)
{
EGLint attributes[] = {
EGL_RED_SIZE, 1,
@@ -2917,12 +3007,26 @@ create_secondary_egl_config (MetaEgl *egl,
EGL_NONE
};
return choose_egl_config_from_gbm_format (egl,
egl_display,
attributes,
GBM_FORMAT_XRGB8888,
egl_config,
error);
switch (mode)
{
case META_RENDERER_NATIVE_MODE_GBM:
return choose_egl_config_from_gbm_format (egl,
egl_display,
attributes,
GBM_FORMAT_XRGB8888,
egl_config,
error);
#ifdef HAVE_EGL_DEVICE
case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
return meta_egl_choose_first_config (egl,
egl_display,
attributes,
egl_config,
error);
#endif
}
return FALSE;
}
static EGLContext
@@ -2966,7 +3070,8 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
EGLContext egl_context;
char **missing_gl_extensions;
if (!create_secondary_egl_config (egl,egl_display, &egl_config, error))
if (!create_secondary_egl_config (egl, renderer_gpu_data->mode, egl_display,
&egl_config, error))
return FALSE;
egl_context = create_secondary_egl_context (egl, egl_display, egl_config, error);

View File

@@ -30,6 +30,7 @@
#include "meta-backend-x11.h"
#include "meta-stage-private.h"
#include "backends/meta-cursor-sprite-xcursor.h"
struct _MetaCursorRendererX11Private
{
@@ -59,13 +60,18 @@ meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer,
gboolean has_server_cursor = FALSE;
if (cursor_sprite)
if (cursor_sprite && META_IS_CURSOR_SPRITE_XCURSOR (cursor_sprite))
{
MetaCursor cursor = meta_cursor_sprite_get_meta_cursor (cursor_sprite);
MetaCursorSpriteXcursor *sprite_xcursor =
META_CURSOR_SPRITE_XCURSOR (cursor_sprite);
MetaCursor cursor;
cursor = meta_cursor_sprite_xcursor_get_cursor (sprite_xcursor);
if (cursor != META_CURSOR_NONE)
{
Cursor xcursor = meta_cursor_create_x_cursor (xdisplay, cursor);
Cursor xcursor;
xcursor = meta_create_x_cursor (xdisplay, cursor);
XDefineCursor (xdisplay, xwindow, xcursor);
XFlush (xdisplay);
XFreeCursor (xdisplay, xcursor);

View File

@@ -225,8 +225,10 @@ is_crtc_assignment_changed (MetaCrtc *crtc,
for (j = 0; j < crtc_info->outputs->len; j++)
{
MetaOutput *output = ((MetaOutput**) crtc_info->outputs->pdata)[j];
MetaCrtc *assigned_crtc;
if (output->crtc != crtc)
assigned_crtc = meta_output_get_assigned_crtc (output);
if (assigned_crtc != crtc)
return TRUE;
}
@@ -243,6 +245,7 @@ is_output_assignment_changed (MetaOutput *output,
MetaOutputInfo **output_infos,
unsigned int n_output_infos)
{
MetaCrtc *assigned_crtc;
gboolean output_is_found = FALSE;
unsigned int i;
@@ -265,8 +268,10 @@ is_output_assignment_changed (MetaOutput *output,
output_is_found = TRUE;
}
assigned_crtc = meta_output_get_assigned_crtc (output);
if (!output_is_found)
return output->crtc != NULL;
return assigned_crtc != NULL;
for (i = 0; i < n_crtc_infos; i++)
{
@@ -279,7 +284,7 @@ is_output_assignment_changed (MetaOutput *output,
((MetaOutput**) crtc_info->outputs->pdata)[j];
if (crtc_info_output == output &&
crtc_info->crtc == output->crtc)
crtc_info->crtc == assigned_crtc)
return FALSE;
}
}
@@ -455,7 +460,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
output = ((MetaOutput**)crtc_info->outputs->pdata)[j];
output->is_dirty = TRUE;
output->crtc = crtc;
meta_output_assign_crtc (output, crtc);
output_ids[j] = output->winsys_id;
}
@@ -521,7 +526,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
continue;
}
output->crtc = NULL;
meta_output_unassign_crtc (output);
output->is_primary = FALSE;
}

View File

@@ -97,10 +97,13 @@ output_set_underscanning_xrandr (MetaOutput *output,
* make the border configurable. */
if (underscanning)
{
MetaCrtc *crtc;
uint32_t border_value;
crtc = meta_output_get_assigned_crtc (output);
prop = XInternAtom (xdisplay, "underscan hborder", False);
border_value = output->crtc->current_mode->width * 0.05;
border_value = crtc->current_mode->width * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
(XID) output->winsys_id,
@@ -109,7 +112,7 @@ output_set_underscanning_xrandr (MetaOutput *output,
1, &border_value);
prop = XInternAtom (xdisplay, "underscan vborder", False);
border_value = output->crtc->current_mode->height * 0.05;
border_value = crtc->current_mode->height * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
(XID) output->winsys_id,
@@ -737,14 +740,14 @@ output_get_crtcs (MetaOutput *output,
}
output->n_possible_crtcs = n_actual_crtcs;
output->crtc = NULL;
meta_output_unassign_crtc (output);
for (l = meta_gpu_get_crtcs (gpu); l; l = l->next)
{
MetaCrtc *crtc = l->data;
if ((XID) crtc->crtc_id == xrandr_output->crtc)
{
output->crtc = crtc;
meta_output_assign_crtc (output, crtc);
break;
}
}

View File

@@ -113,7 +113,7 @@ draw_crtc (MetaMonitor *monitor,
CoglTexture *texture = data->texture;
MetaLogicalMonitor *logical_monitor = data->logical_monitor;
MetaOutput *output = monitor_crtc_mode->output;
MetaCrtc *crtc = output->crtc;
MetaCrtc *crtc;
MetaRendererView *renderer_view = META_RENDERER_VIEW (data->view);
MetaMonitorTransform view_transform;
MetaMonitorTransform layout_transform = META_MONITOR_TRANSFORM_NORMAL;
@@ -129,6 +129,8 @@ draw_crtc (MetaMonitor *monitor,
texture_width = cogl_texture_get_width (texture);
texture_height = cogl_texture_get_height (texture);
crtc = meta_output_get_assigned_crtc (output);
clutter_stage_view_get_layout (data->view, &view_layout);
sample_x = crtc->rect.x - view_layout.x;
sample_y = crtc->rect.y - view_layout.y;

View File

@@ -26,6 +26,8 @@
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
#include <X11/Xcursor/Xcursor.h>
#include "backends/x11/meta-backend-x11.h"
struct _MetaCursorRendererX11Nested

View File

@@ -50,20 +50,22 @@ calculate_view_transform (MetaMonitorManager *monitor_manager,
{
MetaMonitor *main_monitor;
MetaOutput *main_output;
MetaCrtc *crtc;
MetaMonitorTransform crtc_transform;
main_monitor = meta_logical_monitor_get_monitors (logical_monitor)->data;
main_output = meta_monitor_get_main_output (main_monitor);
crtc = meta_output_get_assigned_crtc (main_output);
crtc_transform =
meta_monitor_logical_to_crtc_transform (main_monitor,
logical_monitor->transform);
/*
* Pick any monitor and output and check; all CRTCs of a logical monitor will
* always have the same transform assigned to them.
*/
if (meta_monitor_manager_is_transform_handled (monitor_manager,
main_output->crtc,
crtc,
crtc_transform))
return META_MONITOR_TRANSFORM_NORMAL;
else

View File

@@ -143,7 +143,8 @@ meta_actor_is_untransformed (ClutterActor *actor,
* transform.
*/
gboolean
meta_actor_painting_untransformed (int paint_width,
meta_actor_painting_untransformed (CoglFramebuffer *fb,
int paint_width,
int paint_height,
int *x_origin,
int *y_origin)
@@ -153,8 +154,8 @@ meta_actor_painting_untransformed (int paint_width,
float viewport[4];
int i;
cogl_get_modelview_matrix (&modelview);
cogl_get_projection_matrix (&projection);
cogl_framebuffer_get_modelview_matrix (fb, &modelview);
cogl_framebuffer_get_projection_matrix (fb, &projection);
cogl_matrix_multiply (&modelview_projection,
&projection,
@@ -173,7 +174,7 @@ meta_actor_painting_untransformed (int paint_width,
vertices[3].y = paint_height;
vertices[3].z = 0;
cogl_get_viewport (viewport);
cogl_framebuffer_get_viewport4fv (fb, viewport);
for (i = 0; i < 4; i++)
{

View File

@@ -31,9 +31,10 @@ gboolean meta_actor_is_untransformed (ClutterActor *actor,
int *x_origin,
int *y_origin);
gboolean meta_actor_painting_untransformed (int paint_width,
int paint_height,
int *x_origin,
int *y_origin);
gboolean meta_actor_painting_untransformed (CoglFramebuffer *fb,
int paint_width,
int paint_height,
int *x_origin,
int *y_origin);
#endif /* __META_CLUTTER_UTILS_H__ */

View File

@@ -325,6 +325,7 @@ setup_pipeline (MetaBackgroundActor *self,
PipelineFlags pipeline_flags = 0;
guint8 opacity;
float color_component;
CoglFramebuffer *fb;
CoglPipelineFilter filter;
opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self));
@@ -417,8 +418,12 @@ setup_pipeline (MetaBackgroundActor *self,
color_component,
opacity / 255.);
fb = cogl_get_draw_framebuffer ();
if (!priv->force_bilinear &&
meta_actor_painting_untransformed (actor_pixel_rect->width, actor_pixel_rect->height, NULL, NULL))
meta_actor_painting_untransformed (fb,
actor_pixel_rect->width,
actor_pixel_rect->height,
NULL, NULL))
filter = COGL_PIPELINE_FILTER_NEAREST;
else
filter = COGL_PIPELINE_FILTER_LINEAR;

View File

@@ -279,6 +279,34 @@ meta_background_image_cache_purge (MetaBackgroundImageCache *cache,
image->in_cache = FALSE;
}
/**
* meta_background_image_cache_unload_all:
* @cache: a #MetaBackgroundImageCache
*
* Remove all entries from the cache and unloads them; this would be used
* if textures in video memory have been invalidated.
*/
void
meta_background_image_cache_unload_all (MetaBackgroundImageCache *cache)
{
GHashTableIter iter;
gpointer key, value;
g_return_if_fail (META_IS_BACKGROUND_IMAGE_CACHE (cache));
g_hash_table_iter_init (&iter, cache->images);
while (g_hash_table_iter_next (&iter, &key, &value))
{
MetaBackgroundImage *image = value;
g_clear_pointer (&image->texture, cogl_object_unref);
image->in_cache = FALSE;
image->loaded = FALSE;
}
g_hash_table_remove_all (cache->images);
}
G_DEFINE_TYPE (MetaBackgroundImage, meta_background_image, G_TYPE_OBJECT);
static void

View File

@@ -317,6 +317,20 @@ meta_background_finalize (GObject *object)
G_OBJECT_CLASS (meta_background_parent_class)->finalize (object);
}
static void
free_textures (MetaBackground *self)
{
MetaBackgroundPrivate *priv = self->priv;
free_color_texture (self);
free_wallpaper_texture (self);
set_file (self, &priv->file1, &priv->background_image1, NULL);
set_file (self, &priv->file2, &priv->background_image2, NULL);
mark_changed (self);
}
static void
meta_background_constructed (GObject *object)
{
@@ -326,7 +340,7 @@ meta_background_constructed (GObject *object)
G_OBJECT_CLASS (meta_background_parent_class)->constructed (object);
g_signal_connect_object (meta_screen_get_display (priv->screen), "gl-video-memory-purged",
G_CALLBACK (mark_changed), object, G_CONNECT_SWAPPED);
G_CALLBACK (free_textures), object, G_CONNECT_SWAPPED);
}
static void
@@ -960,8 +974,11 @@ meta_background_set_blend (MetaBackground *self,
void
meta_background_refresh_all (void)
{
MetaBackgroundImageCache *cache = meta_background_image_cache_get_default ();
GSList *l;
meta_background_image_cache_unload_all (cache);
for (l = all_backgrounds; l; l = l->next)
mark_changed (l->data);
}

View File

@@ -29,14 +29,17 @@
#include <meta/meta-shaped-texture.h>
#include "meta-shaped-texture-private.h"
#include "meta-texture-rectangle.h"
#include <cogl/cogl.h>
#include <gdk/gdk.h> /* for gdk_rectangle_intersect() */
#include "clutter-utils.h"
#include "meta-texture-tower.h"
#include "core/boxes-private.h"
#include "meta-cullable.h"
#include <meta/meta-backend.h>
static void meta_shaped_texture_dispose (GObject *object);
@@ -54,8 +57,12 @@ static void meta_shaped_texture_get_preferred_height (ClutterActor *self,
static gboolean meta_shaped_texture_get_paint_volume (ClutterActor *self, ClutterPaintVolume *volume);
static void disable_backing_store (MetaShapedTexture *stex);
static void cullable_iface_init (MetaCullableInterface *iface);
static gboolean meta_debug_show_backing_store = FALSE;
G_DEFINE_TYPE_WITH_CODE (MetaShapedTexture, meta_shaped_texture, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
@@ -71,6 +78,14 @@ enum {
static guint signals[LAST_SIGNAL];
typedef struct
{
CoglTexture *texture;
CoglTexture *mask_texture;
cairo_surface_t *mask_surface;
cairo_region_t *region;
} MetaTextureBackingStore;
struct _MetaShapedTexturePrivate
{
MetaTextureTower *paint_tower;
@@ -92,6 +107,16 @@ struct _MetaShapedTexturePrivate
cairo_region_t *clip_region;
cairo_region_t *unobscured_region;
/* textures get corrupted on suspend, so save them */
cairo_surface_t *saved_base_surface;
cairo_surface_t *saved_mask_surface;
/* We can't just restore external textures, so we need to track
* which parts of the external texture are freshly drawn from
* the client after corruption, and fill in the rest from our
* saved snapshot */
MetaTextureBackingStore *backing_store;
guint tex_width, tex_height;
guint fallback_width, fallback_height;
@@ -119,12 +144,19 @@ meta_shaped_texture_class_init (MetaShapedTextureClass *klass)
G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (MetaShapedTexturePrivate));
if (g_getenv ("MUTTER_DEBUG_BACKING_STORE"))
meta_debug_show_backing_store = TRUE;
}
static void
meta_shaped_texture_init (MetaShapedTexture *self)
{
MetaShapedTexturePrivate *priv;
MetaBackend *backend = meta_get_backend ();
ClutterBackend *clutter_backend = clutter_get_default_backend ();
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
priv = self->priv = META_SHAPED_TEXTURE_GET_PRIVATE (self);
@@ -134,6 +166,12 @@ meta_shaped_texture_init (MetaShapedTexture *self)
priv->mask_texture = NULL;
priv->create_mipmaps = TRUE;
priv->is_y_inverted = TRUE;
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_UNSTABLE_TEXTURES))
{
g_signal_connect_object (backend, "suspending", G_CALLBACK (meta_shaped_texture_save), self, G_CONNECT_SWAPPED);
g_signal_connect_object (backend, "resuming", G_CALLBACK (meta_shaped_texture_restore), self, G_CONNECT_SWAPPED);
}
}
static void
@@ -209,25 +247,74 @@ meta_shaped_texture_dispose (GObject *object)
G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
}
static int
get_layer_indices (MetaShapedTexture *stex,
int *main_layer_index,
int *backing_mask_layer_index,
int *backing_layer_index,
int *mask_layer_index)
{
MetaShapedTexturePrivate *priv = stex->priv;
int next_layer_index = 0;
if (main_layer_index)
*main_layer_index = next_layer_index;
next_layer_index++;
if (priv->backing_store)
{
if (backing_mask_layer_index)
*backing_mask_layer_index = next_layer_index;
next_layer_index++;
if (backing_layer_index)
*backing_layer_index = next_layer_index;
next_layer_index++;
}
else
{
if (backing_mask_layer_index)
*backing_mask_layer_index = -1;
if (backing_layer_index)
*backing_layer_index = -1;
}
if (mask_layer_index)
*mask_layer_index = next_layer_index;
return next_layer_index;
}
static CoglPipeline *
get_base_pipeline (MetaShapedTexture *stex,
CoglContext *ctx)
{
MetaShapedTexturePrivate *priv = stex->priv;
CoglPipeline *pipeline;
int main_layer_index;
int backing_layer_index;
int backing_mask_layer_index;
int i, number_of_layers;
if (priv->base_pipeline)
return priv->base_pipeline;
pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_wrap_mode_s (pipeline, 0,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
cogl_pipeline_set_layer_wrap_mode_t (pipeline, 0,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
cogl_pipeline_set_layer_wrap_mode_s (pipeline, 1,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
cogl_pipeline_set_layer_wrap_mode_t (pipeline, 1,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
number_of_layers = get_layer_indices (stex,
&main_layer_index,
&backing_mask_layer_index,
&backing_layer_index,
NULL);
for (i = 0; i < number_of_layers; i++)
{
cogl_pipeline_set_layer_wrap_mode_s (pipeline, i,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
cogl_pipeline_set_layer_wrap_mode_t (pipeline, i,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
}
if (!priv->is_y_inverted)
{
CoglMatrix matrix;
@@ -235,11 +322,26 @@ get_base_pipeline (MetaShapedTexture *stex,
cogl_matrix_init_identity (&matrix);
cogl_matrix_scale (&matrix, 1, -1, 1);
cogl_matrix_translate (&matrix, 0, -1, 0);
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
cogl_pipeline_set_layer_matrix (pipeline, main_layer_index, &matrix);
}
if (priv->backing_store)
{
g_autofree char *backing_description = NULL;
cogl_pipeline_set_layer_combine (pipeline, backing_mask_layer_index,
"RGBA = REPLACE(PREVIOUS)",
NULL);
backing_description = g_strdup_printf ("RGBA = INTERPOLATE(PREVIOUS, TEXTURE_%d, TEXTURE_%d[A])",
backing_layer_index,
backing_mask_layer_index);
cogl_pipeline_set_layer_combine (pipeline,
backing_layer_index,
backing_description,
NULL);
}
if (priv->snippet)
cogl_pipeline_add_layer_snippet (pipeline, 0, priv->snippet);
cogl_pipeline_add_layer_snippet (pipeline, main_layer_index, priv->snippet);
priv->base_pipeline = pipeline;
@@ -259,12 +361,15 @@ get_masked_pipeline (MetaShapedTexture *stex,
{
MetaShapedTexturePrivate *priv = stex->priv;
CoglPipeline *pipeline;
int mask_layer_index;
if (priv->masked_pipeline)
return priv->masked_pipeline;
get_layer_indices (stex, NULL, NULL, NULL, &mask_layer_index);
pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
cogl_pipeline_set_layer_combine (pipeline, 1,
cogl_pipeline_set_layer_combine (pipeline, mask_layer_index,
"RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
NULL);
@@ -339,6 +444,8 @@ set_cogl_texture (MetaShapedTexture *stex,
if (priv->texture)
cogl_object_unref (priv->texture);
g_clear_pointer (&priv->saved_base_surface, cairo_surface_destroy);
priv->texture = cogl_tex;
if (cogl_tex != NULL)
@@ -373,46 +480,21 @@ set_cogl_texture (MetaShapedTexture *stex,
}
static void
meta_shaped_texture_paint (ClutterActor *actor)
do_paint (MetaShapedTexture *stex,
CoglFramebuffer *fb,
CoglTexture *paint_tex,
cairo_region_t *clip_region)
{
MetaShapedTexture *stex = (MetaShapedTexture *) actor;
MetaShapedTexturePrivate *priv = stex->priv;
guint tex_width, tex_height;
guchar opacity;
CoglContext *ctx;
CoglFramebuffer *fb;
CoglTexture *paint_tex;
ClutterActorBox alloc;
CoglPipelineFilter filter;
if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
return;
if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (stex)))
clutter_actor_realize (CLUTTER_ACTOR (stex));
/* The GL EXT_texture_from_pixmap extension does allow for it to be
* used together with SGIS_generate_mipmap, however this is very
* rarely supported. Also, even when it is supported there
* are distinct performance implications from:
*
* - Updating mipmaps that we don't need
* - Having to reallocate pixmaps on the server into larger buffers
*
* So, we just unconditionally use our mipmap emulation code. If we
* wanted to use SGIS_generate_mipmap, we'd have to query COGL to
* see if it was supported (no API currently), and then if and only
* if that was the case, set the clutter texture quality to HIGH.
* Setting the texture quality to high without SGIS_generate_mipmap
* support for TFP textures will result in fallbacks to XGetImage.
*/
if (priv->create_mipmaps)
paint_tex = meta_texture_tower_get_paint_texture (priv->paint_tower);
else
paint_tex = COGL_TEXTURE (priv->texture);
if (paint_tex == NULL)
return;
int main_layer_index;
int backing_mask_layer_index;
int backing_layer_index;
int mask_layer_index;
tex_width = priv->tex_width;
tex_height = priv->tex_height;
@@ -428,14 +510,15 @@ meta_shaped_texture_paint (ClutterActor *actor)
filter = COGL_PIPELINE_FILTER_LINEAR;
if (meta_actor_painting_untransformed (tex_width, tex_height, NULL, NULL))
if (meta_actor_painting_untransformed (fb,
tex_width, tex_height,
NULL, NULL))
filter = COGL_PIPELINE_FILTER_NEAREST;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
fb = cogl_get_draw_framebuffer ();
opacity = clutter_actor_get_paint_opacity (actor);
clutter_actor_get_allocation_box (actor, &alloc);
opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (stex));
clutter_actor_get_allocation_box (CLUTTER_ACTOR (stex), &alloc);
cairo_region_t *blended_region;
gboolean use_opaque_region = (priv->opaque_region != NULL && opacity == 255);
@@ -474,6 +557,12 @@ meta_shaped_texture_paint (ClutterActor *actor)
}
}
get_layer_indices (stex,
&main_layer_index,
&backing_mask_layer_index,
&backing_layer_index,
&mask_layer_index);
/* First, paint the unblended parts, which are part of the opaque region. */
if (use_opaque_region)
{
@@ -495,8 +584,24 @@ meta_shaped_texture_paint (ClutterActor *actor)
if (!cairo_region_is_empty (region))
{
opaque_pipeline = get_unblended_pipeline (stex, ctx);
cogl_pipeline_set_layer_texture (opaque_pipeline, 0, paint_tex);
cogl_pipeline_set_layer_filters (opaque_pipeline, 0, filter, filter);
cogl_pipeline_set_layer_texture (opaque_pipeline, main_layer_index, paint_tex);
cogl_pipeline_set_layer_filters (opaque_pipeline, main_layer_index, filter, filter);
if (priv->backing_store)
{
cogl_pipeline_set_layer_texture (opaque_pipeline,
backing_mask_layer_index,
priv->backing_store->mask_texture);
cogl_pipeline_set_layer_filters (opaque_pipeline,
backing_mask_layer_index,
filter, filter);
cogl_pipeline_set_layer_texture (opaque_pipeline,
backing_layer_index,
priv->backing_store->texture);
cogl_pipeline_set_layer_filters (opaque_pipeline,
backing_layer_index,
filter, filter);
}
n_rects = cairo_region_num_rectangles (region);
for (i = 0; i < n_rects; i++)
@@ -531,12 +636,28 @@ meta_shaped_texture_paint (ClutterActor *actor)
else
{
blended_pipeline = get_masked_pipeline (stex, ctx);
cogl_pipeline_set_layer_texture (blended_pipeline, 1, priv->mask_texture);
cogl_pipeline_set_layer_filters (blended_pipeline, 1, filter, filter);
cogl_pipeline_set_layer_texture (blended_pipeline, mask_layer_index, priv->mask_texture);
cogl_pipeline_set_layer_filters (blended_pipeline, mask_layer_index, filter, filter);
}
cogl_pipeline_set_layer_texture (blended_pipeline, 0, paint_tex);
cogl_pipeline_set_layer_filters (blended_pipeline, 0, filter, filter);
cogl_pipeline_set_layer_texture (blended_pipeline, main_layer_index, paint_tex);
cogl_pipeline_set_layer_filters (blended_pipeline, main_layer_index, filter, filter);
if (priv->backing_store)
{
cogl_pipeline_set_layer_texture (blended_pipeline,
backing_mask_layer_index,
priv->backing_store->mask_texture);
cogl_pipeline_set_layer_filters (blended_pipeline,
backing_mask_layer_index,
filter, filter);
cogl_pipeline_set_layer_texture (blended_pipeline,
backing_layer_index,
priv->backing_store->texture);
cogl_pipeline_set_layer_filters (blended_pipeline,
backing_layer_index,
filter, filter);
}
CoglColor color;
cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity);
@@ -573,6 +694,52 @@ meta_shaped_texture_paint (ClutterActor *actor)
cairo_region_destroy (blended_region);
}
static void
meta_shaped_texture_paint (ClutterActor *actor)
{
MetaShapedTexture *stex = META_SHAPED_TEXTURE (actor);
MetaShapedTexturePrivate *priv = stex->priv;
CoglTexture *paint_tex = NULL;
CoglFramebuffer *fb;
if (!priv->texture)
return;
if (priv->clip_region && cairo_region_is_empty (priv->clip_region))
return;
if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (stex)))
clutter_actor_realize (CLUTTER_ACTOR (stex));
/* The GL EXT_texture_from_pixmap extension does allow for it to be
* used together with SGIS_generate_mipmap, however this is very
* rarely supported. Also, even when it is supported there
* are distinct performance implications from:
*
* - Updating mipmaps that we don't need
* - Having to reallocate pixmaps on the server into larger buffers
*
* So, we just unconditionally use our mipmap emulation code. If we
* wanted to use SGIS_generate_mipmap, we'd have to query COGL to
* see if it was supported (no API currently), and then if and only
* if that was the case, set the clutter texture quality to HIGH.
* Setting the texture quality to high without SGIS_generate_mipmap
* support for TFP textures will result in fallbacks to XGetImage.
*/
if (priv->create_mipmaps)
paint_tex = meta_texture_tower_get_paint_texture (priv->paint_tower);
if (!paint_tex)
paint_tex = COGL_TEXTURE (priv->texture);
if (cogl_texture_get_width (paint_tex) == 0 ||
cogl_texture_get_height (paint_tex) == 0)
return;
fb = cogl_get_draw_framebuffer ();
do_paint (META_SHAPED_TEXTURE (actor), fb, paint_tex, priv->clip_region);
}
static void
meta_shaped_texture_get_preferred_width (ClutterActor *self,
gfloat for_height,
@@ -706,6 +873,7 @@ meta_shaped_texture_set_mask_texture (MetaShapedTexture *stex,
priv = stex->priv;
g_clear_pointer (&priv->mask_texture, cogl_object_unref);
g_clear_pointer (&priv->saved_mask_surface, cairo_surface_destroy);
if (mask_texture != NULL)
{
@@ -727,6 +895,66 @@ meta_shaped_texture_is_obscured (MetaShapedTexture *self)
return FALSE;
}
static void
meta_texture_backing_store_redraw_mask (MetaTextureBackingStore *backing_store)
{
CoglError *error = NULL;
if (!cogl_texture_set_data (backing_store->mask_texture, COGL_PIXEL_FORMAT_A_8,
cairo_image_surface_get_stride (backing_store->mask_surface),
cairo_image_surface_get_data (backing_store->mask_surface), 0,
&error))
{
g_warning ("Failed to update backing mask texture");
g_clear_pointer (&error, cogl_error_free);
}
}
static gboolean
meta_texture_backing_store_shrink (MetaTextureBackingStore *backing_store,
const cairo_rectangle_int_t *area)
{
cairo_t *cr;
cairo_region_subtract_rectangle (backing_store->region, area);
/* If the client has finally redrawn the entire surface, we can
* ditch our snapshot
*/
if (cairo_region_is_empty (backing_store->region))
return FALSE;
cr = cairo_create (backing_store->mask_surface);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
gdk_cairo_region (cr, backing_store->region);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_fill (cr);
cairo_destroy (cr);
meta_texture_backing_store_redraw_mask (backing_store);
return TRUE;
}
static void
shrink_backing_region (MetaShapedTexture *stex,
const cairo_rectangle_int_t *area)
{
MetaShapedTexturePrivate *priv = stex->priv;
gboolean still_backing_texture;
if (!priv->backing_store)
return;
still_backing_texture =
meta_texture_backing_store_shrink (priv->backing_store, area);
if (!still_backing_texture)
disable_backing_store (stex);
}
/**
* meta_shaped_texture_update_area:
* @stex: #MetaShapedTexture
@@ -756,6 +984,8 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
if (priv->texture == NULL)
return FALSE;
shrink_backing_region (stex, &clip);
meta_texture_tower_update_area (priv->paint_tower, x, y, width, height);
unobscured_region = effective_unobscured_region (stex);
@@ -888,6 +1118,142 @@ meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
return priv->opaque_region;
}
static gboolean
should_get_via_offscreen (MetaShapedTexture *stex)
{
MetaShapedTexturePrivate *priv = stex->priv;
if (!cogl_texture_is_get_data_supported (priv->texture))
return TRUE;
return FALSE;
}
static cairo_surface_t *
get_image_via_offscreen (MetaShapedTexture *stex,
cairo_rectangle_int_t *clip,
CoglTexture **texture)
{
MetaShapedTexturePrivate *priv = stex->priv;
ClutterBackend *clutter_backend = clutter_get_default_backend ();
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
CoglTexture *image_texture;
GError *error = NULL;
CoglOffscreen *offscreen;
CoglFramebuffer *fb;
CoglMatrix projection_matrix;
unsigned int fb_width, fb_height;
cairo_rectangle_int_t fallback_clip;
CoglColor clear_color;
cairo_surface_t *surface;
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_TEXTURE_NPOT))
{
fb_width = priv->tex_width;
fb_height = priv->tex_height;
}
else
{
fb_width = clutter_util_next_p2 (priv->tex_width);
fb_height = clutter_util_next_p2 (priv->tex_height);
}
if (!clip)
{
fallback_clip = (cairo_rectangle_int_t) {
.width = priv->tex_width,
.height = priv->tex_height,
};
clip = &fallback_clip;
}
image_texture =
COGL_TEXTURE (cogl_texture_2d_new_with_size (cogl_context,
fb_width, fb_height));
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (image_texture),
FALSE);
if (!cogl_texture_allocate (COGL_TEXTURE (image_texture), &error))
{
g_error_free (error);
cogl_object_unref (image_texture);
return FALSE;
}
if (fb_width != priv->tex_width || fb_height != priv->tex_height)
{
CoglSubTexture *sub_texture;
sub_texture = cogl_sub_texture_new (cogl_context,
image_texture,
0, 0,
priv->tex_width, priv->tex_height);
cogl_object_unref (image_texture);
image_texture = COGL_TEXTURE (sub_texture);
}
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (image_texture));
fb = COGL_FRAMEBUFFER (offscreen);
cogl_object_unref (image_texture);
if (!cogl_framebuffer_allocate (fb, &error))
{
g_error_free (error);
cogl_object_unref (fb);
return FALSE;
}
cogl_framebuffer_push_matrix (fb);
cogl_matrix_init_identity (&projection_matrix);
cogl_matrix_scale (&projection_matrix,
1.0 / (priv->tex_width / 2.0),
-1.0 / (priv->tex_height / 2.0), 0);
cogl_matrix_translate (&projection_matrix,
-(priv->tex_width / 2.0),
-(priv->tex_height / 2.0), 0);
cogl_framebuffer_set_projection_matrix (fb, &projection_matrix);
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
do_paint (stex, fb, priv->texture, NULL);
cogl_framebuffer_pop_matrix (fb);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
clip->width, clip->height);
cogl_framebuffer_read_pixels (fb,
clip->x, clip->y,
clip->width, clip->height,
CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_data (surface));
cairo_surface_mark_dirty (surface);
if (texture)
{
*texture = cogl_object_ref (image_texture);
if (G_UNLIKELY (meta_debug_show_backing_store))
{
cairo_t *cr;
cr = cairo_create (surface);
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.75);
cairo_paint (cr);
cairo_destroy (cr);
}
cogl_texture_set_data (*texture, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface), 0, NULL);
}
cogl_object_unref (fb);
return surface;
}
/**
* meta_shaped_texture_get_image:
* @stex: A #MetaShapedTexture
@@ -906,34 +1272,52 @@ cairo_surface_t *
meta_shaped_texture_get_image (MetaShapedTexture *stex,
cairo_rectangle_int_t *clip)
{
MetaShapedTexturePrivate *priv = stex->priv;
cairo_rectangle_int_t *transformed_clip = NULL;
CoglTexture *texture, *mask_texture;
cairo_rectangle_int_t texture_rect = { 0, 0, 0, 0 };
cairo_surface_t *surface;
g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), NULL);
texture = COGL_TEXTURE (stex->priv->texture);
texture = COGL_TEXTURE (priv->texture);
if (texture == NULL)
return NULL;
texture_rect.width = cogl_texture_get_width (texture);
texture_rect.height = cogl_texture_get_height (texture);
if (priv->tex_width == 0 || priv->tex_height == 0)
return NULL;
if (clip != NULL)
{
/* GdkRectangle is just a typedef of cairo_rectangle_int_t,
* so we can use the gdk_rectangle_* APIs on these. */
if (!gdk_rectangle_intersect (&texture_rect, clip, clip))
double tex_scale;
cairo_rectangle_int_t tex_rect;
transformed_clip = alloca (sizeof (cairo_rectangle_int_t));
*transformed_clip = *clip;
clutter_actor_get_scale (CLUTTER_ACTOR (stex), &tex_scale, NULL);
meta_rectangle_scale_double (transformed_clip, 1.0 / tex_scale,
META_ROUNDING_STRATEGY_GROW);
tex_rect = (cairo_rectangle_int_t) {
.width = priv->tex_width,
.height = priv->tex_height,
};
if (!meta_rectangle_intersect (&tex_rect, transformed_clip,
transformed_clip))
return NULL;
}
if (clip != NULL)
if (should_get_via_offscreen (stex))
return get_image_via_offscreen (stex, transformed_clip, NULL);
if (transformed_clip)
texture = cogl_texture_new_from_sub_texture (texture,
clip->x,
clip->y,
clip->width,
clip->height);
transformed_clip->x,
transformed_clip->y,
transformed_clip->width,
transformed_clip->height);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
cogl_texture_get_width (texture),
@@ -945,21 +1329,22 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex,
cairo_surface_mark_dirty (surface);
if (clip != NULL)
if (transformed_clip)
cogl_object_unref (texture);
mask_texture = stex->priv->mask_texture;
mask_texture = priv->mask_texture;
if (mask_texture != NULL)
{
cairo_t *cr;
cairo_surface_t *mask_surface;
if (clip != NULL)
mask_texture = cogl_texture_new_from_sub_texture (mask_texture,
clip->x,
clip->y,
clip->width,
clip->height);
if (transformed_clip)
mask_texture =
cogl_texture_new_from_sub_texture (mask_texture,
transformed_clip->x,
transformed_clip->y,
transformed_clip->width,
transformed_clip->height);
mask_surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
cogl_texture_get_width (mask_texture),
@@ -979,13 +1364,233 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex,
cairo_surface_destroy (mask_surface);
if (clip != NULL)
if (transformed_clip)
cogl_object_unref (mask_texture);
}
return surface;
}
static void
meta_texture_backing_store_free (MetaTextureBackingStore *backing_store)
{
g_clear_pointer (&backing_store->texture, cogl_object_unref);
g_clear_pointer (&backing_store->mask_texture, cogl_object_unref);
g_clear_pointer (&backing_store->mask_surface, cairo_surface_destroy);
g_clear_pointer (&backing_store->region, cairo_region_destroy);
g_slice_free (MetaTextureBackingStore, backing_store);
}
static MetaTextureBackingStore *
meta_texture_backing_store_new (CoglTexture *texture)
{
MetaTextureBackingStore *backing_store = NULL;
ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *context = clutter_backend_get_cogl_context (backend);
CoglTexture *mask_texture = NULL;
guchar *mask_data;
int width, height, stride;
cairo_surface_t *surface;
cairo_region_t *region;
cairo_rectangle_int_t backing_rectangle;
width = cogl_texture_get_width (texture);
height = cogl_texture_get_height (texture);
stride = cairo_format_stride_for_width (CAIRO_FORMAT_A8, width);
/* we start off by only letting the backing texture through, and none of the real texture */
backing_rectangle.x = 0;
backing_rectangle.y = 0;
backing_rectangle.width = width;
backing_rectangle.height = height;
region = cairo_region_create_rectangle (&backing_rectangle);
/* initialize mask to transparent, so the entire backing store shows through
* up front
*/
mask_data = g_malloc0 (stride * height);
surface = cairo_image_surface_create_for_data (mask_data,
CAIRO_FORMAT_A8,
width,
height,
stride);
if (meta_texture_rectangle_check (texture))
{
mask_texture = COGL_TEXTURE (cogl_texture_rectangle_new_with_size (context,
width,
height));
cogl_texture_set_components (mask_texture, COGL_TEXTURE_COMPONENTS_A);
cogl_texture_set_region (mask_texture,
0, 0,
0, 0,
width, height,
width, height,
COGL_PIXEL_FORMAT_A_8,
stride, mask_data);
}
else
{
CoglError *error = NULL;
mask_texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (context, width, height,
COGL_PIXEL_FORMAT_A_8,
stride, mask_data, &error));
if (error)
{
g_warning ("Failed to allocate mask texture: %s", error->message);
cogl_error_free (error);
}
}
if (mask_texture)
{
backing_store = g_slice_new0 (MetaTextureBackingStore);
backing_store->texture = cogl_object_ref (texture);
backing_store->mask_texture = mask_texture;
backing_store->mask_surface = surface;
backing_store->region = region;
}
return backing_store;
}
static void
enable_backing_store (MetaShapedTexture *stex,
CoglTexture *texture)
{
MetaShapedTexturePrivate *priv = stex->priv;
g_clear_pointer (&priv->backing_store, meta_texture_backing_store_free);
priv->backing_store = meta_texture_backing_store_new (texture);
meta_shaped_texture_reset_pipelines (stex);
}
static void
disable_backing_store (MetaShapedTexture *stex)
{
MetaShapedTexturePrivate *priv = stex->priv;
g_clear_pointer (&priv->backing_store, meta_texture_backing_store_free);
meta_shaped_texture_reset_pipelines (stex);
}
void
meta_shaped_texture_save (MetaShapedTexture *stex)
{
CoglTexture *texture, *mask_texture;
MetaShapedTexturePrivate *priv = stex->priv;
cairo_surface_t *surface;
g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
texture = COGL_TEXTURE (priv->texture);
if (texture == NULL)
return;
g_clear_pointer (&priv->saved_base_surface, cairo_surface_destroy);
g_clear_pointer (&priv->saved_mask_surface, cairo_surface_destroy);
g_clear_pointer (&priv->backing_store, meta_texture_backing_store_free);
if (should_get_via_offscreen (stex))
{
CoglTexture *backing_texture;
meta_shaped_texture_reset_pipelines (stex);
surface = get_image_via_offscreen (stex, NULL, &backing_texture);
enable_backing_store (stex, backing_texture);
cogl_object_unref (backing_texture);
}
else
{
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
cogl_texture_get_width (texture),
cogl_texture_get_height (texture));
cogl_texture_get_data (texture, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface));
}
priv->saved_base_surface = surface;
mask_texture = stex->priv->mask_texture;
if (mask_texture != NULL)
{
cairo_surface_t *mask_surface;
mask_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
cogl_texture_get_width (mask_texture),
cogl_texture_get_height (mask_texture));
cogl_texture_get_data (mask_texture, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (mask_surface),
cairo_image_surface_get_data (mask_surface));
cairo_surface_mark_dirty (mask_surface);
priv->saved_mask_surface = mask_surface;
}
}
void
meta_shaped_texture_restore (MetaShapedTexture *stex)
{
MetaShapedTexturePrivate *priv = stex->priv;
CoglTexture *texture;
CoglError *error = NULL;
texture = meta_shaped_texture_get_texture (stex);
if (texture == NULL)
return;
if (priv->mask_texture)
{
if (!cogl_texture_set_data (priv->mask_texture, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (priv->saved_mask_surface),
cairo_image_surface_get_data (priv->saved_mask_surface), 0,
&error))
{
g_warning ("Failed to restore mask texture");
g_clear_pointer (&error, cogl_error_free);
}
g_clear_pointer (&priv->saved_mask_surface, cairo_surface_destroy);
}
/* if the main texture doesn't support direct writes, then
* write to the local backing texture instead, and blend old
* versus new at paint time.
*/
if (priv->backing_store)
{
meta_texture_backing_store_redraw_mask (priv->backing_store);
texture = priv->backing_store->texture;
}
if (!cogl_texture_set_data (texture, CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (priv->saved_base_surface),
cairo_image_surface_get_data (priv->saved_base_surface), 0,
&error))
{
g_warning ("Failed to restore texture");
g_clear_pointer (&error, cogl_error_free);
}
g_clear_pointer (&priv->saved_base_surface, cairo_surface_destroy);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
}
void
meta_shaped_texture_set_fallback_size (MetaShapedTexture *self,
guint fallback_width,

View File

@@ -58,5 +58,6 @@ void meta_window_actor_effect_completed (MetaWindowActor *actor,
MetaSurfaceActor *meta_window_actor_get_surface (MetaWindowActor *self);
void meta_window_actor_update_surface (MetaWindowActor *self);
MetaWindowActor *meta_window_actor_from_window (MetaWindow *window);
#endif /* META_WINDOW_ACTOR_PRIVATE_H */

View File

@@ -24,6 +24,7 @@
#include <meta/meta-shadow-factory.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-screen-cast-window.h"
#include "clutter/clutter-mutter.h"
#include "compositor-private.h"
#include "meta-shaped-texture-private.h"
@@ -142,6 +143,8 @@ struct _FrameData
enum
{
FIRST_FRAME,
EFFECTS_COMPLETED,
LAST_SIGNAL
};
@@ -186,8 +189,11 @@ static void do_send_frame_timings (MetaWindowActor *self,
static void cullable_iface_init (MetaCullableInterface *iface);
static void screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface);
G_DEFINE_TYPE_WITH_CODE (MetaWindowActor, meta_window_actor, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init)
G_IMPLEMENT_INTERFACE (META_TYPE_SCREEN_CAST_WINDOW, screen_cast_window_iface_init));
static void
frame_data_free (FrameData *frame)
@@ -238,6 +244,21 @@ meta_window_actor_class_init (MetaWindowActorClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
/**
* MetaWindowActor::effects-completed:
* @actor: the #MetaWindowActor instance
*
* The ::effects-completed signal will be emitted once all pending compositor
* effects are completed.
*/
signals[EFFECTS_COMPLETED] =
g_signal_new ("effects-completed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
pspec = g_param_spec_object ("meta-window",
"MetaWindow",
"The displayed MetaWindow",
@@ -1131,6 +1152,7 @@ meta_window_actor_after_effects (MetaWindowActor *self)
return;
}
g_signal_emit (self, signals[EFFECTS_COMPLETED], 0);
meta_window_actor_sync_visibility (self);
meta_window_actor_sync_actor_geometry (self, FALSE);
}
@@ -2157,3 +2179,135 @@ meta_window_actor_sync_updates_frozen (MetaWindowActor *self)
meta_window_actor_set_updates_frozen (self, meta_window_updates_are_frozen (window));
}
MetaWindowActor *
meta_window_actor_from_window (MetaWindow *window)
{
return META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
}
static void
meta_window_actor_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
ClutterActor *clutter_actor;
clutter_actor = CLUTTER_ACTOR (meta_window_actor_get_texture (window_actor));
bounds->x = 0;
bounds->y = 0;
bounds->width = (int) clutter_actor_get_width (clutter_actor);
bounds->height = (int) clutter_actor_get_height (clutter_actor);
}
static void
meta_window_actor_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
MetaWindow *window;
MetaShapedTexture *stex;
MetaRectangle buffer_rect;
MetaRectangle frame_rect;
double scale_x, scale_y;
stex = meta_surface_actor_get_texture (window_actor->priv->surface);
clutter_actor_get_scale (CLUTTER_ACTOR (stex), &scale_x, &scale_y);
window = window_actor->priv->window;
meta_window_get_buffer_rect (window, &buffer_rect);
meta_window_get_frame_rect (window, &frame_rect);
bounds->x = (int) floor ((frame_rect.x - buffer_rect.x) / scale_x);
bounds->y = (int) floor ((frame_rect.y - buffer_rect.y) / scale_y);
bounds->width = (int) ceil (frame_rect.width / scale_x);
bounds->height = (int) ceil (frame_rect.height / scale_y);
}
static void
meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast_window,
double x,
double y,
double *x_out,
double *y_out)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
MetaShapedTexture *stex;
MetaRectangle bounds;
ClutterVertex v1 = { 0.f, }, v2 = { 0.f, };
meta_window_actor_get_frame_bounds (screen_cast_window, &bounds);
v1.x = CLAMP ((float) x,
bounds.x,
bounds.x + bounds.width);
v1.y = CLAMP ((float) y,
bounds.y,
bounds.y + bounds.height);
stex = meta_surface_actor_get_texture (window_actor->priv->surface);
clutter_actor_apply_transform_to_point (CLUTTER_ACTOR (stex), &v1, &v2);
*x_out = (double) v2.x;
*y_out = (double) v2.y;
}
static void
meta_window_actor_capture_into (MetaScreenCastWindow *screen_cast_window,
MetaRectangle *bounds,
uint8_t *data)
{
MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window);
cairo_surface_t *image;
MetaRectangle clip_rect;
uint8_t *cr_data;
int cr_stride;
int bpp = 4;
if (meta_window_actor_is_destroyed (window_actor))
return;
clip_rect = *bounds;
image = meta_surface_actor_get_image (window_actor->priv->surface, &clip_rect);
cr_data = cairo_image_surface_get_data (image);
cr_stride = cairo_image_surface_get_stride (image);
if (clip_rect.width < bounds->width || clip_rect.height < bounds->height)
{
uint8_t *src, *dst;
src = cr_data;
dst = data;
for (int i = 0; i < clip_rect.height; i++)
{
memcpy (dst, src, cr_stride);
if (clip_rect.width < bounds->width)
memset (dst + cr_stride, 0, (bounds->width * bpp) - cr_stride);
src += cr_stride;
dst += bounds->width * bpp;
}
for (int i = clip_rect.height; i < bounds->height; i++)
{
memset (dst, 0, bounds->width * bpp);
dst += bounds->width * bpp;
}
}
else
{
memcpy (data, cr_data, clip_rect.height * cr_stride);
}
cairo_surface_destroy (image);
}
static void
screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface)
{
iface->get_buffer_bounds = meta_window_actor_get_buffer_bounds;
iface->get_frame_bounds = meta_window_actor_get_frame_bounds;
iface->transform_relative_position = meta_window_actor_transform_relative_position;
iface->capture_into = meta_window_actor_capture_into;
}

View File

@@ -81,7 +81,11 @@ meta_window_group_paint (ClutterActor *actor)
*/
if (clutter_actor_is_in_clone_paint (actor))
{
if (!meta_actor_painting_untransformed (screen_width,
CoglFramebuffer *fb;
fb = cogl_get_draw_framebuffer ();
if (!meta_actor_painting_untransformed (fb,
screen_width,
screen_height,
&paint_x_origin,
&paint_y_origin) ||

View File

@@ -38,6 +38,12 @@ typedef enum
FIXED_DIRECTION_Y = 1 << 1,
} FixedDirections;
typedef enum _MetaRoundingStrategy
{
META_ROUNDING_STRATEGY_SHRINK,
META_ROUNDING_STRATEGY_GROW,
} MetaRoundingStrategy;
/* Output functions -- note that the output buffer had better be big enough:
* rect_to_string: RECT_LENGTH
* region_to_string: (RECT_LENGTH+strlen(separator_string)) *
@@ -218,6 +224,10 @@ GList* meta_rectangle_find_nonintersected_monitor_edges (
gboolean meta_rectangle_is_adjecent_to (MetaRectangle *rect,
MetaRectangle *other);
void meta_rectangle_scale_double (MetaRectangle *rect,
double scale,
MetaRoundingStrategy rounding_strategy);
static inline ClutterRect
meta_rectangle_to_clutter_rect (MetaRectangle *rect)
{

Some files were not shown because too many files have changed in this diff Show More