devdraw: use indirect impl interface

Setting up for a real window system.
This commit is contained in:
Russ Cox 2020-01-25 14:31:52 -05:00
parent 162d0d5cd9
commit 94d381ec9d
4 changed files with 61 additions and 30 deletions

View file

@ -37,6 +37,27 @@ static void setprocname(const char*);
static uint keycvt(uint);
static uint msec(void);
static void rpc_resizeimg(Client*);
static void rpc_resizewindow(Client*, Rectangle);
static void rpc_serve(Client*);
static void rpc_setcursor(Client*, Cursor*, Cursor2*);
static void rpc_setlabel(Client*, char*);
static void rpc_setmouse(Client*, Point);
static void rpc_topwin(Client*);
static void rpc_bouncemouse(Client*, Mouse);
static void rpc_flush(Client*, Rectangle);
static ClientImpl macimpl = {
rpc_resizeimg,
rpc_resizewindow,
rpc_setcursor,
rpc_setlabel,
rpc_setmouse,
rpc_topwin,
rpc_bouncemouse,
rpc_flush
};
@class DrawView;
@class DrawLayer;
@ -201,6 +222,7 @@ rpc_attach(Client *c, char *label, char *winsize)
{
LOG(@"attachscreen(%s, %s)", label, winsize);
c->impl = &macimpl;
dispatch_sync(dispatch_get_main_queue(), ^(void) {
@autoreleasepool {
DrawView *view = [[DrawView new] attach:c winsize:winsize label:label];
@ -302,7 +324,7 @@ rpc_attach(Client *c, char *label, char *winsize)
// rpc_topwin moves the window to the top of the desktop.
// Called from an RPC thread with no client lock held.
void
static void
rpc_topwin(Client *c)
{
DrawView *view = (__bridge DrawView*)c->view;
@ -319,7 +341,7 @@ rpc_topwin(Client *c)
// rpc_setlabel updates the client window's label.
// If label == nil, the call is a no-op.
// Called from an RPC thread with no client lock held.
void
static void
rpc_setlabel(Client *client, char *label)
{
DrawView *view = (__bridge DrawView*)client->view;
@ -344,7 +366,7 @@ rpc_setlabel(Client *client, char *label)
// rpc_setcursor updates the client window's cursor image.
// Either c and c2 are both non-nil, or they are both nil to use the default arrow.
// Called from an RPC thread with no client lock held.
void
static void
rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2)
{
DrawView *view = (__bridge DrawView*)client->view;
@ -460,7 +482,7 @@ rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2)
// rpc_flush flushes changes to view.img's rectangle r
// to the on-screen window, making them visible.
// Called from an RPC thread with no client lock held.
void
static void
rpc_flush(Client *client, Rectangle r)
{
DrawView *view = (__bridge DrawView*)client->view;
@ -506,7 +528,7 @@ rpc_flush(Client *client, Rectangle r)
// rpc_resizeimg forces the client window to discard its current window and make a new one.
// It is called when the user types Cmd-R to toggle whether retina mode is forced.
// Called from an RPC thread with no client lock held.
void
static void
rpc_resizeimg(Client *c)
{
DrawView *view = (__bridge DrawView*)c->view;
@ -541,7 +563,7 @@ rpc_resizeimg(Client *c)
// rpc_resizewindow asks for the client window to be resized to size r.
// Called from an RPC thread with no client lock held.
void
static void
rpc_resizewindow(Client *c, Rectangle r)
{
DrawView *view = (__bridge DrawView*)c->view;
@ -696,7 +718,7 @@ rpc_resizewindow(Client *c, Rectangle r)
// rpc_setmouse moves the mouse cursor.
// Called from an RPC thread with no client lock held.
void
static void
rpc_setmouse(Client *c, Point p)
{
DrawView *view = (__bridge DrawView*)c->view;
@ -1095,7 +1117,7 @@ rpc_putsnarf(char *s)
// rpc_bouncemouse is for sending a mouse event
// back to the X11 window manager rio(1).
// Does not apply here.
void
static void
rpc_bouncemouse(Client *c, Mouse m)
{
}