mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-26 00:52:21 +00:00
Remove calls to assert to check runtime errors in rootston
This commit is contained in:
parent
c8570d0e42
commit
f2c4b80620
@ -202,11 +202,18 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
|||||||
|
|
||||||
struct roots_desktop *desktop_create(struct roots_server *server,
|
struct roots_desktop *desktop_create(struct roots_server *server,
|
||||||
struct roots_config *config) {
|
struct roots_config *config) {
|
||||||
struct roots_desktop *desktop = calloc(1, sizeof(struct roots_desktop));
|
|
||||||
assert(desktop);
|
|
||||||
wlr_log(L_DEBUG, "Initializing roots desktop");
|
wlr_log(L_DEBUG, "Initializing roots desktop");
|
||||||
|
|
||||||
assert(desktop->views = list_create());
|
struct roots_desktop *desktop = calloc(1, sizeof(struct roots_desktop));
|
||||||
|
if (desktop == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
desktop->views = list_create();
|
||||||
|
if (desktop->views == NULL) {
|
||||||
|
free(desktop);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
wl_list_init(&desktop->outputs);
|
wl_list_init(&desktop->outputs);
|
||||||
|
|
||||||
desktop->output_add.notify = output_add_notify;
|
desktop->output_add.notify = output_add_notify;
|
||||||
|
@ -74,15 +74,34 @@ struct roots_input *input_create(struct roots_server *server,
|
|||||||
assert(server->desktop);
|
assert(server->desktop);
|
||||||
|
|
||||||
struct roots_input *input = calloc(1, sizeof(struct roots_input));
|
struct roots_input *input = calloc(1, sizeof(struct roots_input));
|
||||||
assert(input);
|
if (input == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
input->config = config;
|
input->config = config;
|
||||||
input->server = server;
|
input->server = server;
|
||||||
|
|
||||||
assert(input->theme = wlr_xcursor_theme_load("default", 16));
|
input->theme = wlr_xcursor_theme_load("default", 16);
|
||||||
assert(input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr"));
|
if (input->theme == NULL) {
|
||||||
|
wlr_log(L_ERROR, "Cannot load xcursor theme");
|
||||||
|
free(input);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr");
|
||||||
|
if (input->xcursor == NULL) {
|
||||||
|
wlr_log(L_ERROR, "Cannot load xcursor from theme");
|
||||||
|
wlr_xcursor_theme_destroy(input->theme);
|
||||||
|
free(input);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
assert(input->wl_seat = wlr_seat_create(server->wl_display, "seat0"));
|
input->wl_seat = wlr_seat_create(server->wl_display, "seat0");
|
||||||
|
if (input->wl_seat == NULL) {
|
||||||
|
wlr_log(L_ERROR, "Cannot create seat");
|
||||||
|
wlr_xcursor_theme_destroy(input->theme);
|
||||||
|
free(input);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD
|
wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD
|
||||||
| WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_TOUCH);
|
| WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_TOUCH);
|
||||||
|
|
||||||
|
@ -127,6 +127,9 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
|
|||||||
|
|
||||||
void keyboard_add(struct wlr_input_device *device, struct roots_input *input) {
|
void keyboard_add(struct wlr_input_device *device, struct roots_input *input) {
|
||||||
struct roots_keyboard *keyboard = calloc(sizeof(struct roots_keyboard), 1);
|
struct roots_keyboard *keyboard = calloc(sizeof(struct roots_keyboard), 1);
|
||||||
|
if (keyboard == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
device->data = keyboard;
|
device->data = keyboard;
|
||||||
keyboard->device = device;
|
keyboard->device = device;
|
||||||
keyboard->input = input;
|
keyboard->input = input;
|
||||||
@ -141,11 +144,15 @@ void keyboard_add(struct wlr_input_device *device, struct roots_input *input) {
|
|||||||
rules.layout = getenv("XKB_DEFAULT_LAYOUT");
|
rules.layout = getenv("XKB_DEFAULT_LAYOUT");
|
||||||
rules.variant = getenv("XKB_DEFAULT_VARIANT");
|
rules.variant = getenv("XKB_DEFAULT_VARIANT");
|
||||||
rules.options = getenv("XKB_DEFAULT_OPTIONS");
|
rules.options = getenv("XKB_DEFAULT_OPTIONS");
|
||||||
struct xkb_context *context;
|
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
assert(context = xkb_context_new(XKB_CONTEXT_NO_FLAGS));
|
if (context == NULL) {
|
||||||
|
wlr_log(L_ERROR, "Cannot create XKB context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
|
||||||
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
&rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
|
|
||||||
wlr_seat_attach_keyboard(input->wl_seat, device);
|
wlr_seat_attach_keyboard(input->wl_seat, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user