mirror of
https://github.com/elkowar/eww.git
synced 2024-08-16 23:30:34 +03:00
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
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -21,12 +21,12 @@ jobs:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Build x11
|
||||
run: cargo --no-default-features --features=x11 check
|
||||
run: cargo check --no-default-features --features=x11
|
||||
- name: Build wayland
|
||||
run: cargo --no-default-features --features=wayland check
|
||||
run: cargo check --no-default-features --features=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
|
||||
|
||||
|
18
gen-docs.ts
18
gen-docs.ts
@ -15,9 +15,9 @@ interface Widget {
|
||||
function parseVars(code: string): Record<string, string> {
|
||||
const VAR_PATTERN = /^.*\/\/+ *@var +(.*?) +- +(.*)$/;
|
||||
const vars: Record<string, string> = {};
|
||||
|
||||
|
||||
for (const line of code.split("\n")) {
|
||||
|
||||
|
||||
const match = line.match(VAR_PATTERN);
|
||||
if (match && match.length == 3) {
|
||||
const name = match[1];
|
||||
@ -50,12 +50,12 @@ function parseDocs(code: string) {
|
||||
const ARG_TYPE_PATTERN = /(\w+):\s+as_(\w+)/g;
|
||||
|
||||
const widgets: Record<string, Widget> = {};
|
||||
const lines = code.split("\n")
|
||||
|
||||
const lines = code.split("\n")
|
||||
|
||||
let currentWidget = "";
|
||||
|
||||
|
||||
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
||||
|
||||
|
||||
const line = lines[lineIndex]
|
||||
const newWidgetMatch = NEW_WIDGET_PATTERN.exec(line);
|
||||
|
||||
@ -85,13 +85,13 @@ function parseDocs(code: string) {
|
||||
const propMatch = line.match(PROP_PATTERN);
|
||||
if (propMatch && propMatch.length == 3) {
|
||||
let no = lineIndex + 1
|
||||
|
||||
|
||||
while (/\s*\/\//.test(lines[no])) {
|
||||
no += 1
|
||||
} // continue till you find the line with actual code
|
||||
|
||||
|
||||
const matches = [...lines[no].matchAll(ARG_TYPE_PATTERN)].map(z => { z.shift(); return z }).flat() // try to use the iterator directly
|
||||
|
||||
|
||||
const possibleMatch = matches.findIndex(x => x == propMatch[1].replaceAll("-", "_"))
|
||||
if (possibleMatch == -1) {
|
||||
console.log(`Failed to find a match for "${propMatch[1].replace("-", "_")}" ~ ${JSON.stringify(matches, null, 2)} ~ ${lines[no]}`)
|
||||
|
@ -9,7 +9,6 @@ use super::*;
|
||||
|
||||
/// Full window-definition containing the fully expanded widget tree.
|
||||
/// **Use this** rather than `[RawEwwWindowDefinition]`.
|
||||
#[cfg(feature = "x11")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EwwWindowDefinition {
|
||||
pub name: WindowName,
|
||||
@ -17,20 +16,13 @@ pub struct EwwWindowDefinition {
|
||||
pub stacking: WindowStacking,
|
||||
pub screen_number: Option<i32>,
|
||||
pub widget: Box<dyn widget_node::WidgetNode>,
|
||||
pub struts: StrutDefinition,
|
||||
pub focusable: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EwwWindowDefinition {
|
||||
pub name: WindowName,
|
||||
pub geometry: EwwWindowGeometry,
|
||||
pub stacking: WindowStacking,
|
||||
pub screen_number: Option<i32>,
|
||||
pub widget: Box<dyn widget_node::WidgetNode>,
|
||||
#[cfg(feature = "x11")]
|
||||
pub struts: StrutDefinition,
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub exclusive: bool,
|
||||
pub focusable: bool,
|
||||
}
|
||||
|
||||
impl EwwWindowDefinition {
|
||||
@ -51,7 +43,6 @@ impl EwwWindowDefinition {
|
||||
}
|
||||
|
||||
/// Window-definition storing the raw WidgetUse, as received directly from parsing.
|
||||
#[cfg(feature = "x11")]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RawEwwWindowDefinition {
|
||||
pub name: WindowName,
|
||||
@ -59,20 +50,13 @@ pub struct RawEwwWindowDefinition {
|
||||
pub stacking: WindowStacking,
|
||||
pub screen_number: Option<i32>,
|
||||
pub widget: WidgetUse,
|
||||
pub struts: StrutDefinition,
|
||||
pub focusable: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RawEwwWindowDefinition {
|
||||
pub name: WindowName,
|
||||
#[cfg(feature = "x11")]
|
||||
pub struts: StrutDefinition,
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub exclusive: bool,
|
||||
pub geometry: EwwWindowGeometry,
|
||||
pub stacking: WindowStacking,
|
||||
pub screen_number: Option<i32>,
|
||||
pub widget: WidgetUse,
|
||||
pub focusable: bool,
|
||||
}
|
||||
|
||||
impl RawEwwWindowDefinition {
|
||||
@ -118,7 +102,6 @@ pub enum Side {
|
||||
impl std::str::FromStr for Side {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
fn from_str(s: &str) -> Result<Side> {
|
||||
match s {
|
||||
"l" | "left" => Ok(Side::Left),
|
||||
@ -131,14 +114,12 @@ impl std::str::FromStr for Side {
|
||||
}
|
||||
|
||||
// Surface definition if the backend for X11 is enable
|
||||
#[cfg(feature = "x11")]
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||
pub struct StrutDefinition {
|
||||
pub side: Side,
|
||||
pub dist: NumWithUnit,
|
||||
}
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
impl StrutDefinition {
|
||||
pub fn from_xml_element(xml: XmlElement) -> Result<Self> {
|
||||
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 {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
#[cfg(not(feature = "wayland"))]
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
let s = s.to_lowercase();
|
||||
match s.as_str() {
|
||||
|
@ -2,20 +2,38 @@ pub use platform::*;
|
||||
|
||||
#[cfg(feature = "no-x11-wayland")]
|
||||
mod platform {
|
||||
use crate::config::{Side, StrutDefinition};
|
||||
use crate::config::{EwwWindowDefinition, StrutDefinition, WindowStacking};
|
||||
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"))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
mod platform {
|
||||
use gdk;
|
||||
use crate::{
|
||||
config::{EwwWindowDefinition, AnchorAlignment, Side, WindowStacking},
|
||||
};
|
||||
use crate::config::{AnchorAlignment, EwwWindowDefinition, Side, WindowStacking};
|
||||
use anyhow::*;
|
||||
use gdk;
|
||||
use gtk::prelude::*;
|
||||
|
||||
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
|
||||
match window_def.screen_number {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user