mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Add glib main loop integration, use it in flower client.
This commit is contained in:
		
							parent
							
								
									7f77bd8fbe
								
							
						
					
					
						commit
						fb59084fbf
					
				
					 9 changed files with 194 additions and 93 deletions
				
			
		
							
								
								
									
										16
									
								
								pointer.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								pointer.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -98,15 +98,14 @@ draw_pointer(int width, int height)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
connection_update(struct wl_connection *connection,
 | 
			
		||||
		  uint32_t mask, void *data)
 | 
			
		||||
connection_update(uint32_t mask, void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct pollfd *p = data;
 | 
			
		||||
 | 
			
		||||
	p->events = 0;
 | 
			
		||||
	if (mask & WL_CONNECTION_READABLE)
 | 
			
		||||
	if (mask & WL_DISPLAY_READABLE)
 | 
			
		||||
		p->events |= POLLIN;
 | 
			
		||||
	if (mask & WL_CONNECTION_WRITABLE)
 | 
			
		||||
	if (mask & WL_DISPLAY_WRITABLE)
 | 
			
		||||
		p->events |= POLLOUT;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -142,13 +141,12 @@ int main(int argc, char *argv[])
 | 
			
		|||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	display = wl_display_create(socket_name,
 | 
			
		||||
				    connection_update, &p[0]);
 | 
			
		||||
	display = wl_display_create(socket_name);
 | 
			
		||||
	if (display == NULL) {
 | 
			
		||||
		fprintf(stderr, "failed to create display: %m\n");
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	p[0].fd = wl_display_get_fd(display);
 | 
			
		||||
	p[0].fd = wl_display_get_fd(display, connection_update, &p[0]);
 | 
			
		||||
 | 
			
		||||
	pointer.width = 16;
 | 
			
		||||
	pointer.height = 16;
 | 
			
		||||
| 
						 | 
				
			
			@ -168,9 +166,9 @@ int main(int argc, char *argv[])
 | 
			
		|||
		poll(p, 1, -1);
 | 
			
		||||
		mask = 0;
 | 
			
		||||
		if (p[0].revents & POLLIN)
 | 
			
		||||
			mask |= WL_CONNECTION_READABLE;
 | 
			
		||||
			mask |= WL_DISPLAY_READABLE;
 | 
			
		||||
		if (p[0].revents & POLLOUT)
 | 
			
		||||
			mask |= WL_CONNECTION_WRITABLE;
 | 
			
		||||
			mask |= WL_DISPLAY_WRITABLE;
 | 
			
		||||
		wl_display_iterate(display, mask);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue