Rename "inner size" to "surface size" (#3889)
* Rename `WindowEvent::Resized` to `SurfaceResized` * Rename `InnerSizeWriter` to `SurfaceSizeWriter` * Replace `inner_size` with `surface_size` * Rename `resize_increments` to `surface_resize_increments`
This commit is contained in:
parent
d37c591378
commit
8db3e0e043
32 changed files with 466 additions and 436 deletions
|
|
@ -22,8 +22,8 @@ use xkbcommon_dl::xkb_mod_mask_t;
|
|||
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::event::{
|
||||
DeviceEvent, ElementState, Event, Ime, InnerSizeWriter, MouseButton, MouseScrollDelta,
|
||||
RawKeyEvent, Touch, TouchPhase, WindowEvent,
|
||||
DeviceEvent, ElementState, Event, Ime, MouseButton, MouseScrollDelta, RawKeyEvent,
|
||||
SurfaceSizeWriter, Touch, TouchPhase, WindowEvent,
|
||||
};
|
||||
use crate::keyboard::ModifiersState;
|
||||
use crate::platform_impl::common::xkb::{self, XkbState};
|
||||
|
|
@ -598,19 +598,19 @@ impl EventProcessor {
|
|||
// `XSendEvent` (synthetic `ConfigureNotify`) -> position relative to root
|
||||
// `XConfigureNotify` (real `ConfigureNotify`) -> position relative to parent
|
||||
// https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.5
|
||||
// We don't want to send `Moved` when this is false, since then every `Resized`
|
||||
// We don't want to send `Moved` when this is false, since then every `SurfaceResized`
|
||||
// (whether the window moved or not) is accompanied by an extraneous `Moved` event
|
||||
// that has a position relative to the parent window.
|
||||
let is_synthetic = xev.send_event == xlib::True;
|
||||
|
||||
// These are both in physical space.
|
||||
let new_inner_size = (xev.width as u32, xev.height as u32);
|
||||
let new_surface_size = (xev.width as u32, xev.height as u32);
|
||||
let new_inner_position = (xev.x, xev.y);
|
||||
|
||||
let (mut resized, moved) = {
|
||||
let mut shared_state_lock = window.shared_state_lock();
|
||||
|
||||
let resized = util::maybe_change(&mut shared_state_lock.size, new_inner_size);
|
||||
let resized = util::maybe_change(&mut shared_state_lock.size, new_surface_size);
|
||||
let moved = if is_synthetic {
|
||||
util::maybe_change(&mut shared_state_lock.inner_position, new_inner_position)
|
||||
} else {
|
||||
|
|
@ -671,7 +671,7 @@ impl EventProcessor {
|
|||
|
||||
let last_scale_factor = shared_state_lock.last_monitor.scale_factor;
|
||||
let new_scale_factor = {
|
||||
let window_rect = util::AaRect::new(new_outer_position, new_inner_size);
|
||||
let window_rect = util::AaRect::new(new_outer_position, new_surface_size);
|
||||
let monitor = self
|
||||
.target
|
||||
.xconn
|
||||
|
|
@ -695,27 +695,30 @@ impl EventProcessor {
|
|||
&shared_state_lock,
|
||||
);
|
||||
|
||||
let old_inner_size = PhysicalSize::new(width, height);
|
||||
let new_inner_size = PhysicalSize::new(new_width, new_height);
|
||||
let old_surface_size = PhysicalSize::new(width, height);
|
||||
let new_surface_size = PhysicalSize::new(new_width, new_height);
|
||||
|
||||
// Unlock shared state to prevent deadlock in callback below
|
||||
drop(shared_state_lock);
|
||||
|
||||
let inner_size = Arc::new(Mutex::new(new_inner_size));
|
||||
let surface_size = Arc::new(Mutex::new(new_surface_size));
|
||||
callback(&self.target, Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::ScaleFactorChanged {
|
||||
scale_factor: new_scale_factor,
|
||||
inner_size_writer: InnerSizeWriter::new(Arc::downgrade(&inner_size)),
|
||||
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&surface_size)),
|
||||
},
|
||||
});
|
||||
|
||||
let new_inner_size = *inner_size.lock().unwrap();
|
||||
drop(inner_size);
|
||||
let new_surface_size = *surface_size.lock().unwrap();
|
||||
drop(surface_size);
|
||||
|
||||
if new_inner_size != old_inner_size {
|
||||
window.request_inner_size_physical(new_inner_size.width, new_inner_size.height);
|
||||
window.shared_state_lock().dpi_adjusted = Some(new_inner_size.into());
|
||||
if new_surface_size != old_surface_size {
|
||||
window.request_surface_size_physical(
|
||||
new_surface_size.width,
|
||||
new_surface_size.height,
|
||||
);
|
||||
window.shared_state_lock().dpi_adjusted = Some(new_surface_size.into());
|
||||
// if the DPI factor changed, force a resize event to ensure the logical
|
||||
// size is computed with the right DPI factor
|
||||
resized = true;
|
||||
|
|
@ -736,13 +739,13 @@ impl EventProcessor {
|
|||
// XResizeWindow requests, making Xorg, the winit client, and the WM
|
||||
// consume 100% of CPU.
|
||||
if let Some(adjusted_size) = shared_state_lock.dpi_adjusted {
|
||||
if new_inner_size == adjusted_size || !util::wm_name_is_one_of(&["Xfwm4"]) {
|
||||
if new_surface_size == adjusted_size || !util::wm_name_is_one_of(&["Xfwm4"]) {
|
||||
// When this finally happens, the event will not be synthetic.
|
||||
shared_state_lock.dpi_adjusted = None;
|
||||
} else {
|
||||
// Unlock shared state to prevent deadlock in callback below
|
||||
drop(shared_state_lock);
|
||||
window.request_inner_size_physical(adjusted_size.0, adjusted_size.1);
|
||||
window.request_surface_size_physical(adjusted_size.0, adjusted_size.1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -757,7 +760,7 @@ impl EventProcessor {
|
|||
if resized {
|
||||
callback(&self.target, Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::Resized(new_inner_size.into()),
|
||||
event: WindowEvent::SurfaceResized(new_surface_size.into()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl FrameExtentsHeuristic {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn inner_size_to_outer(&self, width: u32, height: u32) -> (u32, u32) {
|
||||
pub fn surface_size_to_outer(&self, width: u32, height: u32) -> (u32, u32) {
|
||||
(
|
||||
width.saturating_add(
|
||||
self.frame_extents.left.saturating_add(self.frame_extents.right) as _
|
||||
|
|
@ -98,7 +98,7 @@ impl XConnection {
|
|||
self.xcb_connection().translate_coordinates(window, root, 0, 0)?.reply().map_err(Into::into)
|
||||
}
|
||||
|
||||
// This is adequate for inner_size
|
||||
// This is adequate for surface_size
|
||||
pub fn get_geometry(
|
||||
&self,
|
||||
window: xproto::Window,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use super::{
|
|||
use crate::cursor::{Cursor, CustomCursor as RootCustomCursor};
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use crate::event::{Event, InnerSizeWriter, WindowEvent};
|
||||
use crate::event::{Event, SurfaceSizeWriter, WindowEvent};
|
||||
use crate::event_loop::AsyncRequestSerial;
|
||||
use crate::platform::x11::WindowType;
|
||||
use crate::platform_impl::x11::atoms::*;
|
||||
|
|
@ -94,32 +94,32 @@ impl CoreWindow for Window {
|
|||
self.0.set_outer_position(position)
|
||||
}
|
||||
|
||||
fn inner_size(&self) -> PhysicalSize<u32> {
|
||||
self.0.inner_size()
|
||||
fn surface_size(&self) -> PhysicalSize<u32> {
|
||||
self.0.surface_size()
|
||||
}
|
||||
|
||||
fn request_inner_size(&self, size: Size) -> Option<PhysicalSize<u32>> {
|
||||
self.0.request_inner_size(size)
|
||||
fn request_surface_size(&self, size: Size) -> Option<PhysicalSize<u32>> {
|
||||
self.0.request_surface_size(size)
|
||||
}
|
||||
|
||||
fn outer_size(&self) -> PhysicalSize<u32> {
|
||||
self.0.outer_size()
|
||||
}
|
||||
|
||||
fn set_min_inner_size(&self, min_size: Option<Size>) {
|
||||
self.0.set_min_inner_size(min_size)
|
||||
fn set_min_surface_size(&self, min_size: Option<Size>) {
|
||||
self.0.set_min_surface_size(min_size)
|
||||
}
|
||||
|
||||
fn set_max_inner_size(&self, max_size: Option<Size>) {
|
||||
self.0.set_max_inner_size(max_size)
|
||||
fn set_max_surface_size(&self, max_size: Option<Size>) {
|
||||
self.0.set_max_surface_size(max_size)
|
||||
}
|
||||
|
||||
fn resize_increments(&self) -> Option<PhysicalSize<u32>> {
|
||||
self.0.resize_increments()
|
||||
fn surface_resize_increments(&self) -> Option<PhysicalSize<u32>> {
|
||||
self.0.surface_resize_increments()
|
||||
}
|
||||
|
||||
fn set_resize_increments(&self, increments: Option<Size>) {
|
||||
self.0.set_resize_increments(increments)
|
||||
fn set_surface_resize_increments(&self, increments: Option<Size>) {
|
||||
self.0.set_surface_resize_increments(increments)
|
||||
}
|
||||
|
||||
fn set_title(&self, title: &str) {
|
||||
|
|
@ -356,9 +356,9 @@ pub struct SharedState {
|
|||
// Used to restore video mode after exiting fullscreen
|
||||
pub desktop_video_mode: Option<(randr::Crtc, randr::Mode)>,
|
||||
pub frame_extents: Option<util::FrameExtentsHeuristic>,
|
||||
pub min_inner_size: Option<Size>,
|
||||
pub max_inner_size: Option<Size>,
|
||||
pub resize_increments: Option<Size>,
|
||||
pub min_surface_size: Option<Size>,
|
||||
pub max_surface_size: Option<Size>,
|
||||
pub surface_resize_increments: Option<Size>,
|
||||
pub base_size: Option<Size>,
|
||||
pub visibility: Visibility,
|
||||
pub has_focus: bool,
|
||||
|
|
@ -396,9 +396,9 @@ impl SharedState {
|
|||
restore_position: None,
|
||||
desktop_video_mode: None,
|
||||
frame_extents: None,
|
||||
min_inner_size: None,
|
||||
max_inner_size: None,
|
||||
resize_increments: None,
|
||||
min_surface_size: None,
|
||||
max_surface_size: None,
|
||||
surface_resize_increments: None,
|
||||
base_size: None,
|
||||
has_focus: false,
|
||||
cursor_hittest: None,
|
||||
|
|
@ -479,10 +479,10 @@ impl UnownedWindow {
|
|||
|
||||
info!("Guessed window scale factor: {}", scale_factor);
|
||||
|
||||
let max_inner_size: Option<(u32, u32)> =
|
||||
window_attrs.max_inner_size.map(|size| size.to_physical::<u32>(scale_factor).into());
|
||||
let min_inner_size: Option<(u32, u32)> =
|
||||
window_attrs.min_inner_size.map(|size| size.to_physical::<u32>(scale_factor).into());
|
||||
let max_surface_size: Option<(u32, u32)> =
|
||||
window_attrs.max_surface_size.map(|size| size.to_physical::<u32>(scale_factor).into());
|
||||
let min_surface_size: Option<(u32, u32)> =
|
||||
window_attrs.min_surface_size.map(|size| size.to_physical::<u32>(scale_factor).into());
|
||||
|
||||
let position =
|
||||
window_attrs.position.map(|position| position.to_physical::<i32>(scale_factor));
|
||||
|
|
@ -491,16 +491,16 @@ impl UnownedWindow {
|
|||
// x11 only applies constraints when the window is actively resized
|
||||
// by the user, so we have to manually apply the initial constraints
|
||||
let mut dimensions: (u32, u32) = window_attrs
|
||||
.inner_size
|
||||
.surface_size
|
||||
.map(|size| size.to_physical::<u32>(scale_factor))
|
||||
.or_else(|| Some((800, 600).into()))
|
||||
.map(Into::into)
|
||||
.unwrap();
|
||||
if let Some(max) = max_inner_size {
|
||||
if let Some(max) = max_surface_size {
|
||||
dimensions.0 = cmp::min(dimensions.0, max.0);
|
||||
dimensions.1 = cmp::min(dimensions.1, max.1);
|
||||
}
|
||||
if let Some(min) = min_inner_size {
|
||||
if let Some(min) = min_surface_size {
|
||||
dimensions.0 = cmp::max(dimensions.0, min.0);
|
||||
dimensions.1 = cmp::max(dimensions.1, min.1);
|
||||
}
|
||||
|
|
@ -717,24 +717,24 @@ impl UnownedWindow {
|
|||
.ignore_error();
|
||||
|
||||
// Set size hints.
|
||||
let mut min_inner_size =
|
||||
window_attrs.min_inner_size.map(|size| size.to_physical::<u32>(scale_factor));
|
||||
let mut max_inner_size =
|
||||
window_attrs.max_inner_size.map(|size| size.to_physical::<u32>(scale_factor));
|
||||
let mut min_surface_size =
|
||||
window_attrs.min_surface_size.map(|size| size.to_physical::<u32>(scale_factor));
|
||||
let mut max_surface_size =
|
||||
window_attrs.max_surface_size.map(|size| size.to_physical::<u32>(scale_factor));
|
||||
|
||||
if !window_attrs.resizable {
|
||||
if util::wm_name_is_one_of(&["Xfwm4"]) {
|
||||
warn!("To avoid a WM bug, disabling resizing has no effect on Xfwm4");
|
||||
} else {
|
||||
max_inner_size = Some(dimensions.into());
|
||||
min_inner_size = Some(dimensions.into());
|
||||
max_surface_size = Some(dimensions.into());
|
||||
min_surface_size = Some(dimensions.into());
|
||||
}
|
||||
}
|
||||
|
||||
let shared_state = window.shared_state.get_mut().unwrap();
|
||||
shared_state.min_inner_size = min_inner_size.map(Into::into);
|
||||
shared_state.max_inner_size = max_inner_size.map(Into::into);
|
||||
shared_state.resize_increments = window_attrs.resize_increments;
|
||||
shared_state.min_surface_size = min_surface_size.map(Into::into);
|
||||
shared_state.max_surface_size = max_surface_size.map(Into::into);
|
||||
shared_state.surface_resize_increments = window_attrs.surface_resize_increments;
|
||||
shared_state.base_size = window_attrs.platform_specific.x11.base_size;
|
||||
|
||||
let normal_hints = WmSizeHints {
|
||||
|
|
@ -746,10 +746,10 @@ impl UnownedWindow {
|
|||
cast_dimension_to_hint(dimensions.0),
|
||||
cast_dimension_to_hint(dimensions.1),
|
||||
)),
|
||||
max_size: max_inner_size.map(cast_physical_size_to_hint),
|
||||
min_size: min_inner_size.map(cast_physical_size_to_hint),
|
||||
max_size: max_surface_size.map(cast_physical_size_to_hint),
|
||||
min_size: min_surface_size.map(cast_physical_size_to_hint),
|
||||
size_increment: window_attrs
|
||||
.resize_increments
|
||||
.surface_resize_increments
|
||||
.map(|size| cast_size_to_hint(size, scale_factor)),
|
||||
base_size: window_attrs
|
||||
.platform_specific
|
||||
|
|
@ -1210,7 +1210,7 @@ impl UnownedWindow {
|
|||
// Check if the self is on this monitor
|
||||
let monitor = self.shared_state_lock().last_monitor.clone();
|
||||
if monitor.name == new_monitor.name {
|
||||
let (width, height) = self.inner_size_physical();
|
||||
let (width, height) = self.surface_size_physical();
|
||||
let (new_width, new_height) = self.adjust_for_dpi(
|
||||
// If we couldn't determine the previous scale
|
||||
// factor (e.g., because all monitors were closed
|
||||
|
|
@ -1224,22 +1224,22 @@ impl UnownedWindow {
|
|||
);
|
||||
|
||||
let window_id = crate::window::WindowId(self.id());
|
||||
let old_inner_size = PhysicalSize::new(width, height);
|
||||
let inner_size = Arc::new(Mutex::new(PhysicalSize::new(new_width, new_height)));
|
||||
let old_surface_size = PhysicalSize::new(width, height);
|
||||
let surface_size = Arc::new(Mutex::new(PhysicalSize::new(new_width, new_height)));
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::ScaleFactorChanged {
|
||||
scale_factor: new_monitor.scale_factor,
|
||||
inner_size_writer: InnerSizeWriter::new(Arc::downgrade(&inner_size)),
|
||||
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&surface_size)),
|
||||
},
|
||||
});
|
||||
|
||||
let new_inner_size = *inner_size.lock().unwrap();
|
||||
drop(inner_size);
|
||||
let new_surface_size = *surface_size.lock().unwrap();
|
||||
drop(surface_size);
|
||||
|
||||
if new_inner_size != old_inner_size {
|
||||
let (new_width, new_height) = new_inner_size.into();
|
||||
self.request_inner_size_physical(new_width, new_height);
|
||||
if new_surface_size != old_surface_size {
|
||||
let (new_width, new_height) = new_surface_size.into();
|
||||
self.request_surface_size_physical(new_width, new_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1559,7 +1559,7 @@ impl UnownedWindow {
|
|||
self.set_position_physical(x, y);
|
||||
}
|
||||
|
||||
pub(crate) fn inner_size_physical(&self) -> (u32, u32) {
|
||||
pub(crate) fn surface_size_physical(&self) -> (u32, u32) {
|
||||
// This should be okay to unwrap since the only error XGetGeometry can return
|
||||
// is BadWindow, and if the window handle is bad we have bigger problems.
|
||||
self.xconn
|
||||
|
|
@ -1569,23 +1569,23 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn inner_size(&self) -> PhysicalSize<u32> {
|
||||
self.inner_size_physical().into()
|
||||
pub fn surface_size(&self) -> PhysicalSize<u32> {
|
||||
self.surface_size_physical().into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outer_size(&self) -> PhysicalSize<u32> {
|
||||
let extents = self.shared_state_lock().frame_extents.clone();
|
||||
if let Some(extents) = extents {
|
||||
let (width, height) = self.inner_size_physical();
|
||||
extents.inner_size_to_outer(width, height).into()
|
||||
let (width, height) = self.surface_size_physical();
|
||||
extents.surface_size_to_outer(width, height).into()
|
||||
} else {
|
||||
self.update_cached_frame_extents();
|
||||
self.outer_size()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn request_inner_size_physical(&self, width: u32, height: u32) {
|
||||
pub(crate) fn request_surface_size_physical(&self, width: u32, height: u32) {
|
||||
self.xconn
|
||||
.xcb_connection()
|
||||
.configure_window(
|
||||
|
|
@ -1601,7 +1601,7 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn request_inner_size(&self, size: Size) -> Option<PhysicalSize<u32>> {
|
||||
pub fn request_surface_size(&self, size: Size) -> Option<PhysicalSize<u32>> {
|
||||
let scale_factor = self.scale_factor();
|
||||
let size = size.to_physical::<u32>(scale_factor).into();
|
||||
if !self.shared_state_lock().is_resizable {
|
||||
|
|
@ -1611,7 +1611,7 @@ impl UnownedWindow {
|
|||
})
|
||||
.expect("Failed to call `XSetWMNormalHints`");
|
||||
}
|
||||
self.request_inner_size_physical(size.0 as u32, size.1 as u32);
|
||||
self.request_surface_size_physical(size.0 as u32, size.1 as u32);
|
||||
|
||||
None
|
||||
}
|
||||
|
|
@ -1638,7 +1638,7 @@ impl UnownedWindow {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn set_min_inner_size_physical(&self, dimensions: Option<(u32, u32)>) {
|
||||
pub(crate) fn set_min_surface_size_physical(&self, dimensions: Option<(u32, u32)>) {
|
||||
self.update_normal_hints(|normal_hints| {
|
||||
normal_hints.min_size =
|
||||
dimensions.map(|(w, h)| (cast_dimension_to_hint(w), cast_dimension_to_hint(h)))
|
||||
|
|
@ -1647,14 +1647,14 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_min_inner_size(&self, dimensions: Option<Size>) {
|
||||
self.shared_state_lock().min_inner_size = dimensions;
|
||||
pub fn set_min_surface_size(&self, dimensions: Option<Size>) {
|
||||
self.shared_state_lock().min_surface_size = dimensions;
|
||||
let physical_dimensions =
|
||||
dimensions.map(|dimensions| dimensions.to_physical::<u32>(self.scale_factor()).into());
|
||||
self.set_min_inner_size_physical(physical_dimensions);
|
||||
self.set_min_surface_size_physical(physical_dimensions);
|
||||
}
|
||||
|
||||
pub(crate) fn set_max_inner_size_physical(&self, dimensions: Option<(u32, u32)>) {
|
||||
pub(crate) fn set_max_surface_size_physical(&self, dimensions: Option<(u32, u32)>) {
|
||||
self.update_normal_hints(|normal_hints| {
|
||||
normal_hints.max_size =
|
||||
dimensions.map(|(w, h)| (cast_dimension_to_hint(w), cast_dimension_to_hint(h)))
|
||||
|
|
@ -1663,15 +1663,15 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_max_inner_size(&self, dimensions: Option<Size>) {
|
||||
self.shared_state_lock().max_inner_size = dimensions;
|
||||
pub fn set_max_surface_size(&self, dimensions: Option<Size>) {
|
||||
self.shared_state_lock().max_surface_size = dimensions;
|
||||
let physical_dimensions =
|
||||
dimensions.map(|dimensions| dimensions.to_physical::<u32>(self.scale_factor()).into());
|
||||
self.set_max_inner_size_physical(physical_dimensions);
|
||||
self.set_max_surface_size_physical(physical_dimensions);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn resize_increments(&self) -> Option<PhysicalSize<u32>> {
|
||||
pub fn surface_resize_increments(&self) -> Option<PhysicalSize<u32>> {
|
||||
WmSizeHints::get(
|
||||
self.xconn.xcb_connection(),
|
||||
self.xwindow as xproto::Window,
|
||||
|
|
@ -1685,8 +1685,8 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_resize_increments(&self, increments: Option<Size>) {
|
||||
self.shared_state_lock().resize_increments = increments;
|
||||
pub fn set_surface_resize_increments(&self, increments: Option<Size>) {
|
||||
self.shared_state_lock().surface_resize_increments = increments;
|
||||
let physical_increments =
|
||||
increments.map(|increments| cast_size_to_hint(increments, self.scale_factor()));
|
||||
self.update_normal_hints(|hints| hints.size_increment = physical_increments)
|
||||
|
|
@ -1704,14 +1704,15 @@ impl UnownedWindow {
|
|||
let scale_factor = new_scale_factor / old_scale_factor;
|
||||
self.update_normal_hints(|normal_hints| {
|
||||
let dpi_adjuster = |size: Size| -> (i32, i32) { cast_size_to_hint(size, scale_factor) };
|
||||
let max_size = shared_state.max_inner_size.map(dpi_adjuster);
|
||||
let min_size = shared_state.min_inner_size.map(dpi_adjuster);
|
||||
let resize_increments = shared_state.resize_increments.map(dpi_adjuster);
|
||||
let max_size = shared_state.max_surface_size.map(dpi_adjuster);
|
||||
let min_size = shared_state.min_surface_size.map(dpi_adjuster);
|
||||
let surface_resize_increments =
|
||||
shared_state.surface_resize_increments.map(dpi_adjuster);
|
||||
let base_size = shared_state.base_size.map(dpi_adjuster);
|
||||
|
||||
normal_hints.max_size = max_size;
|
||||
normal_hints.min_size = min_size;
|
||||
normal_hints.size_increment = resize_increments;
|
||||
normal_hints.size_increment = surface_resize_increments;
|
||||
normal_hints.base_size = base_size;
|
||||
})
|
||||
.expect("Failed to update normal hints");
|
||||
|
|
@ -1734,9 +1735,9 @@ impl UnownedWindow {
|
|||
|
||||
let (min_size, max_size) = if resizable {
|
||||
let shared_state_lock = self.shared_state_lock();
|
||||
(shared_state_lock.min_inner_size, shared_state_lock.max_inner_size)
|
||||
(shared_state_lock.min_surface_size, shared_state_lock.max_surface_size)
|
||||
} else {
|
||||
let window_size = Some(Size::from(self.inner_size()));
|
||||
let window_size = Some(Size::from(self.surface_size()));
|
||||
(window_size, window_size)
|
||||
};
|
||||
self.shared_state_lock().is_resizable = resizable;
|
||||
|
|
@ -1745,11 +1746,11 @@ impl UnownedWindow {
|
|||
.expect_then_ignore_error("Failed to call `XSetWMNormalHints`");
|
||||
|
||||
let scale_factor = self.scale_factor();
|
||||
let min_inner_size = min_size.map(|size| cast_size_to_hint(size, scale_factor));
|
||||
let max_inner_size = max_size.map(|size| cast_size_to_hint(size, scale_factor));
|
||||
let min_surface_size = min_size.map(|size| cast_size_to_hint(size, scale_factor));
|
||||
let max_surface_size = max_size.map(|size| cast_size_to_hint(size, scale_factor));
|
||||
self.update_normal_hints(|normal_hints| {
|
||||
normal_hints.min_size = min_inner_size;
|
||||
normal_hints.max_size = max_inner_size;
|
||||
normal_hints.min_size = min_surface_size;
|
||||
normal_hints.max_size = max_surface_size;
|
||||
})
|
||||
.expect("Failed to call `XSetWMNormalHints`");
|
||||
}
|
||||
|
|
@ -1946,7 +1947,7 @@ impl UnownedWindow {
|
|||
pub fn set_cursor_hittest(&self, hittest: bool) -> Result<(), ExternalError> {
|
||||
let mut rectangles: Vec<Rectangle> = Vec::new();
|
||||
if hittest {
|
||||
let size = self.inner_size();
|
||||
let size = self.surface_size();
|
||||
rectangles.push(Rectangle {
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue