mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 04:42:14 +00:00
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
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user