diff --git a/src/backend/notifications_dbus.rs b/src/backend/notifications_dbus.rs index 336abf9..35da4fd 100644 --- a/src/backend/notifications_dbus.rs +++ b/src/backend/notifications_dbus.rs @@ -1,13 +1,22 @@ // This code was autogenerated with `dbus-codegen-rust -g -m None -d org.freedesktop.Notifications -p /org/freedesktop/Notifications`, see https://github.com/diwic/dbus-rs -use dbus as dbus; +use dbus; #[allow(unused_imports)] use dbus::arg; use dbus::blocking; pub trait OrgFreedesktopDBusProperties { - fn get arg::Get<'b> + 'static>(&self, interface_name: &str, property_name: &str) -> Result; + fn get arg::Get<'b> + 'static>( + &self, + interface_name: &str, + property_name: &str, + ) -> Result; fn get_all(&self, interface_name: &str) -> Result; - fn set(&self, interface_name: &str, property_name: &str, value: I2) -> Result<(), dbus::Error>; + fn set( + &self, + interface_name: &str, + property_name: &str, + value: I2, + ) -> Result<(), dbus::Error>; } #[derive(Debug)] @@ -40,20 +49,42 @@ impl dbus::message::SignalArgs for OrgFreedesktopDBusPropertiesPropertiesChanged const INTERFACE: &'static str = "org.freedesktop.DBus.Properties"; } -impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopDBusProperties for blocking::Proxy<'a, C> { - - fn get arg::Get<'b> + 'static>(&self, interface_name: &str, property_name: &str) -> Result { - self.method_call("org.freedesktop.DBus.Properties", "Get", (interface_name, property_name, )) - .and_then(|r: (arg::Variant, )| Ok((r.0).0, )) +impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopDBusProperties + for blocking::Proxy<'a, C> +{ + fn get arg::Get<'b> + 'static>( + &self, + interface_name: &str, + property_name: &str, + ) -> Result { + self.method_call( + "org.freedesktop.DBus.Properties", + "Get", + (interface_name, property_name), + ) + .and_then(|r: (arg::Variant,)| Ok((r.0).0)) } fn get_all(&self, interface_name: &str) -> Result { - self.method_call("org.freedesktop.DBus.Properties", "GetAll", (interface_name, )) - .and_then(|r: (arg::PropMap, )| Ok(r.0, )) + self.method_call( + "org.freedesktop.DBus.Properties", + "GetAll", + (interface_name,), + ) + .and_then(|r: (arg::PropMap,)| Ok(r.0)) } - fn set(&self, interface_name: &str, property_name: &str, value: I2) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.DBus.Properties", "Set", (interface_name, property_name, arg::Variant(value), )) + fn set( + &self, + interface_name: &str, + property_name: &str, + value: I2, + ) -> Result<(), dbus::Error> { + self.method_call( + "org.freedesktop.DBus.Properties", + "Set", + (interface_name, property_name, arg::Variant(value)), + ) } } @@ -61,11 +92,12 @@ pub trait OrgFreedesktopDBusIntrospectable { fn introspect(&self) -> Result; } -impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C> { - +impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> + OrgFreedesktopDBusIntrospectable for blocking::Proxy<'a, C> +{ fn introspect(&self) -> Result { self.method_call("org.freedesktop.DBus.Introspectable", "Introspect", ()) - .and_then(|r: (String, )| Ok(r.0, )) + .and_then(|r: (String,)| Ok(r.0)) } } @@ -74,15 +106,16 @@ pub trait OrgFreedesktopDBusPeer { fn get_machine_id(&self) -> Result; } -impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopDBusPeer for blocking::Proxy<'a, C> { - +impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopDBusPeer + for blocking::Proxy<'a, C> +{ fn ping(&self) -> Result<(), dbus::Error> { self.method_call("org.freedesktop.DBus.Peer", "Ping", ()) } fn get_machine_id(&self) -> Result { self.method_call("org.freedesktop.DBus.Peer", "GetMachineId", ()) - .and_then(|r: (String, )| Ok(r.0, )) + .and_then(|r: (String,)| Ok(r.0)) } } @@ -95,7 +128,17 @@ pub trait OrgFreedesktopNotifications { fn close_all_notifications(&self) -> Result<(), dbus::Error>; fn hide_latest_notification(&self, close: bool) -> Result<(), dbus::Error>; fn get_capabilities(&self) -> Result, dbus::Error>; - fn notify(&self, app_name: &str, replaces_id: u32, app_icon: &str, summary: &str, body: &str, actions: Vec<&str>, hints: arg::PropMap, expire_timeout: i32) -> Result; + fn notify( + &self, + app_name: &str, + replaces_id: u32, + app_icon: &str, + summary: &str, + body: &str, + actions: Vec<&str>, + hints: arg::PropMap, + expire_timeout: i32, + ) -> Result; fn close_notification(&self, id: u32) -> Result<(), dbus::Error>; fn get_server_information(&self) -> Result<(String, String, String, String), dbus::Error>; fn dnd(&self) -> Result; @@ -115,9 +158,7 @@ impl arg::AppendAll for OrgFreedesktopNotificationsOnDndToggle { impl arg::ReadAll for OrgFreedesktopNotificationsOnDndToggle { fn read(i: &mut arg::Iter) -> Result { - Ok(OrgFreedesktopNotificationsOnDndToggle { - dnd: i.read()?, - }) + Ok(OrgFreedesktopNotificationsOnDndToggle { dnd: i.read()? }) } } @@ -207,28 +248,37 @@ impl dbus::message::SignalArgs for OrgFreedesktopNotificationsNotificationReplie const INTERFACE: &'static str = "org.freedesktop.Notifications"; } -impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopNotifications for blocking::Proxy<'a, C> { - +impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedesktopNotifications + for blocking::Proxy<'a, C> +{ fn set_noti_window_visibility(&self, value: bool) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.Notifications", "SetNotiWindowVisibility", (value, )) + self.method_call( + "org.freedesktop.Notifications", + "SetNotiWindowVisibility", + (value,), + ) } fn toggle_dnd(&self) -> Result { self.method_call("org.freedesktop.Notifications", "ToggleDnd", ()) - .and_then(|r: (bool, )| Ok(r.0, )) + .and_then(|r: (bool,)| Ok(r.0)) } fn set_dnd(&self, state: bool) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.Notifications", "SetDnd", (state, )) + self.method_call("org.freedesktop.Notifications", "SetDnd", (state,)) } fn get_dnd(&self) -> Result { self.method_call("org.freedesktop.Notifications", "GetDnd", ()) - .and_then(|r: (bool, )| Ok(r.0, )) + .and_then(|r: (bool,)| Ok(r.0)) } fn manually_close_notification(&self, id: u32, timeout: bool) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.Notifications", "ManuallyCloseNotification", (id, timeout, )) + self.method_call( + "org.freedesktop.Notifications", + "ManuallyCloseNotification", + (id, timeout), + ) } fn close_all_notifications(&self) -> Result<(), dbus::Error> { @@ -236,21 +286,48 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedes } fn hide_latest_notification(&self, close: bool) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.Notifications", "HideLatestNotification", (close, )) + self.method_call( + "org.freedesktop.Notifications", + "HideLatestNotification", + (close,), + ) } fn get_capabilities(&self) -> Result, dbus::Error> { self.method_call("org.freedesktop.Notifications", "GetCapabilities", ()) - .and_then(|r: (Vec, )| Ok(r.0, )) + .and_then(|r: (Vec,)| Ok(r.0)) } - fn notify(&self, app_name: &str, replaces_id: u32, app_icon: &str, summary: &str, body: &str, actions: Vec<&str>, hints: arg::PropMap, expire_timeout: i32) -> Result { - self.method_call("org.freedesktop.Notifications", "Notify", (app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout, )) - .and_then(|r: (u32, )| Ok(r.0, )) + fn notify( + &self, + app_name: &str, + replaces_id: u32, + app_icon: &str, + summary: &str, + body: &str, + actions: Vec<&str>, + hints: arg::PropMap, + expire_timeout: i32, + ) -> Result { + self.method_call( + "org.freedesktop.Notifications", + "Notify", + ( + app_name, + replaces_id, + app_icon, + summary, + body, + actions, + hints, + expire_timeout, + ), + ) + .and_then(|r: (u32,)| Ok(r.0)) } fn close_notification(&self, id: u32) -> Result<(), dbus::Error> { - self.method_call("org.freedesktop.Notifications", "CloseNotification", (id, )) + self.method_call("org.freedesktop.Notifications", "CloseNotification", (id,)) } fn get_server_information(&self) -> Result<(String, String, String, String), dbus::Error> { @@ -258,10 +335,19 @@ impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref> OrgFreedes } fn dnd(&self) -> Result { - ::get(self, "org.freedesktop.Notifications", "Dnd") + ::get( + self, + "org.freedesktop.Notifications", + "Dnd", + ) } fn set_dnd_(&self, value: bool) -> Result<(), dbus::Error> { - ::set(self, "org.freedesktop.Notifications", "Dnd", value) + ::set( + self, + "org.freedesktop.Notifications", + "Dnd", + value, + ) } } diff --git a/src/backend/wayvr/smithay_wrapper.rs b/src/backend/wayvr/smithay_wrapper.rs index f135d1a..e381976 100644 --- a/src/backend/wayvr/smithay_wrapper.rs +++ b/src/backend/wayvr/smithay_wrapper.rs @@ -2,53 +2,53 @@ use super::egl_data; use smithay::backend::{egl as smithay_egl, renderer::gles::ffi}; pub fn get_egl_display(data: &egl_data::EGLData) -> anyhow::Result { - Ok(unsafe { smithay_egl::EGLDisplay::from_raw(data.display.as_ptr(), data.config.as_ptr())? }) + Ok(unsafe { smithay_egl::EGLDisplay::from_raw(data.display.as_ptr(), data.config.as_ptr())? }) } pub fn get_egl_context( - data: &egl_data::EGLData, - display: &smithay_egl::EGLDisplay, + data: &egl_data::EGLData, + display: &smithay_egl::EGLDisplay, ) -> anyhow::Result { - let display_ptr = display.get_display_handle().handle; - debug_assert!(display_ptr == data.display.as_ptr()); - let config_ptr = data.config.as_ptr(); - let context_ptr = data.context.as_ptr(); - Ok(unsafe { smithay_egl::EGLContext::from_raw(display_ptr, config_ptr, context_ptr)? }) + let display_ptr = display.get_display_handle().handle; + debug_assert!(display_ptr == data.display.as_ptr()); + let config_ptr = data.config.as_ptr(); + let context_ptr = data.context.as_ptr(); + Ok(unsafe { smithay_egl::EGLContext::from_raw(display_ptr, config_ptr, context_ptr)? }) } pub fn create_framebuffer_texture( - gl: &ffi::Gles2, - width: u32, - height: u32, - tex_format: u32, - internal_format: u32, + gl: &ffi::Gles2, + width: u32, + height: u32, + tex_format: u32, + internal_format: u32, ) -> u32 { - unsafe { - let mut tex = 0; - gl.GenTextures(1, &mut tex); - gl.BindTexture(ffi::TEXTURE_2D, tex); - gl.TexParameteri( - ffi::TEXTURE_2D, - ffi::TEXTURE_MIN_FILTER, - ffi::NEAREST as i32, - ); - gl.TexParameteri( - ffi::TEXTURE_2D, - ffi::TEXTURE_MAG_FILTER, - ffi::NEAREST as i32, - ); - gl.TexImage2D( - ffi::TEXTURE_2D, - 0, - internal_format as i32, - width as i32, - height as i32, - 0, - tex_format, - ffi::UNSIGNED_BYTE, - std::ptr::null(), - ); - gl.BindTexture(ffi::TEXTURE_2D, 0); - tex - } + unsafe { + let mut tex = 0; + gl.GenTextures(1, &mut tex); + gl.BindTexture(ffi::TEXTURE_2D, tex); + gl.TexParameteri( + ffi::TEXTURE_2D, + ffi::TEXTURE_MIN_FILTER, + ffi::NEAREST as i32, + ); + gl.TexParameteri( + ffi::TEXTURE_2D, + ffi::TEXTURE_MAG_FILTER, + ffi::NEAREST as i32, + ); + gl.TexImage2D( + ffi::TEXTURE_2D, + 0, + internal_format as i32, + width as i32, + height as i32, + 0, + tex_format, + ffi::UNSIGNED_BYTE, + std::ptr::null(), + ); + gl.BindTexture(ffi::TEXTURE_2D, 0); + tex + } } diff --git a/src/backend/wayvr/time.rs b/src/backend/wayvr/time.rs index 77d7a21..f62d2c5 100644 --- a/src/backend/wayvr/time.rs +++ b/src/backend/wayvr/time.rs @@ -2,8 +2,8 @@ use std::time::{SystemTime, UNIX_EPOCH}; // Returns milliseconds since unix epoch pub fn get_millis() -> u64 { - SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_millis() as u64 + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_millis() as u64 } diff --git a/src/overlays/wayvr.rs b/src/overlays/wayvr.rs index 95395d9..064fda5 100644 --- a/src/overlays/wayvr.rs +++ b/src/overlays/wayvr.rs @@ -153,7 +153,13 @@ impl InteractionHandler for WayVRInteractionHandler { } } - fn on_scroll(&mut self, _app: &mut state::AppState, _hit: &input::PointerHit, delta_y: f32, delta_x: f32) { + fn on_scroll( + &mut self, + _app: &mut state::AppState, + _hit: &input::PointerHit, + delta_y: f32, + delta_x: f32, + ) { let ctx = self.context.borrow(); ctx.wayvr .borrow_mut() diff --git a/src/shaders/mod.rs b/src/shaders/mod.rs index 399afc0..15d835e 100644 --- a/src/shaders/mod.rs +++ b/src/shaders/mod.rs @@ -46,11 +46,11 @@ pub mod frag_color { ", } } - //layout (location = 1) in float corner_radius; - //out_color = in_color; - // Some equation that determines whether to keep the pixel - // Use Lerp not if - //out_color.a = 0; +//layout (location = 1) in float corner_radius; +//out_color = in_color; +// Some equation that determines whether to keep the pixel +// Use Lerp not if +//out_color.a = 0; pub mod frag_glyph { vulkano_shaders::shader! {