diff --git a/configure.ac b/configure.ac index 8e00785..48887e0 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ AS_IF([test "x$orig_CFLAGS" = "x"], [ AX_APPEND_LINK_FLAGS(["-flto"]) ]) m4_foreach([SCROT_FLAG], - [["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"]], [ + [["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"], ["-fno-math-errno"]], [ AX_APPEND_COMPILE_FLAGS(["SCROT_FLAG"]) AS_IF([test "x$LTO_ENABLED" = "xyes"], [ AX_APPEND_LINK_FLAGS(["SCROT_FLAG"]) diff --git a/deps.pc b/deps.pc index d4189b0..6cd3796 100644 --- a/deps.pc +++ b/deps.pc @@ -2,4 +2,5 @@ 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 diff --git a/man/scrot.txt b/man/scrot.txt index f78e9ae..df1b262 100644 --- a/man/scrot.txt +++ b/man/scrot.txt @@ -175,7 +175,7 @@ SELECTION STYLE Without the -l option, a default style is used: - mode=auto,style=solid,width=1,opacity=100 + mode=auto,style=solid,width=1,opacity=100 # TODO: update the default width here Example: diff --git a/src/options.c b/src/options.c index 70099c2..1ed5bf8 100644 --- a/src/options.c +++ b/src/options.c @@ -68,7 +68,6 @@ struct ScrotOptions opt = { .quality = 75, .compression = 7, .lineStyle = LineSolid, - .lineWidth = 1, .lineOpacity = SELECTION_OPACITY_DEFAULT, .stackDirection = HORIZONTAL, .outputFile = defaultOutputFile, diff --git a/src/scrot_selection.c b/src/scrot_selection.c index 1bb55db..ec249cb 100644 --- a/src/scrot_selection.c +++ b/src/scrot_selection.c @@ -39,6 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include @@ -423,6 +424,14 @@ Imlib_Image scrotSelectionSelectMode(void) opt.lineMode = LINE_MODE_CLASSIC; } + 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 = CLAMP(round(dpi / 75.0), 1, 8); + } + if (opt.delaySelection) scrotDoDelay(); diff --git a/src/util.h b/src/util.h index 6a350aa..4e65d64 100644 --- a/src/util.h +++ b/src/util.h @@ -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 CLAMP(X, LO, HI) ((X) < (LO) ? (LO) : ((X) > (HI) ? (HI) : (X))) typedef struct { char *buf;