Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cancel_quit on windows not doing anything #441

Merged
merged 1 commit into from
Jun 18, 2024
Merged
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
13 changes: 5 additions & 8 deletions src/native/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,17 @@

match umsg {
WM_CLOSE => {
let mut quit_requested = false;

let mut d = crate::native_display().lock().unwrap();
// only give user a chance to intervene when sapp_quit() wasn't already called
if !d.quit_ordered {
// if window should be closed and event handling is enabled, give user code
// a change to intervene via sapp_cancel_quit()
d.quit_requested = true;
quit_requested = true;
drop(d);
// the prevent event may require access to native_display
event_handler.quit_requested_event();
// Re-acquire native_display
d = crate::native_display().lock().unwrap();
// if user code hasn't intervened, quit the app
if d.quit_requested {
d.quit_ordered = true;
Expand All @@ -301,11 +303,6 @@
if d.quit_ordered {
PostQuitMessage(0);
}

if quit_requested {
drop(d);
event_handler.quit_requested_event();
}
return 0;
}
WM_SYSCOMMAND => {
Expand Down Expand Up @@ -826,7 +823,7 @@

fn process_request(&mut self, request: Request) {
use Request::*;
unsafe {

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

View workflow job for this annotation

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

unnecessary `unsafe` block

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

View workflow job for this annotation

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

unnecessary `unsafe` block
match request {
ScheduleUpdate => {
self.update_requested = true;
Expand All @@ -840,7 +837,7 @@
} => self.set_window_size(new_width as _, new_height as _),
SetWindowPosition { new_x, new_y } => self.set_window_position(new_x, new_y),
SetFullscreen(fullscreen) => self.set_fullscreen(fullscreen),
ShowKeyboard(show) => {

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

View workflow job for this annotation

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

unused variable: `show`

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

View workflow job for this annotation

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

unused variable: `show`
eprintln!("Not implemented for windows")
}
}
Expand Down
Loading