Codebase list wlroots / a4eb903
Fix indentation in various files emersion 5 years ago
5 changed file(s) with 118 addition(s) and 124 deletion(s). Raw diff Collapse all Expand all
151151 };
152152
153153 bool create_t1 = (simulate_activity_timeout != 0) &&
154 (simulate_activity_timeout < close_timeout);
154 (simulate_activity_timeout < close_timeout);
155155
156156 if (create_t1) {
157157 if (pthread_create(&t1, NULL, &simulate_activity, (void *)&arg) != 0) {
33 #include "rootston/input.h"
44
55 struct roots_switch {
6 struct roots_seat *seat;
7 struct wlr_input_device *device;
8 struct wl_listener device_destroy;
6 struct roots_seat *seat;
7 struct wlr_input_device *device;
8 struct wl_listener device_destroy;
99
10 struct wl_listener toggle;
11 struct wl_list link;
10 struct wl_listener toggle;
11 struct wl_list link;
1212 };
1313
1414 void roots_switch_handle_toggle(struct roots_switch *lid_switch,
15 struct wlr_event_switch_toggle *event);
15 struct wlr_event_switch_toggle *event);
1616
17 #endif // ROOTSTON_SWITCH_H
17 #endif
66
77 static bool outputs_enabled = true;
88
9 static const char *exec_prefix = "exec ";
9 static const char exec_prefix[] = "exec ";
1010
1111 static void double_fork_shell_cmd(const char *shell_cmd) {
12 pid_t pid = fork();
13 if (pid < 0) {
14 wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
15 return;
16 }
12 pid_t pid = fork();
13 if (pid < 0) {
14 wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
15 return;
16 }
1717
18 if (pid == 0) {
19 pid = fork();
20 if (pid == 0) {
21 execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
22 _exit(EXIT_FAILURE);
23 } else {
24 _exit(pid == -1);
25 }
26 }
18 if (pid == 0) {
19 pid = fork();
20 if (pid == 0) {
21 execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
22 _exit(EXIT_FAILURE);
23 } else {
24 _exit(pid == -1);
25 }
26 }
2727
28 int status;
29 while (waitpid(pid, &status, 0) < 0) {
30 if (errno == EINTR) {
31 continue;
32 }
33 wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
34 return;
35 }
28 int status;
29 while (waitpid(pid, &status, 0) < 0) {
30 if (errno == EINTR) {
31 continue;
32 }
33 wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
34 return;
35 }
3636
37 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
38 return;
39 }
37 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
38 return;
39 }
4040
41 wlr_log(WLR_ERROR, "first child failed to fork command");
41 wlr_log(WLR_ERROR, "first child failed to fork command");
4242 }
4343
44 void execute_binding_command(struct roots_seat *seat,
45 struct roots_input *input, const char *command) {
46 if (strcmp(command, "exit") == 0) {
47 wl_display_terminate(input->server->wl_display);
48 } else if (strcmp(command, "close") == 0) {
49 struct roots_view *focus = roots_seat_get_focus(seat);
50 if (focus != NULL) {
51 view_close(focus);
52 }
53 } else if (strcmp(command, "fullscreen") == 0) {
54 struct roots_view *focus = roots_seat_get_focus(seat);
55 if (focus != NULL) {
56 bool is_fullscreen = focus->fullscreen_output != NULL;
57 view_set_fullscreen(focus, !is_fullscreen, NULL);
58 }
59 } else if (strcmp(command, "next_window") == 0) {
60 roots_seat_cycle_focus(seat);
61 } else if (strcmp(command, "alpha") == 0) {
62 struct roots_view *focus = roots_seat_get_focus(seat);
63 if (focus != NULL) {
64 view_cycle_alpha(focus);
65 }
66 } else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
67 const char *shell_cmd = command + strlen(exec_prefix);
68 double_fork_shell_cmd(shell_cmd);
69 } else if (strcmp(command, "maximize") == 0) {
70 struct roots_view *focus = roots_seat_get_focus(seat);
71 if (focus != NULL) {
72 view_maximize(focus, !focus->maximized);
73 }
74 } else if (strcmp(command, "nop") == 0) {
75 wlr_log(WLR_DEBUG, "nop command");
76 } else if (strcmp(command, "toggle_outputs") == 0) {
77 outputs_enabled = !outputs_enabled;
78 struct roots_output *output;
79 wl_list_for_each(output, &input->server->desktop->outputs, link) {
80 wlr_output_enable(output->wlr_output, outputs_enabled);
81 }
82 } else if (strcmp(command, "toggle_decoration_mode") == 0) {
83 struct roots_view *focus = roots_seat_get_focus(seat);
84 if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
85 struct roots_xdg_toplevel_decoration *decoration =
86 focus->roots_xdg_surface->xdg_toplevel_decoration;
87 if (decoration != NULL) {
88 enum wlr_xdg_toplevel_decoration_v1_mode mode =
89 decoration->wlr_decoration->current_mode;
90 mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
91 ? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
92 : WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
93 wlr_xdg_toplevel_decoration_v1_set_mode(
94 decoration->wlr_decoration, mode);
95 }
96 }
97 } else if (strcmp(command, "break_pointer_constraint") == 0) {
98 struct wl_list *list = &input->seats;
99 struct roots_seat *seat;
100 wl_list_for_each(seat, list, link) {
101 roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
102 }
103 } else {
104 wlr_log(WLR_ERROR, "unknown binding command: %s", command);
105 }
44 void execute_binding_command(struct roots_seat *seat,
45 struct roots_input *input, const char *command) {
46 if (strcmp(command, "exit") == 0) {
47 wl_display_terminate(input->server->wl_display);
48 } else if (strcmp(command, "close") == 0) {
49 struct roots_view *focus = roots_seat_get_focus(seat);
50 if (focus != NULL) {
51 view_close(focus);
52 }
53 } else if (strcmp(command, "fullscreen") == 0) {
54 struct roots_view *focus = roots_seat_get_focus(seat);
55 if (focus != NULL) {
56 bool is_fullscreen = focus->fullscreen_output != NULL;
57 view_set_fullscreen(focus, !is_fullscreen, NULL);
58 }
59 } else if (strcmp(command, "next_window") == 0) {
60 roots_seat_cycle_focus(seat);
61 } else if (strcmp(command, "alpha") == 0) {
62 struct roots_view *focus = roots_seat_get_focus(seat);
63 if (focus != NULL) {
64 view_cycle_alpha(focus);
65 }
66 } else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
67 const char *shell_cmd = command + strlen(exec_prefix);
68 double_fork_shell_cmd(shell_cmd);
69 } else if (strcmp(command, "maximize") == 0) {
70 struct roots_view *focus = roots_seat_get_focus(seat);
71 if (focus != NULL) {
72 view_maximize(focus, !focus->maximized);
73 }
74 } else if (strcmp(command, "nop") == 0) {
75 wlr_log(WLR_DEBUG, "nop command");
76 } else if (strcmp(command, "toggle_outputs") == 0) {
77 outputs_enabled = !outputs_enabled;
78 struct roots_output *output;
79 wl_list_for_each(output, &input->server->desktop->outputs, link) {
80 wlr_output_enable(output->wlr_output, outputs_enabled);
81 }
82 } else if (strcmp(command, "toggle_decoration_mode") == 0) {
83 struct roots_view *focus = roots_seat_get_focus(seat);
84 if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
85 struct roots_xdg_toplevel_decoration *decoration =
86 focus->roots_xdg_surface->xdg_toplevel_decoration;
87 if (decoration != NULL) {
88 enum wlr_xdg_toplevel_decoration_v1_mode mode =
89 decoration->wlr_decoration->current_mode;
90 mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
91 ? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
92 : WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
93 wlr_xdg_toplevel_decoration_v1_set_mode(
94 decoration->wlr_decoration, mode);
95 }
96 }
97 } else if (strcmp(command, "break_pointer_constraint") == 0) {
98 struct wl_list *list = &input->seats;
99 struct roots_seat *seat;
100 wl_list_for_each(seat, list, link) {
101 roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
102 }
103 } else {
104 wlr_log(WLR_ERROR, "unknown binding command: %s", command);
105 }
106106 }
00 #include <stdlib.h>
1
21 #include <wlr/util/log.h>
3
42 #include "rootston/bindings.h"
5 #include "rootston/config.h"
6 #include "rootston/input.h"
7 #include "rootston/seat.h"
8 #include "rootston/switch.h"
93
104 void roots_switch_handle_toggle(struct roots_switch *lid_switch,
11 struct wlr_event_switch_toggle *event) {
12 struct wl_list *bound_switches = &lid_switch->seat->input->server->config->switches;
13 struct roots_switch_config *sc;
14 wl_list_for_each(sc, bound_switches, link) {
15 if ((sc->name != NULL && strcmp(event->device->name, sc->name) != 0) &&
16 (sc->name == NULL && event->switch_type != sc->switch_type)) {
17 continue;
18 }
19 if (sc->switch_state != WLR_SWITCH_STATE_TOGGLE &&
20 event->switch_state != sc->switch_state) {
21 continue;
22 }
23 execute_binding_command(lid_switch->seat, lid_switch->seat->input, sc->command);
24 }
5 struct wlr_event_switch_toggle *event) {
6 struct wl_list *bound_switches =
7 &lid_switch->seat->input->server->config->switches;
8 struct roots_switch_config *sc;
9 wl_list_for_each(sc, bound_switches, link) {
10 if ((sc->name != NULL && strcmp(event->device->name, sc->name) != 0) &&
11 (sc->name == NULL && event->switch_type != sc->switch_type)) {
12 continue;
13 }
14 if (sc->switch_state != WLR_SWITCH_STATE_TOGGLE &&
15 event->switch_state != sc->switch_state) {
16 continue;
17 }
18 execute_binding_command(lid_switch->seat,
19 lid_switch->seat->input, sc->command);
20 }
2521 }
231231 }
232232
233233 toplevel_output =
234 calloc(1, sizeof(struct wlr_foreign_toplevel_handle_v1_output));
234 calloc(1, sizeof(struct wlr_foreign_toplevel_handle_v1_output));
235235 if (!toplevel_output) {
236236 wlr_log(WLR_ERROR, "failed to allocate memory for toplevel output");
237237 return;
404404 }
405405
406406 wl_resource_set_implementation(resource, &toplevel_handle_impl, toplevel,
407 foreign_toplevel_resource_destroy);
407 foreign_toplevel_resource_destroy);
408408
409409 wl_list_insert(&toplevel->resources, wl_resource_get_link(resource));
410410 zwlr_foreign_toplevel_manager_v1_send_toplevel(manager_resource, resource);
468468 struct wlr_foreign_toplevel_handle_v1 *toplevel,
469469 struct wl_resource *resource) {
470470 if (toplevel->title) {
471 zwlr_foreign_toplevel_handle_v1_send_title(resource,
472 toplevel->title);
471 zwlr_foreign_toplevel_handle_v1_send_title(resource, toplevel->title);
473472 }
474473 if (toplevel->app_id) {
475 zwlr_foreign_toplevel_handle_v1_send_app_id(resource,
476 toplevel->app_id);
474 zwlr_foreign_toplevel_handle_v1_send_app_id(resource, toplevel->app_id);
477475 }
478476
479477 struct wlr_foreign_toplevel_handle_v1_output *output;
515513 struct wl_resource *toplevel_resource =
516514 create_toplevel_resource_for_resource(toplevel, resource);
517515 toplevel_send_details_to_toplevel_resource(toplevel,
518 toplevel_resource);
516 toplevel_resource);
519517 }
520518 }
521519