Skip to content

Commit

Permalink
resolved merge conflicts in meson.build and render
Browse files Browse the repository at this point in the history
  • Loading branch information
LordCMonkey committed Sep 21, 2020
2 parents fea7e29 + 2cbc0c8 commit fabae09
Show file tree
Hide file tree
Showing 19 changed files with 805 additions and 107 deletions.
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ although the feature sets aren't perfectly overlapping.
--indicator-radius 100 \
--indicator-thickness 7 \
--effect-blur 7x5 \
--effect-vignette 0.5:0.5
--effect-vignette 0.5:0.5 \
--ring-color bb00cc \
--key-hl-color 880033 \
--line-color 00000000 \
--inside-color 00000088 \
--separator-color 00000000 \
--grace 2 \
--fade-in 0.2

## New Features

Expand All @@ -32,13 +34,27 @@ The main new features compared to upstream swaylock are:
* Use `--indicator` to make the indicator always active
* Use `--timestr` and `--datestr` to set the date/time formats
(using strftime-style formatting)
* `--submit-on-touch` to use your touchscreen to submit a password.
If you can unlock your device with anything else than your password,
this might come helpful to trigger PAM's authentication process.
* `--grace <seconds>` to set a password grace period, so that the password
isn't required to unlock until some number of seconds have passed.
* Used together with `--indicator`, the indicator is always shown,
even in the grace period.
* Used together with `--indicator-idle-visible`, the indicator is only
visible after the grace period.
* By default, a key press, a mouse event or a touch event will unlock
during the grace period. Use `--grace-no-mouse` to not unlock as a response
to a mouse event, and `--grace-no-touch` to not unlock as a response to
a touch event.
* `--fade-in <seconds>` to make the lock screen fade in.
* Various effects which can be applied to the background image
* `--effect-blur <radius>x<times>`: Blur the image (thanks to yvbbrjdr's
fast box blur algorithm in
[i3lock-fancy-rapid](https://github.com/yvbbrjdr/i3lock-fancy-rapid))
* `--effect-pixelate <factor>`: Pixelate the image.
* `--effect-scale <scale>`: Scale the image by a factor. This can be used
to pixelate the image, or make other effects faster if you don't need
the full resolution.
to make other effects faster if you don't need the full resolution.
* `--effect-greyscale`: Make the image greyscale.
* `--effect-vignette <base>:<factor>`: Apply a vignette effect (range is 0-1).
* `--effect-compose <position>;<size>;<gravity>;<path>`: Overlay another image.
Expand Down Expand Up @@ -88,7 +104,6 @@ Swaylock will drop root permissions shortly after startup.

## Effects


### Blur

`--effect-blur <radius>x<times>`: Blur the image.
Expand All @@ -97,14 +112,19 @@ Swaylock will drop root permissions shortly after startup.
the blur is, `<times>` is a number which specifies essentially how high quality the blur is
(i.e how closely the effect will resemble a true gaussian blur).

### Pixelate

`--effect-pixelate <factor>`: Pixelate the image.

`<factor>` is the amount of pixelation; a value of 10 will make each 10x10 square of pixels
the same color.

### Scale

`--effect-scale <scale>`: Scale the image by a factor.

This effect scales the internal buffer (with nearest-neighbour interpolation). This has
a few uses:
This effect scales the internal buffer. This has a few uses:

* Use two scale effects for a pixelation effect: `--effect-scale 0.1 --effect-scale 10`
* Use `--effect-scale` in combination with `--scaling` to create a zoom effect:
`--efect-scale 1.1 --scaling center`
* Speed up other effects by making the resolution smaller: with
Expand Down
119 changes: 107 additions & 12 deletions background-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,118 @@ enum background_mode parse_background_mode(const char *mode) {
}

cairo_surface_t *load_background_from_buffer(void *buf, uint32_t format,
uint32_t width, uint32_t height, uint32_t stride) {
cairo_surface_t *image = cairo_image_surface_create(
CAIRO_FORMAT_RGB24, width, height);
uint32_t width, uint32_t height, uint32_t stride, enum wl_output_transform transform) {
bool rotated =
transform == WL_OUTPUT_TRANSFORM_90 ||
transform == WL_OUTPUT_TRANSFORM_270 ||
transform == WL_OUTPUT_TRANSFORM_FLIPPED_90 ||
transform == WL_OUTPUT_TRANSFORM_FLIPPED_270;

// The image from Wayland is flipped.
void *cdata = cairo_image_surface_get_data(image);
uint32_t cstride = cairo_image_surface_get_stride(image);
for (size_t cy = 0; cy < height; ++cy) {
size_t wy = height - cy - 1;
memcpy((char *)cdata + cstride * cy, (char *)buf + stride * wy, width * 4);
cairo_surface_t *image;
if (rotated) {
image = cairo_image_surface_create(CAIRO_FORMAT_RGB24, height, width);
} else {
image = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
}

if (!image) {
swaylock_log(LOG_ERROR, "Failed to create background image.");
if (image == NULL) {
swaylock_log(LOG_ERROR, "Failed to create image..");
return NULL;
}

unsigned char *destbuf = cairo_image_surface_get_data(image);
size_t destwidth = cairo_image_surface_get_width(image);
size_t destheight = cairo_image_surface_get_height(image);
size_t deststride = cairo_image_surface_get_stride(image);
unsigned char *srcbuf = buf;
size_t srcstride = stride;
size_t minstride = srcstride < deststride ? srcstride : deststride;

// Lots of these are mostly-copy-and-pasted, with a lot of boilerplate
// for each case.
// The only interesting differencess between a lot of these cases are
// the definitions of srcx and srcy.
// I don't think it's worth adding a macro to make this "cleaner" though,
// as that would obfuscate what's actually going on.
switch (transform) {
case WL_OUTPUT_TRANSFORM_NORMAL:
// In most cases, the transform is probably normal. Luckily, it can be
// done with just one big memcpy.
if (srcstride == deststride) {
memcpy(destbuf, srcbuf, destheight * deststride);
} else {
for (size_t y = 0; y < destheight; ++y) {
memcpy(destbuf + y * deststride, srcbuf + y * srcstride, minstride);
}
}
break;
case WL_OUTPUT_TRANSFORM_90:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcx = desty;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcy = destwidth - destx - 1;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
case WL_OUTPUT_TRANSFORM_180:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcy = destheight - desty - 1;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcx = destwidth - destx - 1;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
case WL_OUTPUT_TRANSFORM_270:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcx = destheight - desty - 1;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcy = destx;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcy = desty;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcx = destwidth - destx - 1;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcx = desty;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcy = destx;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcy = destheight - desty - 1;
memcpy(destbuf + desty * deststride, srcbuf + srcy * srcstride, minstride);
}
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
for (size_t desty = 0; desty < destheight; ++desty) {
size_t srcx = destheight - desty - 1;
for (size_t destx = 0; destx < destwidth; ++destx) {
size_t srcy = destwidth - destx - 1;
*((uint32_t *)(destbuf + desty * deststride) + destx) =
*((uint32_t *)(srcbuf + srcy * srcstride) + srcx);
}
}
break;
}

return image;
}

Expand Down
2 changes: 2 additions & 0 deletions completions/bash/swaylock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ _swaylock()
--indicator-idle-visible
--indicator-radius
--indicator-thickness
--indicator-x-position
--indicator-y-position
--inside-caps-lock-color
--inside-clear-color
--inside-color
Expand Down
2 changes: 2 additions & 0 deletions completions/fish/swaylock.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ complete -c swaylock -l indicator-caps-lock -s l --description "Show the curr
complete -c swaylock -l indicator-idle-visible --description "Sets the indicator to show even if idle."
complete -c swaylock -l indicator-radius --description "Sets the indicator radius."
complete -c swaylock -l indicator-thickness --description "Sets the indicator thickness."
complete -c swaylock -l indicator-x-position --description "Sets the horizontal position of the indicator."
complete -c swaylock -l indicator-y-position --description "Sets the vertical position of the indicator."
complete -c swaylock -l inside-caps-lock-color --description "Sets the color of the inside of the indicator when Caps Lock is active."
complete -c swaylock -l inside-clear-color --description "Sets the color of the inside of the indicator when cleared."
complete -c swaylock -l inside-color --description "Sets the color of the inside of the indicator."
Expand Down
2 changes: 2 additions & 0 deletions completions/zsh/_swaylock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ _arguments -s \
'(--indicator-idle-visible)'--indicator-idle-visible'[Sets the indicator to show even if idle]' \
'(--indicator-radius)'--indicator-radius'[Sets the indicator radius]:radius:' \
'(--indicator-thickness)'--indicator-thickness'[Sets the indicator thickness]:thickness:' \
'(--indicator-x-position)'--indicator-x-position'[Sets the horizontal position of the indicator]' \
'(--indicator-y-position)'--indicator-y-position'[Sets the vertical position of the indicator]' \
'(--inside-caps-lock-color)'--inside-caps-lock-color'[Sets the color of the inside of the indicator when Caps Lock is active]:color:' \
'(--inside-clear-color)'--inside-clear-color'[Sets the color of the inside of the indicator when cleared]:color:' \
'(--inside-color)'--inside-color'[Sets the color of the inside of the indicator]:color:' \
Expand Down
Loading

0 comments on commit fabae09

Please sign in to comment.