~sircmpwn/wio

wio: Fix for selections with "negative" width or height v1 PROPOSED

~z3bra
When using the "New" or "Resize" elements, wio crash when to cursor goes
to the left of the window's left border, or above the top border.
This patch takes the absolute value of the X and Y distance between the
top-left corner of the window and the cursor to draw the new area, thus
preventing crashes when this going the "negative way" with the cursor.

Willy Goiffon (1):
  Handle new/resize with negative cursor coordinates

 output.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

-- 
2.26.2
Can you re-do this without the macro?
Can you please re-send this with git send-email? Your "There you go.
Same patch without the macros." would end up in the commit message
as-is, and you should put this into a new thread.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/wio/patches/14660/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH wio 1/1] Handle new/resize with negative cursor coordinates Export this patch

~z3bra
From: Willy Goiffon <dev@z3bra.org>

---
 output.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/output.c b/output.c
index 6a059f5..2e552c6 100644
--- a/output.c
+++ b/output.c
@@ -12,6 +12,9 @@
#include "server.h"
#include "view.h"

#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

struct render_data {
	struct wlr_output *output;
	struct wlr_renderer *renderer;
@@ -269,6 +272,7 @@ static void render_layer(
}

static void output_frame(struct wl_listener *listener, void *data) {
	double x1, x2, y1, y2;
	struct wio_output *output = wl_container_of(listener, output, frame);
	struct wio_server *server = output->server;
	struct wlr_renderer *renderer = server->renderer;
@@ -350,11 +354,13 @@ static void output_frame(struct wl_listener *listener, void *data) {
		break;
	case INPUT_STATE_NEW_END:
	case INPUT_STATE_RESIZE_END:
		render_view_border(renderer, output, NULL,
			server->interactive.sx, server->interactive.sy,
			server->cursor->x - server->interactive.sx,
			server->cursor->y - server->interactive.sy,
			1);
		x1 = MIN(server->cursor->x, server->interactive.sx);
		y1 = MIN(server->cursor->y, server->interactive.sy);

		x2 = MAX(server->cursor->x, server->interactive.sx);
		y2 = MAX(server->cursor->y, server->interactive.sy);

		render_view_border(renderer, output, NULL, x1, y1, x2 - x1, y2 - y1, 1);
		break;
	default:
		break;
-- 
2.26.2
Can you re-do this without the macro?

Re: [PATCH v2] Handle new/resize with negative cursor coordinates Export this patch

There you go. Same patch without the macros.

---
 output.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/output.c b/output.c
index 6a059f5..c0877fe 100644
--- a/output.c
+++ b/output.c
@@ -269,6 +269,7 @@ static void render_layer(
}

static void output_frame(struct wl_listener *listener, void *data) {
	double x1, x2, y1, y2;
	struct wio_output *output = wl_container_of(listener, output, frame);
	struct wio_server *server = output->server;
	struct wlr_renderer *renderer = server->renderer;
@@ -350,11 +351,16 @@ static void output_frame(struct wl_listener *listener, void *data) {
		break;
	case INPUT_STATE_NEW_END:
	case INPUT_STATE_RESIZE_END:
		render_view_border(renderer, output, NULL,
			server->interactive.sx, server->interactive.sy,
			server->cursor->x - server->interactive.sx,
			server->cursor->y - server->interactive.sy,
			1);
		x1 = server->cursor->x < server->interactive.sx ?
			server->cursor->x : server->interactive.sx;
		y1 = server->cursor->y < server->interactive.sy ?
			server->cursor->y : server->interactive.sy;
		x2 = server->cursor->x > server->interactive.sx ?
			server->cursor->x : server->interactive.sx;
		y2 = server->cursor->y > server->interactive.sy ?
			server->cursor->y : server->interactive.sy;

		render_view_border(renderer, output, NULL, x1, y1, x2 - x1, y2 - y1, 1);
		break;
	default:
		break;
-- 
2.29.2
Can you please re-send this with git send-email? Your "There you go.
Same patch without the macros." would end up in the commit message
as-is, and you should put this into a new thread.