Exemple #1
0
void rtgui_server_handle_touch(struct rtgui_event_touch *event)
{
	if (rtgui_touch_do_calibration(event) == RT_TRUE)
	{
		struct rtgui_event_mouse emouse;

		/* convert it as a mouse event to rtgui */
		if (event->up_down == RTGUI_TOUCH_MOTION)
		{
			RTGUI_EVENT_MOUSE_MOTION_INIT(&emouse);
			emouse.x = event->x;
			emouse.y = event->y;
			emouse.button = 0;

			rtgui_server_handle_mouse_motion(&emouse);
		}
		else
		{
			RTGUI_EVENT_MOUSE_BUTTON_INIT(&emouse);
			emouse.x = event->x;
			emouse.y = event->y;
			emouse.button = RTGUI_MOUSE_BUTTON_LEFT;
			if (event->up_down == RTGUI_TOUCH_UP)
				emouse.button |= RTGUI_MOUSE_BUTTON_UP;
			else
				emouse.button |= RTGUI_MOUSE_BUTTON_DOWN;

			rtgui_server_handle_mouse_btn(&emouse);
		}
	}
}
Exemple #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));
}
Exemple #3
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_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 ;
    }
}
Exemple #4
0
static void report_touch_input(int updown)
{
	struct rtgui_event_mouse emouse;

	RTGUI_EVENT_MOUSE_BUTTON_INIT(&emouse);
	emouse.wid = RT_NULL;

	/* set emouse button */
	emouse.button = RTGUI_MOUSE_BUTTON_LEFT;
	emouse.parent.sender = RT_NULL;
	
	if (updown)
	{
		ts.xp = ts.xp / ts.count;
		ts.yp = ts.yp / ts.count;;

		if ((touch->calibrating == RT_TRUE) && (touch->calibration_func != RT_NULL))
		{
			touch->x = ts.xp;
			touch->y = ts.yp;
		}
		else
		{
			if (touch->max_x > touch->min_x)
			{
				touch->x = touch->width * (ts.xp-touch->min_x)/(touch->max_x-touch->min_x);
			}
			else
			{
				touch->x = touch->width * ( touch->min_x - ts.xp ) / (touch->min_x-touch->max_x);
			}

			if (touch->max_y > touch->min_y)
			{
				touch->y = touch->height * ( ts.yp - touch->min_y ) / (touch->max_y-touch->min_y);
			}
			else
			{
				touch->y = touch->height * ( touch->min_y - ts.yp ) / (touch->min_y-touch->max_y);
			}
		}

		emouse.x = touch->x;
		emouse.y = touch->y;
		if (touch->first_down_report == RT_TRUE)
		{
			emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
			emouse.button |= RTGUI_MOUSE_BUTTON_DOWN;
		}
		else
		{
			emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
			emouse.button = 0;
		}
	}
	else
	{
		emouse.x = touch->x;
		emouse.y = touch->y;
		emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
		emouse.button |= RTGUI_MOUSE_BUTTON_UP;
		if ((touch->calibrating == RT_TRUE) && (touch->calibration_func != RT_NULL))
		{
			/* callback function */
			touch->calibration_func(emouse.x, emouse.y);
		}
	}

	/* rt_kprintf("touch %s: ts.x: %d, ts.y: %d\n", updown? "down" : "up",
	touch->x, touch->y); */

	/* send event to server */
	if (touch->calibrating != RT_TRUE)
	{
		rtgui_server_post_event((&emouse.parent), sizeof(emouse));
	}
}