output->destroying = 0;
output->name = strdup(name);
wl_list_init(&output->link);
+ wl_signal_init(&output->user_destroy_signal);
output->enabled = false;
wl_list_init(&output->head_list);
}
}
+/** Add destroy callback for an output
+ *
+ * \param output The output to watch.
+ * \param listener The listener to add. The \c notify member must be set.
+ *
+ * The listener callback will be called when user destroys an output. This
+ * may be delayed by a backend in some cases. The main purpose of the
+ * listener is to allow hooking up custom data to the output. The custom data
+ * can be fetched via weston_output_get_destroy_listener() followed by
+ * container_of().
+ *
+ * The \c data argument to the notify callback is the weston_output being
+ * destroyed.
+ *
+ * @note This is for the final destruction of an output, not when it gets
+ * disabled. If you want to keep track of enabled outputs, this is not it.
+ */
+WL_EXPORT void
+weston_output_add_destroy_listener(struct weston_output *output,
+ struct wl_listener *listener)
+{
+ wl_signal_add(&output->user_destroy_signal, listener);
+}
+
+/** Look up destroy listener for an output
+ *
+ * \param output The output to query.
+ * \param notify The notify function used used for the added destroy listener.
+ * \return The listener, or NULL if not found.
+ *
+ * This looks up the previously added destroy listener struct based on the
+ * notify function it has. The listener can be used to access user data
+ * through \c container_of().
+ *
+ * \sa wl_signal_get() weston_output_add_destroy_listener()
+ */
+WL_EXPORT struct wl_listener *
+weston_output_get_destroy_listener(struct weston_output *output,
+ wl_notify_func_t notify)
+{
+ return wl_signal_get(&output->user_destroy_signal, notify);
+}
+
/** Uninitialize an output
*
* Removes the output from the list of enabled outputs if necessary, but
output->destroying = 1;
+ wl_signal_emit(&output->user_destroy_signal, output);
+
if (output->idle_repaint_source)
wl_event_source_remove(output->idle_repaint_source);
uint32_t id;
char *name;
+ /** Matches the lifetime from the user perspective */
+ struct wl_signal user_destroy_signal;
+
void *renderer_state;
struct wl_list link;
struct weston_output_zoom zoom;
int dirty;
struct wl_signal frame_signal;
- struct wl_signal destroy_signal;
+ struct wl_signal destroy_signal; /**< sent when disabled */
int move_x, move_y;
struct timespec frame_time; /* presentation timestamp */
uint64_t msc; /* media stream counter */
weston_output_move(struct weston_output *output, int x, int y);
void
+weston_output_add_destroy_listener(struct weston_output *output,
+ struct wl_listener *listener);
+struct wl_listener *
+weston_output_get_destroy_listener(struct weston_output *output,
+ wl_notify_func_t notify);
+void
weston_output_release(struct weston_output *output);
void
weston_output_transform_coordinate(struct weston_output *output,