Fix no-x11-wayland build (#160)
* test-commit * Update workflow * add cache to rust build * Fix wayland build * Fix no-x11-wayland build
This commit is contained in:
parent
2f433878c2
commit
907f39cf86
4 changed files with 47 additions and 50 deletions
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
|
@ -21,12 +21,12 @@ jobs:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- uses: Swatinem/rust-cache@v1
|
||||||
- name: Build x11
|
- name: Build x11
|
||||||
run: cargo --no-default-features --features=x11 check
|
run: cargo check --no-default-features --features=x11
|
||||||
- name: Build wayland
|
- name: Build wayland
|
||||||
run: cargo --no-default-features --features=wayland check
|
run: cargo check --no-default-features --features=wayland
|
||||||
- name: Build no-x11-wayland
|
- name: Build no-x11-wayland
|
||||||
run: cargo --no-default-features --features=no-x11-wayland check
|
run: cargo check --no-default-features --features=no-x11-wayland
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ use super::*;
|
||||||
|
|
||||||
/// Full window-definition containing the fully expanded widget tree.
|
/// Full window-definition containing the fully expanded widget tree.
|
||||||
/// **Use this** rather than `[RawEwwWindowDefinition]`.
|
/// **Use this** rather than `[RawEwwWindowDefinition]`.
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct EwwWindowDefinition {
|
pub struct EwwWindowDefinition {
|
||||||
pub name: WindowName,
|
pub name: WindowName,
|
||||||
|
@ -17,20 +16,13 @@ pub struct EwwWindowDefinition {
|
||||||
pub stacking: WindowStacking,
|
pub stacking: WindowStacking,
|
||||||
pub screen_number: Option<i32>,
|
pub screen_number: Option<i32>,
|
||||||
pub widget: Box<dyn widget_node::WidgetNode>,
|
pub widget: Box<dyn widget_node::WidgetNode>,
|
||||||
pub struts: StrutDefinition,
|
|
||||||
pub focusable: bool,
|
pub focusable: bool,
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "x11")]
|
||||||
#[derive(Debug, Clone)]
|
pub struts: StrutDefinition,
|
||||||
pub struct EwwWindowDefinition {
|
|
||||||
pub name: WindowName,
|
#[cfg(feature = "wayland")]
|
||||||
pub geometry: EwwWindowGeometry,
|
|
||||||
pub stacking: WindowStacking,
|
|
||||||
pub screen_number: Option<i32>,
|
|
||||||
pub widget: Box<dyn widget_node::WidgetNode>,
|
|
||||||
pub exclusive: bool,
|
pub exclusive: bool,
|
||||||
pub focusable: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EwwWindowDefinition {
|
impl EwwWindowDefinition {
|
||||||
|
@ -51,7 +43,6 @@ impl EwwWindowDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Window-definition storing the raw WidgetUse, as received directly from parsing.
|
/// Window-definition storing the raw WidgetUse, as received directly from parsing.
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct RawEwwWindowDefinition {
|
pub struct RawEwwWindowDefinition {
|
||||||
pub name: WindowName,
|
pub name: WindowName,
|
||||||
|
@ -59,20 +50,13 @@ pub struct RawEwwWindowDefinition {
|
||||||
pub stacking: WindowStacking,
|
pub stacking: WindowStacking,
|
||||||
pub screen_number: Option<i32>,
|
pub screen_number: Option<i32>,
|
||||||
pub widget: WidgetUse,
|
pub widget: WidgetUse,
|
||||||
pub struts: StrutDefinition,
|
|
||||||
pub focusable: bool,
|
pub focusable: bool,
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "x11")]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
pub struts: StrutDefinition,
|
||||||
pub struct RawEwwWindowDefinition {
|
|
||||||
pub name: WindowName,
|
#[cfg(feature = "wayland")]
|
||||||
pub exclusive: bool,
|
pub exclusive: bool,
|
||||||
pub geometry: EwwWindowGeometry,
|
|
||||||
pub stacking: WindowStacking,
|
|
||||||
pub screen_number: Option<i32>,
|
|
||||||
pub widget: WidgetUse,
|
|
||||||
pub focusable: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RawEwwWindowDefinition {
|
impl RawEwwWindowDefinition {
|
||||||
|
@ -118,7 +102,6 @@ pub enum Side {
|
||||||
impl std::str::FromStr for Side {
|
impl std::str::FromStr for Side {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
fn from_str(s: &str) -> Result<Side> {
|
fn from_str(s: &str) -> Result<Side> {
|
||||||
match s {
|
match s {
|
||||||
"l" | "left" => Ok(Side::Left),
|
"l" | "left" => Ok(Side::Left),
|
||||||
|
@ -131,14 +114,12 @@ impl std::str::FromStr for Side {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Surface definition if the backend for X11 is enable
|
// Surface definition if the backend for X11 is enable
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct StrutDefinition {
|
pub struct StrutDefinition {
|
||||||
pub side: Side,
|
pub side: Side,
|
||||||
pub dist: NumWithUnit,
|
pub dist: NumWithUnit,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
impl StrutDefinition {
|
impl StrutDefinition {
|
||||||
pub fn from_xml_element(xml: XmlElement) -> Result<Self> {
|
pub fn from_xml_element(xml: XmlElement) -> Result<Self> {
|
||||||
Ok(StrutDefinition { side: xml.attr("side")?.parse()?, dist: xml.attr("distance")?.parse()? })
|
Ok(StrutDefinition { side: xml.attr("side")?.parse()?, dist: xml.attr("distance")?.parse()? })
|
||||||
|
@ -157,7 +138,7 @@ pub enum WindowStacking {
|
||||||
impl std::str::FromStr for WindowStacking {
|
impl std::str::FromStr for WindowStacking {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
#[cfg(feature = "x11")]
|
#[cfg(not(feature = "wayland"))]
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
let s = s.to_lowercase();
|
let s = s.to_lowercase();
|
||||||
match s.as_str() {
|
match s.as_str() {
|
||||||
|
|
|
@ -2,20 +2,38 @@ pub use platform::*;
|
||||||
|
|
||||||
#[cfg(feature = "no-x11-wayland")]
|
#[cfg(feature = "no-x11-wayland")]
|
||||||
mod platform {
|
mod platform {
|
||||||
use crate::config::{Side, StrutDefinition};
|
use crate::config::{EwwWindowDefinition, StrutDefinition, WindowStacking};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
pub fn reserve_space_for(window: >k::Window, monitor: gdk::Rectangle, strut_def: StrutDefinition) -> Result<()> {
|
use gtk::{self, prelude::*};
|
||||||
|
|
||||||
|
pub fn initialize_window(window_def: &mut EwwWindowDefinition, _monitor: gdk::Rectangle) -> gtk::Window {
|
||||||
|
let window = if window_def.focusable {
|
||||||
|
gtk::Window::new(gtk::WindowType::Toplevel)
|
||||||
|
} else {
|
||||||
|
gtk::Window::new(gtk::WindowType::Popup)
|
||||||
|
};
|
||||||
|
window.set_resizable(true);
|
||||||
|
if !window_def.focusable {
|
||||||
|
window.set_type_hint(gdk::WindowTypeHint::Dock);
|
||||||
|
}
|
||||||
|
if window_def.stacking == WindowStacking::Foreground {
|
||||||
|
window.set_keep_above(true);
|
||||||
|
} else {
|
||||||
|
window.set_keep_below(true);
|
||||||
|
}
|
||||||
|
window
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reserve_space_for(_window: >k::Window, _monitor: gdk::Rectangle, _strut_def: StrutDefinition) -> Result<()> {
|
||||||
Err(anyhow!("Cannot reserve space on non X11 or and wayland backends"))
|
Err(anyhow!("Cannot reserve space on non X11 or and wayland backends"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
mod platform {
|
mod platform {
|
||||||
use gdk;
|
use crate::config::{AnchorAlignment, EwwWindowDefinition, Side, WindowStacking};
|
||||||
use crate::{
|
|
||||||
config::{EwwWindowDefinition, AnchorAlignment, Side, WindowStacking},
|
|
||||||
};
|
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
|
use gdk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
|
||||||
pub fn initialize_window(window_def: &mut EwwWindowDefinition, monitor: gdk::Rectangle) -> gtk::Window {
|
pub fn initialize_window(window_def: &mut EwwWindowDefinition, monitor: gdk::Rectangle) -> gtk::Window {
|
||||||
|
@ -25,9 +43,7 @@ mod platform {
|
||||||
// Sets the monitor where the surface is shown
|
// Sets the monitor where the surface is shown
|
||||||
match window_def.screen_number {
|
match window_def.screen_number {
|
||||||
Some(index) => {
|
Some(index) => {
|
||||||
if let Some(monitor) = gdk::Display::get_default()
|
if let Some(monitor) = gdk::Display::get_default().expect("could not get default display").get_monitor(index) {
|
||||||
.expect("could not get default display")
|
|
||||||
.get_monitor(index) {
|
|
||||||
gtk_layer_shell::set_monitor(&window, &monitor);
|
gtk_layer_shell::set_monitor(&window, &monitor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue