Skip to content

Commit 2530de5

Browse files
N-R-Kguijan
andcommitted
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 Co-authored-by: Guilherme Janczak <guilherme.janczak@yandex.com>
1 parent 541008f commit 2530de5

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

man/scrot.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ 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,opacity=100
179+
180+
The default width is automatically derived from the display DPI.
179181

180182
Example:
181183

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ Imlib_Image scrotSelectionSelectMode(void)
423423
opt.lineMode = LINE_MODE_CLASSIC;
424424
}
425425

426+
if (opt.lineWidth == 0) {
427+
int width = (scr->height + scr->width) / (scr->mheight + scr->mwidth);
428+
opt.lineWidth = MIN(MAX(width/4, 1), 8);
429+
}
430+
426431
if (opt.delaySelection)
427432
scrotDoDelay();
428433

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4343

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

4748
typedef struct {
4849
char *buf;

0 commit comments

Comments
 (0)