Files
netbird/client/ui/xembed_tray_linux.h
Maycon Santos 91acb8147c [management,client] 0.75.0 release with new desktop UI (#6473)
- **Wails v3 application** (`client/ui`) with a React + TypeScript + Tailwind frontend replacing the Fyne UI: main connection view, exit-node switcher, networks/peers browser with detail panels, profile management, settings (general, network, SSH, security, troubleshooting, appearance), debug-bundle creation, and a first-run welcome flow.
- **Internationalization**: go-i18n bundle with 9 locales (en, de, es, fr, hu, it, pt, ru, zh-CN) shared between the tray and the frontend.
- **New system tray** implementation with per-platform theme-aware icons, including a native XEmbed host for Linux (`xembed_tray_linux.c`) and a Linux theme watcher.
- **Session handling**: auth session watcher (`client/internal/auth/sessionwatch`), pending login flow, session-expiration dialog and tray notifications, and `netbird login` improvements.
- **Daemon API extensions** (`daemon.proto`): status stream subscription, event stream, networks/exit-node selection endpoints, and richer full status — with probe throttling on the daemon side to protect against UI-driven request storms.
- **UI preferences store** persisted per profile, autostart management via the daemon (single source of truth in HKCU on Windows).
- **Build system**: Taskfile-based builds per platform (macOS, Linux, Windows), Docker cross-compilation images, MSIX/NSIS/nfpm/AppImage packaging, and a new `frontend-ui` CI workflow.

Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com>
Co-authored-by: Eduard Gert <kontakt@eduardgert.de>
Co-authored-by: braginini <bangvalo@gmail.com>
Co-authored-by: Pascal Fischer <32096965+pascal-fischer@users.noreply.github.com>
Co-authored-by: riccardom <riccardomanfrin@gmail.com>
2026-07-06 13:47:16 +02:00

82 lines
3.5 KiB
C

#ifndef XEMBED_TRAY_H
#define XEMBED_TRAY_H
#include <X11/Xlib.h>
// xembed_default_screen wraps the DefaultScreen macro for CGo.
static inline int xembed_default_screen(Display *dpy) {
return DefaultScreen(dpy);
}
// xembed_install_error_handlers replaces Xlib's default protocol- and
// I/O-error handlers (which call exit()) with logging handlers, so an async
// X error from a tray race doesn't kill the UI process. Process-global and
// idempotent; safe to call after every XOpenDisplay.
void xembed_install_error_handlers(void);
// xembed_find_tray returns the selection owner window for
// _NET_SYSTEM_TRAY_S{screen}, or 0 if no XEmbed tray manager exists.
Window xembed_find_tray(Display *dpy, int screen);
// xembed_get_icon_size queries _NET_SYSTEM_TRAY_ICON_SIZE from the tray
// manager window. Returns the size in pixels, or 0 if not set.
int xembed_get_icon_size(Display *dpy, Window tray_mgr);
// xembed_create_icon creates a tray icon window of the given size,
// sets _XEMBED_INFO, and returns the window ID.
// tray_mgr is the tray manager window; its _NET_SYSTEM_TRAY_VISUAL
// property is queried to obtain a 32-bit ARGB visual for transparency.
Window xembed_create_icon(Display *dpy, int screen, int size, Window tray_mgr);
// xembed_dock sends _NET_SYSTEM_TRAY_OPCODE SYSTEM_TRAY_REQUEST_DOCK
// to the tray manager to embed our icon window.
int xembed_dock(Display *dpy, Window tray_mgr, Window icon_win);
// xembed_draw_icon draws ARGB pixel data onto the icon window.
// data is in [A,R,G,B] byte order per pixel (SNI IconPixmap format).
// img_w, img_h are the source image dimensions.
// win_size is the target window dimension (square).
void xembed_draw_icon(Display *dpy, Window icon_win, int win_size,
const unsigned char *data, int img_w, int img_h);
// xembed_destroy_icon destroys the icon window.
void xembed_destroy_icon(Display *dpy, Window icon_win);
// xembed_poll_event processes pending X11 events. Returns:
// 0 = no actionable event
// 1 = left button press (out_x, out_y filled)
// 2 = right button press (out_x, out_y filled)
// 3 = expose (needs redraw)
// 4 = configure (resize; out_x=width, out_y=height)
// -1 = DestroyNotify on icon window (tray died)
int xembed_poll_event(Display *dpy, Window icon_win,
int *out_x, int *out_y);
// Callback type for menu item clicks. Called with the item's dbusmenu ID.
typedef void (*xembed_menu_click_cb)(int id);
// xembed_popup_menu builds and shows a GTK3 popup menu.
// items is an array of menu item descriptors, count is the number of items.
// cb is called (from the GTK main thread) when an item is clicked.
// x, y are root coordinates for positioning the popup.
// This must be called from the GTK main thread (use g_idle_add).
typedef struct xembed_menu_item {
int id; // dbusmenu item ID
const char *label; // display label (NULL for separator)
int enabled; // whether the item is clickable
int is_check; // whether this is a checkbox item
int checked; // checkbox state (0 or 1)
int is_separator;// 1 if this is a separator
// children + child_count populate when this item is a submenu folder
// (dbusmenu's children-display=="submenu"). NULL/0 means leaf item.
struct xembed_menu_item *children;
int child_count;
} xembed_menu_item;
// Schedule a GTK popup menu on the main thread.
void xembed_show_popup_menu(xembed_menu_item *items, int count,
xembed_menu_click_cb cb, int x, int y);
#endif