Exemple #1
0
static void 
Tracking_Mouse_Move (LCUI_MouseEvent *event)
/* 
 * 功能:跟踪鼠标移动,处理触发的基本事件
 * 说明:这只是根据鼠标事件来处理部件状态的切换
 * */
{
	LCUI_Widget *widget;
	
	/* 获取当前鼠标游标覆盖到的部件的指针 */
	widget = Get_Cursor_Overlay_Widget();
	if( !widget ) {
		goto skip_widget_check;
	}
	/* 获取能响应状态改变的部件的指针 */
	widget = Get_ResponseStatusChange_Widget(widget); 
	if( !widget || overlay_widget == widget ) {
		goto skip_widget_check;
	}
	if ( widget->enabled ) {
		DEBUG_MSG("widget not enabled");
		if( !click_widget  ) {
			DEBUG_MSG("leftbutton is free, widget overlay\n\n");
			Set_Widget_Status (widget, WIDGET_STATUS_OVERLAY);
		}
	} else {
		Set_Widget_Status (widget, WIDGET_STATUS_DISABLE);
	}
	
	/* 如果之前有覆盖到的部件 */
	if (overlay_widget && !click_widget ) {
		if ( overlay_widget->enabled ) {
			Set_Widget_Status (overlay_widget, WIDGET_STATUS_NORMAL);
		} else {
			Set_Widget_Status (overlay_widget, WIDGET_STATUS_DISABLE);
		}
	}
	/* 保存当前覆盖到的按钮部件指针 */
	overlay_widget = widget;
	return;

skip_widget_check:;

	/* 如果鼠标指针在之前有覆盖到的部件 */
	if( overlay_widget != widget && !click_widget ) {
		if ( overlay_widget->enabled ) {
			Set_Widget_Status (overlay_widget, WIDGET_STATUS_NORMAL); 
		} else {
			Set_Widget_Status (overlay_widget, WIDGET_STATUS_DISABLE);
		}
	} 
	overlay_widget = widget;
	/* 如果之前点击过部件,并且现在鼠标左键还处于按下状态,那就处理部件拖动 */ 
	if( click_widget && Mouse_LeftButton (event) == PRESSED 
	 && Widget_Have_Event( click_widget, EVENT_DRAG ) ) {
		_Doing_DragEvent( click_widget, event );
	}
}
Exemple #2
0
static void * Handle_TouchScreen_Input ()
/* 功能:处理触屏输入 */
{
	char *tsdevice;
	struct ts_sample samp;
	int button, x, y, ret;
	LCUI_MouseEvent event;
	
	char str[100];
	while (LCUI_Active()) {
		if (LCUI_Sys.ts.status != INSIDE) {
			tsdevice = getenv("TSLIB_TSDEVICE");
			if( tsdevice != NULL ) {
				LCUI_Sys.ts.td = ts_open(tsdevice, 0);
			} else {
				tsdevice = TS_DEV;
			}
			LCUI_Sys.ts.td = ts_open (tsdevice, 0);
			if (!LCUI_Sys.ts.td) { 
				sprintf (str, "ts_open: %s", tsdevice);
				perror (str);
				LCUI_Sys.ts.status = REMOVE;
				break;
			}

			if (ts_config (LCUI_Sys.ts.td)) {
				perror ("ts_config");
				LCUI_Sys.ts.status = REMOVE;
				break;
			}
			LCUI_Sys.ts.status = INSIDE;
		}

		/* 开始获取触屏点击处的坐标 */ 
		ret = ts_read (LCUI_Sys.ts.td, &samp, 1); 
		if (ret < 0) {
			perror ("ts_read");
			continue;
		}

		if (ret != 1) {
			continue;
		}
		x = samp.x;
		y = samp.y;
		
		if (x > Get_Screen_Width ()) {
			x = Get_Screen_Width ();
		}
		if (y > Get_Screen_Height ()) {
			y = Get_Screen_Height ();
		}
		if (x < 0) {
			x = 0;
		}
		if (y < 0) {
			y = 0;
		}
		/* 设定游标位置 */ 
		Set_Cursor_Pos (Pos(x, y));
		
		event.global_pos.x = x;
		event.global_pos.y = y;
		/* 获取当前鼠标指针覆盖到的部件的指针 */
		event.widget = Get_Cursor_Overlay_Widget();
		/* 如果有覆盖到的部件,就需要计算鼠标指针与部件的相对坐标 */
		if(event.widget != NULL) {
			event.pos.x = x - Get_Widget_Global_Pos(event.widget).x;
			event.pos.y = y - Get_Widget_Global_Pos(event.widget).y;
		} else {/* 否则,和全局坐标一样 */
			event.pos.x = x;
			event.pos.y = y;
		}
		if (samp.pressure > 0) {
			button = 1; 
		} else {
			button = 0; 
		}
			/* 处理鼠标事件 */
		Handle_Mouse_Event(button, &event); 
		//printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
	}
	if(LCUI_Sys.ts.status == INSIDE) {
		ts_close(LCUI_Sys.ts.td); 
	}
	LCUI_Sys.ts.status = REMOVE;
	thread_exit (NULL);
}