Skip to content

Classic selection: calculate line width #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/scrot_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ 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;
}

static void create_cursors(void)
{
struct selection_t *const sel = *selection_get();
Expand Down
4 changes: 3 additions & 1 deletion src/selection_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
8 changes: 2 additions & 6 deletions src/selection_edge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}