Add Xsettings support, for setting scaling related settings
This allows for most GTK and Qt apps to be scaled properly. In the case of mixed DPI, it will default to using the smallest monitor scale.
This commit is contained in:
parent
ec9ff64c1e
commit
572fa4a2bf
9 changed files with 466 additions and 11 deletions
|
|
@ -522,6 +522,8 @@ pub struct ServerState<C: XConnection> {
|
|||
activation_state: Option<ActivationState>,
|
||||
global_output_offset: GlobalOutputOffset,
|
||||
global_offset_updated: bool,
|
||||
output_scales_updated: bool,
|
||||
new_scale: Option<i32>,
|
||||
decoration_manager: Option<ZxdgDecorationManagerV1>,
|
||||
}
|
||||
|
||||
|
|
@ -611,6 +613,8 @@ impl<C: XConnection> ServerState<C> {
|
|||
},
|
||||
},
|
||||
global_offset_updated: false,
|
||||
output_scales_updated: false,
|
||||
new_scale: None,
|
||||
decoration_manager,
|
||||
}
|
||||
}
|
||||
|
|
@ -1058,6 +1062,42 @@ impl<C: XConnection> ServerState<C> {
|
|||
self.global_offset_updated = false;
|
||||
}
|
||||
|
||||
if self.output_scales_updated {
|
||||
let mut mixed_scale = false;
|
||||
let mut scale;
|
||||
|
||||
'b: {
|
||||
let mut keys_iter = self.output_keys.iter();
|
||||
let (key, _) = keys_iter.next().unwrap();
|
||||
let Some::<&Output>(output) = &mut self.objects.get(key).map(AsRef::as_ref) else {
|
||||
// This should never happen, but you never know...
|
||||
break 'b;
|
||||
};
|
||||
|
||||
scale = output.scale();
|
||||
|
||||
for (key, _) in keys_iter {
|
||||
let Some::<&Output>(output) = self.objects.get(key).map(AsRef::as_ref) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if output.scale() != scale {
|
||||
mixed_scale = true;
|
||||
scale = scale.min(output.scale());
|
||||
}
|
||||
}
|
||||
|
||||
if mixed_scale {
|
||||
warn!("Mixed output scales detected, choosing to give apps the smallest detected scale ({scale}x)");
|
||||
}
|
||||
|
||||
debug!("Using new scale {scale}");
|
||||
self.new_scale = Some(scale);
|
||||
}
|
||||
|
||||
self.output_scales_updated = false;
|
||||
}
|
||||
|
||||
{
|
||||
if let Some(FocusData {
|
||||
window,
|
||||
|
|
@ -1083,6 +1123,10 @@ impl<C: XConnection> ServerState<C> {
|
|||
.expect("Failed flushing clientside events");
|
||||
}
|
||||
|
||||
pub fn new_global_scale(&mut self) -> Option<i32> {
|
||||
self.new_scale.take()
|
||||
}
|
||||
|
||||
pub fn new_selection(&mut self) -> Option<ForeignSelection> {
|
||||
self.clipboard_data.as_mut().and_then(|c| {
|
||||
c.source.take().and_then(|s| match s {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue