Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

fix(desktop): NectarLink works on Windows 10 (#103)

average2affccf68f4b
diff --git a/README.md b/README.md
index 43ffe5b..67bd7ac 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
**Your Android phone and your PC, working as one.**
Notifications, messages, calls, clipboard, files, photos, screen mirroring and
-phone apps in windows, between Android and Windows 11. Free and open source.
+phone apps in windows, between Android and Windows 10 (2004+) or 11. Free and open source.
Local-first, end-to-end encrypted, no account and no cloud.
Hi, I'm Bee, and yes, a bee built an app called NectarLink. I build cool stuff
@@ -38,7 +38,7 @@ of new features I wanted that I think you'll enjoy having too.
| | Download | Needs |
|---|---|---|
-| **Windows (x64)** | [Installer (.exe)](https://github.com/thtbee/nectarlink/releases/download/v0.1.4/Nectarlink-0.1.4-x64-setup.exe) | Windows 11, 64-bit Intel or AMD |
+| **Windows (x64)** | [Installer (.exe)](https://github.com/thtbee/nectarlink/releases/download/v0.1.4/Nectarlink-0.1.4-x64-setup.exe) | Windows 10 (2004+) or 11, 64-bit Intel or AMD (Phone as webcam needs Windows 11) |
| **Windows (ARM64)** | From the next release | Windows 11 on ARM (Snapdragon) |
| **Linux (x86_64)** | From the next release: [one command](#on-linux), or a .deb, .rpm, AppImage or .tar.gz | Ubuntu 24.04 or newer, Debian 13, Fedora 40 or newer, 64-bit Intel or AMD |
| **Android** | [App (.apk)](https://github.com/thtbee/nectarlink/releases/download/v0.1.4/Nectarlink-0.1.4-android.apk) | Android 8.0 or newer |
diff --git a/desktop/app/cpp/native_window.cpp b/desktop/app/cpp/native_window.cpp
index 79526ee..bc45aa9 100644
--- a/desktop/app/cpp/native_window.cpp
+++ b/desktop/app/cpp/native_window.cpp
@@ -36,6 +36,25 @@ constexpr int kBackdropMica = 2; // DWMSBT_MAINWINDOW
constexpr int kBackdropAcrylic = 3; // DWMSBT_TRANSIENTWINDOW (Desktop Acrylic blur)
constexpr COLORREF kColorNone = 0xFFFFFFFE; // DWMWA_COLOR_NONE
+constexpr DWORD kFirstWindows11Build = 22000;
+
+// The real Windows build: GetVersionEx lies without a manifest entry, and
+// RtlGetVersion doesn't.
+DWORD windowsBuild()
+{
+ using RtlGetVersionFn = LONG(WINAPI *)(OSVERSIONINFOW *);
+ static const DWORD build = [] {
+ OSVERSIONINFOW info { sizeof(info) };
+ if (const HMODULE ntdll = GetModuleHandleW(L"ntdll.dll")) {
+ const auto fn = reinterpret_cast<RtlGetVersionFn>(GetProcAddress(ntdll, "RtlGetVersion"));
+ if (fn && fn(&info) == 0)
+ return info.dwBuildNumber;
+ }
+ return DWORD(0);
+ }();
+ return build;
+}
+
HWND hwndOf(const QWindow *window)
{
return reinterpret_cast<HWND>(window->winId());
@@ -345,7 +364,14 @@ NativeWindow::NativeWindow(QWindow *parent)
{
// Qt removes the system title bar and lets content fill the window.
#ifdef _WIN32
- setFlags(flags() | Qt::ExpandedClientAreaHint);
+ if (systemBackdropSupported()) {
+ setFlags(flags() | Qt::ExpandedClientAreaHint);
+ } else {
+ // Windows 10 keeps drawing its own caption (icon, title, buttons) over an
+ // expanded client area. A frameless window has no caption at all; the
+ // app bar's buttons and WM_NCHITTEST still give drag, resize and maximize.
+ setFlags(flags() | Qt::FramelessWindowHint);
+ }
setColor(Qt::transparent);
#elif defined(__linux__)
setFlags(flags() | Qt::FramelessWindowHint);
@@ -366,6 +392,15 @@ NativeWindow::NativeWindow(QWindow *parent)
#endif
}
+bool NativeWindow::systemBackdropSupported()
+{
+#ifdef _WIN32
+ return windowsBuild() >= kFirstWindows11Build;
+#else
+ return false;
+#endif
+}
+
void NativeWindow::setBackdrop(bool on)
{
if (m_backdrop == on)
@@ -547,12 +582,31 @@ void NativeWindow::applyFrame()
// its own caption buttons over the app's.
const MARGINS margins { 0, 0, 0, 0 };
DwmExtendFrameIntoClientArea(hwnd, &margins);
+ if (!systemBackdropSupported()) {
+ // Windows 10, frameless: give back the frame styles so Snap, Win+arrow,
+ // min/max animations and the shadow work. WM_NCCALCSIZE below keeps the
+ // whole window as client area, so no caption is drawn.
+ const LONG_PTR style = GetWindowLongPtrW(hwnd, GWL_STYLE);
+ const LONG_PTR want = (style & ~LONG_PTR(WS_POPUP))
+ | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
+ if (style != want) {
+ SetWindowLongPtrW(hwnd, GWL_STYLE, want);
+ SetWindowPos(hwnd, nullptr, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ }
+ const MARGINS shadow { 0, 0, 1, 0 }; // a 1px frame keeps the DWM shadow
+ DwmExtendFrameIntoClientArea(hwnd, &shadow);
+ }
const BOOL dark = m_darkFrame;
DwmSetWindowAttribute(hwnd, kUseImmersiveDarkMode, &dark, sizeof(dark));
- const int backdrop = m_backdrop ? (m_acrylic ? kBackdropAcrylic : kBackdropMica) : kBackdropNone;
- DwmSetWindowAttribute(hwnd, kSystemBackdropType, &backdrop, sizeof(backdrop));
- const COLORREF none = kColorNone;
- DwmSetWindowAttribute(hwnd, kCaptionColor, &none, sizeof(none));
+ // Windows 10 has no system backdrop or caption color: skip both, and the
+ // QML side keeps the window opaque there (see systemBackdropSupported).
+ if (systemBackdropSupported()) {
+ const int backdrop = m_backdrop ? (m_acrylic ? kBackdropAcrylic : kBackdropMica) : kBackdropNone;
+ DwmSetWindowAttribute(hwnd, kSystemBackdropType, &backdrop, sizeof(backdrop));
+ const COLORREF none = kColorNone;
+ DwmSetWindowAttribute(hwnd, kCaptionColor, &none, sizeof(none));
+ }
#elif defined(__linux__)
setColor(m_darkFrame ? QColor(0x14, 0x13, 0x11) : QColor(0xF8, 0xF6, 0xF2));
if (!property("_nl_linux_filter").toBool()) {
@@ -631,6 +685,24 @@ bool NativeWindow::nativeEvent(const QByteArray &eventType, void *message, qintp
const MSG *msg = static_cast<const MSG *>(message);
switch (msg->message) {
+ case WM_NCCALCSIZE:
+ // Windows 10 (frame styles on a frameless window): all client area.
+ if (msg->wParam == TRUE && !systemBackdropSupported()) {
+ if (IsZoomed(msg->hwnd)) {
+ // Maximized windows hang their frame off-screen: pull it back in.
+ auto *params = reinterpret_cast<NCCALCSIZE_PARAMS *>(msg->lParam);
+ const UINT dpi = GetDpiForWindow(msg->hwnd);
+ const int fx = GetSystemMetricsForDpi(SM_CXFRAME, dpi) + GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi);
+ const int fy = GetSystemMetricsForDpi(SM_CYFRAME, dpi) + GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi);
+ params->rgrc[0].left += fx;
+ params->rgrc[0].right -= fx;
+ params->rgrc[0].top += fy;
+ params->rgrc[0].bottom -= fy;
+ }
+ *result = 0;
+ return true;
+ }
+ break;
case WM_NCHITTEST: {
const long hit = hitTest(GET_X_LPARAM(msg->lParam), GET_Y_LPARAM(msg->lParam));
if (hit != HTCLIENT) {
diff --git a/desktop/app/cpp/native_window.h b/desktop/app/cpp/native_window.h
index b97f834..7348f92 100644
--- a/desktop/app/cpp/native_window.h
+++ b/desktop/app/cpp/native_window.h
@@ -32,6 +32,9 @@ class NativeWindow : public QQuickWindow
Q_PROPERTY(QQuickItem *maximizeButton READ maximizeButton WRITE setMaximizeButton NOTIFY maximizeButtonChanged)
Q_PROPERTY(bool maximizeHovered READ maximizeHovered NOTIFY maximizeStateChanged)
Q_PROPERTY(bool maximizePressed READ maximizePressed NOTIFY maximizeStateChanged)
+ // Whether Windows can draw Mica/Acrylic behind the window (Windows 11,
+ // build 22000 and later). Elsewhere the window must stay opaque.
+ Q_PROPERTY(bool systemBackdropSupported READ systemBackdropSupported CONSTANT)
public:
explicit NativeWindow(QWindow *parent = nullptr);
@@ -48,6 +51,7 @@ public:
void setMaximizeButton(QQuickItem *item);
bool maximizeHovered() const { return m_maximizeHovered; }
bool maximizePressed() const { return m_maximizePressed; }
+ static bool systemBackdropSupported();
// Interactive items inside the title strip (buttons, search fields):
// clicks there go to the item instead of dragging the window.
diff --git a/desktop/app/qml/MainWindow.qml b/desktop/app/qml/MainWindow.qml
index 1bad044..a956c7f 100644
--- a/desktop/app/qml/MainWindow.qml
+++ b/desktop/app/qml/MainWindow.qml
@@ -347,7 +347,8 @@ NativeWindow {
// window turns translucent only once the backdrop is in place, and opaque again
// before it is removed.
// Hive keeps its own fixed colors, so it never shows the wallpaper through.
- readonly property bool wantBackdrop: Qt.platform.os === "windows" && (Preferences.backdrop || Theme.glass) && !Theme.amoled && !Theme.hive
+ // Windows 10 has no backdrop: the window stays opaque there.
+ readonly property bool wantBackdrop: Qt.platform.os === "windows" && systemBackdropSupported && (Preferences.backdrop || Theme.glass) && !Theme.amoled && !Theme.hive
property bool micaApplied: false
property bool micaVisible: false
backdrop: micaApplied
diff --git a/desktop/app/qml/Theme.qml b/desktop/app/qml/Theme.qml
index 9acc9ff..3d3b7c0 100644
--- a/desktop/app/qml/Theme.qml
+++ b/desktop/app/qml/Theme.qml
@@ -236,6 +236,10 @@ QtObject {
readonly property string fontUi: "Figtree"
readonly property string fontDisplay: graphite ? "Instrument Serif" : "Figtree"
readonly property string fontMono: "Space Mono"
+ // Caption button glyphs: Segoe Fluent Icons ships with Windows 11 only;
+ // Windows 10's Segoe MDL2 Assets has the same code points.
+ readonly property string captionIconFont: Qt.fontFamilies().indexOf("Segoe Fluent Icons") >= 0
+ ? "Segoe Fluent Icons" : "Segoe MDL2 Assets"
readonly property var typography: Tokens.data.typography
readonly property var labelStyle: graphite ? Tokens.data.themes.graphite.label
: (hive ? Tokens.data.themes.hive.label : Tokens.data.themes.bloom.label)
diff --git a/desktop/app/qml/components/CaptionButtons.qml b/desktop/app/qml/components/CaptionButtons.qml
index 3f6c6fb..2bec8da 100644
--- a/desktop/app/qml/components/CaptionButtons.qml
+++ b/desktop/app/qml/components/CaptionButtons.qml
@@ -4,7 +4,7 @@ import QtQuick.Shapes
import app.nectarlink
// Minimize, maximize/restore and close, drawn like Windows 11's own on Windows
-// (Segoe Fluent Icons) and with crisp vector strokes on Linux where that font
+// (Segoe Fluent Icons, or Segoe MDL2 Assets on Windows 10) and with crisp vector strokes on Linux where that font
// isn't installed. The maximize button is registered with the window so Windows
// shows Snap Layouts when hovering it.
Row {
@@ -94,7 +94,7 @@ Row {
anchors.centerIn: parent
visible: Qt.platform.os === "windows"
text: button.glyph
- font.family: "Segoe Fluent Icons"
+ font.family: Theme.captionIconFont
font.pixelSize: 10
color: button.danger && (button.hovered || button.pressed) ? "#FFFFFF" : Theme.surfaceContent
opacity: buttons.window.active || button.hovered ? 1 : 0.45
diff --git a/desktop/app/qml/pages/SettingsPage.qml b/desktop/app/qml/pages/SettingsPage.qml
index 98be6cf..4eb596f 100644
--- a/desktop/app/qml/pages/SettingsPage.qml
+++ b/desktop/app/qml/pages/SettingsPage.qml
@@ -825,6 +825,7 @@ Item {
id: appearanceBottomPair
readonly property bool showGraphiteAmoled: Theme.graphite && Theme.dark
readonly property bool showMica: Qt.platform.os === "windows"
+ && !!Window.window && Window.window.systemBackdropSupported === true
visible: !Theme.hive && (showMica || showGraphiteAmoled)
width: parent.width
readonly property bool splitCols: showGraphiteAmoled && showMica && width >= 460
diff --git a/desktop/app/qml/setup/SetupWindow.qml b/desktop/app/qml/setup/SetupWindow.qml
index cc1d68b..b39bcb0 100644
--- a/desktop/app/qml/setup/SetupWindow.qml
+++ b/desktop/app/qml/setup/SetupWindow.qml
@@ -30,6 +30,11 @@ NativeWindow {
? (dark ? Qt.rgba(0.55, 0.52, 0.48, 0.55) : Qt.rgba(0.72, 0.68, 0.62, 0.55))
: (dark ? Qt.rgba(1.0, 0.62, 0.18, 0.75) : Qt.rgba(1.0, 0.72, 0.37, 0.80))
+ // Not Theme's: Theme reads the app's settings and data, which setup and
+ // the uninstaller (which deletes them) must leave alone.
+ readonly property string captionIconFont: Qt.fontFamilies().indexOf("Segoe Fluent Icons") >= 0
+ ? "Segoe Fluent Icons" : "Segoe MDL2 Assets"
+
readonly property string action: removing ? "remove"
: Setup.kind === "update" ? "update"
: Setup.kind === "reinstall" ? "reinstall"
@@ -115,7 +120,7 @@ NativeWindow {
anchors.centerIn: parent
visible: Qt.platform.os === "windows"
text: "\ue8bb"
- font.family: "Segoe Fluent Icons"
+ font.family: window.captionIconFont
font.pixelSize: 10
color: closeArea.containsMouse ? "#FFFFFF" : window.ink
}
diff --git a/desktop/app/src/win/mod.rs b/desktop/app/src/win/mod.rs
index f708759..70996a2 100644
--- a/desktop/app/src/win/mod.rs
+++ b/desktop/app/src/win/mod.rs
@@ -250,6 +250,7 @@ mod tests {
let version = os_version();
let parts: Vec<&str> = version.split('.').collect();
assert_eq!(parts.len(), 3, "{version}");
- assert!(parts[2].parse::<u32>().unwrap() >= 22000, "NectarLink targets Windows 11: {version}");
+ // Any real build number; Windows 10 (19041+) runs the app too.
+ assert!(parts[2].parse::<u32>().unwrap() >= 10240, "not a Windows 10 or 11 build: {version}");
}
}