- Remove the `Device`, `Surface`, `RawDevice` and `RawSurface` traits.
We are not trying to merge the different responsibilities between...
- Drm-Surfaces: crtcs and planes for displaying buffers
- Gbm-Surfaces: allocating and managing front- and back-buffers
- EGL-Surfaces: Load drawing apis.
..anymore.
- Instead unify the legacy and atomic backends into one `DrmDevice` and
a `DrmSurface`, that under the hood dispatches onto the different modules.
- Do not keep a list of surfaces inside the devices. These are reference-counting
nightmares and a frequent issue due to the read-only nature of `Rc` and `Arc` and
thread-safety related problems.
- Surfaces are mostly doing state-tracking independently of each other
and contain some more helper functions.
- Simplify session code, because we do not need to pass the events
through three layers of devices and surfaces anymore.
- Each surface now represents a plane. Rendering to a plane is just like
any other rendering step, including the Cursor-plane.
(Legacy interfaces only have one to avoid dealing with short-comings of the api).
- Add module that deals with different kinds of buffers (memory and external),
their allocation and usage for rendering. Also try to properly support modifiers this time.
- Describe gbm functionality as an allocator (instead of a rendering device/surface).
- Also create a quick-and-dirty dumb buffer allocator for tesing / simpler tasks.
- Add a (current untested) wrapper for dmabufs and some code for converting from gbm for now.
- (also untested) Swapchain helper to manage front/backbuffers for surfaceless rendering.
It is not necessary to set the cursor position on winit since the
windowing system already updates the position on its own. Instead, doing
this makes the cursor (almost) stuck and unmovable. Thus, this commit
just removes that code from the winit backend.
Fixes: https://github.com/Smithay/smithay/issues/241
Signed-off-by: Uli Schlachter <psychon@znc.in>
* xwayland: Add LaunchHelper
Calling fork() in a multi-threaded process is a bad idea. I am getting
crashes at exit() and "man fork" says that only async-signal-safe
functions can be called after forking in a multi-threaded process.
exit() is not async-signal safe. Thus, forking needs to happen before
any threads are created.
This commit adds a LaunchHelper to the public API. This is a handle to a
forked child process. So far this does not do much, but the intention is
to use this later instead of fork()ing directly.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* xwayland: Move the fork dance to LaunchHelper
No functional changes intended. This only moves the code over and does
not actually use the LaunchHelper for anything.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* Move checking the launch status to LaunchHelper
This should again have no functional changes, but the error log output
might change slightly, since an IOError instead of a NixError is
returned.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* xwayland: Set $DISPLAY earlier
This way, the WM already gets the correct value of $DISPLAY.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* xwayland: Use the launch helper process
FD passing is now used to give the display number and the sockets to the
launch helper process. That process then forks of the actual process
that spawns Xwayland. Once Xwayland started, this is reported back with
another write on the pipe.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* Add to the comment explaining Xwayland startup
Signed-off-by: Uli Schlachter <psychon@znc.in>
* Please rustfmt
Signed-off-by: Uli Schlachter <psychon@znc.in>
* Make clippy happy
Signed-off-by: Uli Schlachter <psychon@znc.in>
This fixes the following clippy warnings:
error: usage of `Rc<T>` when T is a buffer type
--> src/wayland/dmabuf/mod.rs:265:14
|
265 | formats: Rc<Vec<Format>>,
| ^^^^^^^^^^^^^^^ help: try: `Rc<[Format]>`
|
= note: `-D clippy::rc-buffer` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer
error: usage of `Rc<T>` when T is a buffer type
--> src/wayland/shm/mod.rs:91:14
|
91 | formats: Rc<Vec<wl_shm::Format>>,
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc<[wl_shm::Format]>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer
Signed-off-by: Uli Schlachter <psychon@znc.in>
When starting xwayland with smithay, the first time I would get the
following output (do not ask what happens with displays 0, 1, 2. That's
not important right now):
Dec 29 14:13:31.031 DEBG Attempting to aquire an X11 display lock, D: 3, smithay_module: XWayland
Dec 29 14:13:31.032 DEBG X11 lock aquired, D: 3, smithay_module: XWayland
Dec 29 14:13:31.032 INFO Initialization completed, starting the main loop.
When killing the process with ctrl-c and starting it again, this
happened:
Dec 29 14:13:29.138 DEBG Attempting to aquire an X11 display lock, D: 3, smithay_module: XWayland
Dec 29 14:13:29.138 DEBG Failed to acquire lock, D: 3, smithay_module: XWayland
Dec 29 14:13:29.138 DEBG Lock was blocked by a defunct X11 server, trying again, D: 3, smithay_module: XWayland
Dec 29 14:13:29.139 DEBG Attempting to aquire an X11 display lock, D: 3, smithay_module: XWayland
Dec 29 14:13:29.139 DEBG X11 lock aquired, D: 3, smithay_module: XWayland
Dec 29 14:13:29.139 INFO Cleaning up X11 lock., smithay_module: XWayland
Dec 29 14:13:29.139 DEBG Attempting to aquire an X11 display lock, D: 4, smithay_module: XWayland
Dec 29 14:13:29.139 DEBG X11 lock aquired, D: 4, smithay_module: XWayland
Dec 29 14:13:29.139 INFO Initialization completed, starting the main loop.
The reason for the above behaviour is the
smithay::xwayland::x11_sockets::open_x11_sockets_for_display() failed.
The code successfully acquired the lock file, but then could not bind
the sockets. More specifically, the concrete socket in /tmp/.X11-unix/
already existed and thus bind() failed with EADDRINUSE.
(The code in X11Lock::grab() would then drop the already acquired
X11Lock and its Drop impl deleted the socket. Thus, when I started
things again, this time it successfully acquired display 3.)
Fix this removing the socket before trying to bind it.
This is also done by wlroots: In xwayland/sockets.x, the function
open_socket() has the same job as smithay's open_socket() function.
However, for non-abstract sockets, it would first unlink the target
before trying to bind:
if (addr->sun_path[0]) {
unlink(addr->sun_path);
}
Signed-off-by: Uli Schlachter <psychon@znc.in>
Here is a lock file not created by smithay:
$ xxd /tmp/.X0-lock
00000000: 2020 2020 2020 2035 3537 0a 557.
And this is a lock file created by smithay:
$ xxd /tmp/.X23-lock
00000000: 2020 2020 3130 3733 3332 107332
As you see, the difference is a trailing newline (0x0a).
Lock files 1 to 22 where also created by smithay, because I started it a
couple of times. Reading these lock files fails, since the code expects
a file with at least 11 bytes of content: It uses read_exact() with a
buffer of length 11 in the Err()-branch of the match that this commit
modifies.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Handling SIGUSR1 requires setting a signal handler, which is a global
resource. This can also cause problems in the presence of threads, since
every thread needs to set up a signal handler. This commit instead
changes the code to use a pipe instead (actually a UnixStream). When the
child closes the pipe, the parent wakes up and knows "to do something".
Fixes: https://github.com/Smithay/smithay/issues/246
Signed-off-by: Uli Schlachter <psychon@znc.in>
libinput provides sub-pixel precision for pointer motion & touch events.
Keep this precision by switching all coordinates values from input
events to f64 (rather than i32 or u32). Otherwise, values are rounded
and part of the movment is lost.
Potentially fixes#224
slog-stdlog has a significant dependency tree and is basically unsued if
the downstream crate of Smithay always provides a logger (like anvil),
so it is not really needed.
Change the session backend to rely on Signaler to propagate its
signals. Also introduce the Linkable trait to allow generic composition
of objects needing to listen for signals.
Introduce the `backend_session_elogind` cargo feature which pulls
`backend_session_logind` and makes the logind session backend seek
`libelogind.so` instead of `libsystemd.so`.
Fixes#127
Rework the Session Notifiers so that they are calloop event sources
by themselves, allowing them to be inserted by the user without the
`bind_session` dance.
Also update the logind backend to use the current dbus-rs API, rather
than the deprecated one.
Use helper functions in <LibinputInputBackend as InputBackend>::dipatch_new_events
to simplify the code
Move said helper functions to libinput/helpers.rs
Move libinput.rs to libinput/mod.rs
The resize handler with a window resize request causes oscillations between two window sizes (presumably the inner and the outer). While it's not clear what part of the stack causes it, checking `window.get_inner_size()` already presents the correct size.
Either way, changing the same property in its change handler is a recipe for feedback loops as this one and should be avoided whenever possible, and then carefully fortified too.
This commit removes some clippy warnings (to advance #45) by doing the following:
- replace usage of `mem::uninitialized()` with `MaybeUninit`
- replace usage of `nix::libc::{uint64_t, int32_t}` with `{u64, i32}`
- replace functions inside of `Option::ok_or` with `Option::ok_or_else`
- replace functions inside of `Result::unwrap_or` with `Result::unwrap_or_else`
- replace occurrences of pass-by-reference with pass-by-value when
appropriate
- replace unused variables in pattern-matching with wildcards
- replace `match` expressions that have only one case with `if let`
expressions
- replace UpperCamelCase names of consts with SCREAMING_SNAKE_CASE
- remove `clone()` on types that implement Copy
- remove redundant imports
- remove `fn main()` from doctests
- remove let binding for variables that are returned afterwards
Rework the subsurface tree by:
- forbidding subsurface loops
- storing the relative depth of a parent to its children,
finally respecting the wl_subsurface specification.
closes#23
- Split `DrmDevice` into `LegacyDrmDevice`, `GbmDevice` and `EglDevice`
- Provide common `Device` and `RawDevice` traits
- Change `DrmBackend` into `Surface` (and `RawSurface`) implementations of each `Device` (or `RawDevice`)
- Do not open devices for `UdevHandler` anymore
- `UdevBackend` does not require `LoopHandle` or `Session` anymore
- Type of the created device can be choosed freely by the handler
- `UdevBackendObserver` is not needed anymore
* Rename priviledged to privileged in backend/drm/mod.rs
* Fix a number of typos in comments
* Fix typos in string literals
* Wrap identifiers with backticks in doc comments
* Spelling and capitalisation in doc comments
* Use XWayland in comments
This seems to be the standard capitalisation, even though the executable
is called `Xwayland`.
* Use Glium instead of glium in comments
* Use DRM and API in comments
* Fix remaining occurrence of 'priviledged'
* Reformat code to appease Travis' rustfmt
This event poses issues regarding its semantic (what space are the
coordinates in?) and arguably won't be used anyway. So let's remove it
for now, it can still be added afterwards if it appears to be really
needed.
Unify winit with the other backends in only ever dealing with physical
sizes. All dimensions and coordinates are provided in the physical space
(transformed by the dpi factor provided by winit), and the user is
responsible for dealing with the dpi scaling if they want.
A compositor using it can deal with it either by following the scaling
transmitted by the backend or using some value retrieved by other means
(like a command line argument, like weston does).
This means that a non-hidpi aware implementation will appear very small
on an hidpi screen, but not broken. This is now the current state of
anvil.
This also changes the WinitEventsHandler trait to merge the resized()
and hidpifactorchanged() callbacks into a single one, providing the
physical size and the dpi factor whenever either changes.
Send keymaps to client using a new tempfile for each client, rather than
a single shared tempfile. Doing so prevents a client from tempering with
the contents of the tempfile, which would then cause other clients to
read a corrupted keymap.
See this bug report for details:
https://bugs.freedesktop.org/show_bug.cgi?id=101595
With the new XkbConfig struct, it is now easier to just use xkbcommon's
default configuration, by moving the xkbcommon specific options into a
struct with according documentation.
Additionally, anvil now uses xkbcommon's defaults with all backends
(previously, the winit backend had a hardcoded french keyboard layout).
`DrmDevice` and `UdevBackend` now do not need to be wrapped into `StateToken`s anymore, but can return a separate `SessionObserver` object using the new `AsSessionObserver` trait.
This change was motivated by allowing the `UdevHandle` to obtain a mutable reference to an `EventLoopHandle` to create wayland object, e.g. a `wl_output` object.
Previously this was not possible.
Depends on https://github.com/Smithay/wayland-rs/pull/164