Skip to content

Commit 4b485b7

Browse files
authored
Merge pull request #22 from cococry/commit
Update v1.3
2 parents b4f9dc1 + b981a9b commit 4b485b7

3 files changed

Lines changed: 33 additions & 46 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
ragnar
22
ragnar.o
33
*.patch
4-
config.h

config.h

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727

2828
/* Monitors */
2929
// Ordered From left to right (0 is most left)
30-
#define MONITOR_COUNT 2
31-
static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height = 1080}, (Monitor){.width = 2560, .height = 1440}};
30+
#define MONITOR_COUNT 1
31+
static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height = 1080}};
3232

3333
/* Commands */
3434
#define TERMINAL_CMD "alacritty &"
35-
#define WEB_BROWSER_CMD "brave &"
36-
#define APPLICATION_LAUNCHER_CMD "rofi-app-launcher &"
35+
#define WEB_BROWSER_CMD "firefox &"
36+
#define APPLICATION_LAUNCHER_CMD "dmenu_run &"
3737

3838
#define WM_REFRESH_SPEED 1.0f // In seconds
3939
#define WM_UPDATE_LAG 100
4040
/* Font*/
41-
#define FONT "JetBrains Mono Nerd Font:size=12:style=bold"
41+
#define FONT "monnospace:size=12"
4242
#define FONT_SIZE 12
4343
#define FONT_COLOR "#ffffff"
4444
#define DECORATION_FONT_COLOR "#ffffff"
@@ -48,7 +48,7 @@ static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height
4848
#define TERMINAL_OPEN_KEY XK_Return
4949
#define WEB_BROWSER_OPEN_KEY XK_W
5050
#define APPLICATION_LAUNCHER_OPEN_KEY XK_S
51-
#define WM_TERMINATE_KEY XK_6
51+
#define WM_TERMINATE_KEY XK_C
5252

5353
#define WINDOW_CLOSE_KEY XK_Q
5454
#define WINDOW_FULLSCREEN_KEY XK_F
@@ -95,6 +95,7 @@ static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height
9595
#define WINDOW_MIN_SIZE_LAYOUT_HORIZONTAL 300
9696
#define WINDOW_MIN_SIZE_LAYOUT_VERTICAL 100 // In pixels
9797
#define WINDOW_MAX_GAP 100 // In pixels
98+
#define WINDOW_INITIAL_GAP 10 // In pixels
9899
#define WINDOW_START_GAP 16 // In pixles
99100
#define WINDOW_TRANSPARENT_FRAME false
100101
#define WINDOW_SELECT_HOVERED true
@@ -107,12 +108,12 @@ static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height
107108
#define DECORATION_TITLE_COLOR 0x1a1823
108109

109110
#define DECORATION_SHOW_CLOSE_ICON true
110-
#define DECORATION_CLOSE_ICON ""
111+
#define DECORATION_CLOSE_ICON "X"
111112
#define DECORATION_CLOSE_ICON_COLOR 0x1a1823
112113
#define DECORATION_CLOSE_ICON_SIZE 50
113114

114115
#define DECORATION_SHOW_MAXIMIZE_ICON true
115-
#define DECORATION_MAXIMIZE_ICON " "
116+
#define DECORATION_MAXIMIZE_ICON " |=|"
116117
#define DECORATION_MAXIMIZE_ICON_COLOR 0x1a1823
117118
#define DECORATION_MAXIMIZE_ICON_SIZE 50
118119

@@ -142,7 +143,7 @@ static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height
142143
#define BAR_SIZE 35 // In pixels
143144
#define BAR_PADDING_Y 0
144145
#define BAR_PADDING_X 0
145-
#define BAR_START_MONITOR 1 // Monitor on which the bar is on startup. (0 is most left)
146+
#define BAR_START_MONITOR 0 // Monitor on which the bar is on startup. (0 is most left)
146147
#define BAR_REFRESH_SPEED 1.0 // In seconds
147148
#define BAR_COLOR 0x1e2326
148149
#define BAR_BORDER_COLOR 0x4f5b58
@@ -188,35 +189,26 @@ static const Monitor Monitors[MONITOR_COUNT] = {(Monitor){.width = 1920, .height
188189
#define BAR_INFO_LABEL_SELECTED_COLOR 0x1e2326
189190
#define BAR_VERSION_LABEL_COLOR 0x2e383c
190191

191-
#define BAR_INFO_PROGRAM_ICON ""
192-
#define BAR_INFO_MONITOR_ICON "󰍹"
193-
#define BAR_INFO_DESKTOP_ICON ""
194-
#define BAR_INFO_WINDOW_LAYOUT_ICON ""
195-
196-
#define BAR_SLICES_COUNT 5
192+
#define BAR_SLICES_COUNT 2
197193

198194
#define BAR_INFO_LABEL_DESKTOP_ICON_SIZE 50
199-
static const char* BarInfoLabelDesktopIcons[DESKTOP_COUNT] = { "", "", "", "", "", "" };
200-
static const uint32_t BarInfoLabelPos[MONITOR_COUNT] = {900, 900};
195+
static const char* BarInfoLabelDesktopIcons[DESKTOP_COUNT] = { "1", "2", "3", "4", "5", "6" };
196+
static const uint32_t BarInfoLabelPos[MONITOR_COUNT] = {810};
201197
static BarCommand BarCommands[BAR_SLICES_COUNT] =
202198
{
203-
(BarCommand){.cmd = "echo \" 󰣇\"", .refresh_time = 300.0f},
204-
(BarCommand){.cmd = "echo \" $(date +%R) \"", .refresh_time = 1.0f},
205-
(BarCommand){.cmd = "ram-ragbar", .refresh_time = 1.0f,},
206-
(BarCommand){.cmd = "uptime-ragbar", .refresh_time = 1.0f},
207-
(BarCommand){.cmd = "packages-ragbar", .refresh_time = 60.0f},
199+
(BarCommand){.cmd = "echo \" RGNR\"", .refresh_time = 300.0f},
200+
(BarCommand){.cmd = "echo \" | $(date +%R) \"", .refresh_time = 1.0f},
208201
};
209202

210203
#define BAR_BUTTON_PADDING 20
211-
#define BAR_BUTTON_SIZE 50
212-
#define BAR_BUTTON_COUNT 4
213-
static const uint32_t BarButtonLabelPos[MONITOR_COUNT] = { 1350, 1600 };
204+
#define BAR_BUTTON_SIZE 120
205+
#define BAR_BUTTON_COUNT 3
206+
static const uint32_t BarButtonLabelPos[MONITOR_COUNT] = { 1300 };
214207
static BarButton BarButtons[BAR_BUTTON_COUNT] =
215208
{
216-
(BarButton){.cmd = APPLICATION_LAUNCHER_CMD, .icon = "", .color = 0x2e383c},
217-
(BarButton){.cmd = TERMINAL_CMD, .icon = "", .color = 0x2e383c},
218-
(BarButton){.cmd = WEB_BROWSER_CMD, .icon = "", .color = 0x2e383c},
219-
(BarButton){.cmd = "nitrogen &", .icon = "", .color = 0x2e383c},
209+
(BarButton){.cmd = APPLICATION_LAUNCHER_CMD, .icon = "Search", .color = 0x2e383c},
210+
(BarButton){.cmd = TERMINAL_CMD, .icon = "Terminal", .color = 0x2e383c},
211+
(BarButton){.cmd = WEB_BROWSER_CMD, .icon = "Web", .color = 0x2e383c},
220212
};
221213

222214

ragnar.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <unistd.h>
99
#include "config.h"
1010

11-
#define VERSION "1.3"
11+
#define VERSION "1.3.1"
1212

1313
#define CLIENT_WINDOW_CAP 256
1414

@@ -24,7 +24,6 @@ typedef struct {
2424
Window win;
2525
bool hidden;
2626
FontStruct font;
27-
bool spawned;
2827
int32_t info_label_x;
2928
} Bar;
3029

@@ -176,9 +175,6 @@ void xwm_window_frame(Window win) {
176175
// Creating the X Window frame
177176
int32_t win_x = get_focused_monitor_window_center_x(attribs.width / 2);
178177

179-
180-
/* Invisible helper window for window decoration */
181-
182178
/* Frame window */
183179
Window win_frame;
184180
if(WINDOW_TRANSPARENT_FRAME) {
@@ -212,11 +208,6 @@ void xwm_window_frame(Window win) {
212208
XMapWindow(wm.display, win_frame);
213209
grab_window_input(win);
214210
XRaiseWindow(wm.display, win_frame);
215-
if(!wm.bar.spawned) {
216-
hide_bar();
217-
unhide_bar();
218-
wm.bar.spawned = true;
219-
}
220211
raise_bar();
221212

222213
if(wm.spawning_scratchpad) {
@@ -297,7 +288,6 @@ void xwm_window_frame(Window win) {
297288
}
298289
draw_bar_buttons();
299290
}
300-
301291
void xwm_window_unframe(Window win) {
302292
// If the window was not framed, return
303293
int32_t client_index = get_client_index_window(win);
@@ -310,6 +300,9 @@ void xwm_window_unframe(Window win) {
310300
wm.client_windows[client_index].ignore_unmap = false;
311301
return;
312302
}
303+
if(wm.client_windows[client_index].fullscreen) {
304+
unhide_bar();
305+
}
313306
Window frame_win = wm.client_windows[client_index].frame;
314307

315308
// If master window of layout was unframed, reset master size
@@ -342,6 +335,7 @@ void xwm_window_unframe(Window win) {
342335
if(wm.hard_focused_window_index == client_index) {
343336
wm.hard_focused_window_index = -1;
344337
}
338+
draw_bar_buttons();
345339
if(fullscreen) {
346340
unhide_bar();
347341
}
@@ -357,6 +351,7 @@ void xwm_run() {
357351
wm.focused_monitor = MONITOR_COUNT - 1;
358352
wm.current_layout = WINDOW_LAYOUT_DEFAULT;
359353
wm.bar_monitor = BAR_START_MONITOR;
354+
wm.window_gap = WINDOW_INITIAL_GAP;
360355
wm.window_gap = WINDOW_START_GAP;
361356
wm.decoration_hidden = !SHOW_DECORATION;
362357
wm.spawning_scratchpad = false;
@@ -378,9 +373,10 @@ void xwm_run() {
378373
XSetInputFocus(wm.display, wm.root, RevertToPointerRoot, CurrentTime);
379374
grab_global_input();
380375

381-
if(SHOW_BAR)
376+
if(SHOW_BAR) {
382377
create_bar();
383-
378+
draw_bar_buttons();
379+
}
384380
double refresh_timer = WM_REFRESH_SPEED;
385381
struct timespec start_time = { 0 }, end_time = { 0 };
386382

@@ -390,6 +386,7 @@ void xwm_run() {
390386
wm.delta_time = (end_time.tv_sec - start_time.tv_sec) + (double)(end_time.tv_sec - start_time.tv_sec) / 1e9;
391387
if((BAR_INSTANT_UPDATE && XPending(wm.display)) || (!BAR_INSTANT_UPDATE)) {
392388
XNextEvent(wm.display, &e);
389+
draw_bar();
393390
select_focused_monitor(get_cursor_position().x);
394391
switch (e.type) {
395392
case UnmapNotify:
@@ -1681,7 +1678,6 @@ void create_bar() {
16811678
}
16821679
draw_bar_buttons();
16831680
wm.bar.hidden = false;
1684-
wm.bar.spawned = false;
16851681
}
16861682

16871683
void hide_bar() {
@@ -1826,7 +1822,7 @@ void draw_design(Window win, int32_t xpos, BarLabelDesign design, uint32_t color
18261822
}
18271823
}
18281824
void draw_bar() {
1829-
if(!SHOW_BAR) return;
1825+
if(!SHOW_BAR || wm.bar.hidden) return;
18301826
// Main Label
18311827
XClearWindow(wm.display, wm.bar.win);
18321828
uint32_t xoffset = 0;
@@ -1924,7 +1920,7 @@ void draw_bar_buttons() {
19241920
if(!SHOW_BAR || wm.bar.hidden) return;
19251921
uint32_t xoffset = 0;
19261922
for(uint32_t i = 0; i < BAR_BUTTON_COUNT; i++) {
1927-
//XRaiseWindow(wm.display, BarButtons[i].win);
1923+
XRaiseWindow(wm.display, BarButtons[i].win);
19281924
XClearWindow(wm.display, BarButtons[i].win);
19291925
XGlyphInfo extents;
19301926
if(str_unicode(BarButtons[i].icon)) {

0 commit comments

Comments
 (0)