2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "libs/fvwmlib.h"
20 #include "libs/ColorUtils.h"
21 #include "libs/Strings.h"
27 * Fonction pour Swallow
30 void DrawRelief(struct XObj
*xobj
)
41 segm
[0].x2
=xobj
->x
+xobj
->width
+i
-2;
46 segm
[1].y2
=xobj
->y
+xobj
->height
+i
-2;
49 dpy
,xobj
->gc
,xobj
->TabColor
[shad
]);
52 dpy
,xobj
->gc
,xobj
->TabColor
[hili
]);
53 XDrawSegments(dpy
,x11base
->win
,xobj
->gc
,segm
,2);
56 segm
[0].y1
=xobj
->y
+xobj
->height
+i
-1;
57 segm
[0].x2
=xobj
->x
+xobj
->width
+i
-1;
58 segm
[0].y2
=xobj
->y
+xobj
->height
+i
-1;
59 segm
[1].x1
=xobj
->x
+xobj
->width
+i
-1;
61 segm
[1].x2
=xobj
->x
+xobj
->width
+i
-1;
62 segm
[1].y2
=xobj
->y
+xobj
->height
+i
-1;
65 dpy
,xobj
->gc
,xobj
->TabColor
[hili
]);
68 dpy
,xobj
->gc
,xobj
->TabColor
[shad
]);
69 XDrawSegments(dpy
,x11base
->win
,xobj
->gc
,segm
,2);
75 void InitSwallow(struct XObj
*xobj
)
78 XSetWindowAttributes Attr
;
79 static char *my_sm_env
= NULL
;
80 static char *orig_sm_env
= NULL
;
82 static Bool sm_initialized
= False
;
83 static Bool session_manager
= False
;
86 /* Enregistrement des couleurs et de la police */
87 if (xobj
->colorset
>= 0) {
88 xobj
->TabColor
[fore
] = Colorset
[xobj
->colorset
].fg
;
89 xobj
->TabColor
[back
] = Colorset
[xobj
->colorset
].bg
;
90 xobj
->TabColor
[hili
] = Colorset
[xobj
->colorset
].hilite
;
91 xobj
->TabColor
[shad
] = Colorset
[xobj
->colorset
].shadow
;
93 xobj
->TabColor
[fore
] = GetColor(xobj
->forecolor
);
94 xobj
->TabColor
[back
] = GetColor(xobj
->backcolor
);
95 xobj
->TabColor
[hili
] = GetColor(xobj
->hilicolor
);
96 xobj
->TabColor
[shad
] = GetColor(xobj
->shadcolor
);
100 xobj
->win
=XCreateWindow(dpy
,*xobj
->ParentWin
,
101 -1000,-1000,xobj
->width
,xobj
->height
,0,
102 CopyFromParent
,InputOutput
,CopyFromParent
,
105 /* Redimensionnement du widget */
111 if (xobj
->swallow
== NULL
)
113 fprintf(stderr
,"Error\n");
119 /* use sm only when needed */
120 sm_initialized
= True
;
121 orig_sm_env
= getenv("SESSION_MANAGER");
122 if (orig_sm_env
&& !StrEquals("", orig_sm_env
))
124 /* this set the new SESSION_MANAGER env */
125 session_manager
= fsm_init(x11base
->TabArg
[0]);
129 if (!session_manager
)
131 SendText(fd
, xobj
->swallow
, 0);
135 if (my_sm_env
== NULL
)
137 my_sm_env
= getenv("SESSION_MANAGER");
138 len
= 45 + strlen(my_sm_env
) + strlen(orig_sm_env
);
141 cmd
= safemalloc(len
+ strlen(xobj
->swallow
));
144 "FSMExecFuncWithSessionManagment \"%s\" \"%s\" \"%s\"",
145 my_sm_env
, xobj
->swallow
, orig_sm_env
);
146 SendText(fd
, cmd
, 0);
150 void DestroySwallow(struct XObj
*xobj
)
152 /* Arrete le programme swallow */
154 XKillClient(dpy
, xobj
->win
);
158 void DrawSwallow(struct XObj
*xobj
, XEvent
*evp
)
163 void EvtMouseSwallow(struct XObj
*xobj
,XButtonEvent
*EvtButton
)
167 void EvtKeySwallow(struct XObj
*xobj
,XKeyEvent
*EvtKey
)
171 /* Recupere le pointeur de la fenetre Swallow */
172 void CheckForHangon(struct XObj
*xobj
,unsigned long *body
)
176 cbody
=(char*)calloc(strlen((char *)&body
[3]) + 1,sizeof(char));
177 sprintf(cbody
,"%s",(char *)&body
[3]);
178 if(strcmp(cbody
,xobj
->title
)==0)
180 xobj
->win
= (Window
)body
[0];
182 xobj
->title
=(char*)calloc(sizeof(char),20);
183 sprintf(xobj
->title
,"No window");
184 XUnmapWindow(dpy
,xobj
->win
);
185 XSetWindowBorderWidth(dpy
,xobj
->win
,0);
190 void swallow(struct XObj
*xobj
,unsigned long *body
)
194 if(xobj
->win
== (Window
)body
[0])
197 dpy
,xobj
->win
,*xobj
->ParentWin
,xobj
->x
,xobj
->y
);
198 XResizeWindow(dpy
,xobj
->win
,xobj
->width
,xobj
->height
);
199 XMapWindow(dpy
,xobj
->win
);
201 cmd
,"PropertyChange %u %u %lu %lu",
202 MX_PROPERTY_CHANGE_SWALLOW
, 1, xobj
->win
,
203 (x11base
->swallower_win
)?
204 x11base
->swallower_win
:x11base
->win
);
206 fsm_proxy(dpy
, xobj
->win
, getenv("SESSION_MANAGER"));
210 void ProcessMsgSwallow(
211 struct XObj
*xobj
,unsigned long type
,unsigned long *body
)
221 CheckForHangon(xobj
,body
);