summarylogtreecommitdiffstats
path: root/12-FvwmButtonsTips.patch
blob: 7c6516ff6182003452934efcc939107aa720764c (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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
diff -U3 -r libs/FTips.c libs/FTips.c
--- libs/FTips.c	2007-01-27 12:33:16.000000000 +0100
+++ libs/FTips.c	2011-12-09 21:42:01.022148670 +0100
@@ -505,7 +505,7 @@
 	if (fc == NULL)
 	{
 		fc = default_config;
-	}
+	} 
 	current_config = fc;
 
 	if (label != NULL)
diff -U3 -r modules/FvwmButtons/FvwmButtons.c modules/FvwmButtons/FvwmButtons.c
--- modules/FvwmButtons/FvwmButtons.c	2011-08-27 23:51:29.000000000 +0200
+++ modules/FvwmButtons/FvwmButtons.c	2011-12-09 21:42:01.022148670 +0100
@@ -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"
@@ -907,6 +908,7 @@
 			button_info *tmp = ActiveButton;
 			ActiveButton = b;
 			RedrawButton(tmp, DRAW_FORCE, NULL);
+			
 		}
 		if (
 			b->flags.b_ActiveIcon ||
@@ -1061,6 +1063,9 @@
 
 	tmp.name = NULL;
 	tmp.name_list = NULL;
+
+	FTipsInit(Dpy);
+
 	while ( !isTerminated )
 	{
 		if (My_FNextEvent(Dpy, &Event))
@@ -1186,6 +1191,10 @@
 	  if (!event.xconfigure.send_event &&
 	      Event.xconfigure.window != MyWindow)
 	    continue;
+
+	  if(FTipsHandleEvents(Dpy, &event))
+		  continue;
+
 	  Event.xconfigure.x = event.xconfigure.x;
 	  Event.xconfigure.y = event.xconfigure.y;
 	  Event.xconfigure.send_event = True;
@@ -1228,10 +1237,33 @@
 	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:
@@ -1254,11 +1286,13 @@
 				b = ActiveButton;
 				ActiveButton = NULL;
 				RedrawButton(b, DRAW_FORCE, NULL);
+
 			}
 			if (CurrentButton)
 			{
 				RedrawButton(b, DRAW_FORCE, NULL);
 			}
+			FTipsCancel(Dpy);
 		}
 		break;
 
@@ -1280,8 +1314,8 @@
 	  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)
 	{
@@ -1323,7 +1357,10 @@
 	  RedrawButton(tmp, DRAW_FORCE, NULL);
 	}
 	else
+	{
 	  RedrawButton(b, DRAW_FORCE, NULL);
+	}
+	  
 	if (!act)
 	{
 	  break;
diff -U3 -r modules/FvwmButtons/FvwmButtons.h modules/FvwmButtons/FvwmButtons.h
--- modules/FvwmButtons/FvwmButtons.h	2008-04-05 12:02:45.000000000 +0200
+++ modules/FvwmButtons/FvwmButtons.h	2011-12-09 21:42:01.022148670 +0100
@@ -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 @@
 	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 @@
 	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 @@
 	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 -U3 -r modules/FvwmButtons/parse.c modules/FvwmButtons/parse.c
--- modules/FvwmButtons/parse.c	2008-04-05 12:02:45.000000000 +0200
+++ modules/FvwmButtons/parse.c	2011-12-09 21:42:01.025481917 +0100
@@ -889,6 +889,7 @@
 			"presstitle",
 			"activecolorset",
 			"presscolorset",
+			"tipslabel",
 			"top",
 			NULL
 		};
@@ -1612,7 +1613,33 @@
 					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 +1811,14 @@
 		"colorset",
 		"activecolorset",
 		"presscolorset",
+		"usetips",
+		"tipsfont",
+		"tipsdelay",
+		"tipscolorset",
+		"tipsborderwidth",
+		"tipsplacement",
+		"tipsjustification",
+		"tipsoffset",
 		NULL
 	};
 	int i, j, k;
@@ -1931,7 +1966,97 @@
 			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);