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
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
* Jérôme Duval, jerome.duval@free.fr
|
* Jérôme Duval, jerome.duval@free.fr
|
||||||
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
* 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();
|
fInitialWorkspace = desktop->CurrentWorkspace();
|
||||||
// TODO: this should probably be retrieved when the app is loaded!
|
// 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(("ServerApp %s:\n", Signature()));
|
||||||
STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
||||||
STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
||||||
|
@ -1125,6 +1134,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||||
|
|
||||||
case AS_SET_SYSTEM_FONT:
|
case AS_SET_SYSTEM_FONT:
|
||||||
{
|
{
|
||||||
|
FTRACE(("ServerApp %s: AS_SET_SYSTEM_FONT\n", Signature()));
|
||||||
// gets:
|
// gets:
|
||||||
// 1) string - font type ("plain", ...)
|
// 1) string - font type ("plain", ...)
|
||||||
// 2) string - family
|
// 2) string - family
|
||||||
|
@ -1152,6 +1162,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||||
|
|
||||||
LockedDesktopSettings settings(fDesktop);
|
LockedDesktopSettings settings(fDesktop);
|
||||||
|
|
||||||
|
// TODO: Should we also update our internal copies now?
|
||||||
if (!strcmp(type, "plain"))
|
if (!strcmp(type, "plain"))
|
||||||
settings.SetDefaultPlainFont(font);
|
settings.SetDefaultPlainFont(font);
|
||||||
else if (!strcmp(type, "bold"))
|
else if (!strcmp(type, "bold"))
|
||||||
|
@ -1215,31 +1226,41 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||||
break;
|
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);
|
DesktopSettings settings(fDesktop);
|
||||||
|
|
||||||
|
settings.GetDefaultPlainFont(fPlainFont);
|
||||||
|
settings.GetDefaultBoldFont(fBoldFont);
|
||||||
|
settings.GetDefaultFixedFont(fFixedFont);
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
|
|
||||||
for (int32 i = 0; i < 3; i++) {
|
for (int32 i = 0; i < 3; i++) {
|
||||||
ServerFont font;
|
ServerFont* font;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
settings.GetDefaultPlainFont(font);
|
font = &fPlainFont;
|
||||||
fLink.AttachString("plain");
|
fLink.AttachString("plain");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
settings.GetDefaultBoldFont(font);
|
font = &fBoldFont;
|
||||||
fLink.AttachString("bold");
|
fLink.AttachString("bold");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
settings.GetDefaultFixedFont(font);
|
font = &fFixedFont;
|
||||||
fLink.AttachString("fixed");
|
fLink.AttachString("fixed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fLink.Attach<uint16>(font.FamilyID());
|
fLink.Attach<uint16>(font->FamilyID());
|
||||||
fLink.Attach<uint16>(font.StyleID());
|
fLink.Attach<uint16>(font->StyleID());
|
||||||
fLink.Attach<float>(font.Size());
|
fLink.Attach<float>(font->Size());
|
||||||
fLink.Attach<uint16>(font.Face());
|
fLink.Attach<uint16>(font->Face());
|
||||||
fLink.Attach<uint32>(font.Flags());
|
fLink.Attach<uint32>(font->Flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
fDesktop->UnlockSingleWindow();
|
fDesktop->UnlockSingleWindow();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "ClientMemoryAllocator.h"
|
#include "ClientMemoryAllocator.h"
|
||||||
#include "MessageLooper.h"
|
#include "MessageLooper.h"
|
||||||
|
#include "ServerFont.h"
|
||||||
|
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
|
@ -84,6 +85,8 @@ class ServerApp : public MessageLooper {
|
||||||
|
|
||||||
Desktop* GetDesktop() const { return fDesktop; }
|
Desktop* GetDesktop() const { return fDesktop; }
|
||||||
|
|
||||||
|
const ServerFont& PlainFont() const { return fPlainFont; }
|
||||||
|
|
||||||
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -111,6 +114,10 @@ class ServerApp : public MessageLooper {
|
||||||
BString fSignature;
|
BString fSignature;
|
||||||
team_id fClientTeam;
|
team_id fClientTeam;
|
||||||
|
|
||||||
|
ServerFont fPlainFont;
|
||||||
|
ServerFont fBoldFont;
|
||||||
|
ServerFont fFixedFont;
|
||||||
|
|
||||||
mutable BLocker fWindowListLock;
|
mutable BLocker fWindowListLock;
|
||||||
BObjectList<ServerWindow> fWindowList;
|
BObjectList<ServerWindow> fWindowList;
|
||||||
BPrivate::BTokenSpace fViewTokens;
|
BPrivate::BTokenSpace fViewTokens;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Stefano Ceccherini (burton666@libero.it)
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
* Axel Dörfler, axeld@pinc-software.de
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
* Artur Wyszynski <harakash@gmail.com>
|
* Artur Wyszynski <harakash@gmail.com>
|
||||||
|
* Philippe Saint-Pierre, stpere@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -618,11 +619,14 @@ fDesktop->LockAllWindows();
|
||||||
// fDesktop->LockSingleWindow();
|
// fDesktop->LockSingleWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: default fonts should be created and stored in the Application
|
// Initialize the view with the current application plain font.
|
||||||
DesktopSettings settings(fDesktop);
|
// NOTE: This might be out of sync with the global app_server plain
|
||||||
ServerFont font;
|
// font, but that is so on purpose! The client needs to resync itself
|
||||||
settings.GetDefaultPlainFont(font);
|
// with the app_server fonts upon notification, but if we just use
|
||||||
newView->CurrentState()->SetFont(font);
|
// 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) {
|
if (_parent) {
|
||||||
View *parent;
|
View *parent;
|
||||||
|
|
Loading…
Reference in New Issue