Skip to content

Commit bd0ffe6

Browse files
committed
derive default line width from display dpi
allows better default on high dpi displays where the previous default of 1 pixel would've been too small. Closes: #285
1 parent 53b5edf commit bd0ffe6

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ AS_IF([test "x$orig_CFLAGS" = "x"], [
2828
AX_APPEND_LINK_FLAGS(["-flto"])
2929
])
3030
m4_foreach([SCROT_FLAG],
31-
[["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"]], [
31+
[["-O3"], ["-Wall"], ["-Wextra"], ["-Wpedantic"], ["-fno-math-errno"]], [
3232
AX_APPEND_COMPILE_FLAGS(["SCROT_FLAG"])
3333
AS_IF([test "x$LTO_ENABLED" = "xyes"], [
3434
AX_APPEND_LINK_FLAGS(["SCROT_FLAG"])

deps.pc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Name: scrot's mandatory dependencies
22
Description: ditto
33
Version: infinite
44
Cflags: -D_XOPEN_SOURCE=700L
5+
Libs: -lm
56
Requires: x11 imlib2 >= 1.11.0 xcomposite >= 0.2.0 xext xfixes >= 5.0.1 xinerama >= 1.1.3

man/scrot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ SELECTION STYLE
175175

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

178-
mode=auto,style=solid,width=1,opacity=100
178+
mode=auto,style=solid,width=$dpi/75,opacity=100
179179

180180
Example:
181181

src/options.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct ScrotOptions opt = {
6868
.quality = 75,
6969
.compression = 7,
7070
.lineStyle = LineSolid,
71-
.lineWidth = 1,
7271
.lineOpacity = SELECTION_OPACITY_DEFAULT,
7372
.stackDirection = HORIZONTAL,
7473
.outputFile = defaultOutputFile,

src/scrot_selection.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3535

3636
#include <err.h>
3737
#include <errno.h>
38+
#include <math.h>
3839
#include <stdint.h>
3940
#include <stdlib.h>
4041
#include <string.h>
@@ -423,6 +424,14 @@ Imlib_Image scrotSelectionSelectMode(void)
423424
opt.lineMode = LINE_MODE_CLASSIC;
424425
}
425426

427+
if (opt.lineWidth == 0) {
428+
double mmToInches = 1 / 25.4;
429+
double inchesDiag = hypot(scr->mwidth, scr->mheight) * mmToInches;
430+
double pixelsDiag = hypot(scr->width, scr->height);
431+
double dpi = round(pixelsDiag / inchesDiag);
432+
opt.lineWidth = fmin(fmax(round(dpi / 75.0), 1), 8);
433+
}
434+
426435
if (opt.delaySelection)
427436
scrotDoDelay();
428437

0 commit comments

Comments
 (0)