Skip to content

Commit

Permalink
simpler line width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
N-R-K committed Feb 6, 2025
1 parent bd0ffe6 commit 2ea7a12
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AS_IF([test "x$orig_CFLAGS" = "x"], [
AX_APPEND_LINK_FLAGS(["-flto"])
])
m4_foreach([SCROT_FLAG],
[["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"], ["-fno-math-errno"]], [
[["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"]], [
AX_APPEND_COMPILE_FLAGS(["SCROT_FLAG"])
AS_IF([test "x$LTO_ENABLED" = "xyes"], [
AX_APPEND_LINK_FLAGS(["SCROT_FLAG"])
Expand Down
1 change: 0 additions & 1 deletion deps.pc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ Name: scrot's mandatory dependencies
Description: ditto
Version: infinite
Cflags: -D_XOPEN_SOURCE=700L
Libs: -lm
Requires: x11 imlib2 >= 1.11.0 xcomposite >= 0.2.0 xext xfixes >= 5.0.1 xinerama >= 1.1.3
2 changes: 1 addition & 1 deletion man/scrot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ SELECTION STYLE

Without the -l option, a default style is used:

mode=auto,style=solid,width=$dpi/75,opacity=100
mode=auto,style=solid,width=...,opacity=100 # FIXME: width

Example:

Expand Down
8 changes: 2 additions & 6 deletions src/scrot_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include <err.h>
#include <errno.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -425,11 +424,8 @@ Imlib_Image scrotSelectionSelectMode(void)
}

if (opt.lineWidth == 0) {
double mmToInches = 1 / 25.4;
double inchesDiag = hypot(scr->mwidth, scr->mheight) * mmToInches;
double pixelsDiag = hypot(scr->width, scr->height);
double dpi = round(pixelsDiag / inchesDiag);
opt.lineWidth = fmin(fmax(round(dpi / 75.0), 1), 8);
int width = (scr->height + scr->width) / (scr->mheight + scr->mwidth);
opt.lineWidth = MIN(MAX(width/4, 1), 8);
}

if (opt.delaySelection)
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#define ARRAY_COUNT(X) (sizeof(X) / sizeof(0[X]))
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))

typedef struct {
char *buf;
Expand Down

0 comments on commit 2ea7a12

Please sign in to comment.