Skip to content

Commit 9d876a2

Browse files
committed
WorkspaceManager: Always use braces
1 parent 89a30b1 commit 9d876a2

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

src/WorkspaceManager.vala

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ public class Gala.WorkspaceManager : Object {
4343
// There are some empty workspace at startup
4444
cleanup ();
4545

46-
if (Meta.Prefs.get_dynamic_workspaces ())
46+
if (Meta.Prefs.get_dynamic_workspaces ()) {
4747
manager.override_workspace_layout (Meta.DisplayCorner.TOPLEFT, false, 1, -1);
48+
}
4849

49-
for (var i = 0; i < manager.get_n_workspaces (); i++)
50+
for (var i = 0; i < manager.get_n_workspaces (); i++) {
5051
workspace_added (manager, i);
52+
}
5153

5254
Meta.Prefs.add_listener (prefs_listener);
5355

@@ -59,8 +61,10 @@ public class Gala.WorkspaceManager : Object {
5961

6062
// make sure the last workspace has no windows on it
6163
if (Meta.Prefs.get_dynamic_workspaces ()
62-
&& Utils.get_n_windows (manager.get_workspace_by_index (manager.get_n_workspaces () - 1)) > 0)
64+
&& Utils.get_n_windows (manager.get_workspace_by_index (manager.get_n_workspaces () - 1)) > 0
65+
) {
6366
append_workspace ();
67+
}
6468
}
6569

6670
~WorkspaceManager () {
@@ -77,8 +81,9 @@ public class Gala.WorkspaceManager : Object {
7781

7882
private void workspace_added (Meta.WorkspaceManager manager, int index) {
7983
var workspace = manager.get_workspace_by_index (index);
80-
if (workspace == null)
84+
if (workspace == null) {
8185
return;
86+
}
8287

8388
workspace.window_added.connect (window_added);
8489
workspace.window_removed.connect (window_removed);
@@ -94,19 +99,22 @@ public class Gala.WorkspaceManager : Object {
9499
while (it.next ()) {
95100
var workspace = it.@get ();
96101

97-
if (existing_workspaces.index (workspace) < 0)
102+
if (existing_workspaces.index (workspace) < 0) {
98103
it.remove ();
104+
}
99105
}
100106
}
101107

102108
private void workspace_switched (Meta.WorkspaceManager manager, int from, int to, Meta.MotionDirection direction) {
103-
if (!Meta.Prefs.get_dynamic_workspaces ())
109+
if (!Meta.Prefs.get_dynamic_workspaces ()) {
104110
return;
111+
}
105112

106113
// remove empty workspaces after we switched away from them unless it's the last one
107114
var prev_workspace = manager.get_workspace_by_index (from);
108115
if (Utils.get_n_windows (prev_workspace) < 1
109-
&& from != manager.get_n_workspaces () - 1) {
116+
&& from != manager.get_n_workspaces () - 1
117+
) {
110118

111119
// If we're about to remove a workspace, cancel any DnD going on in the multitasking view
112120
// or else things might get broke
@@ -127,8 +135,10 @@ public class Gala.WorkspaceManager : Object {
127135
if ((window.window_type == Meta.WindowType.NORMAL
128136
|| window.window_type == Meta.WindowType.DIALOG
129137
|| window.window_type == Meta.WindowType.MODAL_DIALOG)
130-
&& workspace.index () == last_workspace)
138+
&& workspace.index () == last_workspace
139+
) {
131140
append_workspace ();
141+
}
132142
}
133143

134144
private void window_removed (Meta.Workspace? workspace, Meta.Window window) {
@@ -143,8 +153,10 @@ public class Gala.WorkspaceManager : Object {
143153

144154
if (window.window_type != Meta.WindowType.NORMAL
145155
&& window.window_type != Meta.WindowType.DIALOG
146-
&& window.window_type != Meta.WindowType.MODAL_DIALOG)
156+
&& window.window_type != Meta.WindowType.MODAL_DIALOG
157+
) {
147158
return;
159+
}
148160

149161
// has already been removed
150162
if (workspace.index () < 0) {
@@ -156,38 +168,41 @@ public class Gala.WorkspaceManager : Object {
156168
if ((!is_active_workspace || wm.is_modal ())
157169
&& remove_freeze_count < 1
158170
&& Utils.get_n_windows (workspace, true, window) == 0
159-
&& workspace != last_workspace) {
171+
&& workspace != last_workspace
172+
) {
160173
remove_workspace (workspace);
161174
}
162175

163176
// if window is the second last and empty, make it the last workspace
164177
if (is_active_workspace
165178
&& remove_freeze_count < 1
166179
&& Utils.get_n_windows (workspace, true, window) == 0
167-
&& workspace.index () == last_workspace_index - 1) {
180+
&& workspace.index () == last_workspace_index - 1
181+
) {
168182
remove_workspace (last_workspace);
169183
}
170184
}
171185

172186
private void window_entered_monitor (Meta.Display display, int monitor, Meta.Window window) {
173-
if (InternalUtils.workspaces_only_on_primary ()
174-
&& monitor == display.get_primary_monitor ())
187+
if (InternalUtils.workspaces_only_on_primary () && monitor == display.get_primary_monitor ()) {
175188
window_added (window.get_workspace (), window);
189+
}
176190
}
177191

178192
private void window_left_monitor (Meta.Display display, int monitor, Meta.Window window) {
179-
if (InternalUtils.workspaces_only_on_primary ()
180-
&& monitor == display.get_primary_monitor ())
193+
if (InternalUtils.workspaces_only_on_primary () && monitor == display.get_primary_monitor ()) {
181194
window_removed (window.get_workspace (), window);
195+
}
182196
}
183197

184198
private void prefs_listener (Meta.Preference pref) {
185199
unowned Meta.WorkspaceManager manager = wm.get_display ().get_workspace_manager ();
186200

187201
if (pref == Meta.Preference.DYNAMIC_WORKSPACES && Meta.Prefs.get_dynamic_workspaces ()) {
188202
// if the last workspace has a window, we need to append a new workspace
189-
if (Utils.get_n_windows (manager.get_workspace_by_index (manager.get_n_workspaces () - 1)) > 0)
203+
if (Utils.get_n_windows (manager.get_workspace_by_index (manager.get_n_workspaces () - 1)) > 0) {
190204
append_workspace ();
205+
}
191206
}
192207
}
193208

@@ -214,11 +229,13 @@ public class Gala.WorkspaceManager : Object {
214229

215230
next = workspace.get_neighbor (Meta.MotionDirection.LEFT);
216231
// if it's the first one we may have another one to the right
217-
if (next == workspace || next == null)
232+
if (next == workspace || next == null) {
218233
next = workspace.get_neighbor (Meta.MotionDirection.RIGHT);
234+
}
219235

220-
if (next != null)
236+
if (next != null) {
221237
next.activate (time);
238+
}
222239
}
223240

224241
// workspace has already been removed
@@ -266,8 +283,7 @@ public class Gala.WorkspaceManager : Object {
266283

267284
foreach (var workspace in manager.get_workspaces ()) {
268285
var last_index = manager.get_n_workspaces () - 1;
269-
if (Utils.get_n_windows (workspace) == 0
270-
&& workspace.index () != last_index) {
286+
if (Utils.get_n_windows (workspace) == 0 && workspace.index () != last_index) {
271287
remove_workspace (workspace);
272288
}
273289
}

0 commit comments

Comments
 (0)