From 2ee975231b88252a7571f85804336c013d674221 Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Tue, 20 Oct 2020 17:04:37 -0500 Subject: [PATCH] fix Windows build --- .github/workflows/rust.yml | 0 .gitignore | 0 .rustfmt.toml | 0 Cargo.toml | 0 README.md | 0 examples/open_window.rs | 0 src/event.rs | 0 src/keyboard.rs | 0 src/lib.rs | 0 src/macos/mod.rs | 0 src/macos/window.rs | 0 src/mouse_cursor.rs | 0 src/win/mod.rs | 0 src/win/window.rs | 19 +++++++++++++------ src/window_info.rs | 0 src/window_open_options.rs | 0 src/x11/cursor.rs | 0 src/x11/mod.rs | 0 src/x11/window.rs | 0 src/x11/xcb_connection.rs | 0 20 files changed, 13 insertions(+), 6 deletions(-) mode change 100755 => 100644 .github/workflows/rust.yml mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .rustfmt.toml mode change 100755 => 100644 Cargo.toml mode change 100755 => 100644 README.md mode change 100755 => 100644 examples/open_window.rs mode change 100755 => 100644 src/event.rs mode change 100755 => 100644 src/keyboard.rs mode change 100755 => 100644 src/lib.rs mode change 100755 => 100644 src/macos/mod.rs mode change 100755 => 100644 src/macos/window.rs mode change 100755 => 100644 src/mouse_cursor.rs mode change 100755 => 100644 src/win/mod.rs mode change 100755 => 100644 src/win/window.rs mode change 100755 => 100644 src/window_info.rs mode change 100755 => 100644 src/window_open_options.rs mode change 100755 => 100644 src/x11/cursor.rs mode change 100755 => 100644 src/x11/mod.rs mode change 100755 => 100644 src/x11/window.rs mode change 100755 => 100644 src/x11/xcb_connection.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.rustfmt.toml b/.rustfmt.toml old mode 100755 new mode 100644 diff --git a/Cargo.toml b/Cargo.toml old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/examples/open_window.rs b/examples/open_window.rs old mode 100755 new mode 100644 diff --git a/src/event.rs b/src/event.rs old mode 100755 new mode 100644 diff --git a/src/keyboard.rs b/src/keyboard.rs old mode 100755 new mode 100644 diff --git a/src/lib.rs b/src/lib.rs old mode 100755 new mode 100644 diff --git a/src/macos/mod.rs b/src/macos/mod.rs old mode 100755 new mode 100644 diff --git a/src/macos/window.rs b/src/macos/window.rs old mode 100755 new mode 100644 diff --git a/src/mouse_cursor.rs b/src/mouse_cursor.rs old mode 100755 new mode 100644 diff --git a/src/win/mod.rs b/src/win/mod.rs old mode 100755 new mode 100644 diff --git a/src/win/window.rs b/src/win/window.rs old mode 100755 new mode 100644 index c74e7d4..bab6d9e --- a/src/win/window.rs +++ b/src/win/window.rs @@ -8,7 +8,7 @@ use winapi::um::winuser::{ SetWindowLongPtrA, TranslateMessage, UnregisterClassA, CS_OWNDC, GWLP_USERDATA, MB_ICONERROR, MB_OK, MB_TOPMOST, MSG, WM_CLOSE, WM_CREATE, WM_MOUSEMOVE, WM_PAINT, WM_SHOWWINDOW, WM_TIMER, WNDCLASSA, WS_CAPTION, WS_CHILD, WS_CLIPSIBLINGS, WS_MAXIMIZEBOX, WS_MINIMIZEBOX, - WS_POPUPWINDOW, WS_SIZEBOX, WS_VISIBLE, + WS_POPUPWINDOW, WS_SIZEBOX, WS_VISIBLE, WM_DPICHANGED, }; use std::cell::RefCell; @@ -24,8 +24,7 @@ use raw_window_handle::{ use crate::{ Event, KeyboardEvent, MouseButton, MouseEvent, Parent::WithParent, ScrollDelta, WindowEvent, - WindowHandler, WindowInfo, WindowOpenOptions, WindowOpenResult, WindowScalePolicy, Size, Point, - PhySize, PhyPoint, + WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy, Size, Point, PhySize, PhyPoint, }; unsafe fn message_box(title: &str, msg: &str) { @@ -108,6 +107,9 @@ unsafe extern "system" fn wnd_proc( .on_event(&mut window, Event::Window(WindowEvent::WillClose)); return DefWindowProcA(hwnd, msg, wparam, lparam); } + WM_DPICHANGED => { + // TODO: Notify app of DPI change + } _ => {} } } @@ -194,8 +196,8 @@ impl Window { let scaling = match options.scale { // TODO: Find system scale factor - WindowScalePolicy::TrySystemScaleFactor => 1.0, - WindowScalePolicy::TrySystemScaleFactorTimes(user_scale) => 1.0 * user_scale, + WindowScalePolicy::TrySystemScaleFactor => get_scaling().unwrap_or(1.0), + WindowScalePolicy::TrySystemScaleFactorTimes(user_scale) => get_scaling().unwrap_or(1.0) * user_scale, WindowScalePolicy::UseScaleFactor(user_scale) => user_scale, WindowScalePolicy::NoScaling => 1.0, }; @@ -254,7 +256,7 @@ impl Window { SetWindowLongPtrA(hwnd, GWLP_USERDATA, Box::into_raw(window_state) as *const _ as _); SetTimer(hwnd, 4242, 13, None); - Ok((WindowHandle { hwnd }, window_info)) + WindowHandle { hwnd } } } } @@ -267,3 +269,8 @@ unsafe impl HasRawWindowHandle for Window { }) } } + +fn get_scaling() -> Option { + // TODO: find system scaling + None +} \ No newline at end of file diff --git a/src/window_info.rs b/src/window_info.rs old mode 100755 new mode 100644 diff --git a/src/window_open_options.rs b/src/window_open_options.rs old mode 100755 new mode 100644 diff --git a/src/x11/cursor.rs b/src/x11/cursor.rs old mode 100755 new mode 100644 diff --git a/src/x11/mod.rs b/src/x11/mod.rs old mode 100755 new mode 100644 diff --git a/src/x11/window.rs b/src/x11/window.rs old mode 100755 new mode 100644 diff --git a/src/x11/xcb_connection.rs b/src/x11/xcb_connection.rs old mode 100755 new mode 100644