aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorIngmar Steen <iksteen@gmail.com>2026-08-31 14:43:32 +0200
committeruser <user@clank>2026-09-02 14:51:02 +0200
commit29061a4aca5e3d645c0e23b885342036ac48f97b (patch)
tree3194ebbff30807cd6d11dfdafdce7bccb4d16006 /include
parentwebdemo: version from contrib/version, published by ship (diff)
downloadslosh-29061a4aca5e3d645c0e23b885342036ac48f97b.tar.gz
slosh-29061a4aca5e3d645c0e23b885342036ac48f97b.tar.xz
slosh-29061a4aca5e3d645c0e23b885342036ac48f97b.zip
Add competitive multiplayer support.
Last input wins, canvas size is adjusted to active connection.
Diffstat (limited to 'include')
-rw-r--r--include/app.h13
-rw-r--r--include/graphics.h1
-rw-r--r--include/proto.h2
-rw-r--r--include/slosh.h8
4 files changed, 23 insertions, 1 deletions
diff --git a/include/app.h b/include/app.h
index a203858..92f2f85 100644
--- a/include/app.h
+++ b/include/app.h
@@ -5,6 +5,7 @@
#ifndef SLOSH_APP_H
#define SLOSH_APP_H
+#include "graphics.h"
#include "kdl.h"
#include "project.h"
#include "shader.h"
@@ -22,10 +23,16 @@ void app_event(app_t *a, const input_event_t *ev);
/* Kitty graphics for this frame: the bytes the client's terminal needs, and
* the same thing as JSON for tests. Bytes are borrowed until the next call. */
const char *app_graphics(app_t *a, size_t *len);
+/* The same frame for one attached terminal. `state` is that terminal's own
+ * transmission/deletion history; the viewport is in canonical screen cells. */
+const char *app_graphics_view(app_t *a, graphics_t *state, uint16_t x,
+ uint16_t y, uint16_t cols, uint16_t rows,
+ size_t *len);
void app_graphics_reset(app_t *a);
/* Did the last app_graphics() stream reach the client? Undelivered frames
* are regenerated: transmissions repeat and deletions stay owed. */
void app_graphics_commit(app_t *a, bool delivered);
+void app_graphics_view_commit(graphics_t *state, bool delivered);
char *app_graphics_json(app_t *a);
/* Transient announcements, drawn bottom-right and expiring on their own. */
@@ -87,6 +94,12 @@ bool app_should_quit(const app_t *a);
/* C-a d asks the client to leave while the session keeps running. */
bool app_detach_requested(const app_t *a);
void app_clear_detach(app_t *a);
+/* A different display took over the shared input stream. End state that cannot
+ * safely span clients (leader chord, pointer drag and hover position). */
+void app_cancel_client_interaction(app_t *a);
+/* A release over client-side filler has no canonical target, but still ends a
+ * pointer gesture without disturbing that client's keyboard leader state. */
+void app_cancel_client_pointer(app_t *a);
size_t app_pane_count(const app_t *a);
/* Tabs. A tab is a layout tree; panes in every tab keep running. */
diff --git a/include/graphics.h b/include/graphics.h
index 6a338df..13cc5dc 100644
--- a/include/graphics.h
+++ b/include/graphics.h
@@ -66,6 +66,7 @@ typedef struct {
uint32_t x_off, y_off; /* offset within the first cell, in pixels */
uint32_t sx, sy, sw, sh; /* source rectangle, in image pixels */
uint32_t px_w, px_h; /* the image's own size */
+ uint32_t cell_px_w, cell_px_h; /* canonical pixels represented by a cell */
int format, compression;
const uint8_t *data; /* NULL once the client has it */
size_t data_len;
diff --git a/include/proto.h b/include/proto.h
index 67b45f0..4df52a6 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -30,7 +30,7 @@ enum {
enum {
EXIT_SESSION_ENDED = 0, /* the last pane closed */
EXIT_DETACHED = 1, /* the user detached */
- EXIT_REPLACED = 2, /* another client attached */
+ EXIT_REPLACED = 2, /* legacy: retained so new clients speak to old servers */
};
typedef struct {
diff --git a/include/slosh.h b/include/slosh.h
index e624bda..75aa658 100644
--- a/include/slosh.h
+++ b/include/slosh.h
@@ -76,6 +76,14 @@ void screen_init(screen_t *s, uint16_t cols, uint16_t rows);
void screen_free(screen_t *s);
void screen_resize(screen_t *s, uint16_t cols, uint16_t rows);
void screen_clear(screen_t *s);
+/* Project a canonical screen into a client-sized one. The source starts at
+ * (x,y); anything beyond its edges is blank filler. Diff history in `dst` is
+ * deliberately left alone, so every attached terminal advances independently. */
+void screen_project(screen_t *dst, const screen_t *src, uint16_t x, uint16_t y);
+/* Move an existing client viewport only as far as needed to keep the canonical
+ * cursor visible, then clamp it to the canonical screen. */
+void screen_follow_cursor(const screen_t *src, uint16_t cols, uint16_t rows,
+ uint16_t *x, uint16_t *y);
cell_t *screen_at(screen_t *s, uint16_t x, uint16_t y);
void screen_put_utf8(screen_t *s, uint16_t x, uint16_t y, const char *txt,
size_t len, color_t fg, color_t bg, uint16_t attrs);