Coding style enforcement

This was done by hand, so I might have missed things. If anyone knows of
a good C style enforcement tool, let me know.
master
Drew DeVault 9 years ago
parent af1b3d9755
commit 2139001c9f

@ -30,7 +30,6 @@ struct sway_container {
wlc_handle handle;
enum swayc_types type;
enum swayc_layouts layout;
// Not including borders or margins
@ -42,9 +41,7 @@ struct sway_container {
int x, y;
bool visible;
bool is_floating;
bool is_focused;
int weight;
@ -52,8 +49,6 @@ struct sway_container {
char *name;
list_t *children;
// Special list for floating windows in workspaces
list_t *floating;
struct sway_container *parent;
@ -72,7 +67,7 @@ swayc_t *new_floating_view(wlc_handle handle);
swayc_t *destroy_output(swayc_t *output);
//destroys workspace if empty and returns parent pointer, else returns NULL
// Destroys workspace if empty and returns parent pointer, else returns NULL
swayc_t *destroy_workspace(swayc_t *workspace);
swayc_t *destroy_container(swayc_t *container);
swayc_t *destroy_view(swayc_t *view);

@ -292,9 +292,11 @@ static bool cmd_layout(struct sway_config *config, int argc, char **argv) {
return false;
}
swayc_t *parent = get_focused_container(&root_container);
while (parent->type == C_VIEW) {
parent = parent->parent;
}
if (strcasecmp(argv[0], "splith") == 0) {
parent->layout = L_HORIZ;
} else if (strcasecmp(argv[0], "splitv") == 0) {
@ -343,19 +345,17 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay
}
swayc_t *focused = get_focused_container(&root_container);
/* Case that focus is on an workspace with 0/1 children.change its layout */
if (focused->type == C_WORKSPACE && focused->children->length <= 1) {
/* Case that focus is on an workspace with 0/1 children.change its layout */
sway_log(L_DEBUG, "changing workspace layout");
focused->layout = layout;
}
} else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) {
/* Case of no siblings. change parent layout */
else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) {
sway_log(L_DEBUG, "changing container layout");
focused->parent->layout = layout;
}
} else {
/* regular case where new split container is build around focused container
* or in case of workspace, container inherits its children */
else {
sway_log(L_DEBUG, "Adding new container around current focused container");
swayc_t *parent = new_container(focused, layout);
set_focused_container(focused);
@ -369,6 +369,7 @@ static bool cmd_split(struct sway_config *config, int argc, char **argv) {
if (!checkarg(argc, "split", EXPECTED_EQUAL_TO, 1)) {
return false;
}
if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
_do_split(config, argc - 1, argv + 1, L_VERT);
} else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) {
@ -377,6 +378,7 @@ static bool cmd_split(struct sway_config *config, int argc, char **argv) {
sway_log(L_ERROR, "Invalid split command (expected either horiziontal or vertical).");
return false;
}
return true;
}

@ -50,13 +50,6 @@ swayc_t *new_output(wlc_handle handle) {
add_child(&root_container, output);
//TODO still dont know why this is here?
// int total_width = 0;
// int i;
// for (i = 0; i < root_container.children->length; ++i) {
// total_width += ((swayc_t*)root_container.children->items[i])->width;
// }
// Create workspace
char *ws_name = NULL;
if (name) {
@ -73,6 +66,7 @@ swayc_t *new_output(wlc_handle handle) {
if (!ws_name) {
ws_name = workspace_next_name();
}
// create and initilize default workspace
swayc_t *ws = new_workspace(output, ws_name);
ws->is_focused = true;
@ -129,9 +123,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
// give them proper layouts
cont->layout = workspace->layout;
workspace->layout = layout;
}
//Or is built around container
else {
} else { // Or is built around container
swayc_t *parent = replace_child(child, cont);
if (parent) {
add_child(cont, child);
@ -157,12 +149,11 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
// TODO: properly set this
view->is_floating = false;
//Case of focused workspace, just create as child of it
if (sibling->type == C_WORKSPACE) {
// Case of focused workspace, just create as child of it
add_child(sibling, view);
}
} else {
// Regular case, create as sibling of current container
else {
add_sibling(sibling, view);
}
return view;
@ -303,5 +294,3 @@ void set_view_visibility(swayc_t *view, void *data) {
}
view->visible = (*p == 2);
}

@ -8,7 +8,7 @@ bool locked_container_focus = false;
bool locked_view_focus = false;
// switches parent focus to c. will switch it accordingly
//TODO, everything needs a handle, so we can set front/back position properly
// TODO: Everything needs a handle, so we can set front/back position properly
static void update_focus(swayc_t *c) {
// Handle if focus switches
swayc_t *parent = c->parent;
@ -189,4 +189,3 @@ swayc_t *get_focused_view(swayc_t *parent) {
}
return parent;
}

@ -220,14 +220,13 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
swayc_t *c = NULL;
switch(state) {
case WLC_BIT_FULLSCREEN:
//I3 just lets it become fullscreen
// i3 just lets it become fullscreen
wlc_view_set_state(view, state, toggle);
c = get_swayc_for_handle(view, &root_container);
sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle);
if (c) {
arrange_windows(c->parent, -1, -1);
//Set it as focused window for that workspace if its going
//fullscreen
// Set it as focused window for that workspace if its going fullscreen
if (toggle) {
swayc_t *ws = c;
while (ws->type != C_WORKSPACE) {
@ -248,8 +247,8 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
}
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
*modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) {
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
uint32_t key, uint32_t sym, enum wlc_key_state state) {
enum { QSIZE = 32 };
if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) {
return false;

@ -63,8 +63,8 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
swayc_t *remove_child(swayc_t *child) {
int i;
swayc_t *parent = child->parent;
// Special case for floating views
if (child->is_floating) {
// Special case for floating views
for (i = 0; i < parent->floating->length; ++i) {
if (parent->floating->items[i] == child) {
list_del(parent->floating, i);

@ -17,8 +17,7 @@ static const char *verbosity_colors[] = {
void init_log(int verbosity) {
v = verbosity;
/* set FD_CLOEXEC flag to prevent programs called with exec to write into
* logs */
/* set FD_CLOEXEC flag to prevent programs called with exec to write into logs */
int i, flag;
int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO };
for (i = 0; i < 3; ++i) {

Loading…
Cancel
Save