-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0009-Fvwm-Buttons-Tips.patch
311 lines (298 loc) · 7.99 KB
/
0009-Fvwm-Buttons-Tips.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
From a272f6479ca32bf27e642367dc8e7f5ce41637a7 Mon Sep 17 00:00:00 2001
From: Anupam Srivastava <[email protected]>
Date: Sat, 2 May 2015 14:41:23 +0530
Subject: [PATCH 09/13] Fvwm Buttons Tips
---
modules/FvwmButtons/FvwmButtons.c | 40 ++++++++++++-
modules/FvwmButtons/FvwmButtons.h | 7 +++
modules/FvwmButtons/parse.c | 121 ++++++++++++++++++++++++++++++++++++++
3 files changed, 166 insertions(+), 2 deletions(-)
diff --git a/modules/FvwmButtons/FvwmButtons.c b/modules/FvwmButtons/FvwmButtons.c
index af62349..dcc3c2f 100644
--- a/modules/FvwmButtons/FvwmButtons.c
+++ b/modules/FvwmButtons/FvwmButtons.c
@@ -62,6 +62,7 @@
#include "libs/Colorset.h"
#include "libs/vpacket.h"
#include "libs/FRender.h"
+#include "libs/FTips.h"
#include "libs/fsm.h"
#include "libs/ColorUtils.h"
#include "libs/Graphics.h"
@@ -1047,6 +1048,9 @@ void Loop(void)
tmp.name = NULL;
tmp.name_list = NULL;
+
+ FTipsInit(Dpy);
+
while ( !isTerminated )
{
if (My_FNextEvent(Dpy, &Event))
@@ -1173,6 +1177,10 @@ void Loop(void)
if (!event.xconfigure.send_event &&
Event.xconfigure.window != MyWindow)
continue;
+
+ if(FTipsHandleEvents(Dpy, &event))
+ continue;
+
fev_sanitise_configure_notify(&event.xconfigure);
Event.xconfigure.x = event.xconfigure.x;
Event.xconfigure.y = event.xconfigure.y;
@@ -1216,10 +1224,33 @@ void Loop(void)
case EnterNotify:
b = handle_new_position(
b, Event.xcrossing.x, Event.xcrossing.y);
+
+ if(Event.xcrossing.mode == NotifyNormal)
+ {
+ b = handle_new_position(
+ b, Event.xcrossing.x, Event.xcrossing.y);
+ FTipsOn(Dpy,MyWindow,UberButton->c->tips_config,
+ (void *)UberButton, b->tipslabel,
+ b->x, b->y, Width,Height);
+ FTipsUpdateLabel(Dpy, b->tipslabel);
+ }
break;
case MotionNotify:
+
b = handle_new_position(b, Event.xmotion.x, Event.xmotion.y);
+
+ x = Event.xbutton.x;
+ y = Event.xbutton.y;
+
+ if(b->tipslabel != NULL)
+ {
+ FTipsOn(Dpy,MyWindow,UberButton->c->tips_config, (void *)UberButton, b->tipslabel, x, y, w, h);
+ FTipsUpdateLabel(Dpy, b->tipslabel);
+ } else {
+ FTipsCancel(Dpy);
+ }
+
break;
case LeaveNotify:
@@ -1242,11 +1273,13 @@ void Loop(void)
b = ActiveButton;
ActiveButton = NULL;
RedrawButton(b, DRAW_FORCE, NULL);
+
}
if (CurrentButton)
{
RedrawButton(b, DRAW_FORCE, NULL);
}
+ FTipsCancel(Dpy);
}
break;
@@ -1268,8 +1301,8 @@ void Loop(void)
Window dummy;
XTranslateCoordinates(
- Dpy, Event.xbutton.window, MyWindow, Event.xbutton.x,
- Event.xbutton.y, &x, &y, &dummy);
+ Dpy, Event.xbutton.window, MyWindow, Event.xbutton.x,
+ Event.xbutton.y, &x, &y, &dummy);
}
if (CurrentButton)
{
@@ -1311,7 +1344,10 @@ void Loop(void)
RedrawButton(tmp, DRAW_FORCE, NULL);
}
else
+ {
RedrawButton(b, DRAW_FORCE, NULL);
+ }
+
if (!act)
{
break;
diff --git a/modules/FvwmButtons/FvwmButtons.h b/modules/FvwmButtons/FvwmButtons.h
index 7ae6308..18cdd7e 100644
--- a/modules/FvwmButtons/FvwmButtons.h
+++ b/modules/FvwmButtons/FvwmButtons.h
@@ -38,6 +38,8 @@
#include "libs/fvwmlib.h"
#include "libs/Picture.h"
#include "libs/Flocale.h"
+#include "libs/FTips.h"
+#define FONT_STRING "-*-fixed-medium-r-normal--13-*"
/* ------------------------------- structs --------------------------------- */
@@ -82,6 +84,7 @@ typedef struct
unsigned b_PressIcon : 1; /* Use alternate Icon on press */
unsigned b_PressColorset : 1; /* Use alternate Colorset on press */
unsigned b_PressTitle : 1; /* Use alternate Title text on press */
+ unsigned b_UseTips : 1; /* Whether to use tips or not. */
} flags_type;
/* Flags for b->swallow */
@@ -131,6 +134,9 @@ struct container_info_struct
int colorset; /* b_Colorset */
int activeColorset; /* b_ActiveColorset */
int pressColorset; /* b_PressColorset */
+ char *tipsfont; /* b_TipsFont*/
+ ftips_config *tips_config; /* Struct that holds tips info.*/
+
Pixel fc; /* b_Fore */
Pixel bc, hc, sc; /* b_Back && !b_IconBack */
FvwmPicture *backicon; /* b_Back && b_IconBack */
@@ -187,6 +193,7 @@ struct button_info_struct
FvwmPicture *pressicon; /* b_PressIcon */
int activeColorset; /* b_ActiveColorset */
int pressColorset; /* b_PressColorset */
+ char *tipslabel; /* b_TipsLabel */
Window IconWin; /* b_Swallow */
Window PanelWin; /* b_Panel */
Window BackIconWin; /* b_Back && b_IconBack */
diff --git a/modules/FvwmButtons/parse.c b/modules/FvwmButtons/parse.c
index ddeedb1..b522d4c 100644
--- a/modules/FvwmButtons/parse.c
+++ b/modules/FvwmButtons/parse.c
@@ -889,6 +889,7 @@ static void ParseButton(button_info **uberb, char *s)
"presstitle",
"activecolorset",
"presscolorset",
+ "tipslabel",
"top",
NULL
};
@@ -1612,7 +1613,30 @@ static void ParseButton(button_info **uberb, char *s)
b->flags.b_ActiveColorset = 0;
}
break;
+ /* --------- TipsLabel ---------*/
+ case 28:
+ s = trimleft(s);
+ t = seekright(&s);
+ if(ub->c->flags.b_UseTips)
+ {
+ if (*s == '(')
+ {
+ fprintf(stderr,
+ "%s: justification not allowed "
+ "for TipsLabel.\n", MyName);
+ }
+ if (t && *t && (t[0] != '-' || t[1] != 0))
+ {
+ if (b->tipslabel != NULL)
+ {
+ free(b->tipslabel);
+ } else {
+ b->tipslabel = t;
+ }
+ }
+ }
+ break;
/* --------------- --------------- */
case 26: /* PressColorset */
i = strtol(s, &t, 10);
@@ -1784,6 +1808,14 @@ static void ParseConfigLine(button_info **ubb, char *s)
"colorset",
"activecolorset",
"presscolorset",
+ "usetips",
+ "tipsfont",
+ "tipsdelay",
+ "tipscolorset",
+ "tipsborderwidth",
+ "tipsplacement",
+ "tipsjustification",
+ "tipsoffset",
NULL
};
int i, j, k;
@@ -1931,7 +1963,96 @@ static void ParseConfigLine(button_info **ubb, char *s)
ub->c->flags.b_PressColorset = 0;
}
break;
+ case 15: /* UseTips */
+ /* We're using tips.*/
+ ub->c->flags.b_UseTips = 1;
+
+ /* Set the defaults up. */
+ ub->c->tips_config = FTipsNewConfig();
+
+ /* Include fonts. */
+ CopyStringWithQuotes(&ub->c->tipsfont,FONT_STRING);
+ ub->c->tips_config->Ffont = FlocaleLoadFont(Dpy,
+ ub->c->tipsfont, MyName);
+ break;
+ case 16: /* TipsFont */
+ if(ub->c->flags.b_UseTips)
+ {
+ CopyStringWithQuotes(&ub->c->tipsfont,s);
+
+ ub->c->tips_config->Ffont = FlocaleLoadFont(Dpy, ub->c->tipsfont,
+ MyName);
+ }
+ break;
+ case 17: /*TipsDelay */
+ if(ub->c->flags.b_UseTips)
+ {
+ i = sscanf(s, "%d %d", &j, &k);
+ if( i > 0)
+ {
+ /* Then only one value was given. Set the
+ * mapped_delay option to this given value
+ * also since it's optional.
+ */
+ ub->c->tips_config->delay = ub->c->tips_config->mapped_delay = j;
+ }
+ if( i > 1)
+ {
+ /* Two values passed in. We only need to
+ * change the value for mapped_delay here.
+ */
+
+ ub->c->tips_config->mapped_delay = k;
+
+ }
+ }
+ break;
+ case 18: /* TipsColorset */
+ if (ub->c->flags.b_UseTips)
+ {
+ i = sscanf(s, "%d", &j);
+ if (i > 0)
+ {
+ ub->c->tips_config->colorset = j;
+ AllocColorset(j);
+ }
+ }
+ break;
+ case 19: /* TipsBorderWidth */
+ if (ub->c->flags.b_UseTips)
+ {
+ i = sscanf(s, "%d", &j);
+ if(i > 0)
+ {
+ ub->c->tips_config->border_width = j;
+ }
+ }
+ break;
+ case 20: /* TipsPlacement */
+ if(ub->c->flags.b_UseTips)
+ {
+ s = trimleft(s);
+
+ /* Options ... */
+ if(!strcasecmp(s, "up"))
+ {
+ i = FTIPS_PLACEMENT_UP;
+ } else if(!strcasecmp(s, "down")) {
+ i = FTIPS_PLACEMENT_DOWN;
+ } else if(!strcasecmp(s, "left")) {
+ i = FTIPS_PLACEMENT_LEFT;
+ } else if(!strcasecmp(s, "right")) {
+ i = FTIPS_PLACEMENT_RIGHT;
+ } else if(!strcasecmp(s, "updown")) {
+ i = FTIPS_PLACEMENT_AUTO_UPDOWN;
+ } else if(!strcasecmp(s, "leftright")) {
+ i = FTIPS_PLACEMENT_AUTO_LEFTRIGHT;
+ }
+
+ ub->c->tips_config->placement = i;
+ }
+ break;
default:
s = trimleft(s);
ParseButton(ubb, s);
--
2.3.6