diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 0c1409788b..04494c7065 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -6,6 +6,7 @@ * DarkWyrm * Jérôme Duval, jerome.duval@free.fr * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ #ifndef APP_SERVER_PROTOCOL_H #define APP_SERVER_PROTOCOL_H @@ -188,6 +189,11 @@ enum { AS_GET_SHOW_ALL_DRAGGERS, AS_SET_SHOW_ALL_DRAGGERS, + AS_SET_FONT_SUBPIXEL_ANTIALIASING, + AS_GET_FONT_SUBPIXEL_ANTIALIASING, + AS_SET_HINTING, + AS_GET_HINTING, + // Graphics calls AS_SET_HIGH_COLOR, AS_SET_LOW_COLOR, diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index eebaa77673..48c8325828 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -6,6 +6,7 @@ * Adrian Oanca * Stephan Aßmus * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ /*! Class used to encapsulate desktop management */ @@ -2461,6 +2462,14 @@ Desktop::MarkDirty(BRegion& region) } +void +Desktop::Redraw() +{ + BRegion dirty(fVirtualScreen.Frame()); + MarkDirty(dirty); +} + + void Desktop::_RebuildClippingForAllWindows(BRegion& stillAvailableOnScreen) { diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 7c35f08cd1..5c7d55ec15 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -6,6 +6,7 @@ * Adrian Oanca * Stephan Aßmus * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ #ifndef DESKTOP_H #define DESKTOP_H @@ -190,6 +191,7 @@ class Desktop : public MessageLooper, public ScreenOwner { #endif // USE_MULTI_LOCKER void MarkDirty(BRegion& region); + void Redraw(); BRegion& BackgroundRegion() { return fBackgroundRegion; } diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 8dc9d38a4d..600c1de546 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -5,12 +5,15 @@ * Authors: * Stephan Aßmus * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ #include "DesktopSettings.h" #include "DesktopSettingsPrivate.h" #include "Desktop.h" +#include "FontCache.h" +#include "FontCacheEntry.h" #include "FontManager.h" #include "ServerConfig.h" @@ -60,7 +63,7 @@ DesktopSettingsPrivate::_SetDefaults() strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH); fMenuInfo.font_size = fPlainFont.Size(); fMenuInfo.background_color.set_to(216, 216, 216); - + fMenuInfo.separator = 0; // look of the separator (R5: (0, 1, 2), default 0) fMenuInfo.click_to_open = true; // always true @@ -69,6 +72,11 @@ DesktopSettingsPrivate::_SetDefaults() fWorkspacesCount = 4; memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors); + + fFontSubpixelAntialiasing = false; + FontCacheEntry::SetDefaultRenderType(glyph_ren_native_gray8); + fHinting = true; + FontCacheEntry::SetDefaultHinting(true); } @@ -101,7 +109,7 @@ DesktopSettingsPrivate::_Load() BPath path(basePath); path.Append("workspaces"); - + BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { @@ -127,7 +135,7 @@ DesktopSettingsPrivate::_Load() path = basePath; path.Append("fonts"); - + status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; @@ -136,6 +144,8 @@ DesktopSettingsPrivate::_Load() const char* family; const char* style; float size; + bool subpix; + bool hinting; if (settings.FindString("plain family", &family) == B_OK && settings.FindString("plain style", &style) == B_OK && settings.FindFloat("plain size", &size) == B_OK) { @@ -158,6 +168,15 @@ DesktopSettingsPrivate::_Load() fFixedFont.SetStyle(fontStyle); fFixedFont.SetSize(size); } + if (settings.FindBool("font subpix", &subpix) == B_OK) { + fFontSubpixelAntialiasing = subpix; + FontCacheEntry::SetDefaultRenderType( + (subpix) ? glyph_ren_subpix : glyph_ren_native_gray8); + } + if (settings.FindBool("hinting", &hinting) == B_OK) { + fHinting = hinting; + FontCacheEntry::SetDefaultHinting(fHinting); + } gFontManager->Unlock(); } } @@ -166,7 +185,7 @@ DesktopSettingsPrivate::_Load() path = basePath; path.Append("mouse"); - + status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; @@ -183,7 +202,7 @@ DesktopSettingsPrivate::_Load() path = basePath; path.Append("appearance"); - + status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; @@ -192,7 +211,7 @@ DesktopSettingsPrivate::_Load() float fontSize; if (settings.FindFloat("font size", &fontSize) == B_OK) fMenuInfo.font_size = fontSize; - + const char* fontFamily; if (settings.FindString("font family", &fontFamily) == B_OK) strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH); @@ -274,6 +293,9 @@ DesktopSettingsPrivate::Save(uint32 mask) settings.AddString("fixed style", fFixedFont.Style()); settings.AddFloat("fixed size", fFixedFont.Size()); + settings.AddBool("font subpix",fFontSubpixelAntialiasing); + settings.AddBool("hinting",fHinting); + BFile file; status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE); if (status == B_OK) { @@ -521,6 +543,42 @@ DesktopSettingsPrivate::UIColor(color_which which) const } +void +DesktopSettingsPrivate::SetFontSubpixelAntialiasing(bool subpix) +{ + if (fFontSubpixelAntialiasing != subpix) { + fFontSubpixelAntialiasing = subpix; + FontCacheEntry::SetDefaultRenderType( + (subpix)?glyph_ren_subpix:glyph_ren_native_gray8); + Save(kFontSettings); + } +} + + +bool +DesktopSettingsPrivate::FontSubpixelAntialiasing() const +{ + return fFontSubpixelAntialiasing; +} + + +void +DesktopSettingsPrivate::SetHinting(bool hinting) +{ + if (fHinting != hinting) { + fHinting = hinting; + FontCacheEntry::SetDefaultHinting(hinting); + Save(kFontSettings); + } +} + + +bool +DesktopSettingsPrivate::Hinting() const +{ + return fHinting; +} + // #pragma mark - read access @@ -613,6 +671,19 @@ DesktopSettings::UIColor(color_which which) const } +bool +DesktopSettings::FontSubpixelAntialiasing() const +{ + return fSettings->FontSubpixelAntialiasing(); +} + + +bool +DesktopSettings::Hinting() const +{ + return fSettings->Hinting(); +} + // #pragma mark - write access @@ -691,3 +762,16 @@ LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color) } +void +LockedDesktopSettings::SetFontSubpixelAntialiasing(bool subpix) +{ + fSettings->SetFontSubpixelAntialiasing(subpix); +} + + +void +LockedDesktopSettings::SetHinting(bool hinting) +{ + fSettings->SetHinting(hinting); +} + diff --git a/src/servers/app/DesktopSettings.h b/src/servers/app/DesktopSettings.h index c928664c15..bb4b30e3ae 100644 --- a/src/servers/app/DesktopSettings.h +++ b/src/servers/app/DesktopSettings.h @@ -4,6 +4,7 @@ * * Authors: * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ #ifndef DESKTOP_SETTINGS_H #define DESKTOP_SETTINGS_H @@ -52,6 +53,9 @@ class DesktopSettings { rgb_color UIColor(color_which which) const; + bool FontSubpixelAntialiasing() const; + bool Hinting() const; + protected: DesktopSettingsPrivate* fSettings; }; @@ -74,6 +78,9 @@ class LockedDesktopSettings : public DesktopSettings { void SetUIColor(color_which which, const rgb_color color); + void SetFontSubpixelAntialiasing(bool subpix); + void SetHinting(bool hinting); + private: Desktop* fDesktop; }; diff --git a/src/servers/app/DesktopSettingsPrivate.h b/src/servers/app/DesktopSettingsPrivate.h index 2a3f78d01d..5d8bb180da 100644 --- a/src/servers/app/DesktopSettingsPrivate.h +++ b/src/servers/app/DesktopSettingsPrivate.h @@ -4,6 +4,7 @@ * * Authors: * Axel Dörfler, axeld@pinc-software.de + * Andrej Spielmann, */ #ifndef DESKTOP_SETTINGS_PRIVATE_H #define DESKTOP_SETTINGS_PRIVATE_H @@ -54,6 +55,12 @@ class DesktopSettingsPrivate { void SetUIColor(color_which which, const rgb_color color); rgb_color UIColor(color_which which) const; + + void SetFontSubpixelAntialiasing(bool subpix); + bool FontSubpixelAntialiasing() const; + void SetHinting(bool hinting); + bool Hinting() const; + private: void _SetDefaults(); status_t _Load(); @@ -70,6 +77,9 @@ class DesktopSettingsPrivate { int32 fWorkspacesCount; BMessage fWorkspaceMessages[kMaxWorkspaces]; + bool fFontSubpixelAntialiasing; + bool fHinting; + server_read_only_memory& fShared; }; diff --git a/src/servers/app/ProfileMessageSupport.cpp b/src/servers/app/ProfileMessageSupport.cpp index 0fbbd49701..48253f7880 100644 --- a/src/servers/app/ProfileMessageSupport.cpp +++ b/src/servers/app/ProfileMessageSupport.cpp @@ -9,7 +9,7 @@ #include "ProfileMessageSupport.h" -#include "ServerProtocol.h" +#include void @@ -174,6 +174,11 @@ string_for_message_code(uint32 code, BString& string) case AS_GET_DECORATOR_SETTINGS: string = "AS_GET_DECORATOR_SETTINGS"; break; case AS_GET_SHOW_ALL_DRAGGERS: string = "AS_GET_SHOW_ALL_DRAGGERS"; break; case AS_SET_SHOW_ALL_DRAGGERS: string = "AS_SET_SHOW_ALL_DRAGGERS"; break; + + case AS_SET_FONT_SUBPIXEL_ANTIALIASING: string = "AS_SET_FONT_SUBPIXEL_ANTIALIASING"; break; + case AS_GET_FONT_SUBPIXEL_ANTIALIASING: string = "AS_GET_FONT_SUBPIXEL_ANTIALIASING"; break; + case AS_SET_HINTING: string = "AS_SET_HINTING"; break; + case AS_GET_HINTING: string = "AS_GET_HINTING"; break; // Graphics calls case AS_SET_HIGH_COLOR: string = "AS_SET_HIGH_COLOR"; break; diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index ca0a09864f..1198a2805a 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -9,6 +9,7 @@ * Stefano Ceccherini (burton666@libero.it) * Axel Dörfler, axeld@pinc-software.de * Jérôme Duval, jerome.duval@free.fr + * Andrej Spielmann, */ /*! @@ -2535,6 +2536,46 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } + case AS_SET_FONT_SUBPIXEL_ANTIALIASING: + { + bool subpix; + if (link.Read(&subpix) == B_OK) { + LockedDesktopSettings settings(fDesktop); + settings.SetFontSubpixelAntialiasing(subpix); + } + fDesktop->Redraw(); + break; + } + + case AS_GET_FONT_SUBPIXEL_ANTIALIASING: + { + DesktopSettings settings(fDesktop); + fLink.StartMessage(B_OK); + fLink.Attach(settings.FontSubpixelAntialiasing()); + fLink.Flush(); + break; + } + + case AS_SET_HINTING: + { + bool hinting; + if (link.Read(&hinting) == B_OK) { + LockedDesktopSettings settings(fDesktop); + settings.SetHinting(hinting); + } + fDesktop->Redraw(); + break; + } + + case AS_GET_HINTING: + { + DesktopSettings settings(fDesktop); + fLink.StartMessage(B_OK); + fLink.Attach(settings.Hinting()); + fLink.Flush(); + break; + } + default: printf("ServerApp %s received unhandled message code %ld\n", Signature(), code);