Skip to content

Commit

Permalink
fixed artifact showing in the top of screen when using center and fit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutim committed Jan 24, 2017
1 parent e44c2be commit 16b07b3
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions setroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ blank_screen( struct screen *s, const char *blank_color, Pixmap *canvas )
void
solid_color( struct monitor *mon )
{
struct wallpaper *w = mon->wall;
struct rgb_triple *col = w->bgcol; // won't be null
struct wallpaper *wall = mon->wall;
struct rgb_triple *col = wall->bgcol; // won't be null

Imlib_Image solid_color = imlib_create_image(mon->width, mon->height);
if (solid_color == NULL)
Expand All @@ -555,7 +555,7 @@ solid_color( struct monitor *mon )
imlib_context_set_color(col->r, col->g, col->b, 255);
imlib_context_set_image(solid_color);
imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
w->image = solid_color;
wall->image = solid_color;
}

void
Expand All @@ -566,10 +566,13 @@ center_wall( struct monitor *mon )

Imlib_Image centered_image = imlib_create_image(mon->width, mon->height);
imlib_context_set_image(centered_image);
if (col != NULL) {

if (col != NULL)
imlib_context_set_color(col->r, col->g, col->b, 255);
imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
}
else
imlib_context_set_color(0, 0, 0, 255);

imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
imlib_context_set_blend(1);

/* this is where we place the image in absolute coordinates */
Expand Down Expand Up @@ -597,10 +600,13 @@ stretch_wall( struct monitor *mon )

Imlib_Image stretched_image = imlib_create_image(mon->width, mon->height);
imlib_context_set_image(stretched_image);
if (col != NULL) {

if (col != NULL)
imlib_context_set_color(col->r, col->g, col->b, 255);
imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
}
else
imlib_context_set_color(0, 0, 0, 255);

imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
imlib_context_set_blend(1);

imlib_blend_image_onto_image(wall->image, 0,
Expand All @@ -622,10 +628,13 @@ fit_height( struct monitor *mon )

Imlib_Image fit_height_image = imlib_create_image(mon->width, mon->height);
imlib_context_set_image(fit_height_image);
if (col != NULL) {

if (col != NULL)
imlib_context_set_color(col->r, col->g, col->b, 255);
imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
}
else
imlib_context_set_color(0, 0, 0, 255);

imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
imlib_context_set_blend(1);

float scaled_width = wall->width * mon->height * (1.0 / wall->height);
Expand All @@ -651,10 +660,13 @@ fit_width( struct monitor *mon )

Imlib_Image fit_width_image = imlib_create_image(mon->width, mon->height);
imlib_context_set_image(fit_width_image);
if (col != NULL) {

if (col != NULL)
imlib_context_set_color(col->r, col->g, col->b, 255);
imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
}
else
imlib_context_set_color(0, 0, 0, 255);

imlib_image_fill_rectangle(0, 0, mon->width, mon->height);
imlib_context_set_blend(1);

float scaled_height = wall->height * mon->width * (1.0 / wall->width);
Expand Down Expand Up @@ -837,7 +849,7 @@ void
parse_opts( unsigned int argc, char **args )
{
/*VARIOUS FLAGS*/
unsigned int store = 0;
unsigned int store = 0;
unsigned int span = 0;

int assign_to_mon = -1;
Expand All @@ -852,8 +864,8 @@ parse_opts( unsigned int argc, char **args )

unsigned int greyscale = 0;

fit_t aspect = FIT_AUTO;
flip_t axis = NONE;
fit_t aspect = FIT_AUTO;
flip_t axis = NONE;

char *image_path = NULL;

Expand Down Expand Up @@ -989,18 +1001,18 @@ parse_opts( unsigned int argc, char **args )

if (image == NULL) invalid_img_error(image_path);
}
w->image_path = image_path;
w->option = aspect;
w->axis = axis;
w->span = span;
w->monitor = assign_to_mon;
w->image_path = image_path;
w->option = aspect;
w->axis = axis;
w->span = span;
w->monitor = assign_to_mon;

if (greyscale != 0) w->greyscale = greyscale;
if (blur_r != 0) w->blur = blur_r;
if (shrp_r != 0) w->sharpen = shrp_r;
if (greyscale != 0) w->greyscale = greyscale;
if (blur_r != 0) w->blur = blur_r;
if (shrp_r != 0) w->sharpen = shrp_r;

if (bright_v != 0.0) w->brightness = bright_v;
if (contrast_v != 0.0) w->contrast = contrast_v;
if (contrast_v != 0.0) w->contrast = contrast_v;

if (bg_col != NULL) w->bgcol = parse_color(bg_col);
if (tn_col != NULL) w->tint = parse_color(tn_col);
Expand Down Expand Up @@ -1140,7 +1152,7 @@ int main(int argc, char** args)
COLORMAP = DefaultColormap(XDPY, XSCRN_NUM);
VISUAL = DefaultVisual(XDPY, XSCRN_NUM);
BITDEPTH = DefaultDepth(XDPY, XSCRN_NUM);
SCREEN = init_screen(XSCRN->width, XSCRN->height);
SCREEN = init_screen(XSCRN->width, XSCRN->height);

#ifdef HAVE_LIBXINERAMA
if (streq(args[argc - 1], "--use-x-geometry"))
Expand Down

6 comments on commit 16b07b3

@Mic92
Copy link

@Mic92 Mic92 commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ttzhou can you make a bugfix release for this one we can point to for NixOS/nixpkgs#27564 ?

@ttzhou
Copy link
Owner

@ttzhou ttzhou commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mic92 latest commit does this. v2.0.0. does that work?

@vyp
Copy link

@vyp vyp commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ttzhou Thanks for your commit! But sorry to be pedantic, I think it should be v2.0.1 at least. That way the numbering can be different from v2.0 (and it would be less confusing).

You don't have to make another commit to change it. Just:

# Deletes local tag.
$ git tag --delete v2.0.0

# Deletes remote tag.
$ git push --delete origin v2.0.0

# Create new v2.0.1 tag.
$ git tag v2.0.1

# Push tag to repository.
$ git push origin v2.0.1

@ttzhou
Copy link
Owner

@ttzhou ttzhou commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mic92 should be good now. hope that helps.

@Mic92
Copy link

@Mic92 Mic92 commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@vyp
Copy link

@vyp vyp commented on 16b07b3 Jul 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ttzhou Thanks so much! 🙏 🙏

Please sign in to comment.