Commit Graph

653 Commits

Author SHA1 Message Date
Alexey Yerin d30683341c clients: don't redraw on xdg_toplevel.configure
Signed-off-by: Alexey Yerin <yyp@disroot.org>
Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
2024-11-06 10:12:51 +02:00
Joan Torres 53419eb991 clients/window: Allow rendering frame wihout shadow
Rendering the shadow currently renders some dark color near the border inside
the inner content.

Altough the content is on top of it, if the content has some transparency,
that dark color appears and this might be unwanted.

Add an option to not render the shadow to avoid that problem.

Signed-off-by: Joan Torres <joan.torres@suse.com>
2024-09-09 13:51:51 +00:00
Joan Torres 1b793b7acd color: update color-management protocol to xx-v4
The main differences is the split of cm_surface functionality with
cm_surface and cm_feedback_surface.

There can only be one cm_surface to set, unset image descriptions. When
cm_surface is destroyed, the image description is automatically unset.

There can be multiple feedback_surfaces for one surface though.
Now the "preferred_changed" signal can be an initial event.

Creator params now have a new request: set_luminances.

Signed-off-by: Joan Torres <joan.torres@suse.com>
2024-08-07 13:36:49 +00:00
Leandro Ribeiro dbdcae9801 clients: add widget_set_image_description_icc()
This function takes an ICC fd, creates an image description for that and
sets the widget surface image description to this one.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-11 10:15:40 -03:00
Daniel Martinez 2bce726992 clients: fix surface viewport memory leak
Signed-off-by: Daniel Martinez <danielmartinez@cock.li>
2024-06-11 09:33:31 +00:00
Leandro Ribeiro 2ac5777316 clients: make main event loop more robust
This makes the toytoolkit event loop more robust. Now it uses the
canonical wl_display_prepare_read(), read() and cancel().

Also, it allows functions that run before the event loop to create
Wayland queues and dispatch events related to such queue. Before our
changes, this would cause issues, because of how the loop was written
and also because dispatch_queue() reads the display fd and queue them on
the appropriate event queues, it doesn't read only the events related to
the queue we are interested.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-05 10:25:27 +00:00
Marius Vlad 5b1207a425 Revert "clients/window: Update min_allocation for smaller widths/heights"
This seems to break interactive resize, giving invalid/0/negative values
to pending allocations.

This reverts commit 9555118095.

Fixes: #780
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-19 14:40:03 +03:00
Marius Vlad 9555118095 clients/window: Update min_allocation for smaller widths/heights
This makes sure we update min_allocation in situations where the
width and height passed is smaller than the one set previously
(obviously except for the first time). This has the side effect of
not overwriting pending_allocations such that we correctly resize when
passed a width/height smaller the ones set-up in the past.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-07-05 21:28:16 +03:00
Derek Foreman f0196739ae toy-toolkit: Fix rotations
Ever since commit 3012934 some rotations have been broken. This is because
I transposed xy and yx in the cairo_matrix_init() call.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-27 11:41:35 +00:00
Michael Olbrich 14fc87cc42 clients/window: dismiss window on tablet tool up events
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
Lyude Paul 0ced0c62ee clients/window: Add tablet cursor support into libtoytoolkit
Again, a lot of this is code that has been reused from the cursor code
for pointers.

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 76ada6fe04 clients/window: add support for handling tablets
Based on a patch from:
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Derek Foreman 3012934a6d ttk: Use weston_matrix_init_transform in toy toolkit
Setup the cairo matrix with our new transform function.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-16 17:01:54 +00:00
Derek Foreman 5079f0b2f9 helpers: Add a u64 from 2 u32 helper
We do this enough that having a single implementation for it is probably
a win.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 08:13:30 +00:00
Derek Foreman 11ba13d717 clients: Fix cursors when compositor gives wl_seat before wl_compositor
We have no guarantee that we can create a surface for the pointer at the
instant we receive a seat that will (probably eventually) need one.

Hold off until we receive an enter event before creating this - at that
point we know with certainty that wl_compositor is available, since we've
used it to create the surface that was entered.

Fixes #659

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-12 11:53:41 -05:00
Derek Foreman 646cc1b389 clients: Set the hotspot with attach if we already have a valid cursor
We want atomic hotspot updates - this can't happen with
wl_pointer_set_cursor. So if we have a surface that already has a cursor
role, just update the hotspot when attaching new content.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:05:09 -05:00
Derek Foreman ebbe30df3c Revert "clients/window: atomically update pointer cursor"
This reverts commit 992ee045f1.

Recreating the surface for every cursor change causes flickering
cursors on some compositors, and is not the best way to achieve
atomic cursor updates

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:05:07 -05:00
Derek Foreman 8b0125d601 Revert "clients/window: Fix animated cursors"
This reverts commit f079f43658.

This only partially fixed a problem introduced in
992ee045f1

I'm reverting that commit in favor of a different fix, so this
broken fix needs to go first.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-08-10 13:04:27 -05:00
Marius Vlad 6744a6278e clients/window: Bump xdg-shell version to latest
It seems we've missed an update from 3 to 4 (bounds events). With it,
this updates to version 5 which sends the capabilities event. Stubs, as
we're not using them.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-26 16:17:43 +03:00
Pekka Paalanen 9229a45116 shared: rewrite fail_on_null() as abort_oom_if_null()
Recently I learnt that fprintf() is not async-signal-safe. Maybe it also
attempts to allocate memory sometimes. Hence, using it when we
presumably are out of memory is wishful thinking.

Therefore replace that with async-signal-safe code. If you have to check
pointers from traditional signal handlers, now you could do that too!

While doing this, we also lose the string formatting for line number. I
would argue that printing file and line number is not that useful, if
the system really is out of memory. If not out of memory, a core dump
would give us much more detailed information about what went wrong.

clients/window.c had some calls to fail_on_null() and these are simply
replaced. They were used for checking that creating new wl_proxy by
issuing a protocol request worked, and IIRC that only fails on
out-of-memory, so the same rationale applies here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-20 12:44:12 +03:00
Daniel Stone c55a14206d cairo-util: Clean up more Cairo detritus; almost all of it
Pango, Cairo, and fontconfig, all want to leave thread-global data
hanging around in order to maintain a cache. Try to clean up as much of
it as we possibly can on exit, apart from the Pango language string
which appears to be unfreeable, so has been added to LSan suppressions.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Daniel Stone 6bfbfb2e10 toytoolkit: Delete remnants of EGL support
This code was all dead, since neither cairo-glesv2 nor the sample nested
compositor ever made it to the Meson build.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Marius Vlad cc69dc447e clients/window: Defer closing of window
Instead of closing the window directly by calling close_handler() use a
deferred task to do that instead.

That way we avoid a potential invalid access on a link which was
previously removed, due to the fact both window_destroy() and
touch_handle_up() traverse the same list.

This is an alternative to 841.

Fixes: #607.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reported-by: He Yong <hyyoxhk@163.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-06-22 15:29:05 +03:00
Marius Vlad b3544c26ad clients/window: Add functions to set/retrieve app_id
Adds appid for all clients using the toolkit, flower, fullscreen, image,
resizor, scaler, smoke, stacking, subsurfaces, terminal,
touch-calibrator, transformed, etc.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Derek Foreman f079f43658 clients/window: Fix animated cursors
Since commit 992ee045f1 we create a new surface when we update the cursor
image. This broke animated cursors by discarding any existing frame
callback used for timing, and moving the setup for frame callbacks to
after the commit on the pointer surface.

To fix this we need another surface commit for the frame callbacks, but
this alone is not enough to fix the regression, as a lingering kludge
intended to fix problems when reusing the pointer surface is no longer
working as intended.

Since we no longer re-use the same surface, we can delete the old surface
on pointer exit, along with any callbacks set on it. Then a frame callback
will be recreated naturally. This lets us remove the now broken kludge
from the past and restore animated cursor functionality.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-20 10:23:59 +00:00
Alyssa Ross 7c12182576 clients: don't use deprecated fontconfig aliases
The "sans" and "mono" aliases for "sans-serif" and "monospace" are
deprecated[1].  Let's standardize on the non-deprecated versions, which were
already in use in some places.

[1]: be453bd159/fonts.conf.in (L33-67)

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2021-11-18 10:57:16 +02:00
Emmanuel Gil Peyrot eff793ab46 Fix indentation all through the project
Fixes a “regression” from 04918f3b0b, but
also other missed pieces.
2021-07-31 15:28:20 +00:00
Pekka Paalanen 2af436bb9c clients/window: clean up xkb compose data
This fixes ASan report:
	SUMMARY: AddressSanitizer: 151360 byte(s) leaked in 451 allocation(s).

The leaks can be observed if you let weston-desktop-shell start fully
before shutting down Weston. Many simple test suite tests are too fast
to hit this, or do not even use desktop-shell.

This clean-up code is copied from keyboard_handle_keymap().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Lujin Wang 928d3a0059 clients: Free output->make/model in output_destroy
== 8 bytes in 1 blocks are definitely lost in loss record 4 of 71
==    at 0x48450F8: malloc (vg_replace_malloc.c:309)
==    by 0x500213F: strdup (strdup.c:42)
==    by 0x40A57F: display_handle_geometry (in weston-desktop-shell)
==    by 0x4864D27: ffi_call_SYSV (in libffi.so.6.0.4)
==    by 0x4865697: ffi_call (in libffi.so.6.0.4)
==    by 0x4880E07: wl_closure_invoke (connection.c:935)
==    by 0x487DD73: dispatch_event.isra.5 (wayland-client.c:1310)
==    by 0x487EF87: dispatch_queue (wayland-client.c:1456)
==    by 0x487EF87: wl_display_dispatch_queue_pending (wayland-client.c:1698)
==    by 0x4104E3: handle_display_data (in weston-desktop-shell)
==    by 0x40FE8F: display_run (in weston-desktop-shell)
==    by 0x405AB3: main (in weston-desktop-shell)

Signed-off-by: Lujin Wang <luwang@nvidia.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen c8c53bafd3 clients/window: destroy remaining globals
Destroy the remaining globals on exit. Fixes a bunch of leaks reported
by ASan.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 1e08a81c43 clients/window: move code into global_destroy()
Another patch will want to call global_destroy() too.

Pure refactoring, no functional change.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen 1f3e9045ad clients/window: fix leaks on start-up failure
Trying to run viewporter-test with ASan leak checking,
weston-desktop-shell helper client reports many leaks, because the
compositor quits before the client can start. Hence the
wl_display_roundtrip() fails.

Clean up by calling display_destroy() when wl_display_roundtrip() fails.
It's late enough that all kinds of things may have been allocated, so a
special local tear-down path is not feasible.

To make that work, display_destroy() must handle many things that might
be NULL which normally aren't. Also display_create() needs to initialize
lists early enough so that cleaning them up works.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Simon Ser 992ee045f1 clients/window: atomically update pointer cursor
Currently, Weston clients update the pointer cursor by first issuing
a wl_surface.commit request to update the buffer, then a
wl_pointer.set_cursor request to update the hotspot. This causes an
issue because buffer and hotspot aren't updated atomically: in-between
the two requests, the buffer is new but the hotspot is old.

To fix this issue, create a new surface each time the cursor is
updated.

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-05-30 15:07:04 +00:00
Peter Hutterer a2086bba66 libweston: replace 0 with the enum value for the xkb init flags
No functional changes, this is cosmetics only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-14 11:49:54 +10:00
Pekka Paalanen 8060d826b7 Redefine output rotations
It was discovered in issue #99 that the implementations of the 90 and 270
degree rotations were actually the inverse of what the Wayland specification
spelled out. This patch fixes the libweston implementation to follow the
specification.

As a result, the behaviour of the the weston.ini transform key also changes. To
force all users to re-think their configuration, the transform key values are
also changed. Since Weston and libweston change their behaviour, the handling
of clients' buffer transform changes too.

All the functions had their 90/270 cases simply swapped, probably due to
confusion of whether WL_OUTPUT_TRANSFORM_* refers to rotating the monitor or
the content.

Hint: a key to understanding weston_matrix_rotate_xy(m, c, s) is that the
rotation matrix is formed as

  c -s
  s  c

that is, it's column-major. This fooled me at first.

Fixing window.c fixes weston-terminal and weston-transformed.

In simple-damage, window_get_transformed_ball() is fixed to follow the proper
transform definitions, but the fix to the viewport path in redraw() is purely
mechanical.  The viewport path looks broken to me in the presence of any
transform, but it is not this patch's job to fix it.

Screen-share fix just repeats the general code fix pattern, I did not even try
to understand that bit.

https://gitlab.freedesktop.org/wayland/weston/issues/99

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-02-27 11:08:48 +00:00
Simon Ser 598d3a15b7
clients/window: fail earlier when frame_create fails
This adds a new NULL check to fail earlier when frame_create fails. This can
happen because PNG files couldn't be loaded from the data directory.

Signed-off-by: Simon Ser <contact@emersion.fr>
2020-02-10 15:49:20 +01:00
Guillaume Champagne 1cb09480e2 window: fix missing prototypes warning
Declare touch_handle_shape and touch_handle_orientation as static
functions as they are local to window.c.

Signed-off-by: Guillaume Champagne <champagne.guillaume.c@gmail.com>
2020-01-29 09:49:41 +00:00
Leandro Ribeiro f0cd00a855 clients/window: drop support for rgb565
Remove member preferred_format from struct window and hardcode
ARGB32 pixel format for clients/window.

The member preferred_format was first added to allow hinting
of a preference for RGB565 when creating a window. But it is
not being used for a long time now. So it's safe to remove it
from the code, dropping support for RGB565 in clients/window.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-11 19:28:30 +00:00
Harish Krupo 7bcbab1f2f clients/window: Add viewport destination support
Add support for setting the widget's destination wp viewport.
Setting it in the widget instead of being set directly by the client
ensure that the widget can be identified in widget_find_widget.

v2: Return -1 on error (Pekka)
    Scale allocated x and y when viewport is set (Pekka)
    Allow user to set -1 for viewport width and height (Pekka)

v3: Use NULL instead of 0 (Daniel)
    return 0 if width and height are -1 (Daniel)

Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
2019-11-25 21:54:40 +00:00
Jeffy Chen 9774917049 clients: Add more sanity checks to catch destroyed window
Add a sanity check to touch_handle_down() and data_device_enter() as
what we did for pointer and keyboard.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2019-11-21 16:54:38 +00:00
Jeffy Chen 179458ad23 clients: Drop corresponding touch points when destroying windows
This is to avoid memory leaking of these touch points.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
2019-11-21 16:54:38 +00:00
Sebastian Wick ac1b92dfea clients/window: bump wl_seat version to 7
Since version 7 clients must use MAP_PRIVATE to map the keymap fd.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:05 +01:00
Sebastian Wick 5b64fbd965 clients/window: bump wl_seat version to 6
Hook up listeners for touch shape and touch orientation.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:04 +01:00
- c505af8820 desktop-shell: Click top left and align clock
Pads launchers with the empty space that used to be around them. Moving
pointer to 0,0 and clicking launches the preferred app. First launcher
has more padding at its start to look nice.

Moves the clock to the right edge with same padding. Keeps one of the
two values for text extents that the code was already retrieving but
never read. Horizontal panel position centers the clock.

Sets text in the panel, meaning tooltips and the clock, to consistent 14
units of the default system font at 85% of the max brightness, so it's
less tiring on eyes.
2019-06-26 21:00:43 +00:00
Antonio Borneo 3957863667 log: remove "%m" from format strings by using strerror(errno)
The printf() format specifier "%m" is a glibc extension to print
the string returned by strerror(errno). While supported by other
libraries (e.g. uClibc and musl), it is not widely portable.

In Weston code the format string is often passed to a logging
function that calls other syscalls before the conversion of "%m"
takes place. If one of such syscall modifies the value in errno,
the conversion of "%m" will incorrectly report the error string
corresponding to the new value of errno.

Remove all the occurrences of the specifier "%m" in Weston code
by using directly the string returned by strerror(errno).
While there, fix some minor indentation issue.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-05-02 22:10:30 +02:00
Harish Krupo 43152a3a8f Fix: clients/window: Premature finish request when copy-pasting
As per the wl_data_offer::finish documentation, the request is only
valid for drag n drop operations and signifies that a dnd is completed.
Send finish request only when we have a dnd operation active.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2019-04-19 22:06:44 +05:30
Harish Krupo ee4c7a24dd window.c: Don't assume registry advertisement order
The toytoolkit assumes that wl_seats are advertised after
wl_data_device_manager and creates a data_device during wl_seat
registry binding. This patch removes this assumption by creating
data_devices for all the wl_seats created up until then.

Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/201

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2019-04-19 16:24:26 +00:00
Pekka Paalanen ecbdcfd373 Rename zalloc.h to libweston/zalloc.h
It is a public installed header used by libweston.h.

See "Rename compositor.h to libweston/libweston.h" for rationale.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-04-18 12:31:46 +03:00
ant8me f99fac22ab clients: use xdg_shell stable instead of v6
Now that Weston supports the stable revision, use it. Better to excercise the
current rather than outdated protocol.

Pekka:
- split the patch, rewrote commit message
- rename xdg_shell_ping to xdg_wm_base_ping
- rename xdg_shell_listener to wm_base_listener
- rename shell to wm_base
- fix continued line alignment
- drop unrelated change of adding parentheses around bit-wise and

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-02-15 11:18:38 +00:00