Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 23, 2024
1 parent 2f1da08 commit f01fa02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions examples/tao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn main() {
edit_m.append_items(&[&copy_i, &PredefinedMenuItem::separator(), &paste_i]);

#[cfg(target_os = "windows")]
{
unsafe {
menu_bar.init_for_hwnd(window.hwnd() as _);
menu_bar.init_for_hwnd(window2.hwnd() as _);
}
Expand Down Expand Up @@ -221,7 +221,9 @@ fn main() {
fn show_context_menu(window: &Window, menu: &dyn ContextMenu, position: Option<Position>) {
println!("Show context menu at position {position:?}");
#[cfg(target_os = "windows")]
menu.show_context_menu_for_hwnd(window.hwnd() as _, position);
unsafe {
menu.show_context_menu_for_hwnd(window.hwnd() as _, position);
}
#[cfg(target_os = "linux")]
menu.show_context_menu_for_gtk_window(window.gtk_window().as_ref(), position);
#[cfg(target_os = "macos")]
Expand Down
6 changes: 3 additions & 3 deletions examples/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ fn main() {
{
use winit::raw_window_handle::*;
if let RawWindowHandle::Win32(handle) = window.window_handle().unwrap().as_raw() {
menu_bar.init_for_hwnd(handle.hwnd.get());
unsafe { menu_bar.init_for_hwnd(handle.hwnd.get()) };
}
if let RawWindowHandle::Win32(handle) = window2.window_handle().unwrap().as_raw() {
menu_bar.init_for_hwnd(handle.hwnd.get());
unsafe { menu_bar.init_for_hwnd(handle.hwnd.get()) };
}
}
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -206,7 +206,7 @@ fn show_context_menu(window: &Window, menu: &dyn ContextMenu, position: Option<P
{
use winit::raw_window_handle::*;
if let RawWindowHandle::Win32(handle) = window.window_handle().unwrap().as_raw() {
menu.show_context_menu_for_hwnd(handle.hwnd.get(), position);
unsafe { menu.show_context_menu_for_hwnd(handle.hwnd.get(), position) };
}
}
#[cfg(target_os = "macos")]
Expand Down
6 changes: 4 additions & 2 deletions examples/wry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn main() -> wry::Result<()> {
.unwrap();

#[cfg(target_os = "windows")]
{
unsafe {
menu_bar.init_for_hwnd(window.hwnd() as _).unwrap();
menu_bar.init_for_hwnd(window2.hwnd() as _).unwrap();
}
Expand Down Expand Up @@ -306,7 +306,9 @@ fn main() -> wry::Result<()> {
fn show_context_menu(window: &Window, menu: &dyn ContextMenu, position: Option<Position>) {
println!("Show context menu at position {position:?}");
#[cfg(target_os = "windows")]
menu.show_context_menu_for_hwnd(window.hwnd() as _, position);
unsafe {
menu.show_context_menu_for_hwnd(window.hwnd() as _, position);
}
#[cfg(target_os = "linux")]
menu.show_context_menu_for_gtk_window(window.gtk_window().as_ref(), position);
#[cfg(target_os = "macos")]
Expand Down

0 comments on commit f01fa02

Please sign in to comment.