481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
1 |
/*
|
2 |
* Routines for un/masking the whole screen.
|
|
3 |
*
|
|
4 |
* Used in showing the WelcomeWindow splash screen.
|
|
5 |
*/
|
|
6 |
||
7 |
#include "ctwm.h" |
|
8 |
||
9 |
#include <sys/select.h> |
|
10 |
||
11 |
#include "screen.h" |
|
12 |
#include "icons.h" |
|
13 |
#include "cursor.h" |
|
14 |
#include "image.h" |
|
15 |
#include "gram.tab.h" |
|
524.1.5
by Matthew Fuller
Pull list.h out of screen.h and #include it in the places that need |
16 |
#include "list.h" |
524.1.3
by Matthew Fuller
Pull vscreen.h out of screen.h and #include it directly in the files |
17 |
#include "vscreen.h" |
538.1.3
by Matthew Fuller
Rename the decorations*.h to win_decorations*.h. |
18 |
#include "win_decorations.h" |
523.1.16
by Matthew Fuller
Move visible() into win_utils. |
19 |
#include "win_utils.h" |
510.1.9
by Matthew Fuller
Only stuff left in workmgr is the actual workspace manager stuff. |
20 |
#include "workspace_manager.h" |
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
21 |
|
22 |
#include "mask_screen.h" |
|
23 |
||
24 |
||
25 |
/* Various internal subbits */
|
|
26 |
static void PaintAllDecoration(void); |
|
27 |
||
28 |
||
29 |
/*
|
|
30 |
* Masking and unmasking; our public interface
|
|
31 |
*/
|
|
481.1.17
by Matthew Fuller
Split definitions. |
32 |
void
|
33 |
MaskScreen(char *file) |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
34 |
{
|
35 |
unsigned long valuemask; |
|
36 |
XSetWindowAttributes attributes; |
|
37 |
XEvent event; |
|
38 |
Cursor waitcursor; |
|
39 |
int x, y; |
|
40 |
XColor black; |
|
41 |
||
42 |
NewFontCursor(&waitcursor, "watch"); |
|
43 |
||
570.1.3
by Matthew Fuller
Setting SaveUnder=False on new windows is pointless, because that's |
44 |
valuemask = (CWBackPixel | CWOverrideRedirect | CWEventMask | CWCursor); |
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
45 |
attributes.override_redirect = True; |
46 |
attributes.event_mask = ExposureMask; |
|
47 |
attributes.cursor = waitcursor; |
|
48 |
attributes.background_pixel = Scr->Black; |
|
49 |
Scr->WindowMask = XCreateWindow(dpy, Scr->Root, 0, 0, |
|
505.1.19
by Matthew Fuller
Remove casts from XCreateWindow() calls. Some of these were probably |
50 |
Scr->rootw, |
51 |
Scr->rooth, |
|
52 |
0, |
|
53 |
CopyFromParent, CopyFromParent, |
|
54 |
CopyFromParent, valuemask, |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
55 |
&attributes); |
56 |
XMapWindow(dpy, Scr->WindowMask); |
|
57 |
XMaskEvent(dpy, ExposureMask, &event); |
|
58 |
||
59 |
if(Scr->Monochrome != COLOR) { |
|
60 |
return; |
|
61 |
}
|
|
62 |
||
685.1.19
by Matthew Fuller
Use designated initializer to be more explicit, and to be sure all the |
63 |
ColorPair WelcomeCp = { |
64 |
.fore = Scr->Black, |
|
65 |
.back = Scr->White, |
|
66 |
};
|
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
67 |
Scr->WelcomeCmap = XCreateColormap(dpy, Scr->WindowMask, Scr->d_visual, |
68 |
AllocNone); |
|
69 |
if(! Scr->WelcomeCmap) { |
|
70 |
return; |
|
71 |
}
|
|
72 |
XSetWindowColormap(dpy, Scr->WindowMask, Scr->WelcomeCmap); |
|
73 |
black.red = 0; |
|
74 |
black.green = 0; |
|
75 |
black.blue = 0; |
|
76 |
XAllocColor(dpy, Scr->WelcomeCmap, &black); |
|
77 |
||
78 |
AlternateCmap = Scr->WelcomeCmap; |
|
79 |
if(! file) { |
|
80 |
Scr->WelcomeImage = GetImage("xwd:welcome.xwd", WelcomeCp); |
|
81 |
#ifdef XPM
|
|
82 |
if(Scr->WelcomeImage == None) { |
|
83 |
Scr->WelcomeImage = GetImage("xpm:welcome.xpm", WelcomeCp); |
|
84 |
}
|
|
85 |
#endif
|
|
86 |
}
|
|
87 |
else { |
|
88 |
Scr->WelcomeImage = GetImage(file, WelcomeCp); |
|
89 |
}
|
|
90 |
AlternateCmap = None; |
|
91 |
if(Scr->WelcomeImage == None) { |
|
92 |
return; |
|
93 |
}
|
|
94 |
||
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
95 |
if(0) { |
96 |
// Dummy
|
|
97 |
}
|
|
98 |
#ifdef CAPTIVE
|
|
99 |
else if(CLarg.is_captive) { |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
100 |
XSetWindowColormap(dpy, Scr->WindowMask, Scr->WelcomeCmap); |
101 |
XSetWMColormapWindows(dpy, Scr->Root, &(Scr->WindowMask), 1); |
|
102 |
}
|
|
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
103 |
#endif
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
104 |
else { |
105 |
XInstallColormap(dpy, Scr->WelcomeCmap); |
|
106 |
}
|
|
107 |
||
108 |
Scr->WelcomeGC = XCreateGC(dpy, Scr->WindowMask, 0, NULL); |
|
109 |
x = (Scr->rootw - Scr->WelcomeImage->width) / 2; |
|
110 |
y = (Scr->rooth - Scr->WelcomeImage->height) / 2; |
|
111 |
||
112 |
XSetWindowBackground(dpy, Scr->WindowMask, black.pixel); |
|
113 |
XClearWindow(dpy, Scr->WindowMask); |
|
114 |
XCopyArea(dpy, Scr->WelcomeImage->pixmap, Scr->WindowMask, Scr->WelcomeGC, 0, 0, |
|
115 |
Scr->WelcomeImage->width, Scr->WelcomeImage->height, x, y); |
|
116 |
}
|
|
117 |
||
118 |
||
119 |
||
481.1.17
by Matthew Fuller
Split definitions. |
120 |
void
|
121 |
UnmaskScreen(void) |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
122 |
{
|
123 |
struct timeval timeout; |
|
124 |
Colormap stdcmap = Scr->RootColormaps.cwins[0]->colormap->c; |
|
125 |
Colormap cmap; |
|
126 |
XColor colors [256], stdcolors [256]; |
|
127 |
int i, j, usec; |
|
128 |
||
129 |
usec = 6000; |
|
130 |
timeout.tv_usec = usec % (unsigned long) 1000000; |
|
131 |
timeout.tv_sec = usec / (unsigned long) 1000000; |
|
132 |
||
133 |
if(Scr->WelcomeImage) { |
|
134 |
Pixel pixels [256]; |
|
135 |
||
136 |
cmap = Scr->WelcomeCmap; |
|
137 |
for(i = 0; i < 256; i++) { |
|
138 |
pixels [i] = i; |
|
139 |
colors [i].pixel = i; |
|
140 |
}
|
|
141 |
XQueryColors(dpy, cmap, colors, 256); |
|
142 |
XFreeColors(dpy, cmap, pixels, 256, 0L); |
|
143 |
XFreeColors(dpy, cmap, pixels, 256, 0L); /* Ah Ah */ |
|
144 |
||
145 |
for(i = 0; i < 256; i++) { |
|
146 |
colors [i].pixel = i; |
|
147 |
colors [i].flags = DoRed | DoGreen | DoBlue; |
|
148 |
stdcolors [i].red = colors [i].red; |
|
149 |
stdcolors [i].green = colors [i].green; |
|
150 |
stdcolors [i].blue = colors [i].blue; |
|
151 |
}
|
|
152 |
for(i = 0; i < 128; i++) { |
|
153 |
for(j = 0; j < 256; j++) { |
|
154 |
colors [j].red = stdcolors [j].red * ((127.0 - i) / 128.0); |
|
155 |
colors [j].green = stdcolors [j].green * ((127.0 - i) / 128.0); |
|
156 |
colors [j].blue = stdcolors [j].blue * ((127.0 - i) / 128.0); |
|
157 |
}
|
|
158 |
XStoreColors(dpy, cmap, colors, 256); |
|
159 |
select(0, NULL, NULL, NULL, &timeout); |
|
160 |
}
|
|
161 |
XFreeColors(dpy, cmap, pixels, 256, 0L); |
|
162 |
XFreeGC(dpy, Scr->WelcomeGC); |
|
163 |
FreeImage(Scr->WelcomeImage); |
|
164 |
}
|
|
165 |
if(Scr->Monochrome != COLOR) { |
|
166 |
goto fin; |
|
167 |
}
|
|
168 |
||
169 |
cmap = XCreateColormap(dpy, Scr->Root, Scr->d_visual, AllocNone); |
|
170 |
if(! cmap) { |
|
171 |
goto fin; |
|
172 |
}
|
|
173 |
for(i = 0; i < 256; i++) { |
|
174 |
colors [i].pixel = i; |
|
175 |
colors [i].red = 0; |
|
176 |
colors [i].green = 0; |
|
177 |
colors [i].blue = 0; |
|
178 |
colors [i].flags = DoRed | DoGreen | DoBlue; |
|
179 |
}
|
|
180 |
XStoreColors(dpy, cmap, colors, 256); |
|
181 |
||
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
182 |
if(0) { |
183 |
// Dummy
|
|
184 |
}
|
|
185 |
#ifdef CAPTIVE
|
|
186 |
else if(CLarg.is_captive) { |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
187 |
XSetWindowColormap(dpy, Scr->Root, cmap); |
188 |
}
|
|
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
189 |
#endif
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
190 |
else { |
191 |
XInstallColormap(dpy, cmap); |
|
192 |
}
|
|
193 |
||
194 |
XUnmapWindow(dpy, Scr->WindowMask); |
|
195 |
XClearWindow(dpy, Scr->Root); |
|
196 |
XSync(dpy, 0); |
|
197 |
PaintAllDecoration(); |
|
198 |
||
199 |
for(i = 0; i < 256; i++) { |
|
200 |
stdcolors [i].pixel = i; |
|
201 |
}
|
|
202 |
XQueryColors(dpy, stdcmap, stdcolors, 256); |
|
203 |
for(i = 0; i < 128; i++) { |
|
204 |
for(j = 0; j < 256; j++) { |
|
205 |
colors [j].pixel = j; |
|
206 |
colors [j].red = stdcolors [j].red * (i / 127.0); |
|
207 |
colors [j].green = stdcolors [j].green * (i / 127.0); |
|
208 |
colors [j].blue = stdcolors [j].blue * (i / 127.0); |
|
209 |
colors [j].flags = DoRed | DoGreen | DoBlue; |
|
210 |
}
|
|
211 |
XStoreColors(dpy, cmap, colors, 256); |
|
212 |
select(0, NULL, NULL, NULL, &timeout); |
|
213 |
}
|
|
214 |
||
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
215 |
if(0) { |
216 |
// Dummy
|
|
217 |
}
|
|
218 |
#ifdef CAPTIVE
|
|
219 |
else if(CLarg.is_captive) { |
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
220 |
XSetWindowColormap(dpy, Scr->Root, stdcmap); |
221 |
}
|
|
692.1.5
by Matthew Fuller
Add ifdef's around references to Screen and CLargs members that are |
222 |
#endif
|
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
223 |
else { |
224 |
XInstallColormap(dpy, stdcmap); |
|
225 |
}
|
|
226 |
||
227 |
XFreeColormap(dpy, cmap); |
|
228 |
||
229 |
fin: |
|
230 |
if(Scr->WelcomeCmap) { |
|
231 |
XFreeColormap(dpy, Scr->WelcomeCmap); |
|
232 |
}
|
|
233 |
XDestroyWindow(dpy, Scr->WindowMask); |
|
234 |
Scr->WindowMask = (Window) 0; |
|
235 |
}
|
|
236 |
||
237 |
||
238 |
||
239 |
||
240 |
/*
|
|
241 |
* Internal utils
|
|
242 |
*/
|
|
243 |
static void |
|
244 |
PaintAllDecoration(void) |
|
245 |
{
|
|
246 |
TwmWindow *tmp_win; |
|
247 |
VirtualScreen *vs; |
|
248 |
||
249 |
for(tmp_win = Scr->FirstWindow; tmp_win != NULL; tmp_win = tmp_win->next) { |
|
250 |
if(! visible(tmp_win)) { |
|
251 |
continue; |
|
252 |
}
|
|
492.2.75
by Matthew Fuller
Convert a bunch of boolean flags in the TwmWindow structure |
253 |
if(tmp_win->mapped) { |
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
254 |
if(tmp_win->frame_bw3D) { |
255 |
PaintBorders(tmp_win, |
|
256 |
(tmp_win->highlight && tmp_win == Scr->Focus)); |
|
257 |
}
|
|
258 |
if(tmp_win->title_w) { |
|
259 |
PaintTitle(tmp_win); |
|
260 |
}
|
|
261 |
if(tmp_win->titlebuttons) { |
|
262 |
PaintTitleButtons(tmp_win); |
|
263 |
}
|
|
264 |
}
|
|
492.2.75
by Matthew Fuller
Convert a bunch of boolean flags in the TwmWindow structure |
265 |
else if((tmp_win->icon_on == true) && |
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
266 |
!Scr->NoIconTitlebar && |
267 |
tmp_win->icon && |
|
268 |
tmp_win->icon->w && |
|
269 |
!tmp_win->icon->w_not_ours && |
|
563.1.4
by Matthew Fuller
Mechanically translate all these full_name references to name. |
270 |
! LookInList(Scr->NoIconTitle, tmp_win->name, &tmp_win->class)) { |
481.1.2
by Matthew Fuller
Pull {Mask,Unmask}Screen() out into their own file, along with the |
271 |
PaintIcon(tmp_win); |
272 |
}
|
|
273 |
}
|
|
274 |
for(vs = Scr->vScreenList; vs != NULL; vs = vs->next) { |
|
275 |
PaintWorkSpaceManager(vs); |
|
276 |
}
|
|
277 |
}
|