Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-moveresize-20200609-46c8838.diff - sites - public wiki contents of suckless…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-moveresize-20200609-46c8838.diff (6406B)
---
1 From 46c883859e0cbab998febfbefd04932379d34034 Mon Sep 17 00:00:00 2001
2 From: oxinosg <[email protected]>
3 Date: Tue, 9 Jun 2020 13:49:23 +0200
4 Subject: [PATCH] [dwm][patch][moveresize] Added moveresizeedge function …
5 allows moving/resizing floating window to edge of screen
6
7 ---
8 config.def.h | 16 ++++++
9 dwm.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++
10 2 files changed, 165 insertions(+)
11
12 diff --git a/config.def.h b/config.def.h
13 index 1c0b587..4195232 100644
14 --- a/config.def.h
15 +++ b/config.def.h
16 @@ -78,6 +78,22 @@ static Key keys[] = {
17 { MODKEY, XK_m, setlayout, {.v …
18 { MODKEY, XK_space, setlayout, {0} …
19 { MODKEY|ShiftMask, XK_space, togglefloating, {0} …
20 + { MODKEY, XK_Down, moveresize, {.v …
21 + { MODKEY, XK_Up, moveresize, {.v …
22 + { MODKEY, XK_Right, moveresize, {.v …
23 + { MODKEY, XK_Left, moveresize, {.v …
24 + { MODKEY|ShiftMask, XK_Down, moveresize, {.v …
25 + { MODKEY|ShiftMask, XK_Up, moveresize, {.v …
26 + { MODKEY|ShiftMask, XK_Right, moveresize, {.v …
27 + { MODKEY|ShiftMask, XK_Left, moveresize, {.v …
28 + { MODKEY|ControlMask, XK_Up, moveresizeedge, {.v …
29 + { MODKEY|ControlMask, XK_Down, moveresizeedge, {.v …
30 + { MODKEY|ControlMask, XK_Left, moveresizeedge, {.v …
31 + { MODKEY|ControlMask, XK_Right, moveresizeedge, {.v …
32 + { MODKEY|ControlMask|ShiftMask, XK_Up, moveresizeedge, {.v …
33 + { MODKEY|ControlMask|ShiftMask, XK_Down, moveresizeedge, {.v …
34 + { MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v …
35 + { MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v …
36 { MODKEY, XK_0, view, {.ui…
37 { MODKEY|ShiftMask, XK_0, tag, {.ui…
38 { MODKEY, XK_comma, focusmon, {.i …
39 diff --git a/dwm.c b/dwm.c
40 index 9fd0286..00fd78a 100644
41 --- a/dwm.c
42 +++ b/dwm.c
43 @@ -183,6 +183,8 @@ static void mappingnotify(XEvent *e);
44 static void maprequest(XEvent *e);
45 static void monocle(Monitor *m);
46 static void motionnotify(XEvent *e);
47 +static void moveresize(const Arg *arg);
48 +static void moveresizeedge(const Arg *arg);
49 static void movemouse(const Arg *arg);
50 static Client *nexttiled(Client *c);
51 static void pop(Client *);
52 @@ -1193,6 +1195,153 @@ movemouse(const Arg *arg)
53 }
54 }
55
56 +void
57 +moveresize(const Arg *arg) {
58 + /* only floating windows can be moved */
59 + Client *c;
60 + c = selmon->sel;
61 + int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh;
62 + char xAbs, yAbs, wAbs, hAbs;
63 + int msx, msy, dx, dy, nmx, nmy;
64 + unsigned int dui;
65 + Window dummy;
66 +
67 + if (!c || !arg)
68 + return;
69 + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
70 + return;
71 + if (sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y…
72 + return;
73 +
74 + /* compute new window position; prevent window from be position…
75 + nw = c->w + w;
76 + if (wAbs == 'W')
77 + nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * …
78 +
79 + nh = c->h + h;
80 + if (hAbs == 'H')
81 + nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * …
82 +
83 + nx = c->x + x;
84 + if (xAbs == 'X') {
85 + if (x < selmon->mx)
86 + nx = selmon->mx;
87 + else if (x > selmon->mx + selmon->mw)
88 + nx = selmon->mx + selmon->mw - nw - 2 * c->bw;
89 + else
90 + nx = x;
91 + }
92 +
93 + ny = c->y + y;
94 + if (yAbs == 'Y') {
95 + if (y < selmon->my)
96 + ny = selmon->my;
97 + else if (y > selmon->my + selmon->mh)
98 + ny = selmon->my + selmon->mh - nh - 2 * c->bw;
99 + else
100 + ny = y;
101 + }
102 +
103 + ox = c->x;
104 + oy = c->y;
105 + ow = c->w;
106 + oh = c->h;
107 +
108 + XRaiseWindow(dpy, c->win);
109 + Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy,…
110 + resize(c, nx, ny, nw, nh, True);
111 +
112 + /* move cursor along with the window to avoid problems caused b…
113 + if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + …
114 + {
115 + nmx = c->x - ox + c->w - ow;
116 + nmy = c->y - oy + c->h - oh;
117 + XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
118 + }
119 +}
120 +
121 +void
122 +moveresizeedge(const Arg *arg) {
123 + /* move or resize floating window to edge of screen */
124 + Client *c;
125 + c = selmon->sel;
126 + char e;
127 + int nx, ny, nw, nh, ox, oy, ow, oh;
128 + int msx, msy, dx, dy, nmx, nmy;
129 + int starty;
130 + unsigned int dui;
131 + Window dummy;
132 +
133 + nx = c->x;
134 + ny = c->y;
135 + nw = c->w;
136 + nh = c->h;
137 +
138 + starty = selmon->showbar ? bh : 0;
139 +
140 + if (!c || !arg)
141 + return;
142 + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
143 + return;
144 + if(sscanf((char *)arg->v, "%c", &e) != 1)
145 + return;
146 +
147 + if(e == 't')
148 + ny = starty;
149 +
150 + if(e == 'b')
151 + ny = c->h > selmon->mh - 2 * c->bw ? c->h : selmon->mh …
152 +
153 + if(e == 'l')
154 + nx = 0;
155 +
156 + if(e == 'r')
157 + nx = c->w > selmon->mw - 2 * c->bw ? c->w : selmon->mw …
158 +
159 + if(e == 'T') {
160 + /* if you click to resize again, it will return to old …
161 + if(c->h + starty == c->oldh + c->oldy) {
162 + nh = c->oldh;
163 + ny = c->oldy;
164 + } else {
165 + nh = c->h + c->y - starty;
166 + ny = starty;
167 + }
168 + }
169 +
170 + if(e == 'B')
171 + nh = c->h + c->y + 2 * c->bw == selmon->mh ? c->oldh : …
172 +
173 + if(e == 'L') {
174 + if(c->w == c->oldw + c->oldx) {
175 + nw = c->oldw;
176 + nx = c->oldx;
177 + } else {
178 + nw = c->w + c->x;
179 + nx = 0;
180 + }
181 + }
182 +
183 + if(e == 'R')
184 + nw = c->w + c->x + 2 * c->bw == selmon->mw ? c->oldw : …
185 +
186 + ox = c->x;
187 + oy = c->y;
188 + ow = c->w;
189 + oh = c->h;
190 +
191 + XRaiseWindow(dpy, c->win);
192 + Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy,…
193 + resize(c, nx, ny, nw, nh, True);
194 +
195 + /* move cursor along with the window to avoid problems caused b…
196 + if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + …
197 + nmx = c->x - ox + c->w - ow;
198 + nmy = c->y - oy + c->h - oh;
199 + XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
200 + }
201 +}
202 +
203 Client *
204 nexttiled(Client *c)
205 {
206 --
207 2.20.1
208
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.