diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/haiku_support.cc | 46 | ||||
-rw-r--r-- | src/haikuterm.c | 39 | ||||
-rw-r--r-- | src/haikuterm.h | 2 |
3 files changed, 31 insertions, 56 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index f0db852e26e..0642dbacff7 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -89,6 +89,7 @@ enum CANCEL_DROP = 3003, SHOW_MENU_BAR = 3004, BE_MENU_BAR_OPEN = 3005, + QUIT_APPLICATION = 3006, }; static color_space dpy_color_space = B_NO_COLOR_SPACE; @@ -418,6 +419,15 @@ public: haiku_write (APP_QUIT_REQUESTED_EVENT, &rq); return 0; } + + void + MessageReceived (BMessage *msg) + { + if (msg->what == QUIT_APPLICATION) + Quit (); + else + BApplication::MessageReceived (msg); + } }; class EmacsWindow : public BWindow @@ -2328,13 +2338,15 @@ public: static int32 start_running_application (void *data) { + Emacs *app = (Emacs *) data; + haiku_io_init_in_app_thread (); - if (!((Emacs *) data)->Lock ()) + if (!app->Lock ()) gui_abort ("Failed to lock application"); - ((Emacs *) data)->Run (); - ((Emacs *) data)->Unlock (); + app->Run (); + app->Unlock (); return 0; } @@ -2404,25 +2416,37 @@ BBitmap_dimensions (void *bitmap, int *left, int *top, *mono_p = (((BBitmap *) bitmap)->ColorSpace () == B_GRAY1); } +static void +wait_for_exit_of_app_thread (void) +{ + status_t ret; + + be_app->PostMessage (QUIT_APPLICATION); + wait_for_thread (app_thread, &ret); +} + /* Set up an application and return it. If starting the application thread fails, abort Emacs. */ void * BApplication_setup (void) { - if (be_app) - return be_app; thread_id id; Emacs *app; + if (be_app) + return be_app; + app = new Emacs; app->Unlock (); + if ((id = spawn_thread (start_running_application, "Emacs app thread", B_DEFAULT_MEDIA_PRIORITY, app)) < 0) gui_abort ("spawn_thread failed"); resume_thread (id); - app_thread = id; + + atexit (wait_for_exit_of_app_thread); return app; } @@ -3772,16 +3796,6 @@ be_popup_file_dialog (int open_p, const char *default_dir, int must_match_p, int } } -void -be_app_quit (void) -{ - if (be_app) - { - while (!be_app->Lock ()); - be_app->Quit (); - } -} - /* Zoom WINDOW. */ void BWindow_zoom (void *window) diff --git a/src/haikuterm.c b/src/haikuterm.c index bc21276437d..6137e985b47 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -115,44 +115,7 @@ haiku_toolkit_position (struct frame *f, int x, int y, static void haiku_delete_terminal (struct terminal *terminal) { - struct haiku_display_info *dpyinfo = terminal->display_info.haiku; - struct terminal *t; - - if (!terminal->name) - return; - - block_input (); - - be_app_quit (); - delete_port (port_application_to_emacs); - - BCursor_delete (dpyinfo->text_cursor); - BCursor_delete (dpyinfo->nontext_cursor); - BCursor_delete (dpyinfo->modeline_cursor); - BCursor_delete (dpyinfo->hand_cursor); - BCursor_delete (dpyinfo->hourglass_cursor); - BCursor_delete (dpyinfo->horizontal_drag_cursor); - BCursor_delete (dpyinfo->vertical_drag_cursor); - BCursor_delete (dpyinfo->left_edge_cursor); - BCursor_delete (dpyinfo->top_left_corner_cursor); - BCursor_delete (dpyinfo->top_edge_cursor); - BCursor_delete (dpyinfo->top_right_corner_cursor); - BCursor_delete (dpyinfo->right_edge_cursor); - BCursor_delete (dpyinfo->bottom_right_corner_cursor); - BCursor_delete (dpyinfo->bottom_edge_cursor); - BCursor_delete (dpyinfo->bottom_left_corner_cursor); - BCursor_delete (dpyinfo->no_cursor); - - /* Close all frames and delete the generic struct terminal. */ - for (t = terminal_list; t; t = t->next_terminal) - { - if (t->type == output_haiku && t->display_info.haiku == dpyinfo) - { - delete_terminal (t); - break; - } - } - unblock_input (); + error ("The Haiku terminal cannot be deleted"); } static const char * diff --git a/src/haikuterm.h b/src/haikuterm.h index 5f905ab4000..7022ea77dec 100644 --- a/src/haikuterm.h +++ b/src/haikuterm.h @@ -260,8 +260,6 @@ extern void syms_of_haikufont (void); extern void syms_of_haikuselect (void); extern void init_haiku_select (void); -extern void be_app_quit (void); - extern void haiku_iconify_frame (struct frame *); extern void haiku_visualize_frame (struct frame *); extern void haiku_unvisualize_frame (struct frame *); |