action.{c,h}: fix coding style

This commit is contained in:
Johan Malm 2022-01-05 21:23:01 +00:00
parent 0b45cce648
commit 3bd65c3a20
2 changed files with 24 additions and 25 deletions

View file

@ -8,6 +8,6 @@ struct action {
struct wl_list link; struct wl_list link;
}; };
struct action *action_create(const char *action_str); struct action *action_create(const char *action_name);
#endif #endif

View file

@ -55,7 +55,7 @@ const char *action_names[] = {
static enum action_type static enum action_type
action_type_from_str(const char *action_name) action_type_from_str(const char *action_name)
{ {
for (size_t i=1; action_names[i] != NULL; i++) { for (size_t i = 1; action_names[i] != NULL; i++) {
if (!strcasecmp(action_name, action_names[i])) { if (!strcasecmp(action_name, action_names[i])) {
return i; return i;
} }
@ -76,7 +76,6 @@ action_create(const char *action_name)
return action; return action;
} }
static void static void
show_menu(struct server *server, const char *menu) show_menu(struct server *server, const char *menu)
{ {
@ -114,16 +113,16 @@ action(struct view *activator, struct server *server, struct wl_list *actions, u
/* Refetch view because it may have been changed due to the previous action */ /* Refetch view because it may have been changed due to the previous action */
view = activator_or_focused_view(activator, server); view = activator_or_focused_view(activator, server);
switch(action->type) { switch (action->type) {
case ACTION_TYPE_CLOSE:; case ACTION_TYPE_CLOSE:
if (view) { if (view) {
view_close(view); view_close(view);
} }
break; break;
case ACTION_TYPE_DEBUG:; case ACTION_TYPE_DEBUG:
/* nothing */ /* nothing */
break; break;
case ACTION_TYPE_EXECUTE:; case ACTION_TYPE_EXECUTE:
{ {
struct buf cmd; struct buf cmd;
buf_init(&cmd); buf_init(&cmd);
@ -133,88 +132,88 @@ action(struct view *activator, struct server *server, struct wl_list *actions, u
free(cmd.buf); free(cmd.buf);
} }
break; break;
case ACTION_TYPE_EXIT:; case ACTION_TYPE_EXIT:
wl_display_terminate(server->wl_display); wl_display_terminate(server->wl_display);
break; break;
case ACTION_TYPE_MOVE_TO_EDGE:; case ACTION_TYPE_MOVE_TO_EDGE:
view_move_to_edge(view, action->arg); view_move_to_edge(view, action->arg);
break; break;
case ACTION_TYPE_SNAP_TO_EDGE:; case ACTION_TYPE_SNAP_TO_EDGE:
view_snap_to_edge(view, action->arg); view_snap_to_edge(view, action->arg);
break; break;
case ACTION_TYPE_NEXT_WINDOW:; case ACTION_TYPE_NEXT_WINDOW:
server->cycle_view = server->cycle_view =
desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_FORWARD); desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_FORWARD);
osd_update(server); osd_update(server);
break; break;
case ACTION_TYPE_PREVIOUS_WINDOW:; case ACTION_TYPE_PREVIOUS_WINDOW:
server->cycle_view = server->cycle_view =
desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_BACKWARD); desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
osd_update(server); osd_update(server);
break; break;
case ACTION_TYPE_RECONFIGURE:; case ACTION_TYPE_RECONFIGURE:
/* Should be changed to signal() */ /* Should be changed to signal() */
spawn_async_no_shell("killall -SIGHUP labwc"); spawn_async_no_shell("killall -SIGHUP labwc");
break; break;
case ACTION_TYPE_SHOW_MENU:; case ACTION_TYPE_SHOW_MENU:
show_menu(server, action->arg); show_menu(server, action->arg);
break; break;
case ACTION_TYPE_TOGGLE_MAXIMIZE:; case ACTION_TYPE_TOGGLE_MAXIMIZE:
if (view) { if (view) {
view_toggle_maximize(view); view_toggle_maximize(view);
} }
break; break;
case ACTION_TYPE_TOGGLE_FULLSCREEN:; case ACTION_TYPE_TOGGLE_FULLSCREEN:
if (view) { if (view) {
view_toggle_fullscreen(view); view_toggle_fullscreen(view);
} }
break; break;
case ACTION_TYPE_TOGGLE_DECORATIONS:; case ACTION_TYPE_TOGGLE_DECORATIONS:
if (view) { if (view) {
view_toggle_decorations(view); view_toggle_decorations(view);
} }
break; break;
case ACTION_TYPE_FOCUS:; case ACTION_TYPE_FOCUS:
view = desktop_view_at_cursor(server); view = desktop_view_at_cursor(server);
if (view) { if (view) {
desktop_focus_and_activate_view(&server->seat, view); desktop_focus_and_activate_view(&server->seat, view);
damage_all_outputs(server); damage_all_outputs(server);
} }
break; break;
case ACTION_TYPE_ICONIFY:; case ACTION_TYPE_ICONIFY:
if (view) { if (view) {
view_minimize(view, true); view_minimize(view, true);
} }
break; break;
case ACTION_TYPE_MOVE:; case ACTION_TYPE_MOVE:
view = desktop_view_at_cursor(server); view = desktop_view_at_cursor(server);
if (view) { if (view) {
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0); interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
} }
break; break;
case ACTION_TYPE_RAISE:; case ACTION_TYPE_RAISE:
if (view) { if (view) {
desktop_move_to_front(view); desktop_move_to_front(view);
damage_all_outputs(server); damage_all_outputs(server);
} }
break; break;
case ACTION_TYPE_RESIZE:; case ACTION_TYPE_RESIZE:
view = desktop_view_at_cursor(server); view = desktop_view_at_cursor(server);
if (view) { if (view) {
interactive_begin(view, LAB_INPUT_STATE_RESIZE, resize_edges); interactive_begin(view, LAB_INPUT_STATE_RESIZE, resize_edges);
} }
break; break;
case ACTION_TYPE_NONE:; case ACTION_TYPE_NONE:
wlr_log(WLR_ERROR, "Not executing unknown action with arg %s", action->arg); wlr_log(WLR_ERROR, "Not executing unknown action with arg %s", action->arg);
break; break;
default:; default:
/* /*
* If we get here it must be a BUG caused most likely by * If we get here it must be a BUG caused most likely by
* action_names and action_type being out of sync or by * action_names and action_type being out of sync or by
* adding a new action without installing a handler here. * adding a new action without installing a handler here.
*/ */
wlr_log(WLR_ERROR, "Not executing invalid action (%u) with arg %s" wlr_log(WLR_ERROR, "Not executing invalid action (%u) with arg %s"
"This is a BUG. Please report.", action->type, action->arg); " This is a BUG. Please report.", action->type, action->arg);
} }
} }
} }