mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-10-28 23:04:22 +00:00
refactor: extract layer surface params
This commit is contained in:
parent
0b964e0a51
commit
55e85a1e95
2 changed files with 28 additions and 11 deletions
|
|
@ -12,6 +12,15 @@ pub struct Margins {
|
||||||
pub left: i32,
|
pub left: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct LayerSurfaceParams {
|
||||||
|
pub anchor: Anchor,
|
||||||
|
pub margin: Margins,
|
||||||
|
pub exclusive_zone: i32,
|
||||||
|
pub keyboard_interactivity: KeyboardInteractivity,
|
||||||
|
pub height: u32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WindowConfig {
|
pub struct WindowConfig {
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
errors::{LayerShikaError, Result},
|
errors::{LayerShikaError, Result},
|
||||||
rendering::{egl_context::EGLContext, femtovg_window::FemtoVGWindow},
|
rendering::{egl_context::EGLContext, femtovg_window::FemtoVGWindow},
|
||||||
};
|
};
|
||||||
use config::WindowConfig;
|
use config::{LayerSurfaceParams, WindowConfig};
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use slint::{
|
use slint::{
|
||||||
platform::{femtovg_renderer::FemtoVGRenderer, update_timers_and_animations},
|
platform::{femtovg_renderer::FemtoVGRenderer, update_timers_and_animations},
|
||||||
|
|
@ -193,7 +193,15 @@ impl WindowingSystem {
|
||||||
Rc::new(vp.get_viewport(&surface, queue_handle, ()))
|
Rc::new(vp.get_viewport(&surface, queue_handle, ()))
|
||||||
});
|
});
|
||||||
|
|
||||||
Self::configure_layer_surface(&layer_surface, &surface, config);
|
let params = LayerSurfaceParams {
|
||||||
|
anchor: config.anchor,
|
||||||
|
margin: config.margin,
|
||||||
|
exclusive_zone: config.exclusive_zone,
|
||||||
|
keyboard_interactivity: config.keyboard_interactivity,
|
||||||
|
height: config.height,
|
||||||
|
};
|
||||||
|
|
||||||
|
Self::configure_layer_surface(&layer_surface, &surface, ¶ms);
|
||||||
|
|
||||||
surface.set_buffer_scale(1);
|
surface.set_buffer_scale(1);
|
||||||
|
|
||||||
|
|
@ -208,19 +216,19 @@ impl WindowingSystem {
|
||||||
fn configure_layer_surface(
|
fn configure_layer_surface(
|
||||||
layer_surface: &Rc<ZwlrLayerSurfaceV1>,
|
layer_surface: &Rc<ZwlrLayerSurfaceV1>,
|
||||||
surface: &WlSurface,
|
surface: &WlSurface,
|
||||||
config: &WindowConfig,
|
params: &LayerSurfaceParams,
|
||||||
) {
|
) {
|
||||||
layer_surface.set_anchor(config.anchor);
|
layer_surface.set_anchor(params.anchor);
|
||||||
layer_surface.set_margin(
|
layer_surface.set_margin(
|
||||||
config.margin.top,
|
params.margin.top,
|
||||||
config.margin.right,
|
params.margin.right,
|
||||||
config.margin.bottom,
|
params.margin.bottom,
|
||||||
config.margin.left,
|
params.margin.left,
|
||||||
);
|
);
|
||||||
|
|
||||||
layer_surface.set_exclusive_zone(config.exclusive_zone);
|
layer_surface.set_exclusive_zone(params.exclusive_zone);
|
||||||
layer_surface.set_keyboard_interactivity(config.keyboard_interactivity);
|
layer_surface.set_keyboard_interactivity(params.keyboard_interactivity);
|
||||||
layer_surface.set_size(1, config.height);
|
layer_surface.set_size(1, params.height);
|
||||||
surface.commit();
|
surface.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue