updated on Tue Jan 10 00:10:07 UTC 2012
[aur-mirror.git] / fvwm+ / 12-FvwmButtonsTips.patch
blob7c6516ff6182003452934efcc939107aa720764c
1 diff -U3 -r libs/FTips.c libs/FTips.c
2 --- libs/FTips.c 2007-01-27 12:33:16.000000000 +0100
3 +++ libs/FTips.c 2011-12-09 21:42:01.022148670 +0100
4 @@ -505,7 +505,7 @@
5 if (fc == NULL)
7 fc = default_config;
8 - }
9 + }
10 current_config = fc;
12 if (label != NULL)
13 diff -U3 -r modules/FvwmButtons/FvwmButtons.c modules/FvwmButtons/FvwmButtons.c
14 --- modules/FvwmButtons/FvwmButtons.c 2011-08-27 23:51:29.000000000 +0200
15 +++ modules/FvwmButtons/FvwmButtons.c 2011-12-09 21:42:01.022148670 +0100
16 @@ -62,6 +62,7 @@
17 #include "libs/Colorset.h"
18 #include "libs/vpacket.h"
19 #include "libs/FRender.h"
20 +#include "libs/FTips.h"
21 #include "libs/fsm.h"
22 #include "libs/ColorUtils.h"
23 #include "libs/Graphics.h"
24 @@ -907,6 +908,7 @@
25 button_info *tmp = ActiveButton;
26 ActiveButton = b;
27 RedrawButton(tmp, DRAW_FORCE, NULL);
30 if (
31 b->flags.b_ActiveIcon ||
32 @@ -1061,6 +1063,9 @@
34 tmp.name = NULL;
35 tmp.name_list = NULL;
37 + FTipsInit(Dpy);
39 while ( !isTerminated )
41 if (My_FNextEvent(Dpy, &Event))
42 @@ -1186,6 +1191,10 @@
43 if (!event.xconfigure.send_event &&
44 Event.xconfigure.window != MyWindow)
45 continue;
47 + if(FTipsHandleEvents(Dpy, &event))
48 + continue;
50 Event.xconfigure.x = event.xconfigure.x;
51 Event.xconfigure.y = event.xconfigure.y;
52 Event.xconfigure.send_event = True;
53 @@ -1228,10 +1237,33 @@
54 case EnterNotify:
55 b = handle_new_position(
56 b, Event.xcrossing.x, Event.xcrossing.y);
58 + if(Event.xcrossing.mode == NotifyNormal)
59 + {
60 + b = handle_new_position(
61 + b, Event.xcrossing.x, Event.xcrossing.y);
62 + FTipsOn(Dpy,MyWindow,UberButton->c->tips_config,
63 + (void *)UberButton, b->tipslabel,
64 + b->x, b->y, Width,Height);
65 + FTipsUpdateLabel(Dpy, b->tipslabel);
66 + }
67 break;
69 case MotionNotify:
71 b = handle_new_position(b, Event.xmotion.x, Event.xmotion.y);
73 + x = Event.xbutton.x;
74 + y = Event.xbutton.y;
76 + if(b->tipslabel != NULL)
77 + {
78 + FTipsOn(Dpy,MyWindow,UberButton->c->tips_config, (void *)UberButton, b->tipslabel, x, y, w, h);
79 + FTipsUpdateLabel(Dpy, b->tipslabel);
80 + } else {
81 + FTipsCancel(Dpy);
82 + }
84 break;
86 case LeaveNotify:
87 @@ -1254,11 +1286,13 @@
88 b = ActiveButton;
89 ActiveButton = NULL;
90 RedrawButton(b, DRAW_FORCE, NULL);
93 if (CurrentButton)
95 RedrawButton(b, DRAW_FORCE, NULL);
97 + FTipsCancel(Dpy);
99 break;
101 @@ -1280,8 +1314,8 @@
102 Window dummy;
104 XTranslateCoordinates(
105 - Dpy, Event.xbutton.window, MyWindow, Event.xbutton.x,
106 - Event.xbutton.y, &x, &y, &dummy);
107 + Dpy, Event.xbutton.window, MyWindow, Event.xbutton.x,
108 + Event.xbutton.y, &x, &y, &dummy);
110 if (CurrentButton)
112 @@ -1323,7 +1357,10 @@
113 RedrawButton(tmp, DRAW_FORCE, NULL);
115 else
117 RedrawButton(b, DRAW_FORCE, NULL);
120 if (!act)
122 break;
123 diff -U3 -r modules/FvwmButtons/FvwmButtons.h modules/FvwmButtons/FvwmButtons.h
124 --- modules/FvwmButtons/FvwmButtons.h 2008-04-05 12:02:45.000000000 +0200
125 +++ modules/FvwmButtons/FvwmButtons.h 2011-12-09 21:42:01.022148670 +0100
126 @@ -38,6 +38,8 @@
127 #include "libs/fvwmlib.h"
128 #include "libs/Picture.h"
129 #include "libs/Flocale.h"
130 +#include "libs/FTips.h"
131 +#define FONT_STRING "-*-fixed-medium-r-normal--13-*"
133 /* ------------------------------- structs --------------------------------- */
135 @@ -82,6 +84,7 @@
136 unsigned b_PressIcon : 1; /* Use alternate Icon on press */
137 unsigned b_PressColorset : 1; /* Use alternate Colorset on press */
138 unsigned b_PressTitle : 1; /* Use alternate Title text on press */
139 + unsigned b_UseTips : 1; /* Whether to use tips or not. */
140 } flags_type;
142 /* Flags for b->swallow */
143 @@ -131,6 +134,9 @@
144 int colorset; /* b_Colorset */
145 int activeColorset; /* b_ActiveColorset */
146 int pressColorset; /* b_PressColorset */
147 + char *tipsfont; /* b_TipsFont*/
148 + ftips_config *tips_config; /* Struct that holds tips info.*/
150 Pixel fc; /* b_Fore */
151 Pixel bc, hc, sc; /* b_Back && !b_IconBack */
152 FvwmPicture *backicon; /* b_Back && b_IconBack */
153 @@ -187,6 +193,7 @@
154 FvwmPicture *pressicon; /* b_PressIcon */
155 int activeColorset; /* b_ActiveColorset */
156 int pressColorset; /* b_PressColorset */
157 + char *tipslabel; /* b_TipsLabel */
158 Window IconWin; /* b_Swallow */
159 Window PanelWin; /* b_Panel */
160 Window BackIconWin; /* b_Back && b_IconBack */
161 diff -U3 -r modules/FvwmButtons/parse.c modules/FvwmButtons/parse.c
162 --- modules/FvwmButtons/parse.c 2008-04-05 12:02:45.000000000 +0200
163 +++ modules/FvwmButtons/parse.c 2011-12-09 21:42:01.025481917 +0100
164 @@ -889,6 +889,7 @@
165 "presstitle",
166 "activecolorset",
167 "presscolorset",
168 + "tipslabel",
169 "top",
170 NULL
172 @@ -1612,7 +1613,33 @@
173 b->flags.b_ActiveColorset = 0;
175 break;
176 + /* --------- TipsLabel ---------*/
177 + case 28:
178 + s = trimleft(s);
179 + t = seekright(&s);
180 + if(ub->c->flags.b_UseTips)
182 + if (*s == '(')
184 + fprintf(stderr,
185 + "%s: justification not allowed "
186 + "for TipsLabel.\n", MyName);
191 + if (t && *t && (t[0] != '-' || t[1] != 0))
193 + if (b->tipslabel != NULL)
195 + free(b->tipslabel);
196 + } else {
197 + b->tipslabel = t;
202 + break;
203 /* --------------- --------------- */
204 case 26: /* PressColorset */
205 i = strtol(s, &t, 10);
206 @@ -1784,6 +1811,14 @@
207 "colorset",
208 "activecolorset",
209 "presscolorset",
210 + "usetips",
211 + "tipsfont",
212 + "tipsdelay",
213 + "tipscolorset",
214 + "tipsborderwidth",
215 + "tipsplacement",
216 + "tipsjustification",
217 + "tipsoffset",
218 NULL
220 int i, j, k;
221 @@ -1931,7 +1966,97 @@
222 ub->c->flags.b_PressColorset = 0;
224 break;
225 + case 15: /* UseTips */
226 + /* We're using tips.*/
227 + ub->c->flags.b_UseTips = 1;
229 + /* Set the defaults up. */
230 + ub->c->tips_config = FTipsNewConfig();
232 + /* Include fonts. */
233 + CopyStringWithQuotes(&ub->c->tipsfont,FONT_STRING);
234 + ub->c->tips_config->Ffont = FlocaleLoadFont(Dpy,
235 + ub->c->tipsfont, MyName);
236 + break;
237 + case 16: /* TipsFont */
238 + if(ub->c->flags.b_UseTips)
240 + CopyStringWithQuotes(&ub->c->tipsfont,s);
242 + ub->c->tips_config->Ffont = FlocaleLoadFont(Dpy, ub->c->tipsfont,
243 + MyName);
246 + break;
247 + case 17: /*TipsDelay */
248 + if(ub->c->flags.b_UseTips)
250 + i = sscanf(s, "%d %d", &j, &k);
251 + if( i > 0)
253 + /* Then only one value was given. Set the
254 + * mapped_delay option to this given value
255 + * also since it's optional.
256 + */
257 + ub->c->tips_config->delay = ub->c->tips_config->mapped_delay = j;
259 + if( i > 1)
261 + /* Two values passed in. We only need to
262 + * change the value for mapped_delay here.
263 + */
265 + ub->c->tips_config->mapped_delay = k;
269 + break;
270 + case 18: /* TipsColorset */
271 + if (ub->c->flags.b_UseTips)
273 + i = sscanf(s, "%d", &j);
274 + if (i > 0)
276 + ub->c->tips_config->colorset = j;
277 + AllocColorset(j);
280 + break;
281 + case 19: /* TipsBorderWidth */
282 + if (ub->c->flags.b_UseTips)
284 + i = sscanf(s, "%d", &j);
286 + if(i > 0)
288 + ub->c->tips_config->border_width = j;
291 + break;
292 + case 20: /* TipsPlacement */
293 + if(ub->c->flags.b_UseTips)
295 + s = trimleft(s);
297 + /* Options ... */
298 + if(!strcasecmp(s, "up"))
300 + i = FTIPS_PLACEMENT_UP;
301 + } else if(!strcasecmp(s, "down")) {
302 + i = FTIPS_PLACEMENT_DOWN;
303 + } else if(!strcasecmp(s, "left")) {
304 + i = FTIPS_PLACEMENT_LEFT;
305 + } else if(!strcasecmp(s, "right")) {
306 + i = FTIPS_PLACEMENT_RIGHT;
307 + } else if(!strcasecmp(s, "updown")) {
308 + i = FTIPS_PLACEMENT_AUTO_UPDOWN;
309 + } else if(!strcasecmp(s, "leftright")) {
310 + i = FTIPS_PLACEMENT_AUTO_LEFTRIGHT;
313 + ub->c->tips_config->placement = i;
315 + break;
316 default:
317 s = trimleft(s);
318 ParseButton(ubb, s);