Hide wayland cursor when X11 compositor loses focus

dev
Kristian Høgsberg 15 years ago
parent 554a131b29
commit 86e0989673
  1. 1
      compositor-drm.c
  2. 15
      compositor-x11.c
  3. 3
      compositor.c
  4. 5
      compositor.h

@ -678,6 +678,7 @@ drm_compositor_create(struct wl_display *display)
WL_EVENT_READABLE, on_drm_input, ec); WL_EVENT_READABLE, on_drm_input, ec);
setup_tty(ec, loop); setup_tty(ec, loop);
ec->base.present = drm_compositor_present; ec->base.present = drm_compositor_present;
ec->base.focus = 1;
return &ec->base; 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_BUTTON_RELEASE |
XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_EXPOSURE | 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 0
}; };
@ -559,6 +561,17 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
r->width = expose->width; r->width = expose->width;
r->height = expose->height; r->height = expose->height;
break; 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: case XCB_CLIENT_MESSAGE:
client_message = (xcb_client_message_event_t *) event; client_message = (xcb_client_message_event_t *) event;
atom = client_message->data.data32[0]; 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) wl_list_for_each(es, &ec->surface_list, link)
wlsc_surface_draw(es, output); wlsc_surface_draw(es, output);
if (ec->focus)
wl_list_for_each(eid, &ec->input_device_list, link) wl_list_for_each(eid, &ec->input_device_list, link)
wlsc_surface_draw(eid->sprite, output); wlsc_surface_draw(eid->sprite, output);
} }
@ -398,7 +399,7 @@ repaint(void *data)
ec->repaint_needed = 0; ec->repaint_needed = 0;
} }
static void void
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor) wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor)
{ {
compositor->repaint_needed = 1; compositor->repaint_needed = 1;

@ -99,6 +99,7 @@ struct wlsc_compositor {
uint32_t current_frame; uint32_t current_frame;
uint32_t modifier_state; uint32_t modifier_state;
uint32_t focus;
void (*present)(struct wlsc_compositor *c); void (*present)(struct wlsc_compositor *c);
}; };
@ -131,8 +132,8 @@ notify_key(struct wlsc_input_device *device, uint32_t key, uint32_t state);
void void
wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs); wlsc_compositor_finish_frame(struct wlsc_compositor *compositor, int msecs);
struct wlsc_input_device * void
wlsc_input_device_create(struct wlsc_compositor *ec); wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
int int
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display); wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display);

Loading…
Cancel
Save