mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 00:58:36 +00:00
Apply clang-format.
This commit is contained in:
parent
cf16110c7a
commit
76b0f049bc
@ -27,8 +27,8 @@
|
||||
*
|
||||
*/
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "gui.h"
|
||||
#include "logging.h"
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#endif /*BUILD_X11*/
|
||||
@ -87,59 +87,54 @@ unsigned int adjust_colours(unsigned int colour) {
|
||||
return colour;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
#ifdef BUILD_WAYLAND
|
||||
static int hex_nibble_value(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
return c - 'a' + 10;
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
return -1;
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
return c - 'a' + 10;
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
long manually_get_x11_color(const char *name) {
|
||||
unsigned short r, g, b;
|
||||
size_t len = strlen(name);
|
||||
if (OsLookupColor(-1, name, len, &r, &g, &b)) {
|
||||
return 0x000000ff | ((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8);
|
||||
}
|
||||
if (name[0] == '#') {
|
||||
name++;
|
||||
len--;
|
||||
}
|
||||
if (len == 6 || len == 8)
|
||||
{
|
||||
unsigned char argb[4] = {0xff, 0, 0, 0};
|
||||
for (size_t i = 0; i + 1 < len; i += 2) {
|
||||
int nib1 = hex_nibble_value(name[i]);
|
||||
int nib2 = hex_nibble_value(name[i+1]);
|
||||
if (nib1 < 0 || nib2 < 0) {
|
||||
goto err;
|
||||
}
|
||||
int val = (nib1 << 4) + nib2;
|
||||
unsigned short r, g, b;
|
||||
size_t len = strlen(name);
|
||||
if (OsLookupColor(-1, name, len, &r, &g, &b)) {
|
||||
return 0x000000ff | ((r & 0xff) << 24) | ((g & 0xff) << 16) |
|
||||
((b & 0xff) << 8);
|
||||
}
|
||||
if (name[0] == '#') {
|
||||
name++;
|
||||
len--;
|
||||
}
|
||||
if (len == 6 || len == 8) {
|
||||
unsigned char argb[4] = {0xff, 0, 0, 0};
|
||||
for (size_t i = 0; i + 1 < len; i += 2) {
|
||||
int nib1 = hex_nibble_value(name[i]);
|
||||
int nib2 = hex_nibble_value(name[i + 1]);
|
||||
if (nib1 < 0 || nib2 < 0) { goto err; }
|
||||
int val = (nib1 << 4) + nib2;
|
||||
|
||||
argb[3 - i / 2] = val;
|
||||
}
|
||||
long out;
|
||||
memcpy(static_cast<void*>(&out), argb, 4);
|
||||
return out;
|
||||
argb[3 - i / 2] = val;
|
||||
}
|
||||
err:
|
||||
NORM_ERR("can't parse X color '%s' (%d)", name, len);
|
||||
return 0xFF00FF;
|
||||
long out;
|
||||
memcpy(static_cast<void *>(&out), argb, 4);
|
||||
return out;
|
||||
}
|
||||
err:
|
||||
NORM_ERR("can't parse X color '%s' (%d)", name, len);
|
||||
return 0xFF00FF;
|
||||
}
|
||||
#endif /* BUILD_WAYLAND */
|
||||
|
||||
long get_x11_color(const char *name) {
|
||||
#ifdef BUILD_X11
|
||||
#ifdef BUILD_WAYLAND
|
||||
if (!display) {
|
||||
return manually_get_x11_color(name);
|
||||
}
|
||||
if (!display) { return manually_get_x11_color(name); }
|
||||
#endif /*BUILD_WAYLAND*/
|
||||
assert(display != nullptr);
|
||||
XColor color;
|
||||
|
45
src/conky.cc
45
src/conky.cc
@ -154,7 +154,7 @@ const char builtin_config_magic[] = "==builtin==";
|
||||
|
||||
#define MAX_IF_BLOCK_DEPTH 5
|
||||
|
||||
//#define SIGNAL_BLOCKING
|
||||
// #define SIGNAL_BLOCKING
|
||||
#undef SIGNAL_BLOCKING
|
||||
|
||||
/* debugging level, used by logging.h */
|
||||
@ -764,9 +764,7 @@ int get_border_total() {
|
||||
dpi_scale(border_width.get(*state));
|
||||
}
|
||||
|
||||
void remove_first_char(char* s) {
|
||||
memmove(s, s + 1, strlen(s));
|
||||
}
|
||||
void remove_first_char(char *s) { memmove(s, s + 1, strlen(s)); }
|
||||
|
||||
static int get_string_width_special(char *s, int special_index) {
|
||||
char *p, *final;
|
||||
@ -1559,30 +1557,29 @@ static void draw_text() {
|
||||
#ifdef BUILD_GUI
|
||||
// XXX:only works if inside set_display_output()
|
||||
for (auto output : display_outputs()) {
|
||||
if (output && output->graphical()) {
|
||||
cur_y = text_start_y;
|
||||
int bw = dpi_scale(border_width.get(*state));
|
||||
if (output && output->graphical()) {
|
||||
cur_y = text_start_y;
|
||||
int bw = dpi_scale(border_width.get(*state));
|
||||
|
||||
/* draw borders */
|
||||
if (draw_borders.get(*state) && bw > 0) {
|
||||
if (stippled_borders.get(*state) != 0) {
|
||||
char ss[2] = {(char)dpi_scale(stippled_borders.get(*state)),
|
||||
(char)dpi_scale(stippled_borders.get(*state))};
|
||||
output->set_line_style(bw, false);
|
||||
output->set_dashes(ss);
|
||||
} else {
|
||||
output->set_line_style(bw, true);
|
||||
/* draw borders */
|
||||
if (draw_borders.get(*state) && bw > 0) {
|
||||
if (stippled_borders.get(*state) != 0) {
|
||||
char ss[2] = {(char)dpi_scale(stippled_borders.get(*state)),
|
||||
(char)dpi_scale(stippled_borders.get(*state))};
|
||||
output->set_line_style(bw, false);
|
||||
output->set_dashes(ss);
|
||||
} else {
|
||||
output->set_line_style(bw, true);
|
||||
}
|
||||
|
||||
int offset = dpi_scale(border_inner_margin.get(*state)) + bw;
|
||||
output->draw_rect(text_offset_x + text_start_x - offset,
|
||||
text_offset_y + text_start_y - offset,
|
||||
text_width + 2 * offset, text_height + 2 * offset);
|
||||
}
|
||||
|
||||
int offset = dpi_scale(border_inner_margin.get(*state)) + bw;
|
||||
output->draw_rect(text_offset_x + text_start_x - offset,
|
||||
text_offset_y + text_start_y - offset,
|
||||
text_width + 2 * offset,
|
||||
text_height + 2 * offset);
|
||||
/* draw text */
|
||||
}
|
||||
|
||||
/* draw text */
|
||||
}
|
||||
}
|
||||
setup_fonts();
|
||||
#endif /* BUILD_GUI */
|
||||
|
@ -54,8 +54,8 @@
|
||||
#include "irc.h"
|
||||
#endif /* BUILD_IRC */
|
||||
#ifdef BUILD_GUI
|
||||
#include "gui.h"
|
||||
#include "fonts.h"
|
||||
#include "gui.h"
|
||||
#endif /* BUILD_GUI */
|
||||
#include "fs.h"
|
||||
#ifdef BUILD_IBM
|
||||
@ -750,7 +750,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)) {
|
||||
obj->data.l =
|
||||
arg != nullptr ? get_x11_color(arg) : default_color.get(*state);
|
||||
set_current_text_color(obj->data.l);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,7 @@ class display_output_wayland : public display_output_base {
|
||||
virtual int calc_text_width(const char *);
|
||||
|
||||
// GUI interface
|
||||
virtual void draw_string_at(int, int, const char *, int );
|
||||
virtual void draw_string_at(int, int, const char *, int);
|
||||
// X11 lookalikes
|
||||
virtual void set_line_style(int, bool);
|
||||
virtual void set_dashes(char *);
|
||||
|
@ -49,9 +49,9 @@
|
||||
|
||||
#include "conky.h"
|
||||
#include "display-x11.hh"
|
||||
#include "gui.h"
|
||||
#include "llua.h"
|
||||
#include "x11.h"
|
||||
#include "gui.h"
|
||||
#ifdef BUILD_X11
|
||||
#include "fonts.h"
|
||||
#endif
|
||||
@ -140,9 +140,7 @@ struct _x11_stuff_s {
|
||||
} x11_stuff;
|
||||
|
||||
static void X11_create_window() {
|
||||
if (!window.window) {
|
||||
return;
|
||||
}
|
||||
if (!window.window) { return; }
|
||||
setup_fonts();
|
||||
load_fonts(utf8_mode.get(*state));
|
||||
#ifdef BUILD_XFT
|
||||
@ -225,8 +223,7 @@ bool display_output_x11::shutdown() { return false; }
|
||||
|
||||
bool display_output_x11::main_loop_wait(double t) {
|
||||
/* wait for X event or timeout */
|
||||
if(!display || !window.gc)
|
||||
return true;
|
||||
if (!display || !window.gc) return true;
|
||||
|
||||
if (XPending(display) == 0) {
|
||||
fd_set fdsr;
|
||||
|
@ -28,8 +28,8 @@
|
||||
*/
|
||||
|
||||
#include "fonts.h"
|
||||
#include "gui.h"
|
||||
#include "display-output.hh"
|
||||
#include "gui.h"
|
||||
#include "logging.h"
|
||||
|
||||
unsigned int selected_font = 0;
|
||||
@ -86,16 +86,16 @@ void load_fonts(bool utf8) {
|
||||
}
|
||||
|
||||
int font_height() {
|
||||
//assert(selected_font < fonts.size());
|
||||
// assert(selected_font < fonts.size());
|
||||
return display_output()->font_height(selected_font);
|
||||
}
|
||||
|
||||
int font_ascent() {
|
||||
//assert(selected_font < fonts.size());
|
||||
// assert(selected_font < fonts.size());
|
||||
return display_output()->font_ascent(selected_font);
|
||||
}
|
||||
|
||||
int font_descent() {
|
||||
//assert(selected_font < fonts.size());
|
||||
// assert(selected_font < fonts.size());
|
||||
return display_output()->font_descent(selected_font);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ int check_mount(struct text_object *obj) {
|
||||
|
||||
int update_meminfo(void) {
|
||||
u_int total_pages, inactive_pages, free_pages, wire_pages, active_pages,
|
||||
bufferspace, laundry_pages;
|
||||
bufferspace, laundry_pages;
|
||||
unsigned long swap_avail, swap_free;
|
||||
|
||||
int pagesize = getpagesize();
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include "logging.h"
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#include "gui.h"
|
||||
#include "x11.h"
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
namespace conky {
|
||||
|
@ -27,11 +27,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gui.h"
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "gui.h"
|
||||
#include "wl.h"
|
||||
|
||||
#ifdef BUILD_IMLIB2
|
||||
@ -63,7 +63,6 @@ void x11_init_window(lua::state &l, bool own);
|
||||
|
||||
/********************* <SETTINGS> ************************/
|
||||
|
||||
|
||||
priv::colour_setting background_colour("own_window_colour", 0);
|
||||
|
||||
bool out_to_gui(lua::state &l) {
|
||||
@ -192,8 +191,8 @@ std::string gethostnamecxx() {
|
||||
/*
|
||||
* The order of these settings cannot be completely arbitrary. Some of them
|
||||
* depend on others, and the setters are called in the order in which they are
|
||||
* defined. The order should be: x11_display_name -> out_to_x -> everything colour
|
||||
* related
|
||||
* defined. The order should be: x11_display_name -> out_to_x -> everything
|
||||
* colour related
|
||||
* -> border_*, own_window_*, etc -> own_window ->
|
||||
* double_buffer -> imlib_cache_size
|
||||
*/
|
||||
|
@ -70,8 +70,7 @@ void imlib_cache_size_setting::lua_setter(lua::state &l, bool init) {
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (display == nullptr || window.visual == nullptr)
|
||||
return;
|
||||
if (display == nullptr || window.visual == nullptr) return;
|
||||
|
||||
if (init && out_to_x.get(l)) {
|
||||
image_list_start = image_list_end = nullptr;
|
||||
|
@ -578,8 +578,7 @@ void update_net_interfaces(FILE *net_dev_fp, bool is_first_update,
|
||||
for (unsigned int k = 0; k < conf.ifc_len / sizeof(struct ifreq); k++) {
|
||||
struct net_stat *ns2;
|
||||
|
||||
ns2 = get_net_stat(conf.ifc_req[k].ifr_ifrn.ifrn_name,
|
||||
nullptr, NULL);
|
||||
ns2 = get_net_stat(conf.ifc_req[k].ifr_ifrn.ifrn_name, nullptr, NULL);
|
||||
ns2->addr = conf.ifc_req[k].ifr_ifru.ifru_addr;
|
||||
char temp_addr[18];
|
||||
snprintf(temp_addr, sizeof(temp_addr), "%u.%u.%u.%u, ",
|
||||
|
@ -370,9 +370,7 @@ const int MAXNUMGPU = 64;
|
||||
namespace {
|
||||
|
||||
// Deleter for nv display to use with std::unique_ptr
|
||||
void close_nvdisplay(Display * dp) {
|
||||
XCloseDisplay(dp);
|
||||
}
|
||||
void close_nvdisplay(Display *dp) { XCloseDisplay(dp); }
|
||||
|
||||
using unique_display_t = std::unique_ptr<Display, decltype(&close_nvdisplay)>;
|
||||
|
||||
@ -758,7 +756,7 @@ static int cache_nvidia_value(TARGET_ID tid, ATTR_ID aid, Display *dpy,
|
||||
static int get_nvidia_value(TARGET_ID tid, ATTR_ID aid, int gid,
|
||||
const char *arg) {
|
||||
auto nvdpy = nvidia_display.get_nvdisplay();
|
||||
Display * dpy = nvdpy ? nvdpy.get() : display;
|
||||
Display *dpy = nvdpy ? nvdpy.get() : display;
|
||||
int value;
|
||||
|
||||
// Check if the aid is cacheable
|
||||
@ -789,7 +787,7 @@ static int get_nvidia_value(TARGET_ID tid, ATTR_ID aid, int gid,
|
||||
static char *get_nvidia_string(TARGET_ID tid, ATTR_ID aid, int gid,
|
||||
const char *arg) {
|
||||
auto nvdpy = nvidia_display.get_nvdisplay();
|
||||
Display * dpy = nvdpy ? nvdpy.get() : display;
|
||||
Display *dpy = nvdpy ? nvdpy.get() : display;
|
||||
char *str;
|
||||
|
||||
// Query nvidia interface
|
||||
@ -962,7 +960,7 @@ void print_nvidia_value(struct text_object *obj, char *p,
|
||||
int error_base;
|
||||
|
||||
auto nvdpy = nvidia_display.get_nvdisplay();
|
||||
Display * dpy = nvdpy ? nvdpy.get() : display;
|
||||
Display *dpy = nvdpy ? nvdpy.get() : display;
|
||||
|
||||
if (!dpy) {
|
||||
NORM_ERR("%s: no display set (try setting nvidia_display)", __func__);
|
||||
@ -1066,7 +1064,7 @@ double get_nvidia_barval(struct text_object *obj) {
|
||||
int error_base;
|
||||
|
||||
auto nvdpy = nvidia_display.get_nvdisplay();
|
||||
Display * dpy = nvdpy ? nvdpy.get() : display;
|
||||
Display *dpy = nvdpy ? nvdpy.get() : display;
|
||||
|
||||
if (!dpy) {
|
||||
NORM_ERR("%s: no display set (try setting nvidia_display)", __func__);
|
||||
|
@ -28,8 +28,8 @@
|
||||
*/
|
||||
#include "conky.h"
|
||||
#ifdef BUILD_GUI
|
||||
#include "gui.h"
|
||||
#include "fonts.h"
|
||||
#include "gui.h"
|
||||
#endif /* BUILD_GUI */
|
||||
#include <cmath>
|
||||
#include "logging.h"
|
||||
|
@ -99,9 +99,7 @@ static void unhash_all_processes() {
|
||||
}
|
||||
}
|
||||
|
||||
struct process *get_first_process() {
|
||||
return first_process;
|
||||
}
|
||||
struct process *get_first_process() { return first_process; }
|
||||
|
||||
void free_all_processes() {
|
||||
struct process *next = nullptr, *pr = first_process;
|
||||
|
22
src/wl.cc
22
src/wl.cc
@ -42,7 +42,7 @@ void out_to_wayland_setting::lua_setter(lua::state &l, bool init) {
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (init && do_convert(l, -1).first) {
|
||||
//init
|
||||
// init
|
||||
}
|
||||
|
||||
++s;
|
||||
@ -52,7 +52,7 @@ void out_to_wayland_setting::cleanup(lua::state &l) {
|
||||
lua::stack_sentry s(l, -1);
|
||||
|
||||
if (do_convert(l, -1).first) {
|
||||
//deinit
|
||||
// deinit
|
||||
}
|
||||
|
||||
l.pop();
|
||||
@ -63,7 +63,8 @@ priv::out_to_wayland_setting out_to_wayland;
|
||||
|
||||
static const char NOT_IN_WAYLAND[] = "Not running in Wayland";
|
||||
|
||||
__attribute__((weak)) void print_monitor(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
__attribute__((weak)) void print_monitor(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
@ -73,8 +74,9 @@ __attribute__((weak)) void print_monitor(struct text_object *obj, char *p, unsig
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_monitor_number(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
__attribute__((weak)) void print_monitor_number(struct text_object *obj,
|
||||
char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
@ -84,7 +86,8 @@ __attribute__((weak)) void print_monitor_number(struct text_object *obj, char *p
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
__attribute__((weak)) void print_desktop(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
@ -94,8 +97,9 @@ __attribute__((weak)) void print_desktop(struct text_object *obj, char *p, unsig
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop_number(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
__attribute__((weak)) void print_desktop_number(struct text_object *obj,
|
||||
char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
@ -106,7 +110,7 @@ __attribute__((weak)) void print_desktop_number(struct text_object *obj, char *p
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop_name(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
|
1580
src/x11-color.cc
1580
src/x11-color.cc
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
||||
/* from xorg-server's oscolor.c */
|
||||
int OsLookupColor(int screen, const char *name, unsigned int len,
|
||||
unsigned short *pred,
|
||||
unsigned short *pgreen,
|
||||
unsigned short *pred, unsigned short *pgreen,
|
||||
unsigned short *pblue);
|
||||
|
11
src/x11.cc
11
src/x11.cc
@ -231,8 +231,8 @@ static void init_X11() {
|
||||
? dispstr.c_str()
|
||||
: nullptr;
|
||||
if ((display = XOpenDisplay(disp)) == nullptr) {
|
||||
std::string err = std::string("can't open display: ") +
|
||||
XDisplayName(disp);
|
||||
std::string err =
|
||||
std::string("can't open display: ") + XDisplayName(disp);
|
||||
#ifdef BUILD_WAYLAND
|
||||
fprintf(stderr, "%s\n", err.c_str());
|
||||
return;
|
||||
@ -326,8 +326,7 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop) {
|
||||
int format, i;
|
||||
unsigned long nitems, bytes;
|
||||
unsigned int n;
|
||||
if (!display)
|
||||
return 0;
|
||||
if (!display) return 0;
|
||||
Window root = RootWindow(display, screen);
|
||||
Window win;
|
||||
Window troot, parent, *children;
|
||||
@ -803,9 +802,7 @@ void x11_init_window(lua::state &l __attribute__((unused)), bool own) {
|
||||
if (window.window == 0u) {
|
||||
window.window = find_desktop_window(&window.root, &window.desktop);
|
||||
}
|
||||
if (window.window == 0u) {
|
||||
return;
|
||||
}
|
||||
if (window.window == 0u) { return; }
|
||||
|
||||
window.visual = DefaultVisual(display, screen);
|
||||
window.colourmap = DefaultColormap(display, screen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user