mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-11-17 23:14:23 +00:00
refactor: remove unused
This commit is contained in:
parent
cc6e82b914
commit
69b56d59ae
11 changed files with 2 additions and 120 deletions
|
|
@ -66,10 +66,6 @@ impl RenderableWindow for FemtoVGWindow {
|
||||||
fn size_cell(&self) -> &Cell<PhysicalSize> {
|
fn size_cell(&self) -> &Cell<PhysicalSize> {
|
||||||
&self.size
|
&self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scale_factor_cell(&self) -> &Cell<f32> {
|
|
||||||
&self.scale_factor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowAdapter for FemtoVGWindow {
|
impl WindowAdapter for FemtoVGWindow {
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,6 @@ impl RenderableWindow for PopupWindow {
|
||||||
fn size_cell(&self) -> &Cell<PhysicalSize> {
|
fn size_cell(&self) -> &Cell<PhysicalSize> {
|
||||||
&self.size
|
&self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scale_factor_cell(&self) -> &Cell<f32> {
|
|
||||||
&self.scale_factor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowAdapter for PopupWindow {
|
impl WindowAdapter for PopupWindow {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ pub trait RenderableWindow: WindowAdapter {
|
||||||
fn scale_factor(&self) -> f32;
|
fn scale_factor(&self) -> f32;
|
||||||
fn render_state(&self) -> &Cell<RenderState>;
|
fn render_state(&self) -> &Cell<RenderState>;
|
||||||
fn size_cell(&self) -> &Cell<PhysicalSize>;
|
fn size_cell(&self) -> &Cell<PhysicalSize>;
|
||||||
fn scale_factor_cell(&self) -> &Cell<f32>;
|
|
||||||
|
|
||||||
fn request_redraw(&self) {
|
fn request_redraw(&self) {
|
||||||
self.render_state().set(RenderState::Dirty);
|
self.render_state().set(RenderState::Dirty);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
use crate::errors::Result;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use wayland_client::{Connection, EventQueue};
|
|
||||||
|
|
||||||
pub fn initialize_wayland<S>() -> Result<(Rc<Connection>, EventQueue<S>)> {
|
|
||||||
let connection = Rc::new(Connection::connect_to_env()?);
|
|
||||||
let event_queue = connection.new_event_queue();
|
|
||||||
Ok((connection, event_queue))
|
|
||||||
}
|
|
||||||
|
|
@ -20,10 +20,6 @@ impl ManagedWlPointer {
|
||||||
connection,
|
connection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn inner(&self) -> &Rc<WlPointer> {
|
|
||||||
&self.pointer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for ManagedWlPointer {
|
impl Deref for ManagedWlPointer {
|
||||||
|
|
@ -57,10 +53,6 @@ impl ManagedWlSurface {
|
||||||
connection,
|
connection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn inner(&self) -> &Rc<WlSurface> {
|
|
||||||
&self.surface
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for ManagedWlSurface {
|
impl Deref for ManagedWlSurface {
|
||||||
|
|
@ -171,10 +163,6 @@ impl ManagedWpViewport {
|
||||||
connection,
|
connection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn inner(&self) -> &Rc<WpViewport> {
|
|
||||||
&self.viewport
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for ManagedWpViewport {
|
impl Deref for ManagedWpViewport {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
pub(crate) mod config;
|
pub(crate) mod config;
|
||||||
pub(crate) mod connection;
|
|
||||||
pub(crate) mod event_handling;
|
pub(crate) mod event_handling;
|
||||||
pub(crate) mod globals;
|
pub(crate) mod globals;
|
||||||
pub(crate) mod managed_proxies;
|
pub(crate) mod managed_proxies;
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,10 @@ impl EventBus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscribe<F>(&self, handler: F)
|
|
||||||
where
|
|
||||||
F: Fn(&WindowStateEvent) + 'static,
|
|
||||||
{
|
|
||||||
self.handlers.borrow_mut().push(Box::new(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn publish(&self, event: &WindowStateEvent) {
|
pub fn publish(&self, event: &WindowStateEvent) {
|
||||||
let handlers = self.handlers.borrow();
|
let handlers = self.handlers.borrow();
|
||||||
for handler in handlers.iter() {
|
for handler in handlers.iter() {
|
||||||
handler(event);
|
handler(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&self) {
|
|
||||||
self.handlers.borrow_mut().clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,6 @@ impl EventContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_event_bus(&mut self, event_bus: EventBus) {
|
|
||||||
self.event_bus = event_bus;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn event_bus(&self) -> &EventBus {
|
|
||||||
&self.event_bus
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_popup_manager(&mut self, popup_manager: Rc<PopupManager>) {
|
pub fn set_popup_manager(&mut self, popup_manager: Rc<PopupManager>) {
|
||||||
self.popup_manager = Some(popup_manager);
|
self.popup_manager = Some(popup_manager);
|
||||||
self.event_bus
|
self.event_bus
|
||||||
|
|
@ -89,10 +81,6 @@ impl EventContext {
|
||||||
self.display_metrics.borrow().scale_factor()
|
self.display_metrics.borrow().scale_factor()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn display_metrics(&self) -> &SharedDisplayMetrics {
|
|
||||||
&self.display_metrics
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(clippy::cast_precision_loss)]
|
#[allow(clippy::cast_precision_loss)]
|
||||||
pub fn update_scale_factor(&mut self, scale_120ths: u32) -> f32 {
|
pub fn update_scale_factor(&mut self, scale_120ths: u32) -> f32 {
|
||||||
let new_scale_factor = self
|
let new_scale_factor = self
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
use crate::rendering::femtovg::main_window::FemtoVGWindow;
|
|
||||||
use crate::wayland::surfaces::popup_manager::{ActiveWindow, PopupManager};
|
|
||||||
use slint::platform::{WindowAdapter, WindowEvent};
|
|
||||||
use std::rc::Rc;
|
|
||||||
use wayland_client::{backend::ObjectId, protocol::wl_surface::WlSurface};
|
|
||||||
|
|
||||||
pub struct EventRouter {
|
|
||||||
main_window: Rc<FemtoVGWindow>,
|
|
||||||
popup_manager: Option<Rc<PopupManager>>,
|
|
||||||
main_surface_id: ObjectId,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventRouter {
|
|
||||||
#[must_use]
|
|
||||||
pub const fn new(main_window: Rc<FemtoVGWindow>, main_surface_id: ObjectId) -> Self {
|
|
||||||
Self {
|
|
||||||
main_window,
|
|
||||||
popup_manager: None,
|
|
||||||
main_surface_id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_popup_manager(&mut self, popup_manager: Rc<PopupManager>) {
|
|
||||||
self.popup_manager = Some(popup_manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dispatch_to_active_window(&self, event: WindowEvent, surface: &WlSurface) {
|
|
||||||
if let Some(popup_manager) = &self.popup_manager {
|
|
||||||
match popup_manager.get_active_window(surface, &self.main_surface_id) {
|
|
||||||
ActiveWindow::Main => {
|
|
||||||
self.main_window.window().dispatch_event(event);
|
|
||||||
}
|
|
||||||
ActiveWindow::Popup(index) => {
|
|
||||||
if let Some(popup_window) = popup_manager.get_popup_window(index) {
|
|
||||||
popup_window.dispatch_event(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ActiveWindow::None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,6 @@ pub mod dimensions;
|
||||||
pub mod display_metrics;
|
pub mod display_metrics;
|
||||||
pub mod event_bus;
|
pub mod event_bus;
|
||||||
pub mod event_context;
|
pub mod event_context;
|
||||||
pub mod event_router;
|
|
||||||
pub mod layer_surface;
|
pub mod layer_surface;
|
||||||
pub mod popup_manager;
|
pub mod popup_manager;
|
||||||
pub mod popup_surface;
|
pub mod popup_surface;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use slint::PhysicalSize;
|
use slint::PhysicalSize;
|
||||||
use wayland_client::backend::ObjectId;
|
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum WindowStateEvent {
|
pub enum WindowStateEvent {
|
||||||
ScaleFactorChanged {
|
ScaleFactorChanged {
|
||||||
|
|
@ -8,11 +8,6 @@ pub enum WindowStateEvent {
|
||||||
source: ScaleSource,
|
source: ScaleSource,
|
||||||
},
|
},
|
||||||
|
|
||||||
SizeChanged {
|
|
||||||
logical_width: u32,
|
|
||||||
logical_height: u32,
|
|
||||||
},
|
|
||||||
|
|
||||||
OutputSizeChanged {
|
OutputSizeChanged {
|
||||||
output_size: PhysicalSize,
|
output_size: PhysicalSize,
|
||||||
},
|
},
|
||||||
|
|
@ -26,27 +21,11 @@ pub enum WindowStateEvent {
|
||||||
serial: u32,
|
serial: u32,
|
||||||
},
|
},
|
||||||
|
|
||||||
SurfaceEntered {
|
|
||||||
surface_id: ObjectId,
|
|
||||||
},
|
|
||||||
|
|
||||||
SurfaceExited,
|
|
||||||
|
|
||||||
RenderRequested,
|
|
||||||
|
|
||||||
PopupConfigurationChanged,
|
PopupConfigurationChanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum ScaleSource {
|
pub enum ScaleSource {
|
||||||
FractionalScale,
|
FractionalScale,
|
||||||
IntegerScale,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait WindowStateEventHandler {
|
|
||||||
fn handle_event(&mut self, event: &WindowStateEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait WindowStateEventEmitter {
|
|
||||||
fn emit_event(&self, event: WindowStateEvent);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue