Add client_paused/client_resumed command.
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 20 Feb 2013 08:16:51 +0000 (08:16 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 20 Feb 2013 08:46:30 +0000 (08:46 +0000)
The xmonitor can be optionally toggled.

Change-Id: Ib9e9c45912c80fc04aa9eb3a95e5e1485d025539

data/baltic.conf.ini
data/private.conf.ini
include/conf.h
include/xmonitor.h
src/conf.c
src/server.c
src/setting.c
src/xmonitor.c

index 2a0f195..d823052 100644 (file)
@@ -27,3 +27,4 @@ provider_method=shm
 debug_mode=false
 overwrite_content=false
 com_core_thread=true
+use_xmonitor=false
index 586d1a0..c5285fe 100644 (file)
@@ -27,3 +27,4 @@ provider_method=pixmap
 debug_mode=false
 overwrite_content=false
 com_core_thread=true
+use_xmonitor=false
index a1b27dd..714cf0c 100644 (file)
@@ -81,6 +81,7 @@ struct conf {
        int debug_mode;
        int overwrite_content;
        int com_core_thread;
+       int use_xmonitor;
 };
 
 extern struct conf g_conf;
@@ -146,6 +147,8 @@ extern int conf_loader(void);
 #define DEFAULT_CLUSTER        "user,created"
 #define MINIMUM_REACTIVATION_TIME      10
 
+#define USE_XMONITOR           g_conf.use_xmonitor
+
 #define HAPI __attribute__((visibility("hidden")))
 
 /* End of a file */
index 3ddc7cd..1ee8eab 100644 (file)
@@ -28,5 +28,7 @@ extern int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void
 extern int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data);
 extern int xmonitor_is_paused(void);
 extern void xmonitor_handle_state_changes(void);
+extern int xmonitor_resume(struct client_node *client);
+extern int xmonitor_pause(struct client_node *client);
 
 /* End of a file */
index ca57d98..c8667f9 100644 (file)
@@ -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");
@@ -437,6 +444,10 @@ HAPI int conf_loader(void)
                        .handler = use_sw_backend_handler,
                },
                {
+                       .name = "use_xmonitor",
+                       .handler = use_xmonitor,
+               },
+               {
                        .name = "provider_method",
                        .handler = provider_method_handler,
                },
index 75f4e18..0347041 100644 (file)
@@ -2335,6 +2335,58 @@ 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", &timestamp);
+       if (ret != 1) {
+               ErrPrint("Invalid parameter\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
+       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", &timestamp);
+       if (ret != 1) {
+               ErrPrint("Invalid parameter\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
+       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;
@@ -5215,6 +5267,15 @@ static struct method s_client_table[] = {
        },
 
        {
+               .cmd = "client_paused",
+               .handler = client_pause_request,
+       },
+       {
+               .cmd = "client_resumed",
+               .handler = client_resume_request,
+       },
+
+       {
                .cmd = NULL,
                .handler = NULL,
        },
index ffcc949..53d1400 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <Eina.h>
 
+#include "client_life.h"
 #include "setting.h"
 #include "util.h"
 #include "debug.h"
index c3924c5..057cbbd 100644 (file)
 #include <dlog.h>
 
 #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;
 
@@ -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,32 @@ static inline void sniff_all_windows(void)
        return;
 }
 
-HAPI int xmonitor_init(void)
+HAPI int xmonitor_pause(struct client_node *client)
+{
+       client_paused(client);
+       xmonitor_handle_state_changes();
+       return 0;
+}
+
+HAPI int xmonitor_resume(struct client_node *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 +373,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 +396,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)