Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
}
/// This for now is Android specific since the process can continue running but the display
/// is restarted. We support reinitializing the display.
fn set_or_replace_display(display: native::NativeDisplayData) {

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-ios)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, aarch64-apple-ios)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-darwin)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, armv7-unknown-linux-gnueabihf)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-unknown-linux-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, aarch64-unknown-linux-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, wasm32-unknown-unknown)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

function `set_or_replace_display` is never used
if let Some(m) = NATIVE_DISPLAY.get() {
// Replace existing display
*m.lock().unwrap() = display;
Expand Down Expand Up @@ -439,6 +439,15 @@
let d = native_display().lock().unwrap();
d.view_ctrl
}

/// Get the main window HWND as a raw pointer (`*mut c_void`).
///
/// Returns `null_mut()` if the window has not been created yet.
/// Only available on Windows.
#[cfg(target_os = "windows")]
pub fn windows_hwnd() -> *mut std::ffi::c_void {
crate::native_display().lock().unwrap().hwnd
}
}

#[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)]
Expand Down
9 changes: 7 additions & 2 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ pub(crate) struct NativeDisplayData {
pub dropped_files: DroppedFiles,
pub blocking_event_loop: bool,

#[cfg(target_os = "windows")]
pub hwnd: *mut std::ffi::c_void,

#[cfg(target_vendor = "apple")]
pub view: crate::native::apple::frameworks::ObjcId,
#[cfg(target_os = "ios")]
pub view_ctrl: crate::native::apple::frameworks::ObjcId,
#[cfg(target_vendor = "apple")]
pub gfx_api: crate::conf::AppleGfxApi,
}
#[cfg(target_vendor = "apple")]
#[cfg(any(target_vendor = "apple", target_os = "windows"))]
unsafe impl Send for NativeDisplayData {}
#[cfg(target_vendor = "apple")]
#[cfg(any(target_vendor = "apple", target_os = "windows"))]
unsafe impl Sync for NativeDisplayData {}

impl NativeDisplayData {
Expand All @@ -56,6 +59,8 @@ impl NativeDisplayData {
clipboard,
dropped_files: Default::default(),
blocking_event_loop: false,
#[cfg(target_os = "windows")]
hwnd: std::ptr::null_mut(),
#[cfg(target_vendor = "apple")]
gfx_api: crate::conf::AppleGfxApi::OpenGl,
#[cfg(target_vendor = "apple")]
Expand Down
1 change: 1 addition & 0 deletions src/native/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
if unsafe { GetClientRect(self.wnd, &mut rect as *mut _ as _) } != 0 {
let mut new_rect = rect;
new_rect.right = new_rect.right - new_rect.left + new_x as i32;
new_rect.bottom = new_rect.bottom - new_rect.top + new_y as i32;

Check warning on line 253 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

value assigned to `new_rect` is never read

Check warning on line 253 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

value assigned to `new_rect` is never read
unsafe {
SetWindowPos(
self.wnd,
Expand Down Expand Up @@ -1203,6 +1203,7 @@
high_dpi: conf.high_dpi,
dpi_scale: display.window_scale,
blocking_event_loop: conf.platform.blocking_event_loop,
hwnd: wnd as *mut std::ffi::c_void,
..NativeDisplayData::new(conf.window_width, conf.window_height, tx, clipboard)
});

Expand Down
Loading