-
Notifications
You must be signed in to change notification settings - Fork 1
/
0006-Inactive-Font.patch
363 lines (345 loc) · 11.8 KB
/
0006-Inactive-Font.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
From cbd2d54af5ec9de94c6bbdab09c45c2aefd4c1eb Mon Sep 17 00:00:00 2001
From: Anupam Srivastava <ansrivastava@corp.ebay.com>
Date: Sat, 2 May 2015 11:16:45 +0530
Subject: [PATCH 06/13] Inactive Font
---
fvwm/add_window.c | 31 +++++++++++++++++++++++++++++++
fvwm/borders.c | 35 +++++++++++++++++++----------------
fvwm/fvwm.h | 5 +++++
fvwm/style.c | 35 +++++++++++++++++++++++++++++++++++
fvwm/style.h | 8 ++++++++
fvwm/window_flags.h | 12 ++++++++++++
6 files changed, 110 insertions(+), 16 deletions(-)
diff --git a/fvwm/add_window.c b/fvwm/add_window.c
index f89890d..8ba0305 100644
--- a/fvwm/add_window.c
+++ b/fvwm/add_window.c
@@ -761,6 +761,18 @@ static void destroy_window_font(FvwmWindow *fw)
fw->title_font = Scr.DefaultFont;
SET_USING_DEFAULT_WINDOW_FONT(fw, 1);
+ if (IS_INACTIVE_WINDOW_FONT_LOADED(fw) && !USING_DEFAULT_INACTIVE_WINDOW_FONT(fw) &&
+ fw->title_font != Scr.DefaultFont)
+ {
+ FlocaleUnloadFont(dpy, fw->title_font);
+ }
+ SET_INACTIVE_WINDOW_FONT_LOADED(fw, 0);
+ /* Fall back to default font. There are some race conditions when a
+ * window is destroyed and recaptured where an invalid font might be
+ * accessed otherwise. */
+ fw->title_font = Scr.DefaultFont;
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 1);
+
return;
}
@@ -1877,6 +1889,25 @@ void setup_window_font(
}
SET_WINDOW_FONT_LOADED(fw, 1);
}
+ /* load inactive font */
+ if (!IS_INACTIVE_WINDOW_FONT_LOADED(fw))
+ {
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCF(*pstyle)) &&
+ SGET_INACTIVE_WINDOW_FONT(*pstyle) &&
+ (fw->inactive_title_font =
+ FlocaleLoadFont(dpy, SGET_INACTIVE_WINDOW_FONT(*pstyle), "FVWM")))
+ {
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 0);
+ }
+ else
+ {
+ /* no explicit font or failed to load, use active title font
+ * instead */
+ fw->inactive_title_font = fw->title_font;
+ SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw, 1);
+ }
+ SET_INACTIVE_WINDOW_FONT_LOADED(fw, 1);
+ }
setup_title_geometry(fw, pstyle);
return;
diff --git a/fvwm/borders.c b/fvwm/borders.c
index 8e24aed..d35f21b 100644
--- a/fvwm/borders.c
+++ b/fvwm/borders.c
@@ -3919,7 +3919,7 @@ static void border_draw_title_stick_lines(
static void border_draw_title_mono(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- FlocaleWinString *fstr, Pixmap dest_pix)
+ FlocaleWinString *fstr, Pixmap dest_pix, Bool do_hilight)
{
int has_vt;
@@ -3929,7 +3929,8 @@ static void border_draw_title_mono(
td->offset - 2, 0, td->length+4, fw->title_thickness);
if (fw->visible_name != (char *)NULL)
{
- FlocaleDrawString(dpy, fw->title_font, fstr, 0);
+ FlocaleDrawString(dpy, do_hilight ? fw->title_font :
+ fw->inactive_title_font, fstr, 0);
}
/* for mono, we clear an area in the title bar where the window
* title goes, so that its more legible. For color, no need */
@@ -3993,7 +3994,7 @@ static void border_draw_title_relief(
static void border_draw_title_deep(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- FlocaleWinString *fstr, Pixmap dest_pix, Window w)
+ FlocaleWinString *fstr, Pixmap dest_pix, Window w, Bool do_hilight)
{
DecorFace *df;
pixmap_background_type bg;
@@ -4015,14 +4016,15 @@ static void border_draw_title_deep(
1);
}
}
- FlocaleDrawString(dpy, fw->title_font, &tdd->fstr, 0);
+ FlocaleDrawString(dpy, do_hilight ? fw->title_font :
+ fw->inactive_title_font, &tdd->fstr, 0);
return;
}
static void border_get_titlebar_draw_descr(
FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd,
- Pixmap dest_pix)
+ Pixmap dest_pix, Bool do_hilight)
{
memset(tdd, 0, sizeof(*tdd));
/* prepare the gcs and variables */
@@ -4036,7 +4038,8 @@ static void border_get_titlebar_draw_descr(
tdd->rgc = td->cd->relief_gc;
tdd->sgc = td->cd->shadow_gc;
}
- NewFontAndColor(fw->title_font, td->cd->fore_color, td->cd->back_color);
+ NewFontAndColor(do_hilight ? fw->title_font : fw->inactive_title_font,
+ td->cd->fore_color, td->cd->back_color);
tdd->tstyle = &TB_STATE(
GetDecor(fw, titlebar))[td->tbstate.tstate].style;
tdd->df = &TB_STATE(GetDecor(fw, titlebar))[td->tbstate.tstate];
@@ -4073,7 +4076,7 @@ static void border_get_titlebar_draw_descr(
}
static void border_set_title_pixmap(
- FvwmWindow *fw, titlebar_descr *td, Pixmap *dest_pix, Window w)
+ FvwmWindow *fw, titlebar_descr *td, Pixmap *dest_pix, Window w, Bool do_hilight)
{
pixmap_background_type bg;
title_draw_descr tdd;
@@ -4081,7 +4084,7 @@ static void border_set_title_pixmap(
Bool free_bg_pixmap = False;
rectangle pix_g;
- border_get_titlebar_draw_descr(fw, td, &tdd, *dest_pix);
+ border_get_titlebar_draw_descr(fw, td, &tdd, *dest_pix, do_hilight);
/* prepare background, either from the window colour or from the
* border style */
if (!DFS_USE_BORDER_STYLE(*tdd.tstyle))
@@ -4149,11 +4152,11 @@ static void border_set_title_pixmap(
if (Pdepth < 2)
{
- border_draw_title_mono(fw, td, &tdd, &fstr, *dest_pix);
+ border_draw_title_mono(fw, td, &tdd, &fstr, *dest_pix, do_hilight);
}
else
{
- border_draw_title_deep(fw, td, &tdd, &fstr, *dest_pix, w);
+ border_draw_title_deep(fw, td, &tdd, &fstr, *dest_pix, w, do_hilight);
}
border_draw_title_relief(fw, td, &tdd, *dest_pix);
border_draw_title_stick_lines(fw, td, &tdd, *dest_pix);
@@ -4162,7 +4165,7 @@ static void border_set_title_pixmap(
}
static void border_draw_title(
- FvwmWindow *fw, titlebar_descr *td)
+ FvwmWindow *fw, titlebar_descr *td, Bool do_hilight)
{
Pixmap p;
@@ -4180,7 +4183,7 @@ static void border_draw_title(
#if 0
fprintf(stderr,"drawing title\n");
#endif
- border_set_title_pixmap(fw, td, &p, FW_W_TITLE(fw));
+ border_set_title_pixmap(fw, td, &p, FW_W_TITLE(fw), do_hilight);
if (td->draw_rotation != ROTATION_0)
{
Pixmap tmp;
@@ -4669,9 +4672,9 @@ static window_parts border_get_titlebar_descr(
if (fw->visible_name != (char *)NULL)
{
ret_td->length = FlocaleTextWidth(
- fw->title_font, fw->visible_name,
- (ret_td->has_vt) ? -strlen(fw->visible_name) :
- strlen(fw->visible_name));
+ do_hilight ? fw->title_font : fw->inactive_title_font,
+ fw->visible_name, (ret_td->has_vt) ?
+ -strlen(fw->visible_name) : strlen(fw->visible_name));
if (ret_td->length > fw->title_length -
2*MIN_WINDOW_TITLE_TEXT_OFFSET)
{
@@ -4777,7 +4780,7 @@ static void border_draw_titlebar(
}
if ((draw_parts & PART_TITLE) != PART_NONE)
{
- border_draw_title(fw, &td);
+ border_draw_title(fw, &td, do_hilight);
}
if ((draw_parts & PART_BUTTONS) != PART_NONE)
{
diff --git a/fvwm/fvwm.h b/fvwm/fvwm.h
index 187db83..425a49c 100644
--- a/fvwm/fvwm.h
+++ b/fvwm/fvwm.h
@@ -200,6 +200,7 @@ typedef struct
unsigned has_icon_font : 1;
unsigned has_no_border : 1;
unsigned has_window_font : 1;
+ unsigned has_inactive_window_font : 1;
unsigned title_dir : 2;
unsigned user_states : 32;
/* static flags that do not change dynamically after the window has
@@ -363,11 +364,13 @@ typedef struct
unsigned is_viewport_moved : 1;
unsigned is_window_being_moved_opaque : 1;
unsigned is_window_font_loaded : 1;
+ unsigned is_inactive_window_font_loaded : 1;
unsigned is_window_shaded : 1;
unsigned used_title_dir_for_shading : 1;
unsigned shaded_dir : 3;
unsigned using_default_icon_font : 1;
unsigned using_default_window_font : 1;
+ unsigned using_default_inactive_window_font : 1;
#define ICON_HINT_NEVER 0
#define ICON_HINT_ONCE 1
#define ICON_HINT_MULTIPLE 2
@@ -679,6 +682,7 @@ typedef struct window_style
signed char icon_title_relief;
char *icon_font;
char *window_font;
+ char *inactive_window_font;
char *fore_color_name;
char *back_color_name;
char *fore_color_name_hi;
@@ -840,6 +844,7 @@ typedef struct FvwmWindow
/* title font */
FlocaleFont *title_font;
+ FlocaleFont *inactive_title_font;
/* /Y coordinate to draw the title name */
short title_text_offset;
short title_length;
diff --git a/fvwm/style.c b/fvwm/style.c
index bb6ecb7..fe76440 100644
--- a/fvwm/style.c
+++ b/fvwm/style.c
@@ -452,6 +452,22 @@ static void merge_styles(
*merged_style, SGET_WINDOW_FONT(*add_style));
}
}
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCF(*add_style)))
+ {
+ if (do_free_src_and_alloc_copy)
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*merged_style));
+ SSET_INACTIVE_WINDOW_FONT(
+ *merged_style, (SGET_INACTIVE_WINDOW_FONT(*add_style)) ?
+ safestrdup(SGET_INACTIVE_WINDOW_FONT(*add_style)) :
+ NULL);
+ }
+ else
+ {
+ SSET_INACTIVE_WINDOW_FONT(
+ *merged_style, SGET_INACTIVE_WINDOW_FONT(*add_style));
+ }
+ }
if (add_style->flags.use_start_on_desk)
{
SSET_START_DESK(*merged_style, SGET_START_DESK(*add_style));
@@ -943,6 +959,10 @@ static void free_style_mask(window_style *style, style_flags *mask)
{
SAFEFREE(SGET_WINDOW_FONT(*style));
}
+ if (pmask->common.has_inactive_window_font)
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*style));
+ }
if (pmask->has_icon)
{
SAFEFREE(SGET_ICON_NAME(*style));
@@ -3381,6 +3401,15 @@ static Bool style_parse_one_style_option(
S_SET_IS_UNICONIFIABLE(SCM(*ps), 1);
S_SET_IS_UNICONIFIABLE(SCC(*ps), 1);
}
+ else if (StrEquals(token, "InactiveFont"))
+ {
+ SAFEFREE(SGET_INACTIVE_WINDOW_FONT(*ps));
+ rest = GetNextToken(rest, &token);
+ SSET_INACTIVE_WINDOW_FONT(*ps, token);
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCF(*ps), (token != NULL));
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCM(*ps), 1);
+ S_SET_HAS_INACTIVE_WINDOW_FONT(SCC(*ps), 1);
+ }
else if (StrEquals(token, "IndexedWindowName"))
{
char *format;
@@ -5263,6 +5292,12 @@ void check_window_style_change(
flags->do_update_window_font = 1;
}
+ /* has_inactive_window_font */
+ if (S_HAS_INACTIVE_WINDOW_FONT(SCC(*ret_style)))
+ {
+ flags->do_update_window_font = True;
+ }
+
/* has_stippled_title */
if (S_HAS_STIPPLED_TITLE(SCC(*ret_style)) ||
S_HAS_NO_STICKY_STIPPLED_TITLE(SCC(*ret_style)) ||
diff --git a/fvwm/style.h b/fvwm/style.h
index 0f9bc31..9fec6c6 100644
--- a/fvwm/style.h
+++ b/fvwm/style.h
@@ -300,6 +300,10 @@
((c).has_window_font)
#define S_SET_HAS_WINDOW_FONT(c,x) \
((c).has_window_font = !!(x))
+#define S_HAS_INACTIVE_WINDOW_FONT(c) \
+ ((c).has_inactive_window_font)
+#define S_SET_HAS_INACTIVE_WINDOW_FONT(c,x) \
+ ((c).has_inactive_window_font = !!(x))
#define S_ICON_OVERRIDE(c) \
((c).s.icon_override)
#define S_SET_ICON_OVERRIDE(c,x) \
@@ -496,6 +500,10 @@
((s).window_font)
#define SSET_WINDOW_FONT(s,x) \
((s).window_font = (x))
+#define SGET_INACTIVE_WINDOW_FONT(s) \
+ ((s).inactive_window_font)
+#define SSET_INACTIVE_WINDOW_FONT(s,x) \
+ ((s).inactive_window_font = (x))
#define SGET_COLORSET(s) \
((s).colorset)
#define SSET_COLORSET(s,x) \
diff --git a/fvwm/window_flags.h b/fvwm/window_flags.h
index 9d04901..f37b4ba 100644
--- a/fvwm/window_flags.h
+++ b/fvwm/window_flags.h
@@ -580,6 +580,12 @@
(fw)->flags.is_window_font_loaded = !!(x)
#define SETM_WINDOW_FONT_LOADED(fw,x) \
(fw)->flag_mask.is_window_font_loaded = !!(x)
+#define IS_INACTIVE_WINDOW_FONT_LOADED(fw) \
+ ((fw)->flags.is_inactive_window_font_loaded)
+#define SET_INACTIVE_WINDOW_FONT_LOADED(fw,x) \
+ (fw)->flags.is_inactive_window_font_loaded = !!(x)
+#define SETM_INACTIVE_WINDOW_FONT_LOADED(fw,x) \
+ (fw)->flag_mask.is_inactive_window_font_loaded = !!(x)
#define CR_MOTION_METHOD(fw) \
((fw)->flags.cr_motion_method)
#define SET_CR_MOTION_METHOD(fw,x) \
@@ -622,6 +628,12 @@
(fw)->flags.using_default_window_font = !!(x)
#define SETM_USING_DEFAULT_WINDOW_FONT(fw,x) \
(fw)->flag_mask.using_default_window_font = !!(x)
+#define USING_DEFAULT_INACTIVE_WINDOW_FONT(fw) \
+ ((fw)->flags.using_default_inactive_window_font)
+#define SET_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw,x) \
+ (fw)->flags.using_default_inactive_window_font = !!(x)
+#define SETM_USING_DEFAULT_INACTIVE_WINDOW_FONT(fw,x) \
+ (fw)->flag_mask.using_default_inactive_window_font = !!(x)
#define USING_DEFAULT_ICON_FONT(fw) \
((fw)->flags.using_default_icon_font)
#define SET_USING_DEFAULT_ICON_FONT(fw,x) \
--
2.3.6