mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 21:58:36 +00:00
Merge pull request #10287 from dotCooCoo/fix/xwayland-tablet-stylus
Linux: the log says why a pen's window stays on Wayland, and names the pens XWayland lists
This commit is contained in:
@@ -396,15 +396,36 @@ fn read_command_line(
|
||||
/// Whether the window opens through XWayland, for Linux Display Server `pref` (`main`).
|
||||
#[cfg(target_os = "linux")]
|
||||
fn opens_through_xwayland(pref: Option<&str>) -> bool {
|
||||
if !xwayland::wanted(pref, |name| std::env::var_os(name), xwayland::pen_attached) {
|
||||
use xwayland::Choice;
|
||||
let choice = xwayland::choose(pref, |name| std::env::var_os(name), xwayland::pen_attached);
|
||||
// On native Wayland winit 0.30 receives no pen input, so the log says why the window stays there.
|
||||
match &choice {
|
||||
Choice::NotWayland | Choice::Chosen | Choice::Pen(_) => {}
|
||||
Choice::NoXDisplay { x11: true } => {
|
||||
log::warn!("Linux Display Server is X11, but there is no X display (DISPLAY is unset): opening the window on Wayland")
|
||||
}
|
||||
Choice::NoXDisplay { x11: false } => log::info!(
|
||||
"opening the window on Wayland, where a pen does not reach it: there is no X display (DISPLAY is unset) to open it through XWayland"
|
||||
),
|
||||
Choice::NativeWayland => log::info!("VECTORCRAFT_NATIVE_WAYLAND is set: opening the window on Wayland, where a pen does not reach it"),
|
||||
Choice::NoPen => log::info!("no pen in /proc/bus/input/devices: opening the window on Wayland"),
|
||||
Choice::NoDeviceList(e) => log::warn!("can't look for a pen ({e}): opening the window on Wayland, where a pen does not reach it"),
|
||||
}
|
||||
if !choice.xwayland() {
|
||||
return false;
|
||||
}
|
||||
if !xwayland::x11_libraries_found() {
|
||||
log::warn!("Linux Display Server is X11, but the X11 libraries aren't all installed: opening the window on Wayland");
|
||||
if let Choice::Pen(name) = &choice {
|
||||
log::warn!(
|
||||
"pen found ({name}), but the X11 libraries aren't all installed: opening the window on Wayland, where the pen does not reach it"
|
||||
);
|
||||
} else {
|
||||
log::warn!("Linux Display Server is X11, but the X11 libraries aren't all installed: opening the window on Wayland");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if pref != Some("x11") {
|
||||
log::info!("pen found: opening the window through XWayland, where the pen works (VECTORCRAFT_NATIVE_WAYLAND=1 keeps Wayland)");
|
||||
if let Choice::Pen(name) = &choice {
|
||||
log::info!("pen found ({name}): opening the window through XWayland, where the pen works (VECTORCRAFT_NATIVE_WAYLAND=1 keeps Wayland)");
|
||||
} else {
|
||||
log::info!("opening the window through XWayland (Preferences › Performance › Linux Display Server)");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//! the rotation's range is 0°, and an axis a pen lacks reads nothing.
|
||||
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use craft::behavior::PointerSample;
|
||||
use craft::ui::runtime::pen::PenSource;
|
||||
@@ -189,6 +189,8 @@ enum Update {
|
||||
struct Pens {
|
||||
devices: HashMap<u16, Device>,
|
||||
last: HashMap<u16, [Option<f32>; 5]>,
|
||||
/// The pens an event has come from, for the log.
|
||||
heard: HashSet<u16>,
|
||||
}
|
||||
|
||||
impl Pens {
|
||||
@@ -197,10 +199,37 @@ impl Pens {
|
||||
/// same id starts without them.
|
||||
fn set_devices(&mut self, devices: impl IntoIterator<Item = Device>) {
|
||||
let devices: HashMap<u16, Device> = devices.into_iter().take(MAX_DEVICES).map(|d| (d.id, d)).collect();
|
||||
self.last.retain(|id, _| devices.get(id).is_some_and(|d| self.devices.get(id) == Some(d)));
|
||||
let unchanged = |id: &u16| devices.get(id).is_some_and(|d| self.devices.get(id) == Some(d));
|
||||
self.last.retain(|id, _| unchanged(id));
|
||||
self.heard.retain(|id| unchanged(id));
|
||||
self.devices = devices;
|
||||
}
|
||||
|
||||
/// The names of the pens listed, by device id, for the log.
|
||||
fn pen_names(&self) -> Vec<&str> {
|
||||
let mut pens: Vec<&Device> = self.devices.values().filter(|d| d.is_pen()).collect();
|
||||
pens.sort_by_key(|d| d.id);
|
||||
pens.into_iter().map(|d| d.name.as_str()).collect()
|
||||
}
|
||||
|
||||
/// The pens listed, as the log line says it: under XWayland on a Wayland session this tells
|
||||
/// whether XWayland lists the pen at all (#5622).
|
||||
fn summary(&self) -> String {
|
||||
let names = self.pen_names();
|
||||
if names.is_empty() {
|
||||
"the X server lists no pen (a pointer device with an \"Abs Pressure\" valuator): a pen draws at full pressure".to_string()
|
||||
} else {
|
||||
format!("pens listed: {}", names.join(", "))
|
||||
}
|
||||
}
|
||||
|
||||
/// The name of pen `id` when this is the first event from it since it was listed, for the log:
|
||||
/// it tells whether the pen's events reach the app at all.
|
||||
fn first_event(&mut self, id: u16) -> Option<&str> {
|
||||
let device = self.devices.get(&id).filter(|d| d.is_pen())?;
|
||||
self.heard.insert(id).then_some(device.name.as_str())
|
||||
}
|
||||
|
||||
/// A raw motion or button event of device `id`, with the valuators that changed.
|
||||
fn handle(&mut self, id: u16, valuators: impl IntoIterator<Item = (u16, f64)>) -> Update {
|
||||
let Some(device) = self.devices.get(&id) else { return Update::Keep };
|
||||
@@ -231,6 +260,9 @@ impl Pens {
|
||||
/// A raw event as the X server sends it: its valuator mask and the values of the valuators
|
||||
/// set in it. A pen's sample or another pointer's `None` goes into `pen`.
|
||||
fn raw_event(&mut self, pen: &PenSource, id: u16, mask: &[u32], values: &[f64]) {
|
||||
if let Some(name) = self.first_event(id) {
|
||||
log::info!("tablet: events arrive from the pen {name:?}");
|
||||
}
|
||||
if let Update::Set(sample) = self.handle(id, valuators(mask, values)) {
|
||||
pen.set(sample);
|
||||
}
|
||||
@@ -304,6 +336,7 @@ mod x11 {
|
||||
.map_err(|e| format!("XISelectEvents failed: {e}"))?;
|
||||
let mut pens = Pens::default();
|
||||
pens.set_devices(query_devices(&conn));
|
||||
log::info!("tablet: {}", pens.summary());
|
||||
std::thread::Builder::new()
|
||||
.name("vectorcraft-tablet-x11".into())
|
||||
.spawn(move || run(&conn, &mut pens, &pen))
|
||||
@@ -321,7 +354,14 @@ mod x11 {
|
||||
let values: Vec<f64> = e.axisvalues.iter().map(|v| fp3232(v.integral, v.frac)).collect();
|
||||
pens.raw_event(pen, e.deviceid, &e.valuator_mask, &values);
|
||||
}
|
||||
Event::XinputHierarchy(_) | Event::XinputDeviceChanged(_) => pens.set_devices(query_devices(conn)),
|
||||
Event::XinputHierarchy(_) | Event::XinputDeviceChanged(_) => {
|
||||
let before = pens.summary();
|
||||
pens.set_devices(query_devices(conn));
|
||||
let after = pens.summary();
|
||||
if after != before {
|
||||
log::info!("tablet: {after}");
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -623,6 +663,31 @@ mod tests {
|
||||
assert!(s.pressure < 0.001, "{}", s.pressure);
|
||||
}
|
||||
|
||||
/// #5622: the log names the pens the X server lists (XWayland's included) and the first event
|
||||
/// from each, once, again after the pen is listed anew, and never for a mouse.
|
||||
#[test]
|
||||
fn the_log_names_the_pens_listed_and_the_first_event_from_each() {
|
||||
let stylus = Device::new(11, "xwayland-tablet stylus:16", Some("xwayland-tablet stylus"), pen_valuators());
|
||||
let eraser = Device::new(12, "xwayland-tablet eraser:16", Some("xwayland-tablet eraser"), pen_valuators());
|
||||
let mut pens = Pens::default();
|
||||
assert!(pens.summary().contains("lists no pen"), "{}", pens.summary());
|
||||
pens.set_devices([eraser.clone(), mouse(4), stylus.clone()]);
|
||||
assert_eq!(pens.summary(), "pens listed: xwayland-tablet stylus:16, xwayland-tablet eraser:16");
|
||||
assert_eq!(pens.first_event(11), Some("xwayland-tablet stylus:16"));
|
||||
assert_eq!(pens.first_event(11), None, "once");
|
||||
assert_eq!(pens.first_event(4), None, "a mouse");
|
||||
assert_eq!(pens.first_event(99), None, "a device not listed");
|
||||
// Listed again unchanged: still heard. Another device under the same id: heard anew.
|
||||
pens.set_devices([eraser.clone(), mouse(4), stylus]);
|
||||
assert_eq!(pens.first_event(11), None);
|
||||
pens.set_devices([eraser, mouse(4), pen(11)]);
|
||||
assert_eq!(pens.first_event(11), Some("Wacom Intuos Pro M Pen stylus"));
|
||||
// The events go into the feed as before.
|
||||
let source = PenSource::default();
|
||||
pens.raw_event(&source, 12, &[0b100], &[65535.0]);
|
||||
assert_eq!(source.current().map(|s| (s.eraser, s.pressure)), Some((true, 1.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixed_point_values() {
|
||||
assert_eq!(fp3232(3, 1 << 31), 3.5);
|
||||
|
||||
@@ -22,18 +22,61 @@ use std::path::{Path, PathBuf};
|
||||
const X11_LIBS: &[&str] =
|
||||
&["libX11.so.6", "libX11-xcb.so.1", "libxcb.so.1", "libXcursor.so.1", "libXi.so.6", "libxkbcommon.so.0", "libxkbcommon-x11.so.0"];
|
||||
|
||||
/// Whether the saved `linuxDisplayServer` and the environment ask for XWayland: `x11` chosen, or
|
||||
/// any other choice (`automatic`, `x11WithPen`, none saved) with `pen` finding a pen and
|
||||
/// `VECTORCRAFT_NATIVE_WAYLAND` unset (or `0`); a Wayland session (winit picks Wayland whenever
|
||||
/// `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set); and an X display to open. `pen` runs only after
|
||||
/// the other checks.
|
||||
pub fn wanted(pref: Option<&str>, var: impl Fn(&str) -> Option<OsString>, pen: impl FnOnce() -> bool) -> bool {
|
||||
/// What the pen check found: the name of the first pen, `None` when there is none, or why the
|
||||
/// device list could not be read.
|
||||
pub type PenProbe = Result<Option<String>, String>;
|
||||
|
||||
/// Where the window opens, and why, as [`choose`] decides it.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Choice {
|
||||
/// Not a Wayland session: the window opens where winit opens it.
|
||||
NotWayland,
|
||||
/// XWayland, because Linux Display Server is X11 (XWayland).
|
||||
Chosen,
|
||||
/// XWayland, because the pen of this name is attached.
|
||||
Pen(String),
|
||||
/// Wayland: the session has no X display (`DISPLAY` is unset, as in the Flatpak on a Wayland
|
||||
/// session), so XWayland can't be used. `x11` is whether X11 (XWayland) was chosen.
|
||||
NoXDisplay { x11: bool },
|
||||
/// Wayland: `VECTORCRAFT_NATIVE_WAYLAND` keeps the window there.
|
||||
NativeWayland,
|
||||
/// Wayland: no pen is attached.
|
||||
NoPen,
|
||||
/// Wayland: the input devices could not be listed, for this reason.
|
||||
NoDeviceList(String),
|
||||
}
|
||||
|
||||
impl Choice {
|
||||
/// Whether the window opens through XWayland.
|
||||
pub fn xwayland(&self) -> bool {
|
||||
matches!(self, Self::Chosen | Self::Pen(_))
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the saved `linuxDisplayServer` and the environment open the window: XWayland for `x11`
|
||||
/// chosen, or for any other choice (`automatic`, `x11WithPen`, none saved) with `pen` finding a pen
|
||||
/// and `VECTORCRAFT_NATIVE_WAYLAND` unset (or `0`), on a Wayland session (winit picks Wayland
|
||||
/// whenever `WAYLAND_DISPLAY` or `WAYLAND_SOCKET` is set) with an X display to open. `pen` runs
|
||||
/// only after the other checks.
|
||||
pub fn choose(pref: Option<&str>, var: impl Fn(&str) -> Option<OsString>, pen: impl FnOnce() -> PenProbe) -> Choice {
|
||||
let set = |name: &str| var(name).is_some_and(|v| !v.is_empty());
|
||||
let session = (set("WAYLAND_DISPLAY") || set("WAYLAND_SOCKET")) && set("DISPLAY");
|
||||
let native_wayland = var("VECTORCRAFT_NATIVE_WAYLAND").is_some_and(|v| !v.is_empty() && v != "0");
|
||||
match pref {
|
||||
Some("x11") => session,
|
||||
_ => session && !native_wayland && pen(),
|
||||
if !set("WAYLAND_DISPLAY") && !set("WAYLAND_SOCKET") {
|
||||
return Choice::NotWayland;
|
||||
}
|
||||
let x11 = pref == Some("x11");
|
||||
if !set("DISPLAY") {
|
||||
return Choice::NoXDisplay { x11 };
|
||||
}
|
||||
if x11 {
|
||||
return Choice::Chosen;
|
||||
}
|
||||
if var("VECTORCRAFT_NATIVE_WAYLAND").is_some_and(|v| !v.is_empty() && v != "0") {
|
||||
return Choice::NativeWayland;
|
||||
}
|
||||
match pen() {
|
||||
Ok(Some(name)) => Choice::Pen(name),
|
||||
Ok(None) => Choice::NoPen,
|
||||
Err(e) => Choice::NoDeviceList(e),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,20 +87,28 @@ const BTN_TOOL_PEN: u32 = 0x140;
|
||||
const ABS_X: u32 = 0x00;
|
||||
const ABS_Y: u32 = 0x01;
|
||||
|
||||
/// Is a pen attached? Reads `/proc/bus/input/devices`; a file that can't be read has no pen.
|
||||
pub fn pen_attached() -> bool {
|
||||
std::fs::read_to_string("/proc/bus/input/devices").is_ok_and(|devices| has_pen(&devices))
|
||||
/// The pen attached, from `/proc/bus/input/devices`, or why that file could not be read.
|
||||
pub fn pen_attached() -> PenProbe {
|
||||
std::fs::read_to_string("/proc/bus/input/devices").map(|devices| find_pen(&devices)).map_err(|e| format!("/proc/bus/input/devices: {e}"))
|
||||
}
|
||||
|
||||
/// Is a pen among the input devices `/proc/bus/input/devices` lists? A pen is a device whose
|
||||
/// Is a pen among the input devices `/proc/bus/input/devices` lists?
|
||||
#[cfg(test)]
|
||||
fn has_pen(devices: &str) -> bool {
|
||||
find_pen(devices).is_some()
|
||||
}
|
||||
|
||||
/// The name of the first pen among the input devices `/proc/bus/input/devices` lists (its
|
||||
/// `N: Name=` line without the quotes, empty when it has none). A pen is a device whose
|
||||
/// `B: KEY=` bitmap has `BTN_TOOL_PEN` and whose `B: ABS=` bitmap has `ABS_X` and `ABS_Y`, as
|
||||
/// libinput asks of a tablet tool. A virtual keyboard made with uinput can claim every key code,
|
||||
/// `BTN_TOOL_PEN` included, but has no absolute axes.
|
||||
fn has_pen(devices: &str) -> bool {
|
||||
devices.split("\n\n").any(|device| {
|
||||
let bitmap = |name: &str| device.lines().find_map(|l| l.strip_prefix(name));
|
||||
bitmap("B: KEY=").is_some_and(|keys| bit_set(keys, BTN_TOOL_PEN))
|
||||
&& bitmap("B: ABS=").is_some_and(|axes| bit_set(axes, ABS_X) && bit_set(axes, ABS_Y))
|
||||
fn find_pen(devices: &str) -> Option<String> {
|
||||
devices.split("\n\n").find_map(|device| {
|
||||
let field = |name: &str| device.lines().find_map(|l| l.strip_prefix(name));
|
||||
let pen = field("B: KEY=").is_some_and(|keys| bit_set(keys, BTN_TOOL_PEN))
|
||||
&& field("B: ABS=").is_some_and(|axes| bit_set(axes, ABS_X) && bit_set(axes, ABS_Y));
|
||||
pen.then(|| field("N: Name=").map_or_else(String::new, |n| n.trim().trim_matches('"').to_string()))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -147,6 +198,11 @@ mod tests {
|
||||
panic!("the pen check ran")
|
||||
}
|
||||
|
||||
/// [`choose`] as a yes or no, with a pen check that finds a pen or none.
|
||||
fn wanted(pref: Option<&str>, var: impl Fn(&str) -> Option<OsString>, pen: impl FnOnce() -> bool) -> bool {
|
||||
choose(pref, var, || Ok(pen().then(|| "Pen".to_string()))).xwayland()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xwayland_only_when_chosen_on_wayland_with_an_x_display() {
|
||||
let wayland = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0")]);
|
||||
@@ -183,6 +239,40 @@ mod tests {
|
||||
assert!(wanted(Some("x11"), &native, no_probe));
|
||||
}
|
||||
|
||||
/// #5622: the choice names why the window stays on Wayland, where the pen does not reach it,
|
||||
/// so that the log tells a missing X display (the Flatpak on a Wayland session) from a pen
|
||||
/// that is not listed or a device list that can't be read.
|
||||
#[test]
|
||||
fn the_choice_says_why_the_window_stays_on_wayland() {
|
||||
let wayland = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0")]);
|
||||
let no_x = env(&[("WAYLAND_DISPLAY", "wayland-0")]);
|
||||
let native = env(&[("WAYLAND_DISPLAY", "wayland-0"), ("DISPLAY", ":0"), ("VECTORCRAFT_NATIVE_WAYLAND", "1")]);
|
||||
let pen = || Ok(Some("ELAN9008:00 04F3:2C82 Stylus".to_string()));
|
||||
let never = || -> PenProbe { panic!("the pen check ran") };
|
||||
assert_eq!(choose(None, env(&[("DISPLAY", ":0")]), never), Choice::NotWayland);
|
||||
assert_eq!(choose(None, &no_x, never), Choice::NoXDisplay { x11: false });
|
||||
assert_eq!(choose(Some("x11"), &no_x, never), Choice::NoXDisplay { x11: true });
|
||||
assert_eq!(choose(Some("x11"), &wayland, never), Choice::Chosen);
|
||||
assert_eq!(choose(Some("automatic"), &native, never), Choice::NativeWayland);
|
||||
assert_eq!(choose(Some("automatic"), &wayland, pen), Choice::Pen("ELAN9008:00 04F3:2C82 Stylus".to_string()));
|
||||
assert_eq!(choose(Some("x11WithPen"), &wayland, || Ok(None)), Choice::NoPen);
|
||||
let unreadable = choose(None, &wayland, || Err("/proc/bus/input/devices: Permission denied".to_string()));
|
||||
assert_eq!(unreadable, Choice::NoDeviceList("/proc/bus/input/devices: Permission denied".to_string()));
|
||||
for stays in [Choice::NotWayland, Choice::NoXDisplay { x11: true }, Choice::NativeWayland, Choice::NoPen, unreadable] {
|
||||
assert!(!stays.xwayland(), "{stays:?}");
|
||||
}
|
||||
assert!(Choice::Chosen.xwayland() && Choice::Pen(String::new()).xwayland());
|
||||
}
|
||||
|
||||
/// The pen check names the pen it found, for the log.
|
||||
#[test]
|
||||
fn the_pen_check_names_the_pen() {
|
||||
assert_eq!(find_pen(WITH_PEN).as_deref(), Some("Wacom Intuos Pro M Pen"));
|
||||
let without = WITH_PEN.split("\n\n").take(2).collect::<Vec<_>>().join("\n\n");
|
||||
assert_eq!(find_pen(&without), None);
|
||||
assert_eq!(find_pen("B: KEY=1c03 0 0 0 0 0\nB: ABS=3\n").as_deref(), Some(""), "a pen without a name line");
|
||||
}
|
||||
|
||||
/// `/proc/bus/input/devices` of a laptop with a Wacom Intuos Pro attached (64-bit longs: the
|
||||
/// pen's `KEY=1c03 0 0 0 0 0` has bit 0x140, `BTN_TOOL_PEN`), from PhotoCraft's tests.
|
||||
const WITH_PEN: &str = "I: Bus=0011 Vendor=0001 Product=0001 Version=ab83\n\
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ The window runs natively on Wayland (eframe's `wayland` feature) and on X11. On
|
||||
- **Clipboard owners that never answer (#510):** reading the clipboard waits on the app that owns it: arboard gives up on an X11 owner after 4 s for each format it tries, and a Wayland read waits for the owner to send its data. So on Linux the check that enables the Paste menu items runs on a background thread with a second clipboard handle (`crates/ui-egui/src/clipboard_probe.rs`, installed as `Services::clipboard_probe`), only while nothing is copied in the app and a document is open, and the window keeps drawing. Every arboard read on Linux and the BSDs, including the UI thread's (a paste, and a Copy or Cut checking what the clipboard held), runs on a worker thread with a handle of its own and waits 2 s at most: an owner that never sends its data costs one read that wait, and later reads fail at once until it answers. A paste's bitmap read waits up to 10 s on the paste's background thread, so the UI thread does not wait for it. When one of a paste's reads gets no answer in its 2 s, or a paste follows a read that has not been answered yet, such as the paste's own check whether the clipboard still holds what VectorCraft copied, the paste waits on that thread for that read's answer, up to 10 s after the read was sent, and pastes what it holds. When the answer is what VectorCraft copied, holds nothing to paste, or does not come, the paste takes the internal clipboard. On X11, quitting within 25 s of a read that got no answer waits for that read to end, so the app's own handle is the last one and hands what it copied to the clipboard manager when one runs. That includes a read of the Paste menu check's handle: quitting waits up to 27 s for the background thread to drop it before the app drops its own, and quits after that wait even when the handle has not been dropped. The app takes its windows off screen before these waits (`apps/vectorcraft/src/quit_windows.rs`). An X11 main window, an XWayland one included, is hidden. winit cannot hide a native Wayland window, so on Linux the app attaches no buffer to the main window's surface, which unmaps it while the window and its connection stay open for the Wayland clipboard. On Linux the X11 windows of floating panels and documents are unmapped through a second X11 connection. On native Wayland, floating panels and documents are normally drawn inside the main window; on the BSDs a native Wayland main window stays on screen until the waits end. Windows and macOS keep the check on the UI thread: Windows only asks which formats the clipboard holds, macOS asks the pasteboard server.
|
||||
- **Copied files:** files copied in a file manager (`text/uri-list`; `CF_HDROP` on Windows, file URLs on macOS) paste as the first one that is art (SVG, PDF, EPS, EMF/WMF or a bitmap; a `.ai` or `.ait` file from the editing data it holds, else as the PDF or PostScript it holds), before the clipboard's other formats (which include the files' paths as text).
|
||||
- **Dropping files on the window does not work under Wayland:** winit 0.30, which eframe 0.37 runs on, has no Wayland drag and drop ([winit#1881](https://github.com/rust-windowing/winit/issues/1881), added in winit 0.31; [egui#1563](https://github.com/emilk/egui/issues/1563)), so no `dropped_files` arrive. Until eframe moves to winit 0.31: copy the files in the file manager and paste them, use File › Place or Open, or open the window through XWayland, where drops work: set **Preferences › Performance › Linux Display Server** to **X11 (XWayland)** and restart (#1151), or start the app with `WAYLAND_DISPLAY= vectorcraft`. The preference (`linuxDisplayServer`, read at startup in `apps/vectorcraft/src/main.rs`, shown on Linux only) has winit open the window on X11 (`EventLoopBuilderExtX11::with_x11`) when the session is Wayland, `DISPLAY` is set and the X11 libraries winit loads are installed (`apps/vectorcraft/src/xwayland.rs` reads `ldconfig -p` and the usual library directories); otherwise the window opens on Wayland and the log says why. Unlike clearing `WAYLAND_DISPLAY`, it leaves the clipboard on the compositor's own.
|
||||
- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found: opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way.
|
||||
- **Pens and pen displays under Wayland (#491, #2028):** winit 0.30 doesn't bind the Wayland tablet protocol (`zwp_tablet_v2`; tablet input arrives in winit 0.31, [winit#4318](https://github.com/rust-windowing/winit/pull/4318), [egui#7731](https://github.com/emilk/egui/pull/7731)). Since Plasma 6.3, KWin no longer turns tablet input into pointer input for such apps ([kwin!6336](https://invent.kde.org/plasma/kwin/-/merge_requests/6336), commit [25c65abd](https://invent.kde.org/plasma/kwin/-/commit/25c65abddd95eb87fb892a8594faccbf509ff62f)), and GNOME's Mutter does not turn it into pointer input either (that commit's message): on KWin the pen moves the compositor's cursor over the window, but the app gets no motion or presses and shows none of its own cursors. Until eframe moves to winit 0.31, the app runs under XWayland, which supports the tablet protocol and hands the pen to X11 apps as a pointer: Preferences › Performance › Linux Display Server's Automatic (the default) and X11 (XWayland) When a Pen Is Attached (`x11WithPen`) open the window through XWayland when `/proc/bus/input/devices` lists a pen as the app starts, a device with the `BTN_TOOL_PEN` key and the `ABS_X` and `ABS_Y` axes, and log `pen found (<the pen's name>): opening the window through XWayland`, as PhotoCraft does (#4967; `VECTORCRAFT_NATIVE_WAYLAND=1` keeps the window on Wayland). When the window stays on Wayland on such a session, the log says why (#5622): `no pen in /proc/bus/input/devices`, `can't look for a pen` with the reason, `VECTORCRAFT_NATIVE_WAYLAND is set`, `there is no X display (DISPLAY is unset)`, or that the X11 libraries aren't all installed. The Flatpak gets no X display on a Wayland session (`--socket=fallback-x11`); `flatpak override --user --nosocket=fallback-x11 --socket=x11 ai.storyteller.vectorcraft` gives it one and keeps its Wayland socket. `--socket=x11` alone is not enough: while `fallback-x11` is set, Flatpak gives the app no X display whenever Wayland is available. `GDK_BACKEND=x11` does not move the window to XWayland: winit does not read it. Under X11 the log lists the pens the X server lists (`tablet: pens listed: …`, for example `xwayland-tablet stylus:16` under XWayland, or `the X server lists no pen`) and the first event from each pen (`tablet: events arrive from the pen …`). For a pen attached after the app started, either run the app under XWayland (Preferences › Performance › Linux Display Server › X11 (XWayland); `WAYLAND_DISPLAY= vectorcraft`, or `env -u WAYLAND_DISPLAY vectorcraft`; for a desktop launcher, put `env WAYLAND_DISPLAY=` before the command in its `Exec=` line), or turn KWin's deprecated emulation back on for the whole session by setting `KWIN_WAYLAND_EMULATE_TABLET=1` in KWin's environment (for example in a file under `~/.config/environment.d/` or in `/etc/environment`) and logging in again. The pen then works as a mouse. Under XWayland the app also reads the pen's pressure (next item); with KWin's emulation on native Wayland the pen has no pressure. Other compositors that don't emulate a pointer for tablets behave the same way.
|
||||
- **Pen pressure under X11 and XWayland (#764):** winit 0.30 hands a pen to an X11 window as a mouse, without its pressure. When the window is on X11, XWayland included, the desktop app opens a second X connection (x11rb's `RustConnection`) and reads XInput2 raw events for every device (`apps/vectorcraft/src/tablet.rs`, from PhotoCraft's `crates/tablet`). A device with an `Abs Pressure` valuator is a pen, unless its XInput type is `TOUCHPAD` or `TOUCHSCREEN`. While a pen is the pointer that moved last, its pressure, scaled from the valuator's range to 0..1, reaches the tools that use pressure: the Paintbrush's pressure-sensitive brushes and the Liquify tools' Use Pressure Pen. The reader also reads `Abs Tilt X` and `Abs Tilt Y` (from a pen that has both) in degrees, scaled to ±60° when the valuator's range does not fit in ±90, and `Abs Rotary Z` (an Art Pen's barrel rotation) as a turn with the middle of the range at 0°; the Paintbrush records them for brushes with Tilt, Bearing and Rotation variation. A pen device whose name or XInput type contains `eraser` (in any case) is the pen's eraser end: while the pointer is over the window, the canvas selects the Eraser tool when the eraser end moves, and it selects the tool used before when the tip moves again (`crates/ui-egui/src/stylus.rs`). The X server needs XInput 2.1 or later; otherwise the log has a `tablet pressure:` warning with the reason, and the pen draws at full pressure.
|
||||
- **Pen tilt and rotation on macOS (#764):** with each tablet event's pressure (#852), `apps/vectorcraft/src/mac_tablet.rs` reads its `tilt`, −1..1 on each axis, scaled to ±60° with each axis keeping AppKit's sign (x positive to the right, y positive towards the bottom and the user), and its `rotation`, negated to run clockwise. Until a pen reports a tilt or a rotation other than 0 after it comes near the tablet, that value reads as none, since a pen without one reports 0. The Paintbrush records them as it does under X11.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user