commit a4adaa6
0uppy
·
2026-08-01 23:57:06 +0000 UTC
parent ed03989
slgro - removed decors, added double borders instead (off by default doe !!)
5 files changed,
+30,
-144
+1,
-1
1@@ -1,5 +1,5 @@
2 project('slgro', 'c',
3- version: '1.3',
4+ version: '1.4',
5 default_options: ['c_std=c99', 'warning_level=2'],
6 )
7
+6,
-13
1@@ -1,18 +1,11 @@
2-border_active = 0xffffffff
3-border_normal = 0xffffffff
4+border_active = 0xff000000
5+border_normal = 0xff000000
6 border_width = 2
7
8-decor_color = 0xff2a2a2a
9-decor_top = 24
10-decor_left = 2
11-decor_right = 2
12-decor_bottom = 2
13-decor_title_enabled = true -- turn this off if you dont want decors!!
14-decor_title_edge = "top"
15-decor_title_align = "center"
16-decor_title_color = 0xff8aaa8a
17-decor_title_padding = 8
18-decor_title_font = "monospace:size=12" -- idk what to set as a default font here so uhhh imma slap monospace here idk lol
19+-- for those who may want double borders, uncomment these !!
20+--border_active_outer = 0xffffffff
21+--border_normal_outer = 0xffffffff
22+--border_width_outher = 2
23
24 motion_throttle_hz = 85
25
+9,
-6
1@@ -48,12 +48,15 @@ struct client {
2 };
3
4 struct config {
5- bool decor_enabled;
6- struct swc_decor decor;
7- uint32_t motion_throttle_hz;
8- uint32_t border_col_active;
9- uint32_t border_col_normal;
10- uint32_t border_width;
11+ uint32_t motion_throttle_hz;
12+
13+ uint32_t border_col_active;
14+ uint32_t border_col_normal;
15+ uint32_t border_width;
16+
17+ uint32_t border_col_active_outer;
18+ uint32_t border_col_normal_outer;
19+ uint32_t border_width_outer;
20 };
21
22 struct screen {
+12,
-64
1@@ -8,7 +8,6 @@
2
3 #include "include/types.h"
4 #include "include/slgro.h"
5-#include "include/util.h"
6
7 struct config cfg;
8 struct bind *binds = NULL;
9@@ -83,22 +82,14 @@ void load_config(void)
10 snprintf(path, sizeof(path), "%s/.config/slgro/config.lua", home ? home : ".");
11
12 cfg.motion_throttle_hz = 85;
13+
14 cfg.border_col_active = 0xffffffff;
15 cfg.border_col_normal = 0xffffffff;
16 cfg.border_width = 2;
17
18- /* defaults for le slgro v1.3 titlebar update, leaving this here currently for testing */
19- cfg.decor.color = 0xff444444;
20- cfg.decor.top = 2;
21- cfg.decor.right = 2;
22- cfg.decor.bottom = 2;
23- cfg.decor.left = 24;
24- cfg.decor.title.enabled = false;
25- cfg.decor.title.edge = SWC_DECOR_EDGE_LEFT;
26- cfg.decor.title.align = SWC_DECOR_ALIGN_START;
27- cfg.decor.title.color = 0xffffffff;
28- cfg.decor.title.padding = 8;
29- cfg.decor.title.font = "monospace:size=12";
30+ cfg.border_col_active_outer = 0;
31+ cfg.border_col_normal_outer = 0;
32+ cfg.border_width_outer = 0;
33
34 lua_State *L = luaL_newstate();
35 luaL_openlibs(L);
36@@ -124,63 +115,20 @@ void load_config(void)
37 if (lua_isnumber(L, -1)) cfg.border_width = (uint32_t)lua_tonumber(L, -1);
38 lua_pop(L, 1);
39
40- lua_getglobal(L, "motion_throttle_hz");
41- if (lua_isnumber(L, -1)) cfg.motion_throttle_hz = (uint32_t)lua_tonumber(L, -1);
42- lua_pop(L, 1);
43-
44- lua_getglobal(L, "decor_color");
45- if (lua_isnumber(L, -1)) cfg.decor.color = (uint32_t)lua_tonumber(L, -1);
46- lua_pop(L, 1);
47-
48- lua_getglobal(L, "decor_top");
49- if (lua_isnumber(L, -1)) cfg.decor.top = (uint32_t)lua_tonumber(L, -1);
50- lua_pop(L, 1);
51-
52- lua_getglobal(L, "decor_right");
53- if (lua_isnumber(L, -1)) cfg.decor.right = (uint32_t)lua_tonumber(L, -1);
54+ lua_getglobal(L, "border_active_outer");
55+ if (lua_isnumber(L, -1)) cfg.border_col_active_outer = (uint32_t)lua_tonumber(L, -1);
56 lua_pop(L, 1);
57
58- lua_getglobal(L, "decor_bottom");
59- if (lua_isnumber(L, -1)) cfg.decor.bottom = (uint32_t)lua_tonumber(L, -1);
60+ lua_getglobal(L, "border_normal_outer");
61+ if (lua_isnumber(L, -1)) cfg.border_col_normal_outer = (uint32_t)lua_tonumber(L, -1);
62 lua_pop(L, 1);
63
64- lua_getglobal(L, "decor_left");
65- if (lua_isnumber(L, -1)) cfg.decor.left = (uint32_t)lua_tonumber(L, -1);
66+ lua_getglobal(L, "border_width_outer");
67+ if (lua_isnumber(L, -1)) cfg.border_width_outer = (uint32_t)lua_tonumber(L, -1);
68 lua_pop(L, 1);
69
70- lua_getglobal(L, "decor_title_enabled");
71- cfg.decor.title.enabled = lua_toboolean(L, -1);
72- lua_pop(L, 1);
73-
74- lua_getglobal(L, "decor_title_color");
75- if (lua_isnumber(L, -1)) cfg.decor.title.color = (uint32_t)lua_tonumber(L, -1);
76- lua_pop(L, 1);
77-
78- lua_getglobal(L, "decor_title_padding");
79- if (lua_isnumber(L, -1)) cfg.decor.title.padding = (uint32_t)lua_tonumber(L, -1);
80- lua_pop(L, 1);
81-
82- lua_getglobal(L, "decor_title_font");
83- if (lua_isstring(L, -1)) cfg.decor.title.font = strdup(lua_tostring(L, -1));
84- lua_pop(L, 1);
85-
86- lua_getglobal(L, "decor_title_edge");
87- if (lua_isstring(L, -1)) {
88- const char *e = lua_tostring(L, -1);
89- if (!strcmp(e, "top")) cfg.decor.title.edge = SWC_DECOR_EDGE_TOP;
90- else if (!strcmp(e, "right")) cfg.decor.title.edge = SWC_DECOR_EDGE_RIGHT;
91- else if (!strcmp(e, "bottom")) cfg.decor.title.edge = SWC_DECOR_EDGE_BOTTOM;
92- else cfg.decor.title.edge = SWC_DECOR_EDGE_LEFT;
93- }
94- lua_pop(L, 1);
95-
96- lua_getglobal(L, "decor_title_align");
97- if (lua_isstring(L, -1)) {
98- const char *a = lua_tostring(L, -1);
99- if (!strcmp(a, "center")) cfg.decor.title.align = SWC_DECOR_ALIGN_CENTER;
100- else if (!strcmp(a, "end")) cfg.decor.title.align = SWC_DECOR_ALIGN_END;
101- else cfg.decor.title.align = SWC_DECOR_ALIGN_START;
102- }
103+ lua_getglobal(L, "motion_throttle_hz");
104+ if (lua_isnumber(L, -1)) cfg.motion_throttle_hz = (uint32_t)lua_tonumber(L, -1);
105 lua_pop(L, 1);
106
107 lua_getglobal(L, "binds");
+2,
-60
1@@ -29,8 +29,6 @@ static void on_win_entered(void* data);
2 static void setup(void);
3 static void setup_binds(void);
4 static void sync_window_visibility(void);
5-static void apply_decor(struct client* c, bool active);
6-static const char* decorstring(struct client* c, char* buf, size_t size);
7
8 #define WHEN_PRESSED(state) \
9 do { if ((state) != WL_KEYBOARD_KEY_STATE_PRESSED) return; } while (0)
10@@ -70,57 +68,6 @@ static void adjust_geom(struct client *c, int dx, int dy, int dw, int dh)
11 swc_window_set_geometry(c->win, &geom);
12 }
13
14-static const char* decorstring(struct client* c, char* buf, size_t size)
15-{
16- char path[64];
17- FILE* fp;
18- pid_t pid;
19- size_t len;
20-
21- if (!c || !buf || size == 0)
22- return NULL;
23-
24- pid = swc_window_get_pid(c->win);
25- if (pid <= 0)
26- return NULL;
27-
28- snprintf(path, sizeof(path), "/proc/%lld/comm", (long long)pid);
29- fp = fopen(path, "r");
30- if (!fp)
31- return NULL;
32-
33- if (!fgets(buf, (int)size, fp)) {
34- fclose(fp);
35- return NULL;
36- }
37-
38- fclose(fp);
39- len = strcspn(buf, "\n");
40- buf[len] = '\0';
41- return buf[0] ? buf : NULL;
42-}
43-
44-static void apply_decor(struct client* c, bool active)
45-{
46- char process_name[256];
47- const char* title;
48- struct swc_decor decor;
49-
50- if (!c)
51- return;
52-
53- if (c->fullscreen) {
54- swc_window_set_decor(c->win, NULL);
55- return;
56- }
57-
58- decor = cfg.decor;
59- title = decorstring(c, process_name, sizeof(process_name));
60- if (title)
61- decor.title.string = title;
62- swc_window_set_decor(c->win, &decor);
63-}
64-
65 struct wm wm;
66 const struct swc_manager manager = {
67 .new_screen = new_screen, .new_window = new_window, .new_device = new_device,
68@@ -142,12 +89,10 @@ static struct client* get_focus_candidate(struct screen* s)
69 static void focus(struct client* c)
70 {
71 if (wm.sel_client && wm.sel_client != c) {
72- swc_window_set_border(wm.sel_client->win, cfg.border_col_normal, cfg.border_width, 0, 0);
73- apply_decor(wm.sel_client, false);
74+ swc_window_set_border(wm.sel_client->win, cfg.border_col_normal, cfg.border_width, cfg.border_col_normal_outer, cfg.border_width_outer);
75 }
76 if (c) {
77- swc_window_set_border(c->win, cfg.border_col_active, cfg.border_width, 0, 0);
78- apply_decor(c, true);
79+ swc_window_set_border(c->win, cfg.border_col_active, cfg.border_width, cfg.border_col_active_outer, cfg.border_width_outer);
80 }
81
82 swc_window_focus(c ? c->win : NULL);
83@@ -330,7 +275,6 @@ void fullscreen(void* data, uint32_t time, uint32_t value, uint32_t state)
84 if (c->fullscreen) {
85 c->fullscreen = false;
86 swc_window_set_stacked(c->win);
87- apply_decor(c, true);
88
89 if (c->w > 0 && c->h > 0) {
90 geom = (struct swc_rectangle){ c->x, c->y, c->w, c->h };
91@@ -349,7 +293,6 @@ void fullscreen(void* data, uint32_t time, uint32_t value, uint32_t state)
92 }
93
94 c->fullscreen = true;
95- apply_decor(c, true);
96 swc_window_set_fullscreen(c->win, c->scr->scr);
97 }
98
99@@ -449,7 +392,6 @@ void new_window(struct swc_window* win)
100 wl_list_insert(&wm.clients, &c->link);
101 swc_window_set_handler(win, &window_handler, c);
102 swc_window_set_stacked(win);
103- apply_decor(c, false);
104
105 int32_t cx = 0, cy = 0;
106 if (swc_cursor_position(&cx, &cy))