Update .clang-format

Align with wlroots style
This commit is contained in:
Johan Malm 2020-09-28 20:41:41 +01:00
parent 96b5ab1fc1
commit 96e05057a3
32 changed files with 669 additions and 515 deletions

View file

@ -7,12 +7,12 @@
#include <stdio.h>
#include <stdlib.h>
#include "theme/theme.h"
#include "xbm/xbm.h"
#include "xbm/parse.h"
#include "config/rcxml.h"
#include "common/dir.h"
#include "common/grab-file.h"
#include "config/rcxml.h"
#include "theme/theme.h"
#include "xbm/parse.h"
#include "xbm/xbm.h"
/* built-in 6x6 buttons */
char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
@ -20,27 +20,30 @@ char iconify_button_normal[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
char max_button_normal[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
char max_button_toggled[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
static struct wlr_texture *texture_from_pixmap(struct wlr_renderer *renderer,
struct pixmap *pixmap)
static struct wlr_texture *
texture_from_pixmap(struct wlr_renderer *renderer, struct pixmap *pixmap)
{
if (!pixmap)
if (!pixmap) {
return NULL;
}
return wlr_texture_from_pixels(renderer, WL_SHM_FORMAT_ARGB8888,
pixmap->width * 4, pixmap->width,
pixmap->height, pixmap->data);
}
static struct wlr_texture *texture_from_builtin(struct wlr_renderer *renderer,
const char *button)
static struct wlr_texture *
texture_from_builtin(struct wlr_renderer *renderer, const char *button)
{
struct pixmap pixmap = parse_xbm_builtin(button, 6);
struct wlr_texture *texture = texture_from_pixmap(renderer, &pixmap);
if (pixmap.data)
if (pixmap.data) {
free(pixmap.data);
}
return texture;
}
static char *xbm_path(const char *button)
static char *
xbm_path(const char *button)
{
static char buffer[4096] = { 0 };
snprintf(buffer, sizeof(buffer), "%s/%s", theme_dir(rc.theme_name),
@ -48,38 +51,48 @@ static char *xbm_path(const char *button)
return buffer;
}
static void load_button(struct wlr_renderer *renderer, const char *filename,
struct wlr_texture **texture, char *button)
static void
load_button(struct wlr_renderer *renderer, const char *filename,
struct wlr_texture **texture, char *button)
{
/* Read file into memory as it's easier to tokenzie that way */
char *buffer = grab_file(xbm_path(filename));
if (!buffer)
if (!buffer) {
goto out;
}
struct token *tokens = tokenize_xbm(buffer);
free(buffer);
struct pixmap pixmap = parse_xbm_tokens(tokens);
*texture = texture_from_pixmap(renderer, &pixmap);
if (tokens)
if (tokens) {
free(tokens);
if (pixmap.data)
}
if (pixmap.data) {
free(pixmap.data);
}
out:
if (!(*texture))
if (!(*texture)) {
*texture = texture_from_builtin(renderer, button);
}
}
/* clang-format off */
void xbm_load(struct wlr_renderer *r)
void
xbm_load(struct wlr_renderer *r)
{
parse_set_color(theme.window_active_button_unpressed_image_color);
load_button(r, "close.xbm", &theme.xbm_close_active_unpressed, close_button_normal);
load_button(r, "max.xbm", &theme.xbm_maximize_active_unpressed, max_button_normal);
load_button(r, "iconify.xbm", &theme.xbm_iconify_active_unpressed, iconify_button_normal);
load_button(r, "close.xbm", &theme.xbm_close_active_unpressed,
close_button_normal);
load_button(r, "max.xbm", &theme.xbm_maximize_active_unpressed,
max_button_normal);
load_button(r, "iconify.xbm", &theme.xbm_iconify_active_unpressed,
iconify_button_normal);
parse_set_color(theme.window_inactive_button_unpressed_image_color);
load_button(r, "close.xbm", &theme.xbm_close_inactive_unpressed, close_button_normal);
load_button(r, "max.xbm", &theme.xbm_maximize_inactive_unpressed, max_button_normal);
load_button(r, "iconify.xbm", &theme.xbm_iconify_inactive_unpressed, iconify_button_normal);
load_button(r, "close.xbm", &theme.xbm_close_inactive_unpressed,
close_button_normal);
load_button(r, "max.xbm", &theme.xbm_maximize_inactive_unpressed,
max_button_normal);
load_button(r, "iconify.xbm", &theme.xbm_iconify_inactive_unpressed,
iconify_button_normal);
}
/* clang-format on */