mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-24 15:48:28 +00:00
More work on imlib2 stuff.
Seems to be some rendering corruption which I'm not sure the reason for, but other than that I think it works okay.
This commit is contained in:
parent
1dc7731f6d
commit
353f0b6ad7
@ -176,6 +176,13 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><command><option>imlib_cache_size</option></command></term>
|
||||||
|
<listitem>
|
||||||
|
IMLIB2 image cache size, in bytes. Defaults to 4MiB. Increase this value if you use $image lots. Set to 0 to disable the image cache.
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command><option>if_up_strictness</option></command></term>
|
<term><command><option>if_up_strictness</option></command></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -1042,6 +1042,16 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>image</option></command>
|
||||||
|
<option><path to image> (-p x,y) (-s WxH)</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
Renders an image from the path specified using IMLIB2. Takes 2 optional arguments, one being a position, the other an size. Changing the x,y position will move the position of the image, and changing the WxH will scale the image. Example: ${image /home/brenden/cheeseburger.jpg -p 20,20 -s 200x200} will render 'cheeseburger.jpg' at (20,20) scaled to 200x200 pixels.
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>i2c</option></command>
|
<command><option>i2c</option></command>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
|
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
|
||||||
|
|
||||||
## Configuration items
|
## Configuration items
|
||||||
color green "\<(alias|alignment|append_file|background|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|gap_x|gap_y|if_up_strictness|imap|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
|
color green "\<(alias|alignment|append_file|background|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|gap_x|gap_y|if_up_strictness|imap|imlib_cache_size|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
|
||||||
|
|
||||||
## Configuration item constants
|
## Configuration item constants
|
||||||
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>"
|
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>"
|
||||||
|
@ -12,7 +12,7 @@ endif
|
|||||||
|
|
||||||
syn region ConkyrcComment start=/^\s*#/ end=/$/
|
syn region ConkyrcComment start=/^\s*#/ end=/$/
|
||||||
|
|
||||||
syn keyword ConkyrcSetting alias alignment append_file background border_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font gap_x gap_y if_up_strictness imap mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
|
syn keyword ConkyrcSetting alias alignment append_file background border_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font gap_x gap_y if_up_strictness imap imlib_cache_size mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
|
||||||
|
|
||||||
syn keyword ConkyrcConstant
|
syn keyword ConkyrcConstant
|
||||||
\ above
|
\ above
|
||||||
|
18
src/conky.c
18
src/conky.c
@ -3725,7 +3725,7 @@ static void generate_text_internal(char *p, int p_max_size,
|
|||||||
OBJ(image) {
|
OBJ(image) {
|
||||||
/* doesn't actually draw anything, just queues it omp. the
|
/* doesn't actually draw anything, just queues it omp. the
|
||||||
* image will get drawn after the X event loop */
|
* image will get drawn after the X event loop */
|
||||||
cimlib_add_image(obj->data.s);
|
cimlib_add_image(obj->data.s);
|
||||||
}
|
}
|
||||||
#endif /* IMLIB2 */
|
#endif /* IMLIB2 */
|
||||||
OBJ(eval) {
|
OBJ(eval) {
|
||||||
@ -6263,10 +6263,6 @@ static void main_loop(void)
|
|||||||
if (output_methods & TO_X) {
|
if (output_methods & TO_X) {
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
|
|
||||||
#ifdef IMLIB2
|
|
||||||
cimlib_event_start();
|
|
||||||
#endif /* IMLIB2 */
|
|
||||||
|
|
||||||
/* wait for X event or timeout */
|
/* wait for X event or timeout */
|
||||||
|
|
||||||
if (!XPending(display)) {
|
if (!XPending(display)) {
|
||||||
@ -6353,15 +6349,11 @@ static void main_loop(void)
|
|||||||
case Expose:
|
case Expose:
|
||||||
{
|
{
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
r.x = ev.xexpose.x;
|
r.x = ev.xexpose.x;
|
||||||
r.y = ev.xexpose.y;
|
r.y = ev.xexpose.y;
|
||||||
r.width = ev.xexpose.width;
|
r.width = ev.xexpose.width;
|
||||||
r.height = ev.xexpose.height;
|
r.height = ev.xexpose.height;
|
||||||
XUnionRectWithRegion(&r, region, region);
|
XUnionRectWithRegion(&r, region, region);
|
||||||
#ifdef IMLIB2
|
|
||||||
cimlib_event_expose(&ev);
|
|
||||||
#endif /* IMLIB2 */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6502,11 +6494,11 @@ static void main_loop(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
draw_stuff();
|
draw_stuff();
|
||||||
#ifdef IMLIB2
|
|
||||||
cimlib_event_end(/*window.x, window.y, */0, 0, window.width, window.height);
|
|
||||||
#endif /* IMLIB2 */
|
|
||||||
XDestroyRegion(region);
|
XDestroyRegion(region);
|
||||||
region = XCreateRegion();
|
region = XCreateRegion();
|
||||||
|
#ifdef IMLIB2
|
||||||
|
cimlib_event_end(text_start_x + border_margin, text_start_y + border_margin, window.width, window.height);
|
||||||
|
#endif /* IMLIB2 */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
@ -7512,11 +7504,13 @@ static void load_config_file(const char *f)
|
|||||||
stippled_borders = 4;
|
stippled_borders = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef IMLIB2
|
||||||
CONF("imlib_cache_size") {
|
CONF("imlib_cache_size") {
|
||||||
if (value) {
|
if (value) {
|
||||||
cimlib_set_cache_size(atoi(value));
|
cimlib_set_cache_size(atoi(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* IMLIB2 */
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
CONF("update_interval") {
|
CONF("update_interval") {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
108
src/imlib2.c
108
src/imlib2.c
@ -28,9 +28,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define NAME_SIZE 1024
|
||||||
|
|
||||||
struct image_list_s {
|
struct image_list_s {
|
||||||
const char *name;
|
char name[NAME_SIZE];
|
||||||
Imlib_Image image;
|
Imlib_Image image;
|
||||||
|
int x, y, w, h;
|
||||||
|
int wh_set;
|
||||||
struct image_list_s *prev;
|
struct image_list_s *prev;
|
||||||
struct image_list_s *next;
|
struct image_list_s *next;
|
||||||
};
|
};
|
||||||
@ -46,9 +50,7 @@ Imlib_Image buffer, image;
|
|||||||
|
|
||||||
void cimlib_set_cache_size(long size)
|
void cimlib_set_cache_size(long size)
|
||||||
{
|
{
|
||||||
if (size > 0) {
|
imlib_set_cache_size(size);
|
||||||
imlib_set_cache_size(size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cimlib_cleanup(void)
|
void cimlib_cleanup(void)
|
||||||
@ -62,7 +64,7 @@ void cimlib_cleanup(void)
|
|||||||
image_list_start = image_list_end = NULL;
|
image_list_start = image_list_end = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cimlib_init(Display *display, Window window, Visual *visual, Colormap colourmap)
|
void cimlib_init(Display *display, Window drawable, Visual *visual, Colormap colourmap)
|
||||||
{
|
{
|
||||||
image_list_start = image_list_end = NULL;
|
image_list_start = image_list_end = NULL;
|
||||||
cimlib_set_cache_size(DEFAULT_CACHE_SIZE);
|
cimlib_set_cache_size(DEFAULT_CACHE_SIZE);
|
||||||
@ -74,15 +76,34 @@ void cimlib_init(Display *display, Window window, Visual *visual, Colormap colou
|
|||||||
imlib_context_set_display(display);
|
imlib_context_set_display(display);
|
||||||
imlib_context_set_visual(visual);
|
imlib_context_set_visual(visual);
|
||||||
imlib_context_set_colormap(colourmap);
|
imlib_context_set_colormap(colourmap);
|
||||||
imlib_context_set_drawable(window);
|
imlib_context_set_drawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cimlib_add_image(const char *name)
|
void cimlib_add_image(const char *args)
|
||||||
{
|
{
|
||||||
struct image_list_s *cur = NULL;
|
struct image_list_s *cur = NULL;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
cur = malloc(sizeof(struct image_list_s));
|
cur = malloc(sizeof(struct image_list_s));
|
||||||
memset(cur, 0, sizeof(struct image_list_s));
|
memset(cur, 0, sizeof(struct image_list_s));
|
||||||
cur->name = name;
|
|
||||||
|
if (!sscanf(args, "%1024s", cur->name)) {
|
||||||
|
ERR("Invalid args for $image. Format is: '<path to image> (-p x,y) (-s WxH)' (got '%s')", args);
|
||||||
|
}
|
||||||
|
// now we check for optional args
|
||||||
|
tmp = strstr(args, "-p ");
|
||||||
|
if (tmp) {
|
||||||
|
tmp += 3;
|
||||||
|
sscanf(tmp, "%i,%i", &cur->x, &cur->y);
|
||||||
|
}
|
||||||
|
tmp = strstr(args, "-s ");
|
||||||
|
if (tmp) {
|
||||||
|
tmp += 3;
|
||||||
|
if (sscanf(tmp, "%ix%i", &cur->w, &cur->h)) {
|
||||||
|
cur->wh_set = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (image_list_end) {
|
if (image_list_end) {
|
||||||
image_list_end->next = cur;
|
image_list_end->next = cur;
|
||||||
cur->prev = image_list_end;
|
cur->prev = image_list_end;
|
||||||
@ -102,8 +123,8 @@ static void cimlib_draw_image(struct image_list_s *cur)
|
|||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
h = imlib_image_get_height();
|
h = imlib_image_get_height();
|
||||||
imlib_context_set_image(buffer);
|
imlib_context_set_image(buffer);
|
||||||
imlib_blend_image_onto_image(image, 0, 0, 0, w, h,
|
imlib_blend_image_onto_image(image, 1, 0, 0, h, w,
|
||||||
0, 0, w, h);
|
cur->x, cur->y, cur->w, cur->h);
|
||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
} else {
|
} else {
|
||||||
@ -111,13 +132,6 @@ static void cimlib_draw_image(struct image_list_s *cur)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cimlib_event_start(void)
|
|
||||||
{
|
|
||||||
if (!image_list_start) return; /* are we actually drawing anything? */
|
|
||||||
/* init our updates to empty */
|
|
||||||
updates = imlib_updates_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cimlib_draw_all(void)
|
static void cimlib_draw_all(void)
|
||||||
{
|
{
|
||||||
struct image_list_s *cur = image_list_start;
|
struct image_list_s *cur = image_list_start;
|
||||||
@ -132,57 +146,17 @@ void cimlib_event_end(int x, int y, int width, int height)
|
|||||||
if (!image_list_start) return; /* are we actually drawing anything? */
|
if (!image_list_start) return; /* are we actually drawing anything? */
|
||||||
/* take all the little rectangles to redraw and merge them into
|
/* take all the little rectangles to redraw and merge them into
|
||||||
* something sane for rendering */
|
* something sane for rendering */
|
||||||
updates = imlib_updates_merge_for_rendering(updates, width, height);
|
buffer = imlib_create_image(width, height);
|
||||||
for (current_update = updates; current_update; current_update = imlib_updates_get_next(current_update)) {
|
/* we can blend stuff now */
|
||||||
int up_x, up_y, up_w, up_h;
|
imlib_context_set_blend(1);
|
||||||
|
|
||||||
/* find out where the first update is */
|
cimlib_draw_all();
|
||||||
imlib_updates_get_coordinates(current_update,
|
|
||||||
&up_x, &up_y, &up_w, &up_h);
|
|
||||||
|
|
||||||
/* create our buffer image for rendering this update */
|
/* set the buffer image as our current image */
|
||||||
buffer = imlib_create_image(up_w, up_h);
|
imlib_context_set_image(buffer);
|
||||||
|
/* render the image at 0, 0 */
|
||||||
/* we can blend stuff now */
|
imlib_render_image_on_drawable(x, y);
|
||||||
imlib_context_set_blend(1);
|
/* don't need that temporary buffer image anymore */
|
||||||
|
imlib_free_image();
|
||||||
cimlib_draw_all();
|
|
||||||
|
|
||||||
/* set the buffer image as our current image */
|
|
||||||
imlib_context_set_image(buffer);
|
|
||||||
/* render the image at 0, 0 */
|
|
||||||
imlib_render_image_on_drawable(up_x, up_y);
|
|
||||||
/* don't need that temporary buffer image anymore */
|
|
||||||
imlib_free_image();
|
|
||||||
}
|
|
||||||
/* if we had updates - free them */
|
|
||||||
if (updates) {
|
|
||||||
imlib_updates_free(updates);
|
|
||||||
} else {
|
|
||||||
/* was likely a timeout, redraw everything */
|
|
||||||
|
|
||||||
/* create our buffer image for rendering this update */
|
|
||||||
buffer = imlib_create_image(width, height);
|
|
||||||
|
|
||||||
/* we can blend stuff now */
|
|
||||||
imlib_context_set_blend(1);
|
|
||||||
|
|
||||||
cimlib_draw_all();
|
|
||||||
|
|
||||||
/* set the buffer image as our current image */
|
|
||||||
imlib_context_set_image(buffer);
|
|
||||||
/* render the image at 0, 0 */
|
|
||||||
imlib_render_image_on_drawable(x, y);
|
|
||||||
/* don't need that temporary buffer image anymore */
|
|
||||||
imlib_free_image();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cimlib_event_expose(XEvent *event)
|
|
||||||
{
|
|
||||||
if (!image_list_start) return; /* are we actually drawing anything? */
|
|
||||||
updates = imlib_update_append_rect(updates,
|
|
||||||
event->xexpose.x, event->xexpose.y,
|
|
||||||
event->xexpose.width, event->xexpose.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,8 @@
|
|||||||
|
|
||||||
void cimlib_add_image(const char *name);
|
void cimlib_add_image(const char *name);
|
||||||
void cimlib_set_cache_size(long size);
|
void cimlib_set_cache_size(long size);
|
||||||
void cimlib_init(Display *display, Window window, Visual *visual, Colormap colourmap);
|
void cimlib_init(Display *display, Window drawable, Visual *visual, Colormap colourmap);
|
||||||
void cimlib_event_start(void);
|
|
||||||
void cimlib_event_end(int x, int y, int width, int height);
|
void cimlib_event_end(int x, int y, int width, int height);
|
||||||
void cimlib_event_expose(XEvent *event);
|
|
||||||
void cimlib_cleanup(void);
|
void cimlib_cleanup(void);
|
||||||
|
|
||||||
#endif /* _CONKY_IMBLI2_H_ */
|
#endif /* _CONKY_IMBLI2_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user