Update resize event send function
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 23 Feb 2013 09:18:51 +0000 (09:18 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Sat, 23 Feb 2013 09:18:51 +0000 (09:18 +0000)
Change-Id: Ic32ca986584c64e8db094cf7183e363f22971cb8

include/conf.h
include/instance.h
packaging/org.tizen.data-provider-master.spec
src/conf.c
src/instance.c
src/script_handler.c
src/server.c

index 714cf0c..c748a26 100644 (file)
@@ -82,6 +82,9 @@ struct conf {
        int overwrite_content;
        int com_core_thread;
        int use_xmonitor;
+
+       double scale_width_factor;
+       double scale_height_factor;
 };
 
 extern struct conf g_conf;
@@ -94,6 +97,9 @@ extern int conf_loader(void);
 #define CR 13
 #define LF 10
 
+#define SCALE_WIDTH_FACTOR     g_conf.scale_width_factor
+#define SCALE_HEIGHT_FACTOR    g_conf.scale_height_factor
+
 #define USE_SW_BACKEND         g_conf.use_sw_backend
 #define PROVIDER_METHOD                g_conf.provider_method
 #define DEBUG_MODE             g_conf.debug_mode
index 016d704..69b6d55 100644 (file)
@@ -113,6 +113,9 @@ enum livebox_visible_state { /*!< Must be sync'd with livebox-viewer */
        LB_VISIBLE_ERROR = 0xFFFFFFFF, /* To enlarge the size of this enumeration type */
 };
 
+#define IS_PD  1
+#define IS_LB  0
+
 struct inst_info;
 struct pkg_info;
 struct script_handle;
@@ -184,6 +187,7 @@ extern const enum instance_state const instance_state(const struct inst_info *in
  */
 extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client);
 extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client);
+extern void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status);
 
 extern int instance_create_lb_buffer(struct inst_info *inst);
 extern int instance_create_pd_buffer(struct inst_info *inst);
index ff61a2d..cf75499 100644 (file)
@@ -1,6 +1,6 @@
 Name: org.tizen.data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.16.11
+Version: 0.16.13
 Release: 1
 Group: framework/livebox
 License: Flora License
index c8667f9..aab6a7a 100644 (file)
@@ -81,12 +81,17 @@ HAPI struct conf g_conf = {
        .debug_mode = 0,
        .overwrite_content = 0,
        .com_core_thread = 1,
-       .use_xmonitor = 1,
+       .use_xmonitor = 0,
+
+       .scale_width_factor = 1.0f,
+       .scale_height_factor = 1.0f,
 };
 
 static void conf_update_size(void)
 {
        ecore_x_window_size_get(0, &g_conf.width, &g_conf.height);
+       g_conf.scale_width_factor = (double)g_conf.width / (double)BASE_W;
+       g_conf.scale_height_factor = (double)g_conf.height / (double)BASE_H;
 }
 
 static void use_xmonitor(char *buffer)
index f3a2e64..feb3abc 100644 (file)
@@ -247,7 +247,7 @@ static inline int instance_recover_visible_state(struct inst_info *inst)
        return ret;
 }
 
-static inline void send_size_changed_event(struct inst_info *inst, int is_pd, int w, int h, int status)
+HAPI void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status)
 {
        struct packet *packet;
        const char *pkgname;
@@ -256,6 +256,8 @@ static inline void send_size_changed_event(struct inst_info *inst, int is_pd, in
        pkgname = package_name(inst->info);
        id = inst->id;
 
+       DbgPrint("Size is changed to %dx%d (%s) %s\n", w, h, id, is_pd ? "pd" : "lb");
+
        packet = packet_create_noack("size_changed", "ssiiii", pkgname, id, is_pd, w, h, status);
        if (packet)
                CLIENT_SEND_EVENT(inst, packet);
@@ -320,9 +322,11 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
 static int update_client_list(struct client_node *client, void *data)
 {
        struct inst_info *inst = data;
+
        if (!instance_has_client(inst, client)) {
                instance_add_client(inst, client);
        }
+
        return 0;
 }
 
@@ -1515,24 +1519,12 @@ HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double prio
        if (priority >= 0.0f && priority <= 1.0f)
                inst->lb.priority = priority;
 
-       if (inst->state == INST_ACTIVATED && (inst->lb.width != w || inst->lb.height != h)) {
-               /*!
-                */
-               send_size_changed_event(inst, 0, w, h, 0);
-       }
-
        inst->lb.width = w;
        inst->lb.height = h;
 }
 
 HAPI void instance_set_pd_info(struct inst_info *inst, int w, int h)
 {
-       if (inst->state == INST_ACTIVATED && (inst->pd.width != w || inst->pd.height != h)) {
-               /*!
-                */
-               send_size_changed_event(inst, 1, w, h, 0);
-       }
-
        inst->pd.width = w;
        inst->pd.height = h;
 }
@@ -1713,6 +1705,8 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi
        int ret;
 
        if (!packet) {
+               ErrPrint("Invalid packet\n");
+               instance_send_resized_event(cbdata->inst, IS_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, -EFAULT);
                instance_unref(cbdata->inst);
                DbgFree(cbdata);
                return;
@@ -1720,17 +1714,22 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi
 
        if (packet_get(packet, "i", &ret) != 1) {
                ErrPrint("Invalid parameter\n");
+               instance_send_resized_event(cbdata->inst, IS_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, -EINVAL);
                instance_unref(cbdata->inst);
                DbgFree(cbdata);
                return;
        }
 
        if (ret == 0) {
-               cbdata->inst->lb.width = cbdata->w;
-               cbdata->inst->lb.height = cbdata->h;
+               /*!
+                * \note
+                * else waiting the first update with new size
+                */
+       } else {
+               DbgPrint("Livebox rejects the new size: %dx%d (%d)\n", cbdata->w, cbdata->h, ret);
+               instance_send_resized_event(cbdata->inst, IS_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, ret);
        }
 
-       send_size_changed_event(cbdata->inst, 0, cbdata->w, cbdata->h, ret);
        instance_unref(cbdata->inst);
        DbgFree(cbdata);
 }
index 6e74ae0..9c49c3f 100644 (file)
@@ -641,10 +641,23 @@ static int update_info(struct inst_info *inst, struct block *block, int is_pd)
                }
 
                if (!block->id) {
-                       if (is_pd)
+                       int resized;
+
+                       if (is_pd) {
+                               resized = (instance_pd_width(inst) != w) || (instance_pd_height(inst) != h);
                                instance_set_pd_info(inst, w, h);
-                       else
+                       } else {
+                               /*!
+                                * \note
+                                * LB Size is already scaled by livebox-service.
+                                * Each livebox uses the LB_SIZE_TYPE_XXX for its size.
+                                */
+                               resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
                                instance_set_lb_info(inst, w, h, NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
+                       }
+
+                       if (resized)
+                               instance_send_resized_event(inst, is_pd, w, h, 0);
 
                        script_handler_resize(info, w, h);
                } else {
index 9d641b4..b48b580 100644 (file)
@@ -4138,13 +4138,13 @@ static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *
 
        inst = package_find_instance_by_id(pkgname, id);
        if (!inst) {
-               DbgPrint("There is no such instance: %s\n", id);
+               DbgPrint("There is a no such instance(%s)\n", id);
                ret = -ENOENT;
        } else if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Instance is already destroyed (%s)\n", id);
+               ErrPrint("Instance(%s) is already destroyed\n", id);
                ret = -EINVAL;
        } else {
-               DbgPrint("Destroy instance (%s)\n", id);
+               DbgPrint("Destroy instance(%s)\n", id);
                ret = instance_destroy(inst);
        }
 
@@ -4253,7 +4253,9 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                ret = -EINVAL;
        } else {
                char *filename;
+               int resized;
 
+               resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
                instance_set_lb_info(inst, w, h, priority, content_info, title);
 
                switch (package_lb_type(instance_package(inst))) {
@@ -4271,14 +4273,13 @@ static struct packet *slave_updated(pid_t pid, int handle, const struct packet *
                        }
                        break;
                case LB_TYPE_BUFFER:
-                       instance_lb_updated_by_instance(inst);
-                       ret = 0;
-                       break;
                default:
                        /*!
                         * \check
                         * text format (inst)
                         */
+                       if (resized)
+                               instance_send_resized_event(inst, IS_LB, w, h, 0);
                        instance_lb_updated_by_instance(inst);
                        ret = 0;
                        break;
@@ -4463,8 +4464,12 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
 
                        ret = buffer_handler_load(info);
                        if (ret == 0) {
+                               int resized;
+                               resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
                                instance_set_lb_info(inst, w, h, -1.0f, NULL, NULL);
                                id = buffer_handler_id(info);
+                               if (resized)
+                                       instance_send_resized_event(inst, IS_LB, w, h, 0);
                                DbgPrint("Buffer handler ID: %s\n", id);
                        } else {
                                DbgPrint("Failed to load a buffer(%d)\n", ret);
@@ -4497,8 +4502,12 @@ static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct p
 
                        ret = buffer_handler_load(info);
                        if (ret == 0) {
+                               int resized;
+                               resized = (instance_pd_width(inst) != w) || (instance_pd_height(inst) != h);
                                instance_set_pd_info(inst, w, h);
                                id = buffer_handler_id(info);
+                               if (resized)
+                                       instance_send_resized_event(inst, IS_PD, w, h, 0);
                                DbgPrint("Buffer handler ID: %s\n", id);
                        } else {
                                DbgPrint("Failed to load a buffer (%d)\n", ret);
@@ -4594,8 +4603,13 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
                                 * id is resued for newly assigned ID
                                 */
                                if (!ret) {
+                                       int resized;
+
                                        id = buffer_handler_id(info);
+                                       resized = (instance_lb_width(inst) != w) || (instance_lb_height(inst) != h);
                                        instance_set_lb_info(inst, w, h, -1.0f, NULL, NULL);
+                                       if (resized)
+                                               instance_send_resized_event(inst, IS_LB, w, h, 0);
                                }
                        }
                }
@@ -4611,9 +4625,12 @@ static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct pa
                                 * id is resued for newly assigned ID
                                 */
                                if (!ret) {
+                                       int resized;
                                        id = buffer_handler_id(info);
-                                       DbgPrint("Set PD Info: %dx%d\n", w, h);
+                                       resized = (instance_pd_width(inst) != w) || (instance_pd_height(inst) != h);
                                        instance_set_pd_info(inst, w, h);
+                                       if (resized)
+                                               instance_send_resized_event(inst, IS_PD, w, h, 0);
                                }
                        }
                }