diff --git a/bin/dwn b/bin/dwn index ebd8535..97d84c3 100755 Binary files a/bin/dwn and b/bin/dwn differ diff --git a/build/ai.o b/build/ai.o index 134230b..9b24d1f 100644 Binary files a/build/ai.o and b/build/ai.o differ diff --git a/build/autostart.o b/build/autostart.o index a6d6a22..2e7f715 100644 Binary files a/build/autostart.o and b/build/autostart.o differ diff --git a/build/client.o b/build/client.o index da60ae1..990bdb1 100644 Binary files a/build/client.o and b/build/client.o differ diff --git a/build/config.o b/build/config.o index 9ff40ca..2667080 100644 Binary files a/build/config.o and b/build/config.o differ diff --git a/build/decorations.o b/build/decorations.o index 64427d8..faaa59c 100644 Binary files a/build/decorations.o and b/build/decorations.o differ diff --git a/build/demo.o b/build/demo.o index c6d4db1..cbfb163 100644 Binary files a/build/demo.o and b/build/demo.o differ diff --git a/build/keys.o b/build/keys.o index 3048b88..446ea3a 100644 Binary files a/build/keys.o and b/build/keys.o differ diff --git a/build/layout.o b/build/layout.o index 3e600f9..0c5f26e 100644 Binary files a/build/layout.o and b/build/layout.o differ diff --git a/build/main.d b/build/main.d index aa82306..0bb59fa 100644 --- a/build/main.d +++ b/build/main.d @@ -21,7 +21,7 @@ build/main.o: src/main.c include/dwn.h include/config.h include/dwn.h \ /usr/include/dbus-1.0/dbus/dbus-threads.h include/systray.h \ include/news.h include/applauncher.h include/ai.h include/autostart.h \ include/services.h include/api.h include/demo.h include/screenshot.h \ - include/ocr.h include/util.h + include/ocr.h include/sysmon.h include/util.h include/dwn.h: include/config.h: include/dwn.h: @@ -61,4 +61,5 @@ include/api.h: include/demo.h: include/screenshot.h: include/ocr.h: +include/sysmon.h: include/util.h: diff --git a/build/main.o b/build/main.o index 3f05ec5..c416aa6 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/build/news.o b/build/news.o index 67cf19d..f88d348 100644 Binary files a/build/news.o and b/build/news.o differ diff --git a/build/notifications.o b/build/notifications.o index 59a15ce..b779828 100644 Binary files a/build/notifications.o and b/build/notifications.o differ diff --git a/build/panel.o b/build/panel.o index 397e2df..e4b69d2 100644 Binary files a/build/panel.o and b/build/panel.o differ diff --git a/build/systray.o b/build/systray.o index 24c3fa7..00565a3 100644 Binary files a/build/systray.o and b/build/systray.o differ diff --git a/build/util.o b/build/util.o index 040b5ea..258492c 100644 Binary files a/build/util.o and b/build/util.o differ diff --git a/build/workspace.o b/build/workspace.o index f30e2c6..f80314e 100644 Binary files a/build/workspace.o and b/build/workspace.o differ diff --git a/include/dwn.h b/include/dwn.h index a59f9d2..8013273 100644 --- a/include/dwn.h +++ b/include/dwn.h @@ -107,6 +107,7 @@ typedef struct Workspace Workspace; typedef struct Monitor Monitor; typedef struct Panel Panel; typedef struct Config Config; +typedef struct SystemMonitor SystemMonitor; struct Client { Window window; @@ -176,6 +177,8 @@ typedef struct { Panel *top_panel; Panel *bottom_panel; + SystemMonitor *sysmon; + Config *config; bool running; diff --git a/src/main.c b/src/main.c index 00e64a5..7ba6536 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "demo.h" #include "screenshot.h" #include "ocr.h" +#include "sysmon.h" #include "util.h" #include @@ -343,7 +344,12 @@ static void handle_map_request(XMapRequestEvent *ev) return; } - client_manage(ev->window); + SystemMonitor *sysmon = sysmon_find_by_window(ev->window); + Client *client = client_manage(ev->window); + + if (sysmon != NULL && client != NULL) { + sysmon_set_client(sysmon, client); + } } static void handle_unmap_notify(XUnmapEvent *ev) @@ -458,6 +464,10 @@ static void handle_expose(XExposeEvent *ev) return; } + if (dwn->sysmon != NULL) { + sysmon_render(dwn->sysmon); + } + if (dwn->top_panel != NULL && ev->window == dwn->top_panel->window) { panel_render(dwn->top_panel); return; @@ -529,6 +539,10 @@ static void handle_button_press(XButtonEvent *ev) return; } + if (dwn->sysmon != NULL) { + sysmon_handle_event(dwn->sysmon, (XEvent *)ev); + } + if (volume_slider != NULL && volume_slider->visible) { if (ev->window == volume_slider->window) { volume_slider_handle_click(volume_slider, ev->x, ev->y); @@ -565,6 +579,11 @@ static void handle_button_press(XButtonEvent *ev) } if (is_client_window) { + SystemMonitor *sysmon = sysmon_find_by_window(ev->window); + if (sysmon != NULL) { + sysmon_handle_event(sysmon, (XEvent *)ev); + return; + } XAllowEvents(dwn->display, ReplayPointer, ev->time); client_focus(c, true); return; @@ -648,6 +667,12 @@ static void handle_motion_notify(XMotionEvent *ev) return; } + SystemMonitor *sysmon = sysmon_find_by_window(ev->window); + if (sysmon != NULL) { + sysmon_handle_event(sysmon, (XEvent *)ev); + return; + } + if (volume_slider != NULL && volume_slider->visible && ev->window == volume_slider->window) { volume_slider_handle_motion(volume_slider, ev->x, ev->y); return; @@ -920,6 +945,8 @@ int dwn_init(void) panels_init(); + dwn->sysmon = sysmon_create(); + systray_init(); xembed_init(); @@ -992,6 +1019,12 @@ void dwn_cleanup(void) keys_cleanup(); xembed_cleanup(); systray_cleanup(); + + if (dwn->sysmon != NULL) { + sysmon_destroy(dwn->sysmon); + dwn->sysmon = NULL; + } + panels_cleanup(); decorations_cleanup(); workspace_cleanup(); @@ -1112,6 +1145,11 @@ void dwn_run(void) panel_update_clock(); panel_update_system_stats(); systray_update(); + + if (dwn->sysmon != NULL) { + sysmon_update(dwn->sysmon); + } + last_clock_update = now; } diff --git a/src/panel.c b/src/panel.c index 2d24213..069c6d4 100644 --- a/src/panel.c +++ b/src/panel.c @@ -717,6 +717,36 @@ void panel_handle_click(Panel *panel, int x, int y, int button) return; } } else if (panel->position == PANEL_BOTTOM) { + int clock_width = panel_text_width(clock_buffer, strlen(clock_buffer)); + int stats_width = panel_calculate_stats_width(); + int stats_x = panel->width - clock_width - stats_width - PANEL_PADDING - WIDGET_SPACING; + int stats_end_x = stats_x + stats_width; + + if (x >= stats_x && x <= stats_end_x && button == 1) { + extern SystemMonitor *sysmon_get_instance(void); + SystemMonitor *mon = sysmon_get_instance(); + if (mon != NULL) { + extern void sysmon_toggle(SystemMonitor *mon); + sysmon_toggle(mon); + } + return; + } + + int date_width = panel_text_width(date_buffer, strlen(date_buffer)); + int top_proc_x = PANEL_PADDING + date_width + WIDGET_SPACING; + int top_proc_width = TOP_PROCESS_WIDGET_WIDTH; + int top_proc_end_x = top_proc_x + top_proc_width; + + if (x >= top_proc_x && x <= top_proc_end_x && button == 1) { + extern SystemMonitor *sysmon_get_instance(void); + SystemMonitor *mon = sysmon_get_instance(); + if (mon != NULL) { + extern void sysmon_toggle(SystemMonitor *mon); + sysmon_toggle(mon); + } + return; + } + if (button == 1) { news_handle_click(x, y); }