summaryrefslogtreecommitdiff
path: root/components/rtgui/server/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'components/rtgui/server/server.c')
-rw-r--r--components/rtgui/server/server.c144
1 files changed, 91 insertions, 53 deletions
diff --git a/components/rtgui/server/server.c b/components/rtgui/server/server.c
index 10ddfbf77a..28f0fb771f 100644
--- a/components/rtgui/server/server.c
+++ b/components/rtgui/server/server.c
@@ -16,14 +16,16 @@
#include <rtgui/event.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/rtgui_object.h>
-#include <rtgui/rtgui_application.h>
+#include <rtgui/rtgui_app.h>
#include <rtgui/driver.h>
#include "mouse.h"
#include "topwin.h"
static struct rt_thread *rtgui_server_tid;
-static struct rtgui_application *rtgui_server_application;
+
+static struct rtgui_app *rtgui_server_application = RT_NULL;
+static struct rtgui_app *rtgui_wm_application = RT_NULL;
void rtgui_server_handle_update(struct rtgui_event_update_end* event)
{
@@ -85,7 +87,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse* event)
}
/* send to client thread */
- rtgui_application_send(topwin->tid, &(ewin.parent), sizeof(ewin));
+ rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin));
return;
}
@@ -101,7 +103,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse* event)
if (rtgui_topwin_get_focus() != wnd)
{
/* raise this window */
- rtgui_topwin_activate_win(wnd);
+ rtgui_topwin_activate_topwin(wnd);
}
if (wnd->title != RT_NULL &&
@@ -112,7 +114,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse* event)
else
{
/* send mouse event to thread */
- rtgui_application_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_mouse));
+ rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_mouse));
}
return ;
}
@@ -144,7 +146,7 @@ void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse* event)
{
event->wid = last_monitor_topwin->wid;
/* send mouse motion event */
- rtgui_application_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
+ rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
if (last_monitor_topwin != win)
@@ -155,7 +157,7 @@ void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse* event)
event->wid = last_monitor_topwin->wid;
/* send mouse motion event */
- rtgui_application_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
+ rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
}
@@ -181,7 +183,7 @@ void rtgui_server_handle_kbd(struct rtgui_event_kbd* event)
event->wid = wnd->wid;
/* send keyboard event to thread */
- rtgui_application_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_kbd));
+ rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_kbd));
return;
}
@@ -200,58 +202,113 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
/* dispatch event */
switch (event->type)
{
+ case RTGUI_EVENT_APP_CREATE:
+ case RTGUI_EVENT_APP_DESTROY:
+ if (rtgui_wm_application != RT_NULL)
+ {
+ /* forward event to wm application */
+ rtgui_send(rtgui_wm_application->tid, event, sizeof(struct rtgui_event_application));
+ }
+ else
+ {
+ /* always ack with OK */
+ rtgui_ack(event, RTGUI_STATUS_OK);
+ }
+ break;
+
+ /* mouse and keyboard event */
+ case RTGUI_EVENT_MOUSE_MOTION:
+ /* handle mouse motion event */
+ rtgui_server_handle_mouse_motion((struct rtgui_event_mouse*)event);
+ break;
+
+ case RTGUI_EVENT_MOUSE_BUTTON:
+ /* handle mouse button */
+ rtgui_server_handle_mouse_btn((struct rtgui_event_mouse*)event);
+ break;
+
+ case RTGUI_EVENT_KBD:
+ /* handle keyboard event */
+ rtgui_server_handle_kbd((struct rtgui_event_kbd*)event);
+ break;
+
/* window event */
case RTGUI_EVENT_WIN_CREATE:
if (rtgui_topwin_add((struct rtgui_event_win_create*)event) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
+ rtgui_ack(event, RTGUI_STATUS_OK);
else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
- break;
-
- case RTGUI_EVENT_WIN_DESTROY:
- if (last_monitor_topwin != RT_NULL &&
- last_monitor_topwin->wid == ((struct rtgui_event_win*)event)->wid)
- last_monitor_topwin = RT_NULL;
- if (rtgui_topwin_remove(((struct rtgui_event_win*)event)->wid) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
- else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_SHOW:
if (rtgui_topwin_show((struct rtgui_event_win*)event) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
+ rtgui_ack(event, RTGUI_STATUS_OK);
else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_HIDE:
if (rtgui_topwin_hide((struct rtgui_event_win*)event) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
+ rtgui_ack(event, RTGUI_STATUS_OK);
else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_MOVE:
if (rtgui_topwin_move((struct rtgui_event_win_move*)event) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
+ rtgui_ack(event, RTGUI_STATUS_OK);
else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_MODAL_ENTER:
if (rtgui_topwin_modal_enter((struct rtgui_event_win_modal_enter*)event) == RT_EOK)
- rtgui_application_ack(event, RTGUI_STATUS_OK);
+ rtgui_ack(event, RTGUI_STATUS_OK);
else
- rtgui_application_ack(event, RTGUI_STATUS_ERROR);
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
+ case RTGUI_EVENT_WIN_ACTIVATE:
+ if (rtgui_topwin_activate((struct rtgui_event_win_activate*)event) == RT_EOK)
+ rtgui_ack(event, RTGUI_STATUS_OK);
+ else
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
+ break;
+
+ case RTGUI_EVENT_WIN_DESTROY:
+ if (last_monitor_topwin != RT_NULL &&
+ last_monitor_topwin->wid == ((struct rtgui_event_win*)event)->wid)
+ last_monitor_topwin = RT_NULL;
+ if (rtgui_topwin_remove(((struct rtgui_event_win*)event)->wid) == RT_EOK)
+ rtgui_ack(event, RTGUI_STATUS_OK);
+ else
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
+ break;
+
case RTGUI_EVENT_WIN_RESIZE:
rtgui_topwin_resize(((struct rtgui_event_win_resize*)event)->wid,
&(((struct rtgui_event_win_resize*)event)->rect));
break;
+ case RTGUI_EVENT_SET_WM:
+ if (rtgui_wm_application != RT_NULL)
+ {
+ rtgui_ack(event, RTGUI_STATUS_ERROR);
+ }
+ else
+ {
+ struct rtgui_event_set_wm *set_wm;
+
+ set_wm = (struct rtgui_event_set_wm*) event;
+ rtgui_wm_application = set_wm->app;
+ rtgui_ack(event, RTGUI_STATUS_OK);
+ }
+ break;
+
/* other event */
+ case RTGUI_EVENT_COMMAND:
+ break;
+
case RTGUI_EVENT_UPDATE_BEGIN:
#ifdef RTGUI_USING_MOUSE_CURSOR
/* hide cursor */
@@ -272,25 +329,6 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
/* handle mouse monitor */
rtgui_server_handle_monitor_add((struct rtgui_event_monitor*)event);
break;
-
- /* mouse and keyboard event */
- case RTGUI_EVENT_MOUSE_MOTION:
- /* handle mouse motion event */
- rtgui_server_handle_mouse_motion((struct rtgui_event_mouse*)event);
- break;
-
- case RTGUI_EVENT_MOUSE_BUTTON:
- /* handle mouse button */
- rtgui_server_handle_mouse_btn((struct rtgui_event_mouse*)event);
- break;
-
- case RTGUI_EVENT_KBD:
- /* handle keyboard event */
- rtgui_server_handle_kbd((struct rtgui_event_kbd*)event);
- break;
-
- case RTGUI_EVENT_COMMAND:
- break;
}
return RT_TRUE;
@@ -307,8 +345,8 @@ static void rtgui_server_entry(void* parameter)
SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#endif
- /* register rtgui server thread */
- rtgui_server_application = rtgui_application_create(rtgui_server_tid,
+ /* create rtgui server application */
+ rtgui_server_application = rtgui_app_create(rtgui_server_tid,
"rtgui");
if (rtgui_server_application == RT_NULL)
return;
@@ -321,16 +359,16 @@ static void rtgui_server_entry(void* parameter)
rtgui_mouse_show_cursor();
#endif
- rtgui_application_run(rtgui_server_application);
+ rtgui_app_run(rtgui_server_application);
- rtgui_application_destroy(rtgui_server_application);
+ rtgui_app_destroy(rtgui_server_application);
rtgui_server_application = RT_NULL;
}
void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size)
{
if (rtgui_server_tid != RT_NULL)
- rtgui_application_send(rtgui_server_tid, event, size);
+ rtgui_send(rtgui_server_tid, event, size);
else
rt_kprintf("post when server is not running\n");
}
@@ -338,7 +376,7 @@ void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size)
rt_err_t rtgui_server_post_event_sync(struct rtgui_event* event, rt_size_t size)
{
if (rtgui_server_tid != RT_NULL)
- return rtgui_application_send_sync(rtgui_server_tid, event, size);
+ return rtgui_send_sync(rtgui_server_tid, event, size);
else
{
rt_kprintf("post when server is not running\n");