feat(win32 gui): issue quit command on window close and exit cleanly
This commit is contained in:
parent
21a7106fe3
commit
a6b29e4fe9
2 changed files with 14 additions and 2 deletions
|
@ -125,8 +125,8 @@ pub fn render(self: *Self) error{}!void {
|
|||
}
|
||||
}
|
||||
pub fn stop(self: *Self) void {
|
||||
_ = self;
|
||||
std.log.warn("TODO: implement stop", .{});
|
||||
gui.stop();
|
||||
if (self.thread) |thread| thread.join();
|
||||
}
|
||||
|
||||
pub fn stdplane(self: *Self) Plane {
|
||||
|
|
|
@ -16,6 +16,8 @@ const windowmsg = @import("windowmsg.zig");
|
|||
|
||||
const HResultError = ddui.HResultError;
|
||||
|
||||
const WM_APP_EXIT = win32.WM_APP + 1;
|
||||
|
||||
pub const DropWriter = struct {
|
||||
pub const WriteError = error{};
|
||||
pub const Writer = std.io.Writer(DropWriter, WriteError, write);
|
||||
|
@ -492,6 +494,11 @@ pub const Win32Error = struct {
|
|||
}
|
||||
};
|
||||
|
||||
pub fn stop() void {
|
||||
const hwnd = global.hwnd orelse return;
|
||||
_ = win32.SendMessageW(hwnd, WM_APP_EXIT, 0, 0);
|
||||
}
|
||||
|
||||
pub fn setWindowTitle(title: [*:0]const u16, err: *Win32Error) error{ NoWindow, Win32 }!void {
|
||||
global.mutex.lock();
|
||||
defer global.mutex.unlock();
|
||||
|
@ -1116,6 +1123,11 @@ fn WndProc(
|
|||
return 1; // background erased
|
||||
},
|
||||
win32.WM_CLOSE => {
|
||||
const state = stateFromHwnd(hwnd);
|
||||
state.pid.send(.{ "cmd", "quit" }) catch |e| onexit(e);
|
||||
return 0;
|
||||
},
|
||||
WM_APP_EXIT => {
|
||||
win32.PostQuitMessage(0);
|
||||
return 0;
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue