1
0
Fork 0
Commit graph

50 commits

Author SHA1 Message Date
Jonas Ådahl
2d010c9b84 cursor-renderer: Disconnect the overlay cursor from the displayed cursor
The displayed cursor is the one displayed on the screen, e.g. via the
hardware cursor plane, by Xorg, or using the stage overlay.

When screen recording under X11, we don't get a stream of pointer and
cursor updates, as they might be grabbed by some other client. Because
of this, the cursor tracker or cursor renderer are not kept up to date
with positional and cursor state.

To be able to use the stage overlays when recording, we need to be able
to update the overlay without updating the displayed cursor, as we
shouldn't update the X server with cursor state we just retrieved from
it.

Thus, to achieve this, create a separate overlay cursor pointer. When
being a display server, they are always the same, but when using X11,
during screen recording, the overlay one will be polled at a fixed
interval to get a somewhat up to date state.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
a10f35c613 cursor-renderer: Keep ref to displayed cursor sprite
If it'd end up beig the XCursor sprite, it'll be unref:ed by the cursor
tracker when receiving a XFixesCursorNotify:XFixesDisplayCursorNotify
X11 event.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
b4a8247191 screen-cast: Track and always record cursors
Always force-track the cursor position (so that the X11 backend can keep
it up to date), and if the cursor wasn't part of the sampled
framebuffer when reading pixels into CPU memory, draw it in an extra
pass using cairo after the fact. The cairo based cursor painting only
happens on the X11 backend, as we otherwise inhibit the hw cursor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
eeee7bed1d cursor-tracker: Add way to force tracking cursor position
On X11 we won't always receive cursor positions, as some other client
might have grabbed the pointer (e.g. for implementing a popup menu). To
make screen casting show a somewhat correct cursor position, we need to
actively poll the X server about the current cursor position.

We only really want to do this when screen casting or taking a
screenshot, so add an API that forces the cursor tracker to track the
cursor position.

On the native backend this is a no-op as we by default always track the
cursor position anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
b319add04b cursor-renderer: Remove unneeded NULL check
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
fcf7c4d0c7 cursor-renderer: Always keep the cursor overlay on the stage
Only when the cursor isn't handled by the backend is the overlay made
visible. This is intended to be used when painting the stage to an
offscreen using clutter_stage_paint_to_(frame)buffer() in a way where
the cursor is always included.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
a9a9a0d1c5 clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.

For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.

This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.

Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:51 +02:00
Jonas Ådahl
9daec23033 cursor-renderer: Use 'after-paint' stage signal instead paint callback
The clutter "thread" repaint callback are not tied to painting, but
indirectly to updating. What the cursor renderer cares about is when we
actually painted, as this is related to the OpenGL fallback paths.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:51 +02:00
Jonas Ådahl
55302dbb38 cursor-renderer: Pass backend to constructor
Then use the backend passed instead of the global singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Georges Basile Stavracas Neto
94682e69aa Replace ClutterRect by graphene_rect_t
https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
160cc9182d Replace ClutterPoint by graphene_point_t
Remove the tests for ClutterPoint since it's
corresponding code moved to private ClutterStage
methods.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Jonas Ådahl
178b975d6a cursor-renderer: Align OpenGL cursor rect to physical pixel grid
When stage views are scaled with fractional scales, the cursor rectangle
won't be aligned with the physical pixel grid, making it potentially
blurry when positioned in between physical pixels. This can be avoided
by aligning the drawn rectangle to the physical pixel grid of the stage
view the cursor is located on.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/610
2019-06-07 19:11:34 +00:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Jonas Ådahl
79d99cbe3f cursor-renderer: Add API to allow inhibiting HW cursor
There may be reasons to temporarly inhibit the HW cursor under certain
circumstances. Allow adding such inhibitations by adding API to the
cursor renderer to allow API users to add generic inhibitors with
whatever logic is deemed necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
206634e0ed cursor-renderer: Rename update_cursor function
Call it meta_cursor_renderer_update_cursor. This avoids confusing it
with the update_cursor MetaCursorRendererClass vfunc when navigating
the file.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:55 +00:00
Jonas Ådahl
ea05d2af49 cursor-renderer/native: Let the backend realize cursor sprite itself
It knows better when it's needed. For now, just do it just as before,
before drawing. Eventually, we can conditionalize where to realize
depending on the cursor sprite position.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:55 +00:00
Jonas Ådahl
9dcf9782b6 cursor-renderer: Centralize hw cursor realization paths
Use a common entry point into the cursor renderer implementations HW
cursor realization paths for all cursor sprite types. This is in
preparation for realizing at more strategic times.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:53 +00:00
Jonas Ådahl
42c78bd41f cursor-renderer/native: Fetch instead of pass wl_buffer when realizing
This is the next step in centralizing the cursor sprite hw sprite
realization paths.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:53 +00:00
Jonas Ådahl
c80fd487f1 cursor-renderer: Fetch instead of pass Xcursor image when realizing
The end goal here is to being able to realize at any point in time
through a single API, so start by moving state into the cursor sprite
implementation.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:52 +00:00
Florian Müllner
7655e09d00 build: Introspect some more types
While MetaStage, MetaWindowGroup and MetaDBusDisplayConfigSkeleton don't
appear explicitly in the public API, their gtypes are still exposed via
meta_get_stage_for_screen(), meta_get_*window_group_for_screen() and
MetaMonitorManager's parent type. Newer versions of gjs will warn about
undefined properties if it encounters a gtype without introspection
information, so expose those types to shut up the warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2018-05-07 21:44:47 +02:00
Olivier Fourdan
67917db45f 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
2018-03-23 15:12:37 +01:00
Philip Withnall
93e450f37c backends: Fix ClutterRect initialisations
With Clang, these initialisations were warning about missing brackets.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=791022
2017-11-30 13:06:13 +00:00
Jonas Ådahl
197401fbf8 cursor-renderer: Track cursor position using floats
To be able to render the pointer cursor sprite at sub-(logical)-pixel
positions, track the pointer position using floats instead of ints.
This also requires users of the cursor sprite rect to deal with
floating points, when e.g. finding the logical monitor etc.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2017-07-14 20:54:27 +08:00
Rui Matos
2c1d3e5b70 cursor-renderer: Add a cursor painted signal
This signal allows interested parties to be notified of a new cursor
frame being painted regardless of whether it's being painted by the
backend directly or if it's a software rendered cursor frame handled
by clutter.

https://bugzilla.gnome.org/show_bug.cgi?id=749913
2016-08-31 20:10:14 +02:00
Carlos Garnacho
362ab781dd backends: Allow multiple "SW" cursor overlays on the stage
All the upper layers are prepared for multiple onscreen cursors, but
this. All MetaCursorRenderers created would poke the same internal
MetaOverlay in the stage.

This will lead to multiple cursor renderers resorting to the "SW"
rendering paths (as it can be seen with tablet support) to reuse the
same overlay, thus leading to flickering when a different
MetaCursorRenderer takes over the overlay.

Fix this by allowing per-cursor-renderer overlays, their lifetime
is attached to the cursor renderer, so is expected to be tear down
if the relevant device (eg. tablet) disappears.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
b3eb56bb78 backend: Realize cursor on default MetaCursorRenderer paths
The cursor is realized on x11/native subclasses, but not if a base
MetaCursorRenderer is created.
2016-05-03 13:05:06 +02:00
Victor Toso
ff312b6958 fix warning due implicit declaration of function
error: implicit declaration of function
  .x = (int)roundf (priv->current_x - (hot_x * texture_scale)),
            ^

https://bugzilla.gnome.org/show_bug.cgi?id=765252
2016-04-20 09:22:52 +02:00
Rui Matos
8b801aac77 Handle meta_screen_get_monitor_for_point() returning NULL
On the X11 backend we don't track the pointer position in
priv->current_x/y which remain set to zero. That means we never set
the clutter stage cursor if point 0,0 isn't covered by any monitor
since we return early.

Commit 4bebc5e5fa introduced this to
avoid crashing on the prepare-at handlers when the cursor position
doesn't fall inside any monitor area but we can handle that higher up
in the stack. In that case, the sprite's scale doesn't matter since
the cursor won't be shown anyway so we can skip setting it.

https://bugzilla.gnome.org/show_bug.cgi?id=763159
2016-03-10 16:01:54 +01:00
Marek Chalupa
4bebc5e5fa cursor-renderer: do not update cursor if it is out of monitor
if the cursor coordinates are out of monitor, just don't render the
cursor

https://bugzilla.gnome.org/show_bug.cgi?id=756698
2015-11-29 19:15:23 +01:00
Jonas Ådahl
79c86ae890 Support scaling of cursor sprites given what output they are on
This commits refactors cursor handling code and plugs in logic so that
cursor sprites changes appearance as it moves across the screen.
Renderers are adapted to handle the necessary functionality.

The logic for changing the cursor sprite appearance is done outside of
MetaCursorSprite, and actually where depends on what type of cursor it
is. In mutter we now have two types of cursors that may have their
appearance changed:

 - Themed cursors (aka root cursors)
 - wl_surface cursors

Themed cursors are created by MetaScreen and when created, when
applicable(*), it will extend the cursor via connecting to a signal
which is emitted everytime the cursor is moved. The signal handler will
calculate the expected scale given the monitor it is on and reload the
theme in a correct size when needed.

wl_surface cursors are created when a wl_surface is assigned the
"cursor" role, i.e. when a client calls wl_pointer.set_cursor. A
cursor role object is created which is connected to the cursor object
by the position signal, and will set a correct texture scale given what
monitor the cursor is on and what scale the wl_surface's active buffer
is in. It will also push new buffers to the same to the cursor object
when new ones are committed to the surface.

This commit also makes texture loading lazy, since the renderer doesn't
calculate a rectangle when the cursor position changes.

The native backend is refactored to be triple-buffered; see the comment
in meta-cursor-renderer-native.c for further explanations.

* when we are running as a Wayland compositor

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:26:22 +08:00
Jonas Ådahl
d3fdaa3232 MetaCursorSprite: Put renderer specific code in the renderer
There were lots of code handling the native renderer specific cases;
move these parts to the renderer. Note that this causes the X11 case to
always generate the texture which is a waste of memory, but his
regression will be fixed in a following commit.

The lazy loading of the texture was removed because it was eventually
always loaded anyway indirectly by the renderer to calculate the
current rect.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:55:12 +08:00
Jonas Ådahl
165050f8f9 backends: Get rid of meta-cursor-private.h
There is nothing special about the private API which only consists of
getters for renderer specific backing buffer. Lets them to the regular
.h file and treat them as part of the normal API.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:54:57 +08:00
Jonas Ådahl
4b667d1e09 Rename MetaCursorReference to MetaCursorSprite
It isn't really a reference to a MetaCursor enum, but a reference
counted cursor sprite, and enum value.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:52:30 +08:00
Carlos Garnacho
74ca936a00 backend: Add meta_cursor_renderer_force_update()
There will be times where additional updates will be needed, such
as animated cursors. We should update the texture and redraw in
that case.

https://bugzilla.gnome.org/show_bug.cgi?id=752342
2015-07-20 22:06:44 +02:00
Jasper St. Pierre
4450b5bb14 Revert "backends: Include Xfixes for cursor events and manipulation"
This reverts commit 34421e90c3.

These aren't needed at all.
2014-12-28 22:41:42 -08:00
Ikey Doherty
34421e90c3 backends: Include Xfixes for cursor events and manipulation
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=737463
2014-12-28 22:40:39 -08:00
Jasper St. Pierre
30953cf2d7 stage: Make the API take a CoglTexture
MetaCursorReference doesn't really need to be part of the API.
2014-08-21 15:04:58 -04:00
Jasper St. Pierre
5f0fab2156 Conditionalize Wayland support again 2014-08-13 20:28:22 -04:00
Jasper St. Pierre
467465c99c backend: Create the stage in the backend, rather than the compositor
This allows creating the stage much earlier than it otherwise would have
been. Our initialization sequence has always been a bit haphazard, with
first the MetaBackend created, then the MetaDisplay, and inside of that,
the MetaScreen and MetaCompositor.

Refactor this out so that the MetaBackend creates the Clutter
stage. Besides the clarity of early initialization, we now have much
easier access to the stage, allowing us to use it for things such as
key focus and beyond.
2014-08-13 20:08:46 -04:00
Jasper St. Pierre
3a0de6a4f1 cursor: Correct switching between fallback and backend cursors
When switching from the stage cursor to the native cursor, we
forgot to repaint the stage to get rid of the old cursor. Fix
this by having the abstract cursor renderer class track whether
we're using the backend, rather than doing chain-up shenanigans.
2014-05-17 13:27:15 -04:00
Jasper St. Pierre
10ac1000f7 cursor-renderer: We always use a MetaStage 2014-05-17 10:50:44 -04:00
Jasper St. Pierre
def097359c cursor-renderer: Remove bogus assert 2014-04-23 10:24:26 -04:00
Jasper St. Pierre
dd440e64da backends: Add a native cursor renderer 2014-04-22 16:56:02 -04:00
Jasper St. Pierre
a1ba480c8a cursor-renderer: Rewrite HW cursors to be cleaner 2014-04-22 16:56:02 -04:00
Jasper St. Pierre
93600d6166 cursor-renderer: Fix HW cursors
We need to make sure that we update the HW cursor if we disable
it for some reason.
2014-04-22 16:56:02 -04:00
Jasper St. Pierre
91784d87b6 Move the painting of the cursor on the stage out of the cursor renderer
This logic is now well-contained the stage. This is the start of us
moving to backend-specific cursor renderers.
2014-04-22 16:56:02 -04:00
Jasper St. Pierre
e21677c782 cursor-renderer: Kill a warning
This can happen during early initialization. We should have a
better initialization plan.
2014-04-22 16:56:01 -04:00
Jasper St. Pierre
4ea9a28eee cursor-renderer: Remove the MetaScreen
It's unused.
2014-04-22 16:56:01 -04:00
Jasper St. Pierre
d189ddcc86 Split out the code that renders the code into a MetaCursorRenderer
Right now, this is the same exact same mess it's always been, but
it will be fixed up soon with backend-specific renderers.
2014-04-21 20:25:20 -04:00