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
|
|
@ -359,6 +359,10 @@ impl Client {
|
|||
size
|
||||
}
|
||||
|
||||
pub fn set_cursor_size(&self, seat: Seat, size: i32) {
|
||||
self.send(&ClientMessage::SetCursorSize { seat, size })
|
||||
}
|
||||
|
||||
pub fn set_size(&self, sized: Resizable, size: i32) {
|
||||
self.send(&ClientMessage::SetSize { sized, size })
|
||||
}
|
||||
|
|
@ -459,6 +463,16 @@ impl Client {
|
|||
connected
|
||||
}
|
||||
|
||||
pub fn connector_set_scale(&self, connector: Connector, scale: f64) {
|
||||
self.send(&ClientMessage::ConnectorSetScale { connector, scale });
|
||||
}
|
||||
|
||||
pub fn connector_get_scale(&self, connector: Connector) -> f64 {
|
||||
let res = self.send_with_response(&ClientMessage::ConnectorGetScale { connector });
|
||||
get_response!(res, 1.0, ConnectorGetScale { scale });
|
||||
scale
|
||||
}
|
||||
|
||||
pub fn connector_type(&self, connector: Connector) -> ConnectorType {
|
||||
let res = self.send_with_response(&ClientMessage::ConnectorType { connector });
|
||||
get_response!(res, CON_UNKNOWN, ConnectorType { ty });
|
||||
|
|
@ -483,6 +497,12 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn connector_size(&self, connector: Connector) -> (i32, i32) {
|
||||
let res = self.send_with_response(&ClientMessage::ConnectorSize { connector });
|
||||
get_response!(res, (0, 0), ConnectorSize { width, height });
|
||||
(width, height)
|
||||
}
|
||||
|
||||
pub fn drm_devices(&self) -> Vec<DrmDevice> {
|
||||
let res = self.send_with_response(&ClientMessage::GetDrmDevices);
|
||||
get_response!(res, vec![], GetDrmDevices { devices });
|
||||
|
|
|
|||
|
|
@ -274,6 +274,20 @@ pub enum ClientMessage<'a> {
|
|||
device: InputDevice,
|
||||
px: f64,
|
||||
},
|
||||
ConnectorSetScale {
|
||||
connector: Connector,
|
||||
scale: f64,
|
||||
},
|
||||
ConnectorGetScale {
|
||||
connector: Connector,
|
||||
},
|
||||
ConnectorSize {
|
||||
connector: Connector,
|
||||
},
|
||||
SetCursorSize {
|
||||
seat: Seat,
|
||||
size: i32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug)]
|
||||
|
|
@ -360,6 +374,13 @@ pub enum Response {
|
|||
GetFont {
|
||||
font: String,
|
||||
},
|
||||
ConnectorGetScale {
|
||||
scale: f64,
|
||||
},
|
||||
ConnectorSize {
|
||||
width: i32,
|
||||
height: i32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug)]
|
||||
|
|
|
|||
|
|
@ -107,6 +107,13 @@ impl Seat {
|
|||
Self(raw)
|
||||
}
|
||||
|
||||
/// Sets the size of the cursor theme.
|
||||
///
|
||||
/// Default: 16.
|
||||
pub fn set_cursor_size(self, size: i32) {
|
||||
get!().set_cursor_size(self, size)
|
||||
}
|
||||
|
||||
/// Creates a compositor-wide hotkey.
|
||||
///
|
||||
/// The closure is invoked when the user presses the last key of the modified keysym.
|
||||
|
|
|
|||
|
|
@ -79,6 +79,23 @@ impl Connector {
|
|||
get!(false).connector_connected(self)
|
||||
}
|
||||
|
||||
/// Returns the scale of the currently connected monitor.
|
||||
pub fn scale(self) -> f64 {
|
||||
if !self.exists() {
|
||||
return 1.0;
|
||||
}
|
||||
get!(1.0).connector_get_scale(self)
|
||||
}
|
||||
|
||||
/// Sets the scale to use for the currently connected monitor.
|
||||
pub fn set_scale(self, scale: f64) {
|
||||
if !self.exists() {
|
||||
return;
|
||||
}
|
||||
log::info!("setting scale to {}", scale);
|
||||
get!().connector_set_scale(self, scale);
|
||||
}
|
||||
|
||||
/// Returns the connector type.
|
||||
pub fn ty(self) -> ConnectorType {
|
||||
if !self.exists() {
|
||||
|
|
@ -95,18 +112,18 @@ impl Connector {
|
|||
get!(Mode::zeroed()).connector_mode(self)
|
||||
}
|
||||
|
||||
/// Returns the width of the current mode of the connector.
|
||||
/// Returns the logical width of the connector.
|
||||
///
|
||||
/// This is a shortcut for `mode().width()`.
|
||||
/// The returned value will be different from `mode().width()` if the scale is not 1.
|
||||
pub fn width(self) -> i32 {
|
||||
self.mode().width
|
||||
get!().connector_size(self).0
|
||||
}
|
||||
|
||||
/// Returns the height of the current mode of the connector.
|
||||
/// Returns the logical height of the connector.
|
||||
///
|
||||
/// This is a shortcut for `mode().height()`.
|
||||
/// The returned value will be different from `mode().height()` if the scale is not 1.
|
||||
pub fn height(self) -> i32 {
|
||||
self.mode().height
|
||||
get!().connector_size(self).1
|
||||
}
|
||||
|
||||
/// Returns the refresh rate in mhz of the current mode of the connector.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue