aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw/cocoa-srv.c
diff options
context:
space:
mode:
authorXiao-Yong Jin <xjin@anl.gov>2018-10-21 20:59:21 -0500
committerRuss Cox <rsc@swtch.com>2018-11-15 20:39:35 -0500
commit9af9ceca26596d562a3ae89fda70bad9f8822ab0 (patch)
tree7e6fbe7099d03cabd7ec724f5ec4dd976093a584 /src/cmd/devdraw/cocoa-srv.c
parentde43b1629d008aa6cdf4f6beb2b06e3859616a3e (diff)
downloadplan9port-9af9ceca26596d562a3ae89fda70bad9f8822ab0.tar.gz
plan9port-9af9ceca26596d562a3ae89fda70bad9f8822ab0.tar.bz2
plan9port-9af9ceca26596d562a3ae89fda70bad9f8822ab0.zip
devdraw: rewrite the Cocoa screen using Metal
Add a new macOS cocoa screen, cocoa-screen-metal.m. Rewrite the macOS cocoa drawing code to use the builtin runloop, and use Metal to push pixels with CAMetalLayer. Remove all of the deprecated code, and simplify some of the logic. Modify mkwsysrules.sh such that the new code is used only when the system version is equal or higher than 10.14. Allow touch events to simulate mouse clicks: three finger tap for the middle mouse button; four finger tap for the 2-1 chord. Support Tresize. Scale 16x16 Cursor up to 32x32 with an EPX algorithm. Support macOS input sources including the basic dead keys and the advanced CJK input methods. Increase the communication buffers in cocoa-srv.c to allow more input, especially for long sentences prepared by the macOS input souces.
Diffstat (limited to 'src/cmd/devdraw/cocoa-srv.c')
-rw-r--r--src/cmd/devdraw/cocoa-srv.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c
index 197fd512..6f9449ad 100644
--- a/src/cmd/devdraw/cocoa-srv.c
+++ b/src/cmd/devdraw/cocoa-srv.c
@@ -21,7 +21,7 @@ typedef struct Tagbuf Tagbuf;
struct Kbdbuf
{
- Rune r[32];
+ Rune r[256];
int ri;
int wi;
int stall;
@@ -29,7 +29,7 @@ struct Kbdbuf
struct Mousebuf
{
- Mouse m[32];
+ Mouse m[256];
Mouse last;
int ri;
int wi;
@@ -38,7 +38,7 @@ struct Mousebuf
struct Tagbuf
{
- int t[32];
+ int t[256];
int ri;
int wi;
};
@@ -97,7 +97,7 @@ servep9p(void)
/* pick off messages one by one */
if(convM2W(mbuf, nn+4, &m) <= 0)
sysfatal("cannot convert message");
- if(trace) fprint(2, "<- %W\n", &m);
+ if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m);
runmsg(&m);
}
}
@@ -191,6 +191,7 @@ runmsg(Wsysmsg *m)
break;
case Trddraw:
+ zlock();
n = m->count;
if(n > sizeof buf)
n = sizeof buf;
@@ -202,13 +203,16 @@ runmsg(Wsysmsg *m)
m->data = buf;
replymsg(m);
}
+ zunlock();
break;
case Twrdraw:
+ zlock();
if(_drawmsgwrite(m->data, m->count) < 0)
replyerror(m);
else
replymsg(m);
+ zunlock();
break;
case Ttop:
@@ -217,7 +221,9 @@ runmsg(Wsysmsg *m)
break;
case Tresize:
- // _xresizewindow(m->rect);
+#if OSX_VERSION >= 101400
+ resizewindow(m->rect);
+#endif
replymsg(m);
break;
}
@@ -238,7 +244,7 @@ replymsg(Wsysmsg *m)
if(m->type%2 == 0)
m->type++;
- if(trace) fprint(2, "-> %W\n", m);
+ if(trace) fprint(2, "%ud [%d] -> %W\n", nsec()/1000000, threadid(), m);
/* copy to output buffer */
n = sizeW2M(m);
@@ -293,11 +299,11 @@ matchmouse(void)
mousetags.ri = 0;
m.mouse = mouse.m[mouse.ri];
m.resized = mouseresized;
+ mouseresized = 0;
/*
if(m.resized)
fprint(2, "sending resize\n");
*/
- mouseresized = 0;
mouse.ri++;
if(mouse.ri == nelem(mouse.m))
mouse.ri = 0;
@@ -367,8 +373,6 @@ abortcompose(void)
keystroke(Kalt);
}
-void resizeimg(void);
-
void
keystroke(int c)
{