tdm: don't send output changes if client doesn't watch them 32/125132/1
authorBoram Park <boram1288.park@samsung.com>
Fri, 14 Apr 2017 02:46:50 +0000 (11:46 +0900)
committerBoram Park <boram1288.park@samsung.com>
Fri, 14 Apr 2017 02:48:41 +0000 (11:48 +0900)
Change-Id: I0c77afab20462f01cc8d2676e868d48b32978878

client/tdm_client.c
protocol/tdm.xml
src/tdm_server.c

index 2062915..4d8ba30 100644 (file)
@@ -499,6 +499,9 @@ tdm_client_output_add_change_handler(tdm_client_output *output,
        h = calloc(1, sizeof *h);
        TDM_RETURN_VAL_IF_FAIL(h != NULL, TDM_ERROR_OUT_OF_MEMORY);
 
+       if (LIST_IS_EMPTY(&private_output->change_handler_list))
+               wl_tdm_output_watch_output_changes(private_output->output, 1);
+
        h->private_output = private_output;
        h->func = func;
        h->user_data = user_data;
@@ -526,6 +529,10 @@ tdm_client_output_remove_change_handler(tdm_client_output *output,
 
                LIST_DEL(&h->link);
                free(h);
+
+               if (LIST_IS_EMPTY(&private_output->change_handler_list))
+                       wl_tdm_output_watch_output_changes(private_output->output, 0);
+
                return;
        }
 }
index 0a157e0..bd5ed89 100644 (file)
             <arg name="id" type="new_id" interface="wl_tdm_vblank"/>
         </request>
 
+        <request name="watch_output_changes">
+            <arg name="enable" type="uint"/>
+        </request>
+
     </interface>
 
     <interface name="wl_tdm_vblank" version="1">
index f803a0b..f025365 100644 (file)
@@ -63,6 +63,7 @@ typedef struct _tdm_server_output_info {
        struct wl_resource *resource;
        tdm_output *output;
        struct list_head vblank_list;
+       unsigned int watch_output_changes;
 } tdm_server_output_info;
 
 typedef struct _tdm_server_vblank_info {
@@ -163,9 +164,23 @@ _tdm_server_cb_output_change(tdm_output *output, tdm_output_change_type type,
                                                         tdm_value value, void *user_data)
 {
        tdm_server_output_info *output_info = user_data;
+       struct wl_client *client;
+       pid_t pid = 0;
 
        TDM_RETURN_IF_FAIL(output_info != NULL);
 
+       client = wl_resource_get_client(output_info->resource);
+       TDM_RETURN_IF_FAIL(client != NULL);
+
+       wl_client_get_credentials(client, &pid, NULL, NULL);
+
+       if (!output_info->watch_output_changes) {
+               TDM_DBG("skip sending the output changes: pid(%d)", (unsigned int)pid);
+               return;
+       }
+
+       TDM_DBG("send the output changes: %d", (unsigned int)pid);
+
        switch (type) {
        case TDM_OUTPUT_CHANGE_DPMS:
                wl_tdm_output_send_dpms(output_info->resource, value.u32);
@@ -392,9 +407,20 @@ _tdm_server_output_cb_create_vblank(struct wl_client *client, struct wl_resource
        return;
 }
 
+static void
+_tdm_server_output_cb_watch_output_changes(struct wl_client *client, struct wl_resource *resource, unsigned int enable)
+{
+       tdm_server_output_info *output_info = wl_resource_get_user_data(resource);
+
+       TDM_RETURN_IF_FAIL(output_info != NULL);
+
+       output_info->watch_output_changes = enable;
+}
+
 static const struct wl_tdm_output_interface tdm_output_implementation = {
        _tdm_server_output_cb_destroy,
        _tdm_server_output_cb_create_vblank,
+       _tdm_server_output_cb_watch_output_changes,
 };
 
 static void