* widgets on non existing output do not spawn * fix no-x11-wayland build Co-authored-by: Bryan Ndjeutcha <ndjeutcha@gmail.com>
This commit is contained in:
parent
0180914015
commit
8800980011
2 changed files with 41 additions and 37 deletions
60
src/app.rs
60
src/app.rs
|
@ -308,41 +308,43 @@ fn initialize_window(
|
||||||
) -> Result<EwwWindow> {
|
) -> Result<EwwWindow> {
|
||||||
let actual_window_rect = window_def.geometry.get_window_rectangle(monitor_geometry);
|
let actual_window_rect = window_def.geometry.get_window_rectangle(monitor_geometry);
|
||||||
|
|
||||||
let window = display_backend::initialize_window(&window_def, monitor_geometry);
|
if let Some(window) = display_backend::initialize_window(&window_def, monitor_geometry) {
|
||||||
|
window.set_title(&format!("Eww - {}", window_def.name));
|
||||||
|
let wm_class_name = format!("eww-{}", window_def.name);
|
||||||
|
window.set_wmclass(&wm_class_name, &wm_class_name);
|
||||||
|
window.set_position(gtk::WindowPosition::Center);
|
||||||
|
window.set_size_request(actual_window_rect.width, actual_window_rect.height);
|
||||||
|
window.set_default_size(actual_window_rect.width, actual_window_rect.height);
|
||||||
|
window.set_decorated(false);
|
||||||
|
// run on_screen_changed to set the visual correctly initially.
|
||||||
|
on_screen_changed(&window, None);
|
||||||
|
window.connect_screen_changed(on_screen_changed);
|
||||||
|
|
||||||
window.set_title(&format!("Eww - {}", window_def.name));
|
window.add(&root_widget);
|
||||||
let wm_class_name = format!("eww-{}", window_def.name);
|
|
||||||
window.set_wmclass(&wm_class_name, &wm_class_name);
|
|
||||||
window.set_position(gtk::WindowPosition::Center);
|
|
||||||
window.set_size_request(actual_window_rect.width, actual_window_rect.height);
|
|
||||||
window.set_default_size(actual_window_rect.width, actual_window_rect.height);
|
|
||||||
window.set_decorated(false);
|
|
||||||
// run on_screen_changed to set the visual correctly initially.
|
|
||||||
on_screen_changed(&window, None);
|
|
||||||
window.connect_screen_changed(on_screen_changed);
|
|
||||||
|
|
||||||
window.add(&root_widget);
|
window.show_all();
|
||||||
|
|
||||||
window.show_all();
|
apply_window_position(window_def.clone(), monitor_geometry, &window)?;
|
||||||
|
let gdk_window = window.get_window().context("couldn't get gdk window from gtk window")?;
|
||||||
|
gdk_window.set_override_redirect(!window_def.focusable);
|
||||||
|
|
||||||
apply_window_position(window_def.clone(), monitor_geometry, &window)?;
|
#[cfg(feature = "x11")]
|
||||||
let gdk_window = window.get_window().context("couldn't get gdk window from gtk window")?;
|
display_backend::reserve_space_for(&window, monitor_geometry, window_def.struts)?;
|
||||||
gdk_window.set_override_redirect(!window_def.focusable);
|
|
||||||
|
|
||||||
#[cfg(feature = "x11")]
|
// this should only be required on x11, as waylands layershell should manage the margins properly anways.
|
||||||
display_backend::reserve_space_for(&window, monitor_geometry, window_def.struts)?;
|
#[cfg(feature = "x11")]
|
||||||
|
window.connect_configure_event({
|
||||||
|
let window_def = window_def.clone();
|
||||||
|
move |window, _evt| {
|
||||||
|
let _ = apply_window_position(window_def.clone(), monitor_geometry, &window);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ok(EwwWindow { name: window_def.name.clone(), definition: window_def, gtk_window: window })
|
||||||
|
} else {
|
||||||
|
Err(anyhow!("monitor {} is unavailable", window_def.screen_number.unwrap()))
|
||||||
|
}
|
||||||
|
|
||||||
// this should only be required on x11, as waylands layershell should manage the margins properly anways.
|
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
window.connect_configure_event({
|
|
||||||
let window_def = window_def.clone();
|
|
||||||
move |window, _evt| {
|
|
||||||
let _ = apply_window_position(window_def.clone(), monitor_geometry, &window);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(EwwWindow { name: window_def.name.clone(), definition: window_def, gtk_window: window })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply the provided window-positioning rules to the window.
|
/// Apply the provided window-positioning rules to the window.
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod platform {
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use gtk::{self, prelude::*};
|
use gtk::{self, prelude::*};
|
||||||
|
|
||||||
pub fn initialize_window(window_def: &EwwWindowDefinition, _monitor: gdk::Rectangle) -> gtk::Window {
|
pub fn initialize_window(window_def: &EwwWindowDefinition, _monitor: gdk::Rectangle) -> Option<gtk::Window> {
|
||||||
let window = if window_def.focusable {
|
let window = if window_def.focusable {
|
||||||
gtk::Window::new(gtk::WindowType::Toplevel)
|
gtk::Window::new(gtk::WindowType::Toplevel)
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,7 @@ mod platform {
|
||||||
} else {
|
} else {
|
||||||
window.set_keep_below(true);
|
window.set_keep_below(true);
|
||||||
}
|
}
|
||||||
window
|
Some(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reserve_space_for(_window: >k::Window, _monitor: gdk::Rectangle, _strut_def: StrutDefinition) -> Result<()> {
|
pub fn reserve_space_for(_window: >k::Window, _monitor: gdk::Rectangle, _strut_def: StrutDefinition) -> Result<()> {
|
||||||
|
@ -36,7 +36,7 @@ mod platform {
|
||||||
use gdk;
|
use gdk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
|
||||||
pub fn initialize_window(window_def: &EwwWindowDefinition, monitor: gdk::Rectangle) -> gtk::Window {
|
pub fn initialize_window(window_def: &EwwWindowDefinition, monitor: gdk::Rectangle) -> Option<gtk::Window> {
|
||||||
let window = gtk::Window::new(gtk::WindowType::Toplevel);
|
let window = gtk::Window::new(gtk::WindowType::Toplevel);
|
||||||
// Initialising a layer shell surface
|
// Initialising a layer shell surface
|
||||||
gtk_layer_shell::init_for_window(&window);
|
gtk_layer_shell::init_for_window(&window);
|
||||||
|
@ -45,9 +45,11 @@ mod platform {
|
||||||
Some(index) => {
|
Some(index) => {
|
||||||
if let Some(monitor) = gdk::Display::get_default().expect("could not get default display").get_monitor(index) {
|
if let Some(monitor) = gdk::Display::get_default().expect("could not get default display").get_monitor(index) {
|
||||||
gtk_layer_shell::set_monitor(&window, &monitor);
|
gtk_layer_shell::set_monitor(&window, &monitor);
|
||||||
};
|
} else {
|
||||||
|
return None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
None => {},
|
||||||
};
|
};
|
||||||
window.set_resizable(true);
|
window.set_resizable(true);
|
||||||
|
|
||||||
|
@ -100,7 +102,7 @@ mod platform {
|
||||||
if window_def.exclusive {
|
if window_def.exclusive {
|
||||||
gtk_layer_shell::auto_exclusive_zone_enable(&window);
|
gtk_layer_shell::auto_exclusive_zone_enable(&window);
|
||||||
}
|
}
|
||||||
window
|
Some(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +121,7 @@ mod platform {
|
||||||
rust_connection::{DefaultStream, RustConnection},
|
rust_connection::{DefaultStream, RustConnection},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn initialize_window(window_def: &EwwWindowDefinition, _monitor: gdk::Rectangle) -> gtk::Window {
|
pub fn initialize_window(window_def: &EwwWindowDefinition, _monitor: gdk::Rectangle) -> Option<gtk::Window> {
|
||||||
let window = if window_def.focusable {
|
let window = if window_def.focusable {
|
||||||
gtk::Window::new(gtk::WindowType::Toplevel)
|
gtk::Window::new(gtk::WindowType::Toplevel)
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,7 +136,7 @@ mod platform {
|
||||||
} else {
|
} else {
|
||||||
window.set_keep_below(true);
|
window.set_keep_below(true);
|
||||||
}
|
}
|
||||||
window
|
Some(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reserve_space_for(window: >k::Window, monitor: gdk::Rectangle, strut_def: StrutDefinition) -> Result<()> {
|
pub fn reserve_space_for(window: >k::Window, monitor: gdk::Rectangle, strut_def: StrutDefinition) -> Result<()> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue