Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow indicator offsets to start from bottom and right #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swaylock.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct swaylock_args {
uint32_t font_size;
uint32_t radius;
uint32_t thickness;
uint32_t indicator_x_position;
uint32_t indicator_y_position;
int32_t indicator_x_position;
int32_t indicator_y_position;
bool override_indicator_x_position;
bool override_indicator_y_position;
bool ignore_empty;
Expand Down
18 changes: 14 additions & 4 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,26 @@ static bool render_frame(struct swaylock_surface *surface) {

// Center the indicator unless overridden by the user
if (state->args.override_indicator_x_position) {
subsurf_xpos = state->args.indicator_x_position -
buffer_width / (2 * surface->scale) + 2 / surface->scale;
if (state->args.indicator_x_position < 0) {
subsurf_xpos = surface->width + state->args.indicator_x_position -
buffer_width / (2 * surface->scale) + 2 / surface->scale;
} else {
subsurf_xpos = state->args.indicator_x_position -
buffer_width / (2 * surface->scale) + 2 / surface->scale;
}
} else {
subsurf_xpos = surface->width / 2 -
buffer_width / (2 * surface->scale) + 2 / surface->scale;
}

if (state->args.override_indicator_y_position) {
subsurf_ypos = state->args.indicator_y_position -
(state->args.radius + state->args.thickness);
if (state->args.indicator_y_position < 0) {
subsurf_ypos = surface->height + state->args.indicator_y_position -
(state->args.radius + state->args.thickness);
} else {
subsurf_ypos = state->args.indicator_y_position -
(state->args.radius + state->args.thickness);
}
} else {
subsurf_ypos = surface->height / 2 -
(state->args.radius + state->args.thickness);
Expand Down