tray: placeholder touch events (currently ignored)

This commit is contained in:
Ian Fan 2020-09-28 11:10:21 +01:00
parent 1e92def4b1
commit a5acbcaa1e
3 changed files with 44 additions and 13 deletions

View file

@ -99,4 +99,8 @@ bool popup_pointer_button(void *data, struct wl_pointer *wl_pointer,
bool popup_pointer_axis(void *data, struct wl_pointer *wl_pointer, bool popup_pointer_axis(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value); uint32_t time, uint32_t axis, wl_fixed_t value);
bool popup_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
uint32_t time, struct wl_surface *surface, int32_t id, wl_fixed_t _x,
wl_fixed_t _y);
#endif #endif

View file

@ -403,7 +403,12 @@ static struct touch_slot *get_touch_slot(struct swaybar_touch *touch, int32_t id
static void wl_touch_down(void *data, struct wl_touch *wl_touch, static void wl_touch_down(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, struct wl_surface *surface, uint32_t serial, uint32_t time, struct wl_surface *surface,
int32_t id, wl_fixed_t _x, wl_fixed_t _y) { int32_t id, wl_fixed_t _x, wl_fixed_t _y) {
// TODO popup #if HAVE_TRAY
if (popup_touch_down(data, wl_touch, serial, time, surface, id, _x, _y)) {
return;
}
#endif
struct swaybar_seat *seat = data; struct swaybar_seat *seat = data;
struct swaybar_output *_output = NULL, *output = NULL; struct swaybar_output *_output = NULL, *output = NULL;
wl_list_for_each(_output, &seat->bar->outputs, link) { wl_list_for_each(_output, &seat->bar->outputs, link) {

View file

@ -810,6 +810,18 @@ void open_popup(struct swaybar_sni *sni, struct swaybar_output *output,
// input hooks // input hooks
static struct swaybar_popup_surface *popup_find_surface(struct swaybar_popup *popup,
struct wl_surface *surface) {
struct swaybar_popup_surface *popup_surface = popup->popup_surface;
while (popup_surface) {
if (popup_surface->surface == surface) {
return popup_surface;
}
popup_surface = popup_surface->child;
}
return NULL;
}
bool popup_pointer_enter(void *data, struct wl_pointer *wl_pointer, bool popup_pointer_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface, uint32_t serial, struct wl_surface *surface,
wl_fixed_t surface_x, wl_fixed_t surface_y) { wl_fixed_t surface_x, wl_fixed_t surface_y) {
@ -820,20 +832,16 @@ bool popup_pointer_enter(void *data, struct wl_pointer *wl_pointer,
} }
struct swaybar_popup *popup = tray->popup; struct swaybar_popup *popup = tray->popup;
struct swaybar_popup_surface *popup_surface = popup->popup_surface; struct swaybar_popup_surface *popup_surface = popup_find_surface(popup, surface);
while (popup_surface) { if (popup_surface) {
if (popup_surface->surface == surface) {
struct swaybar_pointer *pointer = &seat->pointer; struct swaybar_pointer *pointer = &seat->pointer;
pointer->current = popup->output; pointer->current = popup->output;
pointer->serial = serial; pointer->serial = serial;
update_cursor(seat); update_cursor(seat);
popup->pointer_focus = popup_surface; popup->pointer_focus = popup_surface;
return true;
} }
popup_surface = popup_surface->child; return popup_surface;
}
return false;
} }
bool popup_pointer_leave(void *data, struct wl_pointer *wl_pointer, bool popup_pointer_leave(void *data, struct wl_pointer *wl_pointer,
@ -950,3 +958,17 @@ bool popup_pointer_axis(void *data, struct wl_pointer *wl_pointer,
} }
return tray->popup->pointer_focus; return tray->popup->pointer_focus;
} }
bool popup_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
uint32_t time, struct wl_surface *surface, int32_t id, wl_fixed_t _x,
wl_fixed_t _y) {
struct swaybar_seat *seat = data;
struct swaybar_tray *tray = seat->bar->tray;
if (!(tray && tray->popup)) {
return false;
}
struct swaybar_popup_surface *popup_surface = popup_find_surface(tray->popup, surface);
return popup_surface;
}