chore: Update to newest smithay/calloop
This commit is contained in:
parent
8ac85c4112
commit
b07ac107b1
8 changed files with 218 additions and 107 deletions
135
Cargo.lock
generated
135
Cargo.lock
generated
|
|
@ -161,6 +161,19 @@ dependencies = [
|
||||||
"nix 0.22.3",
|
"nix 0.22.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "calloop"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84221146483fe8a40de9af92111abd5a71ab8cf0e3c673df2b209f891a82e02e"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"nix 0.24.1",
|
||||||
|
"slotmap",
|
||||||
|
"thiserror",
|
||||||
|
"vec_map",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.73"
|
version = "1.0.73"
|
||||||
|
|
@ -924,25 +937,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.2"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
|
checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"miow",
|
|
||||||
"ntapi",
|
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"winapi",
|
"windows-sys",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miow"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1024,6 +1026,18 @@ dependencies = [
|
||||||
"memoffset",
|
"memoffset",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.24.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"memoffset",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nohash-hasher"
|
name = "nohash-hasher"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -1040,15 +1054,6 @@ dependencies = [
|
||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ntapi"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
|
|
@ -1081,9 +1086,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_threads"
|
name = "num_threads"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0"
|
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
@ -1099,9 +1104,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.28.3"
|
version = "0.28.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456"
|
checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
@ -1176,9 +1181,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.37"
|
version = "1.0.38"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
|
checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
@ -1329,9 +1334,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.80"
|
version = "1.0.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944"
|
checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
|
|
@ -1402,6 +1407,15 @@ dependencies = [
|
||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slotmap"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
|
|
@ -1411,11 +1425,11 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay"
|
name = "smithay"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/pop-os/smithay?branch=main#7e8c76d420fb60ca4e0844cc0c401837fd735f00"
|
source = "git+https://github.com/pop-os/smithay?branch=main#c24ac85b70606c184a973e396fe4acaae1239147"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"appendlist",
|
"appendlist",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"calloop",
|
"calloop 0.10.0",
|
||||||
"cgmath",
|
"cgmath",
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"drm",
|
"drm",
|
||||||
|
|
@ -1455,7 +1469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3"
|
checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"calloop",
|
"calloop 0.9.3",
|
||||||
"dlib",
|
"dlib",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -1501,9 +1515,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.92"
|
version = "1.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
|
checksum = "04066589568b72ec65f42d65a1a52436e954b168773148893c020269563decf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -1635,6 +1649,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vec_map"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
|
@ -1852,6 +1872,49 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.36.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winit"
|
name = "winit"
|
||||||
version = "0.26.1"
|
version = "0.26.1"
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ use smithay::{
|
||||||
},
|
},
|
||||||
reexports::{
|
reexports::{
|
||||||
calloop::{
|
calloop::{
|
||||||
timer::{Timer, TimerHandle},
|
timer::{TimeoutAction, Timer},
|
||||||
Dispatcher, EventLoop, LoopHandle, RegistrationToken,
|
Dispatcher, EventLoop, InsertError, LoopHandle, RegistrationToken,
|
||||||
},
|
},
|
||||||
drm::control::{connector, crtc, Device as ControlDevice, ModeTypeFlags},
|
drm::control::{connector, crtc, Device as ControlDevice, ModeTypeFlags},
|
||||||
input::Libinput,
|
input::Libinput,
|
||||||
|
|
@ -44,7 +44,7 @@ use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
time::{Duration, Instant, SystemTime},
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod drm_helpers;
|
mod drm_helpers;
|
||||||
|
|
@ -82,7 +82,6 @@ pub struct Surface {
|
||||||
refresh_rate: u32,
|
refresh_rate: u32,
|
||||||
vrr: bool,
|
vrr: bool,
|
||||||
pending: bool,
|
pending: bool,
|
||||||
render_timer: TimerHandle<(DrmNode, crtc::Handle)>,
|
|
||||||
render_timer_token: Option<RegistrationToken>,
|
render_timer_token: Option<RegistrationToken>,
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
fps: Fps,
|
fps: Fps,
|
||||||
|
|
@ -109,7 +108,13 @@ pub fn init_backend(event_loop: &mut EventLoop<'static, State>, state: &mut Stat
|
||||||
}
|
}
|
||||||
state.process_input_event(event);
|
state.process_input_event(event);
|
||||||
for output in state.common.shell.outputs() {
|
for output in state.common.shell.outputs() {
|
||||||
state.backend.kms().schedule_render(output);
|
if let Err(err) = state
|
||||||
|
.backend
|
||||||
|
.kms()
|
||||||
|
.schedule_render(&state.common.event_loop_handle, output)
|
||||||
|
{
|
||||||
|
slog_scope::crit!("Error scheduling event loop for output {}: {:?}", output.name(), err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_err(|err| err.error)
|
.map_err(|err| err.error)
|
||||||
|
|
@ -219,6 +224,7 @@ pub fn init_backend(event_loop: &mut EventLoop<'static, State>, state: &mut Stat
|
||||||
state.common.output_conf.outputs(),
|
state.common.output_conf.outputs(),
|
||||||
&mut state.backend,
|
&mut state.backend,
|
||||||
&mut state.common.shell,
|
&mut state.common.shell,
|
||||||
|
&state.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
state.common.shell.refresh_outputs();
|
state.common.shell.refresh_outputs();
|
||||||
state
|
state
|
||||||
|
|
@ -236,7 +242,13 @@ pub fn init_backend(event_loop: &mut EventLoop<'static, State>, state: &mut Stat
|
||||||
surface.pending = false;
|
surface.pending = false;
|
||||||
}
|
}
|
||||||
for output in state.common.shell.outputs() {
|
for output in state.common.shell.outputs() {
|
||||||
state.backend.kms().schedule_render(output);
|
if let Err(err) = state
|
||||||
|
.backend
|
||||||
|
.kms()
|
||||||
|
.schedule_render(&state.common.event_loop_handle, output)
|
||||||
|
{
|
||||||
|
slog_scope::crit!("Error scheduling event loop for output {}: {:?}", output.name(), err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loop_signal.wakeup();
|
loop_signal.wakeup();
|
||||||
|
|
@ -382,7 +394,7 @@ impl State {
|
||||||
let mut wl_outputs = Vec::new();
|
let mut wl_outputs = Vec::new();
|
||||||
let mut w = self.common.shell.global_space().size.w;
|
let mut w = self.common.shell.global_space().size.w;
|
||||||
for (crtc, conn) in outputs {
|
for (crtc, conn) in outputs {
|
||||||
match device.setup_surface(crtc, conn, &mut self.common.event_loop_handle, (0, w)) {
|
match device.setup_surface(crtc, conn, (0, w)) {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
w += output
|
w += output
|
||||||
.user_data()
|
.user_data()
|
||||||
|
|
@ -403,11 +415,12 @@ impl State {
|
||||||
.output_conf
|
.output_conf
|
||||||
.update(&mut *self.common.display.borrow_mut());
|
.update(&mut *self.common.display.borrow_mut());
|
||||||
for output in wl_outputs {
|
for output in wl_outputs {
|
||||||
if let Err(err) =
|
if let Err(err) = self.backend.kms().apply_config_for_output(
|
||||||
self.backend
|
&output,
|
||||||
.kms()
|
&mut self.common.shell,
|
||||||
.apply_config_for_output(&output, &mut self.common.shell, false)
|
false,
|
||||||
{
|
&self.common.event_loop_handle,
|
||||||
|
) {
|
||||||
slog_scope::warn!("Failed to initialize output: {}", err);
|
slog_scope::warn!("Failed to initialize output: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -415,6 +428,7 @@ impl State {
|
||||||
self.common.output_conf.outputs(),
|
self.common.output_conf.outputs(),
|
||||||
&mut self.backend,
|
&mut self.backend,
|
||||||
&mut self.common.shell,
|
&mut self.common.shell,
|
||||||
|
&self.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
self.common.shell.refresh_outputs();
|
self.common.shell.refresh_outputs();
|
||||||
self.common
|
self.common
|
||||||
|
|
@ -445,7 +459,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (crtc, conn) in changes.added {
|
for (crtc, conn) in changes.added {
|
||||||
match device.setup_surface(crtc, conn, &mut self.common.event_loop_handle, (0, w)) {
|
match device.setup_surface(crtc, conn, (0, w)) {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
w += output
|
w += output
|
||||||
.user_data()
|
.user_data()
|
||||||
|
|
@ -464,11 +478,12 @@ impl State {
|
||||||
self.common.output_conf.remove_heads(outputs_removed.iter());
|
self.common.output_conf.remove_heads(outputs_removed.iter());
|
||||||
self.common.output_conf.add_heads(outputs_added.iter());
|
self.common.output_conf.add_heads(outputs_added.iter());
|
||||||
for output in outputs_added {
|
for output in outputs_added {
|
||||||
if let Err(err) =
|
if let Err(err) = self.backend.kms().apply_config_for_output(
|
||||||
self.backend
|
&output,
|
||||||
.kms()
|
&mut self.common.shell,
|
||||||
.apply_config_for_output(&output, &mut self.common.shell, false)
|
false,
|
||||||
{
|
&self.common.event_loop_handle,
|
||||||
|
) {
|
||||||
slog_scope::warn!("Failed to initialize output: {}", err);
|
slog_scope::warn!("Failed to initialize output: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -479,6 +494,7 @@ impl State {
|
||||||
self.common.output_conf.outputs(),
|
self.common.output_conf.outputs(),
|
||||||
&mut self.backend,
|
&mut self.backend,
|
||||||
&mut self.common.shell,
|
&mut self.common.shell,
|
||||||
|
&self.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
self.common.shell.refresh_outputs();
|
self.common.shell.refresh_outputs();
|
||||||
self.common
|
self.common
|
||||||
|
|
@ -515,6 +531,7 @@ impl State {
|
||||||
self.common.output_conf.outputs(),
|
self.common.output_conf.outputs(),
|
||||||
&mut self.backend,
|
&mut self.backend,
|
||||||
&mut self.common.shell,
|
&mut self.common.shell,
|
||||||
|
&self.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
self.common.shell.refresh_outputs();
|
self.common.shell.refresh_outputs();
|
||||||
self.common
|
self.common
|
||||||
|
|
@ -563,7 +580,6 @@ impl Device {
|
||||||
&mut self,
|
&mut self,
|
||||||
crtc: crtc::Handle,
|
crtc: crtc::Handle,
|
||||||
conn: connector::Handle,
|
conn: connector::Handle,
|
||||||
loop_handle: &mut LoopHandle<'static, State>,
|
|
||||||
position: (i32, i32),
|
position: (i32, i32),
|
||||||
) -> Result<Output> {
|
) -> Result<Output> {
|
||||||
let drm = &mut *self.drm.as_source_mut();
|
let drm = &mut *self.drm.as_source_mut();
|
||||||
|
|
@ -622,27 +638,6 @@ impl Device {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let timer = Timer::new()?;
|
|
||||||
let timer_handle = timer.handle();
|
|
||||||
// render timer
|
|
||||||
let timer_token = loop_handle
|
|
||||||
.insert_source(timer, |(dev_id, crtc), _, state| {
|
|
||||||
let backend = state.backend.kms();
|
|
||||||
if let Some(device) = backend.devices.get_mut(&dev_id) {
|
|
||||||
if let Some(surface) = device.surfaces.get_mut(&crtc) {
|
|
||||||
if let Err(err) = surface.render_output(
|
|
||||||
&mut backend.api,
|
|
||||||
&device.render_node,
|
|
||||||
&mut state.common,
|
|
||||||
) {
|
|
||||||
slog_scope::error!("Error rendering: {}", err);
|
|
||||||
// TODO re-schedule?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let data = Surface {
|
let data = Surface {
|
||||||
output: output.clone(),
|
output: output.clone(),
|
||||||
surface: None,
|
surface: None,
|
||||||
|
|
@ -651,8 +646,7 @@ impl Device {
|
||||||
refresh_rate,
|
refresh_rate,
|
||||||
last_submit: None,
|
last_submit: None,
|
||||||
pending: false,
|
pending: false,
|
||||||
render_timer: timer_handle,
|
render_timer_token: None,
|
||||||
render_timer_token: Some(timer_token),
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
fps: Fps::default(),
|
fps: Fps::default(),
|
||||||
};
|
};
|
||||||
|
|
@ -756,6 +750,7 @@ impl KmsState {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
shell: &mut Shell,
|
shell: &mut Shell,
|
||||||
test_only: bool,
|
test_only: bool,
|
||||||
|
loop_handle: &LoopHandle<'_, State>,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
let recreated = if let Some(device) = self
|
let recreated = if let Some(device) = self
|
||||||
.devices
|
.devices
|
||||||
|
|
@ -840,12 +835,18 @@ impl KmsState {
|
||||||
|
|
||||||
shell.refresh_outputs();
|
shell.refresh_outputs();
|
||||||
if recreated {
|
if recreated {
|
||||||
self.schedule_render(output);
|
if let Err(err) = self.schedule_render(loop_handle, output) {
|
||||||
|
slog_scope::crit!("Error scheduling event loop for output {}: {:?}", output.name(), err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_render(&mut self, output: &Output) {
|
pub fn schedule_render(
|
||||||
|
&mut self,
|
||||||
|
loop_handle: &LoopHandle<'_, State>,
|
||||||
|
output: &Output,
|
||||||
|
) -> Result<(), InsertError<Timer>> {
|
||||||
if let Some((device, crtc, surface)) = self
|
if let Some((device, crtc, surface)) = self
|
||||||
.devices
|
.devices
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
|
|
@ -853,29 +854,53 @@ impl KmsState {
|
||||||
.find(|(_, _, s)| s.output == *output)
|
.find(|(_, _, s)| s.output == *output)
|
||||||
{
|
{
|
||||||
if surface.surface.is_none() {
|
if surface.surface.is_none() {
|
||||||
return;
|
return Ok(());
|
||||||
}
|
}
|
||||||
if !surface.pending {
|
if !surface.pending {
|
||||||
surface.pending = true;
|
surface.pending = true;
|
||||||
/*
|
/*
|
||||||
let duration = surface
|
let instant = surface
|
||||||
.last_submit
|
.last_submit
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|x| match x {
|
.and_then(|x| match x {
|
||||||
DrmEventTime::Monotonic(instant) => {
|
DrmEventTime::Monotonic(instant) => Some(instant),
|
||||||
instant.checked_duration_since(Instant::now())
|
DrmEventTime::Realtime(_) => None,
|
||||||
}
|
|
||||||
DrmEventTime::Realtime(time) => time.duration_since(SystemTime::now()).ok(),
|
|
||||||
})
|
})
|
||||||
.unwrap_or(Duration::ZERO); // + Duration::from_secs_f64((1.0 / surface.refresh_rate as f64) - 20.0);
|
.map(|i| {
|
||||||
|
*i + Duration::from_secs_f64(1.0 / surface.refresh_rate as f64)
|
||||||
|
- Duration::from_millis(20) // render budget
|
||||||
|
});
|
||||||
*/
|
*/
|
||||||
let data = (*device, *crtc);
|
|
||||||
//if surface.vrr {
|
let device = *device;
|
||||||
surface.render_timer.add_timeout(Duration::ZERO, data);
|
let crtc = *crtc;
|
||||||
//} else {
|
surface.render_timer_token = Some(loop_handle.insert_source(
|
||||||
// surface.render_timer.add_timeout(duration, data);
|
//if surface.vrr || instant.is_none() {
|
||||||
//}
|
Timer::immediate()
|
||||||
|
/*} else {
|
||||||
|
Timer::from_deadline(instant.unwrap())
|
||||||
|
}*/,
|
||||||
|
move |_time, _, state| {
|
||||||
|
let backend = state.backend.kms();
|
||||||
|
if let Some(device) = backend.devices.get_mut(&device) {
|
||||||
|
if let Some(surface) = device.surfaces.get_mut(&crtc) {
|
||||||
|
if let Err(err) = surface.render_output(
|
||||||
|
&mut backend.api,
|
||||||
|
&device.render_node,
|
||||||
|
&mut state.common,
|
||||||
|
) {
|
||||||
|
slog_scope::error!("Error rendering: {}", err);
|
||||||
|
return TimeoutAction::ToDuration(Duration::from_secs_f64(
|
||||||
|
1.0 / surface.refresh_rate as f64,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TimeoutAction::Drop
|
||||||
|
},
|
||||||
|
)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@ pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Res
|
||||||
std::iter::once(&output),
|
std::iter::once(&output),
|
||||||
&mut state.backend,
|
&mut state.backend,
|
||||||
&mut state.common.shell,
|
&mut state.common.shell,
|
||||||
|
&state.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
state.common.shell.refresh_outputs();
|
state.common.shell.refresh_outputs();
|
||||||
state.common.config.write_outputs(std::iter::once(&output));
|
state.common.config.write_outputs(std::iter::once(&output));
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Res
|
||||||
std::iter::once(&output),
|
std::iter::once(&output),
|
||||||
&mut state.backend,
|
&mut state.backend,
|
||||||
&mut state.common.shell,
|
&mut state.common.shell,
|
||||||
|
&state.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
state.common.shell.refresh_outputs();
|
state.common.shell.refresh_outputs();
|
||||||
state.common.config.write_outputs(std::iter::once(&output));
|
state.common.config.write_outputs(std::iter::once(&output));
|
||||||
|
|
@ -414,7 +415,8 @@ impl State {
|
||||||
self.process_input_event(event);
|
self.process_input_event(event);
|
||||||
// TODO actually figure out the output
|
// TODO actually figure out the output
|
||||||
for output in self.common.shell.outputs() {
|
for output in self.common.shell.outputs() {
|
||||||
self.backend.schedule_render(output);
|
self.backend
|
||||||
|
.schedule_render(&self.common.event_loop_handle, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{layout::FocusDirection, Shell},
|
shell::{layout::FocusDirection, Shell},
|
||||||
state::BackendData,
|
state::{BackendData, State},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
pub use smithay::{
|
pub use smithay::{
|
||||||
backend::input::KeyState,
|
backend::input::KeyState,
|
||||||
reexports::input::{
|
reexports::{
|
||||||
AccelProfile, ClickMethod, Device as InputDevice, ScrollMethod, SendEventsMode,
|
calloop::LoopHandle,
|
||||||
TapButtonMap,
|
input::{
|
||||||
|
AccelProfile, ClickMethod, Device as InputDevice, ScrollMethod, SendEventsMode,
|
||||||
|
TapButtonMap,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
utils::{Logical, Physical, Point, Size, Transform},
|
utils::{Logical, Physical, Point, Size, Transform},
|
||||||
wayland::{
|
wayland::{
|
||||||
|
|
@ -270,6 +273,7 @@ impl Config {
|
||||||
outputs: impl Iterator<Item = impl std::borrow::Borrow<Output>>,
|
outputs: impl Iterator<Item = impl std::borrow::Borrow<Output>>,
|
||||||
backend: &mut BackendData,
|
backend: &mut BackendData,
|
||||||
shell: &mut Shell,
|
shell: &mut Shell,
|
||||||
|
loop_handle: &LoopHandle<'_, State>,
|
||||||
) {
|
) {
|
||||||
let outputs = outputs.map(|x| x.borrow().clone()).collect::<Vec<_>>();
|
let outputs = outputs.map(|x| x.borrow().clone()).collect::<Vec<_>>();
|
||||||
let mut infos = outputs
|
let mut infos = outputs
|
||||||
|
|
@ -300,7 +304,9 @@ impl Config {
|
||||||
.get::<RefCell<OutputConfig>>()
|
.get::<RefCell<OutputConfig>>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.borrow_mut() = output_config;
|
.borrow_mut() = output_config;
|
||||||
if let Err(err) = backend.apply_config_for_output(&output, false, shell) {
|
if let Err(err) =
|
||||||
|
backend.apply_config_for_output(&output, false, shell, loop_handle)
|
||||||
|
{
|
||||||
slog_scope::warn!(
|
slog_scope::warn!(
|
||||||
"Failed to set new config for output {}: {}",
|
"Failed to set new config for output {}: {}",
|
||||||
output.name(),
|
output.name(),
|
||||||
|
|
@ -322,7 +328,9 @@ impl Config {
|
||||||
.get::<RefCell<OutputConfig>>()
|
.get::<RefCell<OutputConfig>>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.borrow_mut() = output_config;
|
.borrow_mut() = output_config;
|
||||||
if let Err(err) = backend.apply_config_for_output(&output, false, shell) {
|
if let Err(err) =
|
||||||
|
backend.apply_config_for_output(&output, false, shell, loop_handle)
|
||||||
|
{
|
||||||
slog_scope::error!(
|
slog_scope::error!(
|
||||||
"Failed to reset config for output {}: {}",
|
"Failed to reset config for output {}: {}",
|
||||||
output.name(),
|
output.name(),
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ fn main() -> Result<()> {
|
||||||
slog_scope::info!("Cosmic starting up!");
|
slog_scope::info!("Cosmic starting up!");
|
||||||
|
|
||||||
// init event loop
|
// init event loop
|
||||||
let mut event_loop = EventLoop::try_new().with_context(|| "Failed to initialize event loop")?;
|
let mut event_loop =
|
||||||
|
EventLoop::try_new_high_precision().with_context(|| "Failed to initialize event loop")?;
|
||||||
// init wayland
|
// init wayland
|
||||||
let (display, socket) = init_wayland_display(&mut event_loop)?;
|
let (display, socket) = init_wayland_display(&mut event_loop)?;
|
||||||
// init state
|
// init state
|
||||||
|
|
@ -56,7 +57,9 @@ fn main() -> Result<()> {
|
||||||
// do we need to trigger another render
|
// do we need to trigger another render
|
||||||
if state.common.dirty_flag.swap(false, Ordering::SeqCst) {
|
if state.common.dirty_flag.swap(false, Ordering::SeqCst) {
|
||||||
for output in state.common.shell.outputs() {
|
for output in state.common.shell.outputs() {
|
||||||
state.backend.schedule_render(output)
|
state
|
||||||
|
.backend
|
||||||
|
.schedule_render(&state.common.event_loop_handle, output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +86,7 @@ fn init_wayland_display(event_loop: &mut EventLoop<state::State>) -> Result<(Dis
|
||||||
event_loop
|
event_loop
|
||||||
.handle()
|
.handle()
|
||||||
.insert_source(
|
.insert_source(
|
||||||
Generic::from_fd(display.get_poll_fd(), Interest::READ, Mode::Level),
|
Generic::new(display.get_poll_fd(), Interest::READ, Mode::Level),
|
||||||
move |_, _, state: &mut state::State| {
|
move |_, _, state: &mut state::State| {
|
||||||
let display = state.common.display.clone();
|
let display = state.common.display.clone();
|
||||||
let mut display = display.borrow_mut();
|
let mut display = display.borrow_mut();
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,9 @@ fn commit(surface: &WlSurface, state: &mut State) {
|
||||||
// TODO figure out which output the surface is on.
|
// TODO figure out which output the surface is on.
|
||||||
for output in state.common.shell.outputs() {
|
for output in state.common.shell.outputs() {
|
||||||
//.cloned().collect::<Vec<_>>().into_iter() {
|
//.cloned().collect::<Vec<_>>().into_iter() {
|
||||||
state.backend.schedule_render(output);
|
state
|
||||||
|
.backend
|
||||||
|
.schedule_render(&state.common.event_loop_handle, output);
|
||||||
// let space = state.common.spaces.active_space(output);
|
// let space = state.common.spaces.active_space(output);
|
||||||
// get output for surface
|
// get output for surface
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
src/state.rs
13
src/state.rs
|
|
@ -118,10 +118,11 @@ impl BackendData {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
test_only: bool,
|
test_only: bool,
|
||||||
shell: &mut Shell,
|
shell: &mut Shell,
|
||||||
|
loop_handle: &LoopHandle<'_, State>,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
let result = match self {
|
let result = match self {
|
||||||
BackendData::Kms(ref mut state) => {
|
BackendData::Kms(ref mut state) => {
|
||||||
state.apply_config_for_output(output, shell, test_only)
|
state.apply_config_for_output(output, shell, test_only, loop_handle)
|
||||||
}
|
}
|
||||||
BackendData::Winit(ref mut state) => state.apply_config_for_output(output, test_only),
|
BackendData::Winit(ref mut state) => state.apply_config_for_output(output, test_only),
|
||||||
BackendData::X11(ref mut state) => state.apply_config_for_output(output, test_only),
|
BackendData::X11(ref mut state) => state.apply_config_for_output(output, test_only),
|
||||||
|
|
@ -155,13 +156,17 @@ impl BackendData {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_render(&mut self, output: &Output) {
|
pub fn schedule_render(&mut self, loop_handle: &LoopHandle<'_, State>, output: &Output) {
|
||||||
match self {
|
match self {
|
||||||
BackendData::Winit(_) => {} // We cannot do this on the winit backend.
|
BackendData::Winit(_) => {} // We cannot do this on the winit backend.
|
||||||
// Winit has a very strict render-loop and skipping frames breaks atleast the wayland winit-backend.
|
// Winit has a very strict render-loop and skipping frames breaks atleast the wayland winit-backend.
|
||||||
// Swapping with damage (which should be empty on these frames) is likely good enough anyway.
|
// Swapping with damage (which should be empty on these frames) is likely good enough anyway.
|
||||||
BackendData::X11(ref mut state) => state.schedule_render(output),
|
BackendData::X11(ref mut state) => state.schedule_render(output),
|
||||||
BackendData::Kms(ref mut state) => state.schedule_render(output),
|
BackendData::Kms(ref mut state) => {
|
||||||
|
if let Err(err) = state.schedule_render(loop_handle, output) {
|
||||||
|
slog_scope::crit!("Failed to schedule event, are we shutting down? {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => unreachable!("No backend was initialized"),
|
_ => unreachable!("No backend was initialized"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -264,6 +269,7 @@ impl State {
|
||||||
output,
|
output,
|
||||||
test_only,
|
test_only,
|
||||||
&mut state.common.shell,
|
&mut state.common.shell,
|
||||||
|
&state.common.event_loop_handle,
|
||||||
) {
|
) {
|
||||||
slog_scope::warn!(
|
slog_scope::warn!(
|
||||||
"Failed to apply config to {}: {}. Resetting",
|
"Failed to apply config to {}: {}. Resetting",
|
||||||
|
|
@ -284,6 +290,7 @@ impl State {
|
||||||
output,
|
output,
|
||||||
false,
|
false,
|
||||||
&mut state.common.shell,
|
&mut state.common.shell,
|
||||||
|
&state.common.event_loop_handle,
|
||||||
) {
|
) {
|
||||||
slog_scope::error!(
|
slog_scope::error!(
|
||||||
"Failed to reset output config for {}: {}",
|
"Failed to reset output config for {}: {}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue