Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

UI: selection colours WebKitGTK draws (translucent, also in an unfocused window) (#41); redraw the page after leaving full screen on Android

Gabriele Lozuponec1cbe7ad44c5
diff --git a/src/components/Viewer.tsx b/src/components/Viewer.tsx
index 6b68bd3..2c80f49 100644
--- a/src/components/Viewer.tsx
+++ b/src/components/Viewer.tsx
@@ -61,6 +61,27 @@ export function FullscreenButton({ content, hint, onOpen }: { content?: ReactNod
);
}
+/** Chrome on Android redraws only part of the page after leaving full screen: the rest keeps the
+ * full-screen layout until a reload. Once the window has its size back (the address bar slides in
+ * over several resizes), the page is put on a layer of its own for two frames, which makes the
+ * browser draw all of it again. */
+function repaintAfterFullscreen() {
+ const root = document.getElementById("root");
+ if (!root) return;
+ let timer = 0;
+ const repaint = () => {
+ window.removeEventListener("resize", settle);
+ root.style.opacity = "0.999";
+ requestAnimationFrame(() => requestAnimationFrame(() => (root.style.opacity = "")));
+ };
+ const settle = () => {
+ window.clearTimeout(timer);
+ timer = window.setTimeout(repaint, 250);
+ };
+ window.addEventListener("resize", settle);
+ timer = window.setTimeout(repaint, 400);
+}
+
/** The full-screen view as a portal, for parents that own it (see `FullscreenButton`). */
export function Fullscreen(props: { children: ReactNode; hint?: string; onClose: () => void; nav?: ViewerNav }) {
return createPortal(<FullscreenShell {...props} />, document.body);
@@ -200,7 +221,7 @@ function FullscreenShell({ children, hint, onClose, nav }: { children: ReactNode
.catch(() => {});
return () => {
alive = false;
- if (!wasFull) native.setFullscreen(false).catch(() => {});
+ if (!wasFull) native.setFullscreen(false).then(inBrowser ? repaintAfterFullscreen : undefined).catch(() => {});
};
}, []);
diff --git a/src/styles.css b/src/styles.css
index b896934..e9809de 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -103,8 +103,14 @@ textarea, input[type="text"], input[type="number"] { user-select: text; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
-/* Colour set too: WebKitGTK (Linux) otherwise draws a dark theme's selection near-black (#41). */
-::selection, input::selection, textarea::selection { background: var(--selection); color: var(--text); }
+/* Written out, and with alpha 0.99: WebKitGTK (Linux) ignores var() inside ::selection and turns an opaque selection
+ background into its own colour (a dark theme's grey came out near-black, #41); a translucent one it draws as given.
+ Keep them in step with --selection and --text above. */
+::selection, input::selection, textarea::selection { background: rgba(196, 196, 196, 0.99); color: #0d0d0d; }
+:root[data-theme="dark"] ::selection, :root[data-theme="dark"] input::selection,
+:root[data-theme="dark"] textarea::selection { background: rgba(90, 90, 90, 0.99); color: #f2f2f2; }
+:root[data-theme="dark"][data-platform="mac"] ::selection, :root[data-theme="dark"][data-platform="mac"] input::selection,
+:root[data-theme="dark"][data-platform="mac"] textarea::selection { background: rgba(99, 99, 99, 0.99); }
svg { display: block; flex: none; }
.app { display: flex; height: 100%; }