aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLas <las@protonmail.ch>2018-08-04 23:22:21 +0200
committerLas <las@protonmail.ch>2018-09-18 10:14:33 +0200
commit252bcce2f373bc5f0e29a4820ce23373b836e3bb (patch)
tree30f324977c5afc1bbb917f8bf8a5003ada5d7019
parent50a8758313ced79221c67890dde153a5884db76f (diff)
Add focus change event for seats
-rw-r--r--include/wlr/types/wlr_seat.h22
-rw-r--r--types/seat/wlr_seat.c4
-rw-r--r--types/seat/wlr_seat_keyboard.c10
-rw-r--r--types/seat/wlr_seat_pointer.c9
4 files changed, 44 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index b3c02cf2..d850ba52 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -146,6 +146,10 @@ struct wlr_seat_pointer_state {
uint32_t grab_time;
struct wl_listener surface_destroy;
+
+ struct {
+ struct wl_signal focus_change;
+ } events;
};
// TODO: May be useful to be able to simulate keyboard input events
@@ -164,6 +168,10 @@ struct wlr_seat_keyboard_state {
struct wlr_seat_keyboard_grab *grab;
struct wlr_seat_keyboard_grab *default_grab;
+
+ struct {
+ struct wl_signal focus_change;
+ } events;
};
struct wlr_seat_touch_state {
@@ -238,6 +246,20 @@ struct wlr_seat_pointer_request_set_cursor_event {
int32_t hotspot_x, hotspot_y;
};
+struct wlr_seat_pointer_focus_change_event {
+ struct wlr_seat *seat;
+ struct wlr_surface *old_surface, *new_surface;
+ double sx, sy;
+};
+
+struct wlr_seat_keyboard_focus_change_event {
+ struct wlr_seat *seat;
+ struct wlr_surface *old_surface, *new_surface;
+ size_t num_keycodes;
+ uint32_t *keycodes;
+ struct wlr_keyboard_modifiers *modifiers;
+};
+
/**
* Allocates a new wlr_seat and adds a wl_seat global to the display.
*/
diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c
index 2e7da0a4..c4da29e2 100644
--- a/types/seat/wlr_seat.c
+++ b/types/seat/wlr_seat.c
@@ -225,6 +225,8 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
seat->pointer_state.default_grab = pointer_grab;
seat->pointer_state.grab = pointer_grab;
+ wl_signal_init(&seat->pointer_state.events.focus_change);
+
// keyboard state
struct wlr_seat_keyboard_grab *keyboard_grab =
calloc(1, sizeof(struct wlr_seat_keyboard_grab));
@@ -241,6 +243,8 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
seat->keyboard_state.seat = seat;
wl_list_init(&seat->keyboard_state.surface_destroy.link);
+ wl_signal_init(&seat->keyboard_state.events.focus_change);
+
// touch state
struct wlr_seat_touch_grab *touch_grab =
calloc(1, sizeof(struct wlr_seat_touch_grab));
diff --git a/types/seat/wlr_seat_keyboard.c b/types/seat/wlr_seat_keyboard.c
index e8ea300e..4f95b265 100644
--- a/types/seat/wlr_seat_keyboard.c
+++ b/types/seat/wlr_seat_keyboard.c
@@ -291,6 +291,16 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
// as it targets seat->keyboard_state.focused_client
wlr_seat_keyboard_send_modifiers(seat, modifiers);
}
+
+ struct wlr_seat_keyboard_focus_change_event event = {
+ .seat = seat,
+ .new_surface = surface,
+ .old_surface = focused_surface,
+ .num_keycodes = num_keycodes,
+ .keycodes = keycodes,
+ .modifiers = modifiers,
+ };
+ wlr_signal_emit_safe(&seat->keyboard_state.events.focus_change, &event);
}
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c
index 899fb64f..d6df0365 100644
--- a/types/seat/wlr_seat_pointer.c
+++ b/types/seat/wlr_seat_pointer.c
@@ -183,7 +183,14 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
wlr_seat->pointer_state.focused_client = client;
wlr_seat->pointer_state.focused_surface = surface;
- // TODO: send focus change event
+ struct wlr_seat_pointer_focus_change_event event = {
+ .seat = wlr_seat,
+ .new_surface = surface,
+ .old_surface = focused_surface,
+ .sx = sx,
+ .sy = sy,
+ };
+ wlr_signal_emit_safe(&wlr_seat->pointer_state.events.focus_change, &event);
}
void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat) {