From 4d3c36cce4d70dfd88bd5e782e86141775577d30 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 5 Apr 2019 20:43:21 +0200 Subject: devdraw: respond to windowDidBecomeKey on darwin (#239) Fixes bug where devdraw does not "notice" mouse position after task switch. Fixes https://github.com/9fans/plan9port/issues/232. --- src/cmd/devdraw/cocoa-screen-metal.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 049d1c5c..21123f16 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -373,6 +373,11 @@ struct Cursors { return YES; } +- (void)windowDidBecomeKey:(id)arg +{ + [myContent sendmouse:0]; +} + @end @implementation DevDrawView -- cgit v1.2.3 From 0308e1f010cd8650840fa0ceee3b342229982420 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 5 Apr 2019 12:44:47 -0600 Subject: devdraw: fix cocoa metal _flushmemscreen for invalid rectangles (#240) It is possible to receive multiple screen resize events, and resizeimg would be called for different sizes, before _flushmemscreen actually gets called with rectangle sizes different from the most recent resizeimg call. The size mismatch would trigger illegal memory access inside _flushmemscreen. This commit protects _flushmemscreen by returning early if the requested rectangle is outside of the current texture rectangle. --- src/cmd/devdraw/cocoa-screen-metal.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 21123f16..78110302 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -987,6 +987,10 @@ void _flushmemscreen(Rectangle r) { LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); + if(!rectinrect(r, Rect(0, 0, texture.width, texture.height))){ + LOG(@"Rectangle is out of bounds, return."); + return; + } @autoreleasepool{ [texture -- cgit v1.2.3 From dfac95269ab7944810043fb9e78557b06ed3a767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Fri, 5 Apr 2019 18:45:56 +0000 Subject: acme: Update tag after receiving menu/nomenu control event (#251) --- src/cmd/acme/xfid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 5aa4a180..9c7be2c0 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -790,10 +790,12 @@ out: }else if(strncmp(p, "nomenu", 6) == 0){ /* turn off automatic menu */ w->filemenu = FALSE; + settag = TRUE; m = 6; }else if(strncmp(p, "menu", 4) == 0){ /* enable automatic menu */ w->filemenu = TRUE; + settag = TRUE; m = 4; }else if(strncmp(p, "cleartag", 8) == 0){ /* wipe tag right of bar */ -- cgit v1.2.3 From dc60de7b64948e89832f03181e6db799060036b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Travis=20sn=C9=AF=C7=9D=E1=97=A1=C9=94W?= Date: Fri, 5 Apr 2019 14:47:55 -0400 Subject: fortunes: correct a mispelling (#234) --- lib/fortunes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fortunes b/lib/fortunes index c1a4580c..7ac3c1d7 100644 --- a/lib/fortunes +++ b/lib/fortunes @@ -1506,7 +1506,7 @@ This terminal is not for your use, please log off! This time for sure! This will be a memorable month -- no matter how hard you try to forget it. This will hurt me more than it hurts you. -Thos who do not remember the past are condemned to repeat it. +Those who do not remember the past are condemned to repeat it. Those who can't write, write manuals. Those who can, do; those who can't, simulate. Those who can, do; those who can't, write. -- cgit v1.2.3 From 26c6b2579543e928158fa7d3c00d8b0e04ac270c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Apr 2019 15:04:10 -0400 Subject: devdraw: avoid deadlock on pre-Mojave macOS --- src/cmd/devdraw/cocoa-screen.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index c2489a6c..97128da2 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -541,6 +541,11 @@ _flushmemscreen(Rectangle r) return; rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); + + // This can get blocked behind responding to mouse events, + // which need to acquire the zlock, so let go of it during + // the flush. Perhaps the waitUntilDone:YES is wrong? + zunlock(); [appdelegate performSelectorOnMainThread:@selector(callflushimg:) withObject:[NSValue valueWithRect:rect] @@ -548,6 +553,7 @@ _flushmemscreen(Rectangle r) modes:[NSArray arrayWithObjects: NSRunLoopCommonModes, @"waiting image", nil]]; + zlock(); } static void drawimg(NSRect, uint); -- cgit v1.2.3 From 61601587295f6d0ef1c4084530fe0318e0c72b16 Mon Sep 17 00:00:00 2001 From: Chris Schultz Date: Fri, 5 Apr 2019 14:08:20 -0500 Subject: devdraw: prefer low-power GPU for macOS metal rendering (#231) --- src/cmd/devdraw/cocoa-screen-metal.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 78110302..21c041a5 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -153,6 +153,7 @@ threadmain(int argc, char **argv) id library; MTLRenderPipelineDescriptor *pipelineDesc; NSError *error; + NSArray *allDevices; const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable @@ -197,8 +198,18 @@ threadmain(int argc, char **argv) [win setContentView:myContent]; [myContent setWantsLayer:YES]; [myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; - - device = MTLCreateSystemDefaultDevice(); + + device = nil; + allDevices = MTLCopyAllDevices(); + for(id mtlDevice in allDevices) { + if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) { + device = mtlDevice; + break; + } + } + if(!device) + device = MTLCreateSystemDefaultDevice(); + commandQueue = [device newCommandQueue]; layer = (DrawLayer *)[myContent layer]; -- cgit v1.2.3 From 7bb69ba88b8083b3eb9b3afefd8cdeae6aea2149 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Fri, 5 Apr 2019 15:09:35 -0400 Subject: libdraw,devdraw: fix compatibility with old 16x16 cursor protocol (#217) Some libraries that depend on devdraw don't know about 32x32 cursor -- mainly 9fans.net/go/draw. --- src/cmd/devdraw/cocoa-srv.c | 8 ++++++++ src/cmd/devdraw/x11-srv.c | 1 + src/libdraw/drawclient.c | 2 +- src/libdraw/drawfcall.c | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 329dd71f..c1cf5983 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -162,6 +162,14 @@ runmsg(Wsysmsg *m) break; case Tcursor: + if(m->arrowcursor) + setcursor(nil, nil); + else + setcursor(&m->cursor, nil); + replymsg(m); + break; + + case Tcursor2: if(m->arrowcursor) setcursor(nil, nil); else diff --git a/src/cmd/devdraw/x11-srv.c b/src/cmd/devdraw/x11-srv.c index 17563f41..81416482 100644 --- a/src/cmd/devdraw/x11-srv.c +++ b/src/cmd/devdraw/x11-srv.c @@ -332,6 +332,7 @@ runmsg(Wsysmsg *m) break; case Tcursor: + case Tcursor2: if(m->arrowcursor) _xsetcursor(nil); else diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index de20d3a3..f0b1d388 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -296,7 +296,7 @@ _displaycursor(Display *d, Cursor *c, Cursor2 *c2) { Wsysmsg tx, rx; - tx.type = Tcursor; + tx.type = Tcursor2; if(c == nil){ memset(&tx.cursor, 0, sizeof tx.cursor); memset(&tx.cursor2, 0, sizeof tx.cursor2); diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index e36413b6..09051bbc 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -48,6 +48,7 @@ sizeW2M(Wsysmsg *m) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -64,6 +65,8 @@ sizeW2M(Wsysmsg *m) case Tmoveto: return 4+1+1+4+4; case Tcursor: + return 4+1+1+4+4+2*16+2*16+1; + case Tcursor2: return 4+1+1+4+4+2*16+2*16+4+4+4*32+4*32+1; case Rerror: return 4+1+1+_stringsize(m->error); @@ -108,6 +111,7 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -137,6 +141,13 @@ convW2M(Wsysmsg *m, uchar *p, uint n) PUT(p+10, m->mouse.xy.y); break; case Tcursor: + PUT(p+6, m->cursor.offset.x); + PUT(p+10, m->cursor.offset.y); + memmove(p+14, m->cursor.clr, sizeof m->cursor.clr); + memmove(p+46, m->cursor.set, sizeof m->cursor.set); + p[78] = m->arrowcursor; + break; + case Tcursor2: PUT(p+6, m->cursor.offset.x); PUT(p+10, m->cursor.offset.y); memmove(p+14, m->cursor.clr, sizeof m->cursor.clr); @@ -200,6 +211,7 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -229,6 +241,13 @@ convM2W(uchar *p, uint n, Wsysmsg *m) GET(p+10, m->mouse.xy.y); break; case Tcursor: + GET(p+6, m->cursor.offset.x); + GET(p+10, m->cursor.offset.y); + memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); + memmove(m->cursor.set, p+46, sizeof m->cursor.set); + m->arrowcursor = p[78]; + break; + case Tcursor2: GET(p+6, m->cursor.offset.x); GET(p+10, m->cursor.offset.y); memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); @@ -319,8 +338,12 @@ drawfcallfmt(Fmt *fmt) return fmtprint(fmt, "Rmoveto"); case Tcursor: return fmtprint(fmt, "Tcursor arrow=%d", m->arrowcursor); + case Tcursor2: + return fmtprint(fmt, "Tcursor2 arrow=%d", m->arrowcursor); case Rcursor: return fmtprint(fmt, "Rcursor"); + case Rcursor2: + return fmtprint(fmt, "Rcursor2"); case Trdkbd: return fmtprint(fmt, "Trdkbd"); case Rrdkbd: -- cgit v1.2.3 From 5517aa034025214e43fff6760140d3089d3baf80 Mon Sep 17 00:00:00 2001 From: Noah Evans Date: Sat, 6 Apr 2019 04:10:05 +0900 Subject: man/memdraw.3: fix typo --- man/man3/memdraw.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3 index 16a5cd79..243cfe16 100644 --- a/man/man3/memdraw.3 +++ b/man/man3/memdraw.3 @@ -267,7 +267,7 @@ returning pointers to the word and byte, respectively, that contain the beginning of the data for a given pixel. .PP .I Allocmemimage -allocages +allocates images with a given rectangle and channel descriptor (see .B strtochan -- cgit v1.2.3 From 317c3cdb76806629e8c2710b7fb9a69cc3e46867 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 5 Apr 2019 13:11:11 -0600 Subject: devdraw: stop redirecting ^H in cocoa-metal (#209) --- src/cmd/devdraw/cocoa-screen-metal.m | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 21c041a5..5fc03172 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -857,7 +857,6 @@ keycvt(uint code) { switch(code){ case '\r': return '\n'; - case '\b': return 127; case 127: return '\b'; case NSUpArrowFunctionKey: return Kup; case NSDownArrowFunctionKey: return Kdown; -- cgit v1.2.3 From 9179fdaaf4fb5748832b2162d35a515133bad0f5 Mon Sep 17 00:00:00 2001 From: Pocket7878 Date: Sat, 6 Apr 2019 04:12:41 +0900 Subject: samterm: stop ignoring all keys >= Kcmd --- src/cmd/samterm/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index 5b645e84..5fc42908 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -512,10 +512,11 @@ nontypingkey(int c) case PAGEUP: case RIGHTARROW: case SCROLLKEY: + case CUT: + case COPY: + case PASTE: return 1; } - if(c >= Kcmd) - return 1; return 0; } -- cgit v1.2.3 From 3197719090b3fd0a038767f7e8e15e771b1515be Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 19 Apr 2019 22:24:53 -0400 Subject: acme: do not trim spaces during Put The commit that introduced this was pushed accidentally. It is not a good idea to do this. (It breaks programs that think that a clean window means the body matches the on-disk file.) --- src/cmd/acme/exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 0fc6c16b..b3bb0ac3 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -192,7 +192,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt) f |= 2; } aa = getbytearg(argt, TRUE, TRUE, &a); - if(a){ + if(a){ if(strlen(a) > EVENTSIZE){ /* too big; too bad */ free(r); free(aa); @@ -674,7 +674,7 @@ checksha1(char *name, File *f, Dir *d) DigestState *h; uchar out[20]; uchar *buf; - + fd = open(name, OREAD); if(fd < 0) return; @@ -700,7 +700,7 @@ trimspaces(Rune *r, uint *np, int eof) nonspace = 0; w = 0; - n = *np; + n = *np; for(i=0; ib, q, r, n); nn = n; - if(w->autoindent) + // An attempt at automatically trimming trailing spaces. + // Breaks programs that inspect body file and think it will match on-disk file + // when window is clean. Should apply the changes to the actual window instead. + // Later. + if(0 && w->autoindent) nn = trimspaces(r, &n, q+n==q1); m = snprint(s, BUFSIZE+1, "%.*S", nn, r); sha1((uchar*)s, m, nil, h); -- cgit v1.2.3