1 | Index: src/servers/app/ServerApp.h
|
---|
2 | ===================================================================
|
---|
3 | --- src/servers/app/ServerApp.h (révision 30265)
|
---|
4 | +++ src/servers/app/ServerApp.h (copie de travail)
|
---|
5 | @@ -8,11 +8,13 @@
|
---|
6 | * Stephan Aßmus <superstippi@gmx.de>
|
---|
7 | * Stefano Ceccherini (burton666@libero.it)
|
---|
8 | * Axel Dörfler, axeld@pinc-software.de
|
---|
9 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
10 | */
|
---|
11 | #ifndef SERVER_APP_H
|
---|
12 | #define SERVER_APP_H
|
---|
13 |
|
---|
14 |
|
---|
15 | +#include "ServerFont.h"
|
---|
16 | #include "ClientMemoryAllocator.h"
|
---|
17 | #include "MessageLooper.h"
|
---|
18 |
|
---|
19 | @@ -84,6 +86,8 @@
|
---|
20 |
|
---|
21 | Desktop* GetDesktop() const { return fDesktop; }
|
---|
22 |
|
---|
23 | + status_t GetFont(char *which, ServerFont& font);
|
---|
24 | +
|
---|
25 | BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
---|
26 |
|
---|
27 | private:
|
---|
28 | @@ -111,6 +115,10 @@
|
---|
29 | BString fSignature;
|
---|
30 | team_id fClientTeam;
|
---|
31 |
|
---|
32 | + ServerFont fPlainFont;
|
---|
33 | + ServerFont fBoldFont;
|
---|
34 | + ServerFont fFixedFont;
|
---|
35 | +
|
---|
36 | mutable BLocker fWindowListLock;
|
---|
37 | BObjectList<ServerWindow> fWindowList;
|
---|
38 | BPrivate::BTokenSpace fViewTokens;
|
---|
39 | Index: src/servers/app/ServerApp.cpp
|
---|
40 | ===================================================================
|
---|
41 | --- src/servers/app/ServerApp.cpp (révision 30265)
|
---|
42 | +++ src/servers/app/ServerApp.cpp (copie de travail)
|
---|
43 | @@ -10,6 +10,7 @@
|
---|
44 | * Axel Dörfler, axeld@pinc-software.de
|
---|
45 | * Jérôme Duval, jerome.duval@free.fr
|
---|
46 | * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
---|
47 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
48 | */
|
---|
49 |
|
---|
50 | /*!
|
---|
51 | @@ -123,6 +124,14 @@
|
---|
52 | fInitialWorkspace = desktop->CurrentWorkspace();
|
---|
53 | // TODO: this should probably be retrieved when the app is loaded!
|
---|
54 |
|
---|
55 | + // record the current system wide fonts..
|
---|
56 | + desktop->LockSingleWindow();
|
---|
57 | + DesktopSettings settings(desktop);
|
---|
58 | + settings.GetDefaultPlainFont(fPlainFont);
|
---|
59 | + settings.GetDefaultBoldFont(fBoldFont);
|
---|
60 | + settings.GetDefaultFixedFont(fFixedFont);
|
---|
61 | + desktop->UnlockSingleWindow();
|
---|
62 | +
|
---|
63 | STRACE(("ServerApp %s:\n", Signature()));
|
---|
64 | STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
---|
65 | STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
---|
66 | @@ -390,6 +399,36 @@
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | +// Helper function to attach the fonts attribute to a link
|
---|
71 | +// Could be made a method of the link itself, I suppose
|
---|
72 | +
|
---|
73 | +void
|
---|
74 | +_AttachFont(BPrivate::PortLink& fLink, ServerFont& font)
|
---|
75 | +{
|
---|
76 | + fLink.Attach<uint16>(font.FamilyID());
|
---|
77 | + fLink.Attach<uint16>(font.StyleID());
|
---|
78 | + fLink.Attach<float>(font.Size());
|
---|
79 | + fLink.Attach<uint16>(font.Face());
|
---|
80 | + fLink.Attach<uint32>(font.Flags());
|
---|
81 | +}
|
---|
82 | +
|
---|
83 | +
|
---|
84 | +status_t
|
---|
85 | +ServerApp::GetFont(char *which, ServerFont& font)
|
---|
86 | +{
|
---|
87 | + if (!strcmp(which, "plain")) {
|
---|
88 | + font = fPlainFont;
|
---|
89 | + } else if (!strcmp(which, "bold")) {
|
---|
90 | + font = fBoldFont;
|
---|
91 | + } else if (!strcmp(which, "fixed")) {
|
---|
92 | + font = fFixedFont;
|
---|
93 | + } else
|
---|
94 | + return B_BAD_VALUE;
|
---|
95 | +
|
---|
96 | + return B_OK;
|
---|
97 | +}
|
---|
98 | +
|
---|
99 | +
|
---|
100 | /*!
|
---|
101 | \brief Handler function for BApplication API messages
|
---|
102 | \param code Identifier code for the message. Equivalent to BMessage::what
|
---|
103 | @@ -1123,8 +1162,44 @@
|
---|
104 |
|
---|
105 | /* font messages */
|
---|
106 |
|
---|
107 | + case AS_GET_SYSTEM_FONT:
|
---|
108 | + {
|
---|
109 | + FTRACE(("ServerApp %s: AS_GET_SYSTEM_FONT\n", Signature()));
|
---|
110 | + // gets :
|
---|
111 | + // 1) string - font type ("plain", ...)
|
---|
112 | +
|
---|
113 | + char type[B_OS_NAME_LENGTH];
|
---|
114 | + ServerFont font;
|
---|
115 | +
|
---|
116 | + status_t status = link.ReadString(type, sizeof(type));
|
---|
117 | +
|
---|
118 | + if (status == B_OK) {
|
---|
119 | + if (!strcmp(type, "plain")) {
|
---|
120 | + fLink.StartMessage(B_OK);
|
---|
121 | + _AttachFont(fLink, fPlainFont);
|
---|
122 | + } else if (!strcmp(type, "bold")) {
|
---|
123 | + fLink.StartMessage(B_OK);
|
---|
124 | + _AttachFont(fLink, fBoldFont);
|
---|
125 | + } else if (!strcmp(type, "fixed")) {
|
---|
126 | + fLink.StartMessage(B_OK);
|
---|
127 | + _AttachFont(fLink, fFixedFont);
|
---|
128 | + } else {
|
---|
129 | + FTRACE(("Font name not found : %s\n", type));
|
---|
130 | + status = B_BAD_VALUE;
|
---|
131 | + }
|
---|
132 | + }
|
---|
133 | +
|
---|
134 | + if (status != B_OK) {
|
---|
135 | + fLink.StartMessage(status);
|
---|
136 | + }
|
---|
137 | +
|
---|
138 | + fLink.Flush();
|
---|
139 | + break;
|
---|
140 | + }
|
---|
141 | +
|
---|
142 | case AS_SET_SYSTEM_FONT:
|
---|
143 | {
|
---|
144 | + FTRACE(("ServerApp %s: AS_SET_SYSTEM_FONT\n", Signature()));
|
---|
145 | // gets:
|
---|
146 | // 1) string - font type ("plain", ...)
|
---|
147 | // 2) string - family
|
---|
148 | @@ -1209,40 +1284,17 @@
|
---|
149 | // 4) uint16 - face flags
|
---|
150 | // 5) uint32 - font flags
|
---|
151 |
|
---|
152 | - if (!fDesktop->LockSingleWindow()) {
|
---|
153 | - fLink.StartMessage(B_OK);
|
---|
154 | - fLink.Flush();
|
---|
155 | - break;
|
---|
156 | - }
|
---|
157 | -
|
---|
158 | - DesktopSettings settings(fDesktop);
|
---|
159 | fLink.StartMessage(B_OK);
|
---|
160 |
|
---|
161 | - for (int32 i = 0; i < 3; i++) {
|
---|
162 | - ServerFont font;
|
---|
163 | - switch (i) {
|
---|
164 | - case 0:
|
---|
165 | - settings.GetDefaultPlainFont(font);
|
---|
166 | - fLink.AttachString("plain");
|
---|
167 | - break;
|
---|
168 | - case 1:
|
---|
169 | - settings.GetDefaultBoldFont(font);
|
---|
170 | - fLink.AttachString("bold");
|
---|
171 | - break;
|
---|
172 | - case 2:
|
---|
173 | - settings.GetDefaultFixedFont(font);
|
---|
174 | - fLink.AttachString("fixed");
|
---|
175 | - break;
|
---|
176 | - }
|
---|
177 | + fLink.AttachString("plain");
|
---|
178 | + _AttachFont(fLink, fPlainFont);
|
---|
179 |
|
---|
180 | - fLink.Attach<uint16>(font.FamilyID());
|
---|
181 | - fLink.Attach<uint16>(font.StyleID());
|
---|
182 | - fLink.Attach<float>(font.Size());
|
---|
183 | - fLink.Attach<uint16>(font.Face());
|
---|
184 | - fLink.Attach<uint32>(font.Flags());
|
---|
185 | - }
|
---|
186 | + fLink.AttachString("bold");
|
---|
187 | + _AttachFont(fLink, fBoldFont);
|
---|
188 |
|
---|
189 | - fDesktop->UnlockSingleWindow();
|
---|
190 | + fLink.AttachString("fixed");
|
---|
191 | + _AttachFont(fLink, fFixedFont);
|
---|
192 | +
|
---|
193 | fLink.Flush();
|
---|
194 | break;
|
---|
195 | }
|
---|
196 | Index: src/servers/app/ServerWindow.cpp
|
---|
197 | ===================================================================
|
---|
198 | --- src/servers/app/ServerWindow.cpp (révision 30265)
|
---|
199 | +++ src/servers/app/ServerWindow.cpp (copie de travail)
|
---|
200 | @@ -9,6 +9,7 @@
|
---|
201 | * Stefano Ceccherini (burton666@libero.it)
|
---|
202 | * Axel Dörfler, axeld@pinc-software.de
|
---|
203 | * Artur Wyszynski <harakash@gmail.com>
|
---|
204 | + * Philippe Saint-Pierre, stpere@gmail.com
|
---|
205 | */
|
---|
206 |
|
---|
207 | /*!
|
---|
208 | @@ -618,11 +619,12 @@
|
---|
209 | // fDesktop->LockSingleWindow();
|
---|
210 | }
|
---|
211 |
|
---|
212 | - // TODO: default fonts should be created and stored in the Application
|
---|
213 | - DesktopSettings settings(fDesktop);
|
---|
214 | ServerFont font;
|
---|
215 | - settings.GetDefaultPlainFont(font);
|
---|
216 | - newView->CurrentState()->SetFont(font);
|
---|
217 | + if (App()->GetFont("plain", font) == B_OK) {
|
---|
218 | + newView->CurrentState()->SetFont(font);
|
---|
219 | + } else {
|
---|
220 | + debug_printf("Plain font not found!\n");
|
---|
221 | + }
|
---|
222 |
|
---|
223 | if (_parent) {
|
---|
224 | View *parent;
|
---|
225 | Index: src/kits/app/Application.cpp
|
---|
226 | ===================================================================
|
---|
227 | --- src/kits/app/Application.cpp (révision 30265)
|
---|
228 | +++ src/kits/app/Application.cpp (copie de travail)
|
---|
229 | @@ -31,6 +31,7 @@
|
---|
230 | #include <Resources.h>
|
---|
231 | #include <Roster.h>
|
---|
232 | #include <Window.h>
|
---|
233 | +#include <Font.h>
|
---|
234 |
|
---|
235 | #include <AppMisc.h>
|
---|
236 | #include <AppServerLink.h>
|
---|
237 | @@ -250,6 +251,13 @@
|
---|
238 |
|
---|
239 | // uninitialize be_app, the be_app_messenger is invalidated automatically
|
---|
240 | be_app = NULL;
|
---|
241 | +
|
---|
242 | + // free the fonts symbols (they are application specific)
|
---|
243 | + if (fPrivateFonts) {
|
---|
244 | + delete be_plain_font;
|
---|
245 | + delete be_bold_font;
|
---|
246 | + delete be_fixed_font;
|
---|
247 | + }
|
---|
248 | }
|
---|
249 |
|
---|
250 |
|
---|
251 | @@ -282,6 +290,8 @@
|
---|
252 | fInitError = check_app_signature(signature);
|
---|
253 | fAppName = signature;
|
---|
254 |
|
---|
255 | + fPrivateFonts = false;
|
---|
256 | +
|
---|
257 | #ifndef RUN_WITHOUT_REGISTRAR
|
---|
258 | bool isRegistrar = signature
|
---|
259 | && !strcasecmp(signature, kRegistrarSignature);
|
---|
260 | @@ -433,8 +443,13 @@
|
---|
261 |
|
---|
262 | #ifndef RUN_WITHOUT_APP_SERVER
|
---|
263 | // app server connection and IK initialization
|
---|
264 | - if (initGUI)
|
---|
265 | + if (initGUI) {
|
---|
266 | fInitError = _InitGUIContext();
|
---|
267 | + be_plain_font = new BFont("plain");
|
---|
268 | + be_bold_font = new BFont("bold");
|
---|
269 | + be_fixed_font = new BFont("fixed");
|
---|
270 | + fPrivateFonts = true;
|
---|
271 | + }
|
---|
272 | #endif // RUN_WITHOUT_APP_SERVER
|
---|
273 | }
|
---|
274 |
|
---|
275 | Index: src/kits/interface/Font.cpp
|
---|
276 | ===================================================================
|
---|
277 | --- src/kits/interface/Font.cpp (révision 30265)
|
---|
278 | +++ src/kits/interface/Font.cpp (copie de travail)
|
---|
279 | @@ -12,6 +12,7 @@
|
---|
280 |
|
---|
281 |
|
---|
282 | #include <AppServerLink.h>
|
---|
283 | +#include <Application.h>
|
---|
284 | #include <FontPrivate.h>
|
---|
285 | #include <ObjectList.h>
|
---|
286 | #include <ServerProtocol.h>
|
---|
287 | @@ -36,16 +37,17 @@
|
---|
288 | const float kUninitializedAscent = INFINITY;
|
---|
289 | const uint32 kUninitializedExtraFlags = 0xffffffff;
|
---|
290 |
|
---|
291 | -// The actual objects which the globals point to
|
---|
292 | +// Backup fonts (used when no BApplication is present) - legacy behaviour
|
---|
293 | static BFont sPlainFont;
|
---|
294 | static BFont sBoldFont;
|
---|
295 | static BFont sFixedFont;
|
---|
296 |
|
---|
297 | +// Font symbols - these are specific to every application
|
---|
298 | +// they will be changed at BApplication initialization
|
---|
299 | const BFont *be_plain_font = &sPlainFont;
|
---|
300 | const BFont *be_bold_font = &sBoldFont;
|
---|
301 | const BFont *be_fixed_font = &sFixedFont;
|
---|
302 |
|
---|
303 | -
|
---|
304 | struct style {
|
---|
305 | BString name;
|
---|
306 | uint16 face;
|
---|
307 | @@ -349,11 +351,13 @@
|
---|
308 | {
|
---|
309 | }
|
---|
310 |
|
---|
311 | +
|
---|
312 | status_t get_font_cache_info(uint32 id, void *set)
|
---|
313 | {
|
---|
314 | return B_ERROR;
|
---|
315 | }
|
---|
316 |
|
---|
317 | +
|
---|
318 | status_t set_font_cache_info(uint32 id, void *set)
|
---|
319 | {
|
---|
320 | return B_ERROR;
|
---|
321 | @@ -501,6 +505,7 @@
|
---|
322 | // #pragma mark -
|
---|
323 |
|
---|
324 |
|
---|
325 | +
|
---|
326 | BFont::BFont()
|
---|
327 | :
|
---|
328 | // initialise for be_plain_font (avoid circular definition)
|
---|
329 | @@ -526,6 +531,52 @@
|
---|
330 | }
|
---|
331 |
|
---|
332 |
|
---|
333 | +BFont::BFont(const char *which)
|
---|
334 | + :
|
---|
335 | + fFamilyID(0),
|
---|
336 | + fStyleID(0),
|
---|
337 | + fSize(10.0),
|
---|
338 | + fShear(90.0),
|
---|
339 | + fRotation(0.0),
|
---|
340 | + fFalseBoldWidth(0.0),
|
---|
341 | + fSpacing(0),
|
---|
342 | + fEncoding(0),
|
---|
343 | + fFace(0),
|
---|
344 | + fFlags(0),
|
---|
345 | + fExtraFlags(kUninitializedExtraFlags)
|
---|
346 | +{
|
---|
347 | + if (be_app
|
---|
348 | + && (!strcmp(which, "plain")
|
---|
349 | + || !strcmp(which, "bold")
|
---|
350 | + || !strcmp(which, "fixed"))) {
|
---|
351 | +
|
---|
352 | + BPrivate::AppServerLink link;
|
---|
353 | +
|
---|
354 | + link.StartMessage(AS_GET_SYSTEM_FONT);
|
---|
355 | + link.AttachString(which, B_OS_NAME_LENGTH);
|
---|
356 | +
|
---|
357 | + int32 code;
|
---|
358 | + link.FlushWithReply(code);
|
---|
359 | +
|
---|
360 | + if (code == B_OK) {
|
---|
361 | + link.Read<uint16>(&fFamilyID);
|
---|
362 | + link.Read<uint16>(&fStyleID);
|
---|
363 | + link.Read<float>(&fSize);
|
---|
364 | + link.Read<uint16>(&fFace);
|
---|
365 | + link.Read<uint32>(&fFlags);
|
---|
366 | +
|
---|
367 | + fHeight.ascent = kUninitializedAscent;
|
---|
368 | + fExtraFlags = kUninitializedExtraFlags;
|
---|
369 | + return;
|
---|
370 | + }
|
---|
371 | + }
|
---|
372 | + // else...
|
---|
373 | + fHeight.ascent = 7.0;
|
---|
374 | + fHeight.descent = 2.0;
|
---|
375 | + fHeight.leading = 13.0;
|
---|
376 | +}
|
---|
377 | +
|
---|
378 | +
|
---|
379 | BFont::BFont(const BFont &font)
|
---|
380 | {
|
---|
381 | *this = font;
|
---|
382 | @@ -536,8 +587,10 @@
|
---|
383 | {
|
---|
384 | if (font)
|
---|
385 | *this = *font;
|
---|
386 | + else if (be_plain_font)
|
---|
387 | + *this = *be_plain_font;
|
---|
388 | else
|
---|
389 | - *this = *be_plain_font;
|
---|
390 | + *this = BFont("plain");
|
---|
391 | }
|
---|
392 |
|
---|
393 |
|
---|
394 | Index: headers/os/interface/Font.h
|
---|
395 | ===================================================================
|
---|
396 | --- headers/os/interface/Font.h (révision 30265)
|
---|
397 | +++ headers/os/interface/Font.h (copie de travail)
|
---|
398 | @@ -148,6 +148,7 @@
|
---|
399 | class BFont {
|
---|
400 | public:
|
---|
401 | BFont();
|
---|
402 | + BFont(const char *which);
|
---|
403 | BFont(const BFont &font);
|
---|
404 | BFont(const BFont *font);
|
---|
405 |
|
---|
406 | Index: headers/private/app/ServerProtocol.h
|
---|
407 | ===================================================================
|
---|
408 | --- headers/private/app/ServerProtocol.h (révision 30265)
|
---|
409 | +++ headers/private/app/ServerProtocol.h (copie de travail)
|
---|
410 | @@ -108,6 +108,7 @@
|
---|
411 |
|
---|
412 | // Font-related server communications
|
---|
413 | AS_SET_SYSTEM_FONT,
|
---|
414 | + AS_GET_SYSTEM_FONT,
|
---|
415 | AS_GET_SYSTEM_FONTS,
|
---|
416 | AS_GET_SYSTEM_DEFAULT_FONT,
|
---|
417 | AS_SYSTEM_FONT_CHANGED,
|
---|