예제 #1
0
파일: window.c 프로젝트: zhangjinxing/RTGUI
void rtgui_win_move(struct rtgui_win* win, int x, int y)
{
    struct rtgui_event_win_move emove;
    RTGUI_EVENT_WIN_MOVE_INIT(&emove);

    if (win == RT_NULL)
        return;

    /* move window to logic position */
    rtgui_widget_move_to_logic(RTGUI_WIDGET(win),
                               x - RTGUI_WIDGET(win)->extent.x1,
                               y - RTGUI_WIDGET(win)->extent.y1);

    if (win->flag & RTGUI_WIN_FLAG_CONNECTED)
    {
        /* set win hide firstly */
        RTGUI_WIDGET_HIDE(RTGUI_WIDGET(win));

        emove.wid	= win;
        emove.x		= x;
        emove.y		= y;
        if (rtgui_server_post_event_sync(RTGUI_EVENT(&emove),
                                         sizeof(struct rtgui_event_win_move)) != RT_EOK)
        {
            return;
        }
    }

    /* set window visible */
    RTGUI_WIDGET_UNHIDE(RTGUI_WIDGET(win));
    return;
}
예제 #2
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));
}
예제 #3
0
파일: server.c 프로젝트: 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 ;
    }
}