mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-22 13:34:18 +02:00
Add option for disabling cursor
This commit is contained in:
parent
8d78a17320
commit
7da953ca20
5 changed files with 53 additions and 9 deletions
21
keybinding.c
21
keybinding.c
|
|
@ -1523,6 +1523,18 @@ keybinding_configure_message(struct cg_server *server,
|
|||
ipc_send_event(server, "{\"event_name\":\"configure_message\"}");
|
||||
}
|
||||
|
||||
void
|
||||
set_cursor(bool enabled,struct cg_seat* seat) {
|
||||
if(enabled==true) {
|
||||
seat->enable_cursor=true;
|
||||
wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager,
|
||||
DEFAULT_XCURSOR, seat->cursor);
|
||||
} else {
|
||||
seat->enable_cursor=false;
|
||||
wlr_cursor_set_image(seat->cursor, NULL, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Hint: see keybinding.h for details on "data" */
|
||||
int
|
||||
run_action(enum keybinding_action action, struct cg_server *server,
|
||||
|
|
@ -1533,6 +1545,9 @@ run_action(enum keybinding_action action, struct cg_server *server,
|
|||
break;
|
||||
case KEYBINDING_CHANGE_TTY:
|
||||
return keybinding_switch_vt(server->backend, data.u);
|
||||
case KEYBINDING_CURSOR:
|
||||
set_cursor(data.i,server->seat);
|
||||
break;
|
||||
case KEYBINDING_LAYOUT_FULLSCREEN:
|
||||
keybinding_workspace_fullscreen(server);
|
||||
break;
|
||||
|
|
@ -1571,8 +1586,10 @@ run_action(enum keybinding_action action, struct cg_server *server,
|
|||
case KEYBINDING_SWITCH_MODE:
|
||||
if(data.u!=server->seat->default_mode) {
|
||||
wlr_seat_pointer_notify_clear_focus(server->seat->seat);
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager,
|
||||
"dot_box_mask", server->seat->cursor);
|
||||
if(server->seat->enable_cursor==true) {
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager,
|
||||
"dot_box_mask", server->seat->cursor);
|
||||
}
|
||||
}
|
||||
server->seat->mode = data.u;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ enum keybinding_action {
|
|||
KEYBINDING_SHOW_TIME,
|
||||
KEYBINDING_SHOW_INFO,
|
||||
KEYBINDING_DISPLAY_MESSAGE,
|
||||
KEYBINDING_CURSOR,
|
||||
|
||||
KEYBINDING_SWAP_LEFT,
|
||||
KEYBINDING_SWAP_RIGHT,
|
||||
|
|
|
|||
19
parse.c
19
parse.c
|
|
@ -478,6 +478,19 @@ parse_escape(char **saveptr, char **errstr) {
|
|||
return keybinding;
|
||||
}
|
||||
|
||||
int
|
||||
parse_cursor(char **saveptr, char **errstr) {
|
||||
if(strcmp(*saveptr,"enable")==0) {
|
||||
return 1;
|
||||
} else if(strcmp(*saveptr,"disable")==0) {
|
||||
return 0;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR,
|
||||
"Invalid option \"%s\" for \"cursor\". Expected \"enable\" or \"disable\".", *saveptr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
parse_definemode(char **saveptr, char **errstr) {
|
||||
char *mode = strtok_r(NULL, " ", saveptr);
|
||||
|
|
@ -979,6 +992,12 @@ parse_command(struct cg_server *server, struct keybinding *keybinding,
|
|||
if(keybinding->data.kb == NULL) {
|
||||
return -1;
|
||||
}
|
||||
} else if(strcmp(action, "cursor") == 0) {
|
||||
keybinding->action = KEYBINDING_CURSOR;
|
||||
keybinding->data.i = parse_cursor(&saveptr, errstr);
|
||||
if(keybinding->data.i < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if(strcmp(action, "definemode") == 0) {
|
||||
keybinding->action = KEYBINDING_DEFINEMODE;
|
||||
keybinding->data.c = parse_definemode(&saveptr, errstr);
|
||||
|
|
|
|||
20
seat.c
20
seat.c
|
|
@ -63,7 +63,7 @@ update_capabilities(const struct cg_seat *seat) {
|
|||
wlr_seat_set_capabilities(seat->seat, caps);
|
||||
|
||||
/* Hide cursor if the seat doesn't have pointer capability. */
|
||||
if((caps & WL_SEAT_CAPABILITY_POINTER) == 0) {
|
||||
if(((caps & WL_SEAT_CAPABILITY_POINTER) == 0) || seat->enable_cursor == false) {
|
||||
wlr_cursor_set_image(seat->cursor, NULL, 0, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager,
|
||||
|
|
@ -206,13 +206,15 @@ handle_command_key_bindings(struct cg_server *server, xkb_keysym_t sym,
|
|||
|
||||
struct wlr_scene_node *node = wlr_scene_node_at(
|
||||
&server->scene->node, server->seat->cursor->x, server->seat->cursor->y, &sx, &sy);
|
||||
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
|
||||
surface = wlr_scene_surface_from_node(node)->surface;
|
||||
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
|
||||
} else {
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager,
|
||||
"left_ptr", server->seat->cursor);
|
||||
if(server->seat->enable_cursor) {
|
||||
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
|
||||
surface = wlr_scene_surface_from_node(node)->surface;
|
||||
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
|
||||
} else {
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager,
|
||||
"left_ptr", server->seat->cursor);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -542,6 +544,9 @@ handle_request_set_selection(struct wl_listener *listener, void *data) {
|
|||
static void
|
||||
handle_request_set_cursor(struct wl_listener *listener, void *data) {
|
||||
struct cg_seat *seat = wl_container_of(listener, seat, request_set_cursor);
|
||||
if(seat->enable_cursor==false) {
|
||||
return;
|
||||
}
|
||||
struct wlr_seat_pointer_request_set_cursor_event *event = data;
|
||||
struct wlr_surface *focused_surface =
|
||||
event->seat_client->seat->pointer_state.focused_surface;
|
||||
|
|
@ -894,6 +899,7 @@ seat_create(struct cg_server *server, struct wlr_backend *backend) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
seat->enable_cursor=true;
|
||||
seat->seat = wlr_seat_create(server->wl_display, "seat0");
|
||||
if(!seat->seat) {
|
||||
wlr_log(WLR_ERROR, "Cannot allocate seat0");
|
||||
|
|
|
|||
1
seat.h
1
seat.h
|
|
@ -28,6 +28,7 @@ struct cg_seat {
|
|||
uint16_t num_pointers;
|
||||
uint16_t num_touch;
|
||||
|
||||
bool enable_cursor;
|
||||
struct wlr_cursor *cursor;
|
||||
struct cg_tile *cursor_tile;
|
||||
struct wlr_xcursor_manager *xcursor_manager;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue