feat(wayland): panel item
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
pub mod panel_item;
|
||||
pub mod compositor;
|
||||
pub mod shaders;
|
||||
pub mod surface;
|
||||
|
||||
62
src/wayland/panel_item.rs
Normal file
62
src/wayland/panel_item.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
use crate::{
|
||||
core::{client::INTERNAL_CLIENT, registry::Registry},
|
||||
nodes::{
|
||||
core::Node,
|
||||
item::{Item, ItemType, TypeInfo},
|
||||
spatial::Spatial,
|
||||
},
|
||||
};
|
||||
use glam::Mat4;
|
||||
use lazy_static::lazy_static;
|
||||
use nanoid::nanoid;
|
||||
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
||||
use std::sync::Arc;
|
||||
|
||||
lazy_static! {
|
||||
static ref ITEM_TYPE_INFO_PANEL: TypeInfo = TypeInfo {
|
||||
type_name: "panel",
|
||||
aliased_local_signals: vec![
|
||||
"applySurfaceMaterial",
|
||||
"setPointerActive",
|
||||
"setPointerPosition",
|
||||
"setPointerButtonPressed",
|
||||
"scrollPointerAxis",
|
||||
"touchDown",
|
||||
"touchMove",
|
||||
"touchUp",
|
||||
"setKeyboardActive",
|
||||
"setKeymap",
|
||||
"setKeyState",
|
||||
"setKeyModStates",
|
||||
"setKeyRepeat",
|
||||
"resize",
|
||||
"close",
|
||||
],
|
||||
aliased_local_methods: vec![],
|
||||
aliased_remote_signals: vec![],
|
||||
aliased_remote_methods: vec![],
|
||||
ui: Default::default(),
|
||||
items: Registry::new(),
|
||||
acceptors: Registry::new(),
|
||||
};
|
||||
}
|
||||
|
||||
pub struct PanelItem {
|
||||
toplevel_surface: WlSurface,
|
||||
}
|
||||
impl PanelItem {
|
||||
pub fn create(toplevel_surface: WlSurface) -> Arc<Node> {
|
||||
let node = Node::create(&INTERNAL_CLIENT, "/item/panel/item", &nanoid!(), true)
|
||||
.add_to_scenegraph();
|
||||
Spatial::add_to(&node, None, Mat4::IDENTITY).unwrap();
|
||||
|
||||
let specialization = ItemType::Panel(PanelItem { toplevel_surface });
|
||||
let item =
|
||||
ITEM_TYPE_INFO_PANEL
|
||||
.items
|
||||
.add(Item::new(&node, &ITEM_TYPE_INFO_PANEL, specialization));
|
||||
let _ = node.item.set(item);
|
||||
// node.add_local_method("getPath", PanelItem::get_path_flex);
|
||||
node
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use smithay::{
|
||||
wayland::{compositor, shell::xdg::XdgShellHandler},
|
||||
};
|
||||
|
||||
use super::{surface::CoreSurface, WaylandState};
|
||||
use super::{panel_item::PanelItem, surface::CoreSurface, WaylandState};
|
||||
|
||||
impl XdgShellHandler for WaylandState {
|
||||
fn xdg_shell_state(&mut self) -> &mut smithay::wayland::shell::xdg::XdgShellState {
|
||||
@@ -29,6 +29,8 @@ impl XdgShellHandler for WaylandState {
|
||||
|
||||
compositor::with_states(surface.wl_surface(), |data| {
|
||||
data.data_map.insert_if_missing(CoreSurface::new);
|
||||
data.data_map
|
||||
.insert_if_missing(|| PanelItem::create(surface.wl_surface().clone()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user