aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-30 10:25:37 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-30 10:25:37 -0500
commit3973ea5bfe9676bf8673781a966c933b0af0a232 (patch)
tree824b3b03ec5ffa1e09aa529548e818c152242880
parent53e71957f8823e793d2bd98cf23589774e65209a (diff)
unify movemouse/resizemouse
-rw-r--r--config.def.h4
-rw-r--r--dwl.c42
2 files changed, 18 insertions, 28 deletions
diff --git a/config.def.h b/config.def.h
index 5487cee..9f8c2e3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -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} },
};
diff --git a/dwl.c b/dwl.c
index d0fb19b..1060d10 100644
--- a/dwl.c
+++ b/dwl.c
@@ -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;