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:
parent
8a64746ce4
commit
9d9fcc0bb1
@ -481,28 +481,33 @@ meta_workspace_queue_calc_showing (MetaWorkspace *workspace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
workspace_switch_sound(MetaWorkspace *from,
|
workspace_switch_sound (MetaWorkspace *from,
|
||||||
MetaWorkspace *to)
|
MetaWorkspace *to)
|
||||||
{
|
{
|
||||||
MetaSoundPlayer *player;
|
MetaSoundPlayer *player;
|
||||||
MetaWorkspaceLayout layout;
|
MetaWorkspaceLayout layout;
|
||||||
int i, nw, x, y, fi, ti;
|
int n_workspaces;
|
||||||
const char *e;
|
int from_idx, to_idx;
|
||||||
|
int i;
|
||||||
|
int x, y;
|
||||||
|
const char *sound_name;
|
||||||
|
|
||||||
nw = meta_workspace_manager_get_n_workspaces (from->manager);
|
n_workspaces = meta_workspace_manager_get_n_workspaces (from->manager);
|
||||||
fi = meta_workspace_index(from);
|
from_idx = meta_workspace_index(from);
|
||||||
ti = meta_workspace_index(to);
|
to_idx = meta_workspace_index(to);
|
||||||
|
|
||||||
meta_workspace_manager_calc_workspace_layout (from->manager,
|
meta_workspace_manager_calc_workspace_layout (from->manager,
|
||||||
nw,
|
n_workspaces,
|
||||||
fi,
|
from_idx,
|
||||||
&layout);
|
&layout);
|
||||||
|
|
||||||
for (i = 0; i < nw; i++)
|
for (i = 0; i < n_workspaces; i++)
|
||||||
if (layout.grid[i] == ti)
|
{
|
||||||
break;
|
if (layout.grid[i] == to_idx)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (i >= nw)
|
if (i >= n_workspaces)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to find destination workspace in layout");
|
g_warning ("Failed to find destination workspace in layout");
|
||||||
goto finish;
|
goto finish;
|
||||||
@ -519,13 +524,13 @@ workspace_switch_sound(MetaWorkspace *from,
|
|||||||
movement but not such much vertical movement. */
|
movement but not such much vertical movement. */
|
||||||
|
|
||||||
if (x < layout.current_col)
|
if (x < layout.current_col)
|
||||||
e = "desktop-switch-left";
|
sound_name = "desktop-switch-left";
|
||||||
else if (x > layout.current_col)
|
else if (x > layout.current_col)
|
||||||
e = "desktop-switch-right";
|
sound_name = "desktop-switch-right";
|
||||||
else if (y < layout.current_row)
|
else if (y < layout.current_row)
|
||||||
e = "desktop-switch-up";
|
sound_name = "desktop-switch-up";
|
||||||
else if (y > layout.current_row)
|
else if (y > layout.current_row)
|
||||||
e = "desktop-switch-down";
|
sound_name = "desktop-switch-down";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
@ -533,7 +538,9 @@ workspace_switch_sound(MetaWorkspace *from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
player = meta_display_get_sound_player (from->display);
|
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:
|
finish:
|
||||||
meta_workspace_manager_free_workspace_layout (&layout);
|
meta_workspace_manager_free_workspace_layout (&layout);
|
||||||
|
Loading…
Reference in New Issue
Block a user