Commit Graph

106 Commits

Author SHA1 Message Date
Kirill Primak
c752270be7 tinywl: drop focused surface check for interactive ops
This serves as a bad example: compositors should validate serials from
events instead. Also, the current implementation segfaults if
focused_surface is NULL.
2024-09-20 10:48:32 +00:00
Kirill Primak
5c98d1a04a xdg-surface: fix window geometry handling
It was completely wrong: according to the protocol, the effective
geometry is only updated on commit time if there pending state has
new state from xdg_surface.set_window_geometry or
xdg_surface.set_window_geometry has never been sent at all.

This commit adds wlr_xdg_surface.geometry which correctly matches the
effective window geometry and removes now-useless
wlr_xdg_surface_get_geometry().
2024-08-14 18:52:13 +00:00
BiRD
42673a2821 tinywl: Update .gitignore 2024-07-29 11:39:34 -04:00
BiRD
f16a3c1180 tinywl: Edit Makefile for bmake compatibility
- Replace 'shell' calls with '!=' assignments
- Add default target 'all'
- Don't use var '$<' for non-sources
2024-07-29 11:39:34 -04:00
Simon Ser
b10516e1e8 build: bump version to 0.19.0-dev 2024-07-12 23:48:02 +02:00
Leonardo Hernández Hernández
09603cdb0b tinywl: allow specify pkg-config binary 2024-06-22 15:59:12 +00:00
Leonardo Hernández Hernández
d92c238721 tinywl: split compilation into two steps
While we are at it also respect LDFLAGS and optimize pkg-config usage
2024-06-22 15:59:12 +00:00
Leonardo Hernández Hernández
f9214373f8 tinywl: don't try to remove xdg-shell-protocol.c
It is not generated since 62fbf3f4ba
2024-06-22 15:59:12 +00:00
Violet Purcell
c76a232835 tinywl: update for versioned pkg-config file 2024-05-27 22:15:00 +00:00
He Yong
ac1232e576 tinywl: destroy wlr_renderer, wlr_allocator and wlr_cursor
Suggested-by: Alexander Bakker <ab@alexbakker.me>
Suggested-by: Simon Ser <contact@emersion.fr>
2024-03-14 10:07:56 +00:00
Simon Ser
7915a2ff59 tinywl: fix wlr_seat use-after-free on exit
When pressing the keybinding to shut down the compositor, the following
use-after-free is triggered:

    ==1165966==ERROR: AddressSanitizer: heap-use-after-free on address 0x51800000ade0 at pc 0x7fa6728b4531 bp 0x7ffe540a6aa0 sp 0x7ffe540a6a90
    READ of size 8 at 0x51800000ade0 thread T0
        #0 0x7fa6728b4530 in wlr_seat_set_keyboard ../types/seat/wlr_seat_keyboard.c:124
        #1 0x58a83fa7fd4e in keyboard_handle_key ../tinywl/tinywl.c:228
        #2 0x7fa673a1901d in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0xa01d) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
        #3 0x7fa67295b4be in wlr_keyboard_notify_key ../types/wlr_keyboard.c:102
        #4 0x7fa67295c791 in wlr_keyboard_finish ../types/wlr_keyboard.c:165
        #5 0x7fa672848cb1 in destroy_wl_seat ../backend/wayland/seat.c:293
        #6 0x7fa672833dca in backend_destroy ../backend/wayland/backend.c:493
        #7 0x7fa6727b49e8 in wlr_backend_destroy ../backend/backend.c:67
        #8 0x7fa67282d334 in multi_backend_destroy ../backend/multi/backend.c:59
        #9 0x7fa67282da5a in handle_event_loop_destroy ../backend/multi/backend.c:110
        #10 0x7fa673a18b98 in wl_event_loop_destroy (/usr/lib/libwayland-server.so.0+0x9b98) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
        #11 0x7fa673a1b43c in wl_display_destroy (/usr/lib/libwayland-server.so.0+0xc43c) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
        #12 0x58a83fa8ada1 in main ../tinywl/tinywl.c:1068
        #13 0x7fa672043ccf  (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #14 0x7fa672043d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #15 0x58a83fa7e7c4 in _start (/home/simon/src/wlroots/build/tinywl/tinywl+0x167c4) (BuildId: 1febf2a5a18bda0f6b67377a132484061875e248)

    0x51800000ade0 is located 352 bytes inside of 880-byte region [0x51800000ac80,0x51800000aff0)
    freed by thread T0 here:
        #0 0x7fa6732dfdb2 in __interceptor_free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:52
        #1 0x7fa6728c6a1e in wlr_seat_destroy ../types/seat/wlr_seat.c:245
        #2 0x7fa6728c6a7a in handle_display_destroy ../types/seat/wlr_seat.c:251
        #3 0x7fa673a1b3c6 in wl_display_destroy (/usr/lib/libwayland-server.so.0+0xc3c6) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)

    previously allocated by thread T0 here:
        #0 0x7fa6732e0cc1 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
        #1 0x7fa6728c6a9d in wlr_seat_create ../types/seat/wlr_seat.c:255
        #2 0x58a83fa8a8d3 in main ../tinywl/tinywl.c:1024
        #3 0x7fa672043ccf  (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)

This happens because the wlr_seat is destroyed before the
wlr_keyboard. Destroying the wlr_keyboard has the side effect of
implicitly releasing keys currently held down.

Explicitly destroying the wlr_backend before the wl_display fixes
this.

Suggested-by: Isaac Freund <ifreund@ifreund.xyz>
2024-03-04 12:50:14 +00:00
Simon Ser
812451cd8f pointer: use enum wl_pointer_button_state 2024-02-28 16:39:18 +00:00
Simon Ser
842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Kirill Primak
811ca199c4 xdg-shell: drop automatic surface configuration
Compositors now are expected to wait for an initial commit by checking
wlr_xdg_surface.initial_commit on every surface commit and send
(schedule) configure events manually.
2024-02-06 13:48:00 +00:00
Simon Ser
d1b39b5843 backend: take wl_event_loop instead of wl_display in wlr_backend_autocreate() 2024-01-25 15:05:36 +00:00
Simon Ser
00bb1b0f84 seat/pointer: add support for axis_relative_direction event 2024-01-23 08:37:29 +00:00
Kirill Primak
ce89f49b7a tinywl: depend on the server xdg-shell header 2024-01-09 21:39:02 +03:00
Kirill Primak
425f5c07fb tinywl: check initialized instead of initial_commit
oops
2023-12-07 17:59:07 +03:00
Kirill Primak
1cc7ab3e29 tinywl: don't send configures to uninitialized xdg_surfaces 2023-12-07 12:43:39 +03:00
Kirill Primak
c85838892d xdg-{shell,decoration}: improve events
This commit changes the behavior of `new_*` signals to better match
their names (see https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3608).
wlr_xdg_shell.events.new_surface is now emitted when an xdg_surface is
created, and wlr_xdg_shell.events.new_{toplevel,popup} events are
introduced to get notified when an xdg_{toplevel,popup} is created.
Same applies to
`wlr_xdg_decoration_manager_v1.events.new_toplevel_decoration`. As a
result, wlr_xdg_surface.added and wlr_xdg_toplevel_decoration_v1.added
are removed, as we no longer need to track whether the corresponding
event was emitted.

Additionally, this commit changes the behavior of
wlr_xdg_surface.events.destroy: it is now emitted when the xdg_surface
is destroyed, as the name suggests.
wlr_xdg_{toplevel,popup}.events.destroy events are added to get
notified when an xdg_{toplevel,popup} is destroyed.
2023-11-23 12:52:20 +00:00
Simon Ser
6a7463bb8e output-layout: take wl_display in constructor
The output layout creates and destroys wl_output globals. We will
soon need the wl_display to do so.
2023-11-23 11:39:25 +00:00
Simon Ser
3b4d7d2a92 build: bump version to 0.18.0-dev 2023-11-21 17:28:06 +01:00
Simon Ser
fe53ec6937 tinywl: fix wlroots dependency constraint in Makefile 2023-11-21 17:22:02 +01:00
Kirill Primak
6cf0bb4b19 tinywl: don't use "I"/"my" in docs 2023-11-14 19:46:04 +03:00
Kirill Primak
73a387d3b6 tinywl: fix xdg_toplevel_destroy() docs 2023-11-14 19:40:26 +03:00
Simon Ser
73ab5246ea tinywl: stop using the word "view" to refer to toplevels
"View" has been cargo-culted from Weston. In Weston, a view is not
even necessarily a toplevel -- it's just a way to draw an arbitrary
somewhere (a surface may be painted at multiple locations
simultaneously). The Weston concept has been misunderstood and then
was carried over to rootston, Sway, and tinywl.

Let's just use the official Wayland wording instead.
2023-11-14 17:31:35 +01:00
Simon Ser
9e5d0f95f8 tinywl: fix crash when previously focused surface is not a toplevel
It can be e.g. a popup.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3754
2023-11-13 10:32:03 +01:00
Alexander Orzechowski
1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Simon Ser
2926acf60d tinywl: set minimum wlroots version in Makefile 2023-09-01 00:28:55 +09:00
Rose Hudson
f5917f0247 scene_output_layout: make output adding explicit
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3709
2023-08-22 11:53:28 +02:00
Kirill Primak
10ba8ebc70 Don't assume xdg_surface.{toplevel,popup} is non-NULL
This assumption will become incorrect with future commits.
2023-08-21 16:30:29 +00:00
Rose Hudson
214df8eda0 scene_output: optionally record and report timings 2023-07-10 09:57:02 +00:00
Simon Ser
9e6431dc3b tinywl: enable new outputs 2023-06-27 16:26:30 +00:00
Simon Ser
be05097968 output: add wlr_output_state_init()
This changes the semantics of wlr_output_state. Instead of having
fields with uninitialized memory when missing from the committed
bitflag, all fields are always initialized (and maybe NULL/empty),
just like we do in wlr_surface_state. This reduces the chances of
footguns when reading a field, and removes the need to check for
the committed bitfield everywhere.

A new wlr_output_state_init() function takes care of initializing
the Pixman region.
2023-06-23 18:07:26 +00:00
Simon Ser
da04b066ea cursor: add wlr_cursor_set_xcursor()
This keeps track of the last set XCursor. If it hasn't changed,
skip the texture upload.

In the future, support for animated XCursors can be added.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3436
2023-06-15 18:28:43 +02:00
Alexander Orzechowski
73ca1ea48a tinywl: Drop usage of wlr_output.pending 2023-06-13 09:19:51 +00:00
Kirill Primak
b0437fc416 xdg-shell: use unified map logic 2023-06-02 17:26:18 +00:00
Alexander Orzechowski
d5320e5f20 tinywl: Release everything before destroy
This makes -Db_sanatize=address happy.
2023-05-02 10:48:31 -04:00
Simon Ser
0bb574239d compositor: pass version in wlr_compositor_create
This allows wlroots to support newer versions of the interface
without breaking the API.
2023-04-14 17:07:26 +02:00
Kirill Primak
3a200aa279 tinywl: init server to zeros
This fixes e.g. accessing grabbed_view on a toplevel unmap if no
toplevel was grabbed before.
2023-03-04 17:01:11 +03:00
Alexander Orzechowski
7b32c25a4f wlr_scene: Rename wlr_scene_surface_from_buffer
This renames it to wlr_scene_surface_try_from_buffer to be more clear
that this function can return NULL. This is inline with the rest of
wlroots[1].

[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
2023-02-04 02:57:42 -05:00
Simon Ser
711a1a3ed4 xdg-shell: convert to try_from
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/884
2023-02-01 20:12:49 +01:00
Simon Ser
3668c9d86c examples, tinywl: use "default" cursor instead of "left_ptr"
"left_ptr" is the X11 name, "default" is the cursor spec name.
2023-02-01 15:00:42 +01:00
Simon Ser
90d7bce994 tinywl: fix extra whitespace 2023-01-24 00:14:22 +01:00
Alexander Orzechowski
e0b2bf2a6b tinywl: Nuke view->{x, y}
Instead use the scene node position.
2023-01-04 01:47:49 -05:00
Kirill Primak
825f1b2dc6 tinywl: handle wlr_output.events.request_state 2022-12-06 09:05:32 +00:00
Simon Ser
41b7acbab7 backend: return wlr_session in wlr_backend_autocreate() call
Up until now, wlr_backend_autocreate() created the wlr_session and
then stuffed it into struct wlr_multi_backend so that compositors
can grab it later.

This is an abuse of wlr_multi_backend and the wlr_backend API:
wlr_backend_get_session() and wlr_multi_backend.session only exist
to accomodate the needs of wlr_backend_autocreate(). What's more,
the DRM and libinput backends don't implement
wlr_backend_impl.get_session.

Instead, return the struct wlr_session to the compositor in the
wlr_backend_autocreate() call. wlr_backend_get_session() will be
removed in the next commit.
2022-11-15 21:16:25 +00:00
Kirill Primak
b7623694ac tinywl: handle view unmap while grabbed
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3372
2022-11-07 20:09:25 +03:00
Simon Zeni
517ea218c6 tinywl: exit on backend, renderer or allocator creation failure 2022-06-28 13:43:36 +00:00
Isaac Freund
91943a68a6 wlr_input_device: remove anon union field
This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
2022-06-21 18:42:07 +00:00