fix: skip resize if size is unchanged
This commit is contained in:
parent
70b9736dc7
commit
fd2220775b
2 changed files with 25 additions and 0 deletions
|
|
@ -273,6 +273,11 @@ pub struct SctkPopup {
|
|||
|
||||
impl SctkPopup {
|
||||
pub(crate) fn set_size(&mut self, w: u32, h: u32, token: u32) {
|
||||
let guard = self.common.lock().unwrap();
|
||||
if guard.size.width == w && guard.size.height == h {
|
||||
return;
|
||||
}
|
||||
drop(guard);
|
||||
// update geometry
|
||||
self.popup
|
||||
.xdg_surface()
|
||||
|
|
@ -285,6 +290,9 @@ impl SctkPopup {
|
|||
|
||||
pub(crate) fn update_viewport(&mut self, w: u32, h: u32) {
|
||||
let common = self.common.lock().unwrap();
|
||||
if common.size.width == w && common.size.height == h {
|
||||
return;
|
||||
}
|
||||
if let Some(viewport) = common.wp_viewport.as_ref() {
|
||||
// Set inner size without the borders.
|
||||
viewport.set_destination(w as i32, h as i32);
|
||||
|
|
|
|||
|
|
@ -110,6 +110,12 @@ impl winit::window::Window for SctkWinitWindow {
|
|||
if logical_size.width == 0 || logical_size.height == 0 {
|
||||
return None;
|
||||
}
|
||||
if guard.size.width == logical_size.width
|
||||
&& guard.size.height == logical_size.height
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
guard.size = logical_size;
|
||||
guard.requested_size.0 = Some(guard.size.width);
|
||||
guard.requested_size.1 = Some(guard.size.height);
|
||||
|
|
@ -147,6 +153,12 @@ impl winit::window::Window for SctkWinitWindow {
|
|||
if logical_size.height > 0 {
|
||||
guard.size.height = logical_size.height;
|
||||
}
|
||||
if guard.size.width == logical_size.width
|
||||
&& guard.size.height == logical_size.height
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
layer_surface.set_size(logical_size.width, logical_size.height);
|
||||
if let Some(viewport) = guard.wp_viewport.as_ref() {
|
||||
// Set inner size without the borders.
|
||||
|
|
@ -158,6 +170,11 @@ impl winit::window::Window for SctkWinitWindow {
|
|||
}
|
||||
CommonSurface::Lock(_) => {}
|
||||
CommonSurface::Subsurface { .. } => {
|
||||
if guard.size.width == logical_size.width
|
||||
&& guard.size.height == logical_size.height
|
||||
{
|
||||
return None;
|
||||
}
|
||||
guard.requested_size = (
|
||||
(logical_size.width > 0).then_some(logical_size.width),
|
||||
(logical_size.height > 0).then_some(logical_size.height),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue