Compare commits
2 Commits
9bbf6db11c
...
ae2f100b38
Author | SHA1 | Date | |
---|---|---|---|
ae2f100b38 | |||
3c48ab1c7f |
1381
Cargo.lock
generated
1381
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -10,11 +10,3 @@ members = [
|
||||
"systemd",
|
||||
"xcb-xembed",
|
||||
]
|
||||
|
||||
[patch.crates-io]
|
||||
# git source needed until extension event error resolution fix is released
|
||||
xcb = { git = "https://github.com/rust-x-bindings/rust-xcb", rev = "d09b5f91bc07d56673f1bc0d6c7ecd72b5ff7b3e" }
|
||||
# xkb package depends on xcb 0.9
|
||||
xkb = { git = "https://github.com/kelnos/rust-xkb", branch = "xcb-1.x" }
|
||||
# Build error in v0.7.5 when x11 feature enabled
|
||||
ffi = { package = "xkbcommon-sys", git = "https://github.com/kelnos/rust-xkbcommon-sys", branch = "release-0.7.x" }
|
||||
|
@ -5,11 +5,11 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
async-std = { version = "1.11", features = ["attributes"] }
|
||||
async-std = { version = "1", features = ["attributes"] }
|
||||
async-xcb = { path = "../async-xcb" }
|
||||
bscreensaver-command = { path = "../command" }
|
||||
bscreensaver-util = { path = "../util" }
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
xcb = { version = "1", features = ["dpms"] }
|
||||
zbus = "2"
|
||||
zbus = "3"
|
||||
|
@ -77,6 +77,14 @@ fn main() -> anyhow::Result<()> {
|
||||
init_logging("BSCREENSAVER_DIALOG_GTK3_LOG");
|
||||
glib::log_set_default_handler(glib::rust_log_handler);
|
||||
|
||||
// Can't use the rust version as it requires gtk_init() to be
|
||||
// called first, but the underlying C function requires that
|
||||
// it hasn't.
|
||||
let backends = CString::new("x11").unwrap();
|
||||
unsafe {
|
||||
gtk::gdk::ffi::gdk_set_allowed_backends(backends.as_ptr());
|
||||
};
|
||||
|
||||
let config = Configuration::load()?;
|
||||
let new_login_command =
|
||||
if config.new_login_command == NewLoginCommand::Disabled {
|
||||
|
@ -50,4 +50,5 @@ log = "0.4"
|
||||
nix = "0.23"
|
||||
xcb = { version = "1", features = ["randr", "xkb", "xfixes", "xinput"] }
|
||||
xcb-xembed = { path = "../xcb-xembed" }
|
||||
xkb = { version = "0.2", features = ["x11"] }
|
||||
xkb = { version = "0.3", features = ["x11"] }
|
||||
xkbcommon-sys = { version = "1", feature = "x11" }
|
||||
|
@ -2,6 +2,7 @@ pub(crate) mod monitor;
|
||||
pub(crate) mod pidfd;
|
||||
pub mod screensaver;
|
||||
pub mod subservice;
|
||||
pub mod xkb_ext;
|
||||
|
||||
use log::{debug, info};
|
||||
use xcb::{x, XidNew};
|
||||
|
@ -21,7 +21,7 @@ use std::{
|
||||
};
|
||||
use xcb::{randr, x, xfixes, xinput};
|
||||
|
||||
use bscreensaver::{screensaver::{BlankerState, CommandHandlers, Screensaver}, subservice::Subservices};
|
||||
use bscreensaver::{screensaver::{BlankerState, CommandHandlers, Screensaver}, subservice::Subservices, xkb_ext};
|
||||
use bscreensaver_util::{*, settings::Configuration};
|
||||
|
||||
const BLANKED_ARG: &str = "blanked";
|
||||
@ -71,7 +71,7 @@ fn main() -> anyhow::Result<()> {
|
||||
init_xfixes(&conn)?;
|
||||
init_xinput(&conn)?;
|
||||
init_randr(&conn)?;
|
||||
xkb::x11::setup(&conn, xkb::x11::MIN_MAJOR_XKB_VERSION, xkb::x11::MIN_MINOR_XKB_VERSION, xkb::x11::NO_FLAGS)
|
||||
xkb_ext::x11_setup(&conn, xkb::x11::MIN_MAJOR_XKB_VERSION, xkb::x11::MIN_MINOR_XKB_VERSION)
|
||||
.map_err(|_| anyhow::anyhow!("Failed to initialize XKB extension"))?;
|
||||
|
||||
let helper_dir = PathBuf::from(env!("HELPER_DIR"));
|
||||
|
28
locker/src/xkb_ext.rs
Normal file
28
locker/src/xkb_ext.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
#[inline]
|
||||
pub fn x11_setup(connection: &xcb::Connection, major_version: u16, minor_version: u16) -> Result<(u16, u16, u8, u8), ()> {
|
||||
let mut actual_major = MaybeUninit::uninit();
|
||||
let mut actual_minor = MaybeUninit::uninit();
|
||||
let mut base_event = MaybeUninit::uninit();
|
||||
let mut base_error = MaybeUninit::uninit();
|
||||
|
||||
let ret = unsafe {
|
||||
xkbcommon_sys::xkb_x11_setup_xkb_extension(
|
||||
connection.get_raw_conn() as *mut _,
|
||||
major_version,
|
||||
minor_version,
|
||||
xkbcommon_sys::XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
|
||||
actual_major.as_mut_ptr(),
|
||||
actual_minor.as_mut_ptr(),
|
||||
base_event.as_mut_ptr(),
|
||||
base_error.as_mut_ptr()
|
||||
)
|
||||
};
|
||||
|
||||
if ret != 1 {
|
||||
Err(())
|
||||
} else {
|
||||
Ok(unsafe { (actual_major.assume_init(), actual_minor.assume_init(), base_event.assume_init(), base_error.assume_init()) })
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
use gtk::{glib, prelude::*};
|
||||
use glib::clone;
|
||||
use log::warn;
|
||||
use std::{env, process::exit, time::Duration};
|
||||
use std::{env, process::exit, time::Duration, ffi::CString};
|
||||
|
||||
use bscreensaver_util::{init_logging, settings::Configuration, desktop::NewLoginCommand};
|
||||
|
||||
@ -18,6 +18,14 @@ fn main() -> anyhow::Result<()> {
|
||||
init_logging("BSCREENSAVER_SETTINGS");
|
||||
let config = Configuration::load()?;
|
||||
|
||||
// Can't use the rust version as it requires gtk_init() to be
|
||||
// called first, but the underlying C function requires that
|
||||
// it hasn't.
|
||||
let backends = CString::new("x11").unwrap();
|
||||
unsafe {
|
||||
gtk::gdk::ffi::gdk_set_allowed_backends(backends.as_ptr());
|
||||
};
|
||||
|
||||
let app = gtk::Application::builder()
|
||||
.application_id("org.spurint.bscreensaver-settings")
|
||||
.build();
|
||||
|
@ -13,5 +13,5 @@ futures = "0.3"
|
||||
log = "0.4"
|
||||
nix = "0.23"
|
||||
xcb = "1"
|
||||
zbus = "2.2"
|
||||
zbus = "3"
|
||||
logind-zbus = "3"
|
||||
|
@ -16,4 +16,4 @@ shell-words = "1"
|
||||
toml = "0.5"
|
||||
xcb = "1"
|
||||
xdg = "2"
|
||||
zbus = "2"
|
||||
zbus = "3"
|
||||
|
Loading…
Reference in New Issue
Block a user