1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-12 11:04:10 +00:00

Run clang-format.

This commit is contained in:
Brenden Matthews 2022-10-13 14:44:26 -05:00
parent 1f661d2432
commit b06f658ebf
No known key found for this signature in database
GPG Key ID: B49ABB7270D9D4FD
6 changed files with 40 additions and 62 deletions

View File

@ -640,7 +640,7 @@ void print_battery_time(struct text_object *obj, char *p,
} }
void battery_power_draw(struct text_object *obj, char *p, void battery_power_draw(struct text_object *obj, char *p,
unsigned int p_max_size) { unsigned int p_max_size) {
get_battery_power_draw(p, p_max_size, obj->data.s); get_battery_power_draw(p, p_max_size, obj->data.s);
} }

View File

@ -474,9 +474,7 @@ void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) {
fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.rate\"\n"); fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.rate\"\n");
} }
if (rate > 0) { if (rate > 0) { ret = (double)rate / (double)1000; }
ret = (double)rate/(double)1000;
}
snprintf(buffer, n, "%.1f", ret); snprintf(buffer, n, "%.1f", ret);
} }

View File

@ -70,18 +70,14 @@ void gradient_factory::setup_masks() {
mask[2] |= 1 << i; mask[2] |= 1 << i;
} }
if (colour_depth % 3 == 1) { if (colour_depth % 3 == 1) { mask[1] |= 1 << (colour_depth / 3); }
mask[1] |= 1 << (colour_depth / 3);
}
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) { mask[i] = mask[i] << shift[i]; }
mask[i] = mask[i] << shift[i];
}
} }
void gradient_factory::setup_colour_depth() { void gradient_factory::setup_colour_depth() {
#ifdef BUILD_X11 #ifdef BUILD_X11
if (state == nullptr) { // testing purposes if (state == nullptr) { // testing purposes
colour_depth = 24; colour_depth = 24;
} else if (out_to_x.get(*state)) { } else if (out_to_x.get(*state)) {
colour_depth = DisplayPlanes(display, screen); colour_depth = DisplayPlanes(display, screen);

View File

@ -50,7 +50,7 @@ class gradient_factory {
public: public:
gradient_factory(int width, unsigned long first_colour, gradient_factory(int width, unsigned long first_colour,
unsigned long last_colour); unsigned long last_colour);
virtual ~gradient_factory() { } virtual ~gradient_factory() {}
colour_array create_gradient(); colour_array create_gradient();

View File

@ -2353,30 +2353,33 @@ void get_battery_short_status(char *buffer, unsigned int n, const char *bat) {
void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) { void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) {
static int reported = 0; static int reported = 0;
char current_now_path[256], voltage_now_path[256], current_now_val[256], voltage_now_val[256]; char current_now_path[256], voltage_now_path[256], current_now_val[256],
voltage_now_val[256];
char *ptr; char *ptr;
long current_now, voltage_now; long current_now, voltage_now;
FILE *current_now_file; FILE *current_now_file;
FILE *voltage_now_file; FILE *voltage_now_file;
double result; double result;
snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now", bat); snprintf(current_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/current_now",
snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now", bat); bat);
snprintf(voltage_now_path, 255, SYSFS_BATTERY_BASE_PATH "/%s/voltage_now",
bat);
current_now_file = open_file(current_now_path, &reported); current_now_file = open_file(current_now_path, &reported);
voltage_now_file = open_file(voltage_now_path, &reported); voltage_now_file = open_file(voltage_now_path, &reported);
if (current_now_file != nullptr && voltage_now_file != nullptr) { if (current_now_file != nullptr && voltage_now_file != nullptr) {
fgets(current_now_val, 256, current_now_file); fgets(current_now_val, 256, current_now_file);
fgets(voltage_now_val, 256, voltage_now_file); fgets(voltage_now_val, 256, voltage_now_file);
current_now = strtol(current_now_val, &ptr, 10); current_now = strtol(current_now_val, &ptr, 10);
voltage_now = strtol(voltage_now_val, &ptr, 10); voltage_now = strtol(voltage_now_val, &ptr, 10);
result = (double)(current_now*voltage_now)/(double)1000000000000; result = (double)(current_now * voltage_now) / (double)1000000000000;
snprintf(buffer, n, "%.1f", result); snprintf(buffer, n, "%.1f", result);
fclose(current_now_file); fclose(current_now_file);
fclose(voltage_now_file); fclose(voltage_now_file);
} }
} }

View File

@ -32,21 +32,21 @@
#include <gradient.h> #include <gradient.h>
const int width = 4; const int width = 4;
#ifdef BUILD_X11 // 24-bit color depth #ifdef BUILD_X11 // 24-bit color depth
const long colour = 0x996633; // brown const long colour = 0x996633; // brown
const long expected_hue = 256; const long expected_hue = 256;
const long expected_value = 0x99; // max(0x99, 0x66, 0x33) const long expected_value = 0x99; // max(0x99, 0x66, 0x33)
const long expected_chroma = 0x66; // (0x99 - 0x33) const long expected_chroma = 0x66; // (0x99 - 0x33)
const long expected_luma = 20712665L; const long expected_luma = 20712665L;
const long expected_saturation = 122880L; const long expected_saturation = 122880L;
const long expected_red = 0x99; const long expected_red = 0x99;
const long expected_green = 0x66; const long expected_green = 0x66;
const long expected_blue = 0x33; const long expected_blue = 0x33;
#else // 16-bit color depth #else // 16-bit color depth
const long colour = 0x99A6; // brown const long colour = 0x99A6; // brown
const long expected_hue = 275; const long expected_hue = 275;
const long expected_value = 0x13; // max(0x13, 0x0d, 0x06) const long expected_value = 0x13; // max(0x13, 0x0d, 0x06)
const long expected_chroma = 0x0d; // (0x1a - 0x06) const long expected_chroma = 0x0d; // (0x1a - 0x06)
const long expected_luma = 2610173L; const long expected_luma = 2610173L;
const long expected_saturation = 126113L; const long expected_saturation = 126113L;
const long expected_red = 0x13; const long expected_red = 0x13;
@ -66,15 +66,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
factory->convert_from_rgb(colour, result); factory->convert_from_rgb(colour, result);
SECTION("red") { SECTION("red") { REQUIRE(result[0] == expected_red * full_scale); }
REQUIRE(result[0] == expected_red * full_scale); SECTION("green") { REQUIRE(result[1] == expected_green * full_scale); }
} SECTION("blue") { REQUIRE(result[2] == expected_blue * full_scale); }
SECTION("green") {
REQUIRE(result[1] == expected_green * full_scale);
}
SECTION("blue") {
REQUIRE(result[2] == expected_blue * full_scale);
}
delete factory; delete factory;
} }
@ -85,15 +79,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
factory->convert_from_rgb(colour, result); factory->convert_from_rgb(colour, result);
SECTION("hue") { SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); }
REQUIRE(result[0] == expected_hue * 60); SECTION("saturation") { REQUIRE(result[1] == expected_saturation); }
} SECTION("value") { REQUIRE(result[2] == expected_value * full_scale); }
SECTION("saturation") {
REQUIRE(result[1] == expected_saturation);
}
SECTION("value") {
REQUIRE(result[2] == expected_value * full_scale);
}
delete factory; delete factory;
} }
@ -104,15 +92,9 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
factory->convert_from_rgb(colour, result); factory->convert_from_rgb(colour, result);
SECTION("hue") { SECTION("hue") { REQUIRE(result[0] == expected_hue * 60); }
REQUIRE(result[0] == expected_hue * 60); SECTION("chroma") { REQUIRE(result[1] == expected_chroma * full_scale); }
} SECTION("luma") { REQUIRE(result[2] == expected_luma); }
SECTION("chroma") {
REQUIRE(result[1] == expected_chroma * full_scale);
}
SECTION("luma") {
REQUIRE(result[2] == expected_luma);
}
delete factory; delete factory;
} }
@ -121,7 +103,6 @@ TEST_CASE("gradient_factory::convert_from_rgb returns correct value") {
TEST_CASE( TEST_CASE(
"gradient_factory should convert to and from rgb " "gradient_factory should convert to and from rgb "
"and get the initial value") { "and get the initial value") {
SECTION("rgb_gradient_factory") { SECTION("rgb_gradient_factory") {
long tmp[3]; long tmp[3];
auto factory = new conky::rgb_gradient_factory(width, colour, colour); auto factory = new conky::rgb_gradient_factory(width, colour, colour);
@ -129,7 +110,7 @@ TEST_CASE(
auto result = factory->convert_to_rgb(tmp); auto result = factory->convert_to_rgb(tmp);
REQUIRE(result == colour); REQUIRE(result == colour);
delete factory; delete factory;
} }
@ -145,7 +126,7 @@ TEST_CASE(
auto result = factory->convert_to_rgb(tmp); auto result = factory->convert_to_rgb(tmp);
REQUIRE(result == colour); REQUIRE(result == colour);
delete factory; delete factory;
} }
@ -156,7 +137,7 @@ TEST_CASE(
auto result = factory->convert_to_rgb(tmp); auto result = factory->convert_to_rgb(tmp);
REQUIRE(result == colour); REQUIRE(result == colour);
delete factory; delete factory;
} }
#endif #endif