From: Boram Park Date: Fri, 14 Apr 2017 02:46:50 +0000 (+0900) Subject: tdm: don't send output changes if client doesn't watch them X-Git-Tag: accepted/tizen/unified/20170414.163558~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a146084d611e6b2b6a60b20c712ec38f719a61e8;p=platform%2Fcore%2Fuifw%2Flibtdm.git tdm: don't send output changes if client doesn't watch them Change-Id: I0c77afab20462f01cc8d2676e868d48b32978878 --- diff --git a/client/tdm_client.c b/client/tdm_client.c index 2062915..4d8ba30 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -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; } } diff --git a/protocol/tdm.xml b/protocol/tdm.xml index 0a157e0..bd5ed89 100644 --- a/protocol/tdm.xml +++ b/protocol/tdm.xml @@ -55,6 +55,10 @@ + + + + diff --git a/src/tdm_server.c b/src/tdm_server.c index f803a0b..f025365 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -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