mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-10-28 04:24:22 +00:00
refactor: remove absolute paths
This commit is contained in:
parent
9f6cd31322
commit
1c5bb97782
6 changed files with 32 additions and 18 deletions
|
|
@ -18,6 +18,7 @@ clone_on_ref_ptr = "warn"
|
|||
multiple-crate-versions = "allow"
|
||||
module_name_repetitions = "allow"
|
||||
unwrap_used = "warn"
|
||||
absolute_paths = "deny"
|
||||
|
||||
[dependencies]
|
||||
glutin = { version = "0.32.3", default-features = false, features = [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use std::result::Result as StdResult;
|
||||
use thiserror::Error;
|
||||
use wayland_client::backend::WaylandError;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, LayerShikaError>;
|
||||
pub type Result<T> = StdResult<T, LayerShikaError>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum LayerShikaError {
|
||||
|
|
@ -41,5 +43,5 @@ pub enum LayerShikaError {
|
|||
PlatformSetup(String),
|
||||
|
||||
#[error("Failed to flush connection: {0}")]
|
||||
ConnectionFlush(#[from] wayland_client::backend::WaylandError),
|
||||
ConnectionFlush(#[from] WaylandError),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
use crate::errors::{LayerShikaError, Result};
|
||||
use glutin::{
|
||||
api::egl::{context::PossiblyCurrentContext, display::Display, surface::Surface},
|
||||
api::egl::{
|
||||
config::Config,
|
||||
context::{NotCurrentContext, PossiblyCurrentContext},
|
||||
display::Display,
|
||||
surface::Surface,
|
||||
},
|
||||
config::ConfigTemplateBuilder,
|
||||
context::ContextAttributesBuilder,
|
||||
display::GetGlDisplay,
|
||||
|
|
@ -12,9 +17,11 @@ use raw_window_handle::{
|
|||
};
|
||||
use slint::{platform::femtovg_renderer::OpenGLInterface, PhysicalSize};
|
||||
use std::{
|
||||
error::Error,
|
||||
ffi::{self, c_void, CStr},
|
||||
num::NonZeroU32,
|
||||
ptr::NonNull,
|
||||
result::Result as StdResult,
|
||||
};
|
||||
use wayland_client::backend::ObjectId;
|
||||
|
||||
|
|
@ -128,7 +135,7 @@ fn create_wayland_display_handle(display_id: &ObjectId) -> Result<RawDisplayHand
|
|||
fn select_config(
|
||||
glutin_display: &Display,
|
||||
config_template: ConfigTemplateBuilder,
|
||||
) -> Result<glutin::api::egl::config::Config> {
|
||||
) -> Result<Config> {
|
||||
let mut configs = unsafe { glutin_display.find_configs(config_template.build()) }
|
||||
.map_err(|e| LayerShikaError::EGLContextCreation(format!("Failed to find configs: {e}")))?;
|
||||
configs.next().ok_or_else(|| {
|
||||
|
|
@ -138,9 +145,9 @@ fn select_config(
|
|||
|
||||
fn create_context(
|
||||
glutin_display: &Display,
|
||||
config: &glutin::api::egl::config::Config,
|
||||
config: &Config,
|
||||
context_attributes: ContextAttributesBuilder,
|
||||
) -> Result<glutin::api::egl::context::NotCurrentContext> {
|
||||
) -> Result<NotCurrentContext> {
|
||||
unsafe { glutin_display.create_context(config, &context_attributes.build(None)) }
|
||||
.map_err(|e| LayerShikaError::EGLContextCreation(format!("Failed to create context: {e}")))
|
||||
}
|
||||
|
|
@ -155,7 +162,7 @@ fn create_surface_handle(surface_id: &ObjectId) -> Result<RawWindowHandle> {
|
|||
|
||||
fn create_surface(
|
||||
glutin_display: &Display,
|
||||
config: &glutin::api::egl::config::Config,
|
||||
config: &Config,
|
||||
surface_handle: RawWindowHandle,
|
||||
size: PhysicalSize,
|
||||
) -> Result<Surface<WindowSurface>> {
|
||||
|
|
@ -174,12 +181,12 @@ fn create_surface(
|
|||
}
|
||||
|
||||
unsafe impl OpenGLInterface for EGLContext {
|
||||
fn ensure_current(&self) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
fn ensure_current(&self) -> StdResult<(), Box<dyn Error + Send + Sync>> {
|
||||
self.ensure_current()
|
||||
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)
|
||||
.map_err(|e| Box::new(e) as Box<dyn Error + Send + Sync>)
|
||||
}
|
||||
|
||||
fn swap_buffers(&self) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
fn swap_buffers(&self) -> StdResult<(), Box<dyn Error + Send + Sync>> {
|
||||
self.surface.swap_buffers(&self.context).map_err(|e| {
|
||||
LayerShikaError::EGLContextCreation(format!("Failed to swap buffers: {e}")).into()
|
||||
})
|
||||
|
|
@ -189,7 +196,7 @@ unsafe impl OpenGLInterface for EGLContext {
|
|||
&self,
|
||||
width: NonZeroU32,
|
||||
height: NonZeroU32,
|
||||
) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
) -> StdResult<(), Box<dyn Error + Send + Sync>> {
|
||||
self.ensure_current()?;
|
||||
self.surface.resize(&self.context, width, height);
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::errors::{LayerShikaError, Result};
|
||||
use core::ops::Deref;
|
||||
use log::info;
|
||||
use slint::{
|
||||
platform::{femtovg_renderer::FemtoVGRenderer, Renderer, WindowAdapter, WindowEvent},
|
||||
|
|
@ -83,7 +84,7 @@ impl WindowAdapter for FemtoVGWindow {
|
|||
}
|
||||
}
|
||||
|
||||
impl core::ops::Deref for FemtoVGWindow {
|
||||
impl Deref for FemtoVGWindow {
|
||||
type Target = Window;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.window
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ use crate::{
|
|||
};
|
||||
use config::WindowConfig;
|
||||
use log::{debug, error, info};
|
||||
use slint::{platform::femtovg_renderer::FemtoVGRenderer, LogicalPosition, PhysicalSize};
|
||||
use slint::{
|
||||
platform::{femtovg_renderer::FemtoVGRenderer, update_timers_and_animations},
|
||||
LogicalPosition, PhysicalSize,
|
||||
};
|
||||
use slint_interpreter::ComponentInstance;
|
||||
use smithay_client_toolkit::reexports::{
|
||||
calloop::{self, EventLoop, Interest, LoopHandle, Mode, PostAction},
|
||||
calloop::{generic::Generic, EventLoop, Interest, LoopHandle, Mode, PostAction},
|
||||
protocols_wlr::layer_shell::v1::client::{
|
||||
zwlr_layer_shell_v1::ZwlrLayerShellV1, zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
|
||||
},
|
||||
|
|
@ -288,7 +291,7 @@ impl WindowingSystem {
|
|||
self.event_loop
|
||||
.handle()
|
||||
.insert_source(
|
||||
calloop::generic::Generic::new(connection, Interest::READ, Mode::Level),
|
||||
Generic::new(connection, Interest::READ, Mode::Level),
|
||||
move |_, _connection, _shared_data| Ok(PostAction::Continue),
|
||||
)
|
||||
.map_err(|e| LayerShikaError::EventLoop(e.to_string()))?;
|
||||
|
|
@ -312,7 +315,7 @@ impl WindowingSystem {
|
|||
.dispatch_pending(shared_data)
|
||||
.map_err(|e| LayerShikaError::WaylandProtocol(e.to_string()))?;
|
||||
|
||||
slint::platform::update_timers_and_animations();
|
||||
update_timers_and_animations();
|
||||
|
||||
shared_data
|
||||
.window()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::rc::Rc;
|
||||
use slint::PhysicalSize;
|
||||
use slint::{platform::set_platform, PhysicalSize};
|
||||
use slint_interpreter::ComponentDefinition;
|
||||
use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
||||
use wayland_client::protocol::{wl_pointer::WlPointer, wl_surface::WlSurface};
|
||||
|
|
@ -108,7 +108,7 @@ impl WindowStateBuilder {
|
|||
.as_ref()
|
||||
.ok_or_else(|| LayerShikaError::InvalidInput("Window is required".into()))?,
|
||||
));
|
||||
slint::platform::set_platform(Box::new(platform)).map_err(|e| {
|
||||
set_platform(Box::new(platform)).map_err(|e| {
|
||||
LayerShikaError::PlatformSetup(format!("Failed to set platform: {e:?}"))
|
||||
})?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue