mirror of
https://github.com/davatorium/rofi.git
synced 2025-11-06 22:54:53 -05:00
[Test] Add explicit rounding, making it behave same on 64/32
This commit is contained in:
parent
dfec408342
commit
9e9ea5852b
2 changed files with 9 additions and 7 deletions
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "theme.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/** The default width of the scrollbar */
|
||||
#define DEFAULT_SCROLLBAR_WIDTH 8
|
||||
|
||||
|
|
@ -65,7 +67,7 @@ guint scrollbar_scroll_get_line(const scrollbar *sb, int y) {
|
|||
y -= half_handle;
|
||||
y = MIN(MAX(0, y), sb->widget.h - 2 * half_handle);
|
||||
|
||||
unsigned int sel = ((y) / sec);
|
||||
unsigned int sel = round((y) / sec);
|
||||
return MIN(sel, sb->length - 1);
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +180,8 @@ static void scrollbar_draw(widget *wid, cairo_t *draw) {
|
|||
float x = widget_padding_get_left(wid);
|
||||
float width = widget_padding_get_remaining_width(wid);
|
||||
|
||||
float radius = ((width < height) ? width : height) / 2; // Limit radius to prevent overlap
|
||||
float radius = ((width < height) ? width : height) /
|
||||
2; // Limit radius to prevent overlap
|
||||
|
||||
// Draw rounded rectangle
|
||||
cairo_new_sub_path(draw);
|
||||
|
|
@ -189,8 +192,7 @@ static void scrollbar_draw(widget *wid, cairo_t *draw) {
|
|||
cairo_close_path(draw);
|
||||
|
||||
cairo_fill(draw);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
cairo_rectangle(draw, widget_padding_get_left(wid),
|
||||
widget_padding_get_top(wid) + y,
|
||||
widget_padding_get_remaining_width(wid), height);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "helper.h"
|
||||
#include "display.h"
|
||||
#include "helper.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
|
|
@ -132,9 +132,9 @@ int main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) {
|
|||
TASSERTE(cl, 9999u);
|
||||
scrollbar_set_handle_length(sb, 1000);
|
||||
cl = scrollbar_scroll_get_line(sb, 10);
|
||||
TASSERTE(cl, 555u);
|
||||
TASSERTE(cl, 556u);
|
||||
cl = scrollbar_scroll_get_line(sb, 20);
|
||||
TASSERTE(cl, 1666u);
|
||||
TASSERTE(cl, 1667u);
|
||||
cl = scrollbar_scroll_get_line(sb, 0);
|
||||
TASSERTE(cl, 0u);
|
||||
cl = scrollbar_scroll_get_line(sb, 99);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue