devdraw: notify window resize promptly on x11

Fixes #339.
This commit is contained in:
Russ Cox 2020-01-14 19:43:32 -05:00
parent 40d787ab12
commit 1f799495e4
5 changed files with 28 additions and 13 deletions

View file

@ -55,10 +55,7 @@ gfx_replacescreenimage(Client *c, Memimage *m)
_freememimage(om); _freememimage(om);
} }
qunlock(&c->drawlk); qunlock(&c->drawlk);
gfx_mouseresized(c);
qlock(&c->eventlk);
c->mouse.resized = 1;
qunlock(&c->eventlk);
} }
static void static void

View file

@ -187,6 +187,7 @@ void gfx_keystroke(Client*, int);
void gfx_main(void); void gfx_main(void);
void gfx_mousetrack(Client*, int, int, int, uint); void gfx_mousetrack(Client*, int, int, int, uint);
void gfx_replacescreenimage(Client*, Memimage*); void gfx_replacescreenimage(Client*, Memimage*);
void gfx_mouseresized(Client*);
void gfx_started(void); void gfx_started(void);
// rpc_* routines are called on the RPC thread, // rpc_* routines are called on the RPC thread,

View file

@ -518,7 +518,6 @@ rpc_resizeimg(Client *c)
- (void)resizeimg { - (void)resizeimg {
[self initimg]; [self initimg];
gfx_replacescreenimage(self.client, self.img); gfx_replacescreenimage(self.client, self.img);
[self sendmouse:0];
} }
- (void)windowDidResize:(NSNotification *)notification { - (void)windowDidResize:(NSNotification *)notification {

View file

@ -394,12 +394,30 @@ matchmouse(Client *c)
} }
} }
void
gfx_mouseresized(Client *c)
{
gfx_mousetrack(c, -1, -1, -1, -1);
}
void void
gfx_mousetrack(Client *c, int x, int y, int b, uint ms) gfx_mousetrack(Client *c, int x, int y, int b, uint ms)
{ {
Mouse *m; Mouse *m;
qlock(&c->eventlk); qlock(&c->eventlk);
if(x == -1 && y == -1 && b == -1 && ms == -1) {
Mouse *copy;
// repeat last mouse event for resize
if(c->mouse.ri == 0)
copy = &c->mouse.m[nelem(c->mouse.m)-1];
else
copy = &c->mouse.m[c->mouse.ri-1];
x = copy->xy.x;
y = copy->xy.y;
b = copy->buttons;
ms = copy->msec;
}
if(x < c->mouserect.min.x) if(x < c->mouserect.min.x)
x = c->mouserect.min.x; x = c->mouserect.min.x;
if(x > c->mouserect.max.x) if(x > c->mouserect.max.x)

View file

@ -44,7 +44,7 @@ static Xwin*
newxwin(Client *c) newxwin(Client *c)
{ {
Xwin *w; Xwin *w;
w = mallocz(sizeof *w, 1); w = mallocz(sizeof *w, 1);
if(w == nil) if(w == nil)
sysfatal("out of memory"); sysfatal("out of memory");
@ -59,7 +59,7 @@ static Xwin*
findxwin(XDrawable d) findxwin(XDrawable d)
{ {
Xwin *w, **l; Xwin *w, **l;
for(l=&_x.windows; (w=*l) != nil; l=&w->next) { for(l=&_x.windows; (w=*l) != nil; l=&w->next) {
if(w->drawable == d) { if(w->drawable == d) {
/* move to front */ /* move to front */
@ -658,7 +658,7 @@ xattach(Client *client, char *label, char *winsize)
_x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False); _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False);
_x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False); _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False);
} }
atoms[0] = _x.takefocus; atoms[0] = _x.takefocus;
atoms[1] = _x.losefocus; atoms[1] = _x.losefocus;
XChangeProperty(_x.display, w->drawable, _x.wmprotos, XA_ATOM, 32, XChangeProperty(_x.display, w->drawable, _x.wmprotos, XA_ATOM, 32,
@ -700,7 +700,7 @@ xattach(Client *client, char *label, char *winsize)
_x.gcsimplesrc = xgc(w->screenpm, FillStippled, -1); _x.gcsimplesrc = xgc(w->screenpm, FillStippled, -1);
_x.gczero = xgc(w->screenpm, -1, -1); _x.gczero = xgc(w->screenpm, -1, -1);
_x.gcreplsrc = xgc(w->screenpm, FillTiled, -1); _x.gcreplsrc = xgc(w->screenpm, FillTiled, -1);
pmid = XCreatePixmap(_x.display, w->drawable, 1, 1, 1); pmid = XCreatePixmap(_x.display, w->drawable, 1, 1, 1);
_x.gcfill0 = xgc(pmid, FillSolid, 0); _x.gcfill0 = xgc(pmid, FillSolid, 0);
_x.gccopy0 = xgc(pmid, -1, -1); _x.gccopy0 = xgc(pmid, -1, -1);
@ -729,7 +729,7 @@ rpc_setlabel(Client *client, char *label)
{ {
Xwin *w = (Xwin*)client->view; Xwin *w = (Xwin*)client->view;
XTextProperty name; XTextProperty name;
/* /*
* Label and other properties required by ICCCCM. * Label and other properties required by ICCCCM.
*/ */
@ -1032,7 +1032,7 @@ _xreplacescreenimage(Client *client)
XDrawable pixmap; XDrawable pixmap;
Rectangle r; Rectangle r;
Xwin *w; Xwin *w;
w = (Xwin*)client->view; w = (Xwin*)client->view;
r = w->newscreenr; r = w->newscreenr;
pixmap = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth); pixmap = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth);
@ -1527,7 +1527,7 @@ __xputsnarf(char *data)
{ {
XButtonEvent e; XButtonEvent e;
Xwin *w; Xwin *w;
if(strlen(data) >= SnarfSize) if(strlen(data) >= SnarfSize)
return; return;
qlock(&clip.lk); qlock(&clip.lk);
@ -1730,7 +1730,7 @@ rpc_bouncemouse(Client *c, Mouse m)
Xwin *w = (Xwin*)c->view; Xwin *w = (Xwin*)c->view;
XButtonEvent e; XButtonEvent e;
XWindow dw; XWindow dw;
xlock(); xlock();
e.type = ButtonPress; e.type = ButtonPress;
e.state = 0; e.state = 0;