Files
OrionOS/deskbar/include/deskbar.h
T
Claude 2a42b826fb Add 6 desktop features: workspace shortcuts, Exposé, deskbar icons, notifications, screen lock, move-to-desktop
- Super+1-4: switch virtual desktop; Super+Shift+1-4: move focused window to desktop N
- Super+Space: Exposé window overview (tiled grid), click to select, Escape to cancel
- wm/src/expose.c: expose_show/expose_hide using ceil(sqrt) grid layout with saved/restored geometry
- client_move_to_desktop(): moves window between desktops, fires _NET_WM_DESKTOP update
- on_client_message: handles _NET_WM_DESKTOP to move windows from external requests
- deskbar: optional imlib2 app icon rendering (Papirus-Dark → Papirus → hicolor → pixmaps fallback)
- deskbar: XGetClassHint populates cls field for better icon lookup
- deskbar: context menu extended with separator + "→ Desktop 1-4" items via _NET_WM_DESKTOP
- orionnotify/: freedesktop.org notification daemon (libdbus-1), stacks up to 5 popups top-right
- orionlock/: PAM-authenticated fullscreen screen lock with clock, date, password dots
- Lock Screen menu item wired to orionlock
- Root Makefile includes orionnotify and orionlock targets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GHiBQKPfUoaJgCKuA9op1H
2026-08-30 20:14:45 +00:00

184 lines
7.7 KiB
C

#ifndef DESKBAR_H
#define DESKBAR_H
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/*
* OrionDeskbar — modern dark panel, docked top-right.
*
* ┌──────────────────────────┐
* │ [Orion ▾]│ 12:00 PM │ <- top strip: menu + clock
* │ │ Wed Jul 23 │ <- date line
* ├──────────────────────────┤
* │ [F] Firefox ▸ │ <- app entries (letter icon + name)
* │ [T] Thunar ▸ │
* │ [X] [xterm] ▸ │ <- minimized: bracketed + dimmed
* ├──────────────────────────┤
* │ [1] [2] [3] [4] │ <- workspace strip
* ├──────────────────────────┤
* │ [⊙][📶][🔋] │ <- system tray (XEMBED; hidden when empty)
* ├──────────────────────────┤
* │ VOL 50% CPU 12% MEM 45%│ <- status bar
* └──────────────────────────┘
*/
/* ── layout ──────────────────────────────────────────────────────────── */
#define DB_W 200 /* deskbar total width */
#define DB_TOP_H 52 /* top strip height (menu + clock + date) */
#define DB_MENU_W 68 /* width of the Orion menu button */
#define DB_ITEM_H 26 /* app entry row height */
#define DB_ICON_SZ 18 /* app icon square size */
#define DB_WS_H 28 /* workspace strip height */
#define DB_STATUS_H 22 /* status bar height */
#define DB_TRAY_H 26 /* tray section height when icons are present */
#define DB_TRAY_ICON_SZ 20 /* embedded icon window size */
#define DB_TRAY_MAX 16 /* maximum simultaneous tray icons */
#define DB_MAX_APPS 32
/* ── per-app context menu ────────────────────────────────────────────── */
#define DB_CTX_W 160 /* context menu width */
#define DB_CTX_ITEM_H 26 /* item row height */
#define DB_CTX_PAD 4 /* top/bottom padding */
#define DB_CTX_N 3 /* base items: Raise, Minimize, Close */
#define DB_CTX_NDESK 4 /* number of "→ Desktop N" items */
#define DB_CTX_SEP_H 6 /* separator line height */
/* ── fly-out menu ────────────────────────────────────────────────────── */
#define DB_FLYOUT_W 196 /* fly-out menu panel width */
#define DB_FLYOUT_IH 28 /* item row height */
#define DB_FLYOUT_SH 8 /* separator height */
#define DB_FLYOUT_PAD 4 /* top/bottom outer padding */
#define DB_FLYOUT_LPD 13 /* left label padding */
/* ── modern dark palette ──────────────────────────────────────────────── */
#define DB_COL_BG 0x111520 /* dark navy body */
#define DB_COL_MENU_BG 0x0E1A32 /* menu button bg */
#define DB_COL_LOGO_TEXT 0x90BBEE /* "Orion" text */
#define DB_COL_ITEM_BG 0x141828 /* app row bg */
#define DB_COL_ITEM_ALT 0x111520 /* alternate row */
#define DB_COL_ITEM_HOV 0x1E4878 /* hover — blue */
#define DB_COL_ITEM_FOCUS 0x183860 /* focused window row */
#define DB_COL_ITEM_TEXT 0xC0D0E8 /* normal app name */
#define DB_COL_ITEM_HTXT 0xF0F6FF /* text on hover/focus */
#define DB_COL_ITEM_MINI 0x485868 /* dimmed minimized text */
#define DB_COL_DIVIDER 0x1C2030 /* row separator */
#define DB_COL_WS_ACTIVE 0x1E58A8 /* active workspace */
#define DB_COL_WS_INACT 0x202838 /* inactive workspace */
#define DB_COL_WS_TEXT 0x8AB0D0 /* workspace number */
#define DB_COL_CLOCK_TXT 0xD8E8FF /* clock text */
#define DB_COL_DATE_TXT 0x5878A0 /* date text */
#define DB_COL_STATUS_TXT 0x486080 /* status text */
#define DB_COL_BORDER_L 0x223050 /* bevel light */
#define DB_COL_BORDER_D 0x080C14 /* bevel dark */
#define DB_COL_ACCENT 0x1E58A8 /* accent stripe */
/* ── fonts ───────────────────────────────────────────────────────────── */
#define DB_FONT_UI "Sans:size=9"
#define DB_FONT_MENU "Sans:size=10:weight=bold"
#define DB_FONT_CLOCK "Sans:size=11:weight=bold"
#define DB_FONT_DATE "Sans:size=8"
#define DB_FONT_ICON "Sans:size=8:weight=bold"
/* ── app icon color palette (cycled by name hash) ────────────────────── */
static const unsigned long DB_ICON_COLORS[] = {
0x2060A0, /* blue */
0x206040, /* forest green */
0x804020, /* burnt orange */
0x602080, /* purple */
0x208060, /* teal */
0x802040, /* crimson */
0x406020, /* olive */
0x204060, /* dark blue */
};
#define DB_ICON_NCOLORS 8
typedef struct AppEntry {
Window win;
char title[64];
char cls[64]; /* WM_CLASS instance for icon lookup */
int focused;
int minimized;
int desktop; /* which desktop this window is on */
} AppEntry;
typedef struct Deskbar {
Display *dpy;
int screen;
Window root;
Window win;
GC gc;
Colormap cmap;
Visual *visual;
int depth;
XftFont *font_ui;
XftFont *font_menu;
XftFont *font_clock;
XftFont *font_date;
XftFont *font_icon;
int bar_h;
int hovered;
int cur_ws;
int num_ws;
AppEntry apps[DB_MAX_APPS];
int napps;
Atom net_client_list;
Atom net_active_window;
Atom net_current_desktop;
Atom net_number_of_desktops;
Atom net_wm_name;
Atom utf8_string;
/* fly-out menu state */
Window menu_win; /* main fly-out, None when closed */
Window sub_win; /* sub-menu panel, None when closed */
int menu_hov; /* hovered item index in main menu, -1 = none */
int sub_active; /* which sub-menu is open: 0=Apps, 1=Settings, -1=none */
int sub_hov; /* hovered item in sub-menu */
int sw_cache; /* cached screen width for menu positioning */
/* per-app right-click context menu */
Window ctx_win; /* None when closed */
int ctx_app_idx; /* which app row the ctx menu is for */
int ctx_hov; /* hovered item index, -1 = none */
/* system tray (freedesktop.org XEmbed tray protocol) */
Window tray_icons[DB_TRAY_MAX];
int n_tray_icons;
Atom atom_tray_s0; /* _NET_SYSTEM_TRAY_S<screen> */
Atom atom_tray_opcode; /* _NET_SYSTEM_TRAY_OPCODE */
Atom atom_xembed; /* _XEMBED */
Atom atom_manager; /* MANAGER */
} Deskbar;
void db_init(Deskbar *db);
void db_run(Deskbar *db);
void db_draw(Deskbar *db);
void db_update_apps(Deskbar *db);
void db_update_workspace(Deskbar *db);
void db_resize(Deskbar *db);
void db_click(Deskbar *db, int x, int y);
void db_hover(Deskbar *db, int x, int y);
void db_menu_open(Deskbar *db);
void db_menu_close(Deskbar *db);
unsigned long db_color(Deskbar *db, unsigned long rgb);
void db_xft_color(Deskbar *db, unsigned long rgb, XftColor *out);
int db_apps_y(void);
int db_ws_y(Deskbar *db);
#endif