diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index b08a08e53c..b77af29b97 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -10,6 +10,7 @@ * Axel Dörfler, axeld@pinc-software.de * Jérôme Duval, jerome.duval@free.fr * Andrej Spielmann, + * 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(font.FamilyID()); - fLink.Attach(font.StyleID()); - fLink.Attach(font.Size()); - fLink.Attach(font.Face()); - fLink.Attach(font.Flags()); + fLink.Attach(font->FamilyID()); + fLink.Attach(font->StyleID()); + fLink.Attach(font->Size()); + fLink.Attach(font->Face()); + fLink.Attach(font->Flags()); } fDesktop->UnlockSingleWindow(); diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index edad8997fd..f35406b0e0 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -15,6 +15,7 @@ #include "ClientMemoryAllocator.h" #include "MessageLooper.h" +#include "ServerFont.h" #include #include @@ -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 fWindowList; BPrivate::BTokenSpace fViewTokens; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 83e11ada4e..23fdfbdba1 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -9,6 +9,7 @@ * Stefano Ceccherini (burton666@libero.it) * Axel Dörfler, axeld@pinc-software.de * Artur Wyszynski + * 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;