135 lines
3.5 KiB
C
135 lines
3.5 KiB
C
|
|
/*
|
||
|
|
* 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 */
|