From 9d9fcc0bb17d7dd00040d883831fd784878b52f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 23 Nov 2022 10:25:04 +0100 Subject: [PATCH] workspace: Cleanup workspace switch sound function Expand aggressively abbreviated variable names; some style cleanups. Part-of: --- src/core/workspace.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/core/workspace.c b/src/core/workspace.c index 98f6d71ff..d82158e95 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -481,28 +481,33 @@ meta_workspace_queue_calc_showing (MetaWorkspace *workspace) } static void -workspace_switch_sound(MetaWorkspace *from, - MetaWorkspace *to) +workspace_switch_sound (MetaWorkspace *from, + MetaWorkspace *to) { MetaSoundPlayer *player; MetaWorkspaceLayout layout; - int i, nw, x, y, fi, ti; - const char *e; + int n_workspaces; + int from_idx, to_idx; + int i; + int x, y; + const char *sound_name; - nw = meta_workspace_manager_get_n_workspaces (from->manager); - fi = meta_workspace_index(from); - ti = meta_workspace_index(to); + n_workspaces = meta_workspace_manager_get_n_workspaces (from->manager); + from_idx = meta_workspace_index(from); + to_idx = meta_workspace_index(to); meta_workspace_manager_calc_workspace_layout (from->manager, - nw, - fi, + n_workspaces, + from_idx, &layout); - for (i = 0; i < nw; i++) - if (layout.grid[i] == ti) - break; + for (i = 0; i < n_workspaces; i++) + { + if (layout.grid[i] == to_idx) + break; + } - if (i >= nw) + if (i >= n_workspaces) { g_warning ("Failed to find destination workspace in layout"); goto finish; @@ -519,13 +524,13 @@ workspace_switch_sound(MetaWorkspace *from, movement but not such much vertical movement. */ if (x < layout.current_col) - e = "desktop-switch-left"; + sound_name = "desktop-switch-left"; else if (x > layout.current_col) - e = "desktop-switch-right"; + sound_name = "desktop-switch-right"; else if (y < layout.current_row) - e = "desktop-switch-up"; + sound_name = "desktop-switch-up"; else if (y > layout.current_row) - e = "desktop-switch-down"; + sound_name = "desktop-switch-down"; else { g_warn_if_reached (); @@ -533,7 +538,9 @@ workspace_switch_sound(MetaWorkspace *from, } player = meta_display_get_sound_player (from->display); - meta_sound_player_play_from_theme (player, e, _("Workspace switched"), NULL); + meta_sound_player_play_from_theme (player, + sound_name, _("Workspace switched"), + NULL); finish: meta_workspace_manager_free_workspace_layout (&layout);