mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
ohos: Support resizing the surface (#35158)
A window resize requires to also resize the webview, otherwise it will stay at the original size. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
f6d1b30e97
commit
53fcc98585
5 changed files with 87 additions and 31 deletions
|
@ -9,7 +9,6 @@ use std::rc::Rc;
|
|||
|
||||
use log::{debug, info};
|
||||
use servo::compositing::CompositeTarget;
|
||||
use servo::euclid::Size2D;
|
||||
use servo::webrender_traits::SurfmanRenderingContext;
|
||||
/// The EventLoopWaker::wake function will be called from any thread.
|
||||
/// It will be called to notify embedder that some events are available,
|
||||
|
@ -17,7 +16,7 @@ use servo::webrender_traits::SurfmanRenderingContext;
|
|||
pub use servo::EventLoopWaker;
|
||||
use servo::{self, resources, Servo};
|
||||
use surfman::{Connection, SurfaceType};
|
||||
use xcomponent_sys::{OH_NativeXComponent, OH_NativeXComponent_GetXComponentSize};
|
||||
use xcomponent_sys::OH_NativeXComponent;
|
||||
|
||||
use crate::egl::host_trait::HostTrait;
|
||||
use crate::egl::ohos::resources::ResourceReaderInstance;
|
||||
|
@ -68,24 +67,13 @@ pub fn init(
|
|||
.create_adapter()
|
||||
.or(Err("Failed to create adapter"))?;
|
||||
|
||||
let mut width: u64 = 0;
|
||||
let mut height: u64 = 0;
|
||||
let res = unsafe {
|
||||
OH_NativeXComponent_GetXComponentSize(
|
||||
xcomponent,
|
||||
native_window,
|
||||
&mut width as *mut _,
|
||||
&mut height as *mut _,
|
||||
)
|
||||
let Ok(window_size) = (unsafe { super::get_xcomponent_size(xcomponent, native_window) }) else {
|
||||
return Err("Failed to get xcomponent size");
|
||||
};
|
||||
assert_eq!(res, 0, "OH_NativeXComponent_GetXComponentSize failed");
|
||||
let width: i32 = width.try_into().expect("Width too large");
|
||||
let height: i32 = height.try_into().expect("Height too large");
|
||||
|
||||
debug!("Creating surfman widget with width {width} and height {height}");
|
||||
let native_widget = unsafe {
|
||||
connection.create_native_widget_from_ptr(native_window, Size2D::new(width, height))
|
||||
};
|
||||
debug!("Creating surfman widget with {window_size:?}");
|
||||
let native_widget =
|
||||
unsafe { connection.create_native_widget_from_ptr(native_window, window_size) };
|
||||
let surface_type = SurfaceType::Widget { native_widget };
|
||||
|
||||
info!("Creating rendering context");
|
||||
|
@ -102,7 +90,14 @@ pub fn init(
|
|||
|
||||
let window_callbacks = Rc::new(ServoWindowCallbacks::new(
|
||||
callbacks,
|
||||
RefCell::new(Coordinates::new(0, 0, width, height, width, height)),
|
||||
RefCell::new(Coordinates::new(
|
||||
0,
|
||||
0,
|
||||
window_size.width,
|
||||
window_size.height,
|
||||
window_size.width,
|
||||
window_size.height,
|
||||
)),
|
||||
options.display_density as f32,
|
||||
));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue