chore: update c, css, d files
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* AI Integration (OpenRouter API)
|
||||
*/
|
||||
|
||||
#ifndef DWN_AI_H
|
||||
#define DWN_AI_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* AI request states */
|
||||
typedef enum {
|
||||
AI_STATE_IDLE,
|
||||
AI_STATE_PENDING,
|
||||
AI_STATE_COMPLETED,
|
||||
AI_STATE_ERROR
|
||||
} AIState;
|
||||
|
||||
/* AI request structure */
|
||||
typedef struct AIRequest {
|
||||
char *prompt;
|
||||
char *response;
|
||||
AIState state;
|
||||
void (*callback)(struct AIRequest *req);
|
||||
void *user_data;
|
||||
struct AIRequest *next;
|
||||
} AIRequest;
|
||||
|
||||
/* AI context for window analysis */
|
||||
typedef struct {
|
||||
char focused_window[256];
|
||||
char focused_class[64];
|
||||
char workspace_windows[1024];
|
||||
int window_count;
|
||||
} AIContext;
|
||||
|
||||
/* Initialization */
|
||||
bool ai_init(void);
|
||||
void ai_cleanup(void);
|
||||
bool ai_is_available(void);
|
||||
|
||||
/* API calls */
|
||||
AIRequest *ai_send_request(const char *prompt, void (*callback)(AIRequest *));
|
||||
void ai_cancel_request(AIRequest *req);
|
||||
void ai_process_pending(void);
|
||||
|
||||
/* Context analysis */
|
||||
void ai_update_context(void);
|
||||
const char *ai_analyze_task(void);
|
||||
const char *ai_suggest_window(void);
|
||||
const char *ai_suggest_app(void);
|
||||
|
||||
/* Command palette */
|
||||
void ai_show_command_palette(void);
|
||||
void ai_execute_command(const char *command);
|
||||
|
||||
/* Smart features */
|
||||
void ai_auto_organize_workspace(void);
|
||||
void ai_suggest_layout(void);
|
||||
void ai_analyze_workflow(void);
|
||||
|
||||
/* Notification intelligence */
|
||||
bool ai_should_show_notification(const char *app, const char *summary);
|
||||
int ai_notification_priority(const char *app, const char *summary);
|
||||
|
||||
/* Performance monitoring */
|
||||
void ai_monitor_performance(void);
|
||||
const char *ai_performance_suggestion(void);
|
||||
|
||||
/* Exa semantic search */
|
||||
typedef struct {
|
||||
char title[256];
|
||||
char url[512];
|
||||
char snippet[1024];
|
||||
float score;
|
||||
} ExaSearchResult;
|
||||
|
||||
typedef struct ExaRequest {
|
||||
char *query;
|
||||
ExaSearchResult results[10];
|
||||
int result_count;
|
||||
int state; /* Uses AIState enum */
|
||||
void (*callback)(struct ExaRequest *req);
|
||||
void *user_data;
|
||||
struct ExaRequest *next;
|
||||
} ExaRequest;
|
||||
|
||||
bool exa_is_available(void);
|
||||
ExaRequest *exa_search(const char *query, void (*callback)(ExaRequest *));
|
||||
void exa_process_pending(void);
|
||||
void exa_show_app_launcher(void);
|
||||
|
||||
#endif /* DWN_AI_H */
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Application launcher with .desktop file support
|
||||
*/
|
||||
|
||||
#ifndef DWN_APPLAUNCHER_H
|
||||
#define DWN_APPLAUNCHER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Maximum applications to track */
|
||||
#define MAX_APPS 512
|
||||
#define MAX_RECENT_APPS 10
|
||||
|
||||
/* Application entry from .desktop file */
|
||||
typedef struct {
|
||||
char name[128]; /* Display name */
|
||||
char exec[512]; /* Command to execute */
|
||||
char icon[128]; /* Icon name (unused for now) */
|
||||
char desktop_id[256]; /* Desktop file basename for tracking */
|
||||
bool terminal; /* Run in terminal */
|
||||
bool hidden; /* Should be hidden */
|
||||
} AppEntry;
|
||||
|
||||
/* Application launcher state */
|
||||
typedef struct {
|
||||
AppEntry apps[MAX_APPS];
|
||||
int app_count;
|
||||
char recent[MAX_RECENT_APPS][256]; /* Desktop IDs of recent apps */
|
||||
int recent_count;
|
||||
} AppLauncherState;
|
||||
|
||||
/* Initialize the app launcher (scans .desktop files) */
|
||||
void applauncher_init(void);
|
||||
|
||||
/* Cleanup resources */
|
||||
void applauncher_cleanup(void);
|
||||
|
||||
/* Rescan .desktop files */
|
||||
void applauncher_refresh(void);
|
||||
|
||||
/* Show the application launcher (dmenu-based) */
|
||||
void applauncher_show(void);
|
||||
|
||||
/* Launch an application by desktop_id */
|
||||
void applauncher_launch(const char *desktop_id);
|
||||
|
||||
#endif /* DWN_APPLAUNCHER_H */
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* X11 Atoms management (EWMH/ICCCM compliance)
|
||||
*/
|
||||
|
||||
#ifndef DWN_ATOMS_H
|
||||
#define DWN_ATOMS_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* EWMH (Extended Window Manager Hints) atoms */
|
||||
typedef struct {
|
||||
/* Root window properties */
|
||||
Atom NET_SUPPORTED;
|
||||
Atom NET_SUPPORTING_WM_CHECK;
|
||||
Atom NET_CLIENT_LIST;
|
||||
Atom NET_CLIENT_LIST_STACKING;
|
||||
Atom NET_NUMBER_OF_DESKTOPS;
|
||||
Atom NET_DESKTOP_GEOMETRY;
|
||||
Atom NET_DESKTOP_VIEWPORT;
|
||||
Atom NET_CURRENT_DESKTOP;
|
||||
Atom NET_DESKTOP_NAMES;
|
||||
Atom NET_ACTIVE_WINDOW;
|
||||
Atom NET_WORKAREA;
|
||||
|
||||
/* Client window properties */
|
||||
Atom NET_WM_NAME;
|
||||
Atom NET_WM_VISIBLE_NAME;
|
||||
Atom NET_WM_DESKTOP;
|
||||
Atom NET_WM_WINDOW_TYPE;
|
||||
Atom NET_WM_STATE;
|
||||
Atom NET_WM_ALLOWED_ACTIONS;
|
||||
Atom NET_WM_STRUT;
|
||||
Atom NET_WM_STRUT_PARTIAL;
|
||||
Atom NET_WM_PID;
|
||||
|
||||
/* Window types */
|
||||
Atom NET_WM_WINDOW_TYPE_DESKTOP;
|
||||
Atom NET_WM_WINDOW_TYPE_DOCK;
|
||||
Atom NET_WM_WINDOW_TYPE_TOOLBAR;
|
||||
Atom NET_WM_WINDOW_TYPE_MENU;
|
||||
Atom NET_WM_WINDOW_TYPE_UTILITY;
|
||||
Atom NET_WM_WINDOW_TYPE_SPLASH;
|
||||
Atom NET_WM_WINDOW_TYPE_DIALOG;
|
||||
Atom NET_WM_WINDOW_TYPE_NORMAL;
|
||||
Atom NET_WM_WINDOW_TYPE_NOTIFICATION;
|
||||
|
||||
/* Window states */
|
||||
Atom NET_WM_STATE_MODAL;
|
||||
Atom NET_WM_STATE_STICKY;
|
||||
Atom NET_WM_STATE_MAXIMIZED_VERT;
|
||||
Atom NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
Atom NET_WM_STATE_SHADED;
|
||||
Atom NET_WM_STATE_SKIP_TASKBAR;
|
||||
Atom NET_WM_STATE_SKIP_PAGER;
|
||||
Atom NET_WM_STATE_HIDDEN;
|
||||
Atom NET_WM_STATE_FULLSCREEN;
|
||||
Atom NET_WM_STATE_ABOVE;
|
||||
Atom NET_WM_STATE_BELOW;
|
||||
Atom NET_WM_STATE_DEMANDS_ATTENTION;
|
||||
Atom NET_WM_STATE_FOCUSED;
|
||||
|
||||
/* Actions */
|
||||
Atom NET_WM_ACTION_MOVE;
|
||||
Atom NET_WM_ACTION_RESIZE;
|
||||
Atom NET_WM_ACTION_MINIMIZE;
|
||||
Atom NET_WM_ACTION_SHADE;
|
||||
Atom NET_WM_ACTION_STICK;
|
||||
Atom NET_WM_ACTION_MAXIMIZE_HORZ;
|
||||
Atom NET_WM_ACTION_MAXIMIZE_VERT;
|
||||
Atom NET_WM_ACTION_FULLSCREEN;
|
||||
Atom NET_WM_ACTION_CHANGE_DESKTOP;
|
||||
Atom NET_WM_ACTION_CLOSE;
|
||||
|
||||
/* Client messages */
|
||||
Atom NET_CLOSE_WINDOW;
|
||||
Atom NET_MOVERESIZE_WINDOW;
|
||||
Atom NET_WM_MOVERESIZE;
|
||||
Atom NET_REQUEST_FRAME_EXTENTS;
|
||||
Atom NET_FRAME_EXTENTS;
|
||||
|
||||
/* System tray */
|
||||
Atom NET_SYSTEM_TRAY_OPCODE;
|
||||
Atom NET_SYSTEM_TRAY_S0;
|
||||
Atom MANAGER;
|
||||
Atom XEMBED;
|
||||
Atom XEMBED_INFO;
|
||||
} EWMHAtoms;
|
||||
|
||||
/* ICCCM (Inter-Client Communication Conventions Manual) atoms */
|
||||
typedef struct {
|
||||
Atom WM_PROTOCOLS;
|
||||
Atom WM_DELETE_WINDOW;
|
||||
Atom WM_TAKE_FOCUS;
|
||||
Atom WM_STATE;
|
||||
Atom WM_CHANGE_STATE;
|
||||
Atom WM_CLASS;
|
||||
Atom WM_NAME;
|
||||
Atom WM_TRANSIENT_FOR;
|
||||
Atom WM_CLIENT_LEADER;
|
||||
Atom WM_WINDOW_ROLE;
|
||||
} ICCCMAtoms;
|
||||
|
||||
/* Other useful atoms */
|
||||
typedef struct {
|
||||
Atom UTF8_STRING;
|
||||
Atom COMPOUND_TEXT;
|
||||
Atom MOTIF_WM_HINTS;
|
||||
Atom CLIPBOARD;
|
||||
Atom PRIMARY;
|
||||
Atom DWN_RESTART;
|
||||
} MiscAtoms;
|
||||
|
||||
/* Global atom containers */
|
||||
extern EWMHAtoms ewmh;
|
||||
extern ICCCMAtoms icccm;
|
||||
extern MiscAtoms misc_atoms;
|
||||
|
||||
/* Initialization */
|
||||
void atoms_init(Display *display);
|
||||
|
||||
/* EWMH root window setup */
|
||||
void atoms_setup_ewmh(void);
|
||||
void atoms_update_client_list(void);
|
||||
void atoms_update_desktop_names(void);
|
||||
void atoms_set_current_desktop(int desktop);
|
||||
void atoms_set_active_window(Window window);
|
||||
void atoms_set_number_of_desktops(int count);
|
||||
|
||||
/* Window property helpers */
|
||||
bool atoms_get_window_type(Window window, Atom *type);
|
||||
bool atoms_get_window_state(Window window, Atom **states, int *count);
|
||||
bool atoms_set_window_state(Window window, Atom *states, int count);
|
||||
bool atoms_get_window_desktop(Window window, int *desktop);
|
||||
bool atoms_set_window_desktop(Window window, int desktop);
|
||||
char *atoms_get_window_name(Window window);
|
||||
bool atoms_get_wm_class(Window window, char *class_name, char *instance_name, size_t len);
|
||||
|
||||
/* Protocol helpers */
|
||||
bool atoms_window_supports_protocol(Window window, Atom protocol);
|
||||
void atoms_send_protocol(Window window, Atom protocol, Time timestamp);
|
||||
|
||||
/* Client message sending */
|
||||
void atoms_send_client_message(Window window, Atom message_type,
|
||||
long data0, long data1, long data2, long data3, long data4);
|
||||
|
||||
#endif /* DWN_ATOMS_H */
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 19
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* Limits the length of circular references can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_CIRCULAR_LIMIT
|
||||
#define CJSON_CIRCULAR_LIMIT 10000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check item type and return its value */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/array that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items.
|
||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
* but should point to a readable and writable address area. */
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
|
||||
/* If the object is not a boolean type this does nothing and returns cJSON_Invalid else it returns the new type*/
|
||||
#define cJSON_SetBoolValue(object, boolValue) ( \
|
||||
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
|
||||
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
|
||||
cJSON_Invalid\
|
||||
)
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Client (window) management
|
||||
*/
|
||||
|
||||
#ifndef DWN_CLIENT_H
|
||||
#define DWN_CLIENT_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Client creation and destruction */
|
||||
Client *client_create(Window window);
|
||||
void client_destroy(Client *client);
|
||||
|
||||
/* Client management */
|
||||
Client *client_manage(Window window);
|
||||
void client_unmanage(Client *client);
|
||||
Client *client_find_by_window(Window window);
|
||||
Client *client_find_by_frame(Window frame);
|
||||
|
||||
/* Client state */
|
||||
void client_focus(Client *client);
|
||||
void client_unfocus(Client *client);
|
||||
void client_raise(Client *client);
|
||||
void client_lower(Client *client);
|
||||
void client_minimize(Client *client);
|
||||
void client_restore(Client *client);
|
||||
|
||||
/* Client geometry */
|
||||
void client_move(Client *client, int x, int y);
|
||||
void client_resize(Client *client, int width, int height);
|
||||
void client_move_resize(Client *client, int x, int y, int width, int height);
|
||||
void client_configure(Client *client);
|
||||
void client_apply_size_hints(Client *client, int *width, int *height);
|
||||
|
||||
/* Client properties */
|
||||
void client_update_title(Client *client);
|
||||
void client_update_class(Client *client);
|
||||
void client_set_fullscreen(Client *client, bool fullscreen);
|
||||
void client_toggle_fullscreen(Client *client);
|
||||
void client_set_floating(Client *client, bool floating);
|
||||
void client_toggle_floating(Client *client);
|
||||
|
||||
/* Window type checking */
|
||||
bool client_is_floating(Client *client);
|
||||
bool client_is_fullscreen(Client *client);
|
||||
bool client_is_minimized(Client *client);
|
||||
bool client_is_dialog(Window window);
|
||||
bool client_is_dock(Window window);
|
||||
bool client_is_desktop(Window window);
|
||||
|
||||
/* Frame management */
|
||||
void client_create_frame(Client *client);
|
||||
void client_destroy_frame(Client *client);
|
||||
void client_reparent_to_frame(Client *client);
|
||||
void client_reparent_from_frame(Client *client);
|
||||
|
||||
/* Visibility */
|
||||
void client_show(Client *client);
|
||||
void client_hide(Client *client);
|
||||
bool client_is_visible(Client *client);
|
||||
|
||||
/* Close handling */
|
||||
void client_close(Client *client);
|
||||
void client_kill(Client *client);
|
||||
|
||||
/* List operations */
|
||||
void client_add_to_list(Client *client);
|
||||
void client_remove_from_list(Client *client);
|
||||
int client_count(void);
|
||||
int client_count_on_workspace(int workspace);
|
||||
|
||||
/* Iteration */
|
||||
Client *client_get_next(Client *client);
|
||||
Client *client_get_prev(Client *client);
|
||||
Client *client_get_first(void);
|
||||
Client *client_get_last(void);
|
||||
|
||||
#endif /* DWN_CLIENT_H */
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Configuration system
|
||||
*/
|
||||
|
||||
#ifndef DWN_CONFIG_H
|
||||
#define DWN_CONFIG_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Color configuration */
|
||||
typedef struct {
|
||||
unsigned long panel_bg;
|
||||
unsigned long panel_fg;
|
||||
unsigned long workspace_active;
|
||||
unsigned long workspace_inactive;
|
||||
unsigned long workspace_urgent;
|
||||
unsigned long title_focused_bg;
|
||||
unsigned long title_focused_fg;
|
||||
unsigned long title_unfocused_bg;
|
||||
unsigned long title_unfocused_fg;
|
||||
unsigned long border_focused;
|
||||
unsigned long border_unfocused;
|
||||
unsigned long notification_bg;
|
||||
unsigned long notification_fg;
|
||||
} ColorScheme;
|
||||
|
||||
/* Configuration structure */
|
||||
struct Config {
|
||||
/* General */
|
||||
char terminal[128];
|
||||
char launcher[128];
|
||||
char file_manager[128];
|
||||
FocusMode focus_mode;
|
||||
bool show_decorations;
|
||||
|
||||
/* Appearance */
|
||||
int border_width;
|
||||
int title_height;
|
||||
int panel_height;
|
||||
int gap;
|
||||
char font_name[128];
|
||||
ColorScheme colors;
|
||||
|
||||
/* Layout */
|
||||
float default_master_ratio;
|
||||
int default_master_count;
|
||||
LayoutType default_layout;
|
||||
|
||||
/* Panels */
|
||||
bool top_panel_enabled;
|
||||
bool bottom_panel_enabled;
|
||||
|
||||
/* AI */
|
||||
char openrouter_api_key[256];
|
||||
char exa_api_key[256];
|
||||
char ai_model[64];
|
||||
bool ai_enabled;
|
||||
|
||||
/* Paths */
|
||||
char config_path[512];
|
||||
char log_path[512];
|
||||
};
|
||||
|
||||
/* Configuration functions */
|
||||
Config *config_create(void);
|
||||
void config_destroy(Config *cfg);
|
||||
bool config_load(Config *cfg, const char *path);
|
||||
bool config_reload(Config *cfg);
|
||||
void config_set_defaults(Config *cfg);
|
||||
|
||||
/* Getters for commonly used values */
|
||||
const char *config_get_terminal(void);
|
||||
const char *config_get_launcher(void);
|
||||
int config_get_border_width(void);
|
||||
int config_get_title_height(void);
|
||||
int config_get_panel_height(void);
|
||||
int config_get_gap(void);
|
||||
const ColorScheme *config_get_colors(void);
|
||||
|
||||
/* INI parsing helpers */
|
||||
typedef void (*ConfigCallback)(const char *section, const char *key,
|
||||
const char *value, void *user_data);
|
||||
bool config_parse_ini(const char *path, ConfigCallback callback, void *user_data);
|
||||
|
||||
#endif /* DWN_CONFIG_H */
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Window decorations (title bars, borders, buttons)
|
||||
*/
|
||||
|
||||
#ifndef DWN_DECORATIONS_H
|
||||
#define DWN_DECORATIONS_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Button types */
|
||||
typedef enum {
|
||||
BUTTON_CLOSE,
|
||||
BUTTON_MAXIMIZE,
|
||||
BUTTON_MINIMIZE,
|
||||
BUTTON_COUNT
|
||||
} ButtonType;
|
||||
|
||||
/* Button areas for hit testing */
|
||||
typedef struct {
|
||||
int x, y;
|
||||
int width, height;
|
||||
} ButtonArea;
|
||||
|
||||
/* Decoration initialization */
|
||||
void decorations_init(void);
|
||||
void decorations_cleanup(void);
|
||||
|
||||
/* Rendering */
|
||||
void decorations_render(Client *client, bool focused);
|
||||
void decorations_render_title_bar(Client *client, bool focused);
|
||||
void decorations_render_buttons(Client *client, bool focused);
|
||||
void decorations_render_border(Client *client, bool focused);
|
||||
|
||||
/* Hit testing */
|
||||
ButtonType decorations_hit_test_button(Client *client, int x, int y);
|
||||
bool decorations_hit_test_title_bar(Client *client, int x, int y);
|
||||
bool decorations_hit_test_resize_area(Client *client, int x, int y, int *direction);
|
||||
|
||||
/* Button actions */
|
||||
void decorations_button_press(Client *client, ButtonType button);
|
||||
|
||||
/* Text rendering */
|
||||
void decorations_draw_text(Window window, GC gc, int x, int y,
|
||||
const char *text, unsigned long color);
|
||||
|
||||
#endif /* DWN_DECORATIONS_H */
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Main header with shared types and global state
|
||||
*/
|
||||
|
||||
#ifndef DWN_H
|
||||
#define DWN_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Version */
|
||||
#define DWN_VERSION "1.0.0"
|
||||
#define DWN_NAME "DWN"
|
||||
|
||||
/* Limits */
|
||||
#define MAX_CLIENTS 256
|
||||
#define MAX_WORKSPACES 9
|
||||
#define MAX_MONITORS 8
|
||||
#define MAX_NOTIFICATIONS 32
|
||||
#define MAX_KEYBINDINGS 64
|
||||
|
||||
/* Default dimensions */
|
||||
#define DEFAULT_BORDER_WIDTH 2
|
||||
#define DEFAULT_TITLE_HEIGHT 24
|
||||
#define DEFAULT_PANEL_HEIGHT 28
|
||||
#define DEFAULT_GAP 4
|
||||
|
||||
/* Layout types */
|
||||
typedef enum {
|
||||
LAYOUT_TILING,
|
||||
LAYOUT_FLOATING,
|
||||
LAYOUT_MONOCLE,
|
||||
LAYOUT_COUNT
|
||||
} LayoutType;
|
||||
|
||||
/* Focus modes */
|
||||
typedef enum {
|
||||
FOCUS_CLICK,
|
||||
FOCUS_FOLLOW
|
||||
} FocusMode;
|
||||
|
||||
/* Client state flags */
|
||||
typedef enum {
|
||||
CLIENT_NORMAL = 0,
|
||||
CLIENT_FLOATING = (1 << 0),
|
||||
CLIENT_FULLSCREEN = (1 << 1),
|
||||
CLIENT_URGENT = (1 << 2),
|
||||
CLIENT_MINIMIZED = (1 << 3),
|
||||
CLIENT_STICKY = (1 << 4)
|
||||
} ClientFlags;
|
||||
|
||||
/* Forward declarations */
|
||||
typedef struct Client Client;
|
||||
typedef struct Workspace Workspace;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct Panel Panel;
|
||||
typedef struct Config Config;
|
||||
|
||||
/* Client structure - represents a managed window */
|
||||
struct Client {
|
||||
Window window; /* Application window */
|
||||
Window frame; /* Frame window (decoration) */
|
||||
int x, y; /* Position */
|
||||
int width, height; /* Size */
|
||||
int old_x, old_y; /* Previous position (for floating restore) */
|
||||
int old_width, old_height;
|
||||
int border_width;
|
||||
uint32_t flags; /* ClientFlags bitmask */
|
||||
unsigned int workspace; /* Current workspace (0-8) */
|
||||
char title[256]; /* Window title */
|
||||
char class[64]; /* Window class */
|
||||
Client *next; /* Linked list */
|
||||
Client *prev;
|
||||
};
|
||||
|
||||
/* Monitor structure - represents a physical display */
|
||||
struct Monitor {
|
||||
int x, y;
|
||||
int width, height;
|
||||
int index;
|
||||
bool primary;
|
||||
};
|
||||
|
||||
/* Workspace structure */
|
||||
struct Workspace {
|
||||
Client *clients; /* Head of client list */
|
||||
Client *focused; /* Currently focused client */
|
||||
LayoutType layout; /* Current layout */
|
||||
float master_ratio; /* Ratio for master area in tiling */
|
||||
int master_count; /* Number of windows in master area */
|
||||
char name[32]; /* Workspace name */
|
||||
};
|
||||
|
||||
/* Panel widget types */
|
||||
typedef enum {
|
||||
WIDGET_WORKSPACES,
|
||||
WIDGET_TASKBAR,
|
||||
WIDGET_CLOCK,
|
||||
WIDGET_SYSTRAY,
|
||||
WIDGET_AI_STATUS,
|
||||
WIDGET_SEPARATOR
|
||||
} WidgetType;
|
||||
|
||||
/* Global state - singleton pattern */
|
||||
typedef struct {
|
||||
Display *display;
|
||||
int screen;
|
||||
Window root;
|
||||
int screen_width;
|
||||
int screen_height;
|
||||
|
||||
/* Monitors */
|
||||
Monitor monitors[MAX_MONITORS];
|
||||
int monitor_count;
|
||||
|
||||
/* Workspaces */
|
||||
Workspace workspaces[MAX_WORKSPACES];
|
||||
int current_workspace;
|
||||
|
||||
/* Clients */
|
||||
Client *client_list; /* All clients */
|
||||
int client_count;
|
||||
|
||||
/* Panels */
|
||||
Panel *top_panel;
|
||||
Panel *bottom_panel;
|
||||
|
||||
/* Configuration */
|
||||
Config *config;
|
||||
|
||||
/* State */
|
||||
bool running;
|
||||
bool ai_enabled;
|
||||
|
||||
/* Graphics contexts */
|
||||
GC gc;
|
||||
XFontStruct *font;
|
||||
XftFont *xft_font; /* Xft font for UTF-8 rendering */
|
||||
Colormap colormap;
|
||||
|
||||
/* Drag state */
|
||||
Client *drag_client;
|
||||
int drag_start_x, drag_start_y;
|
||||
int drag_orig_x, drag_orig_y;
|
||||
int drag_orig_w, drag_orig_h;
|
||||
bool resizing;
|
||||
} DWNState;
|
||||
|
||||
/* Global state accessor */
|
||||
extern DWNState *dwn;
|
||||
|
||||
/* Core functions */
|
||||
int dwn_init(void);
|
||||
void dwn_cleanup(void);
|
||||
void dwn_run(void);
|
||||
void dwn_quit(void);
|
||||
|
||||
/* Event handlers */
|
||||
void dwn_handle_event(XEvent *ev);
|
||||
|
||||
#endif /* DWN_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Keyboard shortcut handling
|
||||
*/
|
||||
|
||||
#ifndef DWN_KEYS_H
|
||||
#define DWN_KEYS_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
/* Modifier masks */
|
||||
#define MOD_ALT Mod1Mask
|
||||
#define MOD_CTRL ControlMask
|
||||
#define MOD_SHIFT ShiftMask
|
||||
#define MOD_SUPER Mod4Mask
|
||||
|
||||
/* Key binding callback type */
|
||||
typedef void (*KeyCallback)(void);
|
||||
|
||||
/* Key binding structure */
|
||||
typedef struct {
|
||||
unsigned int modifiers;
|
||||
KeySym keysym;
|
||||
KeyCallback callback;
|
||||
const char *description;
|
||||
} KeyBinding;
|
||||
|
||||
/* Initialization */
|
||||
void keys_init(void);
|
||||
void keys_cleanup(void);
|
||||
void keys_grab_all(void);
|
||||
void keys_ungrab_all(void);
|
||||
|
||||
/* Key binding registration */
|
||||
void keys_bind(unsigned int modifiers, KeySym keysym,
|
||||
KeyCallback callback, const char *description);
|
||||
void keys_unbind(unsigned int modifiers, KeySym keysym);
|
||||
void keys_clear_all(void);
|
||||
|
||||
/* Key event handling */
|
||||
void keys_handle_press(XKeyEvent *ev);
|
||||
void keys_handle_release(XKeyEvent *ev);
|
||||
|
||||
/* Default key bindings */
|
||||
void keys_setup_defaults(void);
|
||||
|
||||
/* Key binding callbacks */
|
||||
void key_spawn_terminal(void);
|
||||
void key_spawn_launcher(void);
|
||||
void key_spawn_file_manager(void);
|
||||
void key_spawn_browser(void);
|
||||
void key_close_window(void);
|
||||
void key_quit_dwn(void);
|
||||
void key_cycle_layout(void);
|
||||
void key_toggle_floating(void);
|
||||
void key_toggle_fullscreen(void);
|
||||
void key_toggle_maximize(void);
|
||||
void key_focus_next(void);
|
||||
void key_focus_prev(void);
|
||||
void key_workspace_next(void);
|
||||
void key_workspace_prev(void);
|
||||
void key_workspace_1(void);
|
||||
void key_workspace_2(void);
|
||||
void key_workspace_3(void);
|
||||
void key_workspace_4(void);
|
||||
void key_workspace_5(void);
|
||||
void key_workspace_6(void);
|
||||
void key_workspace_7(void);
|
||||
void key_workspace_8(void);
|
||||
void key_workspace_9(void);
|
||||
void key_move_to_workspace_1(void);
|
||||
void key_move_to_workspace_2(void);
|
||||
void key_move_to_workspace_3(void);
|
||||
void key_move_to_workspace_4(void);
|
||||
void key_move_to_workspace_5(void);
|
||||
void key_move_to_workspace_6(void);
|
||||
void key_move_to_workspace_7(void);
|
||||
void key_move_to_workspace_8(void);
|
||||
void key_move_to_workspace_9(void);
|
||||
void key_increase_master(void);
|
||||
void key_decrease_master(void);
|
||||
void key_increase_master_count(void);
|
||||
void key_decrease_master_count(void);
|
||||
void key_toggle_ai(void);
|
||||
void key_ai_command(void);
|
||||
void key_show_shortcuts(void);
|
||||
void key_start_tutorial(void);
|
||||
|
||||
/* Tutorial system */
|
||||
void tutorial_start(void);
|
||||
void tutorial_stop(void);
|
||||
void tutorial_next_step(void);
|
||||
void tutorial_check_key(unsigned int modifiers, KeySym keysym);
|
||||
bool tutorial_is_active(void);
|
||||
|
||||
#endif /* DWN_KEYS_H */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Layout algorithms (tiling, floating, monocle)
|
||||
*/
|
||||
|
||||
#ifndef DWN_LAYOUT_H
|
||||
#define DWN_LAYOUT_H
|
||||
|
||||
#include "dwn.h"
|
||||
|
||||
/* Layout arrangement */
|
||||
void layout_arrange(int workspace);
|
||||
void layout_arrange_tiling(int workspace);
|
||||
void layout_arrange_floating(int workspace);
|
||||
void layout_arrange_monocle(int workspace);
|
||||
|
||||
/* Layout helpers */
|
||||
int layout_get_usable_area(int *x, int *y, int *width, int *height);
|
||||
int layout_count_tiled_clients(int workspace);
|
||||
|
||||
/* Layout names */
|
||||
const char *layout_get_name(LayoutType layout);
|
||||
const char *layout_get_symbol(LayoutType layout);
|
||||
|
||||
#endif /* DWN_LAYOUT_H */
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* News ticker for bottom panel
|
||||
*/
|
||||
|
||||
#ifndef DWN_NEWS_H
|
||||
#define DWN_NEWS_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Maximum articles to cache */
|
||||
#define MAX_NEWS_ARTICLES 50
|
||||
#define NEWS_API_URL "https://news.app.molodetz.nl/api"
|
||||
|
||||
/* News article */
|
||||
typedef struct {
|
||||
char title[256];
|
||||
char content[1024];
|
||||
char link[512];
|
||||
char author[128];
|
||||
} NewsArticle;
|
||||
|
||||
/* News ticker state */
|
||||
typedef struct {
|
||||
NewsArticle articles[MAX_NEWS_ARTICLES];
|
||||
int article_count;
|
||||
int current_article; /* Currently displayed article index */
|
||||
double scroll_offset; /* Sub-pixel offset for smooth scrolling */
|
||||
bool fetching; /* Currently fetching from API */
|
||||
bool has_error; /* Last fetch failed */
|
||||
long last_fetch; /* Timestamp of last fetch */
|
||||
long last_scroll_update; /* Timestamp of last scroll update */
|
||||
bool interactive_mode; /* User is navigating with up/down */
|
||||
int display_widths[MAX_NEWS_ARTICLES]; /* Cached text widths */
|
||||
int total_width; /* Total scrollable width */
|
||||
int render_x; /* X position where news starts rendering */
|
||||
int render_width; /* Width of news render area */
|
||||
bool widths_dirty; /* Need to recalculate widths */
|
||||
} NewsState;
|
||||
|
||||
/* Global state */
|
||||
extern NewsState news_state;
|
||||
|
||||
/* Initialization */
|
||||
void news_init(void);
|
||||
void news_cleanup(void);
|
||||
|
||||
/* Fetching */
|
||||
void news_fetch_async(void);
|
||||
void news_update(void); /* Called from main loop */
|
||||
|
||||
/* Navigation */
|
||||
void news_next_article(void);
|
||||
void news_prev_article(void);
|
||||
void news_open_current(void);
|
||||
|
||||
/* Rendering */
|
||||
void news_render(Panel *panel, int x, int max_width, int *used_width);
|
||||
void news_handle_click(int x, int y);
|
||||
|
||||
/* Thread-safe access */
|
||||
void news_lock(void);
|
||||
void news_unlock(void);
|
||||
|
||||
#endif /* DWN_NEWS_H */
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* D-Bus Notification daemon
|
||||
*/
|
||||
|
||||
#ifndef DWN_NOTIFICATIONS_H
|
||||
#define DWN_NOTIFICATIONS_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
/* Notification urgency levels */
|
||||
typedef enum {
|
||||
NOTIFY_URGENCY_LOW,
|
||||
NOTIFY_URGENCY_NORMAL,
|
||||
NOTIFY_URGENCY_CRITICAL
|
||||
} NotifyUrgency;
|
||||
|
||||
/* Notification structure */
|
||||
typedef struct Notification {
|
||||
uint32_t id;
|
||||
char app_name[64];
|
||||
char summary[512]; /* Larger summary for AI responses */
|
||||
char *body; /* Dynamically allocated - unlimited size */
|
||||
size_t body_len; /* Length of body text */
|
||||
char icon[256];
|
||||
int timeout; /* -1 = default, 0 = never, >0 = milliseconds */
|
||||
NotifyUrgency urgency;
|
||||
long expire_time; /* Timestamp when notification should disappear */
|
||||
Window window; /* X11 window for rendering */
|
||||
int width; /* Dynamic width based on content */
|
||||
int height; /* Dynamic height based on content */
|
||||
struct Notification *next;
|
||||
} Notification;
|
||||
|
||||
/* D-Bus connection */
|
||||
extern DBusConnection *dbus_conn;
|
||||
|
||||
/* Initialization */
|
||||
bool notifications_init(void);
|
||||
void notifications_cleanup(void);
|
||||
|
||||
/* D-Bus handling */
|
||||
void notifications_process_messages(void);
|
||||
bool notifications_register_service(void);
|
||||
|
||||
/* Notification management */
|
||||
uint32_t notification_show(const char *app_name, const char *summary,
|
||||
const char *body, const char *icon, int timeout);
|
||||
void notification_close(uint32_t id);
|
||||
void notification_close_all(void);
|
||||
Notification *notification_find(uint32_t id);
|
||||
Notification *notification_find_by_window(Window window);
|
||||
|
||||
/* Rendering */
|
||||
void notification_render(Notification *notif);
|
||||
void notifications_render_all(void);
|
||||
void notifications_update(void);
|
||||
void notifications_position(void);
|
||||
void notifications_raise_all(void);
|
||||
|
||||
/* D-Bus method handlers */
|
||||
DBusHandlerResult notifications_handle_message(DBusConnection *conn,
|
||||
DBusMessage *msg,
|
||||
void *user_data);
|
||||
|
||||
/* Server info */
|
||||
void notifications_get_server_info(const char **name, const char **vendor,
|
||||
const char **version, const char **spec_version);
|
||||
void notifications_get_capabilities(const char ***caps, int *count);
|
||||
|
||||
#endif /* DWN_NOTIFICATIONS_H */
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Panel system (top and bottom panels with widgets)
|
||||
*/
|
||||
|
||||
#ifndef DWN_PANEL_H
|
||||
#define DWN_PANEL_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Panel position */
|
||||
typedef enum {
|
||||
PANEL_TOP,
|
||||
PANEL_BOTTOM
|
||||
} PanelPosition;
|
||||
|
||||
/* Panel structure */
|
||||
struct Panel {
|
||||
Window window;
|
||||
PanelPosition position;
|
||||
int x, y;
|
||||
int width, height;
|
||||
bool visible;
|
||||
Pixmap buffer; /* Double buffering */
|
||||
};
|
||||
|
||||
/* Panel initialization */
|
||||
Panel *panel_create(PanelPosition position);
|
||||
void panel_destroy(Panel *panel);
|
||||
void panels_init(void);
|
||||
void panels_cleanup(void);
|
||||
|
||||
/* Panel rendering */
|
||||
void panel_render(Panel *panel);
|
||||
void panel_render_all(void);
|
||||
void panel_render_workspaces(Panel *panel, int x, int *width);
|
||||
void panel_render_taskbar(Panel *panel, int x, int *width);
|
||||
void panel_render_clock(Panel *panel, int x, int *width);
|
||||
void panel_render_systray(Panel *panel, int x, int *width);
|
||||
void panel_render_layout_indicator(Panel *panel, int x, int *width);
|
||||
void panel_render_ai_status(Panel *panel, int x, int *width);
|
||||
|
||||
/* Panel interaction */
|
||||
void panel_handle_click(Panel *panel, int x, int y, int button);
|
||||
int panel_hit_test_workspace(Panel *panel, int x, int y);
|
||||
Client *panel_hit_test_taskbar(Panel *panel, int x, int y);
|
||||
|
||||
/* Panel visibility */
|
||||
void panel_show(Panel *panel);
|
||||
void panel_hide(Panel *panel);
|
||||
void panel_toggle(Panel *panel);
|
||||
|
||||
/* Clock updates */
|
||||
void panel_update_clock(void);
|
||||
|
||||
/* System stats updates */
|
||||
void panel_update_system_stats(void);
|
||||
|
||||
/* System tray */
|
||||
void panel_init_systray(void);
|
||||
void panel_add_systray_icon(Window icon);
|
||||
void panel_remove_systray_icon(Window icon);
|
||||
|
||||
#endif /* DWN_PANEL_H */
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* System tray widgets (WiFi, Audio, etc.)
|
||||
*/
|
||||
|
||||
#ifndef DWN_SYSTRAY_H
|
||||
#define DWN_SYSTRAY_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Maximum number of WiFi networks to show */
|
||||
#define MAX_WIFI_NETWORKS 20
|
||||
|
||||
/* WiFi network info */
|
||||
typedef struct {
|
||||
char ssid[64];
|
||||
int signal; /* Signal strength 0-100 */
|
||||
char security[32]; /* Security type (WPA2, etc.) */
|
||||
bool connected;
|
||||
} WifiNetwork;
|
||||
|
||||
/* WiFi state */
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
bool connected;
|
||||
char current_ssid[64];
|
||||
int signal_strength;
|
||||
WifiNetwork networks[MAX_WIFI_NETWORKS];
|
||||
int network_count;
|
||||
long last_scan; /* Timestamp of last scan */
|
||||
} WifiState;
|
||||
|
||||
/* Audio state */
|
||||
typedef struct {
|
||||
int volume; /* 0-100 */
|
||||
bool muted;
|
||||
} AudioState;
|
||||
|
||||
/* Battery state */
|
||||
typedef struct {
|
||||
bool present; /* Battery exists */
|
||||
bool charging; /* Currently charging */
|
||||
int percentage; /* 0-100 */
|
||||
int time_remaining; /* Minutes remaining */
|
||||
} BatteryState;
|
||||
|
||||
/* Volume slider popup */
|
||||
typedef struct {
|
||||
Window window;
|
||||
int x, y;
|
||||
int width, height;
|
||||
bool visible;
|
||||
bool dragging;
|
||||
} VolumeSlider;
|
||||
|
||||
/* Dropdown menu */
|
||||
typedef struct {
|
||||
Window window;
|
||||
int x, y;
|
||||
int width, height;
|
||||
int item_count;
|
||||
int hovered_item;
|
||||
bool visible;
|
||||
void (*on_select)(int index);
|
||||
} DropdownMenu;
|
||||
|
||||
/* System tray state */
|
||||
extern WifiState wifi_state;
|
||||
extern AudioState audio_state;
|
||||
extern BatteryState battery_state;
|
||||
extern DropdownMenu *wifi_menu;
|
||||
extern VolumeSlider *volume_slider;
|
||||
|
||||
/* Initialization */
|
||||
void systray_init(void);
|
||||
void systray_cleanup(void);
|
||||
|
||||
/* WiFi functions */
|
||||
void wifi_update_state(void);
|
||||
void wifi_scan_networks(void);
|
||||
void wifi_connect(const char *ssid);
|
||||
void wifi_disconnect(void);
|
||||
const char *wifi_get_icon(void);
|
||||
|
||||
/* Audio functions */
|
||||
void audio_update_state(void);
|
||||
void audio_set_volume(int volume);
|
||||
void audio_toggle_mute(void);
|
||||
const char *audio_get_icon(void);
|
||||
|
||||
/* Battery functions */
|
||||
void battery_update_state(void);
|
||||
const char *battery_get_icon(void);
|
||||
|
||||
/* Volume slider functions */
|
||||
VolumeSlider *volume_slider_create(int x, int y);
|
||||
void volume_slider_destroy(VolumeSlider *slider);
|
||||
void volume_slider_show(VolumeSlider *slider);
|
||||
void volume_slider_hide(VolumeSlider *slider);
|
||||
void volume_slider_render(VolumeSlider *slider);
|
||||
void volume_slider_handle_click(VolumeSlider *slider, int x, int y);
|
||||
void volume_slider_handle_motion(VolumeSlider *slider, int x, int y);
|
||||
void volume_slider_handle_release(VolumeSlider *slider);
|
||||
|
||||
/* Dropdown menu functions */
|
||||
DropdownMenu *dropdown_create(int x, int y, int width);
|
||||
void dropdown_destroy(DropdownMenu *menu);
|
||||
void dropdown_show(DropdownMenu *menu);
|
||||
void dropdown_hide(DropdownMenu *menu);
|
||||
void dropdown_add_item(DropdownMenu *menu, const char *label);
|
||||
void dropdown_render(DropdownMenu *menu);
|
||||
int dropdown_hit_test(DropdownMenu *menu, int x, int y);
|
||||
void dropdown_handle_click(DropdownMenu *menu, int x, int y);
|
||||
void dropdown_handle_motion(DropdownMenu *menu, int x, int y);
|
||||
|
||||
/* Panel rendering for systray */
|
||||
void systray_render(Panel *panel, int x, int *width);
|
||||
int systray_get_width(void);
|
||||
void systray_handle_click(int x, int y, int button);
|
||||
int systray_hit_test(int x); /* Returns: 0=wifi, 1=audio, -1=none */
|
||||
|
||||
/* Periodic update */
|
||||
void systray_update(void);
|
||||
|
||||
/* Thread-safe state access */
|
||||
void systray_lock(void);
|
||||
void systray_unlock(void);
|
||||
|
||||
/* Thread-safe state snapshots (copies state under lock) */
|
||||
BatteryState systray_get_battery_snapshot(void);
|
||||
AudioState systray_get_audio_snapshot(void);
|
||||
|
||||
#endif /* DWN_SYSTRAY_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Utility functions
|
||||
*/
|
||||
|
||||
#ifndef DWN_UTIL_H
|
||||
#define DWN_UTIL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Logging levels */
|
||||
typedef enum {
|
||||
LOG_DEBUG,
|
||||
LOG_INFO,
|
||||
LOG_WARN,
|
||||
LOG_ERROR
|
||||
} LogLevel;
|
||||
|
||||
/* Async Logging - non-blocking with max file size (5MB) and rotation */
|
||||
void log_init(const char *log_file);
|
||||
void log_close(void);
|
||||
void log_set_level(LogLevel level);
|
||||
void log_flush(void); /* Force flush pending logs (call before exit/crash) */
|
||||
void log_msg(LogLevel level, const char *fmt, ...);
|
||||
|
||||
/* Convenience macros */
|
||||
#define LOG_DEBUG(...) log_msg(LOG_DEBUG, __VA_ARGS__)
|
||||
#define LOG_INFO(...) log_msg(LOG_INFO, __VA_ARGS__)
|
||||
#define LOG_WARN(...) log_msg(LOG_WARN, __VA_ARGS__)
|
||||
#define LOG_ERROR(...) log_msg(LOG_ERROR, __VA_ARGS__)
|
||||
|
||||
/* Memory allocation with error checking */
|
||||
void *dwn_malloc(size_t size);
|
||||
void *dwn_calloc(size_t nmemb, size_t size);
|
||||
void *dwn_realloc(void *ptr, size_t size);
|
||||
char *dwn_strdup(const char *s);
|
||||
void dwn_free(void *ptr);
|
||||
void secure_wipe(void *ptr, size_t size); /* Securely wipe sensitive data */
|
||||
|
||||
/* String utilities */
|
||||
char *str_trim(char *str);
|
||||
bool str_starts_with(const char *str, const char *prefix);
|
||||
bool str_ends_with(const char *str, const char *suffix);
|
||||
int str_split(char *str, char delim, char **parts, int max_parts);
|
||||
char *shell_escape(const char *str); /* Escape string for safe shell use */
|
||||
|
||||
/* File utilities */
|
||||
bool file_exists(const char *path);
|
||||
char *file_read_all(const char *path);
|
||||
bool file_write_all(const char *path, const char *content);
|
||||
char *expand_path(const char *path);
|
||||
|
||||
/* Color utilities */
|
||||
unsigned long parse_color(const char *color_str);
|
||||
void color_to_rgb(unsigned long color, int *r, int *g, int *b);
|
||||
|
||||
/* Time utilities */
|
||||
long get_time_ms(void);
|
||||
void sleep_ms(int ms);
|
||||
|
||||
/* Process utilities */
|
||||
int spawn(const char *cmd);
|
||||
int spawn_async(const char *cmd);
|
||||
char *spawn_capture(const char *cmd);
|
||||
|
||||
#endif /* DWN_UTIL_H */
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* DWN - Desktop Window Manager
|
||||
* Workspace (tag/virtual desktop) management
|
||||
*/
|
||||
|
||||
#ifndef DWN_WORKSPACE_H
|
||||
#define DWN_WORKSPACE_H
|
||||
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Workspace initialization */
|
||||
void workspace_init(void);
|
||||
void workspace_cleanup(void);
|
||||
|
||||
/* Workspace access */
|
||||
Workspace *workspace_get(int index);
|
||||
Workspace *workspace_get_current(void);
|
||||
int workspace_get_current_index(void);
|
||||
|
||||
/* Workspace switching */
|
||||
void workspace_switch(int index);
|
||||
void workspace_switch_next(void);
|
||||
void workspace_switch_prev(void);
|
||||
|
||||
/* Client management within workspaces */
|
||||
void workspace_add_client(int workspace, Client *client);
|
||||
void workspace_remove_client(int workspace, Client *client);
|
||||
void workspace_move_client(Client *client, int new_workspace);
|
||||
Client *workspace_get_first_client(int workspace);
|
||||
Client *workspace_get_focused_client(int workspace);
|
||||
|
||||
/* Layout */
|
||||
void workspace_set_layout(int workspace, LayoutType layout);
|
||||
LayoutType workspace_get_layout(int workspace);
|
||||
void workspace_cycle_layout(int workspace);
|
||||
void workspace_set_master_ratio(int workspace, float ratio);
|
||||
void workspace_adjust_master_ratio(int workspace, float delta);
|
||||
void workspace_set_master_count(int workspace, int count);
|
||||
void workspace_adjust_master_count(int workspace, int delta);
|
||||
|
||||
/* Arrangement */
|
||||
void workspace_arrange(int workspace);
|
||||
void workspace_arrange_current(void);
|
||||
|
||||
/* Visibility */
|
||||
void workspace_show(int workspace);
|
||||
void workspace_hide(int workspace);
|
||||
|
||||
/* Properties */
|
||||
void workspace_set_name(int workspace, const char *name);
|
||||
const char *workspace_get_name(int workspace);
|
||||
int workspace_client_count(int workspace);
|
||||
bool workspace_is_empty(int workspace);
|
||||
|
||||
/* Focus cycling within workspace */
|
||||
void workspace_focus_next(void);
|
||||
void workspace_focus_prev(void);
|
||||
void workspace_focus_master(void);
|
||||
|
||||
#endif /* DWN_WORKSPACE_H */
|
||||
Reference in New Issue
Block a user