mirror of
https://github.com/swaywm/sway.git
synced 2026-04-30 06:46:24 -04:00
Changed to used list_getp
This commit is contained in:
parent
a4eeedfa34
commit
508200e83d
38 changed files with 249 additions and 249 deletions
|
|
@ -198,7 +198,7 @@ static void render_title_bar(swayc_t *view, cairo_t *cr, struct wlc_geometry *b,
|
|||
int total_len = 0;
|
||||
|
||||
for(int i = view->marks->length - 1; i >= 0; --i) {
|
||||
char *mark = *(char **)list_get(view->marks, i);
|
||||
char *mark = list_getp(view->marks, i);
|
||||
if (*mark != '_') {
|
||||
int width, height;
|
||||
get_text_size(cr, config->font, &width, &height, 1, false, "[%s]", mark);
|
||||
|
|
@ -273,7 +273,7 @@ static char *generate_container_title(swayc_t *container) {
|
|||
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
prev_name = name;
|
||||
swayc_t* child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t* child = list_getp(container->children, i);
|
||||
const char *title = NULL;
|
||||
if (child->type == C_VIEW) {
|
||||
title = child->app_id ? child->app_id :
|
||||
|
|
@ -330,7 +330,7 @@ void update_tabbed_stacked_titlebars(swayc_t *c, cairo_t *cr, struct wlc_geometr
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < c->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(c->children, i);
|
||||
swayc_t *child = list_getp(c->children, i);
|
||||
update_tabbed_stacked_titlebars(child, cr, g, focused, focused_inactive);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -401,7 +401,7 @@ static void update_view_border(swayc_t *view) {
|
|||
|
||||
// generate container titles
|
||||
for (size_t i = 0; i < p->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(p->children, i);
|
||||
swayc_t *child = list_getp(p->children, i);
|
||||
if (child->type == C_CONTAINER) {
|
||||
generate_container_title(child);
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ void update_container_border(swayc_t *container) {
|
|||
return;
|
||||
} else {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
update_container_border(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void input_cmd_apply(struct input_config *input) {
|
|||
// will be applied during normal "new input" event from wlc.
|
||||
struct libinput_device *device = NULL;
|
||||
for (size_t i = 0; i < input_devices->length; ++i) {
|
||||
device = *(struct libinput_device **)list_get(input_devices, i);
|
||||
device = list_getp(input_devices, i);
|
||||
char* dev_identifier = libinput_dev_unique_id(device);
|
||||
if (!dev_identifier) {
|
||||
break;
|
||||
|
|
@ -138,7 +138,7 @@ void input_cmd_apply(struct input_config *input) {
|
|||
|
||||
void remove_view_from_scratchpad(swayc_t *view) {
|
||||
for (size_t i = 0; i < scratchpad->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(scratchpad, i);
|
||||
swayc_t *item = list_getp(scratchpad, i);
|
||||
if (item == view) {
|
||||
if (sp_index == 0) {
|
||||
sp_index = scratchpad->length - 1;
|
||||
|
|
@ -454,7 +454,7 @@ struct cmd_results *handle_command(char *_exec, enum command_context context) {
|
|||
} else if (containers->length == 0) {
|
||||
break;
|
||||
} else {
|
||||
current_container = *(swayc_t **)list_get(containers, i);
|
||||
current_container = list_getp(containers, i);
|
||||
}
|
||||
sway_log(L_INFO, "Running on container '%s'", current_container->name);
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ struct cmd_results *config_commands_command(char *exec) {
|
|||
|
||||
struct command_policy *policy = NULL;
|
||||
for (size_t i = 0; i < config->command_policies->length; ++i) {
|
||||
struct command_policy *p = *(struct command_policy **)list_get(config->command_policies, i);
|
||||
struct command_policy *p = list_getp(config->command_policies, i);
|
||||
if (strcmp(p->command, cmd) == 0) {
|
||||
policy = p;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
|
|||
|
||||
// set bar id
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
if (bar == *(struct bar_config **)list_get(config->bars, i)) {
|
||||
if (bar == list_getp(config->bars, i)) {
|
||||
const int len = 5 + numlen(i); // "bar-" + i + \0
|
||||
bar->id = malloc(len * sizeof(char));
|
||||
if (bar->id) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
struct bar_config *bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
struct bar_config *bar = list_getp(config->bars, i);
|
||||
if (id && strcmp(id, bar->id) == 0) {
|
||||
return bar_set_hidden_state(bar, state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
|||
|
||||
// check if id is used by a previously defined bar
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
struct bar_config *find = *(struct bar_config **)list_get(config->bars, i);
|
||||
struct bar_config *find = list_getp(config->bars, i);
|
||||
if (strcmp(name, find->id) == 0 && config->current_bar != find) {
|
||||
return cmd_results_new(CMD_FAILURE, "id",
|
||||
"Id '%s' already defined for another bar. Id unchanged (%s).",
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
struct bar_config *bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
struct bar_config *bar = list_getp(config->bars, i);
|
||||
if (id && strcmp(id, bar->id) == 0) {
|
||||
return bar_set_mode(bar, mode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
|||
list_t *split = split_string(argv[0], "+");
|
||||
for (size_t i = 0; i < split->length; ++i) {
|
||||
uint32_t tmp_mod;
|
||||
char *item = *(char **)list_get(split, i);
|
||||
char *item = list_getp(split, i);
|
||||
if ((tmp_mod = get_modifier_mask_by_name(item)) > 0) {
|
||||
mod |= tmp_mod;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
|||
if (strcmp("*", output) == 0) {
|
||||
// remove all previous defined outputs and replace with '*'
|
||||
for (size_t i = 0; i < outputs->length; ++i) {
|
||||
char *item = *(char **)list_get(outputs, i);
|
||||
char *item = list_getp(outputs, i);
|
||||
free(item);
|
||||
list_delete(outputs, i);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
|||
// only add output if not already defined with either the same
|
||||
// name or as '*'
|
||||
for (size_t i = 0; i < outputs->length; ++i) {
|
||||
const char *find = *(char **)list_get(outputs, i);
|
||||
const char *find = list_getp(outputs, i);
|
||||
if (strcmp("*", find) == 0 || strcmp(output, find) == 0) {
|
||||
add_output = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
|||
for (size_t i = 0; i < split->length; ++i) {
|
||||
// Check for a modifier key
|
||||
uint32_t mod;
|
||||
char *item = *(char **)list_get(split, i);
|
||||
char *item = list_getp(split, i);
|
||||
if ((mod = get_modifier_mask_by_name(item)) > 0) {
|
||||
binding->modifiers |= mod;
|
||||
continue;
|
||||
|
|
@ -131,7 +131,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
|||
for (size_t i = 0; i < split->length; ++i) {
|
||||
// Check for a modifier key
|
||||
uint32_t mod;
|
||||
char *item = *(char **)list_get(split, i);
|
||||
char *item = list_getp(split, i);
|
||||
if ((mod = get_modifier_mask_by_name(item)) > 0) {
|
||||
binding->modifiers |= mod;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
|||
|
||||
// set modifier keys
|
||||
for (size_t i = 0; i < split->length; ++i) {
|
||||
config->floating_mod |= get_modifier_mask_by_name(*(char **)list_get(split, i));
|
||||
config->floating_mod |= get_modifier_mask_by_name(list_getp(split, i));
|
||||
}
|
||||
free_flat_list(split);
|
||||
if (!config->floating_mod) {
|
||||
|
|
|
|||
|
|
@ -60,17 +60,17 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
|
|||
if (focused->is_floating) {
|
||||
if (workspace->children->length > 0) {
|
||||
for (size_t i = 0;i < workspace->floating->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->floating, i);
|
||||
swayc_t *item = list_getp(workspace->floating, i);
|
||||
if (item == focused) {
|
||||
floating_toggled_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (workspace->children->length > tiled_toggled_index) {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->children, tiled_toggled_index);
|
||||
swayc_t *item = list_getp(workspace->children, tiled_toggled_index);
|
||||
set_focused_container(get_focused_view(item));
|
||||
} else {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->children, 0);
|
||||
swayc_t *item = list_getp(workspace->children, 0);
|
||||
set_focused_container(get_focused_view(item));
|
||||
tiled_toggled_index = 0;
|
||||
}
|
||||
|
|
@ -78,17 +78,17 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
|
|||
} else {
|
||||
if (workspace->floating->length > 0) {
|
||||
for (size_t i = 0;i < workspace->children->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->children, i);
|
||||
swayc_t *item = list_getp(workspace->children, i);
|
||||
if (item == focused) {
|
||||
tiled_toggled_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (workspace->floating->length > floating_toggled_index) {
|
||||
swayc_t *floating = *(swayc_t **)list_get(workspace->floating, floating_toggled_index);
|
||||
swayc_t *floating = list_getp(workspace->floating, floating_toggled_index);
|
||||
set_focused_container(get_focused_view(floating));
|
||||
} else {
|
||||
swayc_t *floating = *(swayc_t **)list_get(workspace->floating, workspace->floating->length - 1);
|
||||
swayc_t *floating = list_getp(workspace->floating, workspace->floating->length - 1);
|
||||
set_focused_container(get_focused_view(floating));
|
||||
tiled_toggled_index = workspace->floating->length - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,9 +134,9 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
|
|||
} else if (inout == OUTER) {
|
||||
//resize all workspace.
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *op = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *op = list_getp(root_container.children, i);
|
||||
for (size_t j = 0; j < op->children->length; ++j) {
|
||||
swayc_t *ws = *(swayc_t **)list_get(op->children, j);
|
||||
swayc_t *ws = list_getp(op->children, j);
|
||||
if (method == SET) {
|
||||
ws->gaps = amount;
|
||||
} else if ((ws->gaps += amount) < 0) {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ static struct cmd_results *cmd_layout_auto(swayc_t *container, int argc, char **
|
|||
for (int i = container->nb_master;
|
||||
i >= 0 && (size_t)i < container->children->length
|
||||
&& i != (int)container->nb_master + inc;) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
item->height = -1;
|
||||
item->width = -1;
|
||||
i += inc > 0 ? 1 : -1;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
|
|||
struct sway_mode *mode = NULL;
|
||||
// Find mode
|
||||
for (size_t i = 0; i < config->modes->length; ++i) {
|
||||
struct sway_mode *find = *(struct sway_mode **)list_get(config->modes, i);
|
||||
struct sway_mode *find = list_getp(config->modes, i);
|
||||
if (strcasecmp(find->name, mode_name) == 0) {
|
||||
mode = find;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ struct cmd_results *cmd_move(int argc, char **argv) {
|
|||
}
|
||||
swayc_t *view = current_container;
|
||||
for (size_t i = 0; i < scratchpad->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(scratchpad, i);
|
||||
swayc_t *item = list_getp(scratchpad, i);
|
||||
if (item == view) {
|
||||
hide_view_in_scratchpad(view);
|
||||
sp_view = NULL;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
|||
// will be applied during normal "new output" event from wlc.
|
||||
swayc_t *cont = NULL;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
cont = *(swayc_t **)list_get(root_container.children, i);
|
||||
cont = list_getp(root_container.children, i);
|
||||
if (cont->name && ((strcmp(cont->name, output->name) == 0) || (strcmp(output->name, "*") == 0))) {
|
||||
apply_output_config(output, cont);
|
||||
|
||||
|
|
|
|||
|
|
@ -118,12 +118,12 @@ static bool resize_tiled(int amount, bool use_width) {
|
|||
// 2. Ensure that the resize operation will not make one of the resized containers drop
|
||||
// below the "sane" size threshold.
|
||||
bool valid = true;
|
||||
swayc_t *focused = *(swayc_t **)list_get(parent->children, idx_focused);
|
||||
swayc_t *focused = list_getp(parent->children, idx_focused);
|
||||
size_t start = use_major ? 0 : (size_t)auto_group_start_index(parent, idx_focused);
|
||||
size_t end = use_major ? parent->children->length : (size_t)auto_group_end_index(parent, idx_focused);
|
||||
sway_log(L_DEBUG, "Check children of container %p [%zu,%zu[", container, start, end);
|
||||
for (size_t i = start; i < end; ) {
|
||||
swayc_t *sibling = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *sibling = list_getp(parent->children, i);
|
||||
double pixels = amount;
|
||||
bool is_before = use_width ? sibling->x < focused->x : sibling->y < focused->y;
|
||||
bool is_after = use_width ? sibling->x > focused->x : sibling->y > focused->y;
|
||||
|
|
@ -149,7 +149,7 @@ static bool resize_tiled(int amount, bool use_width) {
|
|||
if (valid) {
|
||||
for (size_t i = start; i < end; ) {
|
||||
int next_i = use_major ? (size_t)auto_group_end_index(parent, i) : (i + 1);
|
||||
swayc_t *sibling = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *sibling = list_getp(parent->children, i);
|
||||
double pixels = amount;
|
||||
bool is_before = use_width ? sibling->x < focused->x : sibling->y < focused->y;
|
||||
bool is_after = use_width ? sibling->x > focused->x : sibling->y > focused->y;
|
||||
|
|
@ -162,7 +162,7 @@ static bool resize_tiled(int amount, bool use_width) {
|
|||
sway_log(L_DEBUG, "%p: %s", sibling, is_before ? "before" : "after");
|
||||
if (use_major) {
|
||||
for (int j = i; j < next_i; ++j) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->children, j);
|
||||
swayc_t *item = list_getp(parent->children, j);
|
||||
recursive_resize(item, pixels,
|
||||
use_width ?
|
||||
(is_before ? WLC_RESIZE_EDGE_RIGHT : WLC_RESIZE_EDGE_LEFT) :
|
||||
|
|
@ -177,7 +177,7 @@ static bool resize_tiled(int amount, bool use_width) {
|
|||
} else {
|
||||
if (use_major) {
|
||||
for (int j = i; j < next_i; ++j) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->children, j);
|
||||
swayc_t *item = list_getp(parent->children, j);
|
||||
recursive_resize(item, pixels / 2,
|
||||
use_width ? WLC_RESIZE_EDGE_LEFT : WLC_RESIZE_EDGE_TOP);
|
||||
recursive_resize(item, pixels / 2,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ static swayc_t *fetch_view_from_scratchpad() {
|
|||
if ((size_t)sp_index >= scratchpad->length) {
|
||||
sp_index = 0;
|
||||
}
|
||||
swayc_t *view = *(swayc_t **)list_get(scratchpad, sp_index++);
|
||||
swayc_t *view = list_getp(scratchpad, sp_index++);
|
||||
|
||||
if (wlc_view_get_output(view->handle) != swayc_active_output()->handle) {
|
||||
wlc_view_set_output(view->handle, swayc_active_output()->handle);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ struct cmd_results *cmd_set(int argc, char **argv) {
|
|||
struct sway_variable *var = NULL;
|
||||
// Find old variable if it exists
|
||||
for (size_t i = 0; i < config->symbols->length; ++i) {
|
||||
var = *(struct sway_variable **)list_get(config->symbols, i);
|
||||
var = list_getp(config->symbols, i);
|
||||
if (strcmp(var->name, argv[0]) == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ static void free_mode(struct sway_mode *mode) {
|
|||
}
|
||||
free(mode->name);
|
||||
for (size_t i = 0; mode->bindings && i < mode->bindings->length; ++i) {
|
||||
free_binding(*(struct sway_binding **)list_get(mode->bindings, i));
|
||||
free_binding(list_getp(mode->bindings, i));
|
||||
}
|
||||
list_free(mode->bindings);
|
||||
free(mode);
|
||||
|
|
@ -72,7 +72,7 @@ static void free_bar(struct bar_config *bar) {
|
|||
free(bar->font);
|
||||
free(bar->separator_symbol);
|
||||
for (size_t i = 0; bar->bindings && i < bar->bindings->length; ++i) {
|
||||
free_sway_mouse_binding(*(struct sway_mouse_binding **)list_get(bar->bindings, i));
|
||||
free_sway_mouse_binding(list_getp(bar->bindings, i));
|
||||
}
|
||||
list_free(bar->bindings);
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ static void pid_workspace_cleanup() {
|
|||
// work backwards through list and remove any entries
|
||||
// older than PID_WORKSPACE_TIMEOUT
|
||||
for (ssize_t i = config->pid_workspaces->length - 1; i > -1; i--) {
|
||||
pw = *(struct pid_workspace **)list_get(config->pid_workspaces, i);
|
||||
pw = list_getp(config->pid_workspaces, i);
|
||||
|
||||
if (difftime(ts.tv_sec, *pw->time_added) >= PID_WORKSPACE_TIMEOUT) {
|
||||
free_pid_workspace(pw);
|
||||
|
|
@ -173,7 +173,7 @@ void pid_workspace_add(struct pid_workspace *pw) {
|
|||
// work backwards through list and delete any entries that
|
||||
// have the same pid as that in our new pid_workspace
|
||||
for (ssize_t i = config->pid_workspaces->length - 1; i > -1; i--) {
|
||||
list_pw = *(struct pid_workspace **)list_get(config->pid_workspaces, i);
|
||||
list_pw = list_getp(config->pid_workspaces, i);
|
||||
|
||||
if (pw->pid == list_pw->pid) {
|
||||
free_pid_workspace(list_pw);
|
||||
|
|
@ -216,59 +216,59 @@ void free_config(struct sway_config *config) {
|
|||
}
|
||||
size_t i;
|
||||
for (i = 0; config->symbols && i < config->symbols->length; ++i) {
|
||||
free_variable(*(struct sway_variable **)list_get(config->symbols, i));
|
||||
free_variable(list_getp(config->symbols, i));
|
||||
}
|
||||
list_free(config->symbols);
|
||||
|
||||
for (i = 0; config->modes && i < config->modes->length; ++i) {
|
||||
free_mode(*(struct sway_mode **)list_get(config->modes, i));
|
||||
free_mode(list_getp(config->modes, i));
|
||||
}
|
||||
list_free(config->modes);
|
||||
|
||||
for (i = 0; config->bars && i < config->bars->length; ++i) {
|
||||
free_bar(*(struct bar_config **)list_get(config->bars, i));
|
||||
free_bar(list_getp(config->bars, i));
|
||||
}
|
||||
list_free(config->bars);
|
||||
|
||||
free_flat_list(config->cmd_queue);
|
||||
|
||||
for (i = 0; config->workspace_outputs && i < config->workspace_outputs->length; ++i) {
|
||||
free_workspace_output(*(struct workspace_output **)list_get(config->workspace_outputs, i));
|
||||
free_workspace_output(list_getp(config->workspace_outputs, i));
|
||||
}
|
||||
list_free(config->workspace_outputs);
|
||||
|
||||
for (i = 0; config->pid_workspaces && i < config->pid_workspaces->length; ++i) {
|
||||
free_pid_workspace(*(struct pid_workspace **)list_get(config->pid_workspaces, i));
|
||||
free_pid_workspace(list_getp(config->pid_workspaces, i));
|
||||
}
|
||||
list_free(config->pid_workspaces);
|
||||
|
||||
for (i = 0; config->criteria && i < config->criteria->length; ++i) {
|
||||
free_criteria(*(struct criteria **)list_get(config->criteria, i));
|
||||
free_criteria(list_getp(config->criteria, i));
|
||||
}
|
||||
list_free(config->criteria);
|
||||
|
||||
for (i = 0; config->no_focus && i < config->no_focus->length; ++i) {
|
||||
free_criteria(*(struct criteria **)list_get(config->no_focus, i));
|
||||
free_criteria(list_getp(config->no_focus, i));
|
||||
}
|
||||
list_free(config->no_focus);
|
||||
|
||||
for (i = 0; config->input_configs && i < config->input_configs->length; ++i) {
|
||||
free_input_config(*(struct input_config **)list_get(config->input_configs, i));
|
||||
free_input_config(list_getp(config->input_configs, i));
|
||||
}
|
||||
list_free(config->input_configs);
|
||||
|
||||
for (i = 0; config->output_configs && i < config->output_configs->length; ++i) {
|
||||
free_output_config(*(struct output_config **)list_get(config->output_configs, i));
|
||||
free_output_config(list_getp(config->output_configs, i));
|
||||
}
|
||||
list_free(config->output_configs);
|
||||
|
||||
for (i = 0; config->command_policies && i < config->command_policies->length; ++i) {
|
||||
free_command_policy(*(struct command_policy **)list_get(config->command_policies, i));
|
||||
free_command_policy(list_getp(config->command_policies, i));
|
||||
}
|
||||
list_free(config->command_policies);
|
||||
|
||||
for (i = 0; config->feature_policies && i < config->feature_policies->length; ++i) {
|
||||
free_feature_policy(*(struct feature_policy **)list_get(config->feature_policies, i));
|
||||
free_feature_policy(list_getp(config->feature_policies, i));
|
||||
}
|
||||
list_free(config->feature_policies);
|
||||
|
||||
|
|
@ -409,7 +409,7 @@ void update_active_bar_modifiers() {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
struct bar_config *bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
struct bar_config *bar = list_getp(config->bars, i);
|
||||
if (strcmp(bar->mode, "hide") == 0 && strcmp(bar->hidden_state, "hide") == 0) {
|
||||
if (list_lsearch(config->active_bar_modifiers, compare_modifiers, &bar->modifier, NULL) < 0) {
|
||||
list_add(config->active_bar_modifiers, &bar->modifier);
|
||||
|
|
@ -549,7 +549,7 @@ bool load_main_config(const char *file, bool is_active) {
|
|||
|
||||
list_qsort(secconfigs, qstrcmp);
|
||||
for (size_t i = 0; i < secconfigs->length; ++i) {
|
||||
char *_path = *(char **)list_get(secconfigs, i);
|
||||
char *_path = list_getp(secconfigs, i);
|
||||
if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (((s.st_mode & 0777) != 0644) && (s.st_mode & 0777) != 0444)) {
|
||||
sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644 or 444", _path);
|
||||
success = false;
|
||||
|
|
@ -605,7 +605,7 @@ static bool load_include_config(const char *path, const char *parent_dir, struct
|
|||
|
||||
// check if config has already been included
|
||||
for (size_t j = 0; j < config->config_chain->length; ++j) {
|
||||
char *old_path = *(char **)list_get(config->config_chain, j);
|
||||
char *old_path = list_getp(config->config_chain, j);
|
||||
if (strcmp(real_path, old_path) == 0) {
|
||||
sway_log(L_DEBUG, "%s already included once, won't be included again.", real_path);
|
||||
free(real_path);
|
||||
|
|
@ -774,7 +774,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
|||
switch(block) {
|
||||
case CMD_BLOCK_MODE:
|
||||
sway_log(L_DEBUG, "End of mode block");
|
||||
config->current_mode = *(struct sway_mode **)list_get(config->modes, 0);
|
||||
config->current_mode = list_getp(config->modes, 0);
|
||||
block = CMD_BLOCK_END;
|
||||
break;
|
||||
|
||||
|
|
@ -1000,7 +1000,7 @@ void terminate_swaybg(pid_t pid) {
|
|||
|
||||
static bool active_output(const char *name) {
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *cont = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *cont = list_getp(root_container.children, i);
|
||||
if (cont->type == C_OUTPUT && strcasecmp(name, cont->name) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1014,11 +1014,11 @@ void load_swaybars() {
|
|||
list_t *bars = list_new(sizeof(struct bar_config *), 0);
|
||||
struct bar_config *bar = NULL;
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
bar = list_getp(config->bars, i);
|
||||
bool apply = false;
|
||||
if (bar->outputs) {
|
||||
for (size_t j = 0; j < bar->outputs->length; ++j) {
|
||||
char *o = *(char **)list_get(bar->outputs, j);
|
||||
char *o = list_getp(bar->outputs, j);
|
||||
if (!strcmp(o, "*") || active_output(o)) {
|
||||
apply = true;
|
||||
break;
|
||||
|
|
@ -1033,7 +1033,7 @@ void load_swaybars() {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < bars->length; ++i) {
|
||||
bar = *(struct bar_config **)list_get(bars, i);
|
||||
bar = list_getp(bars, i);
|
||||
if (bar->pid != 0) {
|
||||
terminate_swaybar(bar->pid);
|
||||
}
|
||||
|
|
@ -1123,7 +1123,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
|||
} else {
|
||||
int x = 0;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (c->type == C_OUTPUT) {
|
||||
if (c->width + c->x > x) {
|
||||
x = c->width + c->x;
|
||||
|
|
@ -1146,7 +1146,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
|||
|
||||
size_t output_i;
|
||||
for (output_i = 0; output_i < root_container.children->length; ++output_i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(root_container.children, output_i);
|
||||
swayc_t *item = list_getp(root_container.children, output_i);
|
||||
if (item == output) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -1192,7 +1192,7 @@ char *do_var_replacement(char *str) {
|
|||
size_t i;
|
||||
// Find matching variable
|
||||
for (i = 0; i < config->symbols->length; ++i) {
|
||||
struct sway_variable *var = *(struct sway_variable **)list_get(config->symbols, i);
|
||||
struct sway_variable *var = list_getp(config->symbols, i);
|
||||
int vnlen = strlen(var->name);
|
||||
if (strncmp(find, var->name, vnlen) == 0) {
|
||||
int vvlen = strlen(var->value);
|
||||
|
|
@ -1255,15 +1255,15 @@ int sway_binding_cmp_keys(const void *key, const void *item) {
|
|||
}
|
||||
struct wlc_modifiers no_mods = { 0, 0 };
|
||||
for (size_t i = 0; i < binda->keys->length; i++) {
|
||||
xkb_keysym_t ka = **(xkb_keysym_t **)list_get(binda->keys, i),
|
||||
kb = **(xkb_keysym_t **)list_get(bindb->keys, i);
|
||||
xkb_keysym_t ka = *(xkb_keysym_t *)list_getp(binda->keys, i),
|
||||
kb = *(xkb_keysym_t *)list_getp(bindb->keys, i);
|
||||
if (binda->bindcode) {
|
||||
uint32_t *keycode = *(uint32_t **)list_get(binda->keys, i);
|
||||
uint32_t *keycode = list_getp(binda->keys, i);
|
||||
ka = wlc_keyboard_get_keysym_for_key(*keycode, &no_mods);
|
||||
}
|
||||
|
||||
if (bindb->bindcode) {
|
||||
uint32_t *keycode = *(uint32_t **)list_get(bindb->keys, i);
|
||||
uint32_t *keycode = list_getp(bindb->keys, i);
|
||||
kb = wlc_keyboard_get_keysym_for_key(*keycode, &no_mods);
|
||||
}
|
||||
|
||||
|
|
@ -1293,7 +1293,7 @@ int sway_binding_cmp_qsort(const void *a, const void *b) {
|
|||
void free_sway_binding(struct sway_binding *binding) {
|
||||
if (binding->keys) {
|
||||
for (size_t i = 0; i < binding->keys->length; i++) {
|
||||
free(*(void **)list_get(binding->keys, i));
|
||||
free(list_getp(binding->keys, i));
|
||||
}
|
||||
list_free(binding->keys);
|
||||
}
|
||||
|
|
@ -1351,7 +1351,7 @@ struct sway_binding *sway_binding_dup(struct sway_binding *sb) {
|
|||
free_sway_binding(new_sb);
|
||||
return NULL;
|
||||
}
|
||||
*key = **(xkb_keysym_t **)list_get(sb->keys, i);
|
||||
*key = *(xkb_keysym_t *)list_getp(sb->keys, i);
|
||||
list_add(new_sb->keys, &key);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void free_swayc(swayc_t *cont) {
|
|||
// remove children until there are no more, free_swayc calls
|
||||
// remove_child, which removes child from this container
|
||||
while (cont->children->length) {
|
||||
free_swayc(*(swayc_t **)list_get(cont->children, 0));
|
||||
free_swayc(list_getp(cont->children, 0));
|
||||
}
|
||||
list_free(cont->children);
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ static void free_swayc(swayc_t *cont) {
|
|||
}
|
||||
if (cont->floating) {
|
||||
while (cont->floating->length) {
|
||||
free_swayc(*(swayc_t **)list_get(cont->floating, 0));
|
||||
free_swayc(list_getp(cont->floating, 0));
|
||||
}
|
||||
list_free(cont->floating);
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ static void update_root_geometry() {
|
|||
int child_height;
|
||||
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
child = *(swayc_t **)list_get(root_container.children, i);
|
||||
child = list_getp(root_container.children, i);
|
||||
child_width = child->width + child->x;
|
||||
child_height = child->height + child->y;
|
||||
if (child_width > width) {
|
||||
|
|
@ -124,7 +124,7 @@ swayc_t *new_output(wlc_handle handle) {
|
|||
const char *name = wlc_output_get_name(handle);
|
||||
// Find current outputs to see if this already exists
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *op = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *op = list_getp(root_container.children, i);
|
||||
const char *op_name = op->name;
|
||||
if (op_name && name && strcmp(op_name, name) == 0) {
|
||||
sway_log(L_DEBUG, "restoring output %" PRIuPTR ":%s", handle, op_name);
|
||||
|
|
@ -136,7 +136,7 @@ swayc_t *new_output(wlc_handle handle) {
|
|||
|
||||
struct output_config *oc = NULL, *all = NULL;
|
||||
for (size_t i = 0; i < config->output_configs->length; ++i) {
|
||||
struct output_config *cur = *(struct output_config **)list_get(config->output_configs, i);
|
||||
struct output_config *cur = list_getp(config->output_configs, i);
|
||||
if (strcasecmp(name, cur->name) == 0) {
|
||||
sway_log(L_DEBUG, "Matched output config for %s", name);
|
||||
oc = cur;
|
||||
|
|
@ -177,7 +177,7 @@ swayc_t *new_output(wlc_handle handle) {
|
|||
|
||||
if (name) {
|
||||
for (size_t i = 0; i < config->workspace_outputs->length; ++i) {
|
||||
struct workspace_output *wso = *(struct workspace_output **)list_get(config->workspace_outputs, i);
|
||||
struct workspace_output *wso = list_getp(config->workspace_outputs, i);
|
||||
if (strcasecmp(wso->output, name) == 0) {
|
||||
sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
|
||||
// Check if any other workspaces are using this name
|
||||
|
|
@ -202,7 +202,7 @@ swayc_t *new_output(wlc_handle handle) {
|
|||
ws->is_focused = true;
|
||||
} else {
|
||||
sort_workspaces(output);
|
||||
set_focused_container(*(swayc_t **)list_get(output->children, 0));
|
||||
set_focused_container(list_getp(output->children, 0));
|
||||
}
|
||||
|
||||
free(ws_name);
|
||||
|
|
@ -262,7 +262,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
|
|||
workspace->focused = cont;
|
||||
// set all children focu to container
|
||||
for (size_t i = 0; i < workspace->children->length; ++i) {
|
||||
(*(swayc_t **)list_get(workspace->children, i))->parent = cont;
|
||||
((swayc_t *)list_getp(workspace->children, i))->parent = cont;
|
||||
}
|
||||
// Swap children
|
||||
list_t *tmp_list = workspace->children;
|
||||
|
|
@ -432,11 +432,11 @@ swayc_t *destroy_output(swayc_t *output) {
|
|||
// TODO also check if there will ever be no outputs except for exiting
|
||||
// program
|
||||
if (root_container.children->length > 1) {
|
||||
int p = *(swayc_t **)list_get(root_container.children, 0) == output;
|
||||
int p = list_getp(root_container.children, 0) == output;
|
||||
// Move workspace from this output to another output
|
||||
swayc_t *item = *(swayc_t **)list_get(root_container.children, p);
|
||||
swayc_t *item = list_getp(root_container.children, p);
|
||||
while (output->children->length) {
|
||||
swayc_t *child = *(swayc_t **)list_get(output->children, 0);
|
||||
swayc_t *child = list_getp(output->children, 0);
|
||||
remove_child(child);
|
||||
add_child(item, child);
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
|
|||
// Move children to a different workspace on this output
|
||||
swayc_t *new_workspace = NULL;
|
||||
for(size_t i = 0; i < output->children->length; i++) {
|
||||
new_workspace = *(swayc_t **)list_get(output->children, i);
|
||||
new_workspace = list_getp(output->children, i);
|
||||
if (new_workspace != workspace) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -481,12 +481,12 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
|
|||
workspace->name, new_workspace->name);
|
||||
|
||||
for (size_t i = 0; i < workspace->children->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->children, i);
|
||||
swayc_t *item = list_getp(workspace->children, i);
|
||||
move_container_to(item, new_workspace);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < workspace->floating->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(workspace->floating, i);
|
||||
swayc_t *item = list_getp(workspace->floating, i);
|
||||
move_container_to(item, new_workspace);
|
||||
}
|
||||
}
|
||||
|
|
@ -533,14 +533,14 @@ swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *dat
|
|||
// Special case for checking floating stuff
|
||||
if (container->type == C_WORKSPACE) {
|
||||
for (size_t i = 0; i < container->floating->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->floating, i);
|
||||
swayc_t *child = list_getp(container->floating, i);
|
||||
if (test(child, data)) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
if (test(child, data)) {
|
||||
return child;
|
||||
} else {
|
||||
|
|
@ -718,7 +718,7 @@ swayc_t *container_under_pointer(void) {
|
|||
i = len = lookup->floating->length;
|
||||
bool got_floating = false;
|
||||
while (--i > -1) {
|
||||
swayc_t *item = *(swayc_t **)list_get(lookup->floating, i);
|
||||
swayc_t *item = list_getp(lookup->floating, i);
|
||||
if (pointer_test(item, &origin)) {
|
||||
lookup = item;
|
||||
got_floating = true;
|
||||
|
|
@ -732,7 +732,7 @@ swayc_t *container_under_pointer(void) {
|
|||
// search children
|
||||
size_t i, len = lookup->children->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(lookup->children, i);
|
||||
swayc_t *item = list_getp(lookup->children, i);
|
||||
if (pointer_test(item, &origin)) {
|
||||
lookup = item;
|
||||
break;
|
||||
|
|
@ -754,7 +754,7 @@ swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *),
|
|||
swayc_t *con;
|
||||
if (container->type == C_WORKSPACE) {
|
||||
for (size_t i = 0; i < container->floating->length; ++i) {
|
||||
con = *(swayc_t **)list_get(container->floating, i);
|
||||
con = list_getp(container->floating, i);
|
||||
if (f(con, data)) {
|
||||
return con;
|
||||
}
|
||||
|
|
@ -766,7 +766,7 @@ swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *),
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
con = *(swayc_t **)list_get(container->children, i);
|
||||
con = list_getp(container->children, i);
|
||||
if (f(con, data)) {
|
||||
return con;
|
||||
}
|
||||
|
|
@ -836,13 +836,13 @@ void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), voi
|
|||
f(container, data);
|
||||
if (container->children) {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
container_map(child, f, data);
|
||||
}
|
||||
}
|
||||
if (container->floating) {
|
||||
for (size_t i = 0; i < container->floating->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->floating, i);
|
||||
swayc_t *child = list_getp(container->floating, i);
|
||||
container_map(child, f, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -867,13 +867,13 @@ void update_visibility_output(swayc_t *container, wlc_handle output) {
|
|||
else {
|
||||
if (container->children) {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
update_visibility_output(item, output);
|
||||
}
|
||||
}
|
||||
if (container->floating) {
|
||||
for (size_t i = 0; i < container->floating->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->floating, i);
|
||||
swayc_t *item = list_getp(container->floating, i);
|
||||
update_visibility_output(item, output);
|
||||
}
|
||||
}
|
||||
|
|
@ -887,7 +887,7 @@ void update_visibility(swayc_t *container) {
|
|||
container->visible = true;
|
||||
if (container->children) {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
update_visibility(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -897,7 +897,7 @@ void update_visibility(swayc_t *container) {
|
|||
container->visible = true;
|
||||
if (container->children) {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
update_visibility_output(item, container->handle);
|
||||
}
|
||||
}
|
||||
|
|
@ -980,7 +980,7 @@ swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) {
|
|||
? L_HORIZ : L_VERT;
|
||||
if (new_major != prev_major) {
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
double h = child->height;
|
||||
child->height = child->width;
|
||||
child->width = h;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static void free_crit_token(struct crit_token *crit) {
|
|||
|
||||
static void free_crit_tokens(list_t *crit_tokens) {
|
||||
for (size_t i = 0; i < crit_tokens->length; i++) {
|
||||
free_crit_token(*(struct crit_token **)list_get(crit_tokens, i));
|
||||
free_crit_token(list_getp(crit_tokens, i));
|
||||
}
|
||||
list_free(crit_tokens);
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
|
|||
}
|
||||
size_t matches = 0;
|
||||
for (size_t i = 0; i < tokens->length; i++) {
|
||||
struct crit_token *crit = *(struct crit_token **)list_get(tokens, i);
|
||||
struct crit_token *crit = list_getp(tokens, i);
|
||||
switch (crit->type) {
|
||||
case CRIT_CLASS:
|
||||
if (!cont->class) {
|
||||
|
|
@ -365,7 +365,7 @@ void free_criteria(struct criteria *crit) {
|
|||
|
||||
bool criteria_any(swayc_t *cont, list_t *criteria) {
|
||||
for (size_t i = 0; i < criteria->length; i++) {
|
||||
struct criteria *bc = *(struct criteria **)list_get(criteria, i);
|
||||
struct criteria *bc = list_getp(criteria, i);
|
||||
if (criteria_test(cont, bc->tokens)) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ bool criteria_any(swayc_t *cont, list_t *criteria) {
|
|||
list_t *criteria_for(swayc_t *cont) {
|
||||
list_t *matches = list_new(sizeof(struct criteria *), 0);
|
||||
for (size_t i = 0; i < config->criteria->length; i++) {
|
||||
struct criteria *bc = *(struct criteria **)list_get(config->criteria, i);
|
||||
struct criteria *bc = list_getp(config->criteria, i);
|
||||
if (criteria_test(cont, bc->tokens)) {
|
||||
list_add(matches, &bc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void layout_log(const swayc_t *c, int depth) {
|
|||
for (i = 0; i < e; ++i) {
|
||||
fputc('|',stderr);
|
||||
for (d = 0; d < depth; ++d) fputc('-', stderr);
|
||||
layout_log(*(swayc_t **)list_get(c->children, i), depth + 1);
|
||||
layout_log(list_getp(c->children, i), depth + 1);
|
||||
}
|
||||
}
|
||||
if (c->type == C_WORKSPACE) {
|
||||
|
|
@ -68,7 +68,7 @@ void layout_log(const swayc_t *c, int depth) {
|
|||
for (i = 0; i < e; ++i) {
|
||||
fputc('|',stderr);
|
||||
for (d = 0; d < depth; ++d) fputc('=', stderr);
|
||||
layout_log(*(swayc_t **)list_get(c->floating, i), depth + 1);
|
||||
layout_log(list_getp(c->floating, i), depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct desktop_shell_state desktop_shell;
|
|||
|
||||
static struct panel_config *find_or_create_panel_config(struct wl_resource *resource) {
|
||||
for (size_t i = 0; i < desktop_shell.panels->length; i++) {
|
||||
struct panel_config *conf = *(struct panel_config **)list_get(desktop_shell.panels, i);
|
||||
struct panel_config *conf = list_getp(desktop_shell.panels, i);
|
||||
if (conf->wl_resource == resource) {
|
||||
sway_log(L_DEBUG, "Found existing panel config for resource %p", resource);
|
||||
return conf;
|
||||
|
|
@ -36,7 +36,7 @@ static struct panel_config *find_or_create_panel_config(struct wl_resource *reso
|
|||
void background_surface_destructor(struct wl_resource *resource) {
|
||||
sway_log(L_DEBUG, "Background surface killed");
|
||||
for (size_t i = 0; i < desktop_shell.backgrounds->length; ++i) {
|
||||
struct background_config *config = *(struct background_config **)list_get(desktop_shell.backgrounds, i);
|
||||
struct background_config *config = list_getp(desktop_shell.backgrounds, i);
|
||||
if (config->wl_surface_res == resource) {
|
||||
list_delete(desktop_shell.backgrounds, i);
|
||||
break;
|
||||
|
|
@ -47,7 +47,7 @@ void background_surface_destructor(struct wl_resource *resource) {
|
|||
void panel_surface_destructor(struct wl_resource *resource) {
|
||||
sway_log(L_DEBUG, "Panel surface killed");
|
||||
for (size_t i = 0; i < desktop_shell.panels->length; ++i) {
|
||||
struct panel_config *config = *(struct panel_config **)list_get(desktop_shell.panels, i);
|
||||
struct panel_config *config = list_getp(desktop_shell.panels, i);
|
||||
if (config->wl_surface_res == resource) {
|
||||
list_delete(desktop_shell.panels, i);
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
|
|
@ -59,7 +59,7 @@ void panel_surface_destructor(struct wl_resource *resource) {
|
|||
void lock_surface_destructor(struct wl_resource *resource) {
|
||||
sway_log(L_DEBUG, "Lock surface killed");
|
||||
for (size_t i = 0; i < desktop_shell.lock_surfaces->length; ++i) {
|
||||
struct wl_resource *surface = *(struct wl_resource **)list_get(desktop_shell.lock_surfaces, i);
|
||||
struct wl_resource *surface = list_getp(desktop_shell.lock_surfaces, i);
|
||||
if (surface == resource) {
|
||||
list_delete(desktop_shell.lock_surfaces, i);
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ swayc_t *get_focused_float(swayc_t *ws) {
|
|||
ws = swayc_active_workspace();
|
||||
}
|
||||
if (ws->floating->length) {
|
||||
return *(swayc_t **)list_get(ws->floating, ws->floating->length - 1);
|
||||
return list_getp(ws->floating, ws->floating->length - 1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
static struct panel_config *if_panel_find_config(struct wl_client *client) {
|
||||
for (size_t i = 0; i < desktop_shell.panels->length; i++) {
|
||||
struct panel_config *config = *(struct panel_config **)list_get(desktop_shell.panels, i);
|
||||
struct panel_config *config = list_getp(desktop_shell.panels, i);
|
||||
if (config->client == client) {
|
||||
return config;
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ static struct panel_config *if_panel_find_config(struct wl_client *client) {
|
|||
|
||||
static struct background_config *if_background_find_config(struct wl_client *client) {
|
||||
for (size_t i = 0; i < desktop_shell.backgrounds->length; i++) {
|
||||
struct background_config *config = *(struct background_config **)list_get(desktop_shell.backgrounds, i);
|
||||
struct background_config *config = list_getp(desktop_shell.backgrounds, i);
|
||||
if (config->client == client) {
|
||||
return config;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ static void update_panel_geometry(struct panel_config *config) {
|
|||
|
||||
static void update_panel_geometries(wlc_handle output) {
|
||||
for (size_t i = 0; i < desktop_shell.panels->length; i++) {
|
||||
struct panel_config *config = *(struct panel_config **)list_get(desktop_shell.panels, i);
|
||||
struct panel_config *config = list_getp(desktop_shell.panels, i);
|
||||
if (config->output == output) {
|
||||
update_panel_geometry(config);
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ static void update_background_geometry(struct background_config *config) {
|
|||
|
||||
static void update_background_geometries(wlc_handle output) {
|
||||
for (size_t i = 0; i < desktop_shell.backgrounds->length; i++) {
|
||||
struct background_config *config = *(struct background_config **)list_get(desktop_shell.backgrounds, i);
|
||||
struct background_config *config = list_getp(desktop_shell.backgrounds, i);
|
||||
if (config->output == output) {
|
||||
update_background_geometry(config);
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ static bool handle_input_created(struct libinput_device *device) {
|
|||
|
||||
struct input_config *ic = NULL;
|
||||
for (size_t i = 0; i < config->input_configs->length; ++i) {
|
||||
struct input_config *cur = *(struct input_config **)list_get(config->input_configs, i);
|
||||
struct input_config *cur = list_getp(config->input_configs, i);
|
||||
if (strcasecmp(identifier, cur->identifier) == 0) {
|
||||
sway_log(L_DEBUG, "Matched input config for %s",
|
||||
identifier);
|
||||
|
|
@ -155,7 +155,7 @@ static bool handle_input_created(struct libinput_device *device) {
|
|||
|
||||
static void handle_input_destroyed(struct libinput_device *device) {
|
||||
for (size_t i = 0; i < input_devices->length; ++i) {
|
||||
struct libinput_device *item = *(struct libinput_device **)list_get(input_devices, i);
|
||||
struct libinput_device *item = list_getp(input_devices, i);
|
||||
if (item == device) {
|
||||
list_delete(input_devices, i);
|
||||
break;
|
||||
|
|
@ -175,7 +175,7 @@ static bool handle_output_created(wlc_handle output) {
|
|||
|
||||
// Switch to workspace if we need to
|
||||
if (swayc_active_workspace() == NULL) {
|
||||
swayc_t *ws = *(swayc_t **)list_get(op->children, 0);
|
||||
swayc_t *ws = list_getp(op->children, 0);
|
||||
workspace_switch(ws);
|
||||
}
|
||||
|
||||
|
|
@ -190,18 +190,18 @@ static void handle_output_destroyed(wlc_handle output) {
|
|||
size_t i;
|
||||
list_t *list = root_container.children;
|
||||
for (i = 0; i < list->length; ++i) {
|
||||
if ((*(swayc_t **)list_get(list, i))->handle == output) {
|
||||
if (((swayc_t *)list_getp(list, i))->handle == output) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < list->length) {
|
||||
destroy_output(*(swayc_t **)list_get(list, i));
|
||||
destroy_output(list_getp(list, i));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (list->length > 0) {
|
||||
// switch to other outputs active workspace
|
||||
workspace_switch((*(swayc_t **)list_get(root_container.children, 0))->focused);
|
||||
workspace_switch(((swayc_t *)list_getp(root_container.children, 0))->focused);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,12 +246,12 @@ static void ws_cleanup() {
|
|||
if (!root_container.children)
|
||||
return;
|
||||
while (i < root_container.children->length) {
|
||||
op = *(swayc_t **)list_get(root_container.children, i++);
|
||||
op = list_getp(root_container.children, i++);
|
||||
if (!op->children)
|
||||
continue;
|
||||
j = 0;
|
||||
while (j < op->children->length) {
|
||||
ws = *(swayc_t **)list_get(op->children, j++);
|
||||
ws = list_getp(op->children, j++);
|
||||
if (ws->children->length == 0 && ws->floating->length == 0 && ws != op->focused) {
|
||||
if (destroy_workspace(ws)) {
|
||||
j--;
|
||||
|
|
@ -399,7 +399,7 @@ static bool handle_view_created(wlc_handle handle) {
|
|||
// TODO find a better way of doing this
|
||||
// Or to focused container
|
||||
else {
|
||||
focused = get_focused_container(*(swayc_t **)list_get(focused->parent->children, 0));
|
||||
focused = get_focused_container(list_getp(focused->parent->children, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ static bool handle_view_created(wlc_handle handle) {
|
|||
// check if it matches for_window in config and execute if so
|
||||
list_t *criteria = criteria_for(newview);
|
||||
for (size_t i = 0; i < criteria->length; i++) {
|
||||
struct criteria *crit = *(struct criteria **)list_get(criteria, i);
|
||||
struct criteria *crit = list_getp(criteria, i);
|
||||
sway_log(L_DEBUG, "for_window '%s' matches new view %p, cmd: '%s'",
|
||||
crit->crit_raw, newview, crit->cmdlist);
|
||||
struct cmd_results *res = handle_command(crit->cmdlist, CONTEXT_CRITERIA);
|
||||
|
|
@ -556,9 +556,9 @@ static void handle_view_destroyed(wlc_handle handle) {
|
|||
} else {
|
||||
// Is it unmanaged?
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *output = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *output = list_getp(root_container.children, i);
|
||||
for (size_t j = 0; j < output->unmanaged->length; ++j) {
|
||||
wlc_handle *_handle = *(wlc_handle **)list_get(output->unmanaged, j);
|
||||
wlc_handle *_handle = list_getp(output->unmanaged, j);
|
||||
if (*_handle == handle) {
|
||||
list_delete(output->unmanaged, j);
|
||||
free(_handle);
|
||||
|
|
@ -689,13 +689,13 @@ static void handle_binding_command(struct sway_binding *binding) {
|
|||
static bool handle_bindsym(struct sway_binding *binding, uint32_t keysym, uint32_t keycode) {
|
||||
for (size_t i = 0; i < binding->keys->length; ++i) {
|
||||
if (binding->bindcode) {
|
||||
xkb_keycode_t *key = *(xkb_keycode_t **)list_get(binding->keys, i);
|
||||
xkb_keycode_t *key = list_getp(binding->keys, i);
|
||||
if (keycode == *key) {
|
||||
handle_binding_command(binding);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
xkb_keysym_t *key = *(xkb_keysym_t **)list_get(binding->keys, i);
|
||||
xkb_keysym_t *key = list_getp(binding->keys, i);
|
||||
if (keysym == *key) {
|
||||
handle_binding_command(binding);
|
||||
return true;
|
||||
|
|
@ -710,12 +710,12 @@ static bool valid_bindsym(struct sway_binding *binding) {
|
|||
bool match = false;
|
||||
for (size_t i = 0; i < binding->keys->length; ++i) {
|
||||
if (binding->bindcode) {
|
||||
xkb_keycode_t *key = *(xkb_keycode_t **)list_get(binding->keys, i);
|
||||
xkb_keycode_t *key = list_getp(binding->keys, i);
|
||||
if ((match = check_key(0, *key)) == false) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
xkb_keysym_t *key = *(xkb_keysym_t **)list_get(binding->keys, i);
|
||||
xkb_keysym_t *key = list_getp(binding->keys, i);
|
||||
if ((match = check_key(*key, 0)) == false) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -727,7 +727,7 @@ static bool valid_bindsym(struct sway_binding *binding) {
|
|||
|
||||
static bool handle_bindsym_release(struct sway_binding *binding) {
|
||||
if (binding->keys->length == 1) {
|
||||
xkb_keysym_t *key = *(xkb_keysym_t **)list_get(binding->keys, 0);
|
||||
xkb_keysym_t *key = list_getp(binding->keys, 0);
|
||||
if (check_released_key(*key)) {
|
||||
handle_binding_command(binding);
|
||||
return true;
|
||||
|
|
@ -763,7 +763,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
|||
// handle bar modifiers pressed/released
|
||||
uint32_t modifier;
|
||||
for (size_t i = 0; i < config->active_bar_modifiers->length; ++i) {
|
||||
modifier = **(uint32_t **)list_get(config->active_bar_modifiers, i);
|
||||
modifier = *(uint32_t *)list_getp(config->active_bar_modifiers, i);
|
||||
|
||||
switch (modifier_state_changed(modifiers->mods, modifier)) {
|
||||
case MOD_STATE_PRESSED:
|
||||
|
|
@ -780,7 +780,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
|||
// handle bindings
|
||||
list_t *candidates = list_new(sizeof(struct sway_binding *), 0);
|
||||
for (size_t i = 0; i < mode->bindings->length; ++i) {
|
||||
struct sway_binding *binding = *(struct sway_binding **)list_get(mode->bindings, i);
|
||||
struct sway_binding *binding = list_getp(mode->bindings, i);
|
||||
if ((modifiers->mods ^ binding->modifiers) == 0) {
|
||||
switch (state) {
|
||||
case WLC_KEY_STATE_PRESSED: {
|
||||
|
|
@ -799,7 +799,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < candidates->length; ++i) {
|
||||
struct sway_binding *binding = *(struct sway_binding **)list_get(candidates, i);
|
||||
struct sway_binding *binding = list_getp(candidates, i);
|
||||
if (state == WLC_KEY_STATE_PRESSED) {
|
||||
if (!binding->release && handle_bindsym(binding, sym, key)) {
|
||||
list_free(candidates);
|
||||
|
|
@ -910,7 +910,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
|||
struct sway_mode *mode = config->current_mode;
|
||||
// handle bindings
|
||||
for (size_t i = 0; i < mode->bindings->length; ++i) {
|
||||
struct sway_binding *binding = *(struct sway_binding **)list_get(mode->bindings, i);
|
||||
struct sway_binding *binding = list_getp(mode->bindings, i);
|
||||
if ((modifiers->mods ^ binding->modifiers) == 0) {
|
||||
switch (state) {
|
||||
case WLC_BUTTON_STATE_PRESSED: {
|
||||
|
|
@ -1005,7 +1005,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
|||
// Send to front if floating
|
||||
if (pointer->is_floating) {
|
||||
for (size_t i = 0; i < pointer->parent->floating->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(pointer->parent->floating, i);
|
||||
swayc_t *item = list_getp(pointer->parent->floating, i);
|
||||
if (item == pointer) {
|
||||
list_delete(pointer->parent->floating, i);
|
||||
list_add(pointer->parent->floating, &pointer);
|
||||
|
|
@ -1067,7 +1067,7 @@ static void handle_wlc_ready(void) {
|
|||
// Execute commands until there are none left
|
||||
config->active = true;
|
||||
while (config->cmd_queue->length) {
|
||||
char *line = *(char **)list_get(config->cmd_queue, 0);
|
||||
char *line = list_getp(config->cmd_queue, 0);
|
||||
struct cmd_results *res = handle_command(line, CONTEXT_CONFIG);
|
||||
if (res->status != CMD_SUCCESS) {
|
||||
sway_log(L_ERROR, "Error on line '%s': %s", line, res->error);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object)
|
|||
// window is in the scratchpad ? changed : none
|
||||
static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
|
||||
for (size_t i = 0; i < scratchpad->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(scratchpad, i);
|
||||
swayc_t *item = list_getp(scratchpad, i);
|
||||
if (item == c) {
|
||||
return "changed";
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
|||
if (bar->outputs && bar->outputs->length > 0) {
|
||||
json_object *outputs = json_object_new_array();
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
const char *name = *(char **)list_get(bar->outputs, i);
|
||||
const char *name = list_getp(bar->outputs, i);
|
||||
json_object_array_add(outputs, json_object_new_string(name));
|
||||
}
|
||||
json_object_object_add(json, "outputs", outputs);
|
||||
|
|
@ -436,7 +436,7 @@ json_object *ipc_json_describe_container_recursive(swayc_t *c) {
|
|||
json_object *floating = json_object_new_array();
|
||||
if (c->type != C_VIEW && c->floating && c->floating->length > 0) {
|
||||
for (size_t i = 0; i < c->floating->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(c->floating, i);
|
||||
swayc_t *item = list_getp(c->floating, i);
|
||||
json_object_array_add(floating, ipc_json_describe_container_recursive(item));
|
||||
}
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ json_object *ipc_json_describe_container_recursive(swayc_t *c) {
|
|||
json_object *children = json_object_new_array();
|
||||
if (c->type != C_VIEW && c->children && c->children->length > 0) {
|
||||
for (size_t i = 0; i < c->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(c->children, i);
|
||||
swayc_t *item = list_getp(c->children, i);
|
||||
json_object_array_add(children, ipc_json_describe_container_recursive(item));
|
||||
}
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ json_object *ipc_json_describe_container_recursive(swayc_t *c) {
|
|||
if (c->type == C_ROOT) {
|
||||
json_object *scratchpad_json = json_object_new_array();
|
||||
for (size_t i = 0; i < scratchpad->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(scratchpad, i);
|
||||
swayc_t *item = list_getp(scratchpad, i);
|
||||
json_object_array_add(scratchpad_json, ipc_json_describe_container_recursive(item));
|
||||
}
|
||||
json_object_object_add(object, "scratchpad", scratchpad_json);
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ void ipc_client_disconnect(struct ipc_client *client) {
|
|||
sway_log(L_INFO, "IPC Client %d disconnected", client->fd);
|
||||
wlc_event_source_remove(client->event_source);
|
||||
size_t i = 0;
|
||||
while (i < ipc_client_list->length && *(struct ipc_client **)list_get(ipc_client_list, i) != client) i++;
|
||||
while (i < ipc_client_list->length && list_getp(ipc_client_list, i) != client) i++;
|
||||
list_delete(ipc_client_list, i);
|
||||
close(client->fd);
|
||||
free(client);
|
||||
|
|
@ -284,7 +284,7 @@ void ipc_get_pixels(wlc_handle output) {
|
|||
|
||||
struct get_pixels_request *req;
|
||||
for (size_t i = 0; i < ipc_get_pixel_requests->length; ++i) {
|
||||
req = *(struct get_pixels_request **)list_get(ipc_get_pixel_requests, i);
|
||||
req = list_getp(ipc_get_pixel_requests, i);
|
||||
if (req->output != output) {
|
||||
list_add(unhandled, &req);
|
||||
continue;
|
||||
|
|
@ -421,7 +421,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
|||
json_object *inputs = json_object_new_array();
|
||||
if (input_devices) {
|
||||
for(size_t i = 0; i<input_devices->length; i++) {
|
||||
struct libinput_device *device = *(struct libinput_device **)list_get(input_devices, i);
|
||||
struct libinput_device *device = list_getp(input_devices, i);
|
||||
json_object_array_add(inputs, ipc_json_describe_input(device));
|
||||
}
|
||||
}
|
||||
|
|
@ -533,7 +533,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
|||
// Send list of configured bar IDs
|
||||
json_object *bars = json_object_new_array();
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
struct bar_config *bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
struct bar_config *bar = list_getp(config->bars, i);
|
||||
json_object_array_add(bars, json_object_new_string(bar->id));
|
||||
}
|
||||
const char *json_string = json_object_to_json_string(bars);
|
||||
|
|
@ -543,7 +543,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
|||
// Send particular bar's details
|
||||
struct bar_config *bar = NULL;
|
||||
for (size_t i = 0; i < config->bars->length; ++i) {
|
||||
bar = *(struct bar_config **)list_get(config->bars, i);
|
||||
bar = list_getp(config->bars, i);
|
||||
if (strcmp(buf, bar->id) == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -624,7 +624,7 @@ static void ipc_get_marks_callback(swayc_t *container, void *data) {
|
|||
json_object *object = (json_object *)data;
|
||||
if (container->marks) {
|
||||
for (size_t i = 0; i < container->marks->length; ++i) {
|
||||
char *mark = *(char **)list_get(container->marks, i);
|
||||
char *mark = list_getp(container->marks, i);
|
||||
json_object_array_add(object, json_object_new_string(mark));
|
||||
}
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ void ipc_send_event(const char *json_string, enum ipc_command_type event) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < ipc_client_list->length; i++) {
|
||||
struct ipc_client *client = *(struct ipc_client **)list_get(ipc_client_list, i);
|
||||
struct ipc_client *client = list_getp(ipc_client_list, i);
|
||||
if (!(client->security_policy & security_mask)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -775,7 +775,7 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) {
|
|||
if (sb->bindcode) { // bindcode: populate input_codes
|
||||
uint32_t keycode;
|
||||
for (size_t i = 0; i < sb->keys->length; ++i) {
|
||||
keycode = **(uint32_t **)list_get(sb->keys, i);
|
||||
keycode = *(uint32_t *)list_getp(sb->keys, i);
|
||||
json_object_array_add(input_codes, json_object_new_int(keycode));
|
||||
if (i == 0) {
|
||||
input_code = keycode;
|
||||
|
|
@ -785,7 +785,7 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) {
|
|||
uint32_t keysym;
|
||||
char buffer[64];
|
||||
for (size_t i = 0; i < sb->keys->length; ++i) {
|
||||
keysym = **(uint32_t **)list_get(sb->keys, i);
|
||||
keysym = *(uint32_t *)list_getp(sb->keys, i);
|
||||
if (xkb_keysym_get_name(keysym, buffer, 64) > 0) {
|
||||
json_object *str = json_object_new_string(buffer);
|
||||
json_object_array_add(symbols, str);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ int index_child(const swayc_t *child) {
|
|||
if (!child->is_floating) {
|
||||
len = parent->children->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *item = list_getp(parent->children, i);
|
||||
if (item == child) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ int index_child(const swayc_t *child) {
|
|||
} else {
|
||||
len = parent->floating->length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->floating, i);
|
||||
swayc_t *item = list_getp(parent->floating, i);
|
||||
if (item == child) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -108,10 +108,10 @@ void insert_child(swayc_t *parent, swayc_t *child, size_t index) {
|
|||
for (size_t i = index; i < parent->children->length;) {
|
||||
size_t start = auto_group_start_index(parent, i);
|
||||
size_t end = auto_group_end_index(parent, i);
|
||||
swayc_t *first = *(swayc_t **)list_get(parent->children, start);
|
||||
swayc_t *first = list_getp(parent->children, start);
|
||||
if (start + 1 < parent->children->length) {
|
||||
/* preserve the group's dimension along major axis */
|
||||
*get_maj_dim(first) = *get_maj_dim(*(swayc_t **)list_get(parent->children, start + 1));
|
||||
*get_maj_dim(first) = *get_maj_dim(list_getp(parent->children, start + 1));
|
||||
} else {
|
||||
/* new group, let the apply_layout handle it */
|
||||
first->height = first->width = 0;
|
||||
|
|
@ -119,7 +119,7 @@ void insert_child(swayc_t *parent, swayc_t *child, size_t index) {
|
|||
}
|
||||
double remaining = *get_min_dim(parent);
|
||||
for (size_t j = end - 1; j > start; --j) {
|
||||
swayc_t *sibling = *(swayc_t **)list_get(parent->children, j);
|
||||
swayc_t *sibling = list_getp(parent->children, j);
|
||||
if (sibling == child) {
|
||||
/* the inserted child won't yet have its minor
|
||||
dimension set */
|
||||
|
|
@ -217,7 +217,7 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
if (child->is_floating) {
|
||||
// Special case for floating views
|
||||
for (i = 0; i < parent->floating->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->floating, i);
|
||||
swayc_t *item = list_getp(parent->floating, i);
|
||||
if (item == child) {
|
||||
list_delete(parent->floating, i);
|
||||
break;
|
||||
|
|
@ -226,7 +226,7 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
i = 0;
|
||||
} else {
|
||||
for (i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *item = list_getp(parent->children, i);
|
||||
if (item == child) {
|
||||
list_delete(parent->children, i);
|
||||
break;
|
||||
|
|
@ -246,24 +246,24 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
for (size_t j = parent->children->length - 1; j >= i;) {
|
||||
size_t start = auto_group_start_index(parent, j);
|
||||
size_t end = auto_group_end_index(parent, j);
|
||||
swayc_t *first = *(swayc_t **)list_get(parent->children, start);
|
||||
swayc_t *first = list_getp(parent->children, start);
|
||||
if (i == start) {
|
||||
/* removed element was first child in the current group,
|
||||
use its size along the major axis */
|
||||
*get_maj_dim(first) = *get_maj_dim(child);
|
||||
} else if (start > i) {
|
||||
/* preserve the group's dimension along major axis */
|
||||
*get_maj_dim(first) = *get_maj_dim(*(swayc_t **)list_get(parent->children, start - 1));
|
||||
*get_maj_dim(first) = *get_maj_dim(list_getp(parent->children, start - 1));
|
||||
}
|
||||
if (end != parent->children->length) {
|
||||
double remaining = *get_min_dim(parent);
|
||||
for (size_t k = start; k < end - 1; ++k) {
|
||||
swayc_t *sibling = *(swayc_t **)list_get(parent->children, k);
|
||||
swayc_t *sibling = list_getp(parent->children, k);
|
||||
remaining -= *get_min_dim(sibling);
|
||||
}
|
||||
/* last element of the group gets remaining size, elements
|
||||
that don't change groups keep their ratio */
|
||||
*get_min_dim(*(swayc_t **)list_get(parent->children, end - 1)) = remaining;
|
||||
*get_min_dim(list_getp(parent->children, end - 1)) = remaining;
|
||||
} /* else last group, let apply_layout handle it */
|
||||
j = start - 1;
|
||||
}
|
||||
|
|
@ -272,9 +272,9 @@ swayc_t *remove_child(swayc_t *child) {
|
|||
// Set focused to new container
|
||||
if (parent->focused == child) {
|
||||
if (parent->children->length > 0) {
|
||||
parent->focused = *(swayc_t **)list_get(parent->children, i ? i-1:0);
|
||||
parent->focused = list_getp(parent->children, i ? i-1:0);
|
||||
} else if (parent->floating && parent->floating->length) {
|
||||
parent->focused = *(swayc_t **)list_get(parent->floating, parent->floating->length - 1);
|
||||
parent->focused = list_getp(parent->floating, parent->floating->length - 1);
|
||||
} else {
|
||||
parent->focused = NULL;
|
||||
}
|
||||
|
|
@ -335,9 +335,9 @@ void swap_geometry(swayc_t *a, swayc_t *b) {
|
|||
|
||||
static void swap_children(swayc_t *container, size_t a, size_t b) {
|
||||
if (a < container->children->length && b < container->children->length && a != b) {
|
||||
swayc_t *pa = *(swayc_t **)list_get(container->children, a);
|
||||
swayc_t *pb = *(swayc_t **)list_get(container->children, b);
|
||||
*(swayc_t **)list_get(container->children, a) = *(swayc_t **)list_get(container->children, b);
|
||||
swayc_t *pa = list_getp(container->children, a);
|
||||
swayc_t *pb = list_getp(container->children, b);
|
||||
*(swayc_t **)list_get(container->children, a) = list_getp(container->children, b);
|
||||
*(swayc_t **)list_get(container->children, b) = pa;
|
||||
if (is_auto_layout(container->layout)) {
|
||||
size_t ga = auto_group_index(container, a);
|
||||
|
|
@ -384,7 +384,7 @@ void move_container(swayc_t *container, enum movement_direction dir, int move_am
|
|||
// swap first child in auto layout with currently focused child
|
||||
if (is_auto_layout(parent->layout)) {
|
||||
int focused_idx = index_child(container);
|
||||
swayc_t *first = *(swayc_t **)list_get(parent->children, 0);
|
||||
swayc_t *first = list_getp(parent->children, 0);
|
||||
if (focused_idx > 0) {
|
||||
list_swap(parent->children, 0, focused_idx);
|
||||
swap_geometry(first, container);
|
||||
|
|
@ -444,7 +444,7 @@ void move_container(swayc_t *container, enum movement_direction dir, int move_am
|
|||
// when it has not, legal insertion position is 0:len-1
|
||||
if (desired >= 0 && desired - ascended < (ssize_t)parent->children->length) {
|
||||
if (!ascended) {
|
||||
child = *(swayc_t **)list_get(parent->children, desired);
|
||||
child = list_getp(parent->children, desired);
|
||||
// Move container into sibling container
|
||||
if (child->type == C_CONTAINER) {
|
||||
parent = child;
|
||||
|
|
@ -676,7 +676,7 @@ void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) {
|
|||
if (prev_layout != L_TABBED && prev_layout != L_STACKED) {
|
||||
// cache current geometry for all non-float children
|
||||
for (size_t i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *child = list_getp(parent->children, i);
|
||||
child->cached_geometry.origin.x = child->x;
|
||||
child->cached_geometry.origin.y = child->y;
|
||||
child->cached_geometry.size.w = child->width;
|
||||
|
|
@ -688,7 +688,7 @@ void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) {
|
|||
if (prev_layout == L_TABBED || prev_layout == L_STACKED) {
|
||||
// recover cached geometry for all non-float children
|
||||
for (size_t i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *child = list_getp(parent->children, i);
|
||||
// only recoverer cached geometry if non-zero
|
||||
if (!wlc_geometry_equals(&child->cached_geometry, &wlc_geometry_zero)) {
|
||||
child->x = child->cached_geometry.origin.x;
|
||||
|
|
@ -833,7 +833,7 @@ void update_geometry(swayc_t *container) {
|
|||
w = geometry.size.w / l;
|
||||
r = geometry.size.w % l;
|
||||
for (size_t i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *view = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *view = list_getp(parent->children, i);
|
||||
if (view == container) {
|
||||
x = w * i;
|
||||
if ((ssize_t)i == l - 1) {
|
||||
|
|
@ -861,7 +861,7 @@ void update_geometry(swayc_t *container) {
|
|||
} else if (parent->layout == L_STACKED && parent->children->length > 1) {
|
||||
int y = 0;
|
||||
for (size_t i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *view = *(swayc_t **)list_get(parent->children, i);
|
||||
swayc_t *view = list_getp(parent->children, i);
|
||||
if (view == container) {
|
||||
y = title_bar_height * i;
|
||||
}
|
||||
|
|
@ -968,7 +968,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
switch (container->type) {
|
||||
case C_ROOT:
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *output = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *output = list_getp(container->children, i);
|
||||
sway_log(L_DEBUG, "Arranging output '%s' at %f,%f", output->name, output->x, output->y);
|
||||
arrange_windows_r(output, -1, -1);
|
||||
}
|
||||
|
|
@ -985,12 +985,12 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
}
|
||||
// arrange all workspaces:
|
||||
for (i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
arrange_windows_r(child, -1, -1);
|
||||
}
|
||||
// Bring all unmanaged views to the front
|
||||
for (i = 0; i < container->unmanaged->length; ++i) {
|
||||
wlc_handle *handle = *(wlc_handle **)list_get(container->unmanaged, i);
|
||||
wlc_handle *handle = list_getp(container->unmanaged, i);
|
||||
wlc_view_bring_to_front(*handle);
|
||||
}
|
||||
return;
|
||||
|
|
@ -999,7 +999,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
|
||||
width = output->width, height = output->height;
|
||||
for (i = 0; i < desktop_shell.panels->length; ++i) {
|
||||
struct panel_config *config = *(struct panel_config **)list_get(desktop_shell.panels, i);
|
||||
struct panel_config *config = list_getp(desktop_shell.panels, i);
|
||||
if (config->output == output->handle) {
|
||||
struct wlc_size size = *wlc_surface_get_size(config->surface);
|
||||
sway_log(L_DEBUG, "-> Found panel for this workspace: %ux%u, position: %u", size.w, size.h, config->panel_position);
|
||||
|
|
@ -1105,7 +1105,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
// Arrage floating layouts for workspaces last
|
||||
if (container->type == C_WORKSPACE) {
|
||||
for (size_t i = 0; i < container->floating->length; ++i) {
|
||||
swayc_t *view = *(swayc_t **)list_get(container->floating, i);
|
||||
swayc_t *view = list_getp(container->floating, i);
|
||||
if (view->type == C_VIEW) {
|
||||
update_geometry(view);
|
||||
sway_log(L_DEBUG, "Set floating view to %.f x %.f @ %.f, %.f",
|
||||
|
|
@ -1127,7 +1127,7 @@ void apply_horiz_layout(swayc_t *container, const double x, const double y,
|
|||
double scale = 0;
|
||||
// Calculate total width
|
||||
for (int i = start; i < end; ++i) {
|
||||
double *old_width = &(*(swayc_t **)list_get(container->children, i))->width;
|
||||
double *old_width = &((swayc_t *)list_getp(container->children, i))->width;
|
||||
if (*old_width <= 0) {
|
||||
if (end - start > 1) {
|
||||
*old_width = width / (end - start - 1);
|
||||
|
|
@ -1145,7 +1145,7 @@ void apply_horiz_layout(swayc_t *container, const double x, const double y,
|
|||
sway_log(L_DEBUG, "Arranging %p horizontally", container);
|
||||
swayc_t *focused = NULL;
|
||||
for (int i = start; i < end; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
sway_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)", child,
|
||||
child->type, width, scale);
|
||||
|
|
@ -1180,7 +1180,7 @@ void apply_vert_layout(swayc_t *container, const double x, const double y,
|
|||
double scale = 0;
|
||||
// Calculate total height
|
||||
for (i = start; i < end; ++i) {
|
||||
double *old_height = &(*(swayc_t **)list_get(container->children, i))->height;
|
||||
double *old_height = &((swayc_t *)list_getp(container->children, i))->height;
|
||||
if (*old_height <= 0) {
|
||||
if (end - start > 1) {
|
||||
*old_height = height / (end - start - 1);
|
||||
|
|
@ -1198,7 +1198,7 @@ void apply_vert_layout(swayc_t *container, const double x, const double y,
|
|||
sway_log(L_DEBUG, "Arranging %p vertically", container);
|
||||
swayc_t *focused = NULL;
|
||||
for (i = start; i < end; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
sway_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)", child,
|
||||
child->type, height, scale);
|
||||
|
|
@ -1230,7 +1230,7 @@ void apply_tabbed_or_stacked_layout(swayc_t *container, double x, double y,
|
|||
double width, double height) {
|
||||
swayc_t *focused = NULL;
|
||||
for (size_t i = 0; i < container->children->length; ++i) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *child = list_getp(container->children, i);
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
if (child == container->focused) {
|
||||
|
|
@ -1322,7 +1322,7 @@ void apply_auto_layout(swayc_t *container, const double x, const double y,
|
|||
for (size_t group = 0; group < nb_groups; ++group) {
|
||||
int idx;
|
||||
if (auto_group_bounds(container, group, &idx, NULL)) {
|
||||
swayc_t *child = *(swayc_t **)list_get(container->children, idx);
|
||||
swayc_t *child = list_getp(container->children, idx);
|
||||
double *dim = group_layout == L_HORIZ ? &child->height : &child->width;
|
||||
if (*dim <= 0) {
|
||||
// New child with uninitialized dimension
|
||||
|
|
@ -1377,7 +1377,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
|||
|
||||
void arrange_backgrounds(void) {
|
||||
for (size_t i = 0; i < desktop_shell.backgrounds->length; ++i) {
|
||||
struct background_config *bg = *(struct background_config **)list_get(desktop_shell.backgrounds, i);
|
||||
struct background_config *bg = list_getp(desktop_shell.backgrounds, i);
|
||||
wlc_view_send_to_back(bg->handle);
|
||||
}
|
||||
}
|
||||
|
|
@ -1395,10 +1395,10 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, enum movement_dir
|
|||
switch (dir) {
|
||||
case MOVE_LEFT:
|
||||
// get most right child of new output
|
||||
return *(swayc_t **)list_get(ws->children, ws->children->length-1);
|
||||
return list_getp(ws->children, ws->children->length-1);
|
||||
case MOVE_RIGHT:
|
||||
// get most left child of new output
|
||||
return *(swayc_t **)list_get(ws->children, 0);
|
||||
return list_getp(ws->children, 0);
|
||||
case MOVE_UP:
|
||||
case MOVE_DOWN:
|
||||
{
|
||||
|
|
@ -1408,10 +1408,10 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, enum movement_dir
|
|||
if (parent->layout == L_VERT) {
|
||||
if (dir == MOVE_UP) {
|
||||
// get child furthest down on new output
|
||||
return *(swayc_t **)list_get(parent->children, parent->children->length-1);
|
||||
return list_getp(parent->children, parent->children->length-1);
|
||||
} else if (dir == MOVE_DOWN) {
|
||||
// get child furthest up on new output
|
||||
return *(swayc_t **)list_get(parent->children, 0);
|
||||
return list_getp(parent->children, 0);
|
||||
}
|
||||
}
|
||||
return focused_view;
|
||||
|
|
@ -1450,7 +1450,7 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
|||
if (desired < 0) {
|
||||
desired += parent->children->length;
|
||||
}
|
||||
return *(swayc_t **)list_get(parent->children, desired);
|
||||
return list_getp(parent->children, desired);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1518,11 +1518,11 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
|||
if (can_move) {
|
||||
if (container->is_floating) {
|
||||
if (desired < 0) {
|
||||
wrap_candidate = *(swayc_t **)list_get(parent->floating, parent->floating->length-1);
|
||||
wrap_candidate = list_getp(parent->floating, parent->floating->length-1);
|
||||
} else if (desired >= (ssize_t)parent->floating->length){
|
||||
wrap_candidate = *(swayc_t **)list_get(parent->floating, 0);
|
||||
wrap_candidate = list_getp(parent->floating, 0);
|
||||
} else {
|
||||
wrap_candidate = *(swayc_t **)list_get(parent->floating, desired);
|
||||
wrap_candidate = list_getp(parent->floating, desired);
|
||||
}
|
||||
if (wrap_candidate) {
|
||||
wlc_view_bring_to_front(wrap_candidate->handle);
|
||||
|
|
@ -1533,16 +1533,16 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
|||
int len = parent->children->length;
|
||||
if (!wrap_candidate && len > 1) {
|
||||
if (desired < 0) {
|
||||
wrap_candidate = *(swayc_t **)list_get(parent->children, len-1);
|
||||
wrap_candidate = list_getp(parent->children, len-1);
|
||||
} else {
|
||||
wrap_candidate = *(swayc_t **)list_get(parent->children, 0);
|
||||
wrap_candidate = list_getp(parent->children, 0);
|
||||
}
|
||||
if (config->force_focus_wrapping) {
|
||||
return wrap_candidate;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
swayc_t *item = *(swayc_t **)list_get(parent->children, desired);
|
||||
swayc_t *item = list_getp(parent->children, desired);
|
||||
sway_log(L_DEBUG, "%s cont %d-%p dir %i sibling %d: %p", __func__,
|
||||
idx, container, dir, desired, item);
|
||||
return item;
|
||||
|
|
@ -1579,12 +1579,12 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed
|
|||
}
|
||||
if (layout_match) {
|
||||
for (size_t i = 0; i < container->children->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
recursive_resize(item, amount/container->children->length, edge);
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < container->children->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(container->children, i);
|
||||
swayc_t *item = list_getp(container->children, i);
|
||||
recursive_resize(item, amount, edge);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos) {
|
|||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (c->type == C_OUTPUT && strcasecmp(c->name, name) == 0) {
|
||||
return c;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ swayc_t *swayc_opposite_output(enum movement_direction dir,
|
|||
case MOVE_LEFT:
|
||||
case MOVE_RIGHT: ;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (abs_pos->y >= c->y && abs_pos->y <= c->y + c->height) {
|
||||
if (!opposite) {
|
||||
opposite = c;
|
||||
|
|
@ -74,7 +74,7 @@ swayc_t *swayc_opposite_output(enum movement_direction dir,
|
|||
case MOVE_UP:
|
||||
case MOVE_DOWN: ;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (abs_pos->x >= c->x && abs_pos->x <= c->x + c->width) {
|
||||
if (!opposite) {
|
||||
opposite = c;
|
||||
|
|
@ -117,7 +117,7 @@ swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir,
|
|||
case MOVE_RIGHT: ;
|
||||
double delta_y = 0;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (c == output || c->type != C_OUTPUT) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir,
|
|||
case MOVE_DOWN: ;
|
||||
double delta_x = 0;
|
||||
for (size_t i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *c = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *c = list_getp(root_container.children, i);
|
||||
if (c == output || c->type != C_OUTPUT) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct feature_policy *alloc_feature_policy(const char *program) {
|
|||
return NULL;
|
||||
}
|
||||
for (size_t i = 0; i < config->feature_policies->length; ++i) {
|
||||
struct feature_policy *policy = *(struct feature_policy **)list_get(config->feature_policies, i);
|
||||
struct feature_policy *policy = list_getp(config->feature_policies, i);
|
||||
if (strcmp(policy->program, "*") == 0) {
|
||||
default_policy = policy->features;
|
||||
break;
|
||||
|
|
@ -77,7 +77,7 @@ struct ipc_policy *alloc_ipc_policy(const char *program) {
|
|||
return NULL;
|
||||
}
|
||||
for (size_t i = 0; i < config->ipc_policies->length; ++i) {
|
||||
struct ipc_policy *policy = *(struct ipc_policy **)list_get(config->ipc_policies, i);
|
||||
struct ipc_policy *policy = list_getp(config->ipc_policies, i);
|
||||
if (strcmp(policy->program, "*") == 0) {
|
||||
default_policy = policy->features;
|
||||
break;
|
||||
|
|
@ -144,7 +144,7 @@ struct feature_policy *get_feature_policy(const char *name) {
|
|||
struct feature_policy *policy = NULL;
|
||||
|
||||
for (size_t i = 0; i < config->feature_policies->length; ++i) {
|
||||
struct feature_policy *p = *(struct feature_policy **)list_get(config->feature_policies, i);
|
||||
struct feature_policy *p = list_getp(config->feature_policies, i);
|
||||
if (strcmp(p->program, name) == 0) {
|
||||
policy = p;
|
||||
break;
|
||||
|
|
@ -165,7 +165,7 @@ uint32_t get_feature_policy_mask(pid_t pid) {
|
|||
const char *link = get_pid_exe(pid);
|
||||
|
||||
for (size_t i = 0; i < config->feature_policies->length; ++i) {
|
||||
struct feature_policy *policy = *(struct feature_policy **)list_get(config->feature_policies, i);
|
||||
struct feature_policy *policy = list_getp(config->feature_policies, i);
|
||||
if (strcmp(policy->program, "*") == 0) {
|
||||
default_policy = policy->features;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ uint32_t get_ipc_policy_mask(pid_t pid) {
|
|||
const char *link = get_pid_exe(pid);
|
||||
|
||||
for (size_t i = 0; i < config->ipc_policies->length; ++i) {
|
||||
struct ipc_policy *policy = *(struct ipc_policy **)list_get(config->ipc_policies, i);
|
||||
struct ipc_policy *policy = list_getp(config->ipc_policies, i);
|
||||
if (strcmp(policy->program, "*") == 0) {
|
||||
default_policy = policy->features;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ uint32_t get_command_policy_mask(const char *cmd) {
|
|||
uint32_t default_policy = 0;
|
||||
|
||||
for (size_t i = 0; i < config->command_policies->length; ++i) {
|
||||
struct command_policy *policy = *(struct command_policy **)list_get(config->command_policies, i);
|
||||
struct command_policy *policy = list_getp(config->command_policies, i);
|
||||
if (strcmp(policy->command, "*") == 0) {
|
||||
default_policy = policy->context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct workspace_by_number_data {
|
|||
|
||||
static bool workspace_valid_on_output(const char *output_name, const char *ws_name) {
|
||||
for (size_t i = 0; i < config->workspace_outputs->length; ++i) {
|
||||
struct workspace_output *wso = *(struct workspace_output **)list_get(config->workspace_outputs, i);
|
||||
struct workspace_output *wso = list_getp(config->workspace_outputs, i);
|
||||
if (strcasecmp(wso->workspace, ws_name) == 0) {
|
||||
if (strcasecmp(wso->output, output_name) != 0) {
|
||||
return false;
|
||||
|
|
@ -51,7 +51,7 @@ char *workspace_next_name(const char *output_name) {
|
|||
int order = INT_MAX;
|
||||
char *target = NULL;
|
||||
for (size_t i = 0; i < mode->bindings->length; ++i) {
|
||||
struct sway_binding *binding = *(struct sway_binding **)list_get(mode->bindings, i);
|
||||
struct sway_binding *binding = list_getp(mode->bindings, i);
|
||||
char *cmdlist = strdup(binding->command);
|
||||
char *dup = cmdlist;
|
||||
char *name = NULL;
|
||||
|
|
@ -133,12 +133,12 @@ swayc_t *workspace_create(const char* name) {
|
|||
// Search for workspace<->output pair
|
||||
size_t i, e = config->workspace_outputs->length;
|
||||
for (i = 0; i < e; ++i) {
|
||||
struct workspace_output *wso = *(struct workspace_output **)list_get(config->workspace_outputs, i);
|
||||
struct workspace_output *wso = list_getp(config->workspace_outputs, i);
|
||||
if (strcasecmp(wso->workspace, name) == 0) {
|
||||
// Find output to use if it exists
|
||||
e = root_container.children->length;
|
||||
for (i = 0; i < e; ++i) {
|
||||
parent = *(swayc_t **)list_get(root_container.children, i);
|
||||
parent = list_getp(root_container.children, i);
|
||||
if (strcmp(parent->name, wso->output) == 0) {
|
||||
return new_workspace(parent, name);
|
||||
}
|
||||
|
|
@ -206,9 +206,9 @@ swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < output->children->length; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(output->children, i);
|
||||
swayc_t *item = list_getp(output->children, i);
|
||||
if (item == output->focused) {
|
||||
return *(swayc_t **)list_get(output->children, (wrap(i + (next ? 1 : -1), output->children->length)));
|
||||
return list_getp(output->children, (wrap(i + (next ? 1 : -1), output->children->length)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,18 +231,18 @@ swayc_t *workspace_prev_next_impl(swayc_t *workspace, bool next) {
|
|||
size_t start = next ? 0 : 1;
|
||||
size_t end = next ? (current_output->children->length) - 1 : current_output->children->length;
|
||||
for (size_t i = start; i < end; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(current_output->children, i);
|
||||
swayc_t *item = list_getp(current_output->children, i);
|
||||
if (item == workspace) {
|
||||
return *(swayc_t **)list_get(current_output->children, i + offset);
|
||||
return list_getp(current_output->children, i + offset);
|
||||
}
|
||||
}
|
||||
|
||||
// Given workspace is the first/last on the output, jump to the previous/next output
|
||||
size_t num_outputs = root_container.children->length;
|
||||
for (size_t i = 0; i < num_outputs; i++) {
|
||||
swayc_t *item = *(swayc_t **)list_get(root_container.children, i);
|
||||
swayc_t *item = list_getp(root_container.children, i);
|
||||
if (item == current_output) {
|
||||
swayc_t *next_output = *(swayc_t **)list_get(root_container.children, wrap(i + offset, num_outputs));
|
||||
swayc_t *next_output = list_getp(root_container.children, wrap(i + offset, num_outputs));
|
||||
return workspace_output_prev_next_impl(next_output, next);
|
||||
}
|
||||
}
|
||||
|
|
@ -294,13 +294,13 @@ bool workspace_switch(swayc_t *workspace) {
|
|||
// don't change list while traversing it, use intermediate list instead
|
||||
list_t *stickies = list_new(sizeof(swayc_t *), 0);
|
||||
for (size_t i = 0; i < active_ws->floating->length; i++) {
|
||||
swayc_t *cont = *(swayc_t **)list_get(active_ws->floating, i);
|
||||
swayc_t *cont = list_getp(active_ws->floating, i);
|
||||
if (cont->sticky) {
|
||||
list_add(stickies, &cont);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < stickies->length; i++) {
|
||||
swayc_t *cont = *(swayc_t **)list_get(stickies, i);
|
||||
swayc_t *cont = list_getp(stickies, i);
|
||||
sway_log(L_DEBUG, "Moving sticky container %p to %p:%s",
|
||||
cont, workspace, workspace->name);
|
||||
swayc_t *parent = remove_child(cont);
|
||||
|
|
@ -336,7 +336,7 @@ swayc_t *workspace_for_pid(pid_t pid) {
|
|||
|
||||
do {
|
||||
for (i = 0; i < config->pid_workspaces->length; i++) {
|
||||
pw = *(struct pid_workspace **)list_get(config->pid_workspaces, i);
|
||||
pw = list_getp(config->pid_workspaces, i);
|
||||
pid_t *pw_pid = pw->pid;
|
||||
|
||||
if (pid == *pw_pid) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ static void mouse_button_notify(struct window *window, int x, int y,
|
|||
|
||||
struct output *clicked_output = NULL;
|
||||
for (size_t i = 0; i < swaybar.outputs->length; i++) {
|
||||
struct output *output = *(struct output **)list_get(swaybar.outputs, i);
|
||||
struct output *output = list_getp(swaybar.outputs, i);
|
||||
if (window == output->window) {
|
||||
clicked_output = output;
|
||||
break;
|
||||
|
|
@ -81,7 +81,7 @@ static void mouse_button_notify(struct window *window, int x, int y,
|
|||
|
||||
double button_x = 0.5;
|
||||
for (size_t i = 0; i < clicked_output->workspaces->length; i++) {
|
||||
struct workspace *workspace = *(struct workspace **)list_get(clicked_output->workspaces, i);
|
||||
struct workspace *workspace = list_getp(clicked_output->workspaces, i);
|
||||
int button_width, button_height;
|
||||
|
||||
workspace_button_size(window, workspace->name, &button_width, &button_height);
|
||||
|
|
@ -102,7 +102,7 @@ static void mouse_scroll_notify(struct window *window, enum scroll_direction dir
|
|||
// Find output this window lives on
|
||||
struct output *output = NULL;
|
||||
for (i = 0; i < swaybar.outputs->length; ++i) {
|
||||
output = *(struct output **)list_get(swaybar.outputs, i);
|
||||
output = list_getp(swaybar.outputs, i);
|
||||
if (output->window == window) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ static void mouse_scroll_notify(struct window *window, enum scroll_direction dir
|
|||
}
|
||||
int focused = -1;
|
||||
for (i = 0; i < output->workspaces->length; ++i) {
|
||||
struct workspace *ws = *(struct workspace **)list_get(output->workspaces, i);
|
||||
struct workspace *ws = list_getp(output->workspaces, i);
|
||||
if (ws->focused) {
|
||||
focused = i;
|
||||
break;
|
||||
|
|
@ -143,7 +143,7 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) {
|
|||
ipc_bar_init(bar, bar_id);
|
||||
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *bar_output = *(struct output **)list_get(bar->outputs, i);
|
||||
struct output *bar_output = list_getp(bar->outputs, i);
|
||||
|
||||
bar_output->registry = registry_poll();
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) {
|
|||
sway_abort("swaybar requires the compositor to support the desktop-shell extension.");
|
||||
}
|
||||
|
||||
struct output_state *output = *(struct output_state **)list_get(bar_output->registry->outputs, bar_output->idx);
|
||||
struct output_state *output = list_getp(bar_output->registry->outputs, bar_output->idx);
|
||||
|
||||
bar_output->window = window_setup(bar_output->registry,
|
||||
output->width / output->scale, 30, output->scale, false);
|
||||
|
|
@ -190,7 +190,7 @@ void bar_run(struct bar *bar) {
|
|||
pfd[1].events = POLLIN;
|
||||
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *output = *(struct output **)list_get(bar->outputs, i);
|
||||
struct output *output = list_getp(bar->outputs, i);
|
||||
pfd[i+2].fd = wl_display_get_fd(output->registry->display);
|
||||
pfd[i+2].events = POLLIN;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ void bar_run(struct bar *bar) {
|
|||
while (1) {
|
||||
if (dirty) {
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *output = *(struct output **)list_get(bar->outputs, i);
|
||||
struct output *output = list_getp(bar->outputs, i);
|
||||
if (window_prerender(output->window) && output->window->cairo) {
|
||||
render(output, bar->config, bar->status);
|
||||
window_render(output->window);
|
||||
|
|
@ -223,7 +223,7 @@ void bar_run(struct bar *bar) {
|
|||
|
||||
// dispatch wl_display events
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *output = *(struct output **)list_get(bar->outputs, i);
|
||||
struct output *output = list_getp(bar->outputs, i);
|
||||
if (pfd[i+2].revents & POLLIN) {
|
||||
if (wl_display_dispatch(output->registry->display) == -1) {
|
||||
sway_log(L_ERROR, "failed to dispatch wl: %d", errno);
|
||||
|
|
@ -237,7 +237,7 @@ void bar_run(struct bar *bar) {
|
|||
|
||||
void free_workspaces(list_t *workspaces) {
|
||||
for (size_t i = 0; i < workspaces->length; ++i) {
|
||||
struct workspace *ws = *(struct workspace **)list_get(workspaces, i);
|
||||
struct workspace *ws = list_getp(workspaces, i);
|
||||
free(ws->name);
|
||||
free(ws);
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ static void free_output(struct output *output) {
|
|||
|
||||
static void free_outputs(list_t *outputs) {
|
||||
for (size_t i = 0; i < outputs->length; ++i) {
|
||||
struct output *item = *(struct output **)list_get(outputs, i);
|
||||
struct output *item = list_getp(outputs, i);
|
||||
free_output(item);
|
||||
}
|
||||
list_free(outputs);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ static void ipc_parse_config(struct config *config, const char *payload) {
|
|||
|
||||
// free previous outputs list
|
||||
for (size_t i = 0; i < config->outputs->length; ++i) {
|
||||
free(*(char **)list_get(config->outputs, i));
|
||||
free(list_getp(config->outputs, i));
|
||||
}
|
||||
list_free(config->outputs);
|
||||
config->outputs = list_new(sizeof(char *), 0);
|
||||
|
|
@ -215,7 +215,7 @@ static void ipc_parse_config(struct config *config, const char *payload) {
|
|||
|
||||
static void ipc_update_workspaces(struct bar *bar) {
|
||||
for (size_t i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *output = *(struct output **)list_get(bar->outputs, i);
|
||||
struct output *output = list_getp(bar->outputs, i);
|
||||
if (output->workspaces) {
|
||||
free_workspaces(output->workspaces);
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ static void ipc_update_workspaces(struct bar *bar) {
|
|||
json_object_object_get_ex(ws_json, "urgent", &urgent);
|
||||
|
||||
for (size_t j = 0; j < bar->outputs->length; ++j) {
|
||||
struct output *output = *(struct output **)list_get(bar->outputs, j);
|
||||
struct output *output = list_getp(bar->outputs, j);
|
||||
if (strcmp(json_object_get_string(out), output->name) == 0) {
|
||||
struct workspace *ws = malloc(sizeof(struct workspace));
|
||||
ws->num = json_object_get_int(num);
|
||||
|
|
@ -300,7 +300,7 @@ void ipc_bar_init(struct bar *bar, const char *bar_id) {
|
|||
use_output = true;
|
||||
} else {
|
||||
for (size_t j = 0; j < bar->config->outputs->length; ++j) {
|
||||
const char *conf_name = *(char **)list_get(bar->config->outputs, j);
|
||||
const char *conf_name = list_getp(bar->config->outputs, j);
|
||||
if (strcasecmp(name, conf_name) == 0) {
|
||||
use_output = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
double pos = (window->width * window->scale) - 0.5;
|
||||
bool edge = true;
|
||||
for (ssize_t i = line->block_line->length - 1; i >= 0; --i) {
|
||||
struct status_block *block = *(struct status_block **)list_get(line->block_line, i);
|
||||
struct status_block *block = list_getp(line->block_line, i);
|
||||
if (block->full_text && block->full_text[0]) {
|
||||
render_block(window, config, block, &pos, edge, is_focused);
|
||||
edge = false;
|
||||
|
|
@ -329,7 +329,7 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
// Workspaces
|
||||
if (config->workspace_buttons) {
|
||||
for (size_t i = 0; i < output->workspaces->length; ++i) {
|
||||
struct workspace *ws = *(struct workspace **)list_get(output->workspaces, i);
|
||||
struct workspace *ws = list_getp(output->workspaces, i);
|
||||
render_workspace_button(window, config, ws, &x);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static void parse_json(struct bar *bar, const char *text) {
|
|||
if (bar->status->block_line) {
|
||||
//list_foreach(bar->status->block_line, free_status_block);
|
||||
for (size_t i = 0; i < bar->status->block_line->length; ++i) {
|
||||
struct status_block *item = *(struct status_block **)list_get(bar->status->block_line, i);
|
||||
struct status_block *item = list_getp(bar->status->block_line, i);
|
||||
free_status_block(item);
|
||||
}
|
||||
list_free(bar->status->block_line);
|
||||
|
|
@ -453,7 +453,7 @@ void free_status_line(struct status_line *line) {
|
|||
if (line->block_line) {
|
||||
//list_foreach(line->block_line, free_status_block);
|
||||
for (size_t i = 0; i < line->block_line->length; ++i) {
|
||||
struct status_block *item = *(struct status_block **)list_get(line->block_line, i);
|
||||
struct status_block *item = list_getp(line->block_line, i);
|
||||
free_status_block(item);
|
||||
}
|
||||
list_free(line->block_line);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ enum scaling_mode {
|
|||
|
||||
void sway_terminate(int exit_code) {
|
||||
for (size_t i = 0; i < surfaces->length; ++i) {
|
||||
struct window *window = *(struct window **)list_get(surfaces, i);
|
||||
struct window *window = list_getp(surfaces, i);
|
||||
window_teardown(window);
|
||||
}
|
||||
list_free(surfaces);
|
||||
|
|
@ -66,7 +66,7 @@ int main(int argc, const char **argv) {
|
|||
|
||||
int desired_output = atoi(argv[1]);
|
||||
sway_log(L_INFO, "Using output %d of %zu", desired_output, registry->outputs->length);
|
||||
struct output_state *output = *(struct output_state **)list_get(registry->outputs, desired_output);
|
||||
struct output_state *output = list_getp(registry->outputs, desired_output);
|
||||
struct window *window = window_setup(registry,
|
||||
output->width, output->height, output->scale, false);
|
||||
if (!window) {
|
||||
|
|
@ -118,7 +118,7 @@ int main(int argc, const char **argv) {
|
|||
int wheight = window->height * window->scale;
|
||||
|
||||
for (size_t i = 0; i < surfaces->length; ++i) {
|
||||
struct window *window = *(struct window **)list_get(surfaces, i);
|
||||
struct window *window = list_getp(surfaces, i);
|
||||
if (window_prerender(window) && window->cairo) {
|
||||
switch (scaling_mode) {
|
||||
case SCALING_MODE_STRETCH:
|
||||
|
|
@ -195,7 +195,7 @@ int main(int argc, const char **argv) {
|
|||
while (wl_display_dispatch(registry->display) != -1);
|
||||
|
||||
for (size_t i = 0; i < surfaces->length; ++i) {
|
||||
struct window *window = *(struct window **)list_get(surfaces, i);
|
||||
struct window *window = list_getp(surfaces, i);
|
||||
window_teardown(window);
|
||||
}
|
||||
list_free(surfaces);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void sigalarm_handler(int sig) {
|
|||
|
||||
void sway_terminate(int exit_code) {
|
||||
for (size_t i = 0; i < render_data.surfaces->length; ++i) {
|
||||
struct window *window = *(struct window **)list_get(render_data.surfaces, i);
|
||||
struct window *window = list_getp(render_data.surfaces, i);
|
||||
window_teardown(window);
|
||||
}
|
||||
list_free(render_data.surfaces);
|
||||
|
|
@ -556,7 +556,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < registry->outputs->length; ++i) {
|
||||
struct output_state *output = *(struct output_state **)list_get(registry->outputs, i);
|
||||
struct output_state *output = list_getp(registry->outputs, i);
|
||||
struct window *window = window_setup(registry,
|
||||
output->width, output->height, output->scale, true);
|
||||
if (!window) {
|
||||
|
|
@ -607,8 +607,8 @@ int main(int argc, char **argv) {
|
|||
while (wl_display_dispatch(registry->display) != -1) {
|
||||
if (!locked) {
|
||||
for (size_t i = 0; i < registry->outputs->length; ++i) {
|
||||
struct output_state *output = *(struct output_state **)list_get(registry->outputs, i);
|
||||
struct window *window = *(struct window **)list_get(render_data.surfaces, i);
|
||||
struct output_state *output = list_getp(registry->outputs, i);
|
||||
struct window *window = list_getp(render_data.surfaces, i);
|
||||
lock_set_lock_surface(registry->swaylock, output->output, window->surface);
|
||||
}
|
||||
locked = true;
|
||||
|
|
@ -628,7 +628,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < render_data.surfaces->length; ++i) {
|
||||
struct window *window = *(struct window **)list_get(render_data.surfaces, i);
|
||||
struct window *window = list_getp(render_data.surfaces, i);
|
||||
window_teardown(window);
|
||||
}
|
||||
list_free(render_data.surfaces);
|
||||
|
|
@ -642,7 +642,7 @@ int main(int argc, char **argv) {
|
|||
void render(struct render_data *render_data, struct lock_config *config) {
|
||||
for (size_t i = 0; i < render_data->surfaces->length; ++i) {
|
||||
sway_log(L_DEBUG, "Render surface %zu of %zu", i, render_data->surfaces->length);
|
||||
struct window *window = *(struct window **)list_get(render_data->surfaces, i);
|
||||
struct window *window = list_getp(render_data->surfaces, i);
|
||||
if (!window_prerender(window) || !window->cairo) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue