From: Sung-jae Park Date: Tue, 9 Jun 2015 03:25:07 +0000 (+0900) Subject: Apply scale factor manipulation code X-Git-Tag: accepted/tizen/mobile/20150609.090347^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a7fe992615dad64b8c73fbd6ee5112aacbd947fa;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Apply scale factor manipulation code Update build option for ASLR. Change-Id: I19cfd25315f1c965902684b52450de11e904ff1e --- diff --git a/widget_viewer/include/widget_viewer.h b/widget_viewer/include/widget_viewer.h index 61e2802..0d682b0 100644 --- a/widget_viewer/include/widget_viewer.h +++ b/widget_viewer/include/widget_viewer.h @@ -282,6 +282,8 @@ typedef struct widget_damage_region { typedef struct widget_mouse_event_info { double x; /**< X coordinates of Mouse Event */ double y; /**< Y coordinates of Mouse Event */ + double ratio_w; + double ratio_h; } *widget_mouse_event_info_s; /** diff --git a/widget_viewer/src/widget.c b/widget_viewer/src/widget.c index 8d41e36..a098b94 100644 --- a/widget_viewer/src/widget.c +++ b/widget_viewer/src/widget.c @@ -862,13 +862,13 @@ static int send_key_event(widget_h handle, const char *event, unsigned int keyco return master_rpc_async_request(handle, packet, 0, key_ret_cb, NULL); } -static int send_mouse_event(widget_h handle, const char *event, int x, int y) +static int send_mouse_event(widget_h handle, const char *event, int x, int y, double ratio_w, double ratio_h) { struct packet *packet; double timestamp; timestamp = util_timestamp(); - packet = packet_create_noack(event, "ssdiii", handle->common->pkgname, handle->common->id, timestamp, x, y, INPUT_EVENT_SOURCE_VIEWER); + packet = packet_create_noack(event, "ssdiiidd", handle->common->pkgname, handle->common->id, timestamp, x, y, INPUT_EVENT_SOURCE_VIEWER, ratio_w, ratio_h); if (!packet) { ErrPrint("Failed to build param\n"); return WIDGET_ERROR_FAULT; @@ -2272,8 +2272,6 @@ EAPI int widget_viewer_feed_access_event(widget_h handle, widget_access_event_ty EAPI int widget_viewer_feed_mouse_event(widget_h handle, widget_mouse_event_type_e type, widget_mouse_event_info_s info) { - int w = 1; - int h = 1; unsigned int cmd; if (!handle || handle->state != WIDGET_STATE_CREATE) { @@ -2320,8 +2318,6 @@ EAPI int widget_viewer_feed_mouse_event(widget_h handle, widget_mouse_event_type if (flag) { handle->common->gbar.x = info->x; handle->common->gbar.y = info->y; - w = handle->common->gbar.width; - h = handle->common->gbar.height; } switch ((type & ~(WIDGET_MOUSE_EVENT_GBAR_MASK | WIDGET_MOUSE_EVENT_WIDGET_MASK))) { @@ -2382,8 +2378,6 @@ EAPI int widget_viewer_feed_mouse_event(widget_h handle, widget_mouse_event_type if (flag) { handle->common->widget.x = info->x; handle->common->widget.y = info->y; - w = handle->common->widget.width; - h = handle->common->widget.height; } switch ((type & ~(WIDGET_MOUSE_EVENT_GBAR_MASK | WIDGET_MOUSE_EVENT_WIDGET_MASK))) { @@ -2438,7 +2432,7 @@ EAPI int widget_viewer_feed_mouse_event(widget_h handle, widget_mouse_event_type return WIDGET_ERROR_INVALID_PARAMETER; } - return send_mouse_event(handle, (const char *)&cmd, info->x * w, info->y * h); + return send_mouse_event(handle, (const char *)&cmd, info->x, info->y, info->ratio_w, info->ratio_h); } EAPI int widget_viewer_feed_key_event(widget_h handle, widget_key_event_type_e type, widget_key_event_info_s info, widget_ret_cb cb, void *data) diff --git a/widget_viewer_evas/src/widget_viewer_evas.c b/widget_viewer_evas/src/widget_viewer_evas.c index e687153..13531ba 100644 --- a/widget_viewer_evas/src/widget_viewer_evas.c +++ b/widget_viewer_evas/src/widget_viewer_evas.c @@ -291,6 +291,8 @@ struct widget_data { int widget_width; int widget_height; + int fixed_width; + int fixed_height; widget_size_type_e size_type; union { @@ -1016,10 +1018,21 @@ static void gbar_down_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_in if (s_info.conf.field.auto_feed) { minfo.x = (double)data->down.geo.x; minfo.y = (double)data->down.geo.y; + minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_SET, &minfo); } else { - minfo.x = (double)(down->canvas.x - data->down.geo.x) / (double)data->down.geo.w; - minfo.y = (double)(down->canvas.y - data->down.geo.y) / (double)data->down.geo.h; + minfo.x = (double)(down->canvas.x - data->down.geo.x); + minfo.y = (double)(down->canvas.y - data->down.geo.y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_ENTER, &minfo); widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_DOWN, &minfo); } @@ -1047,8 +1060,16 @@ static void gbar_move_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_in data->y = move->cur.canvas.y; if (data->is.field.cancel_click != CANCEL_DISABLED || !s_info.conf.field.auto_feed) { - minfo.x = (double)(move->cur.canvas.x - x) / (double)w; - minfo.y = (double)(move->cur.canvas.y - y) / (double)h; + minfo.x = (double)(move->cur.canvas.x - x); + minfo.y = (double)(move->cur.canvas.y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } if (data->is.field.cancel_click == CANCEL_USER) { widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_ON_HOLD, &minfo); @@ -1151,12 +1172,29 @@ static void gbar_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_info * UNSET will subtract object.x and object.y by master * so we just send original touch position based on screen */ - minfo.x = (double)up->canvas.x / (double)w; - minfo.y = (double)up->canvas.y / (double)h; + minfo.x = (double)up->canvas.x; + minfo.y = (double)up->canvas.y; + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_UNSET, &minfo); } else { - minfo.x = (double)(up->canvas.x - x) / (double)w; - minfo.y = (double)(up->canvas.y - y) / (double)h; + minfo.x = (double)(up->canvas.x - x); + minfo.y = (double)(up->canvas.y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } if (data->down.geo.x != x || data->down.geo.y != y || data->is.field.cancel_click == CANCEL_USER) { widget_viewer_feed_mouse_event(data->handle, WIDGET_GBAR_MOUSE_ON_HOLD, &minfo); @@ -1214,10 +1252,20 @@ static void __widget_down_cb(void *cbdata, Evas *e, Evas_Object *obj, void *even if (s_info.conf.field.auto_feed && data->is.field.mouse_event) { minfo.x = (double)data->down.geo.x; minfo.y = (double)data->down.geo.y; + minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_SET, &minfo); } else { - minfo.x = (double)(data->x - data->down.geo.x) / (double)data->down.geo.w; - minfo.y = (double)(data->y - data->down.geo.y) / (double)data->down.geo.h; + minfo.x = (double)(data->x - data->down.geo.x); + minfo.y = (double)(data->y - data->down.geo.y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_ENTER, &minfo); widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_DOWN, &minfo); @@ -2756,8 +2804,16 @@ static void __widget_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_ if (data->handle && !data->is.field.faulted) { struct widget_mouse_event_info minfo; - minfo.x = (double)(data->x - x) / (double)w; - minfo.y = (double)(data->y - y) / (double)h; + minfo.x = (double)(data->x - x); + minfo.y = (double)(data->y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } evas_object_geometry_get(obj, &x, &y, NULL, NULL); @@ -2776,14 +2832,36 @@ static void __widget_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_ * UNSET will subtract object.x and object.y by master * so we just send original touch position based on screen */ - _minfo.x = (double)up->canvas.x / (double)data->down.geo.w; - _minfo.y = (double)up->canvas.y / (double)data->down.geo.h; + _minfo.x = (double)up->canvas.x; + _minfo.y = (double)up->canvas.y; + DbgPrint("X,Y = %lfx%lf\n", _minfo.x, _minfo.y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + _minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + _minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; + DbgPrint("Width: %d/%d - Height: %d/%d\n", data->fixed_width, data->down.geo.w, data->fixed_height, data->down.geo.h); + DbgPrint("Ratio: %lfx%lf\n", _minfo.ratio_w, _minfo.ratio_h); + } else { + _minfo.ratio_w = 1.0f; + _minfo.ratio_h = 1.0f; + DbgPrint("UNKNOWN Ratio: %lfx%lf\n", minfo.ratio_w, minfo.ratio_h); + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_UNSET, &_minfo); } else { if (!data->is.field.mouse_event) { /* We have to keep the first position of touch down */ - minfo.x = (double)(data->down.x - x) / (double)w; - minfo.y = (double)(data->down.y - y) / (double)h; + minfo.x = (double)(data->down.x - x); + minfo.y = (double)(data->down.y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } + if (data->down.geo.x != x || data->down.geo.y != y || data->is.field.scroll_x || data->is.field.scroll_y || data->is.field.cancel_click == CANCEL_USER || abs(data->x - data->down.x) > CLICK_REGION || abs(data->y - data->down.y) > CLICK_REGION) { widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_ON_HOLD, &minfo); data->is.field.cancel_click = CANCEL_PROCESSED; @@ -2795,6 +2873,7 @@ static void __widget_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_ } } + DbgPrint("%lfx%lf (%lfx%lf)\n", minfo.x, minfo.y, minfo.ratio_w, minfo.ratio_h); widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_UP, &minfo); widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_LEAVE, &minfo); } @@ -2859,8 +2938,17 @@ static void __widget_move_cb(void *cbdata, Evas *e, Evas_Object *obj, void *even evas_object_geometry_get(obj, &x, &y, &w, &h); - minfo.x = (double)(data->x - x) / (double)w; - minfo.y = (double)(data->y - y) / (double)h; + minfo.x = (double)(data->x - x); + minfo.y = (double)(data->y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_ON_HOLD, &minfo); /* @@ -2880,8 +2968,17 @@ static void __widget_move_cb(void *cbdata, Evas *e, Evas_Object *obj, void *even evas_object_geometry_get(obj, &x, &y, &w, &h); - minfo.x = (double)(data->x - x) / (double)w; - minfo.y = (double)(data->y - y) / (double)h; + minfo.x = (double)(data->x - x); + minfo.y = (double)(data->y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_MOVE, &minfo); } @@ -3638,8 +3735,16 @@ static int do_force_mouse_up(struct widget_data *data) evas_object_geometry_get(data->widget, &x, &y, &w, &h); - minfo.x = (double)(data->x - x) / (double)w; - minfo.y = (double)(data->y - y) / (double)h; + minfo.x = (double)(data->x - x); + minfo.y = (double)(data->y - y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } data->is.field.pressed = 0; @@ -3658,14 +3763,34 @@ static int do_force_mouse_up(struct widget_data *data) * UNSET will subtract object.x and object.y by master * so we just send original touch position based on screen */ - minfo.x = (double)data->x / (double)data->down.geo.w; - minfo.y = (double)data->y / (double)data->down.geo.h; + minfo.x = (double)data->x; + minfo.y = (double)data->y; + DbgPrint("X,Y = %lfx%lf\n", minfo.x, minfo.y); + + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)data->down.geo.w; + minfo.ratio_h = (double)data->fixed_height / (double)data->down.geo.h; + DbgPrint("Width: %d/%d - Height: %d/%d\n", data->fixed_width, data->down.geo.w, data->fixed_height, data->down.geo.h); + DbgPrint("Ratio: %lfx%lf\n", minfo.ratio_w, minfo.ratio_h); + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + DbgPrint("UNKNOWN Ratio: %lfx%lf\n", minfo.ratio_w, minfo.ratio_h); + } + widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_UNSET, &minfo); } else { if (!data->is.field.mouse_event) { /* We have to keep the first position of touch down */ - minfo.x = (double)(data->down.x - x) / (double)w; - minfo.y = (double)(data->down.y - y) / (double)h; + minfo.x = (double)(data->down.x - x); + minfo.y = (double)(data->down.y - y); + if (data->size_type != WIDGET_SIZE_TYPE_UNKNOWN) { + minfo.ratio_w = (double)data->fixed_width / (double)w; + minfo.ratio_h = (double)data->fixed_height / (double)h; + } else { + minfo.ratio_w = 1.0f; + minfo.ratio_h = 1.0f; + } } DbgPrint("%x\n", data->is.field.cancel_click); @@ -3675,6 +3800,7 @@ static int do_force_mouse_up(struct widget_data *data) data->is.field.cancel_click = CANCEL_PROCESSED; } + DbgPrint("%lfx%lf (%lfx%lf)\n", minfo.x, minfo.y, minfo.ratio_w, minfo.ratio_h); widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_UP, &minfo); widget_viewer_feed_mouse_event(data->handle, WIDGET_MOUSE_LEAVE, &minfo); } @@ -4864,6 +4990,16 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h) if (widget_service_get_size(type, &w, &h) < 0) { ErrPrint("Failed to get box size\n"); } + data->fixed_width = w; + data->fixed_height = h; + } else { + if (widget_service_get_size(type, &data->fixed_width, &data->fixed_height) < 0) { + ErrPrint("Failed to get box size\n"); + } else { + DbgPrint("Use the given size\n"); + data->fixed_width = w; + data->fixed_width = h; + } } /** diff --git a/widget_viewer_sdk/CMakeLists.txt b/widget_viewer_sdk/CMakeLists.txt index 2060235..3ed56a8 100644 --- a/widget_viewer_sdk/CMakeLists.txt +++ b/widget_viewer_sdk/CMakeLists.txt @@ -30,6 +30,8 @@ IF("${ARCH}" STREQUAL "arm") MESSAGE("add -DTARGET") ENDIF("${ARCH}" STREQUAL "arm") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") + INCLUDE(FindPkgConfig) pkg_check_modules(sdk_pkgs REQUIRED capi-appfw-application @@ -53,7 +55,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../widget_viewer_evas/include) ADD_EXECUTABLE(${PROJECT_NAME} src/main.c) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${sdk_pkgs_LDFLAGS} "-lm -fpie -fPIC" widget_viewer_evas) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${sdk_pkgs_LDFLAGS} "-lm -pie -fPIC" widget_viewer_evas) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PKGNAME}.xml DESTINATION /usr/share/packages)