rtgui_system.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /*
  2. * File : rtgui_system.c
  3. * This file is part of RTGUI in RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-10-04 Bernard first version
  13. */
  14. #include <rtgui/rtgui.h>
  15. #include <rtgui/image.h>
  16. #include <rtgui/font.h>
  17. #include <rtgui/event.h>
  18. #include <rtgui/rtgui_app.h>
  19. #include <rtgui/rtgui_server.h>
  20. #include <rtgui/rtgui_system.h>
  21. #include <rtgui/widgets/window.h>
  22. #include <rtgui/rtgui_theme.h>
  23. #ifdef _WIN32
  24. #define RTGUI_MEM_TRACE
  25. #endif
  26. void rtgui_system_server_init()
  27. {
  28. /* init image */
  29. rtgui_system_image_init();
  30. /* init font */
  31. rtgui_font_system_init();
  32. /* init rtgui server */
  33. rtgui_topwin_init();
  34. rtgui_server_init();
  35. /* init theme */
  36. rtgui_system_theme_init();
  37. }
  38. /************************************************************************/
  39. /* RTGUI Timer */
  40. /************************************************************************/
  41. static void rtgui_time_out(void* parameter)
  42. {
  43. rtgui_timer_t* timer;
  44. rtgui_event_timer_t event;
  45. timer = (rtgui_timer_t*)parameter;
  46. /*
  47. * Note: event_timer can not use RTGUI_EVENT_TIMER_INIT to init, for there is no
  48. * thread context
  49. */
  50. event.parent.type = RTGUI_EVENT_TIMER;
  51. event.parent.sender = RT_NULL;
  52. event.timer = timer;
  53. rtgui_send(timer->tid, &(event.parent), sizeof(rtgui_event_timer_t));
  54. }
  55. rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void* parameter)
  56. {
  57. rtgui_timer_t* timer;
  58. timer = (rtgui_timer_t*) rtgui_malloc(sizeof(rtgui_timer_t));
  59. timer->tid = rt_thread_self();
  60. timer->timeout = timeout;
  61. timer->user_data = parameter;
  62. /* init rt-thread timer */
  63. rt_timer_init(&(timer->timer), "rtgui", rtgui_time_out, timer, time, (rt_uint8_t)flag);
  64. return timer;
  65. }
  66. void rtgui_timer_destory(rtgui_timer_t* timer)
  67. {
  68. RT_ASSERT(timer != RT_NULL);
  69. /* stop timer firstly */
  70. rtgui_timer_stop(timer);
  71. /* detach rt-thread timer */
  72. rt_timer_detach(&(timer->timer));
  73. rtgui_free(timer);
  74. }
  75. void rtgui_timer_start(rtgui_timer_t* timer)
  76. {
  77. RT_ASSERT(timer != RT_NULL);
  78. /* start rt-thread timer */
  79. rt_timer_start(&(timer->timer));
  80. }
  81. void rtgui_timer_stop (rtgui_timer_t* timer)
  82. {
  83. RT_ASSERT(timer != RT_NULL);
  84. /* stop rt-thread timer */
  85. rt_timer_stop(&(timer->timer));
  86. }
  87. /************************************************************************/
  88. /* RTGUI Memory Management */
  89. /************************************************************************/
  90. #ifdef RTGUI_MEM_TRACE
  91. struct rtgui_mem_info
  92. {
  93. rt_uint32_t allocated_size;
  94. rt_uint32_t max_allocated;
  95. };
  96. struct rtgui_mem_info mem_info;
  97. #define MEMTRACE_MAX 4096
  98. #define MEMTRACE_HASH_SIZE 256
  99. struct rti_memtrace_item
  100. {
  101. void* mb_ptr; /* memory block pointer */
  102. rt_uint32_t mb_len; /* memory block length */
  103. struct rti_memtrace_item* next;
  104. };
  105. struct rti_memtrace_item trace_list[MEMTRACE_MAX];
  106. struct rti_memtrace_item *item_hash[MEMTRACE_HASH_SIZE];
  107. struct rti_memtrace_item *item_free;
  108. rt_bool_t rti_memtrace_inited = 0;
  109. void rti_memtrace_init()
  110. {
  111. struct rti_memtrace_item *item;
  112. rt_uint32_t index;
  113. rt_memset(trace_list, 0, sizeof(trace_list));
  114. rt_memset(item_hash, 0, sizeof(item_hash));
  115. item_free = &trace_list[0];
  116. item = &trace_list[0];
  117. for (index = 1; index < MEMTRACE_HASH_SIZE; index ++)
  118. {
  119. item->next = &trace_list[index];
  120. item = item->next;
  121. }
  122. item->next = RT_NULL;
  123. }
  124. void rti_malloc_hook(void* ptr, rt_uint32_t len)
  125. {
  126. rt_uint32_t index;
  127. struct rti_memtrace_item* item;
  128. if (item_free == RT_NULL) return;
  129. mem_info.allocated_size += len;
  130. if (mem_info.max_allocated < mem_info.allocated_size)
  131. mem_info.max_allocated = mem_info.allocated_size;
  132. /* lock context */
  133. item = item_free;
  134. item_free = item->next;
  135. item->mb_ptr = ptr;
  136. item->mb_len = len;
  137. item->next = RT_NULL;
  138. /* get hash item index */
  139. index = ((rt_uint32_t)ptr) % MEMTRACE_HASH_SIZE;
  140. if (item_hash[index] != RT_NULL)
  141. {
  142. /* add to list */
  143. item->next = item_hash[index];
  144. item_hash[index] = item;
  145. }
  146. else
  147. {
  148. /* set list header */
  149. item_hash[index] = item;
  150. }
  151. /* unlock context */
  152. }
  153. void rti_free_hook(void* ptr)
  154. {
  155. rt_uint32_t index;
  156. struct rti_memtrace_item *item;
  157. /* get hash item index */
  158. index = ((rt_uint32_t)ptr) % MEMTRACE_HASH_SIZE;
  159. if (item_hash[index] != RT_NULL)
  160. {
  161. item = item_hash[index];
  162. if (item->mb_ptr == ptr)
  163. {
  164. /* delete item from list */
  165. item_hash[index] = item->next;
  166. }
  167. else
  168. {
  169. /* find ptr in list */
  170. while (item->next != RT_NULL && item->next->mb_ptr != ptr)
  171. item = item->next;
  172. /* delete item from list */
  173. if (item->next != RT_NULL)
  174. {
  175. struct rti_memtrace_item* i;
  176. i = item->next;
  177. item->next = item->next->next;
  178. item = i;
  179. }
  180. else
  181. {
  182. /* not found */
  183. return;
  184. }
  185. }
  186. /* reduce allocated size */
  187. mem_info.allocated_size -= item->mb_len;
  188. /* clear item */
  189. rt_memset(item, 0, sizeof(struct rti_memtrace_item));
  190. /* add item to the free list */
  191. item->next = item_free;
  192. item_free = item;
  193. }
  194. }
  195. #endif
  196. void* rtgui_malloc(rt_size_t size)
  197. {
  198. void* ptr;
  199. ptr = rt_malloc(size);
  200. #ifdef RTGUI_MEM_TRACE
  201. if (rti_memtrace_inited == 0)
  202. {
  203. rti_memtrace_init();
  204. rti_memtrace_inited = 1;
  205. }
  206. if (ptr != RT_NULL)
  207. rti_malloc_hook(ptr, size);
  208. #endif
  209. return ptr;
  210. }
  211. void* rtgui_realloc(void* ptr, rt_size_t size)
  212. {
  213. void* new_ptr;
  214. #ifdef RTGUI_MEM_TRACE
  215. new_ptr = rtgui_malloc(size);
  216. if ((new_ptr != RT_NULL) && (ptr != RT_NULL))
  217. {
  218. rt_memcpy(new_ptr, ptr, size);
  219. rtgui_free(ptr);
  220. }
  221. #else
  222. new_ptr = rt_realloc(ptr, size);
  223. #endif
  224. return new_ptr;
  225. }
  226. void rtgui_free(void* ptr)
  227. {
  228. #ifdef RTGUI_MEM_TRACE
  229. if (ptr != RT_NULL)
  230. rti_free_hook(ptr);
  231. #endif
  232. rt_free(ptr);
  233. }
  234. #if defined(RTGUI_MEM_TRACE) && defined(RT_USING_FINSH)
  235. #include <finsh.h>
  236. void list_mem(void)
  237. {
  238. rt_kprintf("Current Used: %d, Maximal Used: %d\n", mem_info.allocated_size, mem_info.max_allocated);
  239. }
  240. FINSH_FUNCTION_EXPORT(list_mem, display memory information);
  241. #endif
  242. /************************************************************************/
  243. /* RTGUI Event Dump */
  244. /************************************************************************/
  245. #ifdef _WIN32
  246. #define RTGUI_EVENT_DEBUG
  247. #endif
  248. #ifdef RTGUI_EVENT_DEBUG
  249. const char *event_string[] =
  250. {
  251. /* application event */
  252. "APP_CREATE", /* create an application */
  253. "APP_DESTROY", /* destroy an application */
  254. "APP_ACTIVATE", /* activate an application */
  255. /* window event */
  256. "WIN_CREATE", /* create a window */
  257. "WIN_DESTROY", /* destroy a window */
  258. "WIN_SHOW", /* show a window */
  259. "WIN_HIDE", /* hide a window */
  260. "WIN_ACTIVATE", /* activate a window */
  261. "WIN_DEACTIVATE", /* deactivate a window */
  262. "WIN_CLOSE", /* close a window */
  263. "WIN_MOVE", /* move a window */
  264. "WIN_RESIZE", /* resize a window */
  265. "WIN_MODAL_ENTER", /* a window modals */
  266. "SET_WM", /* set window manager */
  267. "UPDATE_BEGIN", /* begin of update rect */
  268. "UPDATE_END", /* end of update rect */
  269. "MONITOR_ADD", /* add a monitor rect */
  270. "MONITOR_REMOVE", /* remove a monitor rect*/
  271. "SHOW", /* the widget is going to be shown */
  272. "HIDE", /* the widget is going to be hidden */
  273. "PAINT", /* paint on screen */
  274. "TIMER", /* timer */
  275. "UPDATE_TOPLVL", /* update toplevel */
  276. /* clip rect information */
  277. "CLIP_INFO", /* clip rect info */
  278. /* mouse and keyboard event */
  279. "MOUSE_MOTION", /* mouse motion */
  280. "MOUSE_BUTTON", /* mouse button info */
  281. "KBD", /* keyboard info */
  282. /* user command event */
  283. "COMMAND", /* user command */
  284. /* request's status event */
  285. "STATUS", /* request result */
  286. "SCROLLED", /* scroll bar scrolled */
  287. "RESIZE", /* widget resize */
  288. };
  289. #define DBG_MSG(x) rt_kprintf x
  290. static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event)
  291. {
  292. char* sender = "(unknown)";
  293. if ((event->type == RTGUI_EVENT_TIMER) ||
  294. (event->type == RTGUI_EVENT_UPDATE_BEGIN) ||
  295. (event->type == RTGUI_EVENT_MOUSE_MOTION) ||
  296. (event->type == RTGUI_EVENT_UPDATE_END))
  297. {
  298. /* don't dump timer event */
  299. return ;
  300. }
  301. if (event->sender != RT_NULL)
  302. sender = event->sender->name;
  303. rt_kprintf("%s -- %s --> %s ", sender, event_string[event->type], tid->name);
  304. switch (event->type)
  305. {
  306. case RTGUI_EVENT_APP_CREATE:
  307. case RTGUI_EVENT_APP_DESTROY:
  308. case RTGUI_EVENT_APP_ACTIVATE:
  309. {
  310. struct rtgui_event_application *eapp = (struct rtgui_event_application *)event;
  311. rt_kprintf("app: %s", eapp->app->name);
  312. }
  313. break;
  314. case RTGUI_EVENT_PAINT:
  315. {
  316. struct rtgui_event_paint *paint = (struct rtgui_event_paint *)event;
  317. if(paint->wid != RT_NULL)
  318. rt_kprintf("win: %s", paint->wid->title);
  319. }
  320. break;
  321. case RTGUI_EVENT_KBD:
  322. {
  323. struct rtgui_event_kbd *ekbd = (struct rtgui_event_kbd*) event;
  324. if (ekbd->wid != RT_NULL)
  325. rt_kprintf("win: %s", ekbd->wid->title);
  326. if (RTGUI_KBD_IS_UP(ekbd)) rt_kprintf(", up");
  327. else rt_kprintf(", down");
  328. }
  329. break;
  330. case RTGUI_EVENT_CLIP_INFO:
  331. {
  332. struct rtgui_event_clip_info *info = (struct rtgui_event_clip_info *)event;
  333. if(info->wid != RT_NULL)
  334. rt_kprintf("win: %s", info->wid->title);
  335. }
  336. break;
  337. case RTGUI_EVENT_WIN_CREATE:
  338. {
  339. struct rtgui_event_win_create *create = (struct rtgui_event_win_create*)event;
  340. rt_kprintf(" win: %s at (x1:%d, y1:%d, x2:%d, y2:%d), addr: %p",
  341. #ifdef RTGUI_USING_SMALL_SIZE
  342. create->wid->title,
  343. RTGUI_WIDGET(create->wid)->extent.x1,
  344. RTGUI_WIDGET(create->wid)->extent.y1,
  345. RTGUI_WIDGET(create->wid)->extent.x2,
  346. RTGUI_WIDGET(create->wid)->extent.y2,
  347. #else
  348. create->title,
  349. create->extent.x1,
  350. create->extent.y1,
  351. create->extent.x2,
  352. create->extent.y2,
  353. #endif
  354. create->wid
  355. );
  356. }
  357. break;
  358. case RTGUI_EVENT_UPDATE_END:
  359. {
  360. struct rtgui_event_update_end* update_end = (struct rtgui_event_update_end*)event;
  361. rt_kprintf("(x:%d, y1:%d, x2:%d, y2:%d)", update_end->rect.x1,
  362. update_end->rect.y1,
  363. update_end->rect.x2,
  364. update_end->rect.y2);
  365. }
  366. break;
  367. case RTGUI_EVENT_WIN_ACTIVATE:
  368. case RTGUI_EVENT_WIN_DEACTIVATE:
  369. case RTGUI_EVENT_WIN_SHOW:
  370. case RTGUI_EVENT_WIN_MODAL_ENTER:
  371. {
  372. struct rtgui_event_win *win = (struct rtgui_event_win *)event;
  373. if(win->wid != RT_NULL)
  374. rt_kprintf("win: %s", win->wid->title);
  375. }
  376. break;
  377. case RTGUI_EVENT_WIN_MOVE:
  378. {
  379. struct rtgui_event_win_move *win = (struct rtgui_event_win_move *)event;
  380. if(win->wid != RT_NULL)
  381. {
  382. rt_kprintf("win: %s", win->wid->title);
  383. rt_kprintf(" to (x:%d, y:%d)", win->x, win->y);
  384. }
  385. }
  386. break;
  387. case RTGUI_EVENT_WIN_RESIZE:
  388. {
  389. struct rtgui_event_win_resize* win = (struct rtgui_event_win_resize *)event;
  390. if (win->wid != RT_NULL)
  391. {
  392. rt_kprintf("win: %s, rect(x1:%d, y1:%d, x2:%d, y2:%d)", win->wid->title,
  393. RTGUI_WIDGET(win->wid)->extent.x1,
  394. RTGUI_WIDGET(win->wid)->extent.y1,
  395. RTGUI_WIDGET(win->wid)->extent.x2,
  396. RTGUI_WIDGET(win->wid)->extent.y2);
  397. }
  398. }
  399. break;
  400. case RTGUI_EVENT_MOUSE_BUTTON:
  401. case RTGUI_EVENT_MOUSE_MOTION:
  402. {
  403. struct rtgui_event_mouse *mouse = (struct rtgui_event_mouse*)event;
  404. if (mouse->button & RTGUI_MOUSE_BUTTON_LEFT) rt_kprintf("left ");
  405. else rt_kprintf("right ");
  406. if (mouse->button & RTGUI_MOUSE_BUTTON_DOWN) rt_kprintf("down ");
  407. else rt_kprintf("up ");
  408. if (mouse->wid != RT_NULL)
  409. rt_kprintf("win: %s at (%d, %d)", mouse->wid->title,
  410. mouse->x, mouse->y);
  411. else
  412. rt_kprintf("(%d, %d)", mouse->x, mouse->y);
  413. }
  414. break;
  415. case RTGUI_EVENT_MONITOR_ADD:
  416. {
  417. struct rtgui_event_monitor *monitor = (struct rtgui_event_monitor*)event;
  418. if (monitor->wid != RT_NULL)
  419. {
  420. rt_kprintf("win: %s, the rect is:(%d, %d) - (%d, %d)", monitor->wid->title,
  421. monitor->rect.x1, monitor->rect.y1,
  422. monitor->rect.x2, monitor->rect.y2);
  423. }
  424. }
  425. break;
  426. }
  427. rt_kprintf("\n");
  428. }
  429. #else
  430. #define DBG_MSG(x)
  431. #define rtgui_event_dump(tid, event)
  432. #endif
  433. /************************************************************************/
  434. /* RTGUI IPC APIs */
  435. /************************************************************************/
  436. rt_err_t rtgui_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
  437. {
  438. rt_err_t result;
  439. struct rtgui_app *app;
  440. RT_ASSERT(tid != RT_NULL);
  441. RT_ASSERT(event != RT_NULL);
  442. RT_ASSERT(event_size != 0);
  443. rtgui_event_dump(tid, event);
  444. /* find struct rtgui_application */
  445. app = (struct rtgui_app*) (tid->user_data);
  446. if (app == RT_NULL)
  447. return -RT_ERROR;
  448. result = rt_mq_send(app->mq, event, event_size);
  449. if (result != RT_EOK)
  450. {
  451. if (event->type != RTGUI_EVENT_TIMER)
  452. rt_kprintf("send event to %s failed\n", app->tid->name);
  453. }
  454. return result;
  455. }
  456. rt_err_t rtgui_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
  457. {
  458. rt_err_t result;
  459. struct rtgui_app *app;
  460. RT_ASSERT(tid != RT_NULL);
  461. RT_ASSERT(event != RT_NULL);
  462. RT_ASSERT(event_size != 0);
  463. rtgui_event_dump(tid, event);
  464. /* find rtgui_application */
  465. app = (struct rtgui_app*) (tid->user_data);
  466. if (app == RT_NULL)
  467. return -RT_ERROR;
  468. result = rt_mq_urgent(app->mq, event, event_size);
  469. if (result != RT_EOK)
  470. rt_kprintf("send ergent event failed\n");
  471. return result;
  472. }
  473. rt_err_t rtgui_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
  474. {
  475. rt_err_t r;
  476. struct rtgui_app *app;
  477. rt_int32_t ack_buffer, ack_status;
  478. struct rt_mailbox ack_mb;
  479. RT_ASSERT(tid != RT_NULL);
  480. RT_ASSERT(event != RT_NULL);
  481. RT_ASSERT(event_size != 0);
  482. rtgui_event_dump(tid, event);
  483. /* init ack mailbox */
  484. r = rt_mb_init(&ack_mb, "ack", &ack_buffer, 1, 0);
  485. if (r!= RT_EOK)
  486. goto __return;
  487. app = (struct rtgui_app*) (tid->user_data);
  488. if (app == RT_NULL)
  489. {
  490. r = -RT_ERROR;
  491. goto __return;
  492. }
  493. event->ack = &ack_mb;
  494. r = rt_mq_send(app->mq, event, event_size);
  495. if (r != RT_EOK)
  496. {
  497. rt_kprintf("send sync event failed\n");
  498. goto __return;
  499. }
  500. r = rt_mb_recv(&ack_mb, (rt_uint32_t*)&ack_status, RT_WAITING_FOREVER);
  501. if (r!= RT_EOK)
  502. goto __return;
  503. if (ack_status != RTGUI_STATUS_OK)
  504. r = -RT_ERROR;
  505. else
  506. r = RT_EOK;
  507. __return:
  508. /* fini ack mailbox */
  509. rt_mb_detach(&ack_mb);
  510. return r;
  511. }
  512. rt_err_t rtgui_ack(rtgui_event_t* event, rt_int32_t status)
  513. {
  514. RT_ASSERT(event != RT_NULL);
  515. RT_ASSERT(event->ack != RT_NULL);
  516. rt_mb_send(event->ack, status);
  517. return RT_EOK;
  518. }
  519. rt_err_t rtgui_recv(rtgui_event_t* event, rt_size_t event_size)
  520. {
  521. struct rtgui_app* app;
  522. rt_err_t r;
  523. RT_ASSERT(event != RT_NULL);
  524. RT_ASSERT(event_size != 0);
  525. app = (struct rtgui_app*) (rt_thread_self()->user_data);
  526. if (app == RT_NULL)
  527. return -RT_ERROR;
  528. r = rt_mq_recv(app->mq, event, event_size, RT_WAITING_FOREVER);
  529. return r;
  530. }
  531. rt_err_t rtgui_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size)
  532. {
  533. struct rtgui_app *app;
  534. rt_err_t r;
  535. RT_ASSERT(event != RT_NULL);
  536. RT_ASSERT(event != 0);
  537. app = (struct rtgui_app*) (rt_thread_self()->user_data);
  538. if (app == RT_NULL)
  539. return -RT_ERROR;
  540. r = rt_mq_recv(app->mq, event, event_size, 0);
  541. return r;
  542. }
  543. rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t event_size)
  544. {
  545. struct rtgui_app *app;
  546. RT_ASSERT(event != RT_NULL);
  547. RT_ASSERT(event_size != 0);
  548. app = (struct rtgui_app*) (rt_thread_self()->user_data);
  549. if (app == RT_NULL)
  550. return -RT_ERROR;
  551. while (rt_mq_recv(app->mq, event, event_size, RT_WAITING_FOREVER) == RT_EOK)
  552. {
  553. if (event->type == type)
  554. {
  555. return RT_EOK;
  556. }
  557. else
  558. {
  559. if (RTGUI_OBJECT(app)->event_handler != RT_NULL)
  560. {
  561. RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
  562. }
  563. }
  564. }
  565. return -RT_ERROR;
  566. }
  567. rt_thread_t rtgui_get_server(void)
  568. {
  569. return rt_thread_find("rtgui");
  570. }