Compare commits
2 Commits
36496ad126
...
76ea118bf2
Author | SHA1 | Date | |
---|---|---|---|
76ea118bf2 | |||
2c51676436 |
@ -39,6 +39,10 @@ struct kiwmi_cursor {
|
|||||||
struct wl_listener cursor_button;
|
struct wl_listener cursor_button;
|
||||||
struct wl_listener cursor_axis;
|
struct wl_listener cursor_axis;
|
||||||
struct wl_listener cursor_frame;
|
struct wl_listener cursor_frame;
|
||||||
|
struct wl_listener cursor_touch_up;
|
||||||
|
struct wl_listener cursor_touch_down;
|
||||||
|
struct wl_listener cursor_touch_motion;
|
||||||
|
struct wl_listener cursor_touch_frame;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal button_down;
|
struct wl_signal button_down;
|
||||||
@ -46,6 +50,7 @@ struct kiwmi_cursor {
|
|||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
struct wl_signal motion;
|
struct wl_signal motion;
|
||||||
struct wl_signal scroll;
|
struct wl_signal scroll;
|
||||||
|
struct wl_signal touch;
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,6 +66,14 @@ struct kiwmi_cursor_motion_event {
|
|||||||
double newy;
|
double newy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct kiwmi_cursor_touch_event {
|
||||||
|
char *event;
|
||||||
|
int id;
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
bool handled;
|
||||||
|
};
|
||||||
|
|
||||||
struct kiwmi_cursor_scroll_event {
|
struct kiwmi_cursor_scroll_event {
|
||||||
const char *device_name;
|
const char *device_name;
|
||||||
bool is_vertical;
|
bool is_vertical;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_pointer.h>
|
#include <wlr/types/wlr_pointer.h>
|
||||||
|
#include <wlr/types/wlr_touch.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
@ -119,6 +120,121 @@ cursor_motion_notify(struct wl_listener *listener, void *data)
|
|||||||
process_cursor_motion(server, event->time_msec);
|
process_cursor_motion(server, event->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
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 wlr_event_touch_down *event = 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 = "down",
|
||||||
|
.id = event->touch_id,
|
||||||
|
.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 &&
|
||||||
|
wlr_surface_accepts_touch(seat, surface)) {
|
||||||
|
wlr_seat_touch_notify_down(seat, surface, event->time_msec,
|
||||||
|
event->touch_id, event->x, event->y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cursor_touch_up_notify(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct kiwmi_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, cursor_touch_up);
|
||||||
|
struct kiwmi_server *server = cursor->server;
|
||||||
|
struct wlr_event_touch_up *event = 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)) {
|
||||||
|
wlr_seat_touch_notify_up(seat, event->time_msec, event->touch_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cursor_touch_motion_notify(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct kiwmi_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, cursor_touch_motion);
|
||||||
|
struct kiwmi_server *server = cursor->server;
|
||||||
|
struct wlr_event_touch_motion *event = 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)) {
|
||||||
|
wlr_seat_touch_notify_motion(seat, event->time_msec,
|
||||||
|
event->touch_id, event->x, event->y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cursor_touch_frame_notify(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct kiwmi_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, cursor_touch_frame);
|
||||||
|
struct kiwmi_server *server = cursor->server;
|
||||||
|
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 = "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)) {
|
||||||
|
wlr_seat_touch_notify_frame(seat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cursor_motion_absolute_notify(struct wl_listener *listener, void *data)
|
cursor_motion_absolute_notify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@ -252,10 +368,23 @@ cursor_create(
|
|||||||
cursor->cursor_frame.notify = cursor_frame_notify;
|
cursor->cursor_frame.notify = cursor_frame_notify;
|
||||||
wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame);
|
wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame);
|
||||||
|
|
||||||
|
cursor->cursor_touch_down.notify = cursor_touch_down_notify;
|
||||||
|
wl_signal_add(&cursor->cursor->events.touch_down, &cursor->cursor_touch_down);
|
||||||
|
|
||||||
|
cursor->cursor_touch_up.notify = cursor_touch_up_notify;
|
||||||
|
wl_signal_add(&cursor->cursor->events.touch_up, &cursor->cursor_touch_up);
|
||||||
|
|
||||||
|
cursor->cursor_touch_motion.notify = cursor_touch_motion_notify;
|
||||||
|
wl_signal_add(&cursor->cursor->events.touch_motion, &cursor->cursor_touch_motion);
|
||||||
|
|
||||||
|
cursor->cursor_touch_frame.notify = cursor_touch_frame_notify;
|
||||||
|
wl_signal_add(&cursor->cursor->events.touch_frame, &cursor->cursor_touch_frame);
|
||||||
|
|
||||||
wl_signal_init(&cursor->events.button_down);
|
wl_signal_init(&cursor->events.button_down);
|
||||||
wl_signal_init(&cursor->events.button_up);
|
wl_signal_init(&cursor->events.button_up);
|
||||||
wl_signal_init(&cursor->events.destroy);
|
wl_signal_init(&cursor->events.destroy);
|
||||||
wl_signal_init(&cursor->events.motion);
|
wl_signal_init(&cursor->events.motion);
|
||||||
|
wl_signal_init(&cursor->events.touch);
|
||||||
wl_signal_init(&cursor->events.scroll);
|
wl_signal_init(&cursor->events.scroll);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
|
@ -162,6 +162,36 @@ kiwmi_cursor_on_motion_notify(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
kiwmi_cursor_on_touch_notify(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct kiwmi_lua_callback *lc = wl_container_of(listener, lc, listener);
|
||||||
|
struct kiwmi_server *server = lc->server;
|
||||||
|
lua_State *L = server->lua->L;
|
||||||
|
struct kiwmi_cursor_touch_event *event = data;
|
||||||
|
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, lc->callback_ref);
|
||||||
|
|
||||||
|
lua_newtable(L);
|
||||||
|
|
||||||
|
lua_pushnumber(L, event->x);
|
||||||
|
lua_setfield(L, -2, "x");
|
||||||
|
|
||||||
|
lua_pushnumber(L, event->y);
|
||||||
|
lua_setfield(L, -2, "y");
|
||||||
|
|
||||||
|
lua_pushnumber(L, event->id);
|
||||||
|
lua_setfield(L, -2, "id");
|
||||||
|
|
||||||
|
lua_pushstring(L, event->event);
|
||||||
|
lua_setfield(L, -2, "name");
|
||||||
|
|
||||||
|
if (lua_pcall(L, 1, 0, 0)) {
|
||||||
|
wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1));
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kiwmi_cursor_on_scroll_notify(struct wl_listener *listener, void *data)
|
kiwmi_cursor_on_scroll_notify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@ -267,6 +297,31 @@ l_kiwmi_cursor_on_motion(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
l_kiwmi_cursor_on_touch(lua_State *L)
|
||||||
|
{
|
||||||
|
struct kiwmi_object *obj =
|
||||||
|
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_cursor");
|
||||||
|
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||||
|
|
||||||
|
struct kiwmi_cursor *cursor = obj->object;
|
||||||
|
struct kiwmi_server *server = cursor->server;
|
||||||
|
|
||||||
|
lua_pushcfunction(L, luaK_kiwmi_lua_callback_new);
|
||||||
|
lua_pushlightuserdata(L, server);
|
||||||
|
lua_pushvalue(L, 2);
|
||||||
|
lua_pushlightuserdata(L, kiwmi_cursor_on_touch_notify);
|
||||||
|
lua_pushlightuserdata(L, &cursor->events.touch);
|
||||||
|
lua_pushlightuserdata(L, obj);
|
||||||
|
|
||||||
|
if (lua_pcall(L, 5, 0, 0)) {
|
||||||
|
wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
l_kiwmi_cursor_on_scroll(lua_State *L)
|
l_kiwmi_cursor_on_scroll(lua_State *L)
|
||||||
{
|
{
|
||||||
@ -296,6 +351,7 @@ static const luaL_Reg kiwmi_cursor_events[] = {
|
|||||||
{"button_down", l_kiwmi_cursor_on_button_down},
|
{"button_down", l_kiwmi_cursor_on_button_down},
|
||||||
{"button_up", l_kiwmi_cursor_on_button_up},
|
{"button_up", l_kiwmi_cursor_on_button_up},
|
||||||
{"motion", l_kiwmi_cursor_on_motion},
|
{"motion", l_kiwmi_cursor_on_motion},
|
||||||
|
{"touch", l_kiwmi_cursor_on_touch},
|
||||||
{"scroll", l_kiwmi_cursor_on_scroll},
|
{"scroll", l_kiwmi_cursor_on_scroll},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
17
rc.fnl
17
rc.fnl
@ -110,6 +110,23 @@
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
(fn choose-view-at [x y]
|
||||||
|
(let [view (kiwmi:view_at x y)]
|
||||||
|
(tset app-state :focus-view view)
|
||||||
|
(tset app-state :in-overview false)
|
||||||
|
(hide-overview)
|
||||||
|
true))
|
||||||
|
|
||||||
|
(let [cursor (kiwmi:cursor)]
|
||||||
|
(cursor:on "button_up"
|
||||||
|
(fn [button-id]
|
||||||
|
(when app-state.in-overview
|
||||||
|
(let [geom (placements (kiwmi:active_output))
|
||||||
|
(x y) (cursor:pos)]
|
||||||
|
(if (< y geom.application.h)
|
||||||
|
(choose-view-at x y)
|
||||||
|
false))))))
|
||||||
|
|
||||||
(kiwmi:on
|
(kiwmi:on
|
||||||
"output"
|
"output"
|
||||||
(fn [output]
|
(fn [output]
|
||||||
|
Loading…
Reference in New Issue
Block a user