Watch
1
0
Fork
You've already forked smithay
0
Commit graph

4,097 commits

Author SHA1 Message Date
Ian Douglas Scott
7878e6ed11 EI protocol support using reis
The EI protocol is needed for the xdg-desktop-portal `RemoteDesktop`
portal to emulate input devices, as well as by the `InputCapture` portal
for Synergy-like uses (input-leap supports Wayland with this portal).

This exposes a relatively simple API for a compositor to create EI seats
and devices, mirroring the `Seat` API. It also provides an
`InputBackend`
that converts emulated input to Smithay input events.

Receiver contexts for the `InputCapture` portal are also a bit more
complicated to implement. Those involve capturing input once the cursor
crosses outside the display. That isn't implemented at all here yet.

We may want to change things in the future to accommodate receiver
contexts, etc. But this API is fairly minimal to use, so future breaking
changes shouldn't be too challenging for a compositor to adapt to.
2026-06-16 15:03:59 +02:00
Ilia Malanin
66fc28b98e xwm: add X11Surface::is_modal, deprecate is_popup 2026-06-12 16:30:53 +02:00
Ilia Malanin
ba0063fbeb xwm: handle _NET_WM_STATE_MODAL client messages 2026-06-12 16:30:53 +02:00
Ian Douglas Scott
f949fa4865 winit: Update winit to 0.31.0-beta.2 2026-06-11 10:43:32 -07:00
Ian Douglas Scott
5627819c06 winit: Create window in resumed() instead of deprecated API
This will be needed for winit 0.31.

In the future, we may want to change the API to more naturally fit
winit. That will be needed if we want to work on Android, and we could
also make things more flexible, like supporting multiple winit windows.
2026-06-11 10:43:32 -07:00
Ian Douglas Scott
47404d0f60 winit: Split off WinitGraphicsBackend::new_with_gl_attr() 2026-06-11 10:43:32 -07:00
Ian Douglas Scott
f1c29704f1 winit: Make window field of WinitEventLoopInner
This will allow initializing this field later, with window creation in
`resumed`.
2026-06-11 10:43:32 -07:00
Ian Douglas Scott
4cb814df62 anvil: Support touch events in winit backend
Need to handle touch events, and `DeviceAdded`.
2026-06-11 10:43:32 -07:00
Brian J. Tarricone
4645e03d6b drm: store the current frame after committing it
`DrmCompositor::commit_frame()` would pass `None` for the `user_data`
arg to `DrmCompositor::handle_flip()`.  When `handle_flip()` sees no
user-data, it dropped the prepared_frame entirely.  The swapchain would
still hold a reference to the frame, but if `reset_buffers()` is called
after `commit_frame()` but before the page flip actually occurs, the
swapchain would drop anything in all of its slots, and frame would be
fully dropped.

On the legacy DRM path, this would cause `EINVAL` to be returned on page
flip, because dropping the frames would also cause all framebuffers to
be deleted, and the driver would have nothing to flip to.

This modifies `handle_flip()` to no longer take the `user_data`
parameter; instead, callers (there are only two of them) are expected to
store the pending frame in the appropriate place.  `commit_frame()` now
stores the pending frame in `self.current_frame`, which will keep it
alive in the case where all data in the swapchain is dropped.
2026-06-11 10:31:01 +02:00
Christian Meissl
e68923f219 drm/atomic: re-initialize the pending mode blob
after suspend/resume we might end up with
a broken mode blob, rendering the surface
dead.
prevent this by always re-initializing the mode
blob on reset_state, which is typically called
after resume.
2026-06-11 10:19:42 +02:00
Christian Meissl
6441deb270 Revert "drm/surface: Make sure we also reset pending"
This break the state after a VT switch as it initializes
the pending state to the current state, making commit_pending
always return false and also looses the configured mode.

This reverts commit 13f07dd1f1.
2026-06-11 10:19:42 +02:00
Victoria Brekenfeld
d8cbd658db renderer/multigpu: Allow manually creating MultiTextures 2026-06-10 18:35:12 +02:00
Christian Meissl
4407304af1 anvil: update primary scan-out output in nested sessions
update_primary_scanout_output needs to be called before
post_repaint so that frame callback throttling works correctly.
2026-06-10 06:47:56 +02:00
Victoria Brekenfeld
13f07dd1f1 drm/surface: Make sure we also reset pending 2026-06-09 19:17:20 +02:00
Victoria Brekenfeld
cc1a0ec732 chore: clippy fixes 2026-06-09 16:46:22 +02:00
Victoria Brekenfeld
9cf08401b5 renderer: Return SyncPoint from blit operations 2026-06-09 16:46:22 +02:00
Victoria Brekenfeld
fa509c7b39 renderer/gles: Bind Dmabufs as textures instead of renderbuffers 2026-06-09 16:46:22 +02:00
rchennau
85f83ab617 drm: propagate acquire_master_lock failure in activate()
When drmSetMaster() fails in activate(), the error was only logged and
execution continued unconditionally, setting active=true. This causes
every subsequent atomic page flip commit to return EPERM because the
compositor holds no DRM master on the device.

Fix: return Err(Error::DrmMasterFailed) on acquisition failure so the
device stays inactive (active=false). Callers that check the return
value will correctly skip rendering until the next ActivateSession event
grants master via the seat manager.

Also map DrmMasterFailed to SwapBuffersError::TemporaryFailure in the
From<Error> impl, since master loss during a VT switch is transient —
the seat manager will re-grant master on the next VT resume.

Reproducer: hybrid GPU system (Intel render + NVIDIA display), VT switch
while cosmic-comp is running. Without this fix, every frame after VT
resume floods journald with EPERM from DRM_MODE_ATOMIC on the NVIDIA
device.

Fixes: pop-os/cosmic-comp#2331, pop-os/cosmic-comp#2302
2026-05-27 16:44:15 +02:00
Brian J. Tarricone
14ba355590 x11: rename X11Surface geometry() to last_configure()
This also:

* Renames pending_geometry() to pending_configure().
* Renames buffered_geometry() to buffered_configure().
* Renames SharedSurfaceState members to reflect the new names.
* Adds a new bbox() function that returns the size of the last buffer
  committed (falling back to the last configure
* Adds geometry() back, but now it is the bbox minus the frame extents.

In addition, now the SpaceElement ::geometry and ::bbox impls now just
delegate to the new functions on X11Surface.
2026-05-27 16:43:18 +02:00
Brian J. Tarricone
bd7656b1f4 desktop: return correct SpaceElement::geometry for X11Surface
Previously this would try to use SurfaceCachedState::geometry, which is
only set for Wayland windows, and then fall back to the bbox.
2026-05-27 16:43:18 +02:00
Brian J. Tarricone
5201db7cbe xwm: notify frame extents changes through XwmHandler::property_notify 2026-05-27 16:43:18 +02:00
Brian J. Tarricone
72a81567b1 xwm: subtract _GTK_FRAME_EXTENTS from SpaceElement::geometry
On X11, clients can set _GTK_FRAME_EXTENTS to describe non-user-visible
areas at the edges of the surface.  This is usually used for drop
shadows.

This is, in a way, the inverse of xdg_toplevel.set_window_geometry.

This change SpaceElement's ::geometry impl for X11Surface to return the
bounding box minus the frame extents.

Related to #2031
2026-05-27 16:43:18 +02:00
Hojjat
7b8ee4cf40 fix: handle WM_STATE correctly for unmapped and hidden windows 2026-05-27 16:43:05 +02:00
Hojjat
bf188f254a fix: wm_state is only touched in set_mapped and set_hidden 2026-05-27 16:43:05 +02:00
Aiden Park
95a8e45004 fix: duplicated "the" in desktop space/grab/tablet input comments
Signed-off-by: Aiden Park <275402320+vip892766gma@users.noreply.github.com>
2026-05-22 16:51:38 +02:00
Mikael Joignant-Mendiboure
d424d785d2 xwayland: ignore InputOnly windows in XWM 2026-05-22 14:01:54 +02:00
Skygrango
df73da7183 Add remove_constraint method to PointerConstraintsHandler and add PointerConstraintsHandler bound to pointer_constraints::remove_constraint
Call PointerConstraintsHandler::remove_constraint when constraint is removed
2026-05-21 09:14:02 -07:00
Ian Douglas Scott
9d6b3e36bc Don't explicitly use as u32 for error enums
`post_error()` takes `impl Into<u32>`.
2026-05-20 13:23:21 +02:00
Victoria Brekenfeld
774f2ab010 wayland/drm_syncobj: Allow temporarily close the device 2026-05-14 22:27:35 +02:00
Ilia Malanin
c0ac12315c xwm: only clear _NET_ACTIVE_WINDOW when X focus is set to NONE explicitly 2026-05-13 16:29:13 +02:00
Ilia Malanin
d041fe09fb fix(xwm): Defer X11 focus release between same-client transitions
The synchronous `set_input_focus(NONE, NONE)` in `X11Surface::leave`
breaks focus transitions between same-client windows. Defer the
focus-out decision to the next event-loop iteration so it can be
cancelled out.
2026-05-13 16:29:13 +02:00
Brian J. Tarricone
ccb2fec9df anvil: use the new _NET_WM_SYNC_REQUEST plumbing
This demos the usage of X11Surface::send_sync_request() in Anvil,
allowing Anvil to throttle X11 ConfigureNotify events sent to the client
when it is unable to repaint fast enough during resizes.
2026-05-13 12:50:57 +02:00
Brian J. Tarricone
76b4aa9cd1 xwm: add support for _NET_WM_SYNC_REQUEST
This handles the protocol details around _NET_WM_SYNC_REQUEST, and
exposes API so the compositor can coordinate configure events and
frame/decoration resize with app repaints.

Additionally, we set _XWAYLAND_ALLOW_COMMITS to 0 on the X11 window
while a sync request is in flight, which instructs the XWayland server
to not commit to the underlying wl_surface.  This avoids black bars
along the edge of the window when resizing.

See https://specifications.freedesktop.org/wm/1.5/ar01s06.html#id-1.7.3
and https://fishsoup.net/misc/wm-spec-synchronization.html for details.
(Note that this does not implement `_NET_WM_FRAME_DRAWN` or
`_NET_WM_FRAME_TIMINGS`; this only implements the core
`_NET_WM_SYNC_REQUEST`.)
2026-05-13 12:50:57 +02:00
Brian J. Tarricone
02ddea919c xwm: move adding surface pre-commit hook to helper function 2026-05-13 12:50:57 +02:00
Mateusz Mikuła
6248ffafb1 dnd: Send only events supported by client 2026-05-12 19:59:02 +02:00
Brian J. Tarricone
64ac253eae x11: X11Surface bbox/geometry should match committed buffer
X11Surface::bbox() returns the geometry stored internally by
X11Surface, which is based on the last committed configure attempted by
the compositor (via configure()).  The problem here is that the client
is free to reject that size (size increments, min size, max size, etc.).

In these cases, we can mis-render the window (placement or size) if the
last configured rect is not the same as the actual committed buffer.

Instead, use the surface/buffer size, and only fall back to X11Surface's
geometry if that's not available.
2026-05-12 17:12:40 +02:00
Ian Douglas Scott
060e9cd9c8 xwm: Set WM_STATE to match _NET_WM_STATE_HIDDEN, instead of mapped 2026-05-07 19:48:57 +02:00
skygrango
732d06bb8f wayland: don't scale non-accelerated pointer values 2026-05-07 12:49:47 +02:00
Brian J. Tarricone
13c71bafc0 Add Window::send_ping()
This is a convenience wrapper on top of ShellClient::send_ping() and
X11Surface::send_ping() that semi-unifies the ping protocols of both
surface types.

Callers still need to implement the surface-type-specific pong/ack
handler to receive replies.
2026-05-05 14:38:16 +02:00
Brian J. Tarricone
10b191634f xwm: implement support for _NET_WM_PING
This adds `X11Surface::ping()`, which, if supported by the client, sends
a `_NET_WM_PING` message to the window.  When the client responds,
`XwmHandler::ping_acked()` is called.
2026-05-05 14:38:16 +02:00
Hichem, Ben Fekih
e5e9f7670a window: add function to return the window id
to make it easier to identify windows.

Example use case:
in a custom compositor to be able to implement a custom IPC to
list and controls current windows

Signed-off-by: Hichem, Ben Fekih <hichem.f@live.de>
2026-05-04 15:45:02 +02:00
Brian J. Tarricone
901b11afc6 xwm: lazily update opaque regions when the property changes
During resize, a client with _NET_WM_OPAQUE_REGION set will send a flood
of changes to this property as the window changes size and the opaque
regions move and change size.  Profiling shows that processing all of
these updates can take 10-15ms, causing missed vblanks.

Not only does it take a while to process the flood of updates, fetching
the updated property value from the XWayland server can be very slow
during this period (I've observed a median of 3ms and P90 of 12ms, with
a P99 of 27ms!).  My theory is that x11rb's socket processing
architecture appears to be working against us here: in this flood of
updates during a resize, a lot of other things are also going on:
configure requests, configure notify events, etc.  This causes x11rb's
incoming event processing to back up, and with the property fetch reply
far down the queue of events to process, it takes a while for it to get
there.

Instead, when receiving a PropertyNotify event for
_NET_WM_OPAQUE_REGION, simply None-out the stored value and mark it as
dirty.  In the pre-commit hook, if the value is dirty, re-fetch the
property.  This avoids several tens of slow property fetches per frame,
coalescing it down to one per frame at most.

I've also taken pains to avoid holding the mutex on SharedSurfaceState
across the XWayland server round-trip; since that call can take several
milliseconds when there's a flood of events, a multi-threaded compositor
might experience lock contention if it's trying to do anything else with
the X11Surface.

This doesn't fully fix the problem: the property fetch in the pre-commit
handler can still be slow to the tune of several milliseconds (and
sometimes worse) during resize.  But this change does eliminate most of
the missed vblanks and skipped frames.  (If x11rb were to expose
poll_for_reply(), we could do this in a non-blocking manner, and
completely eliminate this issue, but it's a private function.)

In normal non-resize situations, the opaque region will change only
rarely (if ever), and even when it does, it should presumably be at a
time when there isn't a flood of traffic with the XWayland server, so
the lazy re-fetch in the pre-commit handler should complete in
microseconds.
2026-05-04 14:53:43 +02:00
Brian J. Tarricone
311639ecd8 xwm: support _NET_WM_OPAQUE_REGION
X11 clients can set this property on their window to indicate a single
fully-opaque region for the window.
2026-04-30 17:27:29 +02:00
Ian Douglas Scott
0d14cd655f Add Dispatch2 and GlobalDispatch2, replacing delegate macros
A single `delegate_dispatch2!` replaces all other delegate macros.

When wayland-rs updates the definition of `Dispatch`, this macro will be
unnecessary, and `Dispatch` type bounds should become inferable by the
type system.

`Dispatch` is now implemented for the user-data type, so `smithay` is
able to provide blanket implementations as long as the user data is a
type owned by `smithay`. Therefore, `GlobalData` replaces `()` as a user
data (`smithay-client-toolkit` already did this), and udata that is
simply a type like `Weak<WlSurface>` is wrapped.
2026-04-30 16:13:15 +02:00
Ian Douglas Scott
2b285e2d2d wayland/toplevel-icon: Add doc example
This makes the documentation more consistent with other protocols, and
means there's a test for the protocol that doesn't otherwise exists
since `anvil` doesn't use it.
2026-04-30 16:13:15 +02:00
Brian J. Tarricone
f0992e76cc xwm: flush X11 connection when setting _NET_SHOWING_DESKTOP 2026-04-28 15:01:29 +02:00
Brian J. Tarricone
db24edc9b6 xwm: support _NET_SHOWING_DESKTOP
This adds a setter and getter for the root window property, and also
adds XwmHandler trait items for the root window client message to enable
or disable the mode.
2026-04-28 12:43:18 +02:00
Brian J. Tarricone
253c154556 xwm: clean up by_serial hash map when surface is destroyed
In a compositor that restarts XWayland on a crash, the new XWayland
instance will start off with a fresh serial counter.  As new X11 windows
are created, they can have the same serial as a window created on the
previous XWayland instance.  Without this cleanup, the lookup in
surface_for_serial() will return a stale/dead wl_surface, and the
xwayland machinery will be unable to properly associate new windows with
a surface.
2026-04-28 12:42:38 +02:00
Brian J. Tarricone
5de53056b5 xwm: use the same depth/visual/colormap for the frame window
The XWayland root window uses a 24bpp visual, so when we copy the depth
and visual from the parent for the frame window, we end up with a 24bpp
frame window.  When XWayland creates the wl_buffer for a client, it ends
up using the frame window as a template for the buffer format, which
will never have an alpha channel.  So if the client wants to do partial
transparency, such as for CSD drop shadows, they'll end up drawing as
opaque rectangles around the window.

Instead, match the client window's visual and colormap when creating the
frame window.  This also caches the colormap that goes along with the
selected visual so we avoid creating a new one with each window (and
then need to free it later).  In practice, clients will likely use one
of a small number of possible visuals, so it'll mostly be cache hits,
and the cache will only have a few entries.
2026-04-27 13:01:23 +02:00
Nikola Hristov
211c19d712 fix(xwm): Pass inputs to xwayland even if input model is None
Resolves #2003
2026-04-24 13:13:49 -07:00