From d898e4b9538f2a036a33d731c811b4caa09b181b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 21 Feb 2013 10:54:53 +0000 Subject: Sync with the latest code Change-Id: I3950d362f4eb8d0396c18c41db958f21a4e3f64e --- src/conf.c | 11 ++++++++++ src/fb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++------------- src/instance.c | 41 +++++++++++++++++++++++++++++------ src/server.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/setting.c | 2 ++ src/xmonitor.c | 61 ++++++++++++++++++++++++++++++++++++++-------------- 6 files changed, 210 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/conf.c b/src/conf.c index ca57d98..c8667f9 100644 --- a/src/conf.c +++ b/src/conf.c @@ -81,6 +81,7 @@ HAPI struct conf g_conf = { .debug_mode = 0, .overwrite_content = 0, .com_core_thread = 1, + .use_xmonitor = 1, }; static void conf_update_size(void) @@ -88,6 +89,12 @@ static void conf_update_size(void) ecore_x_window_size_get(0, &g_conf.width, &g_conf.height); } +static void use_xmonitor(char *buffer) +{ + g_conf.use_xmonitor = !strcasecmp(buffer, "true"); + DbgPrint("Use xmonitor: %d\n", g_conf.use_xmonitor); +} + static void use_sw_backend_handler(char *buffer) { g_conf.use_sw_backend = !strcasecmp(buffer, "true"); @@ -436,6 +443,10 @@ HAPI int conf_loader(void) .name = "use_sw_backend", .handler = use_sw_backend_handler, }, + { + .name = "use_xmonitor", + .handler = use_xmonitor, + }, { .name = "provider_method", .handler = provider_method_handler, diff --git a/src/fb.c b/src/fb.c index 99fc74f..fa8e122 100644 --- a/src/fb.c +++ b/src/fb.c @@ -20,6 +20,7 @@ #include #include +#include #include "util.h" #include "conf.h" @@ -95,13 +96,48 @@ HAPI struct fb_info *fb_create(struct inst_info *inst, int w, int h, enum buffer return info; } +static void sw_render_pre_cb(void *data, Evas *e, void *event_info) +{ + struct fb_info *info = data; + int w; + int h; + + buffer_handler_get_size(info->buffer, &w, &h); + evas_damage_rectangle_add(e, 0, 0, w, h); +} + +static void sw_render_post_cb(void *data, Evas *e, void *event_info) +{ + void *canvas; + Ecore_Evas *internal_ee; + int x, y, w, h; + + internal_ee = ecore_evas_ecore_evas_get(e); + if (!internal_ee) { + LOGD("Failed to get ecore evas\n"); + return; + } + + // Get a pointer of a buffer of the virtual canvas + canvas = (void*)ecore_evas_buffer_pixels_get(internal_ee); + if (!canvas) { + LOGD("Failed to get pixel canvas\n"); + return; + } + + ecore_evas_geometry_get(internal_ee, &x, &y, &w, &h); + evas_data_argb_unpremul(canvas, w * h); +} + static void render_pre_cb(void *data, Evas *e, void *event_info) { fb_pixmap_render_pre(data); + sw_render_pre_cb(data, e, event_info); } static void render_post_cb(void *data, Evas *e, void *event_info) { + sw_render_post_cb(data, e, event_info); fb_pixmap_render_post(data); } @@ -109,6 +145,7 @@ HAPI int fb_create_buffer(struct fb_info *info) { int ow; int oh; + Evas *e; buffer_handler_get_size(info->buffer, &ow, &oh); DbgPrint("Buffer handler size: %dx%d\n", ow, oh); @@ -136,23 +173,22 @@ HAPI int fb_create_buffer(struct fb_info *info) return -EFAULT; } + e = ecore_evas_get(info->ee); if (buffer_handler_type(info->buffer) == BUFFER_TYPE_PIXMAP) { - Evas *e; - e = ecore_evas_get(info->ee); - if (e) { - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb, info); - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, render_post_cb, info); - - /*! - * \note - * ecore_evas_alpha_set tries to access the canvas buffer. - * Without any render_pre/render_post callback. - */ - fb_pixmap_render_pre(info); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - fb_pixmap_render_post(info); - } + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, render_pre_cb, info); + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, render_post_cb, info); + + /*! + * \note + * ecore_evas_alpha_set tries to access the canvas buffer. + * Without any render_pre/render_post callback. + */ + fb_pixmap_render_pre(info); + ecore_evas_alpha_set(info->ee, EINA_TRUE); + fb_pixmap_render_post(info); } else { + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, sw_render_pre_cb, info); + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, sw_render_post_cb, info); ecore_evas_alpha_set(info->ee, EINA_TRUE); } diff --git a/src/instance.c b/src/instance.c index 14572c5..f3a2e64 100644 --- a/src/instance.c +++ b/src/instance.c @@ -247,6 +247,22 @@ 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) +{ + struct packet *packet; + const char *pkgname; + const char *id; + + pkgname = package_name(inst->info); + id = inst->id; + + packet = packet_create_noack("size_changed", "ssiiii", pkgname, id, is_pd, w, h, status); + if (packet) + CLIENT_SEND_EVENT(inst, packet); + else + ErrPrint("Failed to send size changed event\n"); +} + HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_node *client) { struct packet *packet; @@ -979,10 +995,10 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v * so just increase the loaded instance counter * After that, do reset jobs. */ - inst->state = INST_ACTIVATED; - instance_set_lb_info(inst, w, h, priority, content, title); + inst->state = INST_ACTIVATED; + switch (inst->requested_state) { case INST_DESTROYED: instance_unicast_deleted_event(inst, NULL); @@ -1486,9 +1502,6 @@ HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double prio ErrPrint("Heap: %s\n", strerror(errno)); } - inst->lb.width = w; - inst->lb.height = h; - if (_content) { DbgFree(inst->content); inst->content= _content; @@ -1501,10 +1514,25 @@ 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; } @@ -1700,10 +1728,9 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi if (ret == 0) { cbdata->inst->lb.width = cbdata->w; cbdata->inst->lb.height = cbdata->h; - } else { - ErrPrint("Failed to change the size of a livebox (%d)\n", ret); } + send_size_changed_event(cbdata->inst, 0, cbdata->w, cbdata->h, ret); instance_unref(cbdata->inst); DbgFree(cbdata); } diff --git a/src/server.c b/src/server.c index 75f4e18..9d641b4 100644 --- a/src/server.c +++ b/src/server.c @@ -2335,6 +2335,64 @@ out: return NULL; } +static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + double timestamp; + int ret; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is paused - manually reported\n", pid); + ret = -ENOENT; + goto out; + } + + ret = packet_get(packet, "d", ×tamp); + if (ret != 1) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + goto out; + } + + if (USE_XMONITOR) + DbgPrint("XMONITOR enabled. ignore client paused request\n"); + else + xmonitor_pause(client); + +out: + return NULL; +} + +static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet) +{ + struct client_node *client; + double timestamp; + int ret; + + client = client_find_by_pid(pid); + if (!client) { + ErrPrint("Client %d is paused - manually reported\n", pid); + ret = -ENOENT; + goto out; + } + + ret = packet_get(packet, "d", ×tamp); + if (ret != 1) { + ErrPrint("Invalid parameter\n"); + ret = -EINVAL; + goto out; + } + + if (USE_XMONITOR) + DbgPrint("XMONITOR enabled. ignore client resumed request\n"); + else + xmonitor_resume(client); + +out: + return NULL; +} + static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet) { struct client_node *client; @@ -5214,6 +5272,15 @@ static struct method s_client_table[] = { .handler = client_pd_key_up, }, + { + .cmd = "client_paused", + .handler = client_pause_request, + }, + { + .cmd = "client_resumed", + .handler = client_resume_request, + }, + { .cmd = NULL, .handler = NULL, diff --git a/src/setting.c b/src/setting.c index ffcc949..d60807d 100644 --- a/src/setting.c +++ b/src/setting.c @@ -29,6 +29,7 @@ #include +#include "client_life.h" #include "setting.h" #include "util.h" #include "debug.h" @@ -62,6 +63,7 @@ HAPI int setting_is_lcd_off(void) state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */ } + DbgPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP); return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP; } diff --git a/src/xmonitor.c b/src/xmonitor.c index c3924c5..ef89efd 100644 --- a/src/xmonitor.c +++ b/src/xmonitor.c @@ -34,13 +34,13 @@ #include #include "conf.h" -#include "xmonitor.h" #include "debug.h" #include "client_life.h" #include "slave_life.h" #include "main.h" #include "util.h" #include "setting.h" +#include "xmonitor.h" int errno; @@ -66,7 +66,7 @@ static struct info { .pause_list = NULL, .resume_list = NULL, - .paused = 0, + .paused = 1, /*!< The provider is treated as paused process when it is launched */ }; static inline void touch_paused_file(void) @@ -218,14 +218,10 @@ static Eina_Bool client_cb(void *data, int type, void *event) if (!strcmp(name, "_X_ILLUME_DEACTIVATE_WINDOW")) { DbgPrint("PAUSE EVENT\n"); - client_paused(client); - - xmonitor_handle_state_changes(); + xmonitor_pause(client); } else if (!strcmp(name, "_X_ILLUME_ACTIVATE_WINDOW")) { DbgPrint("RESUME EVENT\n"); - client_resumed(client); - - xmonitor_handle_state_changes(); + xmonitor_resume(client); } else { /* ignore event */ } @@ -316,7 +312,34 @@ static inline void sniff_all_windows(void) return; } -HAPI int xmonitor_init(void) +HAPI int xmonitor_pause(struct client_node *client) +{ + DbgPrint("%d is paused\n", client_pid(client)); + client_paused(client); + xmonitor_handle_state_changes(); + return 0; +} + +HAPI int xmonitor_resume(struct client_node *client) +{ + DbgPrint("%d is resumed\n", client_pid(client)); + client_resumed(client); + xmonitor_handle_state_changes(); + return 0; +} + +static inline void disable_xmonitor(void) +{ + ecore_event_handler_del(s_info.create_handler); + ecore_event_handler_del(s_info.destroy_handler); + ecore_event_handler_del(s_info.client_handler); + + s_info.create_handler = NULL; + s_info.destroy_handler = NULL; + s_info.client_handler = NULL; +} + +static inline int enable_xmonitor(void) { if (ecore_x_composite_query() == EINA_FALSE) DbgPrint("====> COMPOSITOR IS NOT ENABLED\n"); @@ -352,6 +375,17 @@ HAPI int xmonitor_init(void) } sniff_all_windows(); + return 0; +} + +HAPI int xmonitor_init(void) +{ + if (USE_XMONITOR) { + int ret; + ret = enable_xmonitor(); + if (ret < 0) + return ret; + } s_info.paused = client_is_all_paused() || setting_is_lcd_off(); if (s_info.paused) { @@ -364,13 +398,8 @@ HAPI int xmonitor_init(void) HAPI void xmonitor_fini(void) { - ecore_event_handler_del(s_info.create_handler); - ecore_event_handler_del(s_info.destroy_handler); - ecore_event_handler_del(s_info.client_handler); - - s_info.create_handler = NULL; - s_info.destroy_handler = NULL; - s_info.client_handler = NULL; + if (USE_XMONITOR) + disable_xmonitor(); } HAPI int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data) -- cgit v1.2.3