mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-30 00:15:58 +01:00
Implement tool tip -> click simulation
This commit is contained in:
parent
eaf6c0ccf4
commit
96b401c05d
1 changed files with 30 additions and 26 deletions
|
@ -8,6 +8,30 @@
|
||||||
#include "rootston/desktop.h"
|
#include "rootston/desktop.h"
|
||||||
|
|
||||||
void cursor_update_position(struct roots_input *input, uint32_t time) {
|
void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||||
|
struct roots_desktop *desktop = input->server->desktop;
|
||||||
|
struct roots_view *view;
|
||||||
|
switch (input->mode) {
|
||||||
|
case ROOTS_CURSOR_PASSTHROUGH:
|
||||||
|
view = view_at(desktop, input->cursor->x, input->cursor->y);
|
||||||
|
if (view) {
|
||||||
|
struct wlr_box box;
|
||||||
|
view_get_input_bounds(view, &box);
|
||||||
|
double sx = input->cursor->x - view->x;
|
||||||
|
double sy = input->cursor->y - view->y;
|
||||||
|
wlr_log(L_DEBUG, "Moving cursor in view at %f, %f", sx, sy);
|
||||||
|
wlr_seat_pointer_enter(input->wl_seat, view->wlr_surface, sx, sy);
|
||||||
|
wlr_seat_pointer_send_motion(input->wl_seat, time, sx, sy);
|
||||||
|
} else {
|
||||||
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ROOTS_CURSOR_MOVE:
|
||||||
|
break;
|
||||||
|
case ROOTS_CURSOR_RESIZE:
|
||||||
|
break;
|
||||||
|
case ROOTS_CURSOR_ROTATE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (input->motion_context.surface) {
|
if (input->motion_context.surface) {
|
||||||
struct example_xdg_surface_v6 *surface;
|
struct example_xdg_surface_v6 *surface;
|
||||||
|
@ -17,20 +41,6 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
struct roots_desktop *desktop = input->server->desktop;
|
|
||||||
struct roots_view *view = view_at(
|
|
||||||
desktop, input->cursor->x, input->cursor->y);
|
|
||||||
if (view) {
|
|
||||||
struct wlr_box box;
|
|
||||||
view_get_input_bounds(view, &box);
|
|
||||||
double sx = input->cursor->x - view->x;
|
|
||||||
double sy = input->cursor->y - view->y;
|
|
||||||
wlr_log(L_DEBUG, "Moving cursor in view at %f, %f", sx, sy);
|
|
||||||
wlr_seat_pointer_enter(input->wl_seat, view->wlr_surface, sx, sy);
|
|
||||||
wlr_seat_pointer_send_motion(input->wl_seat, time, sx, sy);
|
|
||||||
} else {
|
|
||||||
wlr_seat_pointer_clear_focus(input->wl_seat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_view_focus(struct roots_input *input,
|
static void set_view_focus(struct roots_input *input,
|
||||||
|
@ -86,11 +96,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
||||||
int i;
|
int i;
|
||||||
switch (event->state) {
|
switch (event->state) {
|
||||||
case WLR_BUTTON_RELEASED:
|
case WLR_BUTTON_RELEASED:
|
||||||
/*
|
input->active_view = NULL;
|
||||||
if (sample->motion_context.surface) {
|
|
||||||
sample->motion_context.surface = NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
case WLR_BUTTON_PRESSED:
|
case WLR_BUTTON_PRESSED:
|
||||||
i = input->input_events_idx;
|
i = input->input_events_idx;
|
||||||
|
@ -116,17 +122,15 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tool_tip(struct wl_listener *listener, void *data) {
|
static void handle_tool_tip(struct wl_listener *listener, void *data) {
|
||||||
/* TODO
|
|
||||||
struct roots_input *input = wl_container_of(listener, input, tool_tip);
|
struct roots_input *input = wl_container_of(listener, input, tool_tip);
|
||||||
struct wlr_event_tablet_tool_tip *event = data;
|
struct wlr_event_tablet_tool_tip *event = data;
|
||||||
|
|
||||||
struct wlr_xdg_surface_v6 *surface =
|
struct roots_desktop *desktop = input->server->desktop;
|
||||||
example_xdg_surface_at(sample, sample->cursor->x, sample->cursor->y);
|
struct roots_view *view = view_at(
|
||||||
example_set_focused_surface(sample, surface);
|
desktop, input->cursor->x, input->cursor->y);
|
||||||
|
set_view_focus(input, desktop, view);
|
||||||
wlr_seat_pointer_send_button(sample->wl_seat, (uint32_t)event->time_usec,
|
wlr_seat_pointer_send_button(input->wl_seat, (uint32_t)event->time_usec,
|
||||||
BTN_LEFT, event->state);
|
BTN_LEFT, event->state);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cursor_initialize(struct roots_input *input) {
|
void cursor_initialize(struct roots_input *input) {
|
||||||
|
|
Loading…
Reference in a new issue