mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	idle-inhibit: feedback pass
This commit is contained in:
		
							parent
							
								
									bab8c73d3c
								
							
						
					
					
						commit
						3016133f91
					
				
					 5 changed files with 79 additions and 86 deletions
				
			
		| 
						 | 
					@ -11,9 +11,12 @@
 | 
				
			||||||
#include <linux/input-event-codes.h>
 | 
					#include <linux/input-event-codes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Usage: toplevel-decoration [mode]
 | 
					 * Usage: idle-inhibit
 | 
				
			||||||
 * Creates a xdg-toplevel supporting decoration negotiation. If `mode` is
 | 
					 * Creates a xdg-toplevel using the idle-inhibit protocol.
 | 
				
			||||||
 * specified, the client will prefer this decoration mode.
 | 
					 * It will be solid green, when it has an idle inhibitor, and solid yellow if
 | 
				
			||||||
 | 
					 * it does not.
 | 
				
			||||||
 | 
					 * Left click with a pointer will toggle this state. (Touch is not supported
 | 
				
			||||||
 | 
					 * for now).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int width = 500, height = 300;
 | 
					static int width = 500, height = 300;
 | 
				
			||||||
| 
						 | 
					@ -49,7 +52,12 @@ static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32
 | 
				
			||||||
	draw();
 | 
						draw();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void noop () {}
 | 
					/* Function that just does nothing.
 | 
				
			||||||
 | 
					 * When it is noop(void) (like draw) the compiler complains about type
 | 
				
			||||||
 | 
					 * mismatches in the listener struct.
 | 
				
			||||||
 | 
					 * Without any arguments, it can be implicitly casted
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static void noop() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_pointer_listener pointer_listener = {
 | 
					static const struct wl_pointer_listener pointer_listener = {
 | 
				
			||||||
	.enter = noop,
 | 
						.enter = noop,
 | 
				
			||||||
| 
						 | 
					@ -107,11 +115,6 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
 | 
				
			||||||
	.close = xdg_toplevel_handle_close,
 | 
						.close = xdg_toplevel_handle_close,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = {
 | 
					 | 
				
			||||||
// 	.preferred_mode = decoration_handle_preferred_mode,
 | 
					 | 
				
			||||||
// 	.configure = decoration_handle_configure,
 | 
					 | 
				
			||||||
// };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void handle_global(void *data, struct wl_registry *registry,
 | 
					static void handle_global(void *data, struct wl_registry *registry,
 | 
				
			||||||
		uint32_t name, const char *interface, uint32_t version) {
 | 
							uint32_t name, const char *interface, uint32_t version) {
 | 
				
			||||||
	if (strcmp(interface, "wl_compositor") == 0) {
 | 
						if (strcmp(interface, "wl_compositor") == 0) {
 | 
				
			||||||
| 
						 | 
					@ -138,18 +141,6 @@ static const struct wl_registry_listener registry_listener = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char **argv) {
 | 
					int main(int argc, char **argv) {
 | 
				
			||||||
//	if (argc == 2) {
 | 
					 | 
				
			||||||
//		char *mode = argv[1];
 | 
					 | 
				
			||||||
//		if (strcmp(mode, "client") == 0) {
 | 
					 | 
				
			||||||
//			decoration_mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT;
 | 
					 | 
				
			||||||
//		} else if (strcmp(mode, "server") == 0) {
 | 
					 | 
				
			||||||
//			decoration_mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER;
 | 
					 | 
				
			||||||
//		} else {
 | 
					 | 
				
			||||||
//			fprintf(stderr, "Invalid decoration mode\n");
 | 
					 | 
				
			||||||
//			return EXIT_FAILURE;
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
//	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct wl_display *display = wl_display_connect(NULL);
 | 
						struct wl_display *display = wl_display_connect(NULL);
 | 
				
			||||||
	if (display == NULL) {
 | 
						if (display == NULL) {
 | 
				
			||||||
		fprintf(stderr, "Failed to create display\n");
 | 
							fprintf(stderr, "Failed to create display\n");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ struct roots_desktop {
 | 
				
			||||||
	struct wlr_server_decoration_manager *server_decoration_manager;
 | 
						struct wlr_server_decoration_manager *server_decoration_manager;
 | 
				
			||||||
	struct wlr_primary_selection_device_manager *primary_selection_device_manager;
 | 
						struct wlr_primary_selection_device_manager *primary_selection_device_manager;
 | 
				
			||||||
	struct wlr_idle *idle;
 | 
						struct wlr_idle *idle;
 | 
				
			||||||
	struct wlr_idle_inhibit_v1 *idle_inhibit;
 | 
						struct wlr_idle_inhibit_manager_v1 *idle_inhibit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_listener new_output;
 | 
						struct wl_listener new_output;
 | 
				
			||||||
	struct wl_listener layout_change;
 | 
						struct wl_listener layout_change;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,12 +3,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <wayland-server.h>
 | 
					#include <wayland-server.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_idle_inhibit_v1 {
 | 
					struct wlr_idle_inhibit_manager_v1 {
 | 
				
			||||||
	struct wl_list clients;
 | 
						struct wl_list wl_resources; // wl_resource_get_link
 | 
				
			||||||
 | 
						struct wl_list inhibitors; // wlr_idle_inhibit_inhibitor_v1::link
 | 
				
			||||||
	struct wl_global *global;
 | 
						struct wl_global *global;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	struct wl_listener display_destroy;
 | 
						struct wl_listener display_destroy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct {
 | 
				
			||||||
		struct wl_signal new_inhibitor;
 | 
							struct wl_signal new_inhibitor;
 | 
				
			||||||
 | 
						} events;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_idle_inhibit_inhibitor_v1 {
 | 
					struct wlr_idle_inhibit_inhibitor_v1 {
 | 
				
			||||||
| 
						 | 
					@ -16,12 +20,14 @@ struct wlr_idle_inhibit_inhibitor_v1 {
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
	struct wl_listener surface_destroy;
 | 
						struct wl_listener surface_destroy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list link; // wlr_idle_inhibit_manager::inhibitors;
 | 
						struct wl_list link; // wlr_idle_inhibit_manager_v1::inhibitors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct {
 | 
				
			||||||
		struct wl_signal destroy;
 | 
							struct wl_signal destroy;
 | 
				
			||||||
 | 
						} events;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_idle_inhibit_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display);
 | 
					struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display);
 | 
				
			||||||
void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_v1 *idle_inhibit);
 | 
					void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,6 @@ client_protocols = [
 | 
				
			||||||
	'gtk-primary-selection.xml',
 | 
						'gtk-primary-selection.xml',
 | 
				
			||||||
	'idle.xml',
 | 
						'idle.xml',
 | 
				
			||||||
	'screenshooter.xml',
 | 
						'screenshooter.xml',
 | 
				
			||||||
	'server-decoration.xml',
 | 
					 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wl_protos_src = []
 | 
					wl_protos_src = []
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,35 +1,45 @@
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <wlr/util/log.h>
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
 | 
					#include <util/signal.h>
 | 
				
			||||||
#include <wlr/types/wlr_surface.h>
 | 
					#include <wlr/types/wlr_surface.h>
 | 
				
			||||||
#include <wlr/types/wlr_idle_inhibit_v1.h>
 | 
					#include <wlr/types/wlr_idle_inhibit_v1.h>
 | 
				
			||||||
#include "wayland-util.h"
 | 
					#include "wayland-util.h"
 | 
				
			||||||
#include "wayland-server.h"
 | 
					#include "wayland-server.h"
 | 
				
			||||||
#include "idle-inhibit-unstable-v1-protocol.h"
 | 
					#include "idle-inhibit-unstable-v1-protocol.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_idle_inhibit_manager {
 | 
					static struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl;
 | 
				
			||||||
	struct wlr_idle_inhibit_v1 *wlr_idle_inhibit;
 | 
					 | 
				
			||||||
	struct wl_resource *resource;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list link; // wlr_idle_inhibit_v1::clients
 | 
					static struct zwp_idle_inhibitor_v1_interface idle_inhibitor_impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list inhibitors;
 | 
					struct wlr_idle_inhibit_manager_v1 *
 | 
				
			||||||
};
 | 
					wlr_idle_inhibit_manager_v1_from_resource(struct wl_resource *resource) {
 | 
				
			||||||
 | 
						assert(wl_resource_instance_of(resource, &zwp_idle_inhibit_manager_v1_interface,
 | 
				
			||||||
 | 
							&idle_inhibit_impl));
 | 
				
			||||||
 | 
						return wl_resource_get_user_data(resource);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct wlr_idle_inhibit_inhibitor_v1 *
 | 
				
			||||||
 | 
					wlr_idle_inhibit_inhibitor_v1_from_resource(struct wl_resource *resource) {
 | 
				
			||||||
 | 
						assert(wl_resource_instance_of(resource, &zwp_idle_inhibitor_v1_interface,
 | 
				
			||||||
 | 
							&idle_inhibitor_impl));
 | 
				
			||||||
 | 
						return wl_resource_get_user_data(resource);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void idle_inhibit_inhibitor_destroy(struct wl_resource *resource) {
 | 
					static void idle_inhibit_inhibitor_destroy(struct wl_resource *resource) {
 | 
				
			||||||
	struct wlr_idle_inhibit_inhibitor_v1 *inhibitor = wl_resource_get_user_data(resource);
 | 
						struct wlr_idle_inhibit_inhibitor_v1 *inhibitor =
 | 
				
			||||||
 | 
							wlr_idle_inhibit_inhibitor_v1_from_resource(resource);
 | 
				
			||||||
	assert(inhibitor);
 | 
						assert(inhibitor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_signal_emit(&inhibitor->destroy, inhibitor->surface);
 | 
						wlr_signal_emit_safe(&inhibitor->events.destroy, inhibitor->surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_remove(&inhibitor->link);
 | 
						wl_list_remove(&inhibitor->link);
 | 
				
			||||||
	wl_list_remove(&inhibitor->surface_destroy.link);
 | 
						wl_list_remove(&inhibitor->surface_destroy.link);
 | 
				
			||||||
	free(inhibitor);
 | 
						free(inhibitor);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void idle_inhibit_inhibitor_handle_surface_destroy(struct wl_listener *listener,
 | 
					static void idle_inhibit_inhibitor_handle_surface_destroy(
 | 
				
			||||||
		void *data) {
 | 
							struct wl_listener *listener, void *data) {
 | 
				
			||||||
	assert(listener);
 | 
					 | 
				
			||||||
	struct wlr_idle_inhibit_inhibitor_v1 *inhibitor =
 | 
						struct wlr_idle_inhibit_inhibitor_v1 *inhibitor =
 | 
				
			||||||
		wl_container_of(listener, inhibitor, surface_destroy);
 | 
							wl_container_of(listener, inhibitor, surface_destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,11 +58,13 @@ static struct zwp_idle_inhibitor_v1_interface idle_inhibitor_impl = {
 | 
				
			||||||
static void wlr_create_inhibitor(struct wl_client *client,
 | 
					static void wlr_create_inhibitor(struct wl_client *client,
 | 
				
			||||||
		struct wl_resource *resource, uint32_t id,
 | 
							struct wl_resource *resource, uint32_t id,
 | 
				
			||||||
		struct wl_resource *surface_resource) {
 | 
							struct wl_resource *surface_resource) {
 | 
				
			||||||
	struct wlr_surface *surface = wl_resource_get_user_data(surface_resource);
 | 
						struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
 | 
				
			||||||
	struct wlr_idle_inhibit_manager *manager = wl_resource_get_user_data(resource);
 | 
						struct wlr_idle_inhibit_manager_v1 *manager =
 | 
				
			||||||
 | 
							wlr_idle_inhibit_manager_v1_from_resource(resource);
 | 
				
			||||||
	assert(surface && manager);
 | 
						assert(surface && manager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_idle_inhibit_inhibitor_v1 *inhibitor = calloc(1, sizeof(struct wlr_idle_inhibit_inhibitor_v1));
 | 
						struct wlr_idle_inhibit_inhibitor_v1 *inhibitor =
 | 
				
			||||||
 | 
							calloc(1, sizeof(struct wlr_idle_inhibit_inhibitor_v1));
 | 
				
			||||||
	if (!inhibitor) {
 | 
						if (!inhibitor) {
 | 
				
			||||||
		wl_client_post_no_memory(client);
 | 
							wl_client_post_no_memory(client);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -68,7 +80,7 @@ static void wlr_create_inhibitor(struct wl_client *client,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inhibitor->resource = wl_resource;
 | 
						inhibitor->resource = wl_resource;
 | 
				
			||||||
	inhibitor->surface = surface;
 | 
						inhibitor->surface = surface;
 | 
				
			||||||
	wl_signal_init(&inhibitor->destroy);
 | 
						wl_signal_init(&inhibitor->events.destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inhibitor->surface_destroy.notify = idle_inhibit_inhibitor_handle_surface_destroy;
 | 
						inhibitor->surface_destroy.notify = idle_inhibit_inhibitor_handle_surface_destroy;
 | 
				
			||||||
	wl_signal_add(&surface->events.destroy, &inhibitor->surface_destroy);
 | 
						wl_signal_add(&surface->events.destroy, &inhibitor->surface_destroy);
 | 
				
			||||||
| 
						 | 
					@ -78,38 +90,26 @@ static void wlr_create_inhibitor(struct wl_client *client,
 | 
				
			||||||
		inhibitor, idle_inhibit_inhibitor_destroy);
 | 
							inhibitor, idle_inhibit_inhibitor_destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_insert(&manager->inhibitors, &inhibitor->link);
 | 
						wl_list_insert(&manager->inhibitors, &inhibitor->link);
 | 
				
			||||||
	wl_signal_emit(&manager->wlr_idle_inhibit->new_inhibitor, inhibitor);
 | 
						wlr_signal_emit_safe(&manager->events.new_inhibitor, inhibitor);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void idle_inhibit_manager_destroy(struct wl_resource *resource) {
 | 
					static void idle_inhibit_manager_v1_destroy(struct wl_resource *resource) {
 | 
				
			||||||
	struct wlr_idle_inhibit_manager *manager = wl_resource_get_user_data(resource);
 | 
						wl_list_remove(wl_resource_get_link(resource));
 | 
				
			||||||
	assert(manager);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	wl_list_remove(&manager->link);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct wlr_idle_inhibit_inhibitor_v1 *inhibitor;
 | 
					 | 
				
			||||||
	struct wlr_idle_inhibit_inhibitor_v1 *tmp;
 | 
					 | 
				
			||||||
	wl_list_for_each_safe(inhibitor, tmp, &manager->inhibitors, link) {
 | 
					 | 
				
			||||||
		wl_resource_destroy(inhibitor->resource);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void idle_inhibit_manager_handle_destroy(struct wl_client *client,
 | 
					static void idle_inhibit_manager_v1_handle_destroy(struct wl_client *client,
 | 
				
			||||||
		struct wl_resource *manager_resource) {
 | 
							struct wl_resource *manager_resource) {
 | 
				
			||||||
	wl_resource_destroy(manager_resource);
 | 
						wl_resource_destroy(manager_resource);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl = {
 | 
					static struct zwp_idle_inhibit_manager_v1_interface idle_inhibit_impl = {
 | 
				
			||||||
	.destroy = idle_inhibit_manager_handle_destroy,
 | 
						.destroy = idle_inhibit_manager_v1_handle_destroy,
 | 
				
			||||||
	.create_inhibitor = wlr_create_inhibitor,
 | 
						.create_inhibitor = wlr_create_inhibitor,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_v1 *idle_inhibit);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
 | 
					static void handle_display_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct wlr_idle_inhibit_v1 *idle_inhibit =
 | 
						struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
 | 
				
			||||||
		wl_container_of(listener, idle_inhibit, display_destroy);
 | 
							wl_container_of(listener, idle_inhibit, display_destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_idle_inhibit_v1_destroy(idle_inhibit);
 | 
						wlr_idle_inhibit_v1_destroy(idle_inhibit);
 | 
				
			||||||
| 
						 | 
					@ -117,63 +117,60 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
 | 
					static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
 | 
				
			||||||
		uint32_t version, uint32_t id) {
 | 
							uint32_t version, uint32_t id) {
 | 
				
			||||||
	struct wlr_idle_inhibit_v1 *idle_inhibit = data;
 | 
						struct wlr_idle_inhibit_manager_v1 *idle_inhibit = data;
 | 
				
			||||||
	assert(wl_client && idle_inhibit);
 | 
						assert(wl_client && idle_inhibit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_idle_inhibit_manager *manager = calloc(1, sizeof(struct wlr_idle_inhibit_manager));
 | 
					 | 
				
			||||||
	if (!manager) {
 | 
					 | 
				
			||||||
		wl_client_post_no_memory(wl_client);
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct wl_resource *wl_resource  = wl_resource_create(wl_client,
 | 
						struct wl_resource *wl_resource  = wl_resource_create(wl_client,
 | 
				
			||||||
		&zwp_idle_inhibit_manager_v1_interface, version, id);
 | 
							&zwp_idle_inhibit_manager_v1_interface, version, id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!wl_resource) {
 | 
						if (!wl_resource) {
 | 
				
			||||||
		wl_client_post_no_memory(wl_client);
 | 
							wl_client_post_no_memory(wl_client);
 | 
				
			||||||
		free(manager);
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	manager->resource = wl_resource;
 | 
						wl_list_insert(&idle_inhibit->wl_resources, wl_resource_get_link(wl_resource));
 | 
				
			||||||
	wl_list_init(&manager->inhibitors);
 | 
					 | 
				
			||||||
	wl_list_insert(&idle_inhibit->clients, &manager->link);
 | 
					 | 
				
			||||||
	manager->wlr_idle_inhibit = idle_inhibit;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_resource_set_implementation(wl_resource, &idle_inhibit_impl,
 | 
						wl_resource_set_implementation(wl_resource, &idle_inhibit_impl,
 | 
				
			||||||
		manager, idle_inhibit_manager_destroy);
 | 
							idle_inhibit, idle_inhibit_manager_v1_destroy);
 | 
				
			||||||
	wlr_log(L_DEBUG, "idle_inhibit bound");
 | 
						wlr_log(L_DEBUG, "idle_inhibit bound");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_v1 *idle_inhibit) {
 | 
					void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibit) {
 | 
				
			||||||
	if (!idle_inhibit) {
 | 
						if (!idle_inhibit) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_remove(&idle_inhibit->display_destroy.link);
 | 
						wl_list_remove(&idle_inhibit->display_destroy.link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_idle_inhibit_manager *manager;
 | 
						struct wlr_idle_inhibit_inhibitor_v1 *inhibitor;
 | 
				
			||||||
	struct wlr_idle_inhibit_manager *tmp;
 | 
						struct wlr_idle_inhibit_inhibitor_v1 *tmp;
 | 
				
			||||||
	wl_list_for_each_safe(manager, tmp, &idle_inhibit->clients, link) {
 | 
						wl_list_for_each_safe(inhibitor, tmp, &idle_inhibit->inhibitors, link) {
 | 
				
			||||||
		wl_resource_destroy(manager->resource);
 | 
							wl_resource_destroy(inhibitor->resource);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct wl_resource *resource;
 | 
				
			||||||
 | 
						struct wl_resource *tmp_resource;
 | 
				
			||||||
 | 
						wl_resource_for_each_safe(resource, tmp_resource, &idle_inhibit->wl_resources) {
 | 
				
			||||||
 | 
							wl_resource_destroy(inhibitor->resource);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_global_destroy(idle_inhibit->global);
 | 
						wl_global_destroy(idle_inhibit->global);
 | 
				
			||||||
	free(idle_inhibit);
 | 
						free(idle_inhibit);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_idle_inhibit_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) {
 | 
					struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) {
 | 
				
			||||||
	struct wlr_idle_inhibit_v1 *idle_inhibit = calloc(1, sizeof(struct wlr_idle_inhibit_v1));
 | 
						struct wlr_idle_inhibit_manager_v1 *idle_inhibit =
 | 
				
			||||||
 | 
							calloc(1, sizeof(struct wlr_idle_inhibit_manager_v1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!idle_inhibit) {
 | 
						if (!idle_inhibit) {
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_init(&idle_inhibit->clients);
 | 
						wl_list_init(&idle_inhibit->wl_resources);
 | 
				
			||||||
 | 
						wl_list_init(&idle_inhibit->inhibitors);
 | 
				
			||||||
	idle_inhibit->display_destroy.notify = handle_display_destroy;
 | 
						idle_inhibit->display_destroy.notify = handle_display_destroy;
 | 
				
			||||||
	wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy);
 | 
						wl_display_add_destroy_listener(display, &idle_inhibit->display_destroy);
 | 
				
			||||||
	wl_signal_init(&idle_inhibit->new_inhibitor);
 | 
						wl_signal_init(&idle_inhibit->events.new_inhibitor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	idle_inhibit->global = wl_global_create(display,
 | 
						idle_inhibit->global = wl_global_create(display,
 | 
				
			||||||
		&zwp_idle_inhibit_manager_v1_interface, 1,
 | 
							&zwp_idle_inhibit_manager_v1_interface, 1,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue