Skip to content

Commit

Permalink
Merge pull request #2511 from RyanDwyer/refactor-arrange
Browse files Browse the repository at this point in the history
Prepare arrange code for type safe arguments
  • Loading branch information
ddevault authored Aug 28, 2018
2 parents 98ef29c + 126a82f commit 8323043
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 150 deletions.
12 changes: 8 additions & 4 deletions include/sway/tree/arrange.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#ifndef _SWAY_ARRANGE_H
#define _SWAY_ARRANGE_H
#include "sway/desktop/transaction.h"

struct sway_container;

/**
* Arrange layout for all the children of the given container.
*/
void arrange_container(struct sway_container *container);

void arrange_workspace(struct sway_container *workspace);

void arrange_output(struct sway_container *output);

void arrange_root(void);

void arrange_windows(struct sway_container *container);

#endif
2 changes: 1 addition & 1 deletion sway/commands/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
parent->prev_split_layout = prev;
}
container_notify_subtree_changed(parent);
arrange_windows(parent);
arrange_windows(parent->parent);
}

return cmd_results_new(CMD_SUCCESS, NULL, NULL);
Expand Down
1 change: 1 addition & 0 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "log.h"
#include "config.h"
#include "sway/config.h"
#include "sway/desktop/transaction.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/layers.h"
Expand Down
15 changes: 6 additions & 9 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,7 @@ static void render_container_tabbed(struct sway_output *output,
struct sway_container *current = pstate->focused_inactive_child;
struct border_colors *current_colors = &config->border_colors.unfocused;

double width_gap_adjustment = 2 * pstate->current_gaps;
int tab_width =
(pstate->swayc_width - width_gap_adjustment) / pstate->children->length;
int tab_width = (pstate->swayc_width) / pstate->children->length;

// Render tabs
for (int i = 0; i < pstate->children->length; ++i) {
Expand Down Expand Up @@ -656,11 +654,10 @@ static void render_container_tabbed(struct sway_output *output,

// Make last tab use the remaining width of the parent
if (i == pstate->children->length - 1) {
tab_width =
pstate->swayc_width - width_gap_adjustment - tab_width * i;
tab_width = pstate->swayc_width - tab_width * i;
}

render_titlebar(output, damage, child, x, cstate->swayc_y, tab_width,
render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width,
colors, title_texture, marks_texture);

if (child == current) {
Expand Down Expand Up @@ -721,9 +718,9 @@ static void render_container_stacked(struct sway_output *output,
marks_texture = view ? view->marks_unfocused : NULL;
}

int y = cstate->swayc_y + titlebar_height * i;
render_titlebar(output, damage, child, cstate->swayc_x, y,
cstate->swayc_width, colors, title_texture, marks_texture);
int y = pstate->swayc_y + titlebar_height * i;
render_titlebar(output, damage, child, pstate->swayc_x, y,
pstate->swayc_width, colors, title_texture, marks_texture);

if (child == current) {
current_colors = colors;
Expand Down
1 change: 1 addition & 0 deletions sway/desktop/xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "log.h"
#include "sway/decoration.h"
#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/server.h"
Expand Down
1 change: 1 addition & 0 deletions sway/desktop/xdg_shell_v6.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "log.h"
#include "sway/decoration.h"
#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/server.h"
Expand Down
Loading

0 comments on commit 8323043

Please sign in to comment.