mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Add convenience functions for posting display events
This commit is contained in:
		
							parent
							
								
									f66d0f4e14
								
							
						
					
					
						commit
						13b8ae4986
					
				
					 4 changed files with 28 additions and 22 deletions
				
			
		
							
								
								
									
										22
									
								
								compositor.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								compositor.c
									
										
									
									
									
								
							| 
						 | 
					@ -590,14 +590,11 @@ static void
 | 
				
			||||||
shell_create_drag(struct wl_client *client,
 | 
					shell_create_drag(struct wl_client *client,
 | 
				
			||||||
		  struct wl_shell *shell, uint32_t id)
 | 
							  struct wl_shell *shell, uint32_t id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_display *display = wl_client_get_display(client);
 | 
					 | 
				
			||||||
	struct wl_drag *drag;
 | 
						struct wl_drag *drag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	drag = malloc(sizeof *drag);
 | 
						drag = malloc(sizeof *drag);
 | 
				
			||||||
	if (drag == NULL) {
 | 
						if (drag == NULL) {
 | 
				
			||||||
		wl_client_post_event(client,
 | 
							wl_client_post_no_memory(client);
 | 
				
			||||||
				     (struct wl_object *) display,
 | 
					 | 
				
			||||||
				     WL_DISPLAY_NO_MEMORY);
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -627,9 +624,7 @@ compositor_create_surface(struct wl_client *client,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	surface = wlsc_surface_create(ec, NULL, 0, 0, 0, 0);
 | 
						surface = wlsc_surface_create(ec, NULL, 0, 0, 0, 0);
 | 
				
			||||||
	if (surface == NULL) {
 | 
						if (surface == NULL) {
 | 
				
			||||||
		wl_client_post_event(client,
 | 
							wl_client_post_no_memory(client);
 | 
				
			||||||
				     (struct wl_object *) ec->wl_display,
 | 
					 | 
				
			||||||
				     WL_DISPLAY_NO_MEMORY);
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1065,12 +1060,8 @@ wl_drag_set_pointer_focus(struct wl_drag *drag,
 | 
				
			||||||
	if (surface &&
 | 
						if (surface &&
 | 
				
			||||||
	    (!drag->pointer_focus ||
 | 
						    (!drag->pointer_focus ||
 | 
				
			||||||
	     drag->pointer_focus->client != surface->base.client)) {
 | 
						     drag->pointer_focus->client != surface->base.client)) {
 | 
				
			||||||
		wl_surface_post_event(&surface->base,
 | 
							wl_client_post_global(surface->base.client,
 | 
				
			||||||
				      (struct wl_object *) surface->compositor->wl_display,
 | 
									      &drag->drag_offer.base);
 | 
				
			||||||
				      WL_DISPLAY_GLOBAL,
 | 
					 | 
				
			||||||
				      &drag->drag_offer.base,
 | 
					 | 
				
			||||||
				      drag->drag_offer.base.interface->name,
 | 
					 | 
				
			||||||
				      drag->drag_offer.base.interface->version);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		end = drag->types.data + drag->types.size;
 | 
							end = drag->types.data + drag->types.size;
 | 
				
			||||||
		for (p = drag->types.data; p < end; p++)
 | 
							for (p = drag->types.data; p < end; p++)
 | 
				
			||||||
| 
						 | 
					@ -1138,16 +1129,13 @@ static const struct wl_drag_offer_interface drag_offer_interface = {
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
drag_offer(struct wl_client *client, struct wl_drag *drag, const char *type)
 | 
					drag_offer(struct wl_client *client, struct wl_drag *drag, const char *type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_display *display = wl_client_get_display (client);
 | 
					 | 
				
			||||||
	char **p;
 | 
						char **p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p = wl_array_add(&drag->types, sizeof *p);
 | 
						p = wl_array_add(&drag->types, sizeof *p);
 | 
				
			||||||
	if (p)
 | 
						if (p)
 | 
				
			||||||
		*p = strdup(type);
 | 
							*p = strdup(type);
 | 
				
			||||||
	if (!p || !*p)
 | 
						if (!p || !*p)
 | 
				
			||||||
		wl_client_post_event(client,
 | 
							wl_client_post_no_memory(client);
 | 
				
			||||||
				     (struct wl_object *) display,
 | 
					 | 
				
			||||||
				     WL_DISPLAY_NO_MEMORY);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								drm.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								drm.c
									
										
									
									
									
								
							| 
						 | 
					@ -93,9 +93,7 @@ drm_create_buffer(struct wl_client *client, struct wl_drm *drm_base,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer = malloc(sizeof *buffer);
 | 
						buffer = malloc(sizeof *buffer);
 | 
				
			||||||
	if (buffer == NULL) {
 | 
						if (buffer == NULL) {
 | 
				
			||||||
		wl_client_post_event(client,
 | 
							wl_client_post_no_memory(client);
 | 
				
			||||||
				     (struct wl_object *) compositor->wl_display,
 | 
					 | 
				
			||||||
				     WL_DISPLAY_NO_MEMORY, 0);
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,8 +139,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 | 
				
			||||||
					     p[0], opcode);
 | 
										     p[0], opcode);
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		} else if (closure == NULL && errno == ENOMEM) {
 | 
							} else if (closure == NULL && errno == ENOMEM) {
 | 
				
			||||||
			wl_client_post_event(client, &client->display->base,
 | 
								wl_client_post_no_memory(client);
 | 
				
			||||||
					     WL_DISPLAY_NO_MEMORY);
 | 
					 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -233,6 +232,25 @@ wl_client_add_resource(struct wl_client *client,
 | 
				
			||||||
	wl_list_insert(client->resource_list.prev, &resource->link);
 | 
						wl_list_insert(client->resource_list.prev, &resource->link);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WL_EXPORT void
 | 
				
			||||||
 | 
					wl_client_post_no_memory(struct wl_client *client)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wl_client_post_event(client,
 | 
				
			||||||
 | 
								     &client->display->base,
 | 
				
			||||||
 | 
								     WL_DISPLAY_NO_MEMORY);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WL_EXPORT void
 | 
				
			||||||
 | 
					wl_client_post_global(struct wl_client *client, struct wl_object *object)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wl_client_post_event(client,
 | 
				
			||||||
 | 
								     &client->display->base,
 | 
				
			||||||
 | 
								     WL_DISPLAY_GLOBAL,
 | 
				
			||||||
 | 
								     object,
 | 
				
			||||||
 | 
								     object->interface->name,
 | 
				
			||||||
 | 
								     object->interface->version);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WL_EXPORT void
 | 
					WL_EXPORT void
 | 
				
			||||||
wl_resource_destroy(struct wl_resource *resource, struct wl_client *client)
 | 
					wl_resource_destroy(struct wl_resource *resource, struct wl_client *client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,6 +91,8 @@ typedef void (*wl_client_connect_func_t)(struct wl_client *client, struct wl_obj
 | 
				
			||||||
int wl_display_add_global(struct wl_display *display, struct wl_object *object, wl_client_connect_func_t func);
 | 
					int wl_display_add_global(struct wl_display *display, struct wl_object *object, wl_client_connect_func_t func);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wl_client_destroy(struct wl_client *client);
 | 
					void wl_client_destroy(struct wl_client *client);
 | 
				
			||||||
 | 
					void wl_client_post_no_memory(struct wl_client *client);
 | 
				
			||||||
 | 
					void wl_client_post_global(struct wl_client *client, struct wl_object *object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_compositor {
 | 
					struct wl_compositor {
 | 
				
			||||||
	struct wl_object base;
 | 
						struct wl_object base;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue