Commit graph

3355 commits

Author SHA1 Message Date
Ian Douglas Scott
3bb3e08812 Fix warnings from new nightly unexpected_cfgs lint 2024-05-08 13:14:44 +02:00
may
64356be949 add message 2024-05-06 13:49:49 +02:00
may
8f7435df2c add #[must_use] to AxisFrame 2024-05-06 13:49:49 +02:00
Leon Vack
45482a0f69 Avoid unwraping clients from surfaces
Even when handling request for a surface, `surface.client()` may return
`None`. This occurs, for example, if a protocol error is signaled; the surface
remains alive for some time, but `client()` returns `None` immediately after
`post_error` was called.
2024-05-04 10:47:08 +02:00
Bartłomiej Maryńczak
c083833448
wayland.shm: Zero-Initialize private fields of libc::sigaction (#1413)
wayland.shm Zero-Initialize private fields of `libc::sigaction`
2024-05-03 13:17:55 +02:00
PolyMeilex
da69238c09 Clippy fixes 2024-05-03 13:08:17 +02:00
Ivan Molodetskikh
219b783609 Add an y_inverted getter to GlesTexture
May turn out useful too.
2024-05-02 12:20:37 +02:00
Ivan Molodetskikh
5179b41139 Add getters for some WaylandSurfaceRenderElement properties
Useful for custom wrapper render elements.
2024-05-02 12:20:37 +02:00
Ivan Molodetskikh
2cc3162c21 Correct debug tint color
Not sure if this was intentional, but this color is supposed to be
premultiplied, so the color components cannot be above the alpha.
2024-05-02 10:18:21 +02:00
Ian Douglas Scott
95d6e79ed8 wlr_layer: Fix memory leak due to reference cycle
`WlrLayerSurfaceUserData` contains a `WlSurface`.
`LayerSurfaceAttributes`, which is stored in the surfaces `data_map`,
contains a `ZwlrLayerSurfaceV1`. This, somewhat subtly, is a reference
cycle that causes a leak. So one of these references needs to be weak.

I noticed this issue with Valgrind, but this can also be reproduced by
adding  drop impl to `LayerSurfaceAttributes` that panics. Before this
change, running `simple_layer` in anvil and exiting it never drops the
`LayerSurfaceAttributes`. With the change, the panic happens when a
layer surface is closed.
2024-04-29 23:56:14 +02:00
Ottatop
7544c4d4b9 utils: fix Point::constrain clamping at wrong values 2024-04-29 12:12:01 +02:00
Ivan Molodetskikh
0066f74b83 virtual_keyboard: Remove unused instance tracking
Remnants of this commit:
5a0b08c804

It removed the code that decremented or even just accessed the counter,
leaving it to overflow, which causes panics with overflow checks.
2024-04-29 12:08:05 +02:00
Ivan Molodetskikh
ae08c93551 Add getters for SolidColorBuffer/Element color 2024-04-29 08:50:13 +02:00
nferhat
f3e442c288 chore: cargo fmt 2024-04-25 22:01:46 +02:00
nferhat
cf2b3076b5 backend/x11: Include window_id inside X11Event::Focus 2024-04-25 22:01:46 +02:00
nferhat
a707afde4d anvil: Fix X11 backend
Just change the match statement from a tuple enum to a struct enum
2024-04-25 22:01:46 +02:00
nferhat
5346f7a354 backend/x11: Include window_id with X11Event::Input when possible.
This property is not always passed with events (well actually only with
DeviceAdded and DeviceRemoved), so it's an option.

Actual handling of this property should be done downstream, for exmaple
to create multiple outputs represented by different X11 windows.
2024-04-25 22:01:46 +02:00
Colin Marc
8773a74210 Run Xwayland using -displayfd and a pipe
This method, while undocumented, is a lot more robust than an intermediate
shell. It works by passing a pipe to the Xwayland cmdline invocation. When
Xwayland is ready, it writes the display number and a newline to the pipe.

While we're at it, we can remove the hard dependency on Calloop, so that the
Xwayland instance can be used with other event loops.
2024-04-25 22:01:16 +02:00
Ian Douglas Scott
0f2437e586 Send wl_data_source::cancelled on wl_data_offer::destroy
This seems to match the behavior of sway, and fixes
https://github.com/pop-os/cosmic-comp/issues/437.

If `!data.dropped`, `cancelled` has already been sent. If `data.finished`,
`dnd_finished` has been sent. Otherwise, sending `cancelled` here seems
correct.
2024-04-25 10:23:06 +02:00
Kirill Chibisov
40acc58b83 Notify when InputMethod::PopupSurface changes location
Each call to `set_text_input_rectangle` changes the position of the
popup and also will result in popup repositioning, thus notify
users when such request occurs.

The location and text cursor area where separated, since one is used
for the rendering, and the other one is original location.
2024-04-22 10:50:48 +02:00
Ian Douglas Scott
839483a6d4 ci: Exclude use_bindgen from cargo hack check
This can fail trying to use system DRM headers that don't have the
latest features.
2024-04-22 10:47:42 +02:00
Ian Douglas Scott
2848e7f9f9 Update drm, gbm, image; xkbcommon/x11rb deps of Anvil
There's also a new `ash` release, but that seems to require some changes
to use. So I left that for now.
2024-04-22 10:47:42 +02:00
Christian Meissl
7095482153 udev: sort all_gpus by path
this increases the chance that in case we fallback to select the first gpu
in primary_gpu we actually select the first available gpu.
2024-04-22 10:21:23 +02:00
Christian Meissl
c9820407ef anvil: make sure the current fullscreen surface is alive 2024-04-21 11:07:37 +02:00
Victoria Brekenfeld
c293ec730f elements/surface: Snapshot render state 2024-04-19 14:11:43 +02:00
Ian Douglas Scott
49ba4253f1 Call *Grab::unset when grab is removed due to surface not being alive
It seems I missed one place where a grab could be removed.

This fixes an issue on cosmic-comp where a surface being destroyed
during a DnD drag from that surface would result in the DnD surface
still displaying. (For instance, closing cosmic-workspaces with a
keybinding while dragging).

(I guess the `&mut D` argument to `with_grab` is needed after all... I'll
probably not create another dozen PRs adding and removing it again. It's
an internal API anyway.)
2024-04-18 12:48:49 +02:00
Ian Douglas Scott
db380f5351 Allow set_cursor when there is a pointer grab for client
This also updates `cursor_shape` call the same logic.

This fixes calls to `set_cursor` during drag-and-drop. Nautilus is a
good client to test this with, though most drag-and-drop clients should
work.

The Wayland spec doesn't seem that specific about how `set_cursor`,
pointer focus, and drag-and-drop interact. But this seems to mostly
match Sway: the surface loses pointer focus at the start of
drag-and-drop, but can still set the cursor.

I'm not sure if this is likely to be desirable or undesirable when there
is a grab other than a drag-and-drop grab. It could be restricted to
drag-and-drop, but there is not currently any way in Smithay to check
what the drag is, or if there is a drag-and-drop operation. But it
should be possible to downcast the `dyn PointerGrab<D>`, I guess.
2024-04-17 11:43:32 +02:00
Ian Douglas Scott
eea0d9c171 Call *grab::unset in *set_grab, before restoring focus
This fixes an issue I noticed where cancelled drag-and-drop in clients
like Firefox and Nautilus caused a window to ignore pointer events until
losing and regaining focus. It seems calling the `.ungrab` method at the
end of `with_grab` means calling it after pointer focus is restored, and
clients seem not to handle the `wl_pointer.enter` before the drag is
actually over.

Deferring the focus restoration as well is slightly complicated to
implement, and seems problematic when it involves a serial. Maybe there
shouldn't be any input events after the `*set_grab` call but before
returning, but this seems cleaner.

Taking a reference to the handler in `*InterHandle.*set_grab` is a bit
annoying, but easy enough to deal with, and allows this to work more
cleanly. This seems reasonable as long as we don't have a better
solution to the whole `GrabStatus::Borrowed` thing.
2024-04-16 12:00:38 +02:00
Ian Douglas Scott
7cc8d1bb3c Call KeyboardGrab::unset in KeyboardHandle::*_grab
This was already supposed to happen, but I hadn't noticed that these
functions don't delegate to a method of the innter handle, like they do
with touch.

This is a breaking API change, since these functions then need to take
`&mut D`. But this seems reasonable since the equivalents for
pointer/touch already require that, and `&mut D` should be available to
call wherever these are used.
2024-04-16 12:00:38 +02:00
Ian Douglas Scott
2e672566e3 Make GrabStatus more generic instead of defining it three types
It's easy enough to change the type generic to use this in all three
places, so we might as well.
2024-04-16 12:00:38 +02:00
Ian Douglas Scott
033df94071 Add unset method to input grab traits
`unset` is called when a grab is removed with `unset_grab` or replaced
with `set_grab`.

This fixes https://github.com/pop-os/cosmic-comp/issues/403. There are a
couple other grabs in Smithay and cosmic-comp that they run before
unsetting the grab, that may cause issues if the grab is removed without
running it. So this seems useful in general.
2024-04-12 20:42:07 +02:00
Ivan Molodetskikh
c5e9a697e4 renderer: Expose {compile,link}_program()
These seem generic enough and not depending on any internal details.
2024-04-12 14:58:19 +02:00
Ivan Molodetskikh
4f0957e31b renderer: Expose capabilities and debug_flags from GlesFrame 2024-04-12 14:58:19 +02:00
Ivan Molodetskikh
903b39e8e5 renderer: Expose UniformDesc and UniformValue::set() 2024-04-12 14:58:19 +02:00
Ivan Molodetskikh
e237b077bd Expose scale and transform from RendererSurfaceState
Lets one implement custom rendering logic.
2024-04-09 17:03:51 +02:00
Christian Meissl
ba0121aaed gles: optimize bind for the happy path 2024-04-07 11:55:19 +02:00
Christian Meissl
9618318db9 output: reduce weak client upgrades 2024-04-07 11:55:19 +02:00
Christian Meissl
191a72a791 perf: leave some notes about potential improvements 2024-04-07 11:55:19 +02:00
Christian Meissl
1ef9461e37 output: small perf optimizations 2024-04-07 11:55:19 +02:00
Christian Meissl
624db0b0f5 renderer: introduce DamageSet 2024-04-07 11:55:19 +02:00
Christian Meissl
34259ef14a drm: reduce allocations in drm compositor 2024-04-07 11:55:19 +02:00
Christian Meissl
dbaca428fa renderer: reduce allocations in damage tracking 2024-04-07 11:55:19 +02:00
Christian Meissl
89ea793438 renderer: remove allocations from gles renderer 2024-04-07 11:55:19 +02:00
Christian Meissl
44dd9baa33 anvil: get rid of the cursor image mutex 2024-04-07 09:31:08 +02:00
Christian Meissl
c9f5c792c0 wayland: introduce TabletSeatHandler
this moves the tablet tool image callback to
a separate handler trait
2024-04-07 09:31:08 +02:00
Ottatop
fe046332c2 Fix outgoing xwm incremental selection
Removes the seemingly not-supposed-to-be-there clearing of the internal buffer and waits for the final 0-byte data chunk to be sent
2024-04-07 00:09:24 +02:00
Victoria Brekenfeld
54208d54f6 egl: Propagate sync interrupt where possible 2024-04-06 17:25:26 +02:00
Victoria Brekenfeld
ba9ffed263 egl: Handle errornous wait 2024-04-06 17:25:26 +02:00
Victoria Brekenfeld
47a8d5b5e5 anvil: Drop CalloopData 2024-04-02 19:49:40 +02:00
Ivan Molodetskikh
bfa56fc54b {an,small}vil: Fix winit scroll values
The usual value for one wheel tick is 15, not 3. This can be verified
with Firefox by scrolling on a TTY backend vs. on the winit backend
(since this particular fallback is used on the winit backend).
2024-04-02 17:58:38 +02:00