From 5d098091c3adf7c3ffe46db9b4de12a53d44638e Mon Sep 17 00:00:00 2001 From: daltomi Date: Thu, 1 Apr 2021 20:46:11 -0300 Subject: [PATCH] Classic selectione: calculate line width --- src/scrot_selection.c | 8 ++++++++ src/selection_classic.c | 4 +++- src/selection_edge.c | 8 ++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/scrot_selection.c b/src/scrot_selection.c index f90c0863..3c8856cd 100644 --- a/src/scrot_selection.c +++ b/src/scrot_selection.c @@ -52,6 +52,14 @@ static void selection_deallocate(void) *sel = NULL; } +void selection_set_line_width(struct selection_t* const sel) +{ + assert(sel != NULL); + sel->rect.x -= opt.line_width; + sel->rect.y -= opt.line_width; + sel->rect.w += opt.line_width; + sel->rect.h += opt.line_width; +} void selection_calculate_rect(int x0, int y0, int x1, int y1) { diff --git a/src/selection_classic.c b/src/selection_classic.c index 51cc20bf..cb1585a8 100644 --- a/src/selection_classic.c +++ b/src/selection_classic.c @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. extern void selection_calculate_rect(int x0, int y0, int x1, int y1); extern struct selection_t** selection_get(void); +extern void selection_set_line_width(struct selection_t* const sel); struct selection_classic_t { XGCValues gcval; @@ -114,11 +115,12 @@ void selection_classic_draw(void) void selection_classic_motion_draw(int x0, int y0, int x1, int y1) { - struct selection_t const *const sel = *selection_get(); + struct selection_t *const sel = *selection_get(); if (sel->rect.w) { selection_classic_draw(); } selection_calculate_rect(x0, y0, x1, y1); + selection_set_line_width(sel); selection_classic_draw(); } diff --git a/src/selection_edge.c b/src/selection_edge.c index 91914ebc..92e98660 100644 --- a/src/selection_edge.c +++ b/src/selection_edge.c @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. extern void selection_calculate_rect(int x0, int y0, int x1, int y1); extern struct selection_t** selection_get(void); +extern void selection_set_line_width(struct selection_t* const sel); struct selection_edge_t { Window wndDraw; @@ -148,11 +149,6 @@ void selection_edge_motion_draw(int x0, int y0, int x1, int y1) struct selection_t *const sel = *selection_get(); selection_calculate_rect(x0, y0, x1, y1); - - sel->rect.x -= opt.line_width; - sel->rect.y -= opt.line_width; - sel->rect.w += opt.line_width; - sel->rect.h += opt.line_width; - + selection_set_line_width(sel); selection_edge_draw(); }