style: remove comments from header files
This commit is contained in:
+2
-13
@@ -10,7 +10,6 @@
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* AI request states */
|
||||
typedef enum {
|
||||
AI_STATE_IDLE,
|
||||
AI_STATE_PENDING,
|
||||
@@ -18,7 +17,6 @@ typedef enum {
|
||||
AI_STATE_ERROR
|
||||
} AIState;
|
||||
|
||||
/* AI request structure */
|
||||
typedef struct AIRequest {
|
||||
char *prompt;
|
||||
char *response;
|
||||
@@ -28,7 +26,6 @@ typedef struct AIRequest {
|
||||
struct AIRequest *next;
|
||||
} AIRequest;
|
||||
|
||||
/* AI context for window analysis */
|
||||
typedef struct {
|
||||
char focused_window[256];
|
||||
char focused_class[64];
|
||||
@@ -36,40 +33,32 @@ typedef struct {
|
||||
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];
|
||||
@@ -81,7 +70,7 @@ typedef struct ExaRequest {
|
||||
char *query;
|
||||
ExaSearchResult results[10];
|
||||
int result_count;
|
||||
int state; /* Uses AIState enum */
|
||||
int state;
|
||||
void (*callback)(struct ExaRequest *req);
|
||||
void *user_data;
|
||||
struct ExaRequest *next;
|
||||
@@ -92,4 +81,4 @@ ExaRequest *exa_search(const char *query, void (*callback)(ExaRequest *));
|
||||
void exa_process_pending(void);
|
||||
void exa_show_app_launcher(void);
|
||||
|
||||
#endif /* DWN_AI_H */
|
||||
#endif
|
||||
|
||||
+8
-16
@@ -9,41 +9,33 @@
|
||||
|
||||
#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 */
|
||||
char name[128];
|
||||
char exec[512];
|
||||
char icon[128];
|
||||
char desktop_id[256];
|
||||
bool terminal;
|
||||
bool 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 */
|
||||
char recent[MAX_RECENT_APPS][256];
|
||||
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 */
|
||||
#endif
|
||||
|
||||
+1
-17
@@ -10,9 +10,7 @@
|
||||
#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;
|
||||
@@ -25,7 +23,6 @@ typedef struct {
|
||||
Atom NET_ACTIVE_WINDOW;
|
||||
Atom NET_WORKAREA;
|
||||
|
||||
/* Client window properties */
|
||||
Atom NET_WM_NAME;
|
||||
Atom NET_WM_VISIBLE_NAME;
|
||||
Atom NET_WM_DESKTOP;
|
||||
@@ -36,7 +33,6 @@ typedef struct {
|
||||
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;
|
||||
@@ -47,7 +43,6 @@ typedef struct {
|
||||
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;
|
||||
@@ -62,7 +57,6 @@ typedef struct {
|
||||
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;
|
||||
@@ -74,14 +68,12 @@ typedef struct {
|
||||
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;
|
||||
@@ -89,7 +81,6 @@ typedef struct {
|
||||
Atom XEMBED_INFO;
|
||||
} EWMHAtoms;
|
||||
|
||||
/* ICCCM (Inter-Client Communication Conventions Manual) atoms */
|
||||
typedef struct {
|
||||
Atom WM_PROTOCOLS;
|
||||
Atom WM_DELETE_WINDOW;
|
||||
@@ -103,7 +94,6 @@ typedef struct {
|
||||
Atom WM_WINDOW_ROLE;
|
||||
} ICCCMAtoms;
|
||||
|
||||
/* Other useful atoms */
|
||||
typedef struct {
|
||||
Atom UTF8_STRING;
|
||||
Atom COMPOUND_TEXT;
|
||||
@@ -113,15 +103,12 @@ typedef struct {
|
||||
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);
|
||||
@@ -129,7 +116,6 @@ 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);
|
||||
@@ -138,12 +124,10 @@ 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 */
|
||||
#endif
|
||||
|
||||
+1
-12
@@ -10,17 +10,14 @@
|
||||
#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);
|
||||
@@ -28,14 +25,12 @@ 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);
|
||||
@@ -43,7 +38,6 @@ 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);
|
||||
@@ -51,31 +45,26 @@ 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 */
|
||||
#endif
|
||||
|
||||
+1
-12
@@ -10,7 +10,6 @@
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Color configuration */
|
||||
typedef struct {
|
||||
unsigned long panel_bg;
|
||||
unsigned long panel_fg;
|
||||
@@ -27,16 +26,13 @@ typedef struct {
|
||||
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;
|
||||
@@ -44,34 +40,28 @@ struct Config {
|
||||
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);
|
||||
@@ -80,9 +70,8 @@ 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 */
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "dwn.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Button types */
|
||||
typedef enum {
|
||||
BUTTON_CLOSE,
|
||||
BUTTON_MAXIMIZE,
|
||||
@@ -18,32 +17,26 @@ typedef enum {
|
||||
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 */
|
||||
#endif
|
||||
|
||||
+19
-43
@@ -16,24 +16,20 @@
|
||||
#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
|
||||
|
||||
/* Common error/status codes */
|
||||
typedef enum {
|
||||
DWN_OK = 0,
|
||||
DWN_ERROR = -1,
|
||||
@@ -44,7 +40,6 @@ typedef enum {
|
||||
DWN_ERROR_IO = -6
|
||||
} DwnStatus;
|
||||
|
||||
/* Layout types */
|
||||
typedef enum {
|
||||
LAYOUT_TILING,
|
||||
LAYOUT_FLOATING,
|
||||
@@ -52,13 +47,11 @@ typedef enum {
|
||||
LAYOUT_COUNT
|
||||
} LayoutType;
|
||||
|
||||
/* Focus modes */
|
||||
typedef enum {
|
||||
FOCUS_CLICK,
|
||||
FOCUS_FOLLOW
|
||||
} FocusMode;
|
||||
|
||||
/* Client state flags */
|
||||
typedef enum {
|
||||
CLIENT_NORMAL = 0,
|
||||
CLIENT_FLOATING = (1 << 0),
|
||||
@@ -68,31 +61,28 @@ typedef enum {
|
||||
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) */
|
||||
Window window;
|
||||
Window frame;
|
||||
int x, y;
|
||||
int width, height;
|
||||
int old_x, old_y;
|
||||
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 */
|
||||
uint32_t flags;
|
||||
unsigned int workspace;
|
||||
char title[256];
|
||||
char class[64];
|
||||
Client *next;
|
||||
Client *prev;
|
||||
};
|
||||
|
||||
/* Monitor structure - represents a physical display */
|
||||
struct Monitor {
|
||||
int x, y;
|
||||
int width, height;
|
||||
@@ -100,17 +90,15 @@ struct Monitor {
|
||||
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 */
|
||||
Client *clients;
|
||||
Client *focused;
|
||||
LayoutType layout;
|
||||
float master_ratio;
|
||||
int master_count;
|
||||
char name[32];
|
||||
};
|
||||
|
||||
/* Panel widget types */
|
||||
typedef enum {
|
||||
WIDGET_WORKSPACES,
|
||||
WIDGET_TASKBAR,
|
||||
@@ -120,7 +108,6 @@ typedef enum {
|
||||
WIDGET_SEPARATOR
|
||||
} WidgetType;
|
||||
|
||||
/* Global state - singleton pattern */
|
||||
typedef struct {
|
||||
Display *display;
|
||||
int screen;
|
||||
@@ -128,36 +115,28 @@ typedef struct {
|
||||
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 */
|
||||
Client *client_list;
|
||||
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 */
|
||||
XftFont *xft_font;
|
||||
Colormap colormap;
|
||||
|
||||
/* Drag state */
|
||||
Client *drag_client;
|
||||
int drag_start_x, drag_start_y;
|
||||
int drag_orig_x, drag_orig_y;
|
||||
@@ -165,16 +144,13 @@ typedef struct {
|
||||
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 */
|
||||
#endif
|
||||
|
||||
+1
-10
@@ -11,16 +11,13 @@
|
||||
#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;
|
||||
@@ -28,26 +25,21 @@ typedef struct {
|
||||
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);
|
||||
@@ -89,11 +81,10 @@ 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 */
|
||||
#endif
|
||||
|
||||
+1
-4
@@ -9,18 +9,15 @@
|
||||
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
+14
-24
@@ -10,18 +10,15 @@
|
||||
#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"
|
||||
|
||||
/* Sentiment classification */
|
||||
typedef enum {
|
||||
SENTIMENT_NEUTRAL = 0,
|
||||
SENTIMENT_POSITIVE,
|
||||
SENTIMENT_NEGATIVE
|
||||
} NewsSentiment;
|
||||
|
||||
/* News article */
|
||||
typedef struct {
|
||||
char title[256];
|
||||
char content[1024];
|
||||
@@ -31,46 +28,39 @@ typedef struct {
|
||||
float sentiment_score;
|
||||
} 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 */
|
||||
int current_article;
|
||||
double scroll_offset;
|
||||
bool fetching;
|
||||
bool has_error;
|
||||
long last_fetch;
|
||||
long last_scroll_update;
|
||||
bool interactive_mode;
|
||||
int display_widths[MAX_NEWS_ARTICLES];
|
||||
int total_width;
|
||||
int render_x;
|
||||
int render_width;
|
||||
bool widths_dirty;
|
||||
} 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 */
|
||||
void news_update(void);
|
||||
|
||||
/* 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 */
|
||||
#endif
|
||||
|
||||
+9
-18
@@ -11,42 +11,36 @@
|
||||
#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 summary[512];
|
||||
char *body;
|
||||
size_t body_len;
|
||||
char icon[256];
|
||||
int timeout; /* -1 = default, 0 = never, >0 = milliseconds */
|
||||
int timeout;
|
||||
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 */
|
||||
long expire_time;
|
||||
Window window;
|
||||
int width;
|
||||
int height;
|
||||
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);
|
||||
@@ -54,21 +48,18 @@ 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 */
|
||||
#endif
|
||||
|
||||
+2
-11
@@ -10,29 +10,25 @@
|
||||
#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 */
|
||||
Pixmap buffer;
|
||||
};
|
||||
|
||||
/* 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);
|
||||
@@ -42,25 +38,20 @@ 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 */
|
||||
#endif
|
||||
|
||||
+10
-28
@@ -10,18 +10,15 @@
|
||||
#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.) */
|
||||
int signal;
|
||||
char security[32];
|
||||
bool connected;
|
||||
} WifiNetwork;
|
||||
|
||||
/* WiFi state */
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
bool connected;
|
||||
@@ -29,24 +26,21 @@ typedef struct {
|
||||
int signal_strength;
|
||||
WifiNetwork networks[MAX_WIFI_NETWORKS];
|
||||
int network_count;
|
||||
long last_scan; /* Timestamp of last scan */
|
||||
long last_scan;
|
||||
} WifiState;
|
||||
|
||||
/* Audio state */
|
||||
typedef struct {
|
||||
int volume; /* 0-100 */
|
||||
int volume;
|
||||
bool muted;
|
||||
} AudioState;
|
||||
|
||||
/* Battery state */
|
||||
typedef struct {
|
||||
bool present; /* Battery exists */
|
||||
bool charging; /* Currently charging */
|
||||
int percentage; /* 0-100 */
|
||||
int time_remaining; /* Minutes remaining */
|
||||
bool present;
|
||||
bool charging;
|
||||
int percentage;
|
||||
int time_remaining;
|
||||
} BatteryState;
|
||||
|
||||
/* Volume slider popup */
|
||||
typedef struct {
|
||||
Window window;
|
||||
int x, y;
|
||||
@@ -55,7 +49,6 @@ typedef struct {
|
||||
bool dragging;
|
||||
} VolumeSlider;
|
||||
|
||||
/* Dropdown menu */
|
||||
typedef struct {
|
||||
Window window;
|
||||
int x, y;
|
||||
@@ -66,35 +59,29 @@ typedef struct {
|
||||
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);
|
||||
@@ -104,7 +91,6 @@ 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);
|
||||
@@ -115,21 +101,17 @@ 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 */
|
||||
int systray_hit_test(int x);
|
||||
|
||||
/* 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 */
|
||||
#endif
|
||||
|
||||
+4
-14
@@ -12,11 +12,9 @@
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Contract assertion macro - use for programmer errors */
|
||||
#define DWN_ASSERT(cond) assert(cond)
|
||||
#define DWN_ASSERT_MSG(cond, msg) assert((cond) && (msg))
|
||||
|
||||
/* Logging levels */
|
||||
typedef enum {
|
||||
LOG_DEBUG,
|
||||
LOG_INFO,
|
||||
@@ -24,51 +22,43 @@ typedef enum {
|
||||
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_flush(void);
|
||||
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 */
|
||||
void secure_wipe(void *ptr, size_t size);
|
||||
|
||||
/* 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 */
|
||||
char *shell_escape(const char *str);
|
||||
|
||||
/* 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 */
|
||||
#endif
|
||||
|
||||
+1
-10
@@ -10,28 +10,23 @@
|
||||
#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);
|
||||
@@ -40,23 +35,19 @@ 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 */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user