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>
This commit is contained in:
Jonas Ådahl 2022-11-23 10:25:04 +01:00 committed by Marge Bot
parent 8a64746ce4
commit 9d9fcc0bb1

View File

@ -486,23 +486,28 @@ workspace_switch_sound(MetaWorkspace *from,
{
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)
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);