From 52edc8bb1167d670a5c1e37d19b8c09a260fd2cb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 2 Apr 2022 09:40:41 -0700 Subject: [PATCH] window: speculative code to enable initial position on windows need to move this to my windows machine to try it refs: #1794 --- window/src/os/windows/window.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index 70efcb0dd..aaae4f16e 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -328,6 +328,8 @@ impl Window { config: ConfigHandle, class_name: &str, name: &str, + x: i16, + y: i16, width: usize, height: usize, lparam: *const RefCell, @@ -364,7 +366,7 @@ impl Window { let (width, height) = adjust_client_to_window_dimensions(style, width, height); let (x, y) = if (style & WS_POPUP) == 0 { - (CW_USEDEFAULT, CW_USEDEFAULT) + (x, y) } else { // WS_POPUP windows need to specify the initial position. // We pick the middle of the primary monitor @@ -469,8 +471,16 @@ impl Window { }; let width = geometry.width.evaluate_as_pixels(width_context) as usize; let height = geometry.height.evaluate_as_pixels(height_context) as usize; + let x = geometry + .x + .map(|x| x.evaluate_as_pixels(width_context) as i16) + .unwrap_or(CW_USEDEFAULT); + let y = geometry + .y + .map(|y| y.evaluate_as_pixels(height_context) as i16) + .unwrap_or(CW_USEDEFAULT); - let hwnd = match Self::create_window(config, class_name, name, width, height, raw) { + let hwnd = match Self::create_window(config, class_name, name, x, y, width, height, raw) { Ok(hwnd) => HWindow(hwnd), Err(err) => { // Ensure that we drop the extra ref to raw before we return