compositor: add a way to override the default pointer grab
This commit is contained in:
parent
1959ab8d22
commit
cdb4d29096
@ -3404,6 +3404,21 @@ weston_compositor_shutdown(struct weston_compositor *ec)
|
||||
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
|
||||
weston_version(int *major, int *minor, int *micro)
|
||||
{
|
||||
@ -3847,6 +3862,7 @@ int main(int argc, char *argv[])
|
||||
segv_compositor = ec;
|
||||
|
||||
ec->idle_time = idle_time;
|
||||
ec->default_pointer_grab = NULL;
|
||||
|
||||
setenv("WAYLAND_DISPLAY", socket_name, 1);
|
||||
|
||||
|
@ -345,7 +345,7 @@ struct weston_touch {
|
||||
};
|
||||
|
||||
struct weston_pointer *
|
||||
weston_pointer_create(void);
|
||||
weston_pointer_create(struct weston_seat *seat);
|
||||
void
|
||||
weston_pointer_destroy(struct weston_pointer *pointer);
|
||||
void
|
||||
@ -363,6 +363,9 @@ weston_pointer_clamp(struct weston_pointer *pointer,
|
||||
void
|
||||
weston_pointer_move(struct weston_pointer *pointer,
|
||||
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 *
|
||||
weston_keyboard_create(void);
|
||||
@ -586,6 +589,8 @@ struct weston_compositor {
|
||||
uint32_t idle_inhibit;
|
||||
int idle_time; /* timeout, s */
|
||||
|
||||
const struct weston_pointer_grab_interface *default_pointer_grab;
|
||||
|
||||
/* Repaint state. */
|
||||
struct weston_plane primary_plane;
|
||||
uint32_t capabilities; /* combination of enum weston_capability */
|
||||
@ -1073,6 +1078,10 @@ weston_compositor_run_debug_binding(struct weston_compositor *compositor,
|
||||
uint32_t key,
|
||||
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
|
||||
weston_environment_get_fd(const char *env);
|
||||
|
||||
|
18
src/input.c
18
src/input.c
@ -381,7 +381,7 @@ pointer_handle_sprite_destroy(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
WL_EXPORT struct weston_pointer *
|
||||
weston_pointer_create(void)
|
||||
weston_pointer_create(struct weston_seat *seat)
|
||||
{
|
||||
struct weston_pointer *pointer;
|
||||
|
||||
@ -391,7 +391,8 @@ weston_pointer_create(void)
|
||||
|
||||
wl_list_init(&pointer->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->grab = &pointer->default_grab;
|
||||
wl_signal_init(&pointer->focus_signal);
|
||||
@ -417,6 +418,17 @@ weston_pointer_destroy(struct weston_pointer *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 *
|
||||
weston_keyboard_create(void)
|
||||
{
|
||||
@ -1839,7 +1851,7 @@ weston_seat_init_pointer(struct weston_seat *seat)
|
||||
return;
|
||||
}
|
||||
|
||||
pointer = weston_pointer_create();
|
||||
pointer = weston_pointer_create(seat);
|
||||
if (pointer == NULL)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user