diff --git a/src/conky.cc b/src/conky.cc index d9a9b752..d6082632 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -1015,6 +1015,16 @@ static int draw_mode; /* FG, BG or OUTLINE */ #ifdef BUILD_X11 static long current_color; +static int saved_coordinates_x[100]; +static int saved_coordinates_y[100]; + +int get_saved_coordinates_x(int i) { + return saved_coordinates_x[i]; +} +int get_saved_coordinates_y(int i) { + return saved_coordinates_y[i]; +} + static int text_size_updater(char *s, int special_index) { int w = 0; char *p; @@ -1597,6 +1607,11 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) { cur_y += current->arg; break; + case SAVE_COORDINATES: + saved_coordinates_x[static_cast(current->arg)] = cur_x - text_start_x; + saved_coordinates_y[static_cast(current->arg)] = cur_y + text_start_y - last_font_height; + break; + case TAB: { int start = current->arg; int step = current->width; diff --git a/src/conky.h b/src/conky.h index 3f172a25..3479e213 100644 --- a/src/conky.h +++ b/src/conky.h @@ -301,6 +301,9 @@ void set_updatereset(int); int get_updatereset(void); int get_total_updates(void); +int get_saved_coordinates_x(int); +int get_saved_coordinates_y(int); + /* defined in conky.c */ int spaced_print(char *, int, const char *, int, ...) __attribute__((format(printf, 3, 5))); diff --git a/src/core.cc b/src/core.cc index b5e4834a..02be64cc 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1011,6 +1011,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, obj->callbacks.print = &new_offset; END OBJ(voffset, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1; obj->callbacks.print = &new_voffset; + END OBJ(save_coordinates, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 0; + obj->callbacks.print = &new_save_coordinates; END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l = atoi(arg); obj->callbacks.print = &new_goto; #ifdef BUILD_X11 diff --git a/src/imlib2.cc b/src/imlib2.cc index 955ff8ef..33b7daa1 100644 --- a/src/imlib2.cc +++ b/src/imlib2.cc @@ -148,6 +148,15 @@ void cimlib_add_image(const char *args) { tmp += 3; if (sscanf(tmp, "%d", &cur->flush_interval) != 0) { cur->no_cache = 0; } } + tmp = strstr(args, "-i "); + if (tmp != nullptr) { + tmp += 3; + int i; + if (sscanf(tmp, "%d", &i) == 1) { + cur->x = get_saved_coordinates_x(i); + cur->y = get_saved_coordinates_y(i); + } + } if (cur->flush_interval < 0) { NORM_ERR("Imlib2: flush interval should be >= 0"); cur->flush_interval = 0; diff --git a/src/nvidia.cc b/src/nvidia.cc index 4d24db5e..95fe9757 100644 --- a/src/nvidia.cc +++ b/src/nvidia.cc @@ -310,6 +310,7 @@ const char *translate_nvidia_special_type[] = { "nvidiagraph", // GRAPH "", // OFFSET "", // VOFFSET + "", // SAVE_COORDINATES "", // FONT "", // GOTO "" // TAB diff --git a/src/specials.cc b/src/specials.cc index 8ba04efc..981cb6c8 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -749,6 +749,11 @@ void new_voffset(struct text_object *obj, char *p, unsigned int p_max_size) { new_special(p, VOFFSET)->arg = obj->data.l; } +void new_save_coordinates(struct text_object *obj, char *p, unsigned int p_max_size) { + if (p_max_size == 0) { return; } + new_special(p, SAVE_COORDINATES)->arg = obj->data.l; +} + void new_alignr(struct text_object *obj, char *p, unsigned int p_max_size) { if (p_max_size == 0) { return; } new_special(p, ALIGNR)->arg = obj->data.l; diff --git a/src/specials.h b/src/specials.h index 92733920..b7eec086 100644 --- a/src/specials.h +++ b/src/specials.h @@ -51,6 +51,7 @@ enum special_types { GRAPH, OFFSET, VOFFSET, + SAVE_COORDINATES, FONT, GOTO, TAB @@ -105,6 +106,7 @@ void new_bg(struct text_object *, char *, unsigned int); void new_outline(struct text_object *, char *, unsigned int); void new_offset(struct text_object *, char *, unsigned int); void new_voffset(struct text_object *, char *, unsigned int); +void new_save_coordinates(struct text_object *, char *, unsigned int); void new_alignr(struct text_object *, char *, unsigned int); void new_alignc(struct text_object *, char *, unsigned int); void new_goto(struct text_object *, char *, unsigned int);