Commit graph

288 commits

Author SHA1 Message Date
Derek Foreman 49ccd7f786 matrix: add weston_coord_surface_invert()
Simple helper to multiply a surface coordinate by -1, -1. There are no
uses yet, but will be in a follow up patch that wants to have cursor
hotspots in their inverted form.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Loïc Yhuel c00ef0a5ce libweston: Do not include private headers in shell-utils.h
Since it's a public header, it should be usable outside of weston tree.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
2023-09-11 10:28:57 +02:00
Philipp Zabel 1d59530e4b libweston: Set the presentation clock in the compositor
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.

Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.

In the future, this can be extended to determine the subset of clocks
supported by all backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 11:51:56 +03:00
Sergio Gómez cc837eea61 kiosk-shell: Redesign the function 'find_focus_successor()'
The function find_focus_successor() is called when destroying a surface to find
a successor to the current focus. It, however, has the following issues:

- Its first parameter is the weston layer from which to search for a successor.
  This is an unnecessary flexibility for our use, which only adds complexity to
  the user of the function by having to make a call for each layer. We know
  that we want to search for a successor first in the normal layer, and if that
  fails, then in the inactive layer. So we change the signature of
  find_focus_successor(), removing this first parameter.

- It includes logic to decide whether to do the search or not: if the destroyed
  surface is different from the surface that currently has focus, and if their
  outputs are the same, then abort and don't do the search. This returns NULL to
  the calling function. The problem is that the function also returns NULL if
  it does the search and finds no successor. The distinction for the failing
  reason is lost, and the user of the function needs to add more logic to know
  the reason for failure. To simplify, we take the logic out of
  find_focus_successor() and inside the caller.

- It returns the successor view, although it receives surfaces and the client
  has logic to retrieve the surface corresponding to the returned view. To
  simplify and maintain symmetry, we change the signature so that the function
  returns the surface corresponding to the successor view.

Fixes: #738

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-07-27 10:13:48 +03:00
Derek Foreman 550c4c3dbc libweston: Remove plane clip
Currently this isn't calculated properly, and results in clipping away
important damage when a client moves from a non-primary plane to the
primary plane.

Instead of trying to fix it, let's just throw it away.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-20 14:42:55 -05:00
Derek Foreman 89ff5ddfd9 libweston: Replace struct_weston_position with weston_coords
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-19 07:48:30 -05:00
Philipp Zabel 40df321d7c libweston: Document struct weston_mode
The main point of this is to write down that the refresh field is in
units of mHz.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-07-17 15:25:46 +02:00
Christopher Obbard 463ebda4e4 libweston: Split dbus support into seperate build option
Currently dbus support is built when launcher-logind option
is set; let's split that such that dbus is its own option
and launcher-logind depends on dbus.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
2023-07-14 10:55:24 +00:00
Christopher Obbard 9e36620be7 libweston: Decouple dbus helper to public namespace
Currently the dbus helper stuff is internal only in libweston,
let's move it to being public so that custom shells may use
the helper code.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
2023-07-14 10:55:24 +00:00
Derek Foreman ee7971e2cd libweston: have one primary_plane per output
The primary_plane is currently shared amongst all outputs, and is the last
barrier to having overlapping outputs.

Split it up and make it per output instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 9c116e1f13 libweston.h: Move struct weston_plane earlier in the file
We're going to move primary planes from compositor to output, so we need
struct weston_plane to precede struct weston_output.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 71cfca6a13 libweston: Remove view clip region
This is no longer used anywhere.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 820346a372 libweston: Track damage on paint nodes instead of planes
Remove plane->damage and instead accumulate damage on paint
nodes.

This is a step towards allowing multiple overlapping outputs.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman fe2b5db01e libweston: Track plane in paint node instead of view
Tracking the view's plane in the paint node in this way is a step towards
inflicting plane damage from paint node update during the output repaint,
instead of manually doing weston_view_damage_below().

We remove view->plane entirely and do all access through pnodes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 7b2ae2ba77 libweston: Add visible region to weston_view
Later, we'll want to use the visible region for damage tracking in
paint_nodes. For now, we can use it in the renderers where they've been
calculating it independently to draw paint nodes.

We still can't remove view->clip entirely, because
weston_view_damage_below() may be called before the first render of
a view, when its visible region hasn't been calculated yet. The
clip is empty at that point, which allows weston_view_damage_below()
to "work".

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman f7ddaa142a libweston: Replace weston_output_damage() with a flag
In the future we'd like to have multiple overlapping outputs.

weston_output_damage() currently adds damage to the output's coordinates
on the primary plane. This plane is shared between all outputs, so it
would result in damaging more than the intended output.

Eventually, plane damage will go away and be replaced by paint node damage,
and damaging the entire output would involve adding damage to a list of
paint nodes.

Instead, use a flag to indicate the output must be fully redrawn, and add
the damage during the repaint loop.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Daniel Stone fc776c3b59 view: Add weston_view_add_transform and weston_view_remove_transform
They do what they say on the box, and inflict damage where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 7d2c5e0c33 view: Add weston_view_set_alpha()
Does what it says on the box: sets the view's alpha, also inflicting
damage where required.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone bf228370ff view: Add view_list_needs_rebuild member
Most of the time when we're changing things about views, we don't need
to throw away the view list and rebuild it from scratch. The only times
when we need to do this are when views have been added to or removed
from the scene graph, or have been restacked within it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone c859dd1b9e surface: Only rebuild subsurface lists when necessary
There's no need to go through and rebuild the subsurface list every
time. In addition to being unnecessary work, it complicates things like
damage tracking.

Track a new surface dirty status indicating that the subsurface tree has
changed in some way, and only rebuild subsurface stacking when this has
occurred.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 0f99e081c4 surface: Add input-region dirty flag
Used when the input region changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3bba90764e surface: Add buffer-params dirty flag
This indicates that more than just the content changing, the form of the
buffer has changed in a way which may not be like-for-like to the
previous buffer but require significant reinterpretation. Examples
include the format, opacity, colour state, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone d8669679c4 surface: Add position dirty member
This is used when a surface is repositioned via offsets.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 3c1e2e5c32 surface: Add comments to weston_surface_status member
Explain what each member implies.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 6526346b72 surface: Replace viewport.changed with weston_surface_status
Instead of having an individual bool, reuse the surface state's dirty
status for viewport changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 8255274a92 surface: Replace newly_attached with weston_surface_status
Instead of having a bool for whether or not a buffer has been attached
in this commit cycle, use a status bitmask.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-04 15:52:21 +01:00
Daniel Stone 7e1d446279 libweston: Add weston_view::map_signal
It fires when a view is mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone 07103d1842 weston-desktop: Match desktop-shell view mapping semantics
Preserve the same order as desktop-shell for handling view (un)mapping,
so we can move these into a shared helper. These should have no
functional effect but provide a helpful bisect point.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone 2f2e20f3a3 weston_surface: Add map and unmap signals
These signals are emitted when the surface becomes mapped or unmapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-26 15:49:50 +00:00
Daniel Stone 8532c28761 surface: Start tracking weston_surface_status
Akin to the paint_node_status we already have, start also tracking a
surface dirty status. This will allow us to minimise the updates we need
to make.

Currently this is only collected, with no functional change made.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-21 08:02:59 +00:00
Daniel Stone f6d81e42d4 surface: Convert a couple of ints to bools
Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-21 08:02:59 +00:00
Daniel Stone 579019a78d libweston: Add weston_compositor.shutting_down
It does what it says on the box: is true when the compositor is in the
process of shutting down.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Daniel Stone 104676ec1f xwayland: Remove process exit status from libweston API
This shouldn't be relevant to the core.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Daniel Stone e64232a808 xwayland: Only pass Xwayland wl_client to libweston
Remove all handling of process/PID internals from libweston's Xwayland
launcher, and keep this only in the frontend. libweston now only sees
the wl_client and nothing else.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Derek Foreman 2ac566d281 libweston: Add more weston_coord arithmetic helpers
Until now we've only had the unadorned arithmetic functions, but they're
easy to abuse and tedious to use.

For now, we just add weston_coord_global_add/sub functions and use them
where appropriate.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-19 13:09:03 +00:00
Derek Foreman d961e59d4a libweston: Add getters for view position/offset
This is stored as an unadorned weston_coord internally, but with getter
functions we can put together the appropriate global or surface
coordinate.

Use them where appropriate.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-19 13:09:03 +00:00
Derek Foreman 1f81c082b5 libweston: Add weston_coord_truncate()
Truncating a weston coord to integer values is something we do
frequently enough to warrant a helper function.

Use this in the kiosk and desktop shells where appropriate.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-19 13:09:03 +00:00
Derek Foreman 0bf2d82e0c libweston: Use weston_coord in struct weston_touch
Convert the grab coordinate to a weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:58:17 -05:00
Derek Foreman e8208d21d7 libweston: Use weston_coord in struct weston_output
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:22 -05:00
Derek Foreman 244dc963b9 libweston: use weston_coord for weston_view_set_position
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:19 -05:00
Marius Vlad 4bc7bd73d7 libweston/weston-log: Add a iterator helper for debug scope
This adds three new helpers: one to iterate over all debug scopes
created/added and other two are for simpler getters for the scope name
and the description.

Included with this change is also a simple test to retrieve them.

This is an alternative to using the debug scope list advertised when
using the weston-debug private extension. libweston users can use this
directly to know which scopes they can subscribe to, and there's no need
to have a client implementation for the weston-debug protocol.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-05-30 11:05:14 +00:00
Sergio Gómez 4aafd872d0 libweston: Introduce WESTON_ACTIVATE_FLAG_FULLSCREEN in weston_activate_flag
This will be used to let know the constraints code that the reason for
activation is that the client has requested to set the surface to fullscreen.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-25 12:07:03 +03:00
Sergio Gómez ed012ee505 libweston: Store view instead of surface, and add flags, to activation data
Since we want to pass the view to the surface activation listener inside the
constraints code, and the surface is reachable from the view anyway.

The flags field will let us pass the reason for activation to the constraints
code, which will then handle especially the fullscreen case.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-25 12:07:03 +03:00
Philipp Zabel dfa821d4c0 backend-pipewire: pass backend to weston_pipewire_output_api::create_head()
Pass the backend instead of the compositor to the PipeWire output API
create_head() method and increment the API version.

That way the backend will not have to find the backend pointer from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-04-19 13:36:45 +00:00
Philipp Zabel ebc3a22b09 backend-pipewire: add PipeWire backend
Add a separate PipeWire backend based on the PipeWire plugin. The backend
requires PipeWire 0.3.x.

The PipeWire backend can be used as a standalone-backend backend for streaming
and composing Wayland clients to PipeWire.

The backend supports the on-demand creation of heads via the
weston_pipewire_output_api_v1. It also supports per-output pixel format
configuration via a gbm-format option.

Multiple PipeWire outputs can be created by setting the num-outputs option in
the [pipewire] section.

Co-authored-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-04-18 10:48:50 +00:00
Philipp Zabel 7d2112c713 libweston: pass backend to weston_windowed_output_api::create_head()
Pass the backend instead of the compositor to the windowed output API
create_head() method and increment the API version.

That way the backend will not have to find the backend pointer from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-04-17 09:38:50 +02:00
Daniel Stone 6f9c27ac07 input: Consistently use enums for modifier/axis/state
For some reason we'd managed to have a mismatching header prototype and
implementation. Fix this up to consistently use enums everywhere.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-03 20:58:06 +03:00
Michael Olbrich 9eab270de5 tablet: Add binding to activate surfaces using the tablet tool
Based on patches from:
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>
Bastian Farkas <bfarkas@de.adit-jv.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul 6a06669b58 clients: Add support for tablet cursor motion to window frames in libtoytoolkit
When it comes to a window frame, a tablet tool and cursor act almost
identical; they click things, drag things, etc. The tool type and extra
axes don't serve any use in the context of a window frame, so tablet
pointers share the frame_pointer structures used for the mouse pointer.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Michael Olbrich 818c1c275c libweston: handle tablet cursors in the compositor
The tablet is given a separate cursor. Most tablet interaction is an absolute
interaction and shouldn't need a cursor at all, but usually the cursor is used
to indicate the type of virtual tool currently assigned.

Based on patches from
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>
Bastian Farkas <bfarkas@de.adit-jv.com>
Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00