mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-09 15:19:11 +02:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
8ab41ce342
7 changed files with 109 additions and 16 deletions
10
cagebreak.c
10
cagebreak.c
|
|
@ -130,7 +130,7 @@ usage(FILE *file, const char *const cage) {
|
|||
"Usage: %s [OPTIONS]\n"
|
||||
"\n"
|
||||
" -c <path>\t Load configuration file from <path>\n"
|
||||
" -d\t\t Disable socket\n"
|
||||
" -e\t\t Enable socket\n"
|
||||
" -h\t\t Display this help message\n"
|
||||
" -v\t\t Show the version number and exit\n"
|
||||
" -s\t\t Show information about the current setup and exit\n",
|
||||
|
|
@ -140,8 +140,8 @@ usage(FILE *file, const char *const cage) {
|
|||
static bool
|
||||
parse_args(struct cg_server *server, int argc, char *argv[], char **config_path) {
|
||||
int c;
|
||||
server->enable_socket=true;
|
||||
while((c = getopt(argc, argv, "c:hvsd")) != -1) {
|
||||
server->enable_socket=false;
|
||||
while((c = getopt(argc, argv, "c:hvse")) != -1) {
|
||||
switch(c) {
|
||||
case 'h':
|
||||
usage(stdout, argv[0]);
|
||||
|
|
@ -155,8 +155,8 @@ parse_args(struct cg_server *server, int argc, char *argv[], char **config_path)
|
|||
case 'c':
|
||||
*config_path=strdup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
server->enable_socket=false;
|
||||
case 'e':
|
||||
server->enable_socket=true;
|
||||
break;
|
||||
default:
|
||||
usage(stderr, argv[0]);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ struct cg_input_device {
|
|||
char *identifier;
|
||||
struct cg_server *server;
|
||||
struct wlr_input_device *wlr_device;
|
||||
struct wl_list link;
|
||||
struct wl_list link;//input_manager::devices
|
||||
struct wl_listener device_destroy;
|
||||
bool is_virtual;
|
||||
|
||||
|
|
|
|||
72
keybinding.c
72
keybinding.c
|
|
@ -1066,12 +1066,56 @@ print_keyboard_groups(struct cg_server *server) {
|
|||
return dyn_str_to_str(&outp_str);
|
||||
}
|
||||
|
||||
char *
|
||||
print_input_device(struct cg_input_device *dev) {
|
||||
struct dyn_str outp_str;
|
||||
outp_str.len = 0;
|
||||
outp_str.cur_pos = 0;
|
||||
uint32_t nmemb = 4;
|
||||
outp_str.str_arr = calloc(nmemb, sizeof(char *));
|
||||
if(dev->identifier!=NULL) {
|
||||
print_str(&outp_str, "\"%s\": {\n", dev->identifier);
|
||||
} else {
|
||||
print_str(&outp_str, "\"NULL\": {\n");
|
||||
}
|
||||
print_str(&outp_str, "\"is_virtual\": %d,\n", dev->is_virtual);
|
||||
print_str(&outp_str, "\"type\": \"%s\",\n", dev->wlr_device->type==WLR_INPUT_DEVICE_POINTER?"pointer":dev->wlr_device->type==WLR_INPUT_DEVICE_SWITCH?"switch":dev->wlr_device->type==WLR_INPUT_DEVICE_TABLET_PAD?"tablet pad":dev->wlr_device->type==WLR_INPUT_DEVICE_TABLET_TOOL?"tablet tool":dev->wlr_device->type==WLR_INPUT_DEVICE_TOUCH?"touch":dev->wlr_device->type==WLR_INPUT_DEVICE_KEYBOARD?"keyboard":"unknown");
|
||||
print_str(&outp_str, "}");
|
||||
return dyn_str_to_str(&outp_str);
|
||||
}
|
||||
|
||||
char *
|
||||
print_input_devices(struct cg_server *server) {
|
||||
uint32_t ninps = wl_list_length(&server->input->devices);
|
||||
struct dyn_str outp_str;
|
||||
outp_str.len = 0;
|
||||
outp_str.cur_pos = 0;
|
||||
outp_str.str_arr = calloc((2 * ninps - 1) + 2, sizeof(char *));
|
||||
print_str(&outp_str, "\"input_devices\": {");
|
||||
struct cg_input_device *it;
|
||||
uint32_t count = 0;
|
||||
wl_list_for_each(it, &server->input->devices, link) {
|
||||
if(count != 0) {
|
||||
print_str(&outp_str, ",");
|
||||
}
|
||||
++count;
|
||||
char *outp = print_input_device(it);
|
||||
if(outp == NULL) {
|
||||
continue;
|
||||
}
|
||||
print_str(&outp_str, "%s", outp);
|
||||
free(outp);
|
||||
}
|
||||
print_str(&outp_str, "}\n");
|
||||
return dyn_str_to_str(&outp_str);
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_dump(struct cg_server *server) {
|
||||
struct dyn_str str;
|
||||
str.len = 0;
|
||||
str.cur_pos = 0;
|
||||
uint32_t nmemb = 11;
|
||||
uint32_t nmemb = 12;
|
||||
str.str_arr = calloc(nmemb, sizeof(char *));
|
||||
|
||||
print_str(&str, "{\"event_name\":\"dump\",");
|
||||
|
|
@ -1093,6 +1137,11 @@ keybinding_dump(struct cg_server *server) {
|
|||
print_str(&str, "%s,", keyboards_str);
|
||||
free(keyboards_str);
|
||||
}
|
||||
char *input_dev_str = print_input_devices(server);
|
||||
if(input_dev_str!=NULL) {
|
||||
print_str(&str, "%s,", input_dev_str);
|
||||
free(input_dev_str);
|
||||
}
|
||||
print_str(&str, "\"cursor_coords\":{\"x\":%f,\"y\":%f}\n",
|
||||
server->seat->cursor->x, server->seat->cursor->y);
|
||||
print_str(&str, "}");
|
||||
|
|
@ -1474,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,
|
||||
|
|
@ -1484,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;
|
||||
|
|
@ -1522,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