Ensure gtk apps only run on X11
This commit is contained in:
parent
3c48ab1c7f
commit
ae2f100b38
@ -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 {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user