/* Shared window-manager ABI: kernel <-> ring-3 WM. * Only plain types and syscall numbers live here; the kernel window state and * all font/pixel decisions stay elsewhere. */ #ifndef WM_ABI_H #define WM_ABI_H #define WM_MAX_WINDOWS 8 /* Shared chrome layout (the WM draws it, the kernel only stores geometry). */ #define WM_BAR_H 30 /* The WM's start button is the NebOS banner at the top left; it opens the * start menu. The bar notice and the right-aligned status area (clock, * sensors, network, power) never draw left of this edge. */ #define WM_BAR_LEFT_END 160 #define WM_TITLE_H 22 #define WM_CLOSE_W 16 /* No visible frame: the title bar and content start at the window origin. */ #define WM_BORDER_W 0 /* Invisible resize band around a normal window: WM_RESIZE_IN px inside the * outer edge and WM_RESIZE_OUT px outside it. Presses in the inside part * are not routed to the window content; the whole band starts a resize. */ #define WM_RESIZE_IN 1 #define WM_RESIZE_OUT 4 /* Corner grab squares reach this far inside the window along both edges, so * the diagonal resize is easier to hit than the thin edge band. */ #define WM_CORNER_IN 12 /* Keep at least this much of the title bar on-screen when a window is dragged * past an edge, so it can always be grabbed and brought back. */ #define WM_DRAG_VISIBLE 48 /* Fixed user virtual addresses for the WM's mappings. The shadow is one * mapping; each window gets a private content slot large enough for a * full-screen RGB565 canvas (1280x1024 minus the chrome is ~2.5 MB). */ #define WM_SHADOW_VA 0x58000000u #define WM_CONTENT_VA_BASE 0x59000000u #define WM_CONTENT_SLOT 0x00400000u /* 4 MB per window */ /* Window content kind. */ #define WM_KIND_NONE 0 #define WM_KIND_GFX 1 /* Settings sections. The control-center popover's pills ask the WM to open * one of these in the Settings app, and the app's sidebar uses the same * order. */ #define WM_SETTINGS_NETWORK 0 #define WM_SETTINGS_POWER 1 #define WM_SETTINGS_DATETIME 2 #define WM_SETTINGS_APPEARANCE 3 #define WM_SETTINGS_WINDOWS 4 #define WM_SETTINGS_ABOUT 5 #define WM_SETTINGS_COUNT 6 /* Persistent window-manager preferences. The Settings app writes this * structure to a small file on /data (or /share before the data volume is * mounted) and pushes it through SYS_WM_PREFS, so a running WM applies the * change immediately and a restarted WM can restore it. */ #define WM_DEFAULT_BG_RGB 0x202030u struct wm_prefs { unsigned int shadow; /* 1 = soft window shadows */ unsigned int snap; /* 1 = snap to screen edges on drop */ unsigned int resist; /* 1 = edge resistance while dragging */ unsigned int bg_rgb; /* desktop colour without a wallpaper */ unsigned int reserved[4]; }; #define WM_PREFS_MAGIC "NBSET1\0\0" #define WM_PREFS_VERSION 1u #define WM_PREFS_DATA "/data/SETTINGS.CFG" #define WM_PREFS_SHARE "/share/settings.cfg" /* The WM writes the requested section here before focusing an already * running Settings window; the app polls it and switches panes. */ #define WM_SETTINGS_REQUEST "/share/settings.req" struct wm_prefs_file { char magic[8]; unsigned int version; struct wm_prefs prefs; }; /* Canvas-window flags (struct win_create.flags). A popover is chromeless, * always on top and anchored by the WM under the top-bar network icon; its * canvas fills the whole window rectangle. */ #define WIN_F_POPOVER 0x1u struct wm_screen_info { unsigned int width; unsigned int height; unsigned int pitch; unsigned int bpp; unsigned int bytes; void *fb; }; struct wm_mouse_info { unsigned int x; unsigned int y; unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */ }; struct wm_status { struct wm_mouse_info mouse; unsigned int full_redraw; unsigned int boot_ready; /* storage is mounted; spawn the first terminal */ unsigned int kexec_busy; unsigned int kexec_progress; unsigned int kexec_total; /* Panel backlight, for the WM's brightness OSD. seq changes on every * key/command adjustment; level is 0 when no PWM was found. */ unsigned int backlight_present; unsigned int backlight_level; unsigned int backlight_seq; /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER); * the WM reloads its copy when this changes. */ unsigned int wallpaper_seq; /* Current preferences and a change counter (SYS_WM_PREFS). */ unsigned int prefs_seq; struct wm_prefs prefs; /* A client asked the WM to open Settings at a section * (SYS_WM_OPEN_SETTINGS); the sequence makes every request visible. */ unsigned int settings_req_seq; unsigned int settings_req_section; }; /* Wallpaper file: one header followed by tightly packed RGB565 pixels, * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and * the WM stretches the stored image to the framebuffer, so no image decoder * is linked into the WM. The installed data volume wins over the RAM copy. */ #define WM_WALLPAPER_MAGIC "NBWAL1\0" #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN" #define WM_WALLPAPER_SHARE "/share/wallpaper" #define WM_WALLPAPER_MAX_W 1440 #define WM_WALLPAPER_MAX_H 810 struct wm_wallpaper_hdr { char magic[8]; unsigned int width; unsigned int height; unsigned int reserved; }; struct wm_window_info { unsigned int used; unsigned int focused; unsigned int pid; unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */ int x, y; unsigned int w, h; /* outer window rectangle */ unsigned int content_w, content_h; unsigned int dirty; unsigned int dirty_seq; unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */ unsigned int content_gen; char title[16]; }; /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that * changed since the last present. w == 0 or h == 0 means the whole canvas, * so a caller that does not track damage keeps the old behaviour. */ struct wm_win_present { unsigned int x, y, w, h; }; struct wm_map_info { void *va; unsigned int kind; unsigned int w, h; unsigned int stride; /* bytes per row for gfx, cells*2 for text */ unsigned int generation; }; struct wm_rect { int x, y; unsigned int w, h; }; struct wm_present_info { unsigned int count; /* 0..4 */ unsigned int immediate; /* 1: flush now (drag); 0: budgeted */ struct wm_rect rect[4]; }; struct wm_geom { int x, y; }; struct wm_size { unsigned int w, h; /* New window origin minus the old one, in screen pixels. The kernel * carries the previous front canvas over anchored by this delta, so a * left/top edge drag keeps the content in place instead of sliding it * or blanking it until the client repaints. */ int dx, dy; }; /* Generic canvas-window client API (gfx commands own their own window). */ struct win_create { unsigned int w, h; unsigned int flags; /* WIN_F_* */ char title[16]; }; struct win_info { void *fb; /* mapped RGB565 back buffer */ unsigned int width, height; unsigned int id; }; /* Pointer input for generic canvas windows. The ring-3 WM queues press and * release edges; the command polls the current position for hover and drags. */ struct win_pointer { int x, y; /* relative to the canvas, may be outside */ unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */ unsigned int inside; /* pointer is over this window's content */ unsigned int focused; }; /* Scroll accumulated for this window since the previous call, in pixels. * Positive dy means later content (wheel down under natural scrolling). */ struct win_scroll { int dx, dy; }; #define WIN_EV_POINTER_DOWN 1 #define WIN_EV_POINTER_UP 2 struct win_event { unsigned int type; /* WIN_EV_POINTER_* */ int x, y; /* content-relative */ unsigned int buttons; /* buttons after the event */ unsigned int button; /* button that changed: bit0 left, bit1 right */ }; #endif