summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ashkan Kiani <ashkan.k.kiani@gmail.com>2019-04-13 03:33:07 -0700
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-04-13 08:35:17 -0600
commit913445e112b3ceca4ece731a6e57b19cab9d0c6a (patch)
tree0de3cc6ffd2f7410a758547df31bd572363cf3a2 /sway
parentswaybg: add manpage (diff)
downloadsway-913445e112b3ceca4ece731a6e57b19cab9d0c6a.tar.gz
sway-913445e112b3ceca4ece731a6e57b19cab9d0c6a.tar.zst
sway-913445e112b3ceca4ece731a6e57b19cab9d0c6a.zip
Fix potential null accesses
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/move.c90
-rw-r--r--sway/input/seat.c12
2 files changed, 54 insertions, 48 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 926b2e8e..f642f023 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -311,37 +311,39 @@ static bool container_move_in_direction(struct sway_container *container,
311 311
312 while (current) { 312 while (current) {
313 list_t *siblings = container_get_siblings(current); 313 list_t *siblings = container_get_siblings(current);
314 enum sway_container_layout layout = container_parent_layout(current); 314 if (siblings) {
315 int index = list_find(siblings, current); 315 enum sway_container_layout layout = container_parent_layout(current);
316 int desired = index + offs; 316 int index = list_find(siblings, current);
317 317 int desired = index + offs;
318 // Don't allow containers to move out of their 318
319 // fullscreen or floating parent 319 // Don't allow containers to move out of their
320 if (current->fullscreen_mode || container_is_floating(current)) { 320 // fullscreen or floating parent
321 return false; 321 if (current->fullscreen_mode || container_is_floating(current)) {
322 } 322 return false;
323 }
323 324
324 if (is_parallel(layout, move_dir)) { 325 if (is_parallel(layout, move_dir)) {
325 if (desired == -1 || desired == siblings->length) { 326 if (desired == -1 || desired == siblings->length) {
326 if (current->parent == container->parent) { 327 if (current->parent == container->parent) {
327 current = current->parent; 328 current = current->parent;
328 continue; 329 continue;
329 } else {
330 // Reparenting
331 if (current->parent) {
332 container_insert_child(current->parent, container,
333 index + (offs < 0 ? 0 : 1));
334 } else { 330 } else {
335 workspace_insert_tiling(current->workspace, container, 331 // Reparenting
336 index + (offs < 0 ? 0 : 1)); 332 if (current->parent) {
333 container_insert_child(current->parent, container,
334 index + (offs < 0 ? 0 : 1));
335 } else {
336 workspace_insert_tiling(current->workspace, container,
337 index + (offs < 0 ? 0 : 1));
338 }
339 return true;
337 } 340 }
341 } else {
342 // Container can move within its siblings
343 container_move_to_container_from_direction(container,
344 siblings->items[desired], move_dir);
338 return true; 345 return true;
339 } 346 }
340 } else {
341 // Container can move within its siblings
342 container_move_to_container_from_direction(container,
343 siblings->items[desired], move_dir);
344 return true;
345 } 347 }
346 } 348 }
347 349
@@ -350,26 +352,28 @@ static bool container_move_in_direction(struct sway_container *container,
350 352
351 // Maybe rejigger the workspace 353 // Maybe rejigger the workspace
352 struct sway_workspace *ws = container->workspace; 354 struct sway_workspace *ws = container->workspace;
353 if (!is_parallel(ws->layout, move_dir)) { 355 if (ws) {
354 workspace_rejigger(ws, container, move_dir); 356 if (!is_parallel(ws->layout, move_dir)) {
355 return true; 357 workspace_rejigger(ws, container, move_dir);
356 } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) { 358 return true;
357 workspace_rejigger(ws, container, move_dir); 359 } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
358 return true; 360 workspace_rejigger(ws, container, move_dir);
359 } 361 return true;
362 }
360 363
361 // Try adjacent output 364 // Try adjacent output
362 struct sway_output *output = 365 struct sway_output *output =
363 output_get_in_direction(container->workspace->output, move_dir); 366 output_get_in_direction(container->workspace->output, move_dir);
364 if (output) { 367 if (output) {
365 struct sway_workspace *ws = output_get_active_workspace(output); 368 struct sway_workspace *ws = output_get_active_workspace(output);
366 if (!sway_assert(ws, "Expected output to have a workspace")) { 369 if (!sway_assert(ws, "Expected output to have a workspace")) {
367 return false; 370 return false;
371 }
372 container_move_to_workspace_from_direction(container, ws, move_dir);
373 return true;
368 } 374 }
369 container_move_to_workspace_from_direction(container, ws, move_dir); 375 sway_log(SWAY_DEBUG, "Hit edge of output, nowhere else to go");
370 return true;
371 } 376 }
372 sway_log(SWAY_DEBUG, "Hit edge of output, nowhere else to go");
373 return false; 377 return false;
374} 378}
375 379
diff --git a/sway/input/seat.c b/sway/input/seat.c
index d58ff9e6..bdab8b81 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1194,11 +1194,13 @@ void seat_consider_warp_to_focus(struct sway_seat *seat) {
1194 } 1194 }
1195 if (config->mouse_warping == WARP_OUTPUT) { 1195 if (config->mouse_warping == WARP_OUTPUT) {
1196 struct sway_output *output = node_get_output(focus); 1196 struct sway_output *output = node_get_output(focus);
1197 struct wlr_box box; 1197 if (output) {
1198 output_get_box(output, &box); 1198 struct wlr_box box;
1199 if (wlr_box_contains_point(&box, 1199 output_get_box(output, &box);
1200 seat->cursor->cursor->x, seat->cursor->cursor->y)) { 1200 if (wlr_box_contains_point(&box,
1201 return; 1201 seat->cursor->cursor->x, seat->cursor->cursor->y)) {
1202 return;
1203 }
1202 } 1204 }
1203 } 1205 }
1204 1206