Fix indentation in various files

master
emersion 6 years ago
parent f3ef1f907c
commit a4eb90315e
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -152,7 +152,7 @@ int main(int argc, char *argv[]) {
};
bool create_t1 = (simulate_activity_timeout != 0) &&
(simulate_activity_timeout < close_timeout);
(simulate_activity_timeout < close_timeout);
if (create_t1) {
if (pthread_create(&t1, NULL, &simulate_activity, (void *)&arg) != 0) {

@ -4,15 +4,15 @@
#include "rootston/input.h"
struct roots_switch {
struct roots_seat *seat;
struct wlr_input_device *device;
struct wl_listener device_destroy;
struct roots_seat *seat;
struct wlr_input_device *device;
struct wl_listener device_destroy;
struct wl_listener toggle;
struct wl_list link;
struct wl_listener toggle;
struct wl_list link;
};
void roots_switch_handle_toggle(struct roots_switch *lid_switch,
struct wlr_event_switch_toggle *event);
struct wlr_event_switch_toggle *event);
#endif // ROOTSTON_SWITCH_H
#endif

@ -7,101 +7,101 @@
static bool outputs_enabled = true;
static const char *exec_prefix = "exec ";
static const char exec_prefix[] = "exec ";
static void double_fork_shell_cmd(const char *shell_cmd) {
pid_t pid = fork();
if (pid < 0) {
wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
return;
}
pid_t pid = fork();
if (pid < 0) {
wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
return;
}
if (pid == 0) {
pid = fork();
if (pid == 0) {
execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
_exit(EXIT_FAILURE);
} else {
_exit(pid == -1);
}
}
if (pid == 0) {
pid = fork();
if (pid == 0) {
execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
_exit(EXIT_FAILURE);
} else {
_exit(pid == -1);
}
}
int status;
while (waitpid(pid, &status, 0) < 0) {
if (errno == EINTR) {
continue;
}
wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
return;
}
int status;
while (waitpid(pid, &status, 0) < 0) {
if (errno == EINTR) {
continue;
}
wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
return;
}
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
return;
}
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
return;
}
wlr_log(WLR_ERROR, "first child failed to fork command");
wlr_log(WLR_ERROR, "first child failed to fork command");
}
void execute_binding_command(struct roots_seat *seat,
struct roots_input *input, const char *command) {
if (strcmp(command, "exit") == 0) {
wl_display_terminate(input->server->wl_display);
} else if (strcmp(command, "close") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_close(focus);
}
} else if (strcmp(command, "fullscreen") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
bool is_fullscreen = focus->fullscreen_output != NULL;
view_set_fullscreen(focus, !is_fullscreen, NULL);
}
} else if (strcmp(command, "next_window") == 0) {
roots_seat_cycle_focus(seat);
} else if (strcmp(command, "alpha") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_cycle_alpha(focus);
}
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix);
double_fork_shell_cmd(shell_cmd);
} else if (strcmp(command, "maximize") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_maximize(focus, !focus->maximized);
}
} else if (strcmp(command, "nop") == 0) {
wlr_log(WLR_DEBUG, "nop command");
} else if (strcmp(command, "toggle_outputs") == 0) {
outputs_enabled = !outputs_enabled;
struct roots_output *output;
wl_list_for_each(output, &input->server->desktop->outputs, link) {
wlr_output_enable(output->wlr_output, outputs_enabled);
}
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
struct roots_xdg_toplevel_decoration *decoration =
focus->roots_xdg_surface->xdg_toplevel_decoration;
if (decoration != NULL) {
enum wlr_xdg_toplevel_decoration_v1_mode mode =
decoration->wlr_decoration->current_mode;
mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
wlr_xdg_toplevel_decoration_v1_set_mode(
decoration->wlr_decoration, mode);
}
}
} else if (strcmp(command, "break_pointer_constraint") == 0) {
struct wl_list *list = &input->seats;
struct roots_seat *seat;
wl_list_for_each(seat, list, link) {
roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
}
} else {
wlr_log(WLR_ERROR, "unknown binding command: %s", command);
}
struct roots_input *input, const char *command) {
if (strcmp(command, "exit") == 0) {
wl_display_terminate(input->server->wl_display);
} else if (strcmp(command, "close") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_close(focus);
}
} else if (strcmp(command, "fullscreen") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
bool is_fullscreen = focus->fullscreen_output != NULL;
view_set_fullscreen(focus, !is_fullscreen, NULL);
}
} else if (strcmp(command, "next_window") == 0) {
roots_seat_cycle_focus(seat);
} else if (strcmp(command, "alpha") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_cycle_alpha(focus);
}
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
const char *shell_cmd = command + strlen(exec_prefix);
double_fork_shell_cmd(shell_cmd);
} else if (strcmp(command, "maximize") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL) {
view_maximize(focus, !focus->maximized);
}
} else if (strcmp(command, "nop") == 0) {
wlr_log(WLR_DEBUG, "nop command");
} else if (strcmp(command, "toggle_outputs") == 0) {
outputs_enabled = !outputs_enabled;
struct roots_output *output;
wl_list_for_each(output, &input->server->desktop->outputs, link) {
wlr_output_enable(output->wlr_output, outputs_enabled);
}
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
struct roots_view *focus = roots_seat_get_focus(seat);
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
struct roots_xdg_toplevel_decoration *decoration =
focus->roots_xdg_surface->xdg_toplevel_decoration;
if (decoration != NULL) {
enum wlr_xdg_toplevel_decoration_v1_mode mode =
decoration->wlr_decoration->current_mode;
mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
wlr_xdg_toplevel_decoration_v1_set_mode(
decoration->wlr_decoration, mode);
}
}
} else if (strcmp(command, "break_pointer_constraint") == 0) {
struct wl_list *list = &input->seats;
struct roots_seat *seat;
wl_list_for_each(seat, list, link) {
roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
}
} else {
wlr_log(WLR_ERROR, "unknown binding command: %s", command);
}
}

@ -1,26 +1,22 @@
#include <stdlib.h>
#include <wlr/util/log.h>
#include "rootston/bindings.h"
#include "rootston/config.h"
#include "rootston/input.h"
#include "rootston/seat.h"
#include "rootston/switch.h"
void roots_switch_handle_toggle(struct roots_switch *lid_switch,
struct wlr_event_switch_toggle *event) {
struct wl_list *bound_switches = &lid_switch->seat->input->server->config->switches;
struct roots_switch_config *sc;
wl_list_for_each(sc, bound_switches, link) {
if ((sc->name != NULL && strcmp(event->device->name, sc->name) != 0) &&
(sc->name == NULL && event->switch_type != sc->switch_type)) {
continue;
}
if (sc->switch_state != WLR_SWITCH_STATE_TOGGLE &&
event->switch_state != sc->switch_state) {
continue;
}
execute_binding_command(lid_switch->seat, lid_switch->seat->input, sc->command);
}
struct wlr_event_switch_toggle *event) {
struct wl_list *bound_switches =
&lid_switch->seat->input->server->config->switches;
struct roots_switch_config *sc;
wl_list_for_each(sc, bound_switches, link) {
if ((sc->name != NULL && strcmp(event->device->name, sc->name) != 0) &&
(sc->name == NULL && event->switch_type != sc->switch_type)) {
continue;
}
if (sc->switch_state != WLR_SWITCH_STATE_TOGGLE &&
event->switch_state != sc->switch_state) {
continue;
}
execute_binding_command(lid_switch->seat,
lid_switch->seat->input, sc->command);
}
}

@ -232,7 +232,7 @@ void wlr_foreign_toplevel_handle_v1_output_enter(
}
toplevel_output =
calloc(1, sizeof(struct wlr_foreign_toplevel_handle_v1_output));
calloc(1, sizeof(struct wlr_foreign_toplevel_handle_v1_output));
if (!toplevel_output) {
wlr_log(WLR_ERROR, "failed to allocate memory for toplevel output");
return;
@ -405,7 +405,7 @@ static struct wl_resource *create_toplevel_resource_for_resource(
}
wl_resource_set_implementation(resource, &toplevel_handle_impl, toplevel,
foreign_toplevel_resource_destroy);
foreign_toplevel_resource_destroy);
wl_list_insert(&toplevel->resources, wl_resource_get_link(resource));
zwlr_foreign_toplevel_manager_v1_send_toplevel(manager_resource, resource);
@ -469,12 +469,10 @@ static void toplevel_send_details_to_toplevel_resource(
struct wlr_foreign_toplevel_handle_v1 *toplevel,
struct wl_resource *resource) {
if (toplevel->title) {
zwlr_foreign_toplevel_handle_v1_send_title(resource,
toplevel->title);
zwlr_foreign_toplevel_handle_v1_send_title(resource, toplevel->title);
}
if (toplevel->app_id) {
zwlr_foreign_toplevel_handle_v1_send_app_id(resource,
toplevel->app_id);
zwlr_foreign_toplevel_handle_v1_send_app_id(resource, toplevel->app_id);
}
struct wlr_foreign_toplevel_handle_v1_output *output;
@ -516,7 +514,7 @@ static void foreign_toplevel_manager_bind(struct wl_client *client, void *data,
struct wl_resource *toplevel_resource =
create_toplevel_resource_for_resource(toplevel, resource);
toplevel_send_details_to_toplevel_resource(toplevel,
toplevel_resource);
toplevel_resource);
}
}

Loading…
Cancel
Save