Ejemplo n.º 1
0
void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event)
{
    struct rtgui_topwin *wnd;

    /* re-init to server thread */
    RTGUI_EVENT_MOUSE_BUTTON_INIT(event);

	/* set cursor position */
	rtgui_mouse_set_position(event->x, event->y);

#ifdef RTGUI_USING_WINMOVE
    if (rtgui_winrect_is_moved() &&
        event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP))
    {
        struct rtgui_win *win;
        rtgui_rect_t rect;

        if (rtgui_winrect_moved_done(&rect, &win) == RT_TRUE)
        {
            struct rtgui_event_win_move ewin;

            /* move window */
            RTGUI_EVENT_WIN_MOVE_INIT(&ewin);
            ewin.wid = win;
            ewin.x = rect.x1;
            ewin.y = rect.y1;

            /* send to client thread */
            rtgui_send(win->app, &(ewin.parent), sizeof(ewin));

            return;
        }
    }
#endif

    /* get the wnd which contains the mouse */
    wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
    if (wnd == RT_NULL)
        return;

    event->wid = wnd->wid;

    /* only raise window if the button is pressed down */
    if (event->button & RTGUI_MOUSE_BUTTON_DOWN &&
        rtgui_topwin_get_focus() != wnd)
    {
        rtgui_topwin_activate_topwin(wnd);
    }

	/* handle gesture event */
	if (rtgui_gesture_handle(event, wnd) == 0)
        return;

    /* send mouse event to thread */
    rtgui_send(wnd->app,
               (struct rtgui_event *)event,
               sizeof(struct rtgui_event_mouse));
}
Ejemplo n.º 2
0
Archivo: server.c Proyecto: eyeye/RTGUI
void rtgui_server_handle_kbd(struct rtgui_event_kbd *event)
{
    struct rtgui_topwin *wnd;

    /* re-init to server thread */
    RTGUI_EVENT_KBD_INIT(event);

    /* todo: handle input method and global shortcut */

    wnd = rtgui_topwin_get_focus();
    if (wnd != RT_NULL)
    {
        RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE)

        /* send to focus window */
        event->wid = wnd->wid;

        /* send keyboard event to thread */
        rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd));

        return;
    }
}
Ejemplo n.º 3
0
Archivo: server.c Proyecto: eyeye/RTGUI
void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event)
{
    struct rtgui_topwin *wnd;

    /* re-init to server thread */
    RTGUI_EVENT_MOUSE_BUTTON_INIT(event);

	/* set cursor position */
	rtgui_mouse_set_position(event->x, event->y);

#ifdef RTGUI_USING_WINMOVE
    if (rtgui_winrect_is_moved() &&
            event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP))
    {
        struct rtgui_topwin *topwin;
        rtgui_rect_t rect;

        if (rtgui_winrect_moved_done(&rect, &topwin) == RT_TRUE)
        {
            struct rtgui_event_win_move ewin;

            /* move window */
            RTGUI_EVENT_WIN_MOVE_INIT(&ewin);
            ewin.wid = topwin->wid;
            if (topwin->title != RT_NULL)
            {
                if (topwin->flag & WINTITLE_BORDER)
                {
                    ewin.x = rect.x1 + WINTITLE_BORDER_SIZE;
                    ewin.y = rect.y1 + WINTITLE_BORDER_SIZE;
                }
                if (!(topwin->flag & WINTITLE_NO)) ewin.y += WINTITLE_HEIGHT;
            }
            else
            {
                ewin.x = rect.x1;
                ewin.y = rect.y1;
            }

            /* send to client thread */
            rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin));

            return;
        }
    }
#endif

    /* get the wnd which contains the mouse */
    wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
    if (wnd != RT_NULL)
    {
        event->wid = wnd->wid;

        if (rtgui_topwin_get_focus() != wnd)
        {
            /* raise this window */
            rtgui_topwin_activate_topwin(wnd);
        }

        if (wnd->title != RT_NULL &&
                rtgui_rect_contains_point(&(RTGUI_WIDGET(wnd->title)->extent), event->x, event->y) == RT_EOK)
        {
            rtgui_topwin_title_onmouse(wnd, event);
        }
        else
        {
            /* send mouse event to thread */
            rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_mouse));
        }
        return ;
    }
}