mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-22 06:59:44 -05:00
Merge branch 'master' into laggy-move-resize
This commit is contained in:
commit
7904b625f0
25 changed files with 1061 additions and 294 deletions
|
|
@ -150,6 +150,37 @@ void add_binding_config(struct wl_list *bindings, const char* combination,
|
|||
}
|
||||
}
|
||||
|
||||
static void config_handle_cursor(struct roots_config *config,
|
||||
const char *seat_name, const char *name, const char *value) {
|
||||
struct roots_cursor_config *cc;
|
||||
bool found = false;
|
||||
wl_list_for_each(cc, &config->cursors, link) {
|
||||
if (strcmp(cc->seat, seat_name) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cc = calloc(1, sizeof(struct roots_cursor_config));
|
||||
cc->seat = strdup(seat_name);
|
||||
wl_list_insert(&config->cursors, &cc->link);
|
||||
}
|
||||
|
||||
if (strcmp(name, "map-to-output") == 0) {
|
||||
free(cc->mapped_output);
|
||||
cc->mapped_output = strdup(value);
|
||||
} else if (strcmp(name, "geometry") == 0) {
|
||||
free(cc->mapped_box);
|
||||
cc->mapped_box = parse_geometry(value);
|
||||
} else if (strcmp(name, "theme") == 0) {
|
||||
free(cc->theme);
|
||||
cc->theme = strdup(value);
|
||||
} else {
|
||||
wlr_log(L_ERROR, "got unknown cursor config: %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void config_handle_keyboard(struct roots_config *config,
|
||||
const char *device_name, const char *name, const char *value) {
|
||||
struct roots_keyboard_config *kc;
|
||||
|
|
@ -190,6 +221,7 @@ static void config_handle_keyboard(struct roots_config *config,
|
|||
static const char *output_prefix = "output:";
|
||||
static const char *device_prefix = "device:";
|
||||
static const char *keyboard_prefix = "keyboard:";
|
||||
static const char *cursor_prefix = "cursor:";
|
||||
|
||||
static int config_ini_handler(void *user, const char *section, const char *name,
|
||||
const char *value) {
|
||||
|
|
@ -269,16 +301,12 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|||
oc->name, oc->mode.width, oc->mode.height,
|
||||
oc->mode.refresh_rate);
|
||||
}
|
||||
} else if (strncmp(cursor_prefix, section, strlen(cursor_prefix)) == 0) {
|
||||
const char *seat_name = section + strlen(cursor_prefix);
|
||||
config_handle_cursor(config, seat_name, name, value);
|
||||
} else if (strcmp(section, "cursor") == 0) {
|
||||
if (strcmp(name, "map-to-output") == 0) {
|
||||
free(config->cursor.mapped_output);
|
||||
config->cursor.mapped_output = strdup(value);
|
||||
} else if (strcmp(name, "geometry") == 0) {
|
||||
free(config->cursor.mapped_box);
|
||||
config->cursor.mapped_box = parse_geometry(value);
|
||||
} else {
|
||||
wlr_log(L_ERROR, "got unknown cursor config: %s", name);
|
||||
}
|
||||
config_handle_cursor(config, ROOTS_CONFIG_DEFAULT_SEAT_NAME, name,
|
||||
value);
|
||||
} else if (strncmp(device_prefix, section, strlen(device_prefix)) == 0) {
|
||||
const char *device_name = section + strlen(device_prefix);
|
||||
|
||||
|
|
@ -294,7 +322,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|||
if (!found) {
|
||||
dc = calloc(1, sizeof(struct roots_device_config));
|
||||
dc->name = strdup(device_name);
|
||||
dc->seat = strdup("seat0");
|
||||
dc->seat = strdup(ROOTS_CONFIG_DEFAULT_SEAT_NAME);
|
||||
wl_list_insert(&config->devices, &dc->link);
|
||||
}
|
||||
|
||||
|
|
@ -335,6 +363,7 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
|
|||
wl_list_init(&config->outputs);
|
||||
wl_list_init(&config->devices);
|
||||
wl_list_init(&config->keyboards);
|
||||
wl_list_init(&config->cursors);
|
||||
wl_list_init(&config->bindings);
|
||||
|
||||
int c;
|
||||
|
|
@ -415,6 +444,15 @@ void roots_config_destroy(struct roots_config *config) {
|
|||
free(kc);
|
||||
}
|
||||
|
||||
struct roots_cursor_config *cc, *ctmp = NULL;
|
||||
wl_list_for_each_safe(cc, ctmp, &config->cursors, link) {
|
||||
free(cc->seat);
|
||||
free(cc->mapped_output);
|
||||
free(cc->mapped_box);
|
||||
free(cc->theme);
|
||||
free(cc);
|
||||
}
|
||||
|
||||
struct roots_binding_config *bc, *btmp = NULL;
|
||||
wl_list_for_each_safe(bc, btmp, &config->bindings, link) {
|
||||
free(bc->keysyms);
|
||||
|
|
@ -423,8 +461,6 @@ void roots_config_destroy(struct roots_config *config) {
|
|||
}
|
||||
|
||||
free(config->config_path);
|
||||
free(config->cursor.mapped_output);
|
||||
free(config->cursor.mapped_box);
|
||||
free(config);
|
||||
}
|
||||
|
||||
|
|
@ -454,13 +490,33 @@ struct roots_device_config *roots_config_get_device(struct roots_config *config,
|
|||
|
||||
struct roots_keyboard_config *roots_config_get_keyboard(
|
||||
struct roots_config *config, struct wlr_input_device *device) {
|
||||
const char *device_name = "";
|
||||
if (device != NULL) {
|
||||
device_name = device->name;
|
||||
}
|
||||
|
||||
struct roots_keyboard_config *kc;
|
||||
wl_list_for_each(kc, &config->keyboards, link) {
|
||||
if ((device != NULL && strcmp(kc->name, device->name) == 0) ||
|
||||
(device == NULL && strcmp(kc->name, "") == 0)) {
|
||||
if (strcmp(kc->name, device_name) == 0) {
|
||||
return kc;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct roots_cursor_config *roots_config_get_cursor(struct roots_config *config,
|
||||
const char *seat_name) {
|
||||
if (seat_name == NULL) {
|
||||
seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
|
||||
}
|
||||
|
||||
struct roots_cursor_config *cc;
|
||||
wl_list_for_each(cc, &config->cursors, link) {
|
||||
if (strcmp(cc->seat, seat_name) == 0) {
|
||||
return cc;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ void roots_cursor_destroy(struct roots_cursor *cursor) {
|
|||
// TODO
|
||||
}
|
||||
|
||||
static void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t time) {
|
||||
static void roots_cursor_update_position(struct roots_cursor *cursor,
|
||||
uint32_t time) {
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
struct roots_seat *seat = cursor->seat;
|
||||
struct roots_view *view;
|
||||
|
|
@ -122,15 +123,18 @@ static void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t t
|
|||
|
||||
static void roots_cursor_press_button(struct roots_cursor *cursor,
|
||||
struct wlr_input_device *device, uint32_t time, uint32_t button,
|
||||
uint32_t state) {
|
||||
uint32_t state, double lx, double ly) {
|
||||
struct roots_seat *seat = cursor->seat;
|
||||
struct roots_desktop *desktop = seat->input->server->desktop;
|
||||
bool is_touch = device->type == WLR_INPUT_DEVICE_TOUCH;
|
||||
|
||||
struct wlr_surface *surface;
|
||||
double sx, sy;
|
||||
struct roots_view *view = view_at(desktop,
|
||||
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
|
||||
struct roots_view *view = view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||
|
||||
if (state == WLR_BUTTON_PRESSED && view && roots_seat_has_meta_pressed(seat)) {
|
||||
if (state == WLR_BUTTON_PRESSED &&
|
||||
view &&
|
||||
roots_seat_has_meta_pressed(seat)) {
|
||||
roots_seat_focus_view(seat, view);
|
||||
|
||||
uint32_t edges;
|
||||
|
|
@ -159,14 +163,21 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t serial =
|
||||
wlr_seat_pointer_notify_button(seat->seat, time, button, state);
|
||||
uint32_t serial;
|
||||
if (is_touch) {
|
||||
serial = wl_display_get_serial(desktop->server->wl_display);
|
||||
} else {
|
||||
serial =
|
||||
wlr_seat_pointer_notify_button(seat->seat, time, button, state);
|
||||
}
|
||||
|
||||
int i;
|
||||
switch (state) {
|
||||
case WLR_BUTTON_RELEASED:
|
||||
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
|
||||
roots_cursor_update_position(cursor, time);
|
||||
if (!is_touch) {
|
||||
roots_cursor_update_position(cursor, time);
|
||||
}
|
||||
break;
|
||||
case WLR_BUTTON_PRESSED:
|
||||
i = cursor->input_events_idx;
|
||||
|
|
@ -197,7 +208,7 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
|
|||
void roots_cursor_handle_button(struct roots_cursor *cursor,
|
||||
struct wlr_event_pointer_button *event) {
|
||||
roots_cursor_press_button(cursor, event->device, event->time_msec,
|
||||
event->button, event->state);
|
||||
event->button, event->state, cursor->cursor->x, cursor->cursor->y);
|
||||
}
|
||||
|
||||
void roots_cursor_handle_axis(struct roots_cursor *cursor,
|
||||
|
|
@ -208,50 +219,86 @@ void roots_cursor_handle_axis(struct roots_cursor *cursor,
|
|||
|
||||
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
||||
struct wlr_event_touch_down *event) {
|
||||
struct roots_touch_point *point =
|
||||
calloc(1, sizeof(struct roots_touch_point));
|
||||
if (!point) {
|
||||
wlr_log(L_ERROR, "could not allocate memory for touch point");
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
struct wlr_surface *surface = NULL;
|
||||
double lx, ly;
|
||||
bool result =
|
||||
wlr_cursor_absolute_to_layout_coords(cursor->cursor,
|
||||
event->device, event->x_mm, event->y_mm, event->width_mm,
|
||||
event->height_mm, &lx, &ly);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
double sx, sy;
|
||||
view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||
|
||||
point->device = event->device->data;
|
||||
point->slot = event->slot;
|
||||
point->x = event->x_mm / event->width_mm;
|
||||
point->y = event->y_mm / event->height_mm;
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, point->x, point->y);
|
||||
roots_cursor_update_position(cursor, event->time_msec);
|
||||
wl_list_insert(&cursor->touch_points, &point->link);
|
||||
roots_cursor_press_button(cursor, event->device,
|
||||
event->time_msec, BTN_LEFT, 1);
|
||||
uint32_t serial = 0;
|
||||
if (surface) {
|
||||
serial = wlr_seat_touch_notify_down(cursor->seat->seat, surface,
|
||||
event->time_msec, event->touch_id, sx, sy);
|
||||
}
|
||||
|
||||
if (serial && wlr_seat_touch_num_points(cursor->seat->seat) == 1) {
|
||||
cursor->seat->touch_id = event->touch_id;
|
||||
cursor->seat->touch_x = lx;
|
||||
cursor->seat->touch_y = ly;
|
||||
roots_cursor_press_button(cursor, event->device, event->time_msec,
|
||||
BTN_LEFT, 1, lx, ly);
|
||||
}
|
||||
}
|
||||
|
||||
void roots_cursor_handle_touch_up(struct roots_cursor *cursor,
|
||||
struct wlr_event_touch_up *event) {
|
||||
struct roots_touch_point *point;
|
||||
wl_list_for_each(point, &cursor->touch_points, link) {
|
||||
if (point->slot == event->slot) {
|
||||
wl_list_remove(&point->link);
|
||||
free(point);
|
||||
break;
|
||||
}
|
||||
struct wlr_touch_point *point =
|
||||
wlr_seat_touch_get_point(cursor->seat->seat, event->touch_id);
|
||||
if (!point) {
|
||||
return;
|
||||
}
|
||||
roots_cursor_press_button(cursor, event->device,
|
||||
event->time_msec, BTN_LEFT, 0);
|
||||
|
||||
if (wlr_seat_touch_num_points(cursor->seat->seat) == 1) {
|
||||
roots_cursor_press_button(cursor, event->device, event->time_msec,
|
||||
BTN_LEFT, 0, cursor->seat->touch_x, cursor->seat->touch_y);
|
||||
}
|
||||
|
||||
wlr_seat_touch_notify_up(cursor->seat->seat, event->time_msec,
|
||||
event->touch_id);
|
||||
}
|
||||
|
||||
void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
|
||||
struct wlr_event_touch_motion *event) {
|
||||
struct roots_touch_point *point;
|
||||
wl_list_for_each(point, &cursor->touch_points, link) {
|
||||
if (point->slot == event->slot) {
|
||||
point->x = event->x_mm / event->width_mm;
|
||||
point->y = event->y_mm / event->height_mm;
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||
point->x, point->y);
|
||||
roots_cursor_update_position(cursor, event->time_msec);
|
||||
break;
|
||||
}
|
||||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
struct wlr_touch_point *point =
|
||||
wlr_seat_touch_get_point(cursor->seat->seat, event->touch_id);
|
||||
if (!point) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_surface *surface = NULL;
|
||||
double lx, ly;
|
||||
bool result =
|
||||
wlr_cursor_absolute_to_layout_coords(cursor->cursor,
|
||||
event->device, event->x_mm, event->y_mm, event->width_mm,
|
||||
event->height_mm, &lx, &ly);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
double sx, sy;
|
||||
view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||
|
||||
if (surface) {
|
||||
wlr_seat_touch_point_focus(cursor->seat->seat, surface,
|
||||
event->time_msec, event->touch_id, sx, sy);
|
||||
wlr_seat_touch_notify_motion(cursor->seat->seat, event->time_msec,
|
||||
event->touch_id, sx, sy);
|
||||
} else {
|
||||
wlr_seat_touch_point_clear_focus(cursor->seat->seat, event->time_msec,
|
||||
event->touch_id);
|
||||
}
|
||||
|
||||
if (event->touch_id == cursor->seat->touch_id) {
|
||||
cursor->seat->touch_x = lx;
|
||||
cursor->seat->touch_y = ly;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,14 +323,16 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
|
|||
void roots_cursor_handle_tool_tip(struct roots_cursor *cursor,
|
||||
struct wlr_event_tablet_tool_tip *event) {
|
||||
roots_cursor_press_button(cursor, event->device,
|
||||
event->time_msec, BTN_LEFT, event->state);
|
||||
event->time_msec, BTN_LEFT, event->state, cursor->cursor->x,
|
||||
cursor->cursor->y);
|
||||
}
|
||||
|
||||
void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
|
||||
struct wlr_seat_pointer_request_set_cursor_event *event) {
|
||||
struct wlr_surface *focused_surface =
|
||||
event->seat_client->seat->pointer_state.focused_surface;
|
||||
bool has_focused = focused_surface != NULL && focused_surface->resource != NULL;
|
||||
bool has_focused =
|
||||
focused_surface != NULL && focused_surface->resource != NULL;
|
||||
struct wl_client *focused_client = NULL;
|
||||
if (has_focused) {
|
||||
focused_client = wl_resource_get_client(focused_surface->resource);
|
||||
|
|
@ -299,65 +348,3 @@ void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
|
|||
event->hotspot_y);
|
||||
cursor->cursor_client = event->seat_client->client;
|
||||
}
|
||||
|
||||
static void handle_drag_icon_commit(struct wl_listener *listener, void *data) {
|
||||
struct roots_drag_icon *drag_icon =
|
||||
wl_container_of(listener, drag_icon, surface_commit);
|
||||
drag_icon->sx += drag_icon->surface->current->sx;
|
||||
drag_icon->sy += drag_icon->surface->current->sy;
|
||||
}
|
||||
|
||||
static void handle_drag_icon_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_drag_icon *drag_icon =
|
||||
wl_container_of(listener, drag_icon, surface_destroy);
|
||||
wl_list_remove(&drag_icon->link);
|
||||
wl_list_remove(&drag_icon->surface_destroy.link);
|
||||
wl_list_remove(&drag_icon->surface_commit.link);
|
||||
free(drag_icon);
|
||||
}
|
||||
|
||||
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
|
||||
struct wlr_seat_pointer_grab *grab) {
|
||||
struct roots_seat *seat = cursor->seat;
|
||||
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
||||
struct wlr_drag *drag = grab->data;
|
||||
if (drag->icon) {
|
||||
struct roots_drag_icon *iter_icon;
|
||||
wl_list_for_each(iter_icon, &seat->drag_icons, link) {
|
||||
if (iter_icon->surface == drag->icon) {
|
||||
// already in the list
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
struct roots_drag_icon *drag_icon =
|
||||
calloc(1, sizeof(struct roots_drag_icon));
|
||||
drag_icon->mapped = true;
|
||||
drag_icon->surface = drag->icon;
|
||||
wl_list_insert(&seat->drag_icons, &drag_icon->link);
|
||||
|
||||
wl_signal_add(&drag->icon->events.destroy,
|
||||
&drag_icon->surface_destroy);
|
||||
drag_icon->surface_destroy.notify = handle_drag_icon_destroy;
|
||||
|
||||
wl_signal_add(&drag->icon->events.commit,
|
||||
&drag_icon->surface_commit);
|
||||
drag_icon->surface_commit.notify = handle_drag_icon_commit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
||||
struct wlr_seat_pointer_grab *grab) {
|
||||
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
||||
struct wlr_drag *drag = grab->data;
|
||||
struct roots_drag_icon *icon;
|
||||
wl_list_for_each(icon, &cursor->seat->drag_icons, link) {
|
||||
if (icon->surface == drag->icon) {
|
||||
icon->mapped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
roots_cursor_update_position(cursor, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,10 +343,18 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
|||
desktop->server = server;
|
||||
desktop->config = config;
|
||||
|
||||
desktop->xcursor_manager = wlr_xcursor_manager_create(NULL,
|
||||
const char *cursor_theme = NULL;
|
||||
struct roots_cursor_config *cc =
|
||||
roots_config_get_cursor(config, ROOTS_CONFIG_DEFAULT_SEAT_NAME);
|
||||
if (cc != NULL) {
|
||||
cursor_theme = cc->theme;
|
||||
}
|
||||
|
||||
desktop->xcursor_manager = wlr_xcursor_manager_create(cursor_theme,
|
||||
ROOTS_XCURSOR_SIZE);
|
||||
if (desktop->xcursor_manager == NULL) {
|
||||
wlr_log(L_ERROR, "Cannot create XCursor manager");
|
||||
wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s",
|
||||
cursor_theme);
|
||||
wlr_list_free(desktop->views);
|
||||
free(desktop);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
|
|||
struct wlr_input_device *device = data;
|
||||
struct roots_input *input = wl_container_of(listener, input, input_add);
|
||||
|
||||
char *seat_name = "seat0";
|
||||
char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
|
||||
struct roots_device_config *dc =
|
||||
roots_config_get_device(input->config, device);
|
||||
if (dc) {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ int main(int argc, char **argv) {
|
|||
ready(NULL, NULL);
|
||||
#else
|
||||
if (server.desktop->xwayland != NULL) {
|
||||
struct wl_listener xwayland_ready = { .notify = ready };
|
||||
wl_signal_add(&server.desktop->xwayland->events.ready, &xwayland_ready);
|
||||
wl_signal_add(&server.desktop->xwayland->events.ready,
|
||||
&server.desktop->xwayland_ready);
|
||||
server.desktop->xwayland_ready.notify = ready;
|
||||
} else {
|
||||
ready(NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,18 +191,29 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
render_view(view, desktop, wlr_output, &now);
|
||||
}
|
||||
|
||||
struct roots_drag_icon *drag_icon = NULL;
|
||||
struct wlr_drag_icon *drag_icon = NULL;
|
||||
struct roots_seat *seat = NULL;
|
||||
wl_list_for_each(seat, &server->input->seats, link) {
|
||||
wl_list_for_each(drag_icon, &seat->drag_icons, link) {
|
||||
wl_list_for_each(drag_icon, &seat->seat->drag_icons, link) {
|
||||
if (!drag_icon->mapped) {
|
||||
continue;
|
||||
}
|
||||
struct wlr_surface *icon = drag_icon->surface;
|
||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||
double icon_x = cursor->x + drag_icon->sx;
|
||||
double icon_y = cursor->y + drag_icon->sy;
|
||||
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
||||
double icon_x = 0, icon_y = 0;
|
||||
if (drag_icon->is_pointer) {
|
||||
icon_x = cursor->x + drag_icon->sx;
|
||||
icon_y = cursor->y + drag_icon->sy;
|
||||
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
||||
} else {
|
||||
struct wlr_touch_point *point =
|
||||
wlr_seat_touch_get_point(seat->seat, drag_icon->touch_id);
|
||||
if (point) {
|
||||
icon_x = seat->touch_x + drag_icon->sx;
|
||||
icon_y = seat->touch_y + drag_icon->sy;
|
||||
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ rotate = 90
|
|||
map-to-output = VGA-1
|
||||
# Restrict cursor movements to concrete rectangle
|
||||
geometry = 2500x800
|
||||
# Load a custom XCursor theme
|
||||
theme = default
|
||||
|
||||
# Single device configuration. String after semicolon must match device's name.
|
||||
[device:PixArt Dell MS116 USB Optical Mouse]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
|||
roots_cursor_handle_motion(cursor, event);
|
||||
}
|
||||
|
||||
static void handle_cursor_motion_absolute(struct wl_listener *listener, void *data) {
|
||||
static void handle_cursor_motion_absolute(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, motion_absolute);
|
||||
struct wlr_event_pointer_motion_absolute *event = data;
|
||||
|
|
@ -95,23 +96,8 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
|||
roots_cursor_handle_request_set_cursor(cursor, event);
|
||||
}
|
||||
|
||||
static void handle_pointer_grab_begin(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, pointer_grab_begin);
|
||||
struct wlr_seat_pointer_grab *grab = data;
|
||||
roots_cursor_handle_pointer_grab_begin(cursor, grab);
|
||||
}
|
||||
|
||||
static void handle_pointer_grab_end(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct roots_cursor *cursor =
|
||||
wl_container_of(listener, cursor, pointer_grab_end);
|
||||
struct wlr_seat_pointer_grab *grab = data;
|
||||
roots_cursor_handle_pointer_grab_end(cursor, grab);
|
||||
}
|
||||
|
||||
static void seat_reset_device_mappings(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
static void seat_reset_device_mappings(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||
struct roots_config *config = seat->input->config;
|
||||
|
||||
|
|
@ -157,20 +143,29 @@ void roots_seat_configure_cursor(struct roots_seat *seat) {
|
|||
}
|
||||
|
||||
// configure device to output mappings
|
||||
const char *mapped_output = config->cursor.mapped_output;
|
||||
const char *mapped_output = NULL;
|
||||
struct roots_cursor_config *cc =
|
||||
roots_config_get_cursor(config, seat->seat->name);
|
||||
if (cc != NULL) {
|
||||
mapped_output = cc->mapped_output;
|
||||
}
|
||||
wl_list_for_each(output, &desktop->outputs, link) {
|
||||
if (mapped_output && strcmp(mapped_output, output->wlr_output->name) == 0) {
|
||||
if (mapped_output &&
|
||||
strcmp(mapped_output, output->wlr_output->name) == 0) {
|
||||
wlr_cursor_map_to_output(cursor, output->wlr_output);
|
||||
}
|
||||
|
||||
wl_list_for_each(pointer, &seat->pointers, link) {
|
||||
seat_set_device_output_mappings(seat, pointer->device, output->wlr_output);
|
||||
seat_set_device_output_mappings(seat, pointer->device,
|
||||
output->wlr_output);
|
||||
}
|
||||
wl_list_for_each(tablet_tool, &seat->tablet_tools, link) {
|
||||
seat_set_device_output_mappings(seat, tablet_tool->device, output->wlr_output);
|
||||
seat_set_device_output_mappings(seat, tablet_tool->device,
|
||||
output->wlr_output);
|
||||
}
|
||||
wl_list_for_each(touch, &seat->touch, link) {
|
||||
seat_set_device_output_mappings(seat, touch->device, output->wlr_output);
|
||||
seat_set_device_output_mappings(seat, touch->device,
|
||||
output->wlr_output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -185,11 +180,6 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
|||
struct roots_desktop *desktop = seat->input->server->desktop;
|
||||
wlr_cursor_attach_output_layout(wlr_cursor, desktop->layout);
|
||||
|
||||
// TODO: be able to configure per-seat cursor themes
|
||||
seat->cursor->xcursor_manager = desktop->xcursor_manager;
|
||||
|
||||
wl_list_init(&seat->cursor->touch_points);
|
||||
|
||||
roots_seat_configure_cursor(seat);
|
||||
roots_seat_configure_xcursor(seat);
|
||||
|
||||
|
|
@ -213,10 +203,12 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
|||
wl_signal_add(&wlr_cursor->events.touch_up, &seat->cursor->touch_up);
|
||||
seat->cursor->touch_up.notify = handle_touch_up;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.touch_motion, &seat->cursor->touch_motion);
|
||||
wl_signal_add(&wlr_cursor->events.touch_motion,
|
||||
&seat->cursor->touch_motion);
|
||||
seat->cursor->touch_motion.notify = handle_touch_motion;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_axis, &seat->cursor->tool_axis);
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_axis,
|
||||
&seat->cursor->tool_axis);
|
||||
seat->cursor->tool_axis.notify = handle_tool_axis;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &seat->cursor->tool_tip);
|
||||
|
|
@ -225,14 +217,6 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
|||
wl_signal_add(&seat->seat->events.request_set_cursor,
|
||||
&seat->cursor->request_set_cursor);
|
||||
seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
|
||||
|
||||
wl_signal_add(&seat->seat->events.pointer_grab_begin,
|
||||
&seat->cursor->pointer_grab_begin);
|
||||
seat->cursor->pointer_grab_begin.notify = handle_pointer_grab_begin;
|
||||
|
||||
wl_signal_add(&seat->seat->events.pointer_grab_end,
|
||||
&seat->cursor->pointer_grab_end);
|
||||
seat->cursor->pointer_grab_end.notify = handle_pointer_grab_end;
|
||||
}
|
||||
|
||||
struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
||||
|
|
@ -245,7 +229,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
|||
wl_list_init(&seat->pointers);
|
||||
wl_list_init(&seat->touch);
|
||||
wl_list_init(&seat->tablet_tools);
|
||||
wl_list_init(&seat->drag_icons);
|
||||
|
||||
seat->input = input;
|
||||
|
||||
|
|
@ -276,9 +259,11 @@ void roots_seat_destroy(struct roots_seat *seat) {
|
|||
// TODO
|
||||
}
|
||||
|
||||
static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
static void seat_add_keyboard(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
|
||||
struct roots_keyboard *keyboard = roots_keyboard_create(device, seat->input);
|
||||
struct roots_keyboard *keyboard =
|
||||
roots_keyboard_create(device, seat->input);
|
||||
if (keyboard == NULL) {
|
||||
wlr_log(L_ERROR, "could not allocate keyboard for seat");
|
||||
return;
|
||||
|
|
@ -299,7 +284,8 @@ static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *
|
|||
wlr_seat_set_keyboard(seat->seat, device);
|
||||
}
|
||||
|
||||
static void seat_add_pointer(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
static void seat_add_pointer(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1);
|
||||
if (!pointer) {
|
||||
wlr_log(L_ERROR, "could not allocate pointer for seat");
|
||||
|
|
@ -314,7 +300,8 @@ static void seat_add_pointer(struct roots_seat *seat, struct wlr_input_device *d
|
|||
roots_seat_configure_cursor(seat);
|
||||
}
|
||||
|
||||
static void seat_add_touch(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
static void seat_add_touch(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_touch *touch = calloc(sizeof(struct roots_touch), 1);
|
||||
if (!touch) {
|
||||
wlr_log(L_ERROR, "could not allocate touch for seat");
|
||||
|
|
@ -329,12 +316,15 @@ static void seat_add_touch(struct roots_seat *seat, struct wlr_input_device *dev
|
|||
roots_seat_configure_cursor(seat);
|
||||
}
|
||||
|
||||
static void seat_add_tablet_pad(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
static void seat_add_tablet_pad(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void seat_add_tablet_tool(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||
struct roots_tablet_tool *tablet_tool = calloc(sizeof(struct roots_tablet_tool), 1);
|
||||
static void seat_add_tablet_tool(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_tablet_tool *tablet_tool =
|
||||
calloc(sizeof(struct roots_tablet_tool), 1);
|
||||
if (!tablet_tool) {
|
||||
wlr_log(L_ERROR, "could not allocate tablet_tool for seat");
|
||||
return;
|
||||
|
|
@ -446,6 +436,21 @@ void roots_seat_remove_device(struct roots_seat *seat,
|
|||
}
|
||||
|
||||
void roots_seat_configure_xcursor(struct roots_seat *seat) {
|
||||
const char *cursor_theme = NULL;
|
||||
struct roots_cursor_config *cc =
|
||||
roots_config_get_cursor(seat->input->config, seat->seat->name);
|
||||
if (cc != NULL) {
|
||||
cursor_theme = cc->theme;
|
||||
}
|
||||
|
||||
seat->cursor->xcursor_manager =
|
||||
wlr_xcursor_manager_create(cursor_theme, ROOTS_XCURSOR_SIZE);
|
||||
if (seat->cursor->xcursor_manager == NULL) {
|
||||
wlr_log(L_ERROR, "Cannot create XCursor manager for theme %s",
|
||||
cursor_theme);
|
||||
return;
|
||||
}
|
||||
|
||||
struct roots_output *output;
|
||||
wl_list_for_each(output, &seat->input->server->desktop->outputs, link) {
|
||||
if (wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue