Move cursor functions to 'cursor.c'. Implement cursor show method properly
This commit is contained in:
parent
d055b6587e
commit
f5acde9a69
4 changed files with 58 additions and 5 deletions
|
@ -64,6 +64,8 @@ struct kiwmi_cursor_motion_event {
|
||||||
struct kiwmi_cursor *cursor_create(
|
struct kiwmi_cursor *cursor_create(
|
||||||
struct kiwmi_server *server,
|
struct kiwmi_server *server,
|
||||||
struct wlr_output_layout *output_layout);
|
struct wlr_output_layout *output_layout);
|
||||||
|
void cursor_hide(struct kiwmi_cursor *cursor);
|
||||||
|
void cursor_show(struct kiwmi_cursor *cursor);
|
||||||
void cursor_destroy(struct kiwmi_cursor *cursor);
|
void cursor_destroy(struct kiwmi_cursor *cursor);
|
||||||
|
|
||||||
#endif /* KIWMI_INPUT_CURSOR_H */
|
#endif /* KIWMI_INPUT_CURSOR_H */
|
||||||
|
|
|
@ -115,7 +115,6 @@ output_frame_notify(struct wl_listener *listener, void *data)
|
||||||
struct wlr_output_layout *output_layout = desktop->output_layout;
|
struct wlr_output_layout *output_layout = desktop->output_layout;
|
||||||
struct wlr_renderer *renderer =
|
struct wlr_renderer *renderer =
|
||||||
wlr_backend_get_renderer(wlr_output->backend);
|
wlr_backend_get_renderer(wlr_output->backend);
|
||||||
struct kiwmi_cursor *cursor = server->input.cursor;
|
|
||||||
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
|
@ -230,6 +230,60 @@ cursor_frame_notify(struct wl_listener *listener, void *UNUSED(data))
|
||||||
wlr_seat_pointer_notify_frame(input->seat->seat);
|
wlr_seat_pointer_notify_frame(input->seat->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cursor_hide(struct kiwmi_cursor *cursor)
|
||||||
|
{
|
||||||
|
wlr_cursor_set_surface(cursor->cursor, NULL, 0, 0);
|
||||||
|
cursor->visible = false;
|
||||||
|
wlr_seat_pointer_notify_clear_focus(cursor->server->input.seat->seat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cursor_show(struct kiwmi_cursor *cursor)
|
||||||
|
{
|
||||||
|
struct kiwmi_server *server = cursor->server;
|
||||||
|
struct kiwmi_desktop *desktop = &server->desktop;
|
||||||
|
struct wlr_seat *seat = server->input.seat->seat;
|
||||||
|
|
||||||
|
double ox = 0;
|
||||||
|
double oy = 0;
|
||||||
|
struct wlr_output *wlr_output = wlr_output_layout_output_at(
|
||||||
|
desktop->output_layout, cursor->cursor->x, cursor->cursor->y);
|
||||||
|
|
||||||
|
wlr_output_layout_output_coords(
|
||||||
|
desktop->output_layout, wlr_output, &ox, &oy);
|
||||||
|
|
||||||
|
struct kiwmi_output *output = wlr_output->data;
|
||||||
|
|
||||||
|
struct wlr_surface *surface = NULL;
|
||||||
|
double sx;
|
||||||
|
double sy;
|
||||||
|
|
||||||
|
struct kiwmi_layer *layer = layer_at(
|
||||||
|
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
|
||||||
|
&surface,
|
||||||
|
cursor->cursor->x,
|
||||||
|
cursor->cursor->y,
|
||||||
|
&sx,
|
||||||
|
&sy);
|
||||||
|
|
||||||
|
cursor->visible = true;
|
||||||
|
|
||||||
|
if (!layer) {
|
||||||
|
struct kiwmi_view *view = view_at(
|
||||||
|
desktop, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||||
|
|
||||||
|
if (!view) {
|
||||||
|
wlr_xcursor_manager_set_cursor_image(
|
||||||
|
cursor->xcursor_manager, "left_ptr", cursor->cursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surface) {
|
||||||
|
wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct kiwmi_cursor *
|
struct kiwmi_cursor *
|
||||||
cursor_create(
|
cursor_create(
|
||||||
struct kiwmi_server *server,
|
struct kiwmi_server *server,
|
||||||
|
|
|
@ -29,9 +29,7 @@ l_kiwmi_cursor_hide(lua_State *L)
|
||||||
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_cursor");
|
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_cursor");
|
||||||
struct kiwmi_cursor *cursor = obj->object;
|
struct kiwmi_cursor *cursor = obj->object;
|
||||||
|
|
||||||
wlr_cursor_set_surface(cursor->cursor, NULL, 0, 0);
|
cursor_hide(cursor);
|
||||||
cursor->visible = false;
|
|
||||||
wlr_seat_pointer_notify_clear_focus(cursor->server->input.seat->seat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -55,7 +53,7 @@ l_kiwmi_cursor_show(lua_State *L)
|
||||||
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_cursor");
|
*(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_cursor");
|
||||||
struct kiwmi_cursor *cursor = obj->object;
|
struct kiwmi_cursor *cursor = obj->object;
|
||||||
|
|
||||||
cursor->visible = true;
|
cursor_show(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Reference in a new issue