mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Hide wayland cursor when X11 compositor loses focus
This commit is contained in:
		
							parent
							
								
									554a131b29
								
							
						
					
					
						commit
						86e0989673
					
				
					 4 changed files with 22 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -678,6 +678,7 @@ drm_compositor_create(struct wl_display *display)
 | 
			
		|||
				     WL_EVENT_READABLE, on_drm_input, ec);
 | 
			
		||||
	setup_tty(ec, loop);
 | 
			
		||||
	ec->base.present = drm_compositor_present;
 | 
			
		||||
	ec->base.focus = 1;
 | 
			
		||||
 | 
			
		||||
	return &ec->base;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -346,7 +346,9 @@ x11_compositor_create_output(struct x11_compositor *c, int width, int height)
 | 
			
		|||
		XCB_EVENT_MASK_BUTTON_RELEASE |
 | 
			
		||||
		XCB_EVENT_MASK_POINTER_MOTION |
 | 
			
		||||
		XCB_EVENT_MASK_EXPOSURE |
 | 
			
		||||
		XCB_EVENT_MASK_STRUCTURE_NOTIFY,
 | 
			
		||||
		XCB_EVENT_MASK_STRUCTURE_NOTIFY |
 | 
			
		||||
		XCB_EVENT_MASK_ENTER_WINDOW |
 | 
			
		||||
		XCB_EVENT_MASK_LEAVE_WINDOW,
 | 
			
		||||
		0
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -559,6 +561,17 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
 | 
			
		|||
			r->width = expose->width;
 | 
			
		||||
			r->height = expose->height;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case XCB_ENTER_NOTIFY:
 | 
			
		||||
			c->base.focus = 1;
 | 
			
		||||
			wlsc_compositor_schedule_repaint(&c->base);
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case XCB_LEAVE_NOTIFY:
 | 
			
		||||
			c->base.focus = 0;
 | 
			
		||||
			wlsc_compositor_schedule_repaint(&c->base);
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case XCB_CLIENT_MESSAGE:
 | 
			
		||||
			client_message = (xcb_client_message_event_t *) event;
 | 
			
		||||
			atom = client_message->data.data32[0];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -375,6 +375,7 @@ wlsc_output_repaint(struct wlsc_output *output)
 | 
			
		|||
	wl_list_for_each(es, &ec->surface_list, link)
 | 
			
		||||
		wlsc_surface_draw(es, output);
 | 
			
		||||
 | 
			
		||||
	if (ec->focus)
 | 
			
		||||
		wl_list_for_each(eid, &ec->input_device_list, link)
 | 
			
		||||
			wlsc_surface_draw(eid->sprite, output);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -398,7 +399,7 @@ repaint(void *data)
 | 
			
		|||
	ec->repaint_needed = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
void
 | 
			
		||||
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor)
 | 
			
		||||
{
 | 
			
		||||
	compositor->repaint_needed = 1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,6 +99,7 @@ struct wlsc_compositor {
 | 
			
		|||
	uint32_t current_frame;
 | 
			
		||||
 | 
			
		||||
	uint32_t modifier_state;
 | 
			
		||||
	uint32_t focus;
 | 
			
		||||
 | 
			
		||||
	void (*present)(struct wlsc_compositor *c);
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -131,8 +132,8 @@ notify_key(struct wlsc_input_device *device, uint32_t key, uint32_t state);
 | 
			
		|||
 | 
			
		||||
void
 | 
			
		||||
wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
 | 
			
		||||
struct wlsc_input_device *
 | 
			
		||||
wlsc_input_device_create(struct wlsc_compositor *ec);
 | 
			
		||||
void
 | 
			
		||||
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue