wayland: implement scaling
This involves many subsystems:
- config:
- allow setting the connector scale
- allow setting the cursor size
- cursors:
- load server cursors for all requested sizes and scales
- wl_surface:
- track the output the surface belongs to
- send wl_surface.enter/leave
- wl_output:
- implement wl_output.scale
- text:
- pre-render texts for all used scales
- renderer:
- properly align scale textures and rectangles
- wp_fractional_scale:
- new interface for fractional scaling
This commit is contained in:
parent
16aec8f87e
commit
e52a60b3b6
41 changed files with 1417 additions and 364 deletions
78
src/ifs/wl_surface/wp_fractional_scale_v1.rs
Normal file
78
src/ifs/wl_surface/wp_fractional_scale_v1.rs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wp_fractional_scale_v1::*, WpFractionalScaleV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct WpFractionalScaleV1 {
|
||||
pub id: WpFractionalScaleV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl WpFractionalScaleV1 {
|
||||
pub fn new(id: WpFractionalScaleV1Id, surface: &Rc<WlSurface>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: surface.client.clone(),
|
||||
surface: surface.clone(),
|
||||
tracker: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn install(self: &Rc<Self>) -> Result<(), WpFractionalScaleError> {
|
||||
if self.surface.fractional_scale.get().is_some() {
|
||||
return Err(WpFractionalScaleError::Exists);
|
||||
}
|
||||
self.surface.fractional_scale.set(Some(self.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn send_preferred_scale(&self) {
|
||||
self.client.event(PreferredScale {
|
||||
self_id: self.id,
|
||||
scale: self.surface.output.get().preferred_scale.get(),
|
||||
});
|
||||
}
|
||||
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), WpFractionalScaleError> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
self.surface.fractional_scale.take();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
WpFractionalScaleV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for WpFractionalScaleV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WpFractionalScaleV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpFractionalScaleError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has a fractional scale extension attached")]
|
||||
Exists,
|
||||
}
|
||||
efrom!(WpFractionalScaleError, MsgParserError);
|
||||
efrom!(WpFractionalScaleError, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue