~ruther/dwl

3973ea5bfe9676bf8673781a966c933b0af0a232 — Devin J. Pohly 5 years ago 53e7195
unify movemouse/resizemouse
2 files changed, 18 insertions(+), 28 deletions(-)

M config.def.h
M dwl.c
M config.def.h => config.def.h +2 -2
@@ 78,7 78,7 @@ static const Key keys[] = {
};

static const Button buttons[] = {
	{ MODKEY, BTN_LEFT,   movemouse,      {0} },
	{ MODKEY, BTN_LEFT,   moveresize,     {.ui = CurMove} },
	{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
	{ MODKEY, BTN_RIGHT,  resizemouse,    {0} },
	{ MODKEY, BTN_RIGHT,  moveresize,     {.ui = CurResize} },
};

M dwl.c => dwl.c +16 -26
@@ 148,7 148,7 @@ static void maprequest(struct wl_listener *listener, void *data);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time);
static void motionrelative(struct wl_listener *listener, void *data);
static void movemouse(const Arg *arg);
static void moveresize(const Arg *arg);
static void pointerfocus(Client *c, struct wlr_surface *surface,
		double sx, double sy, uint32_t time);
static void quit(const Arg *arg);


@@ 157,7 157,6 @@ static void render(struct wlr_surface *surface, int sx, int sy, void *data);
static void renderclients(Monitor *m, struct timespec *now);
static void rendermon(struct wl_listener *listener, void *data);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizemouse(const Arg *arg);
static void run(char *startup_cmd);
static void scalebox(struct wlr_box *box, float scale);
static Client *selclient(void);


@@ 733,7 732,7 @@ motionrelative(struct wl_listener *listener, void *data)
}

void
movemouse(const Arg *arg)
moveresize(const Arg *arg)
{
	struct wlr_surface *surface;
	grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);


@@ 742,8 741,20 @@ movemouse(const Arg *arg)

	/* Float the window and tell motionnotify to grab it */
	setfloating(grabc, 1);
	cursor_mode = CurMove;
	wlr_xcursor_manager_set_cursor_image(cursor_mgr, "fleur", cursor);
	switch (cursor_mode = arg->ui) {
	case CurMove:
		wlr_xcursor_manager_set_cursor_image(cursor_mgr, "fleur", cursor);
		break;
	case CurResize:
		/* Doesn't work for X11 output - the next absolute motion event
		 * returns the cursor to where it started */
		wlr_cursor_warp_closest(cursor, NULL,
				grabc->geom.x + grabc->geom.width,
				grabc->geom.y + grabc->geom.height);
		wlr_xcursor_manager_set_cursor_image(cursor_mgr,
				"bottom_right_corner", cursor);
		break;
	}
}

void


@@ 940,27 951,6 @@ resize(Client *c, int x, int y, int w, int h, int interact)
}

void
resizemouse(const Arg *arg)
{
	struct wlr_surface *surface;
	grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);
	if (!grabc)
		return;

	/* Doesn't work for X11 output - the next absolute motion event
	 * returns the cursor to where it started */
	wlr_cursor_warp_closest(cursor, NULL,
			grabc->geom.x + grabc->geom.width,
			grabc->geom.y + grabc->geom.height);

	/* Float the window and tell motionnotify to resize it */
	setfloating(grabc, 1);
	cursor_mode = CurResize;
	wlr_xcursor_manager_set_cursor_image(cursor_mgr,
			"bottom_right_corner", cursor);
}

void
run(char *startup_cmd)
{
	pid_t startup_pid = -1;