#include <Evas.h>
#include <dlfcn.h>
#include <Eina.h>
+#include <math.h>
#include <X11/Xlib.h>
int resource_cnt;
int pressed;
+
+ int orientation;
} *vwin_info_t;
static inline Evas_Object *get_highlighted_object(Evas_Object *obj)
return ho;
}
+static inline void apply_orientation(int degree, int *x, int *y)
+{
+ int _x;
+ int _y;
+ int _angle;
+
+ switch (degree) {
+ case 0:
+ return;
+ case 90:
+ _x = *x;
+ _y = *y;
+
+ *x = -_y;
+ *y = _x;
+ return;
+ case 180:
+ _x = *x;
+ _y = *y;
+ _angle = degree;
+
+ *x = -_x;
+ *y = -_y;
+ return;
+ case 270:
+ _x = *x;
+ _y = *y;
+ _angle = degree;
+
+ *x = _y;
+ *y = -_x;
+ return;
+ default:
+ _x = *x;
+ _y = *y;
+ _angle = degree;
+
+ *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle);
+ *y = (double)_x * sin((double)_angle) + (double)_y * cos((double)_angle);
+ return;
+ }
+}
+
/**
* @note
* Every user event (mouse) on the buffer will be passed via this event callback
evas_event_feed_mouse_out(info->e, timestamp, NULL);
break;
case WIDGET_BUFFER_EVENT_DOWN:
+ apply_orientation(info->degree, &event_info->info.pointer.x, &event_info->info.pointer.y);
+
if (info->pressed) {
ErrPrint("MOUSE UP is not called\n");
ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
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->degree, &event_info->info.pointer.x, &event_info->info.pointer.y);
/**
* @note
* Calculate the event occurred X & Y on the buffer
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->degree, &event_info->info.pointer.x, &event_info->info.pointer.y);
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;
}
}
+static void pre_orientation_cb(const char *id, void *data)
+{
+ vwin_info_t info = data;
+ char *path = NULL;
+
+ /* Try provider_app first */
+ if (id) {
+ path = widget_util_uri_to_path(id);
+
+ if (path && strcmp(info->id, path)) {
+ /* Skip */
+ DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id);
+ return;
+ }
+
+ DbgPrint("Pre orientation event callback is called [%s]\n", id);
+ info->orientation = widget_get_orientation(path);
+ }
+}
+
static void pre_destroy_cb(const char *id, void *data)
{
vwin_info_t info = data;
evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info);
widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info);
+ widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info);
+
+ info->orientation = widget_get_orientation(info->id);
return info->e;
}
int (*request_update_by_id)(const char *uri);
int (*trigger_update_monitor)(const char *id, int is_gbar);
int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name);
+ int (*add_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data);
+ int (*del_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data);
+ int (*orientation)(const char *id);
enum load_type {
LOAD_TYPE_UNKNOWN = -1,
struct _app {
int (*send)(widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar);
- int (*add_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data);
- int (*del_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data);
} app;
} binder;
} s_info = {
.request_update_by_id = NULL,
.trigger_update_monitor = NULL,
.update_extra_info = NULL,
+ .add_pre_callback = NULL,
+ .del_pre_callback = NULL,
+ .orientation = NULL,
.type = LOAD_TYPE_UNKNOWN, /* Not initialized */
.binder = {
.slave = {
},
.app = {
.send = NULL,
- .add_pre_callback = NULL,
- .del_pre_callback = NULL,
},
},
};
#define FUNC_PREFIX "widget_"
-#define FUNC_WIDGET_SEND_UPDATED FUNC_PREFIX "send_buffer_updated"
-#define FUNC_WIDGET_PROVIDER_APP_UPDATED FUNC_PREFIX "provider_app_buffer_updated"
-#define FUNC_WIDGET_FIND_PKGNAME FUNC_PREFIX "find_pkgname"
-#define FUNC_WIDGET_REQUEST_UPDATE_BY_ID FUNC_PREFIX "request_update_by_id"
-#define FUNC_WIDGET_TRIGGER_UPDATE_MONITOR FUNC_PREFIX "trigger_update_monitor"
-#define FUNC_WIDGET_UPDATE_EXTRA_INFO FUNC_PREFIX "update_extra_info"
-#define FUNC_WIDGET_ADD_PRE_CALLBACK FUNC_PREFIX "provider_app_add_pre_callback"
-#define FUNC_WIDGET_DEL_PRE_CALLBACK FUNC_PREFIX "provider_app_del_pre_callback"
+#define FUNC_WIDGET_SEND_UPDATED FUNC_PREFIX "send_buffer_updated"
+#define FUNC_WIDGET_FIND_PKGNAME FUNC_PREFIX "find_pkgname"
+#define FUNC_WIDGET_REQUEST_UPDATE_BY_ID FUNC_PREFIX "request_update_by_id"
+#define FUNC_WIDGET_TRIGGER_UPDATE_MONITOR FUNC_PREFIX "trigger_update_monitor"
+#define FUNC_WIDGET_UPDATE_EXTRA_INFO FUNC_PREFIX "update_extra_info"
+
+#define FUNC_WIDGET_PROVIDER_APP_UPDATED FUNC_PREFIX "provider_app_buffer_updated"
+
+#define FUNC_WIDGET_PROVIDER_APP_ADD_PRE_CALLBACK FUNC_PREFIX "provider_app_add_pre_callback"
+#define FUNC_WIDGET_PROVIDER_APP_DEL_PRE_CALLBACK FUNC_PREFIX "provider_app_del_pre_callback"
+#define FUNC_WIDGET_PROVIDER_APP_ORIENTATION FUNC_PREFIX "provider_app_get_orientation"
static inline void load_update_function(void)
{
}
}
-int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data)
+PUBLIC int widget_get_orientation(const char *id)
{
- static int loaded = 0;
- if (!loaded && !s_info.binder.app.add_pre_callback) {
- s_info.binder.app.add_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_ADD_PRE_CALLBACK);
- loaded = 1;
- }
-
- if (!s_info.binder.app.add_pre_callback) {
- return WIDGET_ERROR_NOT_SUPPORTED;
+ if (!s_info.orientation) {
+ s_info.orientation = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_ORIENTATION);
+ if (!s_info.orientation) {
+ return WIDGET_ERROR_NOT_SUPPORTED;
+ }
}
- return s_info.binder.app.add_pre_callback(type, cb, data);
+ return s_info.orientation(id);
}
-int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data)
+PUBLIC int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data)
{
- static int loaded = 0;
- if (!loaded && !s_info.binder.app.del_pre_callback) {
- s_info.binder.app.del_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_DEL_PRE_CALLBACK);
- loaded = 1;
+ if (!s_info.add_pre_callback) {
+ s_info.add_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_ADD_PRE_CALLBACK);
+ if (!s_info.add_pre_callback) {
+ return WIDGET_ERROR_NOT_SUPPORTED;
+ }
}
- if (!s_info.binder.app.del_pre_callback) {
- return WIDGET_ERROR_NOT_SUPPORTED;
+ return s_info.add_pre_callback(type, cb, data);
+}
+
+PUBLIC int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data)
+{
+ if (!s_info.del_pre_callback) {
+ s_info.del_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_DEL_PRE_CALLBACK);
+ if (!s_info.del_pre_callback) {
+ return WIDGET_ERROR_NOT_SUPPORTED;
+ }
}
- return s_info.binder.app.del_pre_callback(type, cb, data);
+ return s_info.del_pre_callback(type, cb, data);
}
static int send_updated(const char *pkgname, const char *id, widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar, const char *descfile)