feat: subsurface reposition
This commit is contained in:
parent
4eb7f9b2fe
commit
8e7b7e586f
3 changed files with 32 additions and 3 deletions
|
|
@ -57,6 +57,13 @@ pub enum Action {
|
||||||
/// id of the subsurface
|
/// id of the subsurface
|
||||||
id: Id,
|
id: Id,
|
||||||
},
|
},
|
||||||
|
/// reposition the subsurface
|
||||||
|
Reposition {
|
||||||
|
/// id of the subsurface
|
||||||
|
id: Id,
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Action {
|
impl fmt::Debug for Action {
|
||||||
|
|
@ -72,6 +79,11 @@ impl fmt::Debug for Action {
|
||||||
"Action::SubsurfaceAction::Destroy {{ id: {:?} }}",
|
"Action::SubsurfaceAction::Destroy {{ id: {:?} }}",
|
||||||
id
|
id
|
||||||
),
|
),
|
||||||
|
Action::Reposition { id, x, y } => write!(
|
||||||
|
f,
|
||||||
|
"Action::SubsurfaceAction::Reposition {{ id: {:?}, x: {:?}, y: {:?} }}",
|
||||||
|
id, x, y
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,15 @@ pub fn destroy_subsurface<Message>(id: SurfaceId) -> Task<Message> {
|
||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reposition_subsurface<Message>(
|
||||||
|
id: SurfaceId,
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
) -> Task<Message> {
|
||||||
|
task::effect(Action::PlatformSpecific(
|
||||||
|
platform_specific::Action::Wayland(wayland::Action::Subsurface(
|
||||||
|
wayland::subsurface::Action::Reposition { id, x, y },
|
||||||
|
)),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,6 @@ impl SctkState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
|
_ = wl_surface.frame(&self.queue_handle, wl_surface.clone());
|
||||||
wl_surface.commit();
|
wl_surface.commit();
|
||||||
|
|
||||||
|
|
@ -1417,7 +1416,7 @@ impl SctkState {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Action::Subsurface(action) => match action {
|
Action::Subsurface(action) => match action {
|
||||||
platform_specific::wayland::subsurface::Action::Subsurface { subsurface: subsurface_settings } => {
|
subsurface::Action::Subsurface { subsurface: subsurface_settings } => {
|
||||||
let parent_id = subsurface_settings.parent;
|
let parent_id = subsurface_settings.parent;
|
||||||
if let Ok((_, parent, subsurface, common_surface, common)) = self.get_subsurface(subsurface_settings.clone()) {
|
if let Ok((_, parent, subsurface, common_surface, common)) = self.get_subsurface(subsurface_settings.clone()) {
|
||||||
// TODO Ashley: all surfaces should probably have an optional title for a11y if nothing else
|
// TODO Ashley: all surfaces should probably have an optional title for a11y if nothing else
|
||||||
|
|
@ -1437,7 +1436,7 @@ impl SctkState {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
platform_specific::wayland::subsurface::Action::Destroy { id } => {
|
subsurface::Action::Destroy { id } => {
|
||||||
let mut destroyed = vec![];
|
let mut destroyed = vec![];
|
||||||
if let Some(subsurface) = self.subsurfaces.iter().position(|s| s.id == id) {
|
if let Some(subsurface) = self.subsurfaces.iter().position(|s| s.id == id) {
|
||||||
let subsurface = self.subsurfaces.remove(subsurface);
|
let subsurface = self.subsurfaces.remove(subsurface);
|
||||||
|
|
@ -1457,6 +1456,12 @@ impl SctkState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
subsurface::Action::Reposition { id, x, y } => {
|
||||||
|
if let Some(subsurface) = self.subsurfaces.iter().find(|s| s.id == id) {
|
||||||
|
subsurface.instance.wl_subsurface.set_position(x, y);
|
||||||
|
subsurface.instance.wl_surface.commit();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue