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;
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;
}
}
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 {
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);
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