Fix the rotation logic 61/39161/1
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 7 May 2015 06:17:14 +0000 (15:17 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 7 May 2015 06:17:14 +0000 (15:17 +0900)
Rotation should be process in the first quadrant.

Change-Id: I3f34bc2058288eae6e85e39c02210224a534064f

src/virtual_window.c

index 8766611..664690d 100644 (file)
@@ -60,7 +60,7 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj)
        return ho;
 }
 
-static inline void apply_orientation(int degree, int *x, int *y, input_event_source_e source)
+static inline void apply_orientation(int degree, int *x, int *y, int width, int height, input_event_source_e source)
 {
        int _x;
        int _y;
@@ -71,35 +71,31 @@ static inline void apply_orientation(int degree, int *x, int *y, input_event_sou
                return;
        }
 
+       _x = *x;
+       _y = *y;
+
        switch (degree) {
        case 0:
                return;
        case 90:
-               _x = *x;
-               _y = *y;
-
-               *x = -_y;
-               *y = _x;
+               *x = _y;
+               *y = width - _x;
                return;
        case 180:
-               _x = *x;
-               _y = *y;
-               _angle = degree;
-
-               *x = -_x;
-               *y = -_y;
+               *x = width - _x;
+               *y = height - _y;
                return;
        case 270:
-               _x = *x;
-               _y = *y;
-               _angle = degree;
-
-               *x = _y;
-               *y = -_x;
+               *x = height - _y;
+               *y = _x;
                return;
        default:
-               _x = *x;
-               _y = *y;
+               /**
+                * @FIXME
+                * This rotation formular is not work correctly.
+                * The pointer should be rotated by other way.
+                * This is not what we want.
+                */
                _angle = degree;
 
                *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle);
@@ -197,7 +193,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_
                evas_event_feed_mouse_out(info->e, timestamp, NULL);
                break;
        case WIDGET_BUFFER_EVENT_DOWN:
-               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
+               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source);
 
                if (info->pressed) {
                        ErrPrint("MOUSE UP is not called\n");
@@ -226,7 +222,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_
                ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
                break;
        case WIDGET_BUFFER_EVENT_MOVE:
-               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
+               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source);
                /**
                 * @note
                 * Calculate the event occurred X & Y on the buffer
@@ -234,7 +230,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_
                evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
                break;
        case WIDGET_BUFFER_EVENT_UP:
-               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
+               apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source);
                evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
                evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL);
                info->pressed = 0;