summarylogtreecommitdiffstats
path: root/14-Hover.patch
blob: b6a705a0d8922f9e013531cf092187d43e4a92a1 (plain)
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
diff --unified --recursive --text fvwm-2.6.9/fvwm/borders.c fvwm-patched/fvwm/borders.c
--- fvwm-2.6.9/fvwm/borders.c	2020-08-21 16:16:28.114047517 -0600
+++ fvwm-patched/fvwm/borders.c	2020-08-21 16:34:52.530676541 -0600
@@ -58,6 +58,7 @@
 /* ---------------------------- imports ------------------------------------ */
 
 extern Window PressedW;
+extern Window HoverW;
 
 /* ---------------------------- included code files ------------------------ */
 
@@ -235,6 +236,7 @@
 	unsigned clear_bmask : NUMBER_OF_TITLE_BUTTONS;
 	unsigned draw_bmask : NUMBER_OF_TITLE_BUTTONS;
 	unsigned max_bmask : NUMBER_OF_TITLE_BUTTONS;
+	unsigned hover_bmask : NUMBER_OF_TITLE_BUTTONS;
 	ButtonState bstate[NUMBER_OF_TITLE_BUTTONS];
 	unsigned is_title_pressed : 1;
 	unsigned is_title_lit : 1;
@@ -340,8 +342,12 @@
 
 /* rules to get button state */
 static ButtonState border_flags_to_button_state(
-	int is_pressed, int is_lit, int is_toggled)
+	int is_pressed, int is_lit, int is_toggled, int is_hover)
 {
+	if (is_lit && is_hover && Scr.gs.use_hover_buttons)
+	{
+		return BS_ActiveHover;
+	}
 	if (!is_lit && Scr.gs.use_inactive_buttons)
 	{
 		if (is_pressed && Scr.gs.use_inactive_down_buttons)
@@ -862,7 +868,7 @@
 	/* check if state changed */
 	old_state = border_flags_to_button_state(
 		(fw->decor_state.parts_inverted & PART_TITLE),
-		(fw->decor_state.parts_lit & PART_TITLE), 0);
+		(fw->decor_state.parts_lit & PART_TITLE), 0, 0);
 	if (old_state != td->tbstate.tstate)
 	{
 		draw_parts |= PART_TITLE;
@@ -886,7 +892,8 @@
 		old_state = border_flags_to_button_state(
 			(fw->decor_state.buttons_inverted & mask),
 			(fw->decor_state.buttons_lit & mask),
-			(fw->decor_state.buttons_toggled & mask));
+			(fw->decor_state.buttons_toggled & mask),
+			(fw->decor_state.buttons_hover & mask));
 		if (old_state != td->tbstate.bstate[i])
 		{
 			draw_parts |= PART_BUTTONS;
@@ -4392,6 +4399,7 @@
 	fw->decor_state.buttons_inverted = td->tbstate.pressed_bmask;
 	fw->decor_state.buttons_lit = td->tbstate.lit_bmask;
 	fw->decor_state.buttons_toggled = td->tbstate.toggled_bmask;
+	fw->decor_state.buttons_hover = td->tbstate.hover_bmask;
 
 	return;
 }
@@ -4660,13 +4668,18 @@
 		{
 			tbstate->toggled_bmask |= mask;
 		}
+		if (FW_W_BUTTON(fw, i) == HoverW)
+		{
+			tbstate->hover_bmask |= mask;
+		}
 		tbstate->bstate[i] = border_flags_to_button_state(
 			tbstate->pressed_bmask & mask,
 			tbstate->lit_bmask & mask,
-			tbstate->toggled_bmask & mask);
+			tbstate->toggled_bmask & mask,
+			tbstate->hover_bmask & mask);
 	}
 	tbstate->tstate = border_flags_to_button_state(
-		tbstate->is_title_pressed, tbstate->is_title_lit, 0);
+		tbstate->is_title_pressed, tbstate->is_title_lit, 0, 0);
 }
 
 static window_parts border_get_titlebar_descr(
@@ -4931,6 +4944,7 @@
 		fw->decor_state.buttons_lit = 0;
 		fw->decor_state.buttons_inverted = 0;
 		fw->decor_state.buttons_toggled = 0;
+		fw->decor_state.buttons_hover = 0;
 		return;
 	}
 	memset(&td, 0, sizeof(td));
@@ -4982,6 +4996,7 @@
 		fw->decor_state.buttons_toggled =
 			(fw->decor_state.buttons_toggled &
 			 ~td.tbstate.max_bmask) | td.tbstate.toggled_bmask;
+		fw->decor_state.buttons_hover &= td.tbstate.hover_bmask;
 	}
 
 	return;
@@ -5072,11 +5087,12 @@
 	ButtonState bs;
 	int is_pressed;
 	int is_toggled;
+	int is_hover;
 	int i;
 
 	/* title */
 	is_pressed = (FW_W_TITLE(fw) == PressedW);
-	bs = border_flags_to_button_state(is_pressed, has_focus, 0);
+	bs = border_flags_to_button_state(is_pressed, has_focus, 0, 0);
 	if (DFS_USE_BORDER_STYLE(TB_STATE(GetDecor(fw, titlebar))[bs].style))
 	{
 		return 1;
@@ -5089,8 +5105,9 @@
 		}
 		is_pressed = (FW_W_BUTTON(fw, i) == PressedW);
 		is_toggled = (is_button_toggled(fw, i) == True);
+		is_hover = (FW_W_BUTTON(fw, i) == HoverW);
 		bs = border_flags_to_button_state(
-			is_pressed, (has_focus == True), is_toggled);
+			is_pressed, (has_focus == True), is_toggled, is_hover);
 		if (DFS_USE_BORDER_STYLE(
 			    TB_STATE(GetDecor(fw, buttons[i]))[bs].style))
 		{
@@ -5551,6 +5568,7 @@
 				DEFAULT_USE_INACTIVE_BUTTONS;
 			Scr.gs.use_inactive_down_buttons =
 				DEFAULT_USE_INACTIVE_DOWN_BUTTONS;
+			Scr.gs.use_hover_buttons = 0;
 			return;
 		}
 		first = False;
@@ -5572,6 +5590,12 @@
 				action, &action,
 				DEFAULT_USE_INACTIVE_DOWN_BUTTONS, True);
 		}
+		else if (StrEquals("hover", token))
+		{
+			Scr.gs.use_hover_buttons = ParseToggleArgument(
+				action, &action,
+				0, True);
+		}
 		else
 		{
 			Scr.gs.use_active_down_buttons =
@@ -5580,6 +5604,7 @@
 				DEFAULT_USE_INACTIVE_BUTTONS;
 			Scr.gs.use_inactive_down_buttons =
 				DEFAULT_USE_INACTIVE_DOWN_BUTTONS;
+			Scr.gs.use_hover_buttons = 0;
 			fvwm_msg(ERR, "cmd_button_state",
 				 "Unknown button state %s", token);
 			return;
Only in fvwm-patched/fvwm: borders.c.orig
diff --unified --recursive --text fvwm-2.6.9/fvwm/builtins.c fvwm-patched/fvwm/builtins.c
--- fvwm-2.6.9/fvwm/builtins.c	2020-08-21 16:16:28.114047517 -0600
+++ fvwm-patched/fvwm/builtins.c	2020-08-21 16:34:52.530676541 -0600
@@ -94,12 +94,16 @@
 {
 	"ActiveUp",
 	"ActiveDown",
+	"ActiveHover",
 	"InactiveUp",
 	"InactiveDown",
+	"InactiveHover",
 	"ToggledActiveUp",
 	"ToggledActiveDown",
+	"ToggledActiveHover",
 	"ToggledInactiveUp",
 	"ToggledInactiveDown",
+	"ToggledInactiveHover",
 	"Active",
 	"Inactive",
 	"ToggledActive",
@@ -110,10 +114,13 @@
 	"AllInactive",
 	"AllUp",
 	"AllDown",
+	"AllHover",
 	"AllActiveUp",
 	"AllActiveDown",
+	"AllActiveHover",
 	"AllInactiveUp",
 	"AllInactiveDown",
+	"AllInactiveHover",
 	NULL
 };
 
Only in fvwm-patched/fvwm: builtins.c.orig
diff --unified --recursive --text fvwm-2.6.9/fvwm/events.c fvwm-patched/fvwm/events.c
--- fvwm-2.6.9/fvwm/events.c	2018-05-26 05:35:26.000000000 -0600
+++ fvwm-patched/fvwm/events.c	2020-08-21 16:38:28.601284882 -0600
@@ -184,6 +184,7 @@
 
 int last_event_type = 0;
 Window PressedW = None;
+Window HoverW = None;
 
 /* ---------------------------- local functions ---------------------------- */
 
@@ -1785,6 +1786,23 @@
 	return;
 }
 
+static void redraw_hover(FvwmWindow* fw, Window w)
+{
+	if (fw)
+	{
+		int i;
+		for (i = 0; i < NUMBER_OF_TITLE_BUTTONS; i++)
+		{
+			if (w == FW_W_BUTTON(fw, i))
+			{
+				HoverW = FW_W_BUTTON(fw, i);
+			}
+		}
+		border_redraw_decorations(fw);
+		HoverW = None;
+	}
+}
+
 /* ---------------------------- event handlers ----------------------------- */
 
 void HandleButtonPress(const evh_args_t *ea)
@@ -1980,6 +1998,8 @@
 	ewp = &te->xcrossing;
 ENTER_DBG((stderr, "++++++++ en (%d): fw %p w 0x%08x sw 0x%08x mode 0x%x detail 0x%x '%s'\n", ++ecount, fw, (int)ewp->window, (int)ewp->subwindow, ewp->mode, ewp->detail, fw?fw->visible_name:"(none)"));
 
+	redraw_hover(fw, ewp->window);
+
 	if (
 		ewp->window == Scr.Root &&
 		ewp->detail == NotifyInferior && ewp->mode == NotifyNormal)
@@ -2687,6 +2707,8 @@
 
 	DBUG("HandleLeaveNotify", "Routine Entered");
 
+	redraw_hover(fw, te->xcrossing.window);
+
 ENTER_DBG((stderr, "-------- ln (%d): fw %p w 0x%08x sw 0x%08x mode 0x%x detail 0x%x '%s'\n", ++ecount, fw, (int)te->xcrossing.window, (int)te->xcrossing.subwindow, te->xcrossing.mode, te->xcrossing.detail, fw?fw->visible_name:"(none)"));
 	lwp = &te->xcrossing;
 	if (
Only in fvwm-patched/fvwm: events.c.orig
diff --unified --recursive --text fvwm-2.6.9/fvwm/fvwm.h fvwm-patched/fvwm/fvwm.h
--- fvwm-2.6.9/fvwm/fvwm.h	2020-08-21 16:11:42.983734347 -0600
+++ fvwm-patched/fvwm/fvwm.h	2020-08-21 16:34:52.534676586 -0600
@@ -827,6 +827,7 @@
 		unsigned buttons_lit : NUMBER_OF_TITLE_BUTTONS;
 		unsigned buttons_inverted : NUMBER_OF_TITLE_BUTTONS;
 		unsigned buttons_toggled : NUMBER_OF_TITLE_BUTTONS;
+		unsigned buttons_hover : NUMBER_OF_TITLE_BUTTONS;
 		unsigned parts_drawn : 12;
 		unsigned parts_lit : 12;
 		unsigned parts_inverted : 12;
diff --unified --recursive --text fvwm-2.6.9/fvwm/screen.h fvwm-patched/fvwm/screen.h
--- fvwm-2.6.9/fvwm/screen.h	2020-08-21 16:16:28.118047433 -0600
+++ fvwm-patched/fvwm/screen.h	2020-08-21 16:34:52.534676586 -0600
@@ -202,12 +202,16 @@
 	BS_All = -1,
 	BS_ActiveUp,
 	BS_ActiveDown,
+	BS_ActiveHover,
 	BS_InactiveUp,
 	BS_InactiveDown,
+	BS_InactiveHover,
 	BS_ToggledActiveUp,
 	BS_ToggledActiveDown,
+	BS_ToggledActiveHover,
 	BS_ToggledInactiveUp,
 	BS_ToggledInactiveDown,
+	BS_ToggledInactiveHover,
 	BS_MaxButtonState,
 	BS_MaxButtonStateMask = BS_MaxButtonState - 1,
 	BS_Active,
@@ -220,10 +224,13 @@
 	BS_AllInactive,
 	BS_AllUp,
 	BS_AllDown,
+	BS_AllHover,
 	BS_AllActiveUp,
 	BS_AllActiveDown,
+	BS_AllActiveHover,
 	BS_AllInactiveUp,
 	BS_AllInactiveDown,
+	BS_AllInactiveHover,
 	BS_MaxButtonStateName
 } ButtonState;
 
@@ -511,6 +518,7 @@
 		unsigned use_active_down_buttons : 1;
 		unsigned use_inactive_buttons : 1;
 		unsigned use_inactive_down_buttons : 1;
+		unsigned use_hover_buttons : 1;
 	} gs; /* global style structure */
 	struct
 	{
Only in fvwm-patched/fvwm: screen.h.orig