Haiku: handle the quit request message
This commit is contained in:
parent
0038e27fc3
commit
93ac4ace0a
3 changed files with 18 additions and 19 deletions
|
@ -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();
|
||||
Sync();
|
||||
|
||||
//if (NeedsUpdate()) {
|
||||
// ERR_PRINT("NEEDS UPDATE");
|
||||
// Main::force_redraw();
|
||||
//}
|
||||
|
||||
//ERR_PRINT("iteration 2");
|
||||
break;
|
||||
|
||||
case B_INVALIDATE:
|
||||
ERR_PRINT("WINDOW B_INVALIDATE");
|
||||
//Main::force_redraw();
|
||||
if (Main::iteration() == true) {
|
||||
view->EnableDirectMode(false);
|
||||
Quit();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -30,6 +30,7 @@ void OS_Haiku::run() {
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
app->Run();
|
||||
window->StopMessageRunner();
|
||||
delete app;
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue