diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2022-11-23 10:25:04 +0100 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-12-17 13:25:13 +0000 |
commit | 9d9fcc0bb17d7dd00040d883831fd784878b52f7 (patch) | |
tree | 86e5c925e30f1d015a5de8e3472d26fb6d5b1401 | |
parent | 8a64746ce4ccfd66762a2e15ad02106e6f92c643 (diff) | |
download | mutter-9d9fcc0bb17d7dd00040d883831fd784878b52f7.tar.gz |
workspace: Cleanup workspace switch sound function
Expand aggressively abbreviated variable names; some style cleanups.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2707>
-rw-r--r-- | src/core/workspace.c | 43 |
1 files 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); |