mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-06 14:09:29 +00:00
Fixed GCC 4.7.0 issues, double buffering
Signed-off-by: Brenden Matthews <brenden@diddyinc.com>
This commit is contained in:
parent
cf7610cf42
commit
bf7248ecd6
@ -105,7 +105,7 @@ option(BUILD_X11 "Build X11 support" true)
|
|||||||
if(BUILD_X11)
|
if(BUILD_X11)
|
||||||
option(OWN_WINDOW "Enable own_window support" true)
|
option(OWN_WINDOW "Enable own_window support" true)
|
||||||
option(BUILD_XDAMAGE "Build Xdamage 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_XFT "Build Xft (freetype fonts) support" true)
|
||||||
option(BUILD_IMLIB2 "Enable Imlib2 support" false)
|
option(BUILD_IMLIB2 "Enable Imlib2 support" false)
|
||||||
else(BUILD_X11)
|
else(BUILD_X11)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "c++wrap.hh"
|
#include "c++wrap.hh"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !defined(HAVE_PIPE2) || !defined(HAVE_O_CLOEXEC)
|
#if !defined(HAVE_PIPE2) || !defined(HAVE_O_CLOEXEC)
|
||||||
|
54
src/conky.cc
54
src/conky.cc
@ -236,7 +236,8 @@ static void reload_config(void);
|
|||||||
|
|
||||||
static void print_version(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"
|
"\nCompiled in features:\n\n"
|
||||||
"System config file: " SYSTEM_CONFIG_FILE"\n"
|
"System config file: " SYSTEM_CONFIG_FILE"\n"
|
||||||
"Package library path: " PACKAGE_LIBDIR"\n\n")
|
"Package library path: " PACKAGE_LIBDIR"\n\n")
|
||||||
@ -1959,10 +1960,16 @@ static void draw_stuff(void)
|
|||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
draw_mode = FG;
|
draw_mode = FG;
|
||||||
draw_text();
|
draw_text();
|
||||||
#if defined(BUILD_X11) && defined(BUILD_XDBE)
|
#if defined(BUILD_X11)
|
||||||
|
#if defined(BUILD_XDBE)
|
||||||
if (out_to_x.get(*state)) {
|
if (out_to_x.get(*state)) {
|
||||||
xdbe_swap_buffers();
|
xdbe_swap_buffers();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (out_to_x.get(*state)) {
|
||||||
|
xpmdb_swap_buffers();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif /* BUILD_X11 && BUILD_XDBE */
|
#endif /* BUILD_X11 && BUILD_XDBE */
|
||||||
if(overwrite_fpointer) {
|
if(overwrite_fpointer) {
|
||||||
fclose(overwrite_fpointer);
|
fclose(overwrite_fpointer);
|
||||||
@ -1982,6 +1989,10 @@ static void clear_text(int exposures)
|
|||||||
/* The swap action is XdbeBackground, which clears */
|
/* The swap action is XdbeBackground, which clears */
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
|
#else
|
||||||
|
if (use_xpmdb.get(*state)) {
|
||||||
|
return;
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (display && window.window) { // make sure these are !null
|
if (display && window.window) { // make sure these are !null
|
||||||
/* there is some extra space for borders and outlines */
|
/* there is some extra space for borders and outlines */
|
||||||
@ -2116,6 +2127,22 @@ static void main_loop(void)
|
|||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
/* swap buffers */
|
/* swap buffers */
|
||||||
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
|
#endif
|
||||||
|
|
||||||
changed++;
|
changed++;
|
||||||
@ -2172,8 +2199,11 @@ static void main_loop(void)
|
|||||||
|
|
||||||
clear_text(1);
|
clear_text(1);
|
||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#if defined(BUILD_XDBE)
|
||||||
if (use_xdbe.get(*state)) {
|
if (use_xdbe.get(*state)) {
|
||||||
|
#else
|
||||||
|
if (use_xpmdb.get(*state)) {
|
||||||
|
#endif
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
int border_total = get_border_total();
|
int border_total = get_border_total();
|
||||||
|
|
||||||
@ -2183,7 +2213,6 @@ static void main_loop(void)
|
|||||||
r.height = text_height + 2*border_total;
|
r.height = text_height + 2*border_total;
|
||||||
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
|
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle X events */
|
/* handle X events */
|
||||||
@ -2334,8 +2363,11 @@ static void main_loop(void)
|
|||||||
* all, then no swap happens and we can safely do nothing. */
|
* all, then no swap happens and we can safely do nothing. */
|
||||||
|
|
||||||
if (!XEmptyRegion(x11_stuff.region)) {
|
if (!XEmptyRegion(x11_stuff.region)) {
|
||||||
#ifdef BUILD_XDBE
|
#if defined(BUILD_XDBE)
|
||||||
if (use_xdbe.get(*state)) {
|
if (use_xdbe.get(*state)) {
|
||||||
|
#else
|
||||||
|
if (use_xpmdb.get(*state)) {
|
||||||
|
#endif
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
int border_total = get_border_total();
|
int border_total = get_border_total();
|
||||||
|
|
||||||
@ -2345,7 +2377,6 @@ static void main_loop(void)
|
|||||||
r.height = text_height + 2*border_total;
|
r.height = text_height + 2*border_total;
|
||||||
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
|
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
XSetRegion(display, window.gc, x11_stuff.region);
|
XSetRegion(display, window.gc, x11_stuff.region);
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
if (use_xft.get(*state)) {
|
if (use_xft.get(*state)) {
|
||||||
@ -2735,9 +2766,7 @@ static void print_help(const char *prog_name) {
|
|||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
" -o, --own-window create own window to draw\n"
|
" -o, --own-window create own window to draw\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_XDBE
|
|
||||||
" -b, --double-buffer double buffer (prevents flickering)\n"
|
" -b, --double-buffer double buffer (prevents flickering)\n"
|
||||||
#endif
|
|
||||||
" -w, --window-id=WIN_ID window id to draw\n"
|
" -w, --window-id=WIN_ID window id to draw\n"
|
||||||
" -x X x position\n"
|
" -x X x position\n"
|
||||||
" -y Y y position\n"
|
" -y Y y position\n"
|
||||||
@ -2766,9 +2795,7 @@ static const char *getopt_string = "vVqdDSs:t:u:i:hc:p:"
|
|||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
"o"
|
"o"
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_XDBE
|
|
||||||
"b"
|
"b"
|
||||||
#endif
|
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
#ifdef BUILD_BUILTIN_CONFIG
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
"C"
|
"C"
|
||||||
@ -2792,9 +2819,7 @@ static const struct option longopts[] = {
|
|||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
{ "own-window", 0, NULL, 'o' },
|
{ "own-window", 0, NULL, 'o' },
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_XDBE
|
|
||||||
{ "double-buffer", 0, NULL, 'b' },
|
{ "double-buffer", 0, NULL, 'b' },
|
||||||
#endif
|
|
||||||
{ "window-id", 1, NULL, 'w' },
|
{ "window-id", 1, NULL, 'w' },
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
{ "text", 1, NULL, 't' },
|
{ "text", 1, NULL, 't' },
|
||||||
@ -2891,6 +2916,11 @@ void initialisation(int argc, char **argv) {
|
|||||||
state->pushboolean(true);
|
state->pushboolean(true);
|
||||||
use_xdbe.lua_set(*state);
|
use_xdbe.lua_set(*state);
|
||||||
break;
|
break;
|
||||||
|
#else
|
||||||
|
case 'b':
|
||||||
|
state->pushboolean(true);
|
||||||
|
use_xpmdb.lua_set(*state);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
case 't':
|
case 't':
|
||||||
|
@ -176,6 +176,11 @@ static void cimlib_draw_image(struct image_list_s *cur, int *clip_x, int
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
static int rep = 0;
|
static int rep = 0;
|
||||||
|
|
||||||
|
if (imlib_context_get_drawable() != window.drawable) {
|
||||||
|
imlib_context_set_drawable(window.drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
image = imlib_load_image(cur->name);
|
image = imlib_load_image(cur->name);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
if (!rep)
|
if (!rep)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "update-cb.hh"
|
#include "update-cb.hh"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
namespace conky {
|
namespace conky {
|
||||||
|
@ -27,9 +27,12 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
// the following probably requires a is-gcc-4.7.0 check
|
||||||
|
#include <mutex>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "c++wrap.hh"
|
#include "c++wrap.hh"
|
||||||
|
54
src/x11.cc
54
src/x11.cc
@ -170,6 +170,48 @@ namespace priv {
|
|||||||
|
|
||||||
++s;
|
++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
|
#endif
|
||||||
|
|
||||||
void colour_setting::lua_setter(lua::state &l, bool init)
|
void colour_setting::lua_setter(lua::state &l, bool init)
|
||||||
@ -316,6 +358,8 @@ priv::own_window_setting own_window;
|
|||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
priv::use_xdbe_setting use_xdbe;
|
priv::use_xdbe_setting use_xdbe;
|
||||||
|
#else
|
||||||
|
priv::use_xpmdb_setting use_xpmdb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BUILD_IMLIB2
|
#ifdef BUILD_IMLIB2
|
||||||
@ -1176,4 +1220,14 @@ void xdbe_swap_buffers(void)
|
|||||||
XdbeSwapBuffers(display, &swap, 1);
|
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 */
|
#endif /* BUILD_XDBE */
|
||||||
|
20
src/x11.h
20
src/x11.h
@ -74,6 +74,8 @@ struct conky_window {
|
|||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
XdbeBackBuffer back_buffer;
|
XdbeBackBuffer back_buffer;
|
||||||
|
#else
|
||||||
|
Pixmap back_buffer;
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_XFT
|
#ifdef BUILD_XFT
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
@ -116,6 +118,8 @@ void print_desktop_name(struct text_object *, char *, int);
|
|||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
void xdbe_swap_buffers(void);
|
void xdbe_swap_buffers(void);
|
||||||
|
#else
|
||||||
|
void xpmdb_swap_buffers(void);
|
||||||
#endif /* BUILD_XDBE */
|
#endif /* BUILD_XDBE */
|
||||||
|
|
||||||
/* alignments */
|
/* alignments */
|
||||||
@ -173,6 +177,20 @@ namespace priv {
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class use_xpmdb_setting: public conky::simple_config_setting<bool> {
|
||||||
|
typedef conky::simple_config_setting<bool> 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 {
|
struct colour_traits {
|
||||||
static const lua::Type type = lua::TSTRING;
|
static const lua::Type type = lua::TSTRING;
|
||||||
typedef unsigned long Type;
|
typedef unsigned long Type;
|
||||||
@ -235,6 +253,8 @@ extern priv::own_window_setting own_window;
|
|||||||
|
|
||||||
#ifdef BUILD_XDBE
|
#ifdef BUILD_XDBE
|
||||||
extern priv::use_xdbe_setting use_xdbe;
|
extern priv::use_xdbe_setting use_xdbe;
|
||||||
|
#else
|
||||||
|
extern priv::use_xpmdb_setting use_xpmdb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*X11_H_*/
|
#endif /*X11_H_*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user