1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

Apply clang-format.

This commit is contained in:
Brenden Matthews 2023-02-24 08:43:15 -05:00
parent 4e1e815fdd
commit a39015b7bd
No known key found for this signature in database
GPG Key ID: B49ABB7270D9D4FD
12 changed files with 96 additions and 80 deletions

View File

@ -34,9 +34,10 @@ void colour_setting::lua_setter(lua::state &l, bool init) {
}
} // namespace priv
priv::colour_setting color[COLORS_CUSTOM] = {{"color0", white_argb32}, {"color1", white_argb32},
{"color2", white_argb32}, {"color3", white_argb32},
{"color4", white_argb32}, {"color5", white_argb32},
{"color6", white_argb32}, {"color7", white_argb32},
{"color8", white_argb32}, {"color9", white_argb32}};
priv::colour_setting color[COLORS_CUSTOM] = {
{"color0", white_argb32}, {"color1", white_argb32},
{"color2", white_argb32}, {"color3", white_argb32},
{"color4", white_argb32}, {"color5", white_argb32},
{"color6", white_argb32}, {"color7", white_argb32},
{"color8", white_argb32}, {"color9", white_argb32}};
priv::colour_setting default_color("default_color", white_argb32);

View File

@ -23,8 +23,8 @@
*/
#pragma once
#include "config.h"
#include "colours.h"
#include "config.h"
#include "setting.hh"
namespace priv {

View File

@ -51,7 +51,7 @@ Colour Colour::from_argb32(uint32_t argb) {
return out;
}
Colour error_colour { 0xff, 0x00, 0x00, 0xff };
Colour error_colour{0xff, 0x00, 0x00, 0xff};
Colour parse_color(const char *name) {
unsigned short r, g, b;

View File

@ -29,10 +29,10 @@
#ifndef _COLOURS_H
#define _COLOURS_H
#include <memory>
#include <string>
#include <cassert>
#include <climits>
#include <memory>
#include <string>
#ifdef BUILD_X11
#include "x11.h"
#endif /* BUILD_X11 */
@ -43,7 +43,7 @@ struct Colour {
uint8_t blue;
uint8_t alpha;
public:
public:
// Compare two instances.
bool operator==(const Colour &c) const {
return c.red == red && c.green == green && c.blue == blue &&

View File

@ -1432,16 +1432,22 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
break;
#endif /* BUILD_GUI */
case FG:
if (draw_mode == FG) { set_foreground_color(Colour::from_argb32(current->arg)); }
if (draw_mode == FG) {
set_foreground_color(Colour::from_argb32(current->arg));
}
break;
#ifdef BUILD_GUI
case BG:
if (draw_mode == BG) { set_foreground_color(Colour::from_argb32(current->arg)); }
if (draw_mode == BG) {
set_foreground_color(Colour::from_argb32(current->arg));
}
break;
case OUTLINE:
if (draw_mode == OUTLINE) { set_foreground_color(Colour::from_argb32(current->arg)); }
if (draw_mode == OUTLINE) {
set_foreground_color(Colour::from_argb32(current->arg));
}
break;
case OFFSET:

View File

@ -37,9 +37,9 @@
#include <sys/utsname.h> /* struct uname_s */
#include <csignal>
#include <memory>
#include "colours.h"
#include "common.h" /* at least for struct dns_data */
#include "luamm.hh"
#include "colours.h"
#if defined(HAS_MCHECK_H)
#include <mcheck.h>

View File

@ -32,8 +32,8 @@
#include "algebra.h"
#include "bsdapm.h"
#include "build.h"
#include "colours.h"
#include "colour-settings.h"
#include "colours.h"
#include "combine.h"
#include "diskio.h"
#include "entropy.h"
@ -751,7 +751,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
#endif /* BUILD_GUI */
END OBJ(color, nullptr)
#ifdef BUILD_GUI
if (out_to_gui(*state)) {
if (out_to_gui(*state)) {
Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state);
obj->data.l = c.to_argb32();
set_current_text_color(c);
@ -767,34 +767,44 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.print = &new_fg;
#ifdef BUILD_GUI
END OBJ(color0, nullptr) Colour c = color[0].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color1, nullptr) Colour c = color[1].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color2, nullptr) Colour c = color[2].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color3, nullptr) Colour c = color[3].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color4, nullptr) Colour c = color[4].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color5, nullptr) Colour c = color[5].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color6, nullptr) Colour c = color[6].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color7, nullptr) Colour c = color[7].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color8, nullptr) Colour c = color[8].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(color9, nullptr) Colour c = color[9].get(*state);
obj->data.l = c.to_argb32(); set_current_text_color(c);
obj->data.l = c.to_argb32();
set_current_text_color(c);
obj->callbacks.print = &new_fg;
END OBJ(font, nullptr) scan_font(obj, arg);
obj->callbacks.print = &new_font;
@ -1440,14 +1450,14 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
#ifdef BUILD_GUI
obj->data.l =
(arg != nullptr ? parse_color(arg) : default_shade_color.get(*state))
.to_argb32();
.to_argb32();
obj->callbacks.print = &new_bg;
#endif /* BUILD_GUI */
END OBJ(outlinecolor, nullptr)
#ifdef BUILD_GUI
obj->data.l =
(arg != nullptr ? parse_color(arg) : default_outline_color.get(*state))
.to_argb32();
.to_argb32();
obj->callbacks.print = &new_outline;
#endif /* BUILD_GUI */
END OBJ(stippled_hr, nullptr)

View File

@ -26,8 +26,8 @@
#include <config.h>
#include "conky.h"
#include "colours.h"
#include "conky.h"
#include "display-ncurses.hh"
#include "gui.h"
#include "nc.h"
@ -40,7 +40,7 @@
#endif
#ifdef BUILD_NCURSES
extern WINDOW *ncurses_window;
extern WINDOW* ncurses_window;
#endif
namespace conky {
@ -65,39 +65,38 @@ extern void init_ncurses_output() {}
#define COLORS_BUILTIN 8
Colour ncurses_colors[COLORS_BUILTIN + COLORS_CUSTOM] = {
{0x00, 0x00, 0x00, 0xff}, // BLACK
{0xff, 0x00, 0x00, 0xff}, // RED
{0x00, 0xff, 0x00, 0xff}, // GREEN
{0xff, 0xff, 0x00, 0xff}, // YELLOW
{0x00, 0x00, 0xff, 0xff}, // BLUE
{0xff, 0x00, 0xff, 0xff}, // MAGENTA
{0x00, 0xff, 0xff, 0xff}, // CYAN
{0xff, 0xff, 0xff, 0xff}, // WHITE
{0x00, 0x00, 0x00, 0xff}, // BLACK
{0xff, 0x00, 0x00, 0xff}, // RED
{0x00, 0xff, 0x00, 0xff}, // GREEN
{0xff, 0xff, 0x00, 0xff}, // YELLOW
{0x00, 0x00, 0xff, 0xff}, // BLUE
{0xff, 0x00, 0xff, 0xff}, // MAGENTA
{0x00, 0xff, 0xff, 0xff}, // CYAN
{0xff, 0xff, 0xff, 0xff}, // WHITE
};
// Find the nearest ncurses color.
int to_ncurses(const Colour& c) {
int mindiff = INT_MAX;
int best_nccolor = 0;
for (int nccolor = 0; nccolor < COLORS_BUILTIN + COLORS_CUSTOM; nccolor++) {
const Colour& other = ncurses_colors[nccolor];
int diff = abs(c.red - other.red) +
abs(c.green - other.green) +
abs(c.blue - other.blue);
// Find the nearest ncurses color.
int to_ncurses(const Colour& c) {
int mindiff = INT_MAX;
int best_nccolor = 0;
for (int nccolor = 0; nccolor < COLORS_BUILTIN + COLORS_CUSTOM; nccolor++) {
const Colour& other = ncurses_colors[nccolor];
int diff = abs(c.red - other.red) + abs(c.green - other.green) +
abs(c.blue - other.blue);
if (diff < mindiff) {
mindiff = diff;
best_nccolor = nccolor;
}
if (diff < mindiff) {
mindiff = diff;
best_nccolor = nccolor;
}
return best_nccolor;
}
return best_nccolor;
}
Colour from_ncurses(int nccolor) {
if (nccolor >= 0 && nccolor < COLORS_BUILTIN + COLORS_CUSTOM) {
return ncurses_colors[nccolor];
}
return error_colour;
if (nccolor >= 0 && nccolor < COLORS_BUILTIN + COLORS_CUSTOM) {
return ncurses_colors[nccolor];
}
return error_colour;
}
display_output_ncurses::display_output_ncurses()
@ -114,9 +113,10 @@ bool display_output_ncurses::detect() {
}
bool display_output_ncurses::initialize() {
for(int i = 0; i < COLORS_CUSTOM; i++) {
for (int i = 0; i < COLORS_CUSTOM; i++) {
Colour c = color[i].get(*state);
init_color(COLORS_BUILTIN + i, (1000*c.red)/255, (1000*c.green)/255, (1000*c.blue)/255);
init_color(COLORS_BUILTIN + i, (1000 * c.red) / 255, (1000 * c.green) / 255,
(1000 * c.blue) / 255);
ncurses_colors[COLORS_BUILTIN + i] = c;
}
@ -139,7 +139,7 @@ void display_output_ncurses::begin_draw_text() {
void display_output_ncurses::end_draw_text() {}
void display_output_ncurses::draw_string(const char *s, int) {
void display_output_ncurses::draw_string(const char* s, int) {
printw("%s", s);
}

View File

@ -29,8 +29,8 @@
#include <type_traits>
#include <vector>
#include "luamm.hh"
#include "colours.h"
#include "luamm.hh"
namespace conky {

View File

@ -523,9 +523,9 @@ bool display_output_wayland::main_loop_wait(double t) {
bool scale_changed = global_window->scale != global_window->pending_scale;
/* resize window if it isn't right size */
if ((fixed_size == 0) && (text_width + 2 * border_total != width ||
text_height + 2 * border_total != height ||
scale_changed)) {
if ((fixed_size == 0) &&
(text_width + 2 * border_total != width ||
text_height + 2 * border_total != height || scale_changed)) {
/* clamp text_width to configured maximum */
if (maximum_width.get(*state)) {
int mw = global_window->scale * maximum_width.get(*state);
@ -668,11 +668,10 @@ void display_output_wayland::cleanup() {
void display_output_wayland::set_foreground_color(Colour c) {
current_color = c;
#ifdef BUILD_ARGB
current_color.alpha = own_window_argb_value.get(*state);
current_color.alpha = own_window_argb_value.get(*state);
#endif /* BUILD_ARGB */
if (global_window->cr) {
cairo_set_source_rgba(global_window->cr,
current_color.red / 255.0,
cairo_set_source_rgba(global_window->cr, current_color.red / 255.0,
current_color.green / 255.0,
current_color.blue / 255.0,
current_color.alpha / 255.0);
@ -813,11 +812,8 @@ void display_output_wayland::clear_text(int exposures) {
#endif
}
#endif
cairo_set_source_rgba(window->cr,
color.red / 255.0,
color.green / 255.0,
color.blue / 255.0,
color.alpha / 255.0);
cairo_set_source_rgba(window->cr, color.red / 255.0, color.green / 255.0,
color.blue / 255.0, color.alpha / 255.0);
cairo_set_operator(window->cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(window->cr);
cairo_restore(window->cr);
@ -841,7 +837,8 @@ int display_output_wayland::font_descent(unsigned int f) {
return pango_fonts[f].metrics.descent;
}
void display_output_wayland::setup_fonts(void) { /* Nothing to do here */ }
void display_output_wayland::setup_fonts(void) { /* Nothing to do here */
}
void display_output_wayland::set_font(unsigned int f) {
assert(f < pango_fonts.size());
@ -1045,8 +1042,8 @@ void window_allocate_buffer(struct window *window) {
int scale = window->pending_scale;
struct shm_pool *pool;
pool = shm_pool_create(window->shm, data_length_for_shm_surface(
&window->rectangle, scale));
pool = shm_pool_create(
window->shm, data_length_for_shm_surface(&window->rectangle, scale));
if (!pool) {
fprintf(stderr, "could not allocate shm pool\n");
return;
@ -1127,7 +1124,8 @@ void window_resize(struct window *window, int width, int height) {
void window_commit_buffer(struct window *window) {
assert(window->cairo_surface != nullptr);
wl_surface_set_buffer_scale(global_window->surface, global_window->pending_scale);
wl_surface_set_buffer_scale(global_window->surface,
global_window->pending_scale);
wl_surface_attach(window->surface,
get_buffer_from_cairo_surface(window->cairo_surface), 0, 0);
/* repaint all the pixels in the surface, change size to only repaint changed

View File

@ -51,8 +51,8 @@
#include <sstream>
#include <unordered_map>
#include "conky.h"
#include "colours.h"
#include "conky.h"
#include "display-x11.hh"
#include "gui.h"
#include "llua.h"
@ -64,7 +64,7 @@
// TODO: cleanup externs (move to conky.h ?)
#ifdef OWN_WINDOW
extern int fixed_size, fixed_pos;
#endif /* OWN_WINDOW */
#endif /* OWN_WINDOW */
extern int text_start_x, text_start_y; /* text start position in window */
extern int text_offset_x, text_offset_y; /* offset for start position */
extern int text_width,
@ -612,7 +612,8 @@ void display_output_x11::set_foreground_color(Colour c) {
current_color.alpha = own_window_argb_value.get(*state);
}
#endif /* BUILD_ARGB */
XSetForeground(display, window.gc, current_color.to_x11_color(display, screen));
XSetForeground(display, window.gc,
current_color.to_x11_color(display, screen));
}
int display_output_x11::calc_text_width(const char *s) {

View File

@ -599,7 +599,6 @@ void x11_init_window(lua::state &l __attribute__((unused)), bool own) {
0,
0};
XWMHints wmHint;
Atom xa;
@ -630,7 +629,8 @@ void x11_init_window(lua::state &l __attribute__((unused)), bool own) {
if (own_window_type.get(l) == TYPE_UTILITY) {
XRectangle rect;
XserverRegion region = XFixesCreateRegion(display, &rect, 1);
XFixesSetWindowShapeRegion(display, window.window, ShapeInput, 0, 0, region);
XFixesSetWindowShapeRegion(display, window.window, ShapeInput, 0, 0,
region);
XFixesDestroyRegion(display, region);
}
#endif /* BUILD_XFIXES */