mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-23 14:04:19 +02:00
Apply clang-format
This commit is contained in:
parent
d23a73f2b9
commit
9ac95ce69c
8 changed files with 93 additions and 49 deletions
|
|
@ -264,7 +264,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
server.modes = malloc(4 * sizeof(char *));
|
||||
if(!server.modes) {
|
||||
wlr_log(WLR_ERROR,"Error allocating mode array");
|
||||
wlr_log(WLR_ERROR, "Error allocating mode array");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -286,8 +286,8 @@ main(int argc, char *argv[]) {
|
|||
server.modes[1] = strdup("root");
|
||||
server.modes[2] = strdup("resize");
|
||||
server.modes[3] = NULL;
|
||||
if(!server.modes[0]||!server.modes[1]||server.modes[2]) {
|
||||
wlr_log(WLR_ERROR,"Error allocating default modes");
|
||||
if(!server.modes[0] || !server.modes[1] || server.modes[2]) {
|
||||
wlr_log(WLR_ERROR, "Error allocating default modes");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +551,8 @@ end:
|
|||
free(server.modes);
|
||||
|
||||
struct cg_output_config *output_config, *output_config_tmp;
|
||||
wl_list_for_each_safe(output_config, output_config_tmp, &server.output_config, link) {
|
||||
wl_list_for_each_safe(output_config, output_config_tmp,
|
||||
&server.output_config, link) {
|
||||
wl_list_remove(&output_config->link);
|
||||
free(output_config->output_name);
|
||||
free(output_config);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@
|
|||
|
||||
#define _POSIX_C_SOURCE 200812L
|
||||
|
||||
|
||||
#include "../keybinding.h"
|
||||
#include "../output.h"
|
||||
#include "../parse.h"
|
||||
#include "../seat.h"
|
||||
#include "../server.h"
|
||||
#include "../output.h"
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -450,7 +449,8 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||
server.modes = realloc(server.modes, 4 * sizeof(char *));
|
||||
|
||||
struct cg_output_config *output_config, *output_config_tmp;
|
||||
wl_list_for_each_safe(output_config, output_config_tmp, &server.output_config, link) {
|
||||
wl_list_for_each_safe(output_config, output_config_tmp,
|
||||
&server.output_config, link) {
|
||||
wl_list_remove(&output_config->link);
|
||||
free(output_config->output_name);
|
||||
free(output_config);
|
||||
|
|
|
|||
|
|
@ -453,7 +453,9 @@ keybinding_workspace_fullscreen(struct cg_server *server) {
|
|||
}
|
||||
|
||||
workspace_free_tiles(output->workspaces[output->curr_workspace]);
|
||||
if(full_screen_workspace_tiles(server->output_layout,output->wlr_output, output->workspaces[output->curr_workspace])!=0) {
|
||||
if(full_screen_workspace_tiles(
|
||||
server->output_layout, output->wlr_output,
|
||||
output->workspaces[output->curr_workspace]) != 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate space for fullscreen workspace");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
32
output.c
32
output.c
|
|
@ -480,8 +480,8 @@ handle_output_destroy(struct wl_listener *listener, void *data) {
|
|||
output_destroy(output);
|
||||
}
|
||||
|
||||
struct cg_output_config*
|
||||
output_find_config(struct cg_server* server, struct wlr_output* output) {
|
||||
struct cg_output_config *
|
||||
output_find_config(struct cg_server *server, struct wlr_output *output) {
|
||||
struct cg_output_config *config;
|
||||
wl_list_for_each(config, &server->output_config, link) {
|
||||
if(strcmp(config->output_name, output->name) == 0) {
|
||||
|
|
@ -491,31 +491,33 @@ output_find_config(struct cg_server* server, struct wlr_output* output) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void output_set_mode(struct wlr_output *output, int width, int height,
|
||||
float refresh_rate) {
|
||||
static void
|
||||
output_set_mode(struct wlr_output *output, int width, int height,
|
||||
float refresh_rate) {
|
||||
int mhz = (int)(refresh_rate * 1000);
|
||||
|
||||
if (wl_list_empty(&output->modes)) {
|
||||
if(wl_list_empty(&output->modes)) {
|
||||
wlr_log(WLR_DEBUG, "Assigning custom mode to %s", output->name);
|
||||
wlr_output_set_custom_mode(output, width, height,
|
||||
refresh_rate > 0 ? mhz : 0);
|
||||
refresh_rate > 0 ? mhz : 0);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_output_mode *mode, *best = NULL;
|
||||
wl_list_for_each(mode, &output->modes, link) {
|
||||
if (mode->width == width && mode->height == height) {
|
||||
if (mode->refresh == mhz) {
|
||||
if(mode->width == width && mode->height == height) {
|
||||
if(mode->refresh == mhz) {
|
||||
best = mode;
|
||||
break;
|
||||
}
|
||||
if (best == NULL || mode->refresh > best->refresh) {
|
||||
if(best == NULL || mode->refresh > best->refresh) {
|
||||
best = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!best) {
|
||||
wlr_log(WLR_ERROR, "Configured mode for %s not available", output->name);
|
||||
if(!best) {
|
||||
wlr_log(WLR_ERROR, "Configured mode for %s not available",
|
||||
output->name);
|
||||
wlr_log(WLR_INFO, "Picking preferred mode instead");
|
||||
best = wlr_output_preferred_mode(output);
|
||||
} else {
|
||||
|
|
@ -525,7 +527,7 @@ static void output_set_mode(struct wlr_output *output, int width, int height,
|
|||
}
|
||||
|
||||
void
|
||||
output_configure(struct cg_server* server, struct cg_output *output) {
|
||||
output_configure(struct cg_server *server, struct cg_output *output) {
|
||||
struct wlr_output *wlr_output = output->wlr_output;
|
||||
struct cg_output_config *config = output_find_config(server, wlr_output);
|
||||
if(output->wlr_output->enabled) {
|
||||
|
|
@ -541,8 +543,10 @@ output_configure(struct cg_server* server, struct cg_output *output) {
|
|||
wlr_output_set_mode(wlr_output, preferred_mode);
|
||||
}
|
||||
} else {
|
||||
output_set_mode(wlr_output, config->pos.width, config->pos.height, config->refresh_rate);
|
||||
wlr_output_layout_add(server->output_layout, wlr_output, config->pos.x, config->pos.y);
|
||||
output_set_mode(wlr_output, config->pos.width, config->pos.height,
|
||||
config->refresh_rate);
|
||||
wlr_output_layout_add(server->output_layout, wlr_output, config->pos.x,
|
||||
config->pos.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
6
output.h
6
output.h
|
|
@ -29,9 +29,9 @@ struct cg_output {
|
|||
|
||||
struct cg_output_config {
|
||||
struct wlr_box pos;
|
||||
char* output_name;
|
||||
char *output_name;
|
||||
float refresh_rate;
|
||||
struct wl_list link;// cg_server::output_config
|
||||
struct wl_list link; // cg_server::output_config
|
||||
};
|
||||
|
||||
typedef void (*cg_surface_iterator_func_t)(struct cg_output *output,
|
||||
|
|
@ -42,7 +42,7 @@ typedef void (*cg_surface_iterator_func_t)(struct cg_output *output,
|
|||
void
|
||||
handle_new_output(struct wl_listener *listener, void *data);
|
||||
void
|
||||
output_configure(struct cg_server* server, struct cg_output* output);
|
||||
output_configure(struct cg_server *server, struct cg_output *output);
|
||||
void
|
||||
output_surface_for_each_surface(struct cg_output *output,
|
||||
struct wlr_surface *surface, double ox,
|
||||
|
|
|
|||
74
parse.c
74
parse.c
|
|
@ -1,9 +1,9 @@
|
|||
#define _POSIX_C_SOURCE 200812L
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "keybinding.h"
|
||||
#include "output.h"
|
||||
|
|
@ -68,10 +68,11 @@ struct keybinding *
|
|||
parse_keybinding(struct cg_server *server, char **saveptr) {
|
||||
struct keybinding *keybinding = malloc(sizeof(struct keybinding));
|
||||
if(keybinding == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate memory for keybinding in parse_keybinding");
|
||||
wlr_log(WLR_ERROR,
|
||||
"Failed to allocate memory for keybinding in parse_keybinding");
|
||||
return NULL;
|
||||
}
|
||||
char *key = strtok_r(NULL, " ", saveptr);
|
||||
char *key = strtok_r(NULL, " ", saveptr);
|
||||
if(parse_key(keybinding, key) != 0) {
|
||||
wlr_log(WLR_ERROR, "Could not parse key definition \"%s\"", key);
|
||||
free(keybinding);
|
||||
|
|
@ -158,7 +159,8 @@ struct keybinding *
|
|||
parse_escape(char **saveptr) {
|
||||
struct keybinding *keybinding = malloc(sizeof(struct keybinding));
|
||||
if(keybinding == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate memory for keybinding in parse_escape");
|
||||
wlr_log(WLR_ERROR,
|
||||
"Failed to allocate memory for keybinding in parse_escape");
|
||||
return NULL;
|
||||
}
|
||||
char *key = strtok_r(NULL, " ", saveptr);
|
||||
|
|
@ -202,7 +204,7 @@ parse_workspaces(char **saveptr) {
|
|||
}
|
||||
|
||||
int
|
||||
parse_uint(char **saveptr, const char* delim) {
|
||||
parse_uint(char **saveptr, const char *delim) {
|
||||
char *uint_str = strtok_r(NULL, delim, saveptr);
|
||||
if(uint_str == NULL) {
|
||||
wlr_log(WLR_ERROR, "Expected a non-negative integer, got nothing");
|
||||
|
|
@ -212,13 +214,16 @@ parse_uint(char **saveptr, const char* delim) {
|
|||
if(uint >= 0 && uint <= INT_MAX) {
|
||||
return uint;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Error parsing non-negative integer. Must be a number larger or equal to 0 and less or equal to %d",INT_MAX);
|
||||
wlr_log(WLR_ERROR,
|
||||
"Error parsing non-negative integer. Must be a number larger "
|
||||
"or equal to 0 and less or equal to %d",
|
||||
INT_MAX);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
parse_float(char **saveptr, const char* delim) {
|
||||
parse_float(char **saveptr, const char *delim) {
|
||||
char *uint_str = strtok_r(NULL, delim, saveptr);
|
||||
if(uint_str == NULL) {
|
||||
wlr_log(WLR_ERROR, "Expected a non-negative float, got nothing");
|
||||
|
|
@ -228,68 +233,95 @@ parse_float(char **saveptr, const char* delim) {
|
|||
if(ufloat >= 0) {
|
||||
return ufloat;
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Error parsing non-negative float. Must be a number larger or equal to 0");
|
||||
wlr_log(WLR_ERROR, "Error parsing non-negative float. Must be a number "
|
||||
"larger or equal to 0");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
parse_output_config(struct wl_list *config_list, char **saveptr) {
|
||||
struct cg_output_config* cfg = malloc(sizeof(struct cg_output_config));
|
||||
struct cg_output_config *cfg = malloc(sizeof(struct cg_output_config));
|
||||
if(cfg == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate memory for output configuration");
|
||||
wlr_log(WLR_ERROR,
|
||||
"Failed to allocate memory for output configuration");
|
||||
goto error;
|
||||
}
|
||||
char *name = strtok_r(NULL, " ", saveptr);
|
||||
if(name == NULL) {
|
||||
wlr_log(WLR_ERROR, "Expected name of output to be configured, got none");
|
||||
wlr_log(WLR_ERROR,
|
||||
"Expected name of output to be configured, got none");
|
||||
goto error;
|
||||
}
|
||||
char *pos_str = strtok_r(NULL, " ", saveptr);
|
||||
if(pos_str == NULL || strcmp(pos_str, "pos") != 0) {
|
||||
wlr_log(WLR_ERROR, "Expected keyword \"pos\" in output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Expected keyword \"pos\" in output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cfg->pos.x = parse_uint(saveptr, " ");
|
||||
if(cfg->pos.x < 0) {
|
||||
wlr_log(WLR_ERROR, "Error parsing x coordinate of output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Error parsing x coordinate of output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cfg->pos.y = parse_uint(saveptr, " ");
|
||||
if(cfg->pos.y < 0) {
|
||||
wlr_log(WLR_ERROR, "Error parsing y coordinate of output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Error parsing y coordinate of output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
char *res_str = strtok_r(NULL, " ", saveptr);
|
||||
if(res_str == NULL || strcmp(res_str, "res") != 0) {
|
||||
wlr_log(WLR_ERROR, "Expected keyword \"res\" in output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Expected keyword \"res\" in output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cfg->pos.width = parse_uint(saveptr, "x");
|
||||
if(cfg->pos.width <= 0) {
|
||||
wlr_log(WLR_ERROR, "Error parsing width of output configuration for output %s (hint: width must be larger than 0)", name);
|
||||
wlr_log(WLR_ERROR,
|
||||
"Error parsing width of output configuration for output %s "
|
||||
"(hint: width must be larger than 0)",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cfg->pos.height = parse_uint(saveptr, " ");
|
||||
if(cfg->pos.height <= 0) {
|
||||
wlr_log(WLR_ERROR, "Error parsing height of output configuration for output %s (hint: height must e larger than 0)", name);
|
||||
wlr_log(WLR_ERROR,
|
||||
"Error parsing height of output configuration for output %s "
|
||||
"(hint: height must e larger than 0)",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
char *rate_str = strtok_r(NULL, " ", saveptr);
|
||||
if(rate_str == NULL || strcmp(rate_str, "rate") != 0) {
|
||||
wlr_log(WLR_ERROR, "Expected keyword \"rate\" in output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Expected keyword \"rate\" in output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cfg->refresh_rate = parse_float(saveptr, " ");
|
||||
if(cfg->refresh_rate <= 0.0) {
|
||||
wlr_log(WLR_ERROR, "Error parsing refresh rate of output configuration for output %s", name);
|
||||
wlr_log(
|
||||
WLR_ERROR,
|
||||
"Error parsing refresh rate of output configuration for output %s",
|
||||
name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +331,9 @@ parse_output_config(struct wl_list *config_list, char **saveptr) {
|
|||
|
||||
error:
|
||||
free(cfg);
|
||||
wlr_log(WLR_ERROR, "Output configuration must be of the form \"output <name> pos <x> <y> res <width>x<height> rate <refresh_rate>");
|
||||
wlr_log(WLR_ERROR,
|
||||
"Output configuration must be of the form \"output <name> pos <x> "
|
||||
"<y> res <width>x<height> rate <refresh_rate>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@
|
|||
#include "workspace.h"
|
||||
|
||||
int
|
||||
full_screen_workspace_tiles(struct wlr_output_layout *layout,struct wlr_output *output,
|
||||
full_screen_workspace_tiles(struct wlr_output_layout *layout,
|
||||
struct wlr_output *output,
|
||||
struct cg_workspace *workspace) {
|
||||
workspace->focused_tile = calloc(1, sizeof(struct cg_tile));
|
||||
if(!workspace->focused_tile) {
|
||||
|
|
@ -45,8 +46,9 @@ full_screen_workspace(struct cg_output *output) {
|
|||
if(!workspace) {
|
||||
return NULL;
|
||||
}
|
||||
workspace->server=output->server;
|
||||
if(full_screen_workspace_tiles(output->server->output_layout, output->wlr_output, workspace)!=0) {
|
||||
workspace->server = output->server;
|
||||
if(full_screen_workspace_tiles(output->server->output_layout,
|
||||
output->wlr_output, workspace) != 0) {
|
||||
free(workspace);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ struct cg_workspace {
|
|||
struct cg_workspace *
|
||||
full_screen_workspace(struct cg_output *output);
|
||||
int
|
||||
full_screen_workspace_tiles(struct wlr_output_layout *layout,struct wlr_output *output,
|
||||
full_screen_workspace_tiles(struct wlr_output_layout *layout,
|
||||
struct wlr_output *output,
|
||||
struct cg_workspace *workspace);
|
||||
void
|
||||
workspace_free_tiles(struct cg_workspace *workspace);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue