예제 #1
0
static void _touch_session()
{
    touch_point_t tpd;
#ifdef RT_USING_RTGUI
    struct rtgui_event_mouse emouse;
#endif

    ft5406_read_touch(&tpd);

#ifdef RT_USING_RTGUI
    emouse.parent.sender = RT_NULL;
    emouse.wid = RT_NULL;

    emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
    emouse.x = tpd.TOUCH_X;
    emouse.y = tpd.TOUCH_Y;
    emouse.ts = rt_tick_get();
    emouse.id = emouse.ts;
    if (emouse.id == 0) emouse.id = 1;
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif

    do
    {
        rt_thread_delay(RT_TICK_PER_SECOND / BSP_TOUCH_SAMPLE_HZ);
        if (ft5406_read_touch(&tpd) != 0)
            break;

#ifdef RT_USING_RTGUI
        emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
        emouse.x = tpd.TOUCH_X;
        emouse.y = tpd.TOUCH_Y;
        emouse.ts = rt_tick_get();
        rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif
    }
    while (1);

#ifdef RT_USING_RTGUI
    /* Always send touch up event. */
    emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
    emouse.x = tpd.TOUCH_X;
    emouse.y = tpd.TOUCH_Y;
    emouse.ts = rt_tick_get();
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif

    //} while (rt_sem_take(&_tp_sem, TOUCH_SLP_TIME) == RT_EOK);
}
예제 #2
0
void push_event_touch_end(int x, int y)
{
    struct rtgui_event_mouse emouse;

    emouse.parent.sender = RT_NULL;
    emouse.wid = RT_NULL;

    emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
    emouse.x = x;
    emouse.y = y;
    emouse.ts = rt_tick_get();
    emouse.id = emouse_id;
    
    dbg_log(DBG_LOG, "[line]:%d up event id:%d x:%d y:%d\n", __LINE__, emouse.id, x, y);
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
}
예제 #3
0
void push_event_touch_move(int x, int y)
{
    struct rtgui_event_mouse emouse;

    emouse.parent.sender = RT_NULL;
    emouse.wid = RT_NULL;

    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
    emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
    emouse.x = x;
    emouse.y = y;
    emouse.ts = rt_tick_get();
    emouse.id = emouse_id;

    LOG_D("[line]:%d motion event id:%d x:%d y:%d", __LINE__, emouse.id, x, y);
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
}
예제 #4
0
파일: window.c 프로젝트: zhangjinxing/RTGUI
void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect)
{
    struct rtgui_event_win_resize event;

    if (win == RT_NULL || rect == RT_NULL) return;

    RTGUI_WIDGET(win)->extent = *rect;

    if (win->flag & RTGUI_WIN_FLAG_CONNECTED)
    {
        /* set window resize event to server */
        RTGUI_EVENT_WIN_RESIZE_INIT(&event);
        event.wid = win;
        event.rect = *rect;

        rtgui_server_post_event(&(event.parent), sizeof(struct rtgui_event_win_resize));
    }
}
예제 #5
0
파일: key.c 프로젝트: bright-pan/smart-lock
static void key_thread_entry(void *parameter)
{
#ifdef RT_USING_RTGUI
    rt_time_t next_delay;
    rt_uint8_t i;

    struct rtgui_event_kbd kbd_event;
    
    key_io_init();

    /* init keyboard event */
    RTGUI_EVENT_KBD_INIT(&kbd_event);
    kbd_event.mod  = RTGUI_KMOD_NONE;
    kbd_event.unicode = 0;

    while (1)
    {
        next_delay = RT_TICK_PER_SECOND/10;
        kbd_event.key = RTGUIK_UNKNOWN;
        kbd_event.type = RTGUI_KEYDOWN;

        if (KEY_ENTER_GETVALUE() == 0 )
        {
            for(i=0; ; i++)
            {
                rt_thread_delay( next_delay );
                if (KEY_ENTER_GETVALUE() == 0)
                {
                    if (i>=4)
                    {
                        /* HOME key */
                        kbd_event.key  = RTGUIK_HOME;
                        next_delay = RT_TICK_PER_SECOND/5;
                        break;
                    }
                }
                else
                {
                    kbd_event.key  = RTGUIK_RETURN;
                    break;
                }
            }
        }

        if (KEY_DOWN_GETVALUE() == 0)
        {
            kbd_event.key  = RTGUIK_DOWN;
        }

        if (KEY_UP_GETVALUE() == 0)
        {
            kbd_event.key  = RTGUIK_UP;
        }

        if (KEY_RIGHT_GETVALUE() == 0)
        {
            kbd_event.key  = RTGUIK_RIGHT;
        }

        if (KEY_LEFT_GETVALUE() == 0)
        {
            kbd_event.key  = RTGUIK_LEFT;
        }

        if (kbd_event.key != RTGUIK_UNKNOWN)
        {
            /* post down event */
            rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event));
        }
        else
        {
            kbd_event.type = RTGUI_KEYUP;
            rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event));
        }
        /* wait next key press */
        rt_thread_delay(next_delay);
    }
#else
	extern struct rt_messagequeue mq;
	rt_time_t next_delay;
	struct lcd_msg msg;
	msg.type = KEY_MSG;
	
	key_io_init();
	
	while (1)
	{
		msg.key = NO_KEY;
	
		next_delay = RT_TICK_PER_SECOND/10;
	
		if (KEY_ENTER_GETVALUE() == 0 )
		{
			msg.key  = KEY_ENTER;
		}
	
		if (KEY_DOWN_GETVALUE() == 0)
		{
			msg.key  = KEY_DOWN;
		}
	
		if (KEY_UP_GETVALUE() == 0)
		{
			msg.key  = KEY_UP;
		}
	
		if (KEY_RIGHT_GETVALUE() == 0)
		{
			msg.key  = KEY_RIGHT;
		}
	
		if (KEY_LEFT_GETVALUE() == 0)
		{
			msg.key  = KEY_LEFT;
		}
	
		rt_mq_send(&mq, &msg, sizeof(msg));
	
		/* wait next key press */
		rt_thread_delay(next_delay);
	}
#endif
}
예제 #6
0
static void key_thread_entry(void *parameter)
{
    rt_time_t next_delay;
    struct rtgui_event_kbd kbd_event;

    GPIO_Configuration();
//    EXTI_Configuration();
//    NVIC_Configuration();

    /* init keyboard event */
    RTGUI_EVENT_KBD_INIT(&kbd_event);
    kbd_event.wid = RT_NULL;
    kbd_event.mod  = RTGUI_KMOD_NONE;
    kbd_event.unicode = 0;

    while (1)
    {
        next_delay = 10;
        kbd_event.key = RTGUIK_UNKNOWN;
        kbd_event.type = RTGUI_KEYDOWN;

        if ( key_enter_GETVALUE() == 1 )
        {
            rt_thread_delay( next_delay*4 );
            if (key_enter_GETVALUE() == 1)
            {
                /* HOME key */
                rt_kprintf("key_home\n");
                kbd_event.key  = RTGUIK_HOME;
            }
            else
            {
                rt_kprintf("key_enter\n");
                kbd_event.key  = RTGUIK_RETURN;
            }
        }

        if ( key_up_GETVALUE()    == 1 )
        {
            rt_kprintf("key_up\n");
            kbd_event.key  = RTGUIK_UP;
        }

        if ( key_down_GETVALUE()  == 1 )
        {
            rt_kprintf("key_down\n");
            kbd_event.key  = RTGUIK_DOWN;
        }

        if ( key_left_GETVALUE()  == 1 )
        {
            rt_kprintf("key_left\n");
            kbd_event.key  = RTGUIK_LEFT;
        }

        if ( key_right_GETVALUE() == 1 )
        {
            rt_kprintf("key_right\n");
            kbd_event.key  = RTGUIK_RIGHT;
        }

        if(key_stop_GETVALUE() == 1)
        {
            rt_kprintf("key_stop\n");
        }

        if(key_menu_GETVALUE() == 1)
        {
            rt_kprintf("key_menu\n");
        }

        if (kbd_event.key != RTGUIK_UNKNOWN)
        {
            /* post down event */
            rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event));

            next_delay = 10;
            /* delay to post up event */
            rt_thread_delay(next_delay);

            /* post up event */
            kbd_event.type = RTGUI_KEYUP;
            rtgui_server_post_event(&(kbd_event.parent), sizeof(kbd_event));
        }

        /* wait next key press */
        rt_thread_delay(next_delay);
    }
}
예제 #7
0
static void *sdl_loop(void *lpParam)
#endif
{
    int quit = 0;
    SDL_Event event;
    int button_state = 0;
    rt_device_t device;

#ifndef _WIN32
    sigset_t  sigmask, oldmask;
    /* set the getchar without buffer */
    sigfillset(&sigmask);
    pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
#endif

    sdlfb_hw_init();

    device = rt_device_find("sdl");
    rtgui_graphic_set_device(device);
#ifdef _WIN32
    SetEvent(sdl_ok_event);
#endif
    /* handle SDL event */
    while (!quit)
    {
        SDL_WaitEvent(&event);

        switch (event.type)
        {
        case SDL_MOUSEMOTION:
        {
            struct rtgui_event_mouse emouse;
            emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
            emouse.parent.sender = RT_NULL;
            emouse.wid = RT_NULL;

            emouse.x = ((SDL_MouseMotionEvent *)&event)->x;
            emouse.y = ((SDL_MouseMotionEvent *)&event)->y;

            /* init mouse button */
            emouse.button = button_state;

            /* send event to server */
            rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
        }
        break;

        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
        {
            struct rtgui_event_mouse emouse;
            SDL_MouseButtonEvent *mb;

            emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
            emouse.parent.sender = RT_NULL;
            emouse.wid = RT_NULL;

            mb = (SDL_MouseButtonEvent *)&event;

            emouse.x = mb->x;
            emouse.y = mb->y;

            /* init mouse button */
            emouse.button = 0;

            /* set emouse button */
            if (mb->button & (1 << (SDL_BUTTON_LEFT - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_LEFT;
            }
            else if (mb->button & (1 << (SDL_BUTTON_RIGHT - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_RIGHT;
            }
            else if (mb->button & (1 << (SDL_BUTTON_MIDDLE - 1)))
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_MIDDLE;
            }

            if (mb->type == SDL_MOUSEBUTTONDOWN)
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_DOWN;
                button_state = emouse.button;
            }
            else
            {
                emouse.button |= RTGUI_MOUSE_BUTTON_UP;
                button_state = 0;
            }


            /* send event to server */
            rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
        }
        break;

        case SDL_KEYUP:
        {
            struct rtgui_event_kbd ekbd;
            ekbd.parent.type    = RTGUI_EVENT_KBD;
            ekbd.parent.sender  = RT_NULL;
            ekbd.type = RTGUI_KEYUP;
            ekbd.wid = RT_NULL;
            ekbd.mod = event.key.keysym.mod;
            ekbd.key = event.key.keysym.sym;

            /* FIXME: unicode */
            ekbd.unicode = 0;

            /* send event to server */
            rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
        }
        break;

        case SDL_KEYDOWN:
        {
            struct rtgui_event_kbd ekbd;
            ekbd.parent.type    = RTGUI_EVENT_KBD;
            ekbd.parent.sender  = RT_NULL;
            ekbd.type = RTGUI_KEYDOWN;
            ekbd.wid = RT_NULL;
            ekbd.mod = event.key.keysym.mod;
            ekbd.key = event.key.keysym.sym;

            /* FIXME: unicode */
            ekbd.unicode = 0;

            /* send event to server */
            rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
        }
        break;

        case SDL_QUIT:
            SDL_Quit();
            quit = 1;
            break;

        default:
            break;
        }

        if (quit)
            break;
    }
    //exit(0);
    return 0;
}
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
{
	struct rtgui_dc_hw* dc;
	rtgui_widget_t* widget;

	/* adjudge owner */
	if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
	if (!RTGUI_IS_TOPLEVEL(owner->toplevel)) return RT_NULL;

	/* set init visible as true */
	RTGUI_WIDGET_DC_SET_VISIBLE(owner);

	/* check widget visible */
	widget = owner;
	while (widget != RT_NULL)
	{
		if (RTGUI_WIDGET_IS_HIDE(widget))
		{
			RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
			return RT_NULL;
		}

		widget = widget->parent;
	}

	if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_NULL;

	/* create DC */
	dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
	dc->parent.type = RTGUI_DC_HW;
	dc->parent.engine = &dc_hw_engine;
	dc->owner = owner;
	dc->hw_driver = rtgui_graphic_driver_get_default();

	if (RTGUI_IS_WINTITLE(owner->toplevel))
	{
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef _WIN32
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#else
			/* hide cursor */
			rtgui_mouse_hide_cursor();
#endif
#endif
		}
	}
	else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
		RTGUI_IS_WIN(owner->toplevel))
	{
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#endif
#else
			/* send draw begin to server */
			struct rtgui_event_update_begin eupdate;
			RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
			eupdate.rect = RTGUI_WIDGET(top)->extent;

			rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return &(dc->parent);
}
static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
{
	rtgui_widget_t* owner;
	struct rtgui_dc_hw* self;

	if (dc == RT_NULL || dc->type != RTGUI_DC_HW) return RT_FALSE;

	self = (struct rtgui_dc_hw*)dc;
	/* get owner */
	owner = self->owner;

	if (RTGUI_IS_WINTITLE(owner->toplevel))
	{
		/* update title extent */
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);

		top->drawing --;
		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#else
#ifdef RTGUI_USING_MOUSE_CURSOR
			/* show cursor */
			rtgui_mouse_show_cursor();
#endif

			/* update screen */
			rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#endif
		}
	}
	else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
		RTGUI_IS_WIN(owner->toplevel))
	{
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing --;

		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#else
			/* send to server to end drawing */
			struct rtgui_event_update_end eupdate;
			RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
			eupdate.rect = owner->extent;

			rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	/* release hardware dc */
	rtgui_free(self);

	return RT_TRUE;
}
예제 #10
0
파일: touch.c 프로젝트: lgnq/mini2440
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));
	}
}
예제 #11
0
파일: main.c 프로젝트: amsl/RTGUI
int main(int argc, char *argv[])
{
    SDL_Event event;
    int button_state = 0;
    rt_device_t device;

    rt_system_tick_init();

    rt_kprintf("RTGUI simulator ....\n");

    /* init rtt system */
    rt_mq_system_init();
    rt_mb_system_init();
    rt_thread_system_init();

    finsh_thread_init();

    /* init driver */
    sdlfb_hw_init();
    device = rt_device_find("sdl");
    rtgui_gdev_set(device);

    /* init gui system */
    rtgui_system_server_init();

    /* initial user application */
    rt_application_init();

    /* handle SDL event */
    while ( !done )
    {
        /* Check for events */
        while ( SDL_PollEvent(&event) )
        {
            switch (event.type)
            {
            case SDL_MOUSEMOTION:
            {
                struct rtgui_event_mouse emouse;
                emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
                emouse.parent.sender = RT_NULL;
                emouse.wid = RT_NULL;

                emouse.x = ((SDL_MouseMotionEvent*)&event)->x;
                emouse.y = ((SDL_MouseMotionEvent*)&event)->y;

                /* init mouse button */
                emouse.button = button_state;

                /* send event to server */
                rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
            }
            break;

            case SDL_MOUSEBUTTONDOWN:
            case SDL_MOUSEBUTTONUP:
            {
                struct rtgui_event_mouse emouse;
                SDL_MouseButtonEvent* mb;

                emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
                emouse.parent.sender = RT_NULL;
                emouse.wid = RT_NULL;

                mb = (SDL_MouseButtonEvent*)&event;

                emouse.x = mb->x;
                emouse.y = mb->y;

                /* init mouse button */
                emouse.button = 0;

                /* set emouse button */
                if (mb->button & (1 << (SDL_BUTTON_LEFT - 1)) )
                {
                    emouse.button |= RTGUI_MOUSE_BUTTON_LEFT;
                }
                else if (mb->button & (1 << (SDL_BUTTON_RIGHT - 1)))
                {
                    emouse.button |= RTGUI_MOUSE_BUTTON_RIGHT;
                }
                else if (mb->button & (1 << (SDL_BUTTON_MIDDLE - 1)))
                {
                    emouse.button |= RTGUI_MOUSE_BUTTON_MIDDLE;
                }

                if (mb->type == SDL_MOUSEBUTTONDOWN)
                {
                    emouse.button |= RTGUI_MOUSE_BUTTON_DOWN;
                    button_state = emouse.button;
                }
                else
                {
                    emouse.button |= RTGUI_MOUSE_BUTTON_UP;
                    button_state = 0;
                }


                /* send event to server */
                rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
            }
            break;

            case SDL_KEYUP:
            {
                struct rtgui_event_kbd ekbd;
                ekbd.parent.type	= RTGUI_EVENT_KBD;
                ekbd.parent.sender	= RT_NULL;
                ekbd.type = RTGUI_KEYUP;
                ekbd.wid = RT_NULL;
                ekbd.mod = event.key.keysym.mod;
                ekbd.key = event.key.keysym.sym;

                /* FIXME: unicode */
                ekbd.unicode = 0;

                /* send event to server */
                rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
            }
            break;

            case SDL_KEYDOWN:
            {
                struct rtgui_event_kbd ekbd;
                ekbd.parent.type	= RTGUI_EVENT_KBD;
                ekbd.parent.sender	= RT_NULL;
                ekbd.type = RTGUI_KEYDOWN;
                ekbd.wid = RT_NULL;
                ekbd.mod = event.key.keysym.mod;
                ekbd.key = event.key.keysym.sym;

                /* FIXME: unicode */
                ekbd.unicode = 0;

                /* send event to server */
                rtgui_server_post_event(&ekbd.parent, sizeof(struct rtgui_event_kbd));
            }
            break;

            case SDL_QUIT:
                done = 1;
                break;

            default:
                break;
            }

            SDL_Delay(20);
        }
    }

    SDL_Quit();

    return 0;
}
예제 #12
0
static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
{
	rtgui_widget_t* owner;
	
	if (dc == RT_NULL || dc->type != RTGUI_DC_CLIENT) return RT_FALSE;

	/* get owner */
	owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);

	if (RTGUI_IS_WINTITLE(owner->toplevel))
	{
		/* update title extent */
		struct rtgui_win* top = RTGUI_WIN(owner->toplevel);

		top->drawing --;
		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else
#ifdef RTGUI_USING_MOUSE_CURSOR
			/* show cursor */
			rtgui_mouse_show_cursor();
#endif

			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#endif
		}
	}
	else if (RTGUI_IS_APP(owner->toplevel) ||
		RTGUI_IS_WIN(owner->toplevel))
	{
		struct rtgui_win* top = RTGUI_WIN(owner->toplevel);
		top->drawing --;

		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else
			/* send to server to end drawing */
			struct rtgui_event_update_end eupdate;
			RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
			eupdate.rect = owner->extent;

			rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return RT_TRUE;
}
예제 #13
0
struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
{
	struct rtgui_dc* dc;
	rtgui_widget_t* widget;

	/* adjudge owner */
	if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
	if (!RTGUI_IS_WIN(owner->toplevel)) return RT_NULL;

	dc = RTGUI_WIDGET_DC(owner);
	/* set init visible as true */
	RTGUI_WIDGET_DC_SET_VISIBLE(owner);

	/* check widget visible */
	widget = owner;
	while (widget != RT_NULL)
	{
		if (RTGUI_WIDGET_IS_HIDE(widget))
		{
			RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
			return RT_NULL;
		}

		widget = widget->parent;
	}

	if (RTGUI_IS_WINTITLE(owner->toplevel))
	{
		struct rtgui_win* top = RTGUI_WIN(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef _WIN32
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#else
			/* hide cursor */
			rtgui_mouse_hide_cursor();
#endif
#endif
		}
	}
	else if (RTGUI_IS_APP(owner->toplevel))
	{
		RT_ASSERT(0);
	}
	else if (RTGUI_IS_WIN(owner->toplevel))
	{
		struct rtgui_win* top = RTGUI_WIN(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#endif
#else
			/* send draw begin to server */
			struct rtgui_event_update_begin eupdate;
			RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
			eupdate.rect = RTGUI_WIDGET(top)->extent;

			rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return dc;
}