Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Transparent apps (the Terminal): window border and title separator drawn opaque (solidOver), so nothing behind the window shows through them; both themes

Federico Pereiraed7e4099eebf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89747e2..20bf537 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -120,6 +120,10 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
### Fixed
+- **A see-through line around the Terminal.** The Terminal's window has a transparent background, so
+ its 1-pixel border and the line under its title bar let what was behind the window show through (a
+ colored line when it was over another window). Both are now drawn opaque for transparent apps, in
+ Lord Flow and Lord Classic.
- **The login screen no longer stays running behind your session.** It was a whole display server
kept in memory after sign-in (about 53 MB of its own, 78 MB counting shared pages, measured in a
VMware VM). It now closes 10 seconds after a session takes the screen and starts again in a few
diff --git a/sdk/index.js b/sdk/index.js
index 71e62b0..d399656 100644
--- a/sdk/index.js
+++ b/sdk/index.js
@@ -83,7 +83,7 @@ export const windowIcon = (w) => windowIconOf(w, getAppOf);
export { systemInfo, systemReport, lordosVersion, useSystemInfo, useServerStats, useCpuUsage, formatBytes, formatDuration } from './system.js';
export * as fs from './fs.js';
export { useDirectory } from './fs.js';
-export { ThemeProvider, useTheme, DEFAULT_TOKENS } from './theme.js';
+export { ThemeProvider, useTheme, DEFAULT_TOKENS, solidOver } from './theme.js';
export {
Button, Toggle, Segmented, SidebarItem, SectionTitle, ScrollView, TextInput, hasTextFocus, takeTextFocus, releaseTextFocus, textFocusOwner, Stepper, Slider,
AppHost, useAppWindow, useKeyboard, focusToken, restoreFocus, pasteIntoFocused, FloatingWindows, useWindowState,
diff --git a/sdk/theme.js b/sdk/theme.js
index c08e96a..0a21583 100644
--- a/sdk/theme.js
+++ b/sdk/theme.js
@@ -80,3 +80,15 @@ export function ThemeProvider({ tokens, children }) {
}
export const useTheme = () => useContext(ThemeContext);
+
+// A translucent line color (rgba) laid over an opaque one (#rrggbb), as one opaque color. A window of an
+// app with a transparent background (the Terminal) has nothing behind its border and title separator,
+// so those are drawn already mixed: otherwise what is behind the window shows through them.
+export function solidOver(rgba, hex) {
+ const m = /rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?\)/.exec(String(rgba));
+ const h = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(String(hex));
+ if (!m || !h) return rgba;
+ const a = m[4] == null ? 1 : +m[4];
+ const c = [1, 2, 3].map((i) => Math.round(+m[i] * a + parseInt(h[i], 16) * (1 - a)));
+ return `rgb(${c[0]}, ${c[1]}, ${c[2]})`;
+}
diff --git a/themes/classic/components/Window.jsx b/themes/classic/components/Window.jsx
index 57d856c..5fd2cdd 100644
--- a/themes/classic/components/Window.jsx
+++ b/themes/classic/components/Window.jsx
@@ -7,7 +7,7 @@
// Lord Classic has no global menu bar: an app that declares menus (File, Edit, View, Go…; the same
// ones Lord Flow shows on top, useAppMenus) gets them in a strip under its title bar, with Window and
// Help, as desktop apps do on a taskbar layout. Apps without menus of their own get no strip.
-import { View, Text, Layer, addListener, wm, AppHost, windowTitle, WindowShell, windowIcon, snapZoneAt, screen, useAppMenus, getApp, appGroup, windowMenuItems, t as tr } from '@lordos/sdk';
+import { View, Text, Layer, addListener, wm, AppHost, windowTitle, WindowShell, windowIcon, snapZoneAt, screen, useAppMenus, getApp, appGroup, windowMenuItems, solidOver, t as tr } from '@lordos/sdk';
import { useEffect, useRef, useState } from 'react';
import { MinimizeGlyph, MaximizeGlyph, RestoreGlyph, CloseGlyph, LayoutGlyph } from '../glyphs.jsx';
import { Menu } from './Menu.jsx';
@@ -187,7 +187,8 @@ export function Window({ win, t, focused, app, tv }) {
return (
<WindowShell win={win} resizable={!tv} onMouseDown={() => wm.focus(win.id)} style={{
borderRadius: flat ? 0 : 8, backgroundColor: app.transparent ? 'transparent' : t.windowBg, overflow: 'hidden',
- border: `1px solid ${focused ? t.windowBorder : t.separator}`, boxShadow: shadow, ...tvStyle,
+ // a transparent app (the Terminal) has nothing behind its border: the border is drawn opaque
+ border: `1px solid ${app.transparent ? solidOver(focused ? t.windowBorder : t.separator, t.titleBg) : (focused ? t.windowBorder : t.separator)}`, boxShadow: shadow, ...tvStyle,
}}>
<View onMouseDown={(e) => {
if (e.button) return;
diff --git a/themes/default/components/Window.jsx b/themes/default/components/Window.jsx
index 069d887..a836859 100644
--- a/themes/default/components/Window.jsx
+++ b/themes/default/components/Window.jsx
@@ -2,7 +2,7 @@
// (the SDK's AppHost); the theme only decides how the frame looks. Moving and resizing (invisible
// borders on all 4 sides and 4 corners, <WindowShell>) is done by lord-server in C
// (docs/WINDOWS.md); the JS drag below is only kept for a maximized window.
-import { View, Text, addListener, wm, AppHost, windowTitle, WindowShell, t as tr } from '@lordos/sdk';
+import { View, Text, addListener, wm, AppHost, windowTitle, WindowShell, t as tr, solidOver } from '@lordos/sdk';
import { useEffect, useRef, useState } from 'react';
import { Menu } from './Menu.jsx';
@@ -59,7 +59,8 @@ export function Window({ win, app, t, focused, fx }) {
return (
<WindowShell win={win} onMouseDown={() => wm.focus(win.id)} style={{
borderRadius: win.maximized ? 0 : 12, backgroundColor: app.transparent ? 'transparent' : t.windowBg, overflow: 'hidden',
- border: `1px solid ${t.windowBorder}`,
+ // a transparent app (the Terminal) has nothing behind its border: the border is drawn opaque
+ border: `1px solid ${app.transparent ? solidOver(t.windowBorder, t.titleBg) : t.windowBorder}`,
boxShadow: focused ? '0 24px 56px rgba(0,0,0,0.55)' : '0 10px 28px rgba(0,0,0,0.32)',
...fxs,
}}>
@@ -80,7 +81,7 @@ export function Window({ win, app, t, focused, fx }) {
))}
</View>
</View>
- <View style={{ height: 1, backgroundColor: t.separator }} />
+ <View style={{ height: 1, backgroundColor: app.transparent ? solidOver(t.separator, t.titleBg) : t.separator }} />
<View style={{ flex: 1 }}><AppHost id={win.id} focused={focused} /></View>
</WindowShell>
);