Compare commits

..

2 Commits

Author SHA1 Message Date
Daniel Barlow 9b36e46674 add eufonctl script 2022-07-11 23:22:01 +00:00
Daniel Barlow 5a7f2abab9 untested initial support for touch events
all it does is call lua handlers. no pointer emulation.  co-ordinate
system is screwy too.
2022-07-11 23:22:01 +00:00
4 changed files with 65 additions and 30 deletions

9
bin/eufonctl.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
SOCAT=socat
display=$1
test -n "$display" || display=$WAYLAND_DISPLAY
test -n "$display" || display=wayland-0
socket_name="${XDG_RUNTIME_DIR}/kiwmi-repl.${display}.socket"
${SOCAT} - unix-connect:$socket_name

View File

@ -10,6 +10,7 @@
, gtk3
, gtk-layer-shell
, lua5_3
, socat
} :
let
lua = lua5_3;
@ -63,5 +64,12 @@ stdenv.mkDerivation {
webkitgtk
];
installPhase = ''
mkdir -p $out/bin
substitute bin/eufon.sh $out/bin/eufon \
--replace SOCAT=socat SOCAT=${socat}/bin/socat
chmod +x $out/bin/eufon
'';
src = ./.;
}

View File

@ -125,32 +125,51 @@ cursor_touch_down_notify(struct wl_listener *listener, void *data)
{
struct kiwmi_cursor *cursor =
wl_container_of(listener, cursor, cursor_touch_down);
struct kiwmi_server *server = cursor->server;
struct kiwmi_server *server = cursor->server;
struct kiwmi_desktop *desktop = &server->desktop;
struct wlr_event_touch_down *event = data;
struct kiwmi_input *input = &server->input;
struct wlr_seat *seat = input->seat->seat;
struct wlr_surface *surface = NULL;
/* FIXME x,y are in the wrong co-ordinate system */
/* FIXME figure out what scaling should be done here.
* Does the touch co-ordinate system map onto a single output
* (e.g. phone screen) or onto the entire layout (tablet,
* maybe?)
*/
double lx = 720 * event->x;
double ly = 1440 * event->y;
double sx, sy;
struct kiwmi_view *view = view_at(
desktop,
lx, ly,
&surface,
&sx, &sy);
wlr_log(WLR_DEBUG, "view %x surface %x %f,%f %f,%f\n",
view, surface, lx, ly, sx, sy);
/* we send the event to lua with 0..1 co-ordinates, because
* it may not be over any surface
*/
struct kiwmi_cursor_touch_event new_event = {
.event = "down",
.id = event->touch_id,
.x = event->x,
.x = event->x,
.y = event->y,
};
struct wlr_surface *surface = NULL;
wl_signal_emit(&cursor->events.touch, &new_event);
/*
FIXME when we figure out the co-ordinates then find view
at this xy and pass the event on if it wants it
*/
if(false &&
!new_event.handled &&
if(!new_event.handled &&
surface &&
wlr_surface_accepts_touch(seat, surface)) {
wlr_log(WLR_DEBUG, "surface %x %f %f\n",
surface, sx, sy);
wlr_seat_touch_notify_down(seat, surface, event->time_msec,
event->touch_id, event->x, event->y);
event->touch_id, sx, sy);
}
}
@ -164,16 +183,13 @@ cursor_touch_up_notify(struct wl_listener *listener, void *data)
struct kiwmi_input *input = &server->input;
struct wlr_seat *seat = input->seat->seat;
/* FIXME x,y are in the wrong co-ordinate system */
struct kiwmi_cursor_touch_event new_event = {
.event = "up",
.id = event->touch_id,
};
struct wlr_surface *surface = NULL;
wl_signal_emit(&cursor->events.touch, &new_event);
if(false &&
!new_event.handled &&
wlr_surface_accepts_touch(seat, surface)) {
if(!new_event.handled) {
wlr_seat_touch_notify_up(seat, event->time_msec, event->touch_id);
}
}
@ -188,19 +204,20 @@ cursor_touch_motion_notify(struct wl_listener *listener, void *data)
struct kiwmi_input *input = &server->input;
struct wlr_seat *seat = input->seat->seat;
/* FIXME x,y are in the wrong co-ordinate system */
struct kiwmi_cursor_touch_event new_event = {
.event = "motion",
.id = event->touch_id,
.x = event->x,
.y = event->y,
};
struct wlr_surface *surface = NULL;
wl_signal_emit(&cursor->events.touch, &new_event);
if(false &&
!new_event.handled &&
wlr_surface_accepts_touch(seat, surface)) {
if(!new_event.handled) {
/* UNSURE: should we still send this even if the touch_down
* didn't get sent because the surface doesn't accept
* touch? */
wlr_seat_touch_notify_motion(seat, event->time_msec,
event->touch_id, event->x, event->y);
}
@ -216,21 +233,13 @@ cursor_touch_frame_notify(struct wl_listener *listener, void *data)
struct wlr_seat *seat = input->seat->seat;
/* FIXME x,y are in the wrong co-ordinate system */
struct kiwmi_cursor_touch_event new_event = {
.event = "frame",
};
struct wlr_surface *surface = NULL;
wl_signal_emit(&cursor->events.touch, &new_event);
/*
FIXME when we figure out the co-ordinates then find view
at this xy and pass the event on if it wants it
*/
if(false &&
!new_event.handled &&
wlr_surface_accepts_touch(seat, surface)) {
if(!new_event.handled) {
wlr_seat_touch_notify_frame(seat);
}
}

View File

@ -28,6 +28,12 @@ new_pointer(struct kiwmi_input *input, struct wlr_input_device *device)
wlr_cursor_attach_input_device(input->cursor->cursor, device);
}
static void
new_touch(struct kiwmi_input *input, struct wlr_input_device *device)
{
wlr_cursor_attach_input_device(input->cursor->cursor, device);
}
static void
new_keyboard(struct kiwmi_input *input, struct wlr_input_device *device)
{
@ -53,6 +59,9 @@ new_input_notify(struct wl_listener *listener, void *data)
case WLR_INPUT_DEVICE_POINTER:
new_pointer(input, device);
break;
case WLR_INPUT_DEVICE_TOUCH:
new_touch(input, device);
break;
case WLR_INPUT_DEVICE_KEYBOARD:
new_keyboard(input, device);
break;