diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index b1769ec3..2e5141fd 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -105,7 +105,7 @@ option(BUILD_X11 "Build X11 support" true) if(BUILD_X11) option(OWN_WINDOW "Enable own_window support" true) option(BUILD_XDAMAGE "Build Xdamage support" true) - option(BUILD_XDBE "Build Xdbe (double-buffer) support" true) + option(BUILD_XDBE "Build Xdbe (double-buffer) support" false) option(BUILD_XFT "Build Xft (freetype fonts) support" true) option(BUILD_IMLIB2 "Enable Imlib2 support" false) else(BUILD_X11) diff --git a/src/c++wrap.cc b/src/c++wrap.cc index b8de2910..c21b4735 100644 --- a/src/c++wrap.cc +++ b/src/c++wrap.cc @@ -25,6 +25,7 @@ #include "c++wrap.hh" +#include #include #if !defined(HAVE_PIPE2) || !defined(HAVE_O_CLOEXEC) diff --git a/src/conky.cc b/src/conky.cc index c3519a18..4e7162ee 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -236,10 +236,11 @@ static void reload_config(void); static void print_version(void) { - std::cout << _(PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n" +// std::cout << _(PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n" + std::cout << _(PACKAGE_NAME" " VERSION" compiled for " BUILD_ARCH"\n" "\nCompiled in features:\n\n" - "System config file: "SYSTEM_CONFIG_FILE"\n" - "Package library path: "PACKAGE_LIBDIR"\n\n") + "System config file: " SYSTEM_CONFIG_FILE"\n" + "Package library path: " PACKAGE_LIBDIR"\n\n") << _("\n General:\n") #ifdef HAVE_OPENMP << _(" * OpenMP\n") @@ -362,10 +363,10 @@ static void print_version(void) << _(" * XMMS2\n") #endif /* BUILD_XMMS2 */ << _("\n Default values:\n") - << " * Netdevice: "DEFAULTNETDEV"\n" - << " * Local configfile: "CONFIG_FILE"\n" + << " * Netdevice: " DEFAULTNETDEV"\n" + << " * Local configfile: " CONFIG_FILE"\n" #ifdef BUILD_I18N - << " * Localedir: "LOCALE_DIR"\n" + << " * Localedir: " LOCALE_DIR"\n" #endif #ifdef BUILD_HTTP << " * HTTP-port: " << HTTPPORT << "\n" @@ -1959,10 +1960,16 @@ static void draw_stuff(void) #endif /* BUILD_X11 */ draw_mode = FG; draw_text(); -#if defined(BUILD_X11) && defined(BUILD_XDBE) +#if defined(BUILD_X11) +#if defined(BUILD_XDBE) if (out_to_x.get(*state)) { xdbe_swap_buffers(); } +#else + if (out_to_x.get(*state)) { + xpmdb_swap_buffers(); + } +#endif #endif /* BUILD_X11 && BUILD_XDBE */ if(overwrite_fpointer) { fclose(overwrite_fpointer); @@ -1982,6 +1989,10 @@ static void clear_text(int exposures) /* The swap action is XdbeBackground, which clears */ return; } else +#else + if (use_xpmdb.get(*state)) { + return; + } else #endif if (display && window.window) { // make sure these are !null /* there is some extra space for borders and outlines */ @@ -2116,6 +2127,22 @@ static void main_loop(void) #ifdef BUILD_XDBE /* swap buffers */ xdbe_swap_buffers(); +#else + if (use_xpmdb.get(*state)) { + + XFreePixmap(display, window.back_buffer); + window.back_buffer = XCreatePixmap(display, + window.window, window.width, window.height, DefaultDepth(display, screen)); + + if (window.back_buffer != None) { + window.drawable = window.back_buffer; + } else { + // this is probably reallllly bad + NORM_ERR("Failed to allocate back buffer"); + } + XSetForeground(display, window.gc, 0); + XFillRectangle(display, window.drawable, window.gc, 0, 0, window.width, window.height); + } #endif changed++; @@ -2172,8 +2199,11 @@ static void main_loop(void) clear_text(1); -#ifdef BUILD_XDBE +#if defined(BUILD_XDBE) if (use_xdbe.get(*state)) { +#else + if (use_xpmdb.get(*state)) { +#endif XRectangle r; int border_total = get_border_total(); @@ -2183,7 +2213,6 @@ static void main_loop(void) r.height = text_height + 2*border_total; XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region); } -#endif } /* handle X events */ @@ -2334,8 +2363,11 @@ static void main_loop(void) * all, then no swap happens and we can safely do nothing. */ if (!XEmptyRegion(x11_stuff.region)) { -#ifdef BUILD_XDBE +#if defined(BUILD_XDBE) if (use_xdbe.get(*state)) { +#else + if (use_xpmdb.get(*state)) { +#endif XRectangle r; int border_total = get_border_total(); @@ -2345,7 +2377,6 @@ static void main_loop(void) r.height = text_height + 2*border_total; XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region); } -#endif XSetRegion(display, window.gc, x11_stuff.region); #ifdef BUILD_XFT if (use_xft.get(*state)) { @@ -2715,7 +2746,7 @@ void load_config_file() static void print_help(const char *prog_name) { printf("Usage: %s [OPTION]...\n" - PACKAGE_NAME" is a system monitor that renders text on desktop or to own transparent\n" + PACKAGE_NAME " is a system monitor that renders text on desktop or to own transparent\n" "window. Command line options will override configurations defined in config\n" "file.\n" " -v, --version version\n" @@ -2735,16 +2766,14 @@ static void print_help(const char *prog_name) { #ifdef OWN_WINDOW " -o, --own-window create own window to draw\n" #endif -#ifdef BUILD_XDBE " -b, --double-buffer double buffer (prevents flickering)\n" -#endif " -w, --window-id=WIN_ID window id to draw\n" " -x X x position\n" " -y Y y position\n" #endif /* BUILD_X11 */ " -t, --text=TEXT text to render, remember single quotes, like -t '$uptime'\n" " -u, --interval=SECS update interval\n" - " -i COUNT number of times to update "PACKAGE_NAME" (and quit)\n" + " -i COUNT number of times to update " PACKAGE_NAME " (and quit)\n" " -p, --pause=SECS pause for SECS seconds at startup before doing anything\n", prog_name ); @@ -2766,9 +2795,7 @@ static const char *getopt_string = "vVqdDSs:t:u:i:hc:p:" #ifdef OWN_WINDOW "o" #endif -#ifdef BUILD_XDBE "b" -#endif #endif /* BUILD_X11 */ #ifdef BUILD_BUILTIN_CONFIG "C" @@ -2792,9 +2819,7 @@ static const struct option longopts[] = { #ifdef OWN_WINDOW { "own-window", 0, NULL, 'o' }, #endif -#ifdef BUILD_XDBE { "double-buffer", 0, NULL, 'b' }, -#endif { "window-id", 1, NULL, 'w' }, #endif /* BUILD_X11 */ { "text", 1, NULL, 't' }, @@ -2891,6 +2916,11 @@ void initialisation(int argc, char **argv) { state->pushboolean(true); use_xdbe.lua_set(*state); break; +#else + case 'b': + state->pushboolean(true); + use_xpmdb.lua_set(*state); + break; #endif #endif /* BUILD_X11 */ case 't': diff --git a/src/ibm.cc b/src/ibm.cc index a72b3660..dc518305 100644 --- a/src/ibm.cc +++ b/src/ibm.cc @@ -101,7 +101,7 @@ void get_ibm_acpi_fan(struct text_object *obj, char *p, int p_max_size) } } else { CRIT_ERR(NULL, NULL, "can't open '%s': %s\nYou are not using the IBM ACPI. Remove " - "ibm* from your "PACKAGE_NAME" config file.", fan, strerror(errno)); + "ibm* from your " PACKAGE_NAME" config file.", fan, strerror(errno)); } fclose(fp); @@ -154,7 +154,7 @@ int get_ibm_acpi_temps(void) } } else { CRIT_ERR(NULL, NULL, "can't open '%s': %s\nYou are not using the IBM ACPI. Remove " - "ibm* from your "PACKAGE_NAME" config file.", thermal, strerror(errno)); + "ibm* from your " PACKAGE_NAME" config file.", thermal, strerror(errno)); } fclose(fp); @@ -205,7 +205,7 @@ void get_ibm_acpi_volume(struct text_object *obj, char *p, int p_max_size) } } else { CRIT_ERR(NULL, NULL, "can't open '%s': %s\nYou are not using the IBM ACPI. Remove " - "ibm* from your "PACKAGE_NAME" config file.", volume, strerror(errno)); + "ibm* from your " PACKAGE_NAME" config file.", volume, strerror(errno)); } fclose(fp); @@ -253,7 +253,7 @@ void get_ibm_acpi_brightness(struct text_object *obj, char *p, int p_max_size) } } else { CRIT_ERR(NULL, NULL, "can't open '%s': %s\nYou are not using the IBM ACPI. Remove " - "ibm* from your "PACKAGE_NAME" config file.", filename, strerror(errno)); + "ibm* from your " PACKAGE_NAME" config file.", filename, strerror(errno)); } fclose(fp); diff --git a/src/imlib2.cc b/src/imlib2.cc index 215fdede..72df23a7 100644 --- a/src/imlib2.cc +++ b/src/imlib2.cc @@ -176,6 +176,11 @@ static void cimlib_draw_image(struct image_list_s *cur, int *clip_x, int time_t now = time(NULL); static int rep = 0; + if (imlib_context_get_drawable() != window.drawable) { + imlib_context_set_drawable(window.drawable); + } + + image = imlib_load_image(cur->name); if (!image) { if (!rep) diff --git a/src/linux.cc b/src/linux.cc index e2c765f6..15da7e97 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -1050,7 +1050,7 @@ static int open_sysfs_sensor(const char *dir, const char *dev, const char *type, fd = open(path, O_RDONLY); if (fd < 0) { NORM_ERR("can't open '%s': %s\nplease check your device or remove this " - "var from "PACKAGE_NAME, path, strerror(errno)); + "var from " PACKAGE_NAME, path, strerror(errno)); } } diff --git a/src/llua.cc b/src/llua.cc index 343725bf..16fc44aa 100644 --- a/src/llua.cc +++ b/src/llua.cc @@ -161,7 +161,7 @@ void llua_init(void) free(old_path); free(new_path); - lua_pushstring(lua_L, PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH); + lua_pushstring(lua_L, PACKAGE_NAME" " VERSION" compiled " BUILD_DATE" for " BUILD_ARCH); lua_setglobal(lua_L, "conky_build_info"); lua_pushstring(lua_L, VERSION); diff --git a/src/read_tcpip.cc b/src/read_tcpip.cc index 4f59c430..ebf40626 100644 --- a/src/read_tcpip.cc +++ b/src/read_tcpip.cc @@ -78,7 +78,7 @@ void parse_tcp_ping_arg(struct text_object *obj, const char *arg, void *free_at_ obj->data.opaque = addr; memset(addr, 0, sizeof(struct sockaddr_in)); hostname = (char *) malloc(strlen(arg)+1); - switch( sscanf(arg, "%s %"SCNu16, hostname, &(addr->sin_port)) ) { + switch( sscanf(arg, "%s %" SCNu16, hostname, &(addr->sin_port)) ) { case 1: addr->sin_port = DEFAULT_TCP_PING_PORT; break; diff --git a/src/sony.cc b/src/sony.cc index a16004eb..5eefd01b 100644 --- a/src/sony.cc +++ b/src/sony.cc @@ -72,7 +72,7 @@ void get_sony_fanspeed(struct text_object *obj, char *p_client_buffer, int clien } } else { CRIT_ERR(NULL, NULL, "can't open '%s': %s\nEnable sony support or remove " - "sony* from your "PACKAGE_NAME" config file.", + "sony* from your " PACKAGE_NAME" config file.", fan, strerror(errno)); } diff --git a/src/specials.cc b/src/specials.cc index e0e87d1f..b7ac8987 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -193,10 +193,10 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale) g->scale = defscale; g->tempgrad = FALSE; if (args) { - if (strstr(args, " "TEMPGRAD) || strncmp(args, TEMPGRAD, strlen(TEMPGRAD)) == 0) { + if (strstr(args, " " TEMPGRAD) || strncmp(args, TEMPGRAD, strlen(TEMPGRAD)) == 0) { g->tempgrad = TRUE; } - if (strstr(args, " "LOGGRAPH) || strncmp(args, LOGGRAPH, strlen(LOGGRAPH)) == 0) { + if (strstr(args, " " LOGGRAPH) || strncmp(args, LOGGRAPH, strlen(LOGGRAPH)) == 0) { g->flags |= SF_SHOWLOG; } if (sscanf(args, "%d,%d %x %x %lf", &g->height, &g->width, &g->first_colour, &g->last_colour, &g->scale) == 5) { diff --git a/src/update-cb.cc b/src/update-cb.cc index 1cd19e38..20fb2f0c 100644 --- a/src/update-cb.cc +++ b/src/update-cb.cc @@ -25,6 +25,7 @@ #include "update-cb.hh" +#include #include namespace conky { diff --git a/src/update-cb.hh b/src/update-cb.hh index 470d38c3..182239f8 100644 --- a/src/update-cb.hh +++ b/src/update-cb.hh @@ -27,9 +27,12 @@ #include #include #include +// the following probably requires a is-gcc-4.7.0 check +#include #include #include + #include #include "c++wrap.hh" diff --git a/src/x11.cc b/src/x11.cc index c269c0e9..6521a7c2 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -170,6 +170,48 @@ namespace priv { ++s; } + + + +#else + bool use_xpmdb_setting::set_up(lua::state &l) + { + // double_buffer makes no sense when not drawing to X + if(not out_to_x.get(l)) + return false; + + window.back_buffer = XCreatePixmap(display, + window.window, window.width+1, window.height+1, DefaultDepth(display, screen)); + if (window.back_buffer != None) { + window.drawable = window.back_buffer; + } else { + NORM_ERR("Failed to allocate back buffer"); + return false; + } + + + XFlush(display); + return true; + } + + void use_xpmdb_setting::lua_setter(lua::state &l, bool init) + { + lua::stack_sentry s(l, -2); + + Base::lua_setter(l, init); + + if(init && do_convert(l, -1).first) { + if(not set_up(l)) { + l.pop(); + l.pushboolean(false); + } + + fprintf(stderr, PACKAGE_NAME": drawing to %s buffer\n", + do_convert(l, -1).first?"double":"single"); + } + + ++s; + } #endif void colour_setting::lua_setter(lua::state &l, bool init) @@ -316,6 +358,8 @@ priv::own_window_setting own_window; #ifdef BUILD_XDBE priv::use_xdbe_setting use_xdbe; +#else +priv::use_xpmdb_setting use_xpmdb; #endif #ifdef BUILD_IMLIB2 @@ -1176,4 +1220,14 @@ void xdbe_swap_buffers(void) XdbeSwapBuffers(display, &swap, 1); } } +#else +void xpmdb_swap_buffers(void) +{ + if (use_xpmdb.get(*state)) { + XCopyArea(display, window.back_buffer, window.window, window.gc, 0, 0, window.width, window.height, 0, 0); + XSetForeground(display, window.gc, 0); + XFillRectangle(display, window.drawable, window.gc, 0, 0, window.width, window.height); + XFlush(display); + } +} #endif /* BUILD_XDBE */ diff --git a/src/x11.h b/src/x11.h index bc137b87..ee2e910f 100644 --- a/src/x11.h +++ b/src/x11.h @@ -74,6 +74,8 @@ struct conky_window { #ifdef BUILD_XDBE XdbeBackBuffer back_buffer; +#else + Pixmap back_buffer; #endif #ifdef BUILD_XFT XftDraw *xftdraw; @@ -116,6 +118,8 @@ void print_desktop_name(struct text_object *, char *, int); #ifdef BUILD_XDBE void xdbe_swap_buffers(void); +#else +void xpmdb_swap_buffers(void); #endif /* BUILD_XDBE */ /* alignments */ @@ -172,6 +176,20 @@ namespace priv { : Base("double_buffer", false, false) {} }; + + class use_xpmdb_setting: public conky::simple_config_setting { + typedef conky::simple_config_setting Base; + + bool set_up(lua::state &l); + protected: + virtual void lua_setter(lua::state &l, bool init); + + public: + use_xpmdb_setting() + : Base("double_buffer", false, false) + {} + }; + struct colour_traits { static const lua::Type type = lua::TSTRING; @@ -235,6 +253,8 @@ extern priv::own_window_setting own_window; #ifdef BUILD_XDBE extern priv::use_xdbe_setting use_xdbe; +#else +extern priv::use_xpmdb_setting use_xpmdb; #endif #endif /*X11_H_*/