Patch based in large on work done by Philippe Saint-Pierre:
* When a BApplication is created, the interface kit globals for this team are initialized, including be_plain_font, be_bold_font and be_fixed_font. The plain font specifically is assumed the default font for all BViews. A BView is not required to every set the font, it will then just be the plain font, because the app_server already assigned it when the view is created. Here is where the problem starts. When the system fonts change, they change on the app_server and are picked up by new applications. Old applications will run with the old fonts, because the values remain the same and are stored in the already initialized be_*_font globals. So this was never a problem. What was a problem is that the app_server would use the current plain font for applications which were already initialized before the font was changed, so the values in their be_plain_font would not match the values in the server side font used when creating new views. * This patch already prepares for the situation in which client applications want to update their be_*_font globals. This needs to be a manual act of the client applications, otherwise we would break existing apps. Maybe we could automate this for BWindows with the B_AUTO_UPDATE_SIZE_LIMITS flag and any child views with B_SUPPORTS_LAYOUT. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
65d2b8a8e9
commit
fc235d5599
|
@ -10,6 +10,7 @@
|
|||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Jérôme Duval, jerome.duval@free.fr
|
||||
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -123,6 +124,14 @@ ServerApp::ServerApp(Desktop* desktop, port_id clientReplyPort,
|
|||
fInitialWorkspace = desktop->CurrentWorkspace();
|
||||
// TODO: this should probably be retrieved when the app is loaded!
|
||||
|
||||
// record the current system wide fonts..
|
||||
desktop->LockSingleWindow();
|
||||
DesktopSettings settings(desktop);
|
||||
settings.GetDefaultPlainFont(fPlainFont);
|
||||
settings.GetDefaultBoldFont(fBoldFont);
|
||||
settings.GetDefaultFixedFont(fFixedFont);
|
||||
desktop->UnlockSingleWindow();
|
||||
|
||||
STRACE(("ServerApp %s:\n", Signature()));
|
||||
STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
||||
STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
||||
|
@ -1125,6 +1134,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||
|
||||
case AS_SET_SYSTEM_FONT:
|
||||
{
|
||||
FTRACE(("ServerApp %s: AS_SET_SYSTEM_FONT\n", Signature()));
|
||||
// gets:
|
||||
// 1) string - font type ("plain", ...)
|
||||
// 2) string - family
|
||||
|
@ -1152,6 +1162,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||
|
||||
LockedDesktopSettings settings(fDesktop);
|
||||
|
||||
// TODO: Should we also update our internal copies now?
|
||||
if (!strcmp(type, "plain"))
|
||||
settings.SetDefaultPlainFont(font);
|
||||
else if (!strcmp(type, "bold"))
|
||||
|
@ -1215,31 +1226,41 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||
break;
|
||||
}
|
||||
|
||||
// The client is requesting the system fonts, this
|
||||
// could happend either at application start up, or
|
||||
// because the client is resyncing with the global
|
||||
// fonts. So we record the current system wide fonts
|
||||
// into our own copies at this point.
|
||||
DesktopSettings settings(fDesktop);
|
||||
|
||||
settings.GetDefaultPlainFont(fPlainFont);
|
||||
settings.GetDefaultBoldFont(fBoldFont);
|
||||
settings.GetDefaultFixedFont(fFixedFont);
|
||||
|
||||
fLink.StartMessage(B_OK);
|
||||
|
||||
for (int32 i = 0; i < 3; i++) {
|
||||
ServerFont font;
|
||||
ServerFont* font;
|
||||
switch (i) {
|
||||
case 0:
|
||||
settings.GetDefaultPlainFont(font);
|
||||
font = &fPlainFont;
|
||||
fLink.AttachString("plain");
|
||||
break;
|
||||
case 1:
|
||||
settings.GetDefaultBoldFont(font);
|
||||
font = &fBoldFont;
|
||||
fLink.AttachString("bold");
|
||||
break;
|
||||
case 2:
|
||||
settings.GetDefaultFixedFont(font);
|
||||
font = &fFixedFont;
|
||||
fLink.AttachString("fixed");
|
||||
break;
|
||||
}
|
||||
|
||||
fLink.Attach<uint16>(font.FamilyID());
|
||||
fLink.Attach<uint16>(font.StyleID());
|
||||
fLink.Attach<float>(font.Size());
|
||||
fLink.Attach<uint16>(font.Face());
|
||||
fLink.Attach<uint32>(font.Flags());
|
||||
fLink.Attach<uint16>(font->FamilyID());
|
||||
fLink.Attach<uint16>(font->StyleID());
|
||||
fLink.Attach<float>(font->Size());
|
||||
fLink.Attach<uint16>(font->Face());
|
||||
fLink.Attach<uint32>(font->Flags());
|
||||
}
|
||||
|
||||
fDesktop->UnlockSingleWindow();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "ClientMemoryAllocator.h"
|
||||
#include "MessageLooper.h"
|
||||
#include "ServerFont.h"
|
||||
|
||||
#include <ObjectList.h>
|
||||
#include <TokenSpace.h>
|
||||
|
@ -84,6 +85,8 @@ class ServerApp : public MessageLooper {
|
|||
|
||||
Desktop* GetDesktop() const { return fDesktop; }
|
||||
|
||||
const ServerFont& PlainFont() const { return fPlainFont; }
|
||||
|
||||
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
||||
|
||||
private:
|
||||
|
@ -111,6 +114,10 @@ class ServerApp : public MessageLooper {
|
|||
BString fSignature;
|
||||
team_id fClientTeam;
|
||||
|
||||
ServerFont fPlainFont;
|
||||
ServerFont fBoldFont;
|
||||
ServerFont fFixedFont;
|
||||
|
||||
mutable BLocker fWindowListLock;
|
||||
BObjectList<ServerWindow> fWindowList;
|
||||
BPrivate::BTokenSpace fViewTokens;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* Stefano Ceccherini (burton666@libero.it)
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Artur Wyszynski <harakash@gmail.com>
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -618,11 +619,14 @@ fDesktop->LockAllWindows();
|
|||
// fDesktop->LockSingleWindow();
|
||||
}
|
||||
|
||||
// TODO: default fonts should be created and stored in the Application
|
||||
DesktopSettings settings(fDesktop);
|
||||
ServerFont font;
|
||||
settings.GetDefaultPlainFont(font);
|
||||
newView->CurrentState()->SetFont(font);
|
||||
// Initialize the view with the current application plain font.
|
||||
// NOTE: This might be out of sync with the global app_server plain
|
||||
// font, but that is so on purpose! The client needs to resync itself
|
||||
// with the app_server fonts upon notification, but if we just use
|
||||
// the current font here, the be_plain_font on the client may still
|
||||
// hold old values. So this needs to be an update initiated by the
|
||||
// client application.
|
||||
newView->CurrentState()->SetFont(App()->PlainFont());
|
||||
|
||||
if (_parent) {
|
||||
View *parent;
|
||||
|
|
Loading…
Reference in New Issue