Skip to content

Commit d29dd8d

Browse files
committed
fix: send size update when autosized surface resizes
1 parent 2aee373 commit d29dd8d

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

sctk/src/application.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ use iced_futures::{
3131
},
3232
Executor, Runtime, Subscription,
3333
};
34-
// use iced_native::{
35-
// application::{self, StyleSheet},
36-
// clipboard,
37-
// command::platform_specific::{
38-
// self,
39-
// wayland::{data_device::DndIcon, popup},
40-
// },
41-
// event::Status,
42-
// layout::Limits,
43-
// mouse::{self, Interaction},
44-
// widget::{operation::{self, focusable::{focus, find_focused}}, Tree, self},
45-
// Element, Renderer, Widget,
46-
// };
4734
use log::error;
4835

4936
use sctk::{
@@ -60,10 +47,6 @@ use iced_graphics::{
6047
// Color, Point, Viewport,
6148
Viewport,
6249
};
63-
// use iced_native::user_interface::{self, UserInterface};
64-
// use iced_native::window::Id as SurfaceId;
65-
use itertools::Itertools;
66-
// use iced_native::widget::Operation;
6750
use iced_runtime::{
6851
clipboard,
6952
command::{
@@ -79,12 +62,12 @@ use iced_runtime::{
7962
Command, Debug, Program, UserInterface,
8063
};
8164
use iced_style::application::{self, StyleSheet};
65+
use itertools::Itertools;
8266
use raw_window_handle::{
8367
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle,
8468
WaylandDisplayHandle, WaylandWindowHandle,
8569
};
8670
use std::mem::ManuallyDrop;
87-
// use iced_native::widget::operation::OperationWrapper;
8871

8972
pub enum Event<Message> {
9073
/// A normal sctk event
@@ -963,6 +946,18 @@ where
963946
None => continue,
964947
};
965948
state.set_logical_size(w as f64, h as f64);
949+
match surface_id {
950+
SurfaceIdWrapper::Window(id) => {
951+
ev_proxy.send_event(Event::Window(
952+
platform_specific::wayland::window::Action::Size {
953+
id: *id,
954+
width: w,
955+
height: h,
956+
},
957+
));
958+
}
959+
_ => {}
960+
};
966961
}
967962
auto_size_surfaces
968963
.insert(*surface_id, (w, h, limits, false));

sctk/src/event_loop/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ where
700700
if let Some(window) = self.state.windows.iter_mut().find(|w| w.id == id) {
701701
let (width, height) = (NonZeroU32::new(width).unwrap_or(NonZeroU32::new(1).unwrap()), NonZeroU32::new(height).unwrap_or(NonZeroU32::new(1).unwrap()));
702702
window.requested_size = Some((width.get(), height.get()));
703-
window.window.xdg_surface().set_window_geometry(0, 0, width.get() as i32, height.get() as i32);
703+
window.window.set_window_geometry(0, 0, width.get() as u32, height.get() as u32);
704+
window.current_size = Some((width, height));
704705
// TODO Ashley maybe don't force window size?
705706
pending_redraws.push(window.window.wl_surface().id());
706707

0 commit comments

Comments
 (0)