示例#1
0
文件: rtgui_app.c 项目: zdgaoyu/RTGUI
rt_inline void _rtgui_application_event_loop(struct rtgui_app *app)
{
	rt_err_t result;
	rt_uint16_t current_ref;
	struct rtgui_event *event;

	_rtgui_application_check(app);

	/* point to event buffer */
	event = (struct rtgui_event*)app->event_buffer;

	current_ref = ++app->ref_count;

	while (current_ref <= app->ref_count)
	{
		RT_ASSERT(current_ref == app->ref_count);

		if (app->on_idle != RT_NULL)
		{
			result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic));
			if (result == RT_EOK)
				RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
			else if (result == -RT_ETIMEOUT)
				app->on_idle(RTGUI_OBJECT(app), RT_NULL);
		}
		else
		{
			result = rtgui_recv(event, sizeof(union rtgui_event_generic));
			if (result == RT_EOK)
				RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
		}
	}
}
示例#2
0
文件: rtgui_app.c 项目: zdgaoyu/RTGUI
void rtgui_app_destroy(struct rtgui_app *app)
{
	rt_thread_t srv_tid;
    _rtgui_application_check(app);

	if (!(app->state_flag & RTGUI_APP_FLAG_EXITED))
	{
		rt_kprintf("cannot destroy a running application: %s.\n",
				   app->name);
		return;
	}

	/* send a message to notify rtgui server */
	srv_tid = rtgui_get_server();
	if (srv_tid != rt_thread_self()) /* must not the server thread */
	{
		struct rtgui_event_application event;
		RTGUI_EVENT_APP_DESTROY_INIT(&event);
		event.app = app;

		if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) != RT_EOK)
		{
			rt_kprintf("destroy an application in server failed\n");
			return ;
		}
	}

	app->tid->user_data = 0;
	rt_mq_delete(app->mq);
	rtgui_object_destroy(RTGUI_OBJECT(app));
}
示例#3
0
文件: rtgui_app.c 项目: zdgaoyu/RTGUI
rt_base_t rtgui_app_run(struct rtgui_app *app)
{
	_rtgui_application_check(app);

	app->state_flag &= ~RTGUI_APP_FLAG_EXITED;

	_rtgui_application_event_loop(app);

	if (app->ref_count == 0)
		app->state_flag |= RTGUI_APP_FLAG_EXITED;

	return app->exit_code;
}
示例#4
0
/**
 * set this application as window manager
 */
rt_err_t rtgui_app_set_as_wm(struct rtgui_app *app)
{
    struct rtgui_app *srv_app;
    struct rtgui_event_set_wm event;

    _rtgui_application_check(app);

    srv_app = rtgui_get_server();
    if (srv_app != RT_NULL)
    {
        /* notify rtgui server, this is a window manager */
        RTGUI_EVENT_SET_WM_INIT(&event);
        event.app = app;

        rtgui_send_sync(srv_app, RTGUI_EVENT(&event), sizeof(event));
        return RT_EOK;
    }

    return RT_ERROR;
}
示例#5
0
void rtgui_app_set_main_win(struct rtgui_app *app, struct rtgui_win *win)
{
    _rtgui_application_check(app);
    app->main_object = RTGUI_OBJECT(win);
}
示例#6
0
rtgui_idle_func_t rtgui_app_get_onidle(struct rtgui_app *app)
{

    _rtgui_application_check(app);
    return app->on_idle;
}
示例#7
0
void rtgui_app_set_onidle(struct rtgui_app *app, rtgui_idle_func_t onidle)
{
    _rtgui_application_check(app);
    app->on_idle = onidle;
}