-
Notifications
You must be signed in to change notification settings - Fork 1
/
0001-Show-qubes-domain-in-configurable-colored-borders.patch
655 lines (620 loc) · 26.9 KB
/
0001-Show-qubes-domain-in-configurable-colored-borders.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
From 918a05ea1155351f64b7191fd5d5f53bdd877cb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?=
Date: Mon, 6 Apr 2020 11:36:26 +0200
Subject: [PATCH] Show qubes domain in configurable colored borders
Authors:
- SietsevanderMolen
- Dhole
- anadahz
- FireGrace
---
include/atoms_rest.xmacro | 2 +
include/config_directives.h | 2 +-
include/configuration.h | 2 +-
include/data.h | 23 ++++++++
include/window.h | 14 +++++
parser-specs/config.spec | 12 +++--
src/commands.c | 18 +------
src/config.c | 104 +++++++++++++++++++++++++++++++++---
src/config_directives.c | 79 ++++++++++++++++++---------
src/manage.c | 6 ++-
src/resize.c | 2 +-
src/restore_layout.c | 6 +--
src/window.c | 56 +++++++++++++++++++
src/x.c | 44 ++++++++++-----
14 files changed, 299 insertions(+), 71 deletions(-)
diff --git a/include/atoms_rest.xmacro b/include/atoms_rest.xmacro
index b65a81d8..bc017423 100644
--- a/include/atoms_rest.xmacro
+++ b/include/atoms_rest.xmacro
@@ -18,3 +18,5 @@ xmacro(_NET_REQUEST_FRAME_EXTENTS)
xmacro(_NET_FRAME_EXTENTS)
xmacro(_MOTIF_WM_HINTS)
xmacro(WM_CHANGE_STATE)
+xmacro(_QUBES_VMNAME)
+xmacro(_QUBES_LABEL)
diff --git a/include/config_directives.h b/include/config_directives.h
index 06fbd3b0..646f6301 100644
--- a/include/config_directives.h
+++ b/include/config_directives.h
@@ -66,7 +66,7 @@ CFGFUN(ipc_socket, const char *path);
CFGFUN(ipc_kill_timeout, const long timeout_ms);
CFGFUN(restart_state, const char *path);
CFGFUN(popup_during_fullscreen, const char *value);
-CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator, const char *child_border);
+CFGFUN(color, const char *colorclass, const char *labelqube, const char *border, const char *background, const char *text, const char *indicator, const char *child_border);
CFGFUN(color_single, const char *colorclass, const char *color);
CFGFUN(floating_modifier, const char *modifiers);
CFGFUN(default_border, const char *windowtype, const char *border, const long width);
diff --git a/include/configuration.h b/include/configuration.h
index d7c2ab8b..7f956ef1 100644
--- a/include/configuration.h
+++ b/include/configuration.h
@@ -232,7 +232,7 @@ struct Config {
struct Colortriple unfocused;
struct Colortriple urgent;
struct Colortriple placeholder;
- } client;
+ } client[QUBE_NUM_LABELS];
struct config_bar {
struct Colortriple focused;
struct Colortriple unfocused;
diff --git a/include/data.h b/include/data.h
index c0e34b41..746db82d 100644
--- a/include/data.h
+++ b/include/data.h
@@ -145,6 +145,23 @@ typedef enum {
FOCUS_WRAPPING_WORKSPACE = 3
} focus_wrapping_t;
+/**
+ * Qubes colors
+ */
+typedef enum {
+ QUBE_DOM0 = 0,
+ QUBE_RED = 1,
+ QUBE_ORANGE = 2,
+ QUBE_YELLOW = 3,
+ QUBE_GREEN = 4,
+ QUBE_GRAY = 5,
+ QUBE_BLUE = 6,
+ QUBE_PURPLE = 7,
+ QUBE_BLACK = 8,
+} qube_label_t;
+
+#define QUBE_NUM_LABELS 9
+
/**
* Stores a rectangle, for example the size of a window, the child window etc.
*
@@ -427,6 +444,12 @@ struct Window {
/** The name of the window. */
i3String *name;
+ /** The name of the qubes vm. */
+ i3String *qubes_vmname;
+
+ /** The qubes label. */
+ int qubes_label;
+
/** The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window
* sets "buddy list"). Useful to match specific windows in assignments or
* for_window. */
diff --git a/include/window.h b/include/window.h
index 6673e835..73941bb7 100644
--- a/include/window.h
+++ b/include/window.h
@@ -40,6 +40,20 @@ void window_update_name(i3Window *win, xcb_get_property_reply_t *prop);
*/
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop);
+/**
+ * Updates the qubes vmname by using _QUBES_VMNAME (encoded in UTF-8) for the given
+ * window.
+ *
+ */
+void window_update_qubes_vmname(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
+
+/**
+ * Updates the qubes label by using _QUBES_LABEL (encoded in UTF-8) for the given
+ * window.
+ *
+ */
+void window_update_qubes_label(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
+
/**
* Updates the CLIENT_LEADER (logical parent window).
*
diff --git a/parser-specs/config.spec b/parser-specs/config.spec
index 93901fd9..5b5d5bcc 100644
--- a/parser-specs/config.spec
+++ b/parser-specs/config.spec
@@ -56,7 +56,7 @@ state INITIAL:
colorclass = 'client.background'
-> COLOR_SINGLE
colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
- -> COLOR_BORDER
+ -> COLOR_QUBE
# We ignore comments and 'set' lines (variables).
state IGNORE_LINE:
@@ -311,6 +311,10 @@ state COLOR_SINGLE:
-> call cfg_color_single($colorclass, $color)
# colorclass border background text indicator
+state COLOR_QUBE:
+ qubelabel = word
+ -> COLOR_BORDER
+
state COLOR_BORDER:
border = word
-> COLOR_BACKGROUND
@@ -327,13 +331,13 @@ state COLOR_INDICATOR:
indicator = word
-> COLOR_CHILD_BORDER
end
- -> call cfg_color($colorclass, $border, $background, $text, NULL, NULL)
+ -> call cfg_color($colorclass, $qubelabel, $border, $background, $text, NULL, NULL)
state COLOR_CHILD_BORDER:
child_border = word
- -> call cfg_color($colorclass, $border, $background, $text, $indicator, $child_border)
+ -> call cfg_color($colorclass, $qubelabel, $border, $background, $text, $indicator, $child_border)
end
- -> call cfg_color($colorclass, $border, $background, $text, $indicator, NULL)
+ -> call cfg_color($colorclass, $qubelabel, $border, $background, $text, $indicator, NULL)
# <exec|exec_always> [--no-startup-id] command
state EXEC:
diff --git a/src/commands.c b/src/commands.c
index 6a6ea5a3..6e0df7b2 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -706,23 +706,7 @@ void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, c
}
static int border_width_from_style(border_style_t border_style, long border_width, Con *con) {
- if (border_style == BS_NONE) {
- return 0;
- }
- if (border_width >= 0) {
- return logical_px(border_width);
- }
-
- const bool is_floating = con_inside_floating(con) != NULL;
- /* Load the configured defaults. */
- if (is_floating && border_style == config.default_floating_border) {
- return config.default_floating_border_width;
- } else if (!is_floating && border_style == config.default_border) {
- return config.default_border_width;
- } else {
- /* Use some hardcoded values. */
- return logical_px(border_style == BS_NORMAL ? 2 : 1);
- }
+ return 3;
}
/*
diff --git a/src/config.c b/src/config.c
index 81919566..62388f73 100644
--- a/src/config.c
+++ b/src/config.c
@@ -199,14 +199,100 @@ bool load_configuration(const char *override_configpath, config_load_t load_type
x.child_border = draw_util_hex_to_color(cbackground); \
} while (0)
- config.client.background = draw_util_hex_to_color("#000000");
- INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff", "#2e9ef4");
- INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff", "#484e50");
- INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888", "#292d2e");
- INIT_COLOR(config.client.urgent, "#2f343a", "#900000", "#ffffff", "#900000");
+ config.client[QUBE_DOM0].background = draw_util_hex_to_color("#c4c4c4");
+ INIT_COLOR(config.client[QUBE_DOM0].focused,
+ "#f7f7f7", "#f5f5f5", "#000000", "#0a0a0a");
+ INIT_COLOR(config.client[QUBE_DOM0].focused_inactive,
+ "#f7f7f7", "#dcdcdc", "#191919", "#232323");
+ INIT_COLOR(config.client[QUBE_DOM0].unfocused,
+ "#f7f7f7", "#c4c4c4", "#323232", "#3b3b3b");
+ INIT_COLOR(config.client[QUBE_DOM0].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_RED].background = draw_util_hex_to_color("#841b1b");
+ INIT_COLOR(config.client[QUBE_RED].focused,
+ "#d06767", "#bd2727", "#ffffff", "#27bdbd");
+ INIT_COLOR(config.client[QUBE_RED].focused_inactive,
+ "#d06767", "#971f1f", "#e5e5e5", "#1f9797");
+ INIT_COLOR(config.client[QUBE_RED].unfocused,
+ "#d06767", "#841b1b", "#cccccc", "#1b8484");
+ INIT_COLOR(config.client[QUBE_RED].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_ORANGE].background = draw_util_hex_to_color("#a16e1b");
+ INIT_COLOR(config.client[QUBE_ORANGE].focused,
+ "#eebb67", "#e79e27", "#000000", "#2770e7");
+ INIT_COLOR(config.client[QUBE_ORANGE].focused_inactive,
+ "#eebb67", "#b87e1f", "#191919", "#1f59b8");
+ INIT_COLOR(config.client[QUBE_ORANGE].unfocused,
+ "#eebb67", "#a16e1b", "#323232", "#1b4ea1");
+ INIT_COLOR(config.client[QUBE_ORANGE].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_YELLOW].background = draw_util_hex_to_color("#a1a023");
+ INIT_COLOR(config.client[QUBE_YELLOW].focused,
+ "#eeec6f", "#e7e532", "#000000", "#3234e7");
+ INIT_COLOR(config.client[QUBE_YELLOW].focused_inactive,
+ "#eeec6f", "#b8b728", "#191919", "#2829b8");
+ INIT_COLOR(config.client[QUBE_YELLOW].unfocused,
+ "#eeec6f", "#a1a023", "#323232", "#2324a1");
+ INIT_COLOR(config.client[QUBE_YELLOW].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_GREEN].background = draw_util_hex_to_color("#3e972c");
+ INIT_COLOR(config.client[QUBE_GREEN].focused,
+ "#8be379", "#5ad840", "#000000", "#be40d8");
+ INIT_COLOR(config.client[QUBE_GREEN].focused_inactive,
+ "#8be379", "#48ac33", "#191919", "#9833ac");
+ INIT_COLOR(config.client[QUBE_GREEN].unfocused,
+ "#8be379", "#3e972c", "#323232", "#852c97");
+ INIT_COLOR(config.client[QUBE_GREEN].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_GRAY].background = draw_util_hex_to_color("#636368");
+ INIT_COLOR(config.client[QUBE_GRAY].focused,
+ "#afafb4", "#8e8e95", "#ffffff", "#95958e");
+ INIT_COLOR(config.client[QUBE_GRAY].focused_inactive,
+ "#afafb4", "#717177", "#e5e5e5", "#777771");
+ INIT_COLOR(config.client[QUBE_GRAY].unfocused,
+ "#afafb4", "#636368", "#cccccc", "#686863");
+ INIT_COLOR(config.client[QUBE_GRAY].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_BLUE].background = draw_util_hex_to_color("#275197");
+ INIT_COLOR(config.client[QUBE_BLUE].focused,
+ "#739de3", "#3874d8", "#ffffff", "#d89c38");
+ INIT_COLOR(config.client[QUBE_BLUE].focused_inactive,
+ "#739de3", "#2c5cac", "#e5e5e5", "#ac7c2c");
+ INIT_COLOR(config.client[QUBE_BLUE].unfocused,
+ "#739de3", "#275197", "#cccccc", "#976d27");
+ INIT_COLOR(config.client[QUBE_BLUE].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_PURPLE].background = draw_util_hex_to_color("#6f276f");
+ INIT_COLOR(config.client[QUBE_PURPLE].focused,
+ "#bb73bb", "#9f389f", "#ffffff", "#389f38");
+ INIT_COLOR(config.client[QUBE_PURPLE].focused_inactive,
+ "#bb73bb", "#7f2c7f", "#e5e5e5", "#2c7f2c");
+ INIT_COLOR(config.client[QUBE_PURPLE].unfocused,
+ "#bb73bb", "#6f276f", "#cccccc", "#276f27");
+ INIT_COLOR(config.client[QUBE_PURPLE].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
+
+ config.client[QUBE_BLACK].background = draw_util_hex_to_color("#141414");
+ INIT_COLOR(config.client[QUBE_BLACK].focused,
+ "#5b5b5b", "#333333", "#ffffff", "#cccccc");
+ INIT_COLOR(config.client[QUBE_BLACK].focused_inactive,
+ "#5b5b5b", "#1e1e1e", "#e5e5e5", "#e1e1e1");
+ INIT_COLOR(config.client[QUBE_BLACK].unfocused,
+ "#5b5b5b", "#141414", "#cccccc", "#ebebeb");
+ INIT_COLOR(config.client[QUBE_BLACK].urgent,
+ "#bd2727", "#e79e27", "#333333", "#27bdbd");
/* border and indicator color are ignored for placeholder contents */
- INIT_COLOR(config.client.placeholder, "#000000", "#0c0c0c", "#ffffff", "#000000");
+ INIT_COLOR(config.client[QUBE_DOM0].placeholder,
+ "#000000", "#0c0c0c", "#ffffff", "#000000");
+
/* the last argument (indicator color) is ignored for bar colors */
INIT_COLOR(config.bar.focused, "#4c7899", "#285577", "#ffffff", "#000000");
@@ -244,6 +330,12 @@ bool load_configuration(const char *override_configpath, config_load_t load_type
set_font(&config.font);
}
+ /* redefine defaults, to overwrite user settings easily */
+ config.default_border = BS_NORMAL;
+ config.default_floating_border = BS_NORMAL;
+ config.default_border_width = logical_px(2);
+ config.default_floating_border_width = logical_px(2);
+
if (load_type == C_RELOAD) {
translate_keysyms();
grab_all_keys(conn);
diff --git a/src/config_directives.c b/src/config_directives.c
index 4712296c..379f24b6 100644
--- a/src/config_directives.c
+++ b/src/config_directives.c
@@ -395,32 +395,63 @@ CFGFUN(popup_during_fullscreen, const char *value) {
CFGFUN(color_single, const char *colorclass, const char *color) {
/* used for client.background only currently */
- config.client.background = draw_util_hex_to_color(color);
-}
-
-CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator, const char *child_border) {
-#define APPLY_COLORS(classname) \
- do { \
- if (strcmp(colorclass, "client." #classname) == 0) { \
- config.client.classname.border = draw_util_hex_to_color(border); \
- config.client.classname.background = draw_util_hex_to_color(background); \
- config.client.classname.text = draw_util_hex_to_color(text); \
- if (indicator != NULL) { \
- config.client.classname.indicator = draw_util_hex_to_color(indicator); \
- } \
- if (child_border != NULL) { \
- config.client.classname.child_border = draw_util_hex_to_color(child_border); \
- } else { \
- config.client.classname.child_border = config.client.classname.background; \
- } \
- } \
+ config.client[QUBE_DOM0].background = draw_util_hex_to_color(color);
+}
+
+CFGFUN(color, const char *colorclass, const char *qubelabel, const char *border, const char *background, const char *text, const char *indicator, const char *child_border) {
+#define APPLY_COLORS(classname, label) \
+ do { \
+ if (strcmp(colorclass, "client." #classname) == 0) { \
+ config.client[label].classname.border = \
+ draw_util_hex_to_color(border); \
+ config.client[label].classname.background = \
+ draw_util_hex_to_color(background); \
+ config.client[label].classname.text = \
+ draw_util_hex_to_color(text); \
+ if (indicator != NULL) { \
+ config.client[label].classname.indicator = \
+ draw_util_hex_to_color(indicator); \
+ } \
+ if (child_border != NULL) { \
+ config.client[label].classname.child_border = \
+ draw_util_hex_to_color(child_border); \
+ } else { \
+ config.client[label].classname.child_border = \
+ config.client[label].classname.background;\
+ } \
+ } \
} while (0)
- APPLY_COLORS(focused_inactive);
- APPLY_COLORS(focused);
- APPLY_COLORS(unfocused);
- APPLY_COLORS(urgent);
- APPLY_COLORS(placeholder);
+ int valid_color = 1;
+ qube_label_t label = QUBE_DOM0;
+ if (strcmp(qubelabel, "dom0") == 0) {
+ label = QUBE_DOM0;
+ } else if (strcmp(qubelabel, "red") == 0) {
+ label = QUBE_RED;
+ } else if (strcmp(qubelabel, "orange") == 0) {
+ label = QUBE_ORANGE;
+ } else if (strcmp(qubelabel, "yellow") == 0) {
+ label = QUBE_YELLOW;
+ } else if (strcmp(qubelabel, "green") == 0) {
+ label = QUBE_GREEN;
+ } else if (strcmp(qubelabel, "gray") == 0) {
+ label = QUBE_GRAY;
+ } else if (strcmp(qubelabel, "blue") == 0) {
+ label = QUBE_BLUE;
+ } else if (strcmp(qubelabel, "purple") == 0) {
+ label = QUBE_PURPLE;
+ } else if (strcmp(qubelabel, "black") == 0) {
+ label = QUBE_BLACK;
+ } else {
+ valid_color = 0;
+ }
+
+ if (valid_color) {
+ APPLY_COLORS(focused_inactive, label);
+ APPLY_COLORS(focused, label);
+ APPLY_COLORS(unfocused, label);
+ APPLY_COLORS(urgent, label);
+ }
#undef APPLY_COLORS
}
diff --git a/src/manage.c b/src/manage.c
index 8b56fd6e..9dbd86f9 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -116,7 +116,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
xcb_get_window_attributes_reply_t *attr = NULL;
xcb_get_property_cookie_t wm_type_cookie, strut_cookie, state_cookie,
- utf8_title_cookie, title_cookie,
+ utf8_title_cookie, title_cookie, qubes_vmname_cookie, qubes_label_cookie,
class_cookie, leader_cookie, transient_cookie,
role_cookie, startup_id_cookie, wm_hints_cookie,
wm_normal_hints_cookie, motif_wm_hints_cookie, wm_user_time_cookie, wm_desktop_cookie;
@@ -181,6 +181,8 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
strut_cookie = GET_PROPERTY(A__NET_WM_STRUT_PARTIAL, UINT32_MAX);
state_cookie = GET_PROPERTY(A__NET_WM_STATE, UINT32_MAX);
utf8_title_cookie = GET_PROPERTY(A__NET_WM_NAME, 128);
+ qubes_vmname_cookie = GET_PROPERTY(A__QUBES_VMNAME, 128);
+ qubes_label_cookie = GET_PROPERTY(A__QUBES_LABEL, UINT32_MAX);
leader_cookie = GET_PROPERTY(A_WM_CLIENT_LEADER, UINT32_MAX);
transient_cookie = GET_PROPERTY(XCB_ATOM_WM_TRANSIENT_FOR, UINT32_MAX);
title_cookie = GET_PROPERTY(XCB_ATOM_WM_NAME, 128);
@@ -205,6 +207,8 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
window_update_class(cwindow, xcb_get_property_reply(conn, class_cookie, NULL));
window_update_name_legacy(cwindow, xcb_get_property_reply(conn, title_cookie, NULL));
window_update_name(cwindow, xcb_get_property_reply(conn, utf8_title_cookie, NULL));
+ window_update_qubes_vmname(cwindow, xcb_get_property_reply(conn, qubes_vmname_cookie, NULL), true);
+ window_update_qubes_label(cwindow, xcb_get_property_reply(conn, qubes_label_cookie, NULL), true);
window_update_leader(cwindow, xcb_get_property_reply(conn, leader_cookie, NULL));
window_update_transient_for(cwindow, xcb_get_property_reply(conn, transient_cookie, NULL));
window_update_strut_partial(cwindow, xcb_get_property_reply(conn, strut_cookie, NULL));
diff --git a/src/resize.c b/src/resize.c
index 97a0f946..aa711f38 100644
--- a/src/resize.c
+++ b/src/resize.c
@@ -208,7 +208,7 @@ void resize_graphical_handler(Con *first, Con *second, orientation_t orientation
}
mask = XCB_CW_BACK_PIXEL;
- values[0] = config.client.focused.border.colorpixel;
+ values[0] = config.client[QUBE_DOM0].focused.border.colorpixel;
mask |= XCB_CW_OVERRIDE_REDIRECT;
values[1] = 1;
diff --git a/src/restore_layout.c b/src/restore_layout.c
index 186c0907..1c215113 100644
--- a/src/restore_layout.c
+++ b/src/restore_layout.c
@@ -129,8 +129,8 @@ void restore_connect(void) {
}
static void update_placeholder_contents(placeholder_state *state) {
- const color_t foreground = config.client.placeholder.text;
- const color_t background = config.client.placeholder.background;
+ const color_t foreground = config.client[QUBE_DOM0].placeholder.text;
+ const color_t background = config.client[QUBE_DOM0].placeholder.background;
draw_util_clear_surface(&(state->surface), background);
@@ -199,7 +199,7 @@ static void open_placeholder_window(Con *con) {
true,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
(uint32_t[]){
- config.client.placeholder.background.colorpixel,
+ config.client[QUBE_DOM0].placeholder.background.colorpixel,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY,
});
/* Make i3 not focus this window. */
diff --git a/src/window.c b/src/window.c
index 369aaa96..21d78197 100644
--- a/src/window.c
+++ b/src/window.c
@@ -130,6 +130,62 @@ void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop) {
free(prop);
}
+/*
+ * Updates the qubes vmname by using _QUBES_VMNAME (encoded in UTF-8) for the given
+ * window.
+ *
+ */
+void window_update_qubes_vmname(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt) {
+ if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
+ win->qubes_vmname = i3string_from_utf8("dom0");
+ FREE(prop);
+ return;
+ }
+
+ i3string_free(win->qubes_vmname);
+
+ /* Truncate the name at the first zero byte. See i3 #3515. */
+ const int len = xcb_get_property_value_length(prop);
+ char *qubes_vmname = sstrndup(xcb_get_property_value(prop), len);
+ win->qubes_vmname = i3string_from_utf8(qubes_vmname);
+ free(qubes_vmname);
+
+ LOG("_QUBES_VMNAME set to \"%s\"\n", i3string_as_utf8(win->qubes_vmname));
+
+ if (before_mgmt) {
+ free(prop);
+ return;
+ }
+
+ run_assignments(win);
+
+ free(prop);
+}
+
+/*
+ * Updates the qubes label by using _QUBES_LABEL (encoded in UTF-8) for the given
+ * window.
+ *
+ */
+void window_update_qubes_label(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt) {
+ if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
+ win->qubes_label = 0;
+ FREE(prop);
+ return;
+ }
+
+ win->qubes_label = *(int*) xcb_get_property_value(prop);
+
+ if (before_mgmt) {
+ free(prop);
+ return;
+ }
+
+ run_assignments(win);
+
+ free(prop);
+}
+
/*
* Updates the CLIENT_LEADER (logical parent window).
*
diff --git a/src/x.c b/src/x.c
index 8d89eafd..185e6009 100644
--- a/src/x.c
+++ b/src/x.c
@@ -493,15 +493,25 @@ void x_draw_decoration(Con *con) {
/* 1: build deco_params and compare with cache */
struct deco_render_params *p = scalloc(1, sizeof(struct deco_render_params));
+ /* Find out which Qubes label to use */
+ qube_label_t label = QUBE_DOM0;
+ struct Window *win = con->window;
+ if (win != NULL) {
+ DLOG("con->qubes_label is %d\n", win->qubes_label);
+ if (win->qubes_label >= 0 && win->qubes_label < QUBE_NUM_LABELS) {
+ label = win->qubes_label;
+ }
+ }
+
/* find out which colors to use */
if (con->urgent)
- p->color = &config.client.urgent;
+ p->color = &config.client[label].urgent;
else if (con == focused || con_inside_focused(con))
- p->color = &config.client.focused;
+ p->color = &config.client[label].focused;
else if (con == TAILQ_FIRST(&(parent->focus_head)))
- p->color = &config.client.focused_inactive;
+ p->color = &config.client[label].focused_inactive;
else
- p->color = &config.client.unfocused;
+ p->color = &config.client[label].unfocused;
p->border_style = con_border_style(con);
@@ -510,7 +520,7 @@ void x_draw_decoration(Con *con) {
p->con_rect = (struct width_height){r->width, r->height};
p->con_window_rect = (struct width_height){w->width, w->height};
p->con_deco_rect = con->deco_rect;
- p->background = config.client.background;
+ p->background = config.client[QUBE_DOM0].background;
p->con_is_leaf = con_is_leaf(con);
p->parent_layout = con->parent->layout;
@@ -542,16 +552,16 @@ void x_draw_decoration(Con *con) {
/* 2: draw the client.background, but only for the parts around the window_rect */
if (con->window != NULL) {
/* top area */
- draw_util_rectangle(&(con->frame_buffer), config.client.background,
+ draw_util_rectangle(&(con->frame_buffer), config.client[QUBE_DOM0].background,
0, 0, r->width, w->y);
/* bottom area */
- draw_util_rectangle(&(con->frame_buffer), config.client.background,
+ draw_util_rectangle(&(con->frame_buffer), config.client[QUBE_DOM0].background,
0, w->y + w->height, r->width, r->height - (w->y + w->height));
/* left area */
- draw_util_rectangle(&(con->frame_buffer), config.client.background,
+ draw_util_rectangle(&(con->frame_buffer), config.client[QUBE_DOM0].background,
0, 0, w->x, r->height);
/* right area */
- draw_util_rectangle(&(con->frame_buffer), config.client.background,
+ draw_util_rectangle(&(con->frame_buffer), config.client[QUBE_DOM0].background,
w->x + w->width, 0, r->width - (w->x + w->width), r->height);
}
@@ -656,7 +666,6 @@ void x_draw_decoration(Con *con) {
}
i3String *title = NULL;
- struct Window *win = con->window;
if (win == NULL) {
if (con->title_format == NULL) {
char *_title;
@@ -676,6 +685,17 @@ void x_draw_decoration(Con *con) {
goto copy_pixmaps;
}
+ /* Set Qubes window title only when the container has a title and contains
+ * a window. */
+ if (win != NULL) {
+ char *title_buf;
+ sasprintf(&title_buf, "[%s] %s", i3string_as_utf8(win->qubes_vmname), i3string_as_utf8(title));
+ if (con->title_format != NULL)
+ I3STRING_FREE(title);
+ title = i3string_from_utf8(title_buf);
+ FREE(title_buf);
+ }
+
int title_offset_x;
switch (config.title_align) {
case ALIGN_LEFT:
@@ -704,9 +724,7 @@ void x_draw_decoration(Con *con) {
con->deco_rect.y + text_offset_y,
deco_width - mark_width - 2 * title_padding);
- if (win == NULL || con->title_format != NULL) {
- I3STRING_FREE(title);
- }
+ I3STRING_FREE(title);
x_draw_decoration_after_title(con, p);
copy_pixmaps:
--
2.25.1