From 93ac4ace0a0d84fdd7003fcaa02296d55ad5b2ad Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Sat, 20 Jun 2015 01:59:32 +0300 Subject: Haiku: handle the quit request message --- platform/haiku/haiku_direct_window.cpp | 32 +++++++++++++------------------- platform/haiku/haiku_direct_window.h | 2 ++ platform/haiku/os_haiku.cpp | 3 +++ 3 files changed, 18 insertions(+), 19 deletions(-) (limited to 'platform/haiku') diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 62231565a9..3fccab10dd 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -2,7 +2,7 @@ #include "haiku_direct_window.h" HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) - : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, 0) + : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { last_mouse_pos_valid = false; last_buttons_state = 0; @@ -33,10 +33,13 @@ void HaikuDirectWindow::SetInput(InputDefault* p_input) { input = p_input; } +void HaikuDirectWindow::SetMainLoop(MainLoop* p_main_loop) { + main_loop = p_main_loop; +} + bool HaikuDirectWindow::QuitRequested() { - view->EnableDirectMode(false); - be_app->PostMessage(B_QUIT_REQUESTED); - return true; + main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); + return false; } void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { @@ -44,24 +47,15 @@ void HaikuDirectWindow::DirectConnected(direct_buffer_info* info) { view->EnableDirectMode(true); } -void HaikuDirectWindow::MessageReceived(BMessage* message) -{ +void HaikuDirectWindow::MessageReceived(BMessage* message) { switch (message->what) { case REDRAW_MSG: - //ERR_PRINT("iteration 1"); - Main::iteration(); - - //if (NeedsUpdate()) { - // ERR_PRINT("NEEDS UPDATE"); - // Main::force_redraw(); - //} - - //ERR_PRINT("iteration 2"); - break; + Sync(); - case B_INVALIDATE: - ERR_PRINT("WINDOW B_INVALIDATE"); - //Main::force_redraw(); + if (Main::iteration() == true) { + view->EnableDirectMode(false); + Quit(); + } break; default: diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index be4dcd9e94..c985cdc5d6 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -18,6 +18,7 @@ private: uint32 last_buttons_state; int last_button_mask; + MainLoop* main_loop; InputDefault* input; HaikuGLView* view; BMessageRunner* update_runner; @@ -35,6 +36,7 @@ public: void StartMessageRunner(); void StopMessageRunner(); void SetInput(InputDefault* p_input); + void SetMainLoop(MainLoop* p_main_loop); virtual bool QuitRequested(); virtual void DirectConnected(direct_buffer_info* info); virtual void MessageReceived(BMessage* message); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 3694244e0a..699b0ba1ce 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -29,6 +29,7 @@ void OS_Haiku::run() { } } */ + app->Run(); window->StopMessageRunner(); @@ -142,6 +143,7 @@ void OS_Haiku::finalize() { void OS_Haiku::set_main_loop(MainLoop* p_main_loop) { main_loop = p_main_loop; input->set_main_loop(p_main_loop); + window->SetMainLoop(p_main_loop); } MainLoop* OS_Haiku::get_main_loop() const { @@ -154,6 +156,7 @@ void OS_Haiku::delete_main_loop() { } main_loop = NULL; + window->SetMainLoop(NULL); } void OS_Haiku::release_rendering_thread() { -- cgit v1.2.3