compositor: add a way to override the default pointer grab

This commit is contained in:
Giulio Camuffo 2013-11-14 23:42:53 +01:00 committed by Kristian Høgsberg
parent 1959ab8d22
commit cdb4d29096
3 changed files with 41 additions and 4 deletions

View File

@ -3404,6 +3404,21 @@ weston_compositor_shutdown(struct weston_compositor *ec)
weston_config_destroy(ec->config); weston_config_destroy(ec->config);
} }
WL_EXPORT void
weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
const struct weston_pointer_grab_interface *interface)
{
struct weston_seat *seat;
ec->default_pointer_grab = interface;
wl_list_for_each(seat, &ec->seat_list, link) {
if (seat->pointer) {
weston_pointer_set_default_grab(seat->pointer,
interface);
}
}
}
WL_EXPORT void WL_EXPORT void
weston_version(int *major, int *minor, int *micro) weston_version(int *major, int *minor, int *micro)
{ {
@ -3847,6 +3862,7 @@ int main(int argc, char *argv[])
segv_compositor = ec; segv_compositor = ec;
ec->idle_time = idle_time; ec->idle_time = idle_time;
ec->default_pointer_grab = NULL;
setenv("WAYLAND_DISPLAY", socket_name, 1); setenv("WAYLAND_DISPLAY", socket_name, 1);

View File

@ -345,7 +345,7 @@ struct weston_touch {
}; };
struct weston_pointer * struct weston_pointer *
weston_pointer_create(void); weston_pointer_create(struct weston_seat *seat);
void void
weston_pointer_destroy(struct weston_pointer *pointer); weston_pointer_destroy(struct weston_pointer *pointer);
void void
@ -363,6 +363,9 @@ weston_pointer_clamp(struct weston_pointer *pointer,
void void
weston_pointer_move(struct weston_pointer *pointer, weston_pointer_move(struct weston_pointer *pointer,
wl_fixed_t x, wl_fixed_t y); wl_fixed_t x, wl_fixed_t y);
void
weston_pointer_set_default_grab(struct weston_pointer *pointer,
const struct weston_pointer_grab_interface *interface);
struct weston_keyboard * struct weston_keyboard *
weston_keyboard_create(void); weston_keyboard_create(void);
@ -586,6 +589,8 @@ struct weston_compositor {
uint32_t idle_inhibit; uint32_t idle_inhibit;
int idle_time; /* timeout, s */ int idle_time; /* timeout, s */
const struct weston_pointer_grab_interface *default_pointer_grab;
/* Repaint state. */ /* Repaint state. */
struct weston_plane primary_plane; struct weston_plane primary_plane;
uint32_t capabilities; /* combination of enum weston_capability */ uint32_t capabilities; /* combination of enum weston_capability */
@ -1073,6 +1078,10 @@ weston_compositor_run_debug_binding(struct weston_compositor *compositor,
uint32_t key, uint32_t key,
enum wl_keyboard_key_state state); enum wl_keyboard_key_state state);
void
weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
const struct weston_pointer_grab_interface *interface);
int int
weston_environment_get_fd(const char *env); weston_environment_get_fd(const char *env);

View File

@ -381,7 +381,7 @@ pointer_handle_sprite_destroy(struct wl_listener *listener, void *data)
} }
WL_EXPORT struct weston_pointer * WL_EXPORT struct weston_pointer *
weston_pointer_create(void) weston_pointer_create(struct weston_seat *seat)
{ {
struct weston_pointer *pointer; struct weston_pointer *pointer;
@ -391,7 +391,8 @@ weston_pointer_create(void)
wl_list_init(&pointer->resource_list); wl_list_init(&pointer->resource_list);
wl_list_init(&pointer->focus_resource_list); wl_list_init(&pointer->focus_resource_list);
pointer->default_grab.interface = &default_pointer_grab_interface; weston_pointer_set_default_grab(pointer,
seat->compositor->default_pointer_grab);
pointer->default_grab.pointer = pointer; pointer->default_grab.pointer = pointer;
pointer->grab = &pointer->default_grab; pointer->grab = &pointer->default_grab;
wl_signal_init(&pointer->focus_signal); wl_signal_init(&pointer->focus_signal);
@ -417,6 +418,17 @@ weston_pointer_destroy(struct weston_pointer *pointer)
free(pointer); free(pointer);
} }
void
weston_pointer_set_default_grab(struct weston_pointer *pointer,
const struct weston_pointer_grab_interface *interface)
{
if (interface)
pointer->default_grab.interface = interface;
else
pointer->default_grab.interface =
&default_pointer_grab_interface;
}
WL_EXPORT struct weston_keyboard * WL_EXPORT struct weston_keyboard *
weston_keyboard_create(void) weston_keyboard_create(void)
{ {
@ -1839,7 +1851,7 @@ weston_seat_init_pointer(struct weston_seat *seat)
return; return;
} }
pointer = weston_pointer_create(); pointer = weston_pointer_create(seat);
if (pointer == NULL) if (pointer == NULL)
return; return;