aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-04-14 00:29:28 +0200
committerFederico Angelilli <code@fedang.net>2024-04-14 00:29:28 +0200
commit3768820fb27ff394114a17f6612417bcc78689a0 (patch)
tree9f954b70fcb3855f0d3c3e955a5ad3b233287401 /src
parentcccfc17f790e84a9e574af97726cc5ef63a22447 (diff)
Fix size scaling and use scale only every 25%
Diffstat (limited to 'src')
-rw-r--r--src/comet.c2
-rw-r--r--src/draw.c15
-rw-r--r--src/draw.h2
-rw-r--r--src/window.c6
4 files changed, 10 insertions, 15 deletions
diff --git a/src/comet.c b/src/comet.c
index 24e89ea..54bb851 100644
--- a/src/comet.c
+++ b/src/comet.c
@@ -298,7 +298,7 @@ int main(int argc, char **argv)
draw_set_separator(draw, 10);
draw_set_font(draw, "Hack 13 Bold");
draw_set_context(draw, context);
- draw_set_size(draw, height, x_padding, x_padding, y_padding, scale);
+ draw_set_size(draw, height, x_padding, x_padding, y_padding);
State *state = state_create(win, draw);
diff --git a/src/draw.c b/src/draw.c
index c47aa00..44baba6 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -188,7 +188,7 @@ static void compute_width(Drawer *draw, Window *win)
{
int screen_width = win->con->screen_size->width;
double scale = window_get_scale(win);
- draw->width = screen_width / scale - draw->right_pad - draw->left_pad;
+ draw->width = (screen_width - draw->right_pad - draw->left_pad) / scale;
log_debug("Draw context width calculated [scale=%lf, width=%d]", scale, draw->width);
}
@@ -368,20 +368,17 @@ void draw_set_context(Drawer *draw, PangoContext *context)
log_debug("Pango context updated [context=%p]", context);
}
-void draw_set_size(Drawer *draw, int height, int left_pad, int right_pad, int top_pad, double scale)
+void draw_set_size(Drawer *draw, int height, int left_pad, int right_pad, int top_pad)
{
g_assert(height > 0);
- draw->height = height / scale;
- draw->left_pad = left_pad / scale;
- draw->right_pad = right_pad / scale;
- draw->top_pad = top_pad / scale;
+ draw->height = height;
+ draw->left_pad = left_pad;
+ draw->right_pad = right_pad;
+ draw->top_pad = top_pad;
log_debug("Draw context size updated [height=%d, left_pad=%d, right_pad=%d, top_pad=%d]",
height, left_pad, right_pad, top_pad);
-
- log_debug("Draw context size scaled [scale=%lf, height=%d, left_pad=%d, right_pad=%d, top_pad=%d]",
- scale, draw->height, draw->left_pad, draw->right_pad, draw->top_pad);
}
void draw_destroy(Drawer *draw)
diff --git a/src/draw.h b/src/draw.h
index 433f063..6d0119f 100644
--- a/src/draw.h
+++ b/src/draw.h
@@ -60,7 +60,7 @@ void draw_set_font(Drawer *draw, const char *font);
void draw_set_context(Drawer *draw, PangoContext *context);
-void draw_set_size(Drawer *draw, int height, int left_pad, int right_pad, int top_pad, double scale);
+void draw_set_size(Drawer *draw, int height, int left_pad, int right_pad, int top_pad);
void draw_destroy(Drawer *draw);
diff --git a/src/window.c b/src/window.c
index c179b0e..30d492f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -181,10 +181,8 @@ cairo_t *window_get_context(Window *win)
double window_get_scale(Window *win)
{
- // FIXME
- return 1;
-
- return MAX(1, win->con->screen_dpi / 96.0);
+ const int n = 4;
+ return MAX(1, floor((win->con->screen_dpi / 96.0) * n) * (1.0 / n));
}
void window_get_screen_size(Window *win, int *width, int *height)