mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Add event to associate visuals with a pixel format token
This commit is contained in:
		
							parent
							
								
									4453ba084a
								
							
						
					
					
						commit
						4bde293ff8
					
				
					 3 changed files with 46 additions and 50 deletions
				
			
		| 
						 | 
				
			
			@ -83,6 +83,17 @@
 | 
			
		|||
    <request name="create_surface">
 | 
			
		||||
      <arg name="id" type="new_id" interface="wl_surface"/>
 | 
			
		||||
    </request>
 | 
			
		||||
 | 
			
		||||
    <enum name="visual">
 | 
			
		||||
      <entry name="argb32" value="0"/>
 | 
			
		||||
      <entry name="premultiplied_argb32" value="1"/>
 | 
			
		||||
      <entry name="xrgb32" value="2"/>
 | 
			
		||||
    </enum>
 | 
			
		||||
 | 
			
		||||
    <event name="token_visual">
 | 
			
		||||
      <arg name="id" type="new_id" interface="wl_object"/>
 | 
			
		||||
      <arg name="token" type="uint"/>
 | 
			
		||||
    </event>
 | 
			
		||||
  </interface>
 | 
			
		||||
 | 
			
		||||
  <!-- Shared memory support -->
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,10 +82,6 @@ struct wl_display {
 | 
			
		|||
	struct wl_list global_listener_list;
 | 
			
		||||
	struct wl_list global_list;
 | 
			
		||||
 | 
			
		||||
	struct wl_visual *argb_visual;
 | 
			
		||||
	struct wl_visual *premultiplied_argb_visual;
 | 
			
		||||
	struct wl_visual *rgb_visual;
 | 
			
		||||
 | 
			
		||||
	wl_display_update_func_t update;
 | 
			
		||||
	void *update_data;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -208,39 +204,6 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
 | 
			
		|||
	wl_closure_destroy(closure);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
add_visual(struct wl_display *display, uint32_t id)
 | 
			
		||||
{
 | 
			
		||||
	struct wl_visual *visual;
 | 
			
		||||
 | 
			
		||||
	visual = (struct wl_visual *)
 | 
			
		||||
		wl_proxy_create_for_id(display, &wl_visual_interface, id);
 | 
			
		||||
	if (display->argb_visual == NULL)
 | 
			
		||||
		display->argb_visual = visual;
 | 
			
		||||
	else if (display->premultiplied_argb_visual == NULL)
 | 
			
		||||
		display->premultiplied_argb_visual = visual;
 | 
			
		||||
	else
 | 
			
		||||
		display->rgb_visual = visual;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WL_EXPORT struct wl_visual *
 | 
			
		||||
wl_display_get_argb_visual(struct wl_display *display)
 | 
			
		||||
{
 | 
			
		||||
	return display->argb_visual;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WL_EXPORT struct wl_visual *
 | 
			
		||||
wl_display_get_premultiplied_argb_visual(struct wl_display *display)
 | 
			
		||||
{
 | 
			
		||||
	return display->premultiplied_argb_visual;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WL_EXPORT struct wl_visual *
 | 
			
		||||
wl_display_get_rgb_visual(struct wl_display *display)
 | 
			
		||||
{
 | 
			
		||||
	return display->rgb_visual;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Can't do this, there may be more than one instance of an
 | 
			
		||||
 * interface... */
 | 
			
		||||
WL_EXPORT uint32_t
 | 
			
		||||
| 
						 | 
				
			
			@ -278,8 +241,6 @@ display_handle_global(void *data,
 | 
			
		|||
	if (strcmp(interface, "wl_display") == 0)
 | 
			
		||||
		wl_hash_table_insert(display->objects,
 | 
			
		||||
				     id, &display->proxy.object);
 | 
			
		||||
	else if (strcmp(interface, "wl_visual") == 0)
 | 
			
		||||
		add_visual(display, id);
 | 
			
		||||
 | 
			
		||||
	global = malloc(sizeof *global);
 | 
			
		||||
	global->id = id;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -822,6 +822,29 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
compositor_bind(struct wl_client *client,
 | 
			
		||||
		struct wl_object *global, uint32_t version)
 | 
			
		||||
{
 | 
			
		||||
	struct wl_compositor *compositor =
 | 
			
		||||
		container_of(global, struct wl_compositor, object);
 | 
			
		||||
 | 
			
		||||
	wl_client_post_event(client, global,
 | 
			
		||||
			     WL_COMPOSITOR_TOKEN_VISUAL,
 | 
			
		||||
			     &compositor->argb_visual.object,
 | 
			
		||||
			     WL_COMPOSITOR_VISUAL_ARGB32);
 | 
			
		||||
 | 
			
		||||
	wl_client_post_event(client, global,
 | 
			
		||||
			     WL_COMPOSITOR_TOKEN_VISUAL,
 | 
			
		||||
			     &compositor->premultiplied_argb_visual.object,
 | 
			
		||||
			     WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32);
 | 
			
		||||
 | 
			
		||||
	wl_client_post_event(client, global,
 | 
			
		||||
			     WL_COMPOSITOR_TOKEN_VISUAL,
 | 
			
		||||
			     &compositor->rgb_visual.object,
 | 
			
		||||
			     WL_COMPOSITOR_VISUAL_XRGB32);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
WL_EXPORT int
 | 
			
		||||
wl_compositor_init(struct wl_compositor *compositor,
 | 
			
		||||
		   const struct wl_compositor_interface *interface,
 | 
			
		||||
| 
						 | 
				
			
			@ -830,13 +853,15 @@ wl_compositor_init(struct wl_compositor *compositor,
 | 
			
		|||
	compositor->object.interface = &wl_compositor_interface;
 | 
			
		||||
	compositor->object.implementation = (void (**)(void)) interface;
 | 
			
		||||
	wl_display_add_object(display, &compositor->object);
 | 
			
		||||
	if (wl_display_add_global(display, &compositor->object, NULL))
 | 
			
		||||
	if (wl_display_add_global(display,
 | 
			
		||||
				  &compositor->object, compositor_bind))
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	compositor->argb_visual.object.interface = &wl_visual_interface;
 | 
			
		||||
	compositor->argb_visual.object.implementation = NULL;
 | 
			
		||||
	wl_display_add_object(display, &compositor->argb_visual.object);
 | 
			
		||||
	if (wl_display_add_global(display, &compositor->argb_visual.object, NULL))
 | 
			
		||||
	if (wl_display_add_global(display,
 | 
			
		||||
				  &compositor->argb_visual.object, NULL))
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	compositor->premultiplied_argb_visual.object.interface =
 | 
			
		||||
| 
						 | 
				
			
			@ -851,8 +876,7 @@ wl_compositor_init(struct wl_compositor *compositor,
 | 
			
		|||
 | 
			
		||||
	compositor->rgb_visual.object.interface = &wl_visual_interface;
 | 
			
		||||
	compositor->rgb_visual.object.implementation = NULL;
 | 
			
		||||
	wl_display_add_object(display,
 | 
			
		||||
			      &compositor->rgb_visual.object);
 | 
			
		||||
	wl_display_add_object(display, &compositor->rgb_visual.object);
 | 
			
		||||
       if (wl_display_add_global(display,
 | 
			
		||||
				 &compositor->rgb_visual.object, NULL))
 | 
			
		||||
	       return -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue