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;
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
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;
}
*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;
}
}
}
-void
-be_app_quit (void)
-{
- if (be_app)
- {
- while (!be_app->Lock ());
- be_app->Quit ();
- }
-}
-
/* Zoom WINDOW. */
void
BWindow_zoom (void *window)
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 *
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 *);