Switched to loading images with one function
This commit is contained in:
parent
e89c45a7db
commit
4aa0a6105c
30
mpdart.c
30
mpdart.c
|
@ -86,13 +86,11 @@ void set_window_name(char* name) {
|
||||||
XFlush(xdisplay);
|
XFlush(xdisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_image_path(char* path) {
|
void imlib_update(char* path) {
|
||||||
|
|
||||||
if (im_image_path)
|
if (im_image_path)
|
||||||
free(im_image_path);
|
free(im_image_path);
|
||||||
im_image_path = path;
|
im_image_path = path;
|
||||||
}
|
|
||||||
|
|
||||||
void imlib_update(void) {
|
|
||||||
|
|
||||||
if (im_image) {
|
if (im_image) {
|
||||||
imlib_context_set_image(im_image);
|
imlib_context_set_image(im_image);
|
||||||
|
@ -118,23 +116,23 @@ void imlib_update(void) {
|
||||||
im_w = imlib_image_get_width();
|
im_w = imlib_image_get_width();
|
||||||
im_h = imlib_image_get_height();
|
im_h = imlib_image_get_height();
|
||||||
|
|
||||||
|
imlib_context_set_image(im_buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void imlib_render(int up_w, int up_h) {
|
void imlib_render(int up_w, int up_h) {
|
||||||
|
|
||||||
imlib_context_set_image(im_buffer);
|
|
||||||
|
|
||||||
imlib_context_set_blend(1);
|
|
||||||
imlib_blend_image_onto_image(im_image, 0,
|
imlib_blend_image_onto_image(im_image, 0,
|
||||||
0, 0, im_w, im_h,
|
0, 0, im_w, im_h,
|
||||||
0, 0, up_w, up_h);
|
0, 0, up_w, up_h);
|
||||||
imlib_context_set_blend(0);
|
|
||||||
|
|
||||||
imlib_render_image_on_drawable(0, 0);
|
imlib_render_image_on_drawable(0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get currently playing song from mpd and update X window */
|
/* get currently playing song from mpd and update X window */
|
||||||
void update_mpd_song(void) {
|
void update_mpd_song(void) {
|
||||||
|
|
||||||
static int song_id;
|
static int song_id;
|
||||||
static int old_song_id = -1;
|
static int old_song_id = -1;
|
||||||
|
|
||||||
|
@ -145,8 +143,7 @@ void update_mpd_song(void) {
|
||||||
|
|
||||||
if (!song) {
|
if (!song) {
|
||||||
fprintf(stderr, "Failed to get song from mpd\n");
|
fprintf(stderr, "Failed to get song from mpd\n");
|
||||||
set_image_path(0);
|
imlib_update(0);
|
||||||
imlib_update();
|
|
||||||
set_window_name("None");
|
set_window_name("None");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,8 +189,7 @@ void update_mpd_song(void) {
|
||||||
art album etc */
|
art album etc */
|
||||||
if (extension && (!strcmp(extension, ".jpg") || !strcmp(extension, ".png"))) {
|
if (extension && (!strcmp(extension, ".jpg") || !strcmp(extension, ".png"))) {
|
||||||
printf("Using '%s' as album art.\n", ent->d_name);
|
printf("Using '%s' as album art.\n", ent->d_name);
|
||||||
set_image_path(asprintf("%s/%s", dirname, ent->d_name));
|
imlib_update(asprintf("%s/%s", dirname, ent->d_name));
|
||||||
imlib_update();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +199,7 @@ void update_mpd_song(void) {
|
||||||
|
|
||||||
free(pretty_name);
|
free(pretty_name);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old_song_id = song_id;
|
old_song_id = song_id;
|
||||||
|
@ -350,7 +347,6 @@ int main(int argc, char** argv) {
|
||||||
if(!mpd_send_idle_mask(connection, MPD_IDLE_PLAYER))
|
if(!mpd_send_idle_mask(connection, MPD_IDLE_PLAYER))
|
||||||
die("Unable to send idle to mpd");
|
die("Unable to send idle to mpd");
|
||||||
|
|
||||||
|
|
||||||
/* mpd event loop */
|
/* mpd event loop */
|
||||||
while (1) {
|
while (1) {
|
||||||
/* sleep for a day at a time */
|
/* sleep for a day at a time */
|
||||||
|
@ -373,10 +369,10 @@ int main(int argc, char** argv) {
|
||||||
ww = ev.xconfigure.width;
|
ww = ev.xconfigure.width;
|
||||||
wh = ev.xconfigure.height;
|
wh = ev.xconfigure.height;
|
||||||
break;
|
break;
|
||||||
case Expose:
|
/* case Expose: */
|
||||||
ww = ev.xexpose.width;
|
/* ww = ev.xexpose.width; */
|
||||||
wh = ev.xexpose.height;
|
/* wh = ev.xexpose.height; */
|
||||||
break;
|
/* break; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imlib_render(ww, wh);
|
imlib_render(ww, wh);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user