Fix move windows

This commit is contained in:
BitHeaven 2023-03-12 15:48:17 +05:00
parent bf6e6ab982
commit 79bfbfdf15
5 changed files with 34 additions and 14 deletions

View File

@ -37,7 +37,7 @@ static char *colors[][3] = {
static const char *tags[] = { "", "", "3", "", "5", "6", "7", "8", "" };
/* launcher commands (They must be NULL terminated) */
static const char* grabc[] = { "grabc", "|", "tr", "-d", "'\n'", "|", "xclipboard", "-selection", "clipboard", NULL };
static const char* grabc[] = { "grabc", "|", "tr", "-d", "'\n'", "|", "xclip", "-selection", "clipboard", NULL };
static const char* bhev[] = { "firefox", "bhev.ru", NULL };
static const char* youtube[] = { "firefox", "youtube.com", NULL };

BIN
dwm

Binary file not shown.

42
dwm.c
View File

@ -837,8 +837,8 @@ drawstatusbar(Monitor *m, int bh, int extra, char* stext) {
if (extra) {
w = m->ww;
// w = m->ww - w - 2 * hpb;
ret = 1;
w = m->ww - w - 2 * hpb;
ret = m->ww - w;
x = 0 - 1;
x2 = m->ww - w2 - 2 * hpb;
} else {
@ -980,8 +980,6 @@ void
drawbar(Monitor *m)
{
int x, w, tw = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
@ -1034,8 +1032,8 @@ drawbar(Monitor *m)
if (m->showextrabar) {
if (m == selmon) { /* extra status is only drawn on selected monitor */
sw = drawstatusbar(m, bh, 1, estext);
drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
sw = drawstatusbar(m, bh, 1, estext);
drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
}
}
@ -1637,9 +1635,14 @@ void
resizemouse(const Arg *arg)
{
int ocx, ocy, nw, nh;
int ocx2, ocy2, nx, ny;
Client *c;
Monitor *m;
XEvent ev;
int horizcorner, vertcorner;
int di;
unsigned int dui;
Window dummy;
Time lasttime = 0;
if (!(c = selmon->sel))
@ -1649,10 +1652,19 @@ resizemouse(const Arg *arg)
restack(selmon);
ocx = c->x;
ocy = c->y;
ocx2 = c->x + c->w;
ocy2 = c->y + c->h;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
return;
horizcorner = nx < c->w / 2;
vertcorner = ny < c->h / 2;
XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
horizcorner ? (-c->bw) : (c->w + c->bw -1),
vertcorner ? (-c->bw) : (c->h + c->bw -1));
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@ -1666,8 +1678,12 @@ resizemouse(const Arg *arg)
continue;
lasttime = ev.xmotion.time;
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
// nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
// nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
nx = horizcorner ? ev.xmotion.x : c->x;
ny = vertcorner ? ev.xmotion.y : c->y;
nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
@ -1677,11 +1693,15 @@ resizemouse(const Arg *arg)
togglefloating(NULL);
}
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
resize(c, c->x, c->y, nw, nh, 1);
// resize(c, c->x, c->y, nw, nh, 1);
resize(c, nx, ny, nw, nh, 1);
break;
}
} while (ev.type != ButtonRelease);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
horizcorner ? (-c->bw) : (c->w + c->bw - 1),
vertcorner ? (-c->bw) : (c->h + c->bw - 1));
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {

BIN
dwm.o

Binary file not shown.