From c2ec1cfe8a468d3ebaabfb6695e7925fba5b1d29 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 13 Nov 2002 15:13:48 +0000 Subject: [PATCH] - Fixed userdefaults in WINGs not to synchronize on exit a domain that is marked not to be synchronized. - WMGLOBAL options can now be set in the WindowMaker configuration files to overwrite values in WMGLOBAL. - You can now pass "SystemFont", "BoldSystemFont", "SystemFont-##" or "BoldSystemFont-##", with ## being the font size to any font creating function to create a font with the (bold) system font font specification. - Replaced AA with Anitialiased in WINGs font creation function names - Added WMCreateFontWithFlags(), WMHasAntialiasingSupport() and WMIsAntialiasingEnabled() - Created a separate font cacahe for antialiased fonts - Added test at startup if Xft supports rendering antialiased fonts (in case the application was compiled with Xft support, but is run on an X server without support for xft rendering (RENDER extension missing). If no Xft support antialiasing will be disabled even if it is enabled in the configuration file. - Finished the Info Panel to work with antialiased fonts. - Code cleanup in dialog.c. Remade part of Info Panel drawing the Window Maker logo. - Fixed technical style drawing of window resizing. --- WINGs/ChangeLog | 19 ++-- WINGs/Examples/connect.c | 1 + WINGs/Examples/server.c | 1 + WINGs/NEWS | 56 ++++++++--- WINGs/Tests/testmywidget.c | 1 + WINGs/Tests/wmfile.c | 1 + WINGs/Tests/wmquery.c | 1 + WINGs/Tests/wtest.c | 4 +- WINGs/WINGs/WINGs.h | 183 ++++++++++++++++++++-------------- WINGs/WINGs/WINGsP.h | 8 +- WINGs/configuration.c | 8 +- WINGs/userdefaults.c | 48 +++++---- WINGs/wapplication.c | 10 +- WINGs/wfont.c | 223 +++++++++++++++++++++++++++++------------- WINGs/wframe.c | 2 +- WINGs/widgets.c | 17 +++- WINGs/wlist.c | 3 - WINGs/wtextfield.c | 3 +- WINGs/wview.c | 15 +-- WindowMaker/Defaults/WMGLOBAL | 2 +- src/dialog.c | 107 ++++++-------------- src/moveres.c | 13 +-- src/screen.c | 3 + src/screen.h | 2 + src/wconfig.h.in | 2 - 25 files changed, 432 insertions(+), 301 deletions(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index 5c18cbff..0c88c198 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -12,20 +12,23 @@ Changes since wmaker 0.80.1: WMCreateRGBAColor() and WMSetColorAlpha() - Miscelaneous code cleanups in wtext.c - Added Xft support in WINGs (for drawing antialiased fonts with transparency). -- Added a new function: WMCreateAAFont() to create a font which will be - drawn antialiased using Xft (if available, else function returns NULL) -- New options in WMGLOBAL: AntialiasedText, AASystemFont and AABoldSystemFont. - Check NEWS for details. +- Added a new function: WMCreateAntialiasedFont() to create a font which will + be drawn antialiased using Xft (if available, else function returns NULL) +- New options in WMGLOBAL: AntialiasedText, AntialiasedSystemFont and + AntialiasedBoldSystemFont. Check NEWS for details. - Fixed some improper calls to snprintf in wfont.c -- Added double buffering when drawing a WMFrame title with an AA font to avoid - flickering. +- Added double buffering when drawing a WMFrame title with an antialiased font + to avoid flickering. - Added double buffering when drawing WMList items to avoid flickering. Double buffering for list also works for user drawn lists. Read NEWS for details and incompatibilities introduced by this change. -- Added new Bool WMIsAAFont(WMFont *font) to check if a font is AA or not. +- Added WMIsAntialiasedFont(WMFont *font) to check if a font is antialiased. - Added WMGetColorAlpha(WMColor *color) -- Added WMCreateNonAAFont() - Better outline when drawing balloons. +- Added WMCreateFontWithFlags() +- You can now pass "SystemFont", "BoldSystemFont", "SystemFont-##" or + "BoldSystemFont-##", with ## being the font size to any font creating + function to create a font with the (bold) system font font specification. Changes since wmaker 0.80.0: diff --git a/WINGs/Examples/connect.c b/WINGs/Examples/connect.c index be753fb8..6f28fa9b 100644 --- a/WINGs/Examples/connect.c +++ b/WINGs/Examples/connect.c @@ -7,6 +7,7 @@ #include +#include #include #include diff --git a/WINGs/Examples/server.c b/WINGs/Examples/server.c index 502febcd..895ec9d2 100644 --- a/WINGs/Examples/server.c +++ b/WINGs/Examples/server.c @@ -7,6 +7,7 @@ #include +#include #include #include diff --git a/WINGs/NEWS b/WINGs/NEWS index 6ac1290e..28fad2d4 100644 --- a/WINGs/NEWS +++ b/WINGs/NEWS @@ -130,7 +130,7 @@ You need at least Xfree86 version 4.0.x for this but at least 4.1.x is recommended. For Xft support there is a new function to create a font that will render -using antialiasing and transparency: WMCreateAAFont(). +using antialiasing and transparency: WMCreateAntialiasedFont(). Passing such a font to WMDrawString() or WMDrawImageString() will result in antialiased text displayed on screen. Modifying the alpha value for the WMColor passed to WMDrawString() or WMDrawImageString() will result in text @@ -140,12 +140,12 @@ To control antialiased font behavior, there are 3 new options that go into WMGLOBAL. Two of them are to set the system font used when an antialiased font is required. They operate in a similar way as SystemFont and BoldSystemFont, just they are used when antialiased fonts are requested. -They are named AASystemFont respectively AABoldSystemFont. They are kept -separate from SystemFont and BoldSystemFont because the same fonts don't -render well as both normal and antialiased if they are not TrueType fonts. -Even though you can specify any font in the XLFD format for these new -options, it is recomended to use TrueType fonts for the antialiased case -since other fonts (standard X fonts) don't render well and give ugly +They are named AntialiasedSystemFont respectively AntialiasedBoldSystemFont. +They are kept separate from SystemFont and BoldSystemFont because the same +fonts don't render well as both normal and antialiased if they are not +TrueType fonts. Even though you can specify any font in the XLFD format for +these new options, it is recomended to use TrueType fonts for the antialiased +case since other fonts (standard X fonts) don't render well and give ugly results. The third option is an option that globally controls if WINGs uses or not @@ -155,11 +155,45 @@ was compiled in, and antialiased fonts can be found) then revert to normal fonts if not possible. Note that this applies if WMCreateFont(), WMSystemFont(), WMSystemFontOfSize(), WMBoldSystemFont() or WMBoldSystemFontOFize() are used. If any of the direct creation functions -are used, such as WMCreateAAFont() or WMCreateNormalFont(), then that kind -of font is returned independently of the value of AntialiasedText. +are used, such as WMCreateAntialiasedFont() or WMCreateNormalFont(), then +that kind of font is returned independently of the value of AntialiasedText. (However note that an antialiased font cannot be created if Xft support was -no compiled into WINGs, even if you call WMCreateAAFont() directly. In this -case WMCreateAAFont() will always return NULL) +no compiled into WINGs, even if you call WMCreateAntialiasedFont() directly. +In this case WMCreateAntialiasedFont() will always return NULL) + +These 3 options from WMGLOBAL (which apply to all WINGs applications) can be +overwritten on a per application basis by putting them in the application's +specific domain file (usually ~/GNUstep/Defaults/application_name). + +There is also another new font creation function available. +WMCreateFontWithFlags(screen, fontName, flags) + +flags will specify what kind of font to create. They are defined in WINGs.h +as an enum: WMFontFlags + +If WFDefaultFont is passed then the function will work exactly like +WMCreateFont() by creating a font according to the options from the +configuration. +However if some specific flag is passed than that option will be altered. All +the other options will keep their default values. + +There are 2 font options available (at this time): +1. Font type (if a normal font or a font set) +2. Font antialiasing (if it's an antialiased font or not) + +If flags specifies a value for each of the available options then a specific +font which only takes into account those flag values will be created and all +the font options specified in the configuration (like MultiByte or Antialiasing) +will be ignored. +However if only some of the options are specified, then for the missing options +the default values from the configuration will be used. + +For example if antialiasing is enabled in the configuration and you pass +WFNotAntialiased as the flag, then a font with all the properties defined in +the configuration (except antialiasing) will be created. This means that if +MultiByte is defined a fontset will be created, else a normal font will be +created and you don't have to worry about the rest of the flags you didn't +specify. diff --git a/WINGs/Tests/testmywidget.c b/WINGs/Tests/testmywidget.c index 2164f105..13e5e596 100644 --- a/WINGs/Tests/testmywidget.c +++ b/WINGs/Tests/testmywidget.c @@ -1,6 +1,7 @@ #include +#include #include "mywidget.h" diff --git a/WINGs/Tests/wmfile.c b/WINGs/Tests/wmfile.c index 9a82ed41..379d13db 100644 --- a/WINGs/Tests/wmfile.c +++ b/WINGs/Tests/wmfile.c @@ -17,6 +17,7 @@ #include #include +#include #include "logo.xpm" diff --git a/WINGs/Tests/wmquery.c b/WINGs/Tests/wmquery.c index f46ad78e..bd127589 100644 --- a/WINGs/Tests/wmquery.c +++ b/WINGs/Tests/wmquery.c @@ -8,6 +8,7 @@ #include #include +#include #include "logo.xpm" diff --git a/WINGs/Tests/wtest.c b/WINGs/Tests/wtest.c index f0936399..9fd9f920 100644 --- a/WINGs/Tests/wtest.c +++ b/WINGs/Tests/wtest.c @@ -5,7 +5,7 @@ #include #include - +#include /* @@ -1293,6 +1293,8 @@ main(int argc, char **argv) testDragAndDrop(scr); testText(scr); + testFontPanel(scr); + #if 0 testColorPanel(scr); testScrollView(scr); diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 3073cbd3..8cb37464 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -85,58 +85,83 @@ enum { /* button types */ typedef enum { /* 0 is reserved for internal use */ - WBTMomentaryPush = 1, - WBTPushOnPushOff = 2, - WBTToggle = 3, - WBTSwitch = 4, - WBTRadio = 5, - WBTMomentaryChange = 6, - WBTOnOff = 7, - WBTMomentaryLight = 8 + WBTMomentaryPush = 1, + WBTPushOnPushOff = 2, + WBTToggle = 3, + WBTSwitch = 4, + WBTRadio = 5, + WBTMomentaryChange = 6, + WBTOnOff = 7, + WBTMomentaryLight = 8 } WMButtonType; /* button behaviour masks */ enum { - WBBSpringLoadedMask = (1 << 0), - WBBPushInMask = (1 << 1), - WBBPushChangeMask = (1 << 2), - WBBPushLightMask = (1 << 3), - WBBStateLightMask = (1 << 5), - WBBStateChangeMask = (1 << 6), - WBBStatePushMask = (1 << 7) + WBBSpringLoadedMask = (1 << 0), + WBBPushInMask = (1 << 1), + WBBPushChangeMask = (1 << 2), + WBBPushLightMask = (1 << 3), + WBBStateLightMask = (1 << 5), + WBBStateChangeMask = (1 << 6), + WBBStatePushMask = (1 << 7) +}; + + +/* Font flags */ +typedef enum { + WFDefaultFont = 0, + WFNormalFont = (1<<0), + WFFontSet = (1<<1), + WFAntialiased = (1<<2), + WFNotAntialiased = (1<<3) +} WMFontFlags; + + +/* Font copy masks */ +typedef enum { + WFMUnchanged = 0, + WFMMediumWeight = 1, + WFMNormalWeight = 2, + WFMRegularWeight = 3 +} WMCopyFontMask; + + +/* Use default system font size in system font name */ +enum { + WFDefaultSize = -1 }; /* frame title positions */ typedef enum { WTPNoTitle, - WTPAboveTop, - WTPAtTop, - WTPBelowTop, - WTPAboveBottom, - WTPAtBottom, - WTPBelowBottom + WTPAboveTop, + WTPAtTop, + WTPBelowTop, + WTPAboveBottom, + WTPAtBottom, + WTPBelowBottom } WMTitlePosition; /* relief types */ typedef enum { WRFlat, - WRSimple, - WRRaised, - WRSunken, - WRGroove, - WRRidge, - WRPushed + WRSimple, + WRRaised, + WRSunken, + WRGroove, + WRRidge, + WRPushed } WMReliefType; /* alignment types */ typedef enum { WALeft, - WACenter, - WARight, - WAJustified /* not valid for textfields */ + WACenter, + WARight, + WAJustified /* not valid for textfields */ } WMAlignment; @@ -155,58 +180,58 @@ typedef enum { /* scroller arrow position */ typedef enum { WSAMaxEnd, - WSAMinEnd, - WSANone + WSAMinEnd, + WSANone } WMScrollArrowPosition; /* scroller parts */ typedef enum { WSNoPart, - WSDecrementPage, - WSIncrementPage, - WSDecrementLine, - WSIncrementLine, - WSDecrementWheel, - WSIncrementWheel, - WSKnob, - WSKnobSlot + WSDecrementPage, + WSIncrementPage, + WSDecrementLine, + WSIncrementLine, + WSDecrementWheel, + WSIncrementWheel, + WSKnob, + WSKnobSlot } WMScrollerPart; /* usable scroller parts */ typedef enum { WSUNoParts, - WSUOnlyArrows, - WSUAllParts + WSUOnlyArrows, + WSUAllParts } WMUsableScrollerParts; /* matrix types */ typedef enum { WMRadioMode, - WMHighlightMode, - WMListMode, - WMTrackMode + WMHighlightMode, + WMListMode, + WMTrackMode } WMMatrixTypes; typedef enum { WTTopTabsBevelBorder, - WTNoTabsBevelBorder, - WTNoTabsLineBorder, - WTNoTabsNoBorder + WTNoTabsBevelBorder, + WTNoTabsLineBorder, + WTNoTabsNoBorder } WMTabViewType; /* text movement types */ enum { WMIllegalTextMovement, - WMReturnTextMovement, - WMEscapeTextMovement, - WMTabTextMovement, - WMBacktabTextMovement, - WMLeftTextMovement, - WMRightTextMovement, - WMUpTextMovement, - WMDownTextMovement + WMReturnTextMovement, + WMEscapeTextMovement, + WMTabTextMovement, + WMBacktabTextMovement, + WMLeftTextMovement, + WMRightTextMovement, + WMUpTextMovement, + WMDownTextMovement }; /* text field special events */ @@ -233,13 +258,13 @@ typedef enum { typedef enum { - WMGrayModeColorPanel = 1, - WMRGBModeColorPanel = 2, - WMCMYKModeColorPanel = 3, - WMHSBModeColorPanel = 4, - WMCustomPaletteModeColorPanel = 5, - WMColorListModeColorPanel = 6, - WMWheelModeColorPanel = 7 + WMGrayModeColorPanel = 1, + WMRGBModeColorPanel = 2, + WMCMYKModeColorPanel = 3, + WMHSBModeColorPanel = 4, + WMCustomPaletteModeColorPanel = 5, + WMColorListModeColorPanel = 6, + WMWheelModeColorPanel = 7 } WMColorPanelMode; @@ -260,17 +285,17 @@ typedef enum { enum { WLDSSelected = (1 << 16), - WLDSDisabled = (1 << 17), - WLDSFocused = (1 << 18), - WLDSIsBranch = (1 << 19) + WLDSDisabled = (1 << 17), + WLDSFocused = (1 << 18), + WLDSIsBranch = (1 << 19) }; /* alert panel return values */ enum { WAPRDefault = 0, - WAPRAlternate = 1, - WAPROther = -1, - WAPRError = -2 + WAPRAlternate = 1, + WAPROther = -1, + WAPRError = -2 }; @@ -278,8 +303,8 @@ enum { /* types of input observers */ enum { WIReadMask = (1 << 0), - WIWriteMask = (1 << 1), - WIExceptMask = (1 << 2) + WIWriteMask = (1 << 1), + WIExceptMask = (1 << 2) }; @@ -314,7 +339,7 @@ enum { typedef struct W_WidgetType { W_Class widgetClass; struct W_View *view; - + } W_WidgetType; @@ -695,23 +720,29 @@ WMPoint WMGetDraggingInfoImageLocation(WMDraggingInfo *info); /* ....................................................................... */ +Bool WMHasAntialiasingSupport(WMScreen *scrPtr); + +Bool WMIsAntialiasingEnabled(WMScreen *scrPtr); + +/* ....................................................................... */ + WMFont* WMCreateFontSet(WMScreen *scrPtr, char *fontName); WMFont* WMCreateNormalFont(WMScreen *scrPtr, char *fontName); -WMFont* WMCreateAAFont(WMScreen *scrPtr, char *fontName); - -WMFont* WMCreateNonAAFont(WMScreen *scrPtr, char *fontName); +WMFont* WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName); WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName); +WMFont* WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags); + WMFont* WMRetainFont(WMFont *font); void WMReleaseFont(WMFont *font); unsigned int WMFontHeight(WMFont *font); -Bool WMIsAAFont(WMFont *font); +Bool WMIsAntialiasedFont(WMFont *font); /* WMFont* WMUserFontOfSize(WMScreen *scrPtr, int size); diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h index 68b34928..3cbd6d02 100644 --- a/WINGs/WINGs/WINGsP.h +++ b/WINGs/WINGs/WINGsP.h @@ -131,14 +131,16 @@ typedef struct W_Screen { Window rootWin; - struct _XftDraw *xftdraw; - struct W_View *rootView; RContext *rcontext; struct W_IMContext *imctx; + struct _XftDraw *xftdraw; /* shared XftDraw */ + + Bool hasXftSupport; /* if it can antialias text */ + /* application related */ W_FocusInfo *focusInfo; @@ -198,6 +200,8 @@ typedef struct W_Screen { WMHashTable *fontCache; + WMHashTable *xftFontCache; + WMHashTable *fontSetCache; Bool useMultiByte; diff --git a/WINGs/configuration.c b/WINGs/configuration.c index d3f674e0..0b2ee2fc 100644 --- a/WINGs/configuration.c +++ b/WINGs/configuration.c @@ -14,9 +14,9 @@ _WINGsConfiguration WINGsConfiguration; #define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*" -#define AASYSTEM_FONT "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*" +#define XFTSYSTEM_FONT "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*" -#define AABOLD_SYSTEM_FONT "-*-arial-bold-r-normal-*-%d-*-*-*-*-*-*-*" +#define XFTBOLD_SYSTEM_FONT "-*-arial-bold-r-normal-*-%d-*-*-*-*-*-*-*" #define FLOPPY_PATH "/floppy" @@ -140,10 +140,10 @@ W_ReadConfigurations(void) WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT; } if (!WINGsConfiguration.antialiasedSystemFont) { - WINGsConfiguration.antialiasedSystemFont = AASYSTEM_FONT; + WINGsConfiguration.antialiasedSystemFont = XFTSYSTEM_FONT; } if (!WINGsConfiguration.antialiasedBoldSystemFont) { - WINGsConfiguration.antialiasedBoldSystemFont = AABOLD_SYSTEM_FONT; + WINGsConfiguration.antialiasedBoldSystemFont = XFTBOLD_SYSTEM_FONT; } if (!WINGsConfiguration.floppyPath) { WINGsConfiguration.floppyPath = FLOPPY_PATH; diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index aed5f464..b6744070 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -39,6 +39,7 @@ static UserDefaults *sharedUserDefaults = NULL; char *WMUserDefaultsDidChangeNotification = "WMUserDefaultsDidChangeNotification"; +static void synchronizeUserDefaults(void *foo); extern char *WMGetApplicationName(); @@ -93,19 +94,14 @@ wdefaultspathfordomain(char *domain) static void -#ifndef HAVE_ATEXIT -saveDefaultsChanges(int foo, void *bar) -#else +#ifdef HAVE_ATEXIT saveDefaultsChanges(void) +#else +saveDefaultsChanges(int foo, void *bar) #endif { /* save the user defaults databases */ - UserDefaults *tmp = sharedUserDefaults; - - while (tmp) { - WMSynchronizeUserDefaults(tmp); - tmp = tmp->next; - } + synchronizeUserDefaults(NULL); } @@ -116,10 +112,10 @@ registerSaveOnExit(void) static Bool registeredSaveOnExit = False; if (!registeredSaveOnExit) { -#ifndef HAVE_ATEXIT - on_exit(saveDefaultsChanges, (void*)NULL); -#else +#ifdef HAVE_ATEXIT atexit(saveDefaultsChanges); +#else + on_exit(saveDefaultsChanges, (void*)NULL); #endif registeredSaveOnExit = True; } @@ -136,7 +132,6 @@ synchronizeUserDefaults(void *foo) WMSynchronizeUserDefaults(database); database = database->next; } - WMAddTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, NULL); } @@ -146,7 +141,8 @@ addSynchronizeTimerHandler(void) static Bool initialized = False; if (!initialized) { - WMAddTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, NULL); + WMAddPersistentTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, + NULL); initialized = True; } } @@ -265,7 +261,7 @@ WMGetStandardUserDefaults(void) if (sharedUserDefaults) { defaults = sharedUserDefaults; while (defaults) { - /* Trick, path == NULL only for StandardUserDefaults db */ + /* path == NULL only for StandardUserDefaults db */ if (defaults->path == NULL) return defaults; defaults = defaults->next; @@ -284,18 +280,17 @@ WMGetStandardUserDefaults(void) key = WMCreatePLString(WMGetApplicationName()); defaults->searchList[0] = key; - /* temporary kluge */ + /* temporary kluge. wmaker handles synchronization itself */ if (strcmp(WMGetApplicationName(), "WindowMaker")==0) { - domain = NULL; - path = NULL; - } else { - path = wdefaultspathfordomain(WMGetFromPLString(key)); + defaults->dontSync = 1; + } - if (stat(path, &stbuf) >= 0) - defaults->timestamp = stbuf.st_mtime; + path = wdefaultspathfordomain(WMGetFromPLString(key)); - domain = WMReadPropListFromFile(path); - } + if (stat(path, &stbuf) >= 0) + defaults->timestamp = stbuf.st_mtime; + + domain = WMReadPropListFromFile(path); if (!domain) domain = WMCreatePLDictionary(NULL, NULL, NULL); @@ -332,7 +327,7 @@ WMGetStandardUserDefaults(void) i = 0; while (defaults->searchList[i]) { WMAddToPLArray(defaults->searchListArray, - defaults->searchList[i]); + defaults->searchList[i]); i++; } @@ -409,7 +404,7 @@ WMGetDefaultsFromPath(char *path) i = 0; while (defaults->searchList[i]) { WMAddToPLArray(defaults->searchListArray, - defaults->searchList[i]); + defaults->searchList[i]); i++; } @@ -669,6 +664,7 @@ WMSetUDSearchList(WMUserDefaults *database, WMPropList *list) for (i=0; isearchList[i] = WMGetFromPLArray(list, i); } + database->searchList[c] = NULL; database->searchListArray = WMDeepCopyPropList(list); } diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c index 1b4c32f4..91f835e3 100644 --- a/WINGs/wapplication.c +++ b/WINGs/wapplication.c @@ -34,19 +34,19 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv) assert(argc!=NULL); assert(argv!=NULL); assert(applicationName!=NULL); - + /* // TODO: check if to move inside #ifdef I18N */ setlocale(LC_ALL, ""); - + #ifdef I18N if (getenv("NLSPATH")) bindtextdomain("WINGs", getenv("NLSPATH")); else bindtextdomain("WINGs", LOCALEDIR); #endif - + _WINGS_progname = argv[0]; - + WMApplication.applicationName = wstrdup(applicationName); WMApplication.argc = *argc; @@ -55,7 +55,7 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv) WMApplication.argv[i] = wstrdup(argv[i]); } WMApplication.argv[i] = NULL; - + /* initialize notification center */ W_InitNotificationCenter(); } diff --git a/WINGs/wfont.c b/WINGs/wfont.c index 840af4ec..098803c0 100644 --- a/WINGs/wfont.c +++ b/WINGs/wfont.c @@ -104,6 +104,51 @@ W_CreateFontSetWithGuess(Display *dpy, char *xlfd, char ***missing, } +static char* +xlfdFromFontName(char *fontName, Bool antialiased) +{ + char *systemFont, *boldSystemFont; + char *font; + int size; + + if (antialiased) { + systemFont = WINGsConfiguration.antialiasedSystemFont; + boldSystemFont = WINGsConfiguration.antialiasedBoldSystemFont; + } else { + systemFont = WINGsConfiguration.systemFont; + boldSystemFont = WINGsConfiguration.boldSystemFont; + } + + size = WINGsConfiguration.defaultFontSize; + + if (strcmp(fontName, "SystemFont")==0) { + font = systemFont; + size = WINGsConfiguration.defaultFontSize; + } else if (strncmp(fontName, "SystemFont-", 11)==0) { + font = systemFont; + if (sscanf(&fontName[11], "%i", &size)!=1) { + size = WINGsConfiguration.defaultFontSize; + wwarning(_("Invalid size specification '%s' in %s. " + "Using default %d\n"), &fontName[11], fontName, size); + } + } else if (strcmp(fontName, "BoldSystemFont")==0) { + font = boldSystemFont; + size = WINGsConfiguration.defaultFontSize; + } else if (strncmp(fontName, "BoldSystemFont-", 15)==0) { + font = boldSystemFont; + if (sscanf(&fontName[15], "%i", &size)!=1) { + size = WINGsConfiguration.defaultFontSize; + wwarning(_("Invalid size specification '%s' in %s. " + "Using default %d\n"), &fontName[15], fontName, size); + } + } else { + font = NULL; + } + + return (font!=NULL ? makeFontSetOfSize(font, size) : wstrdup(fontName)); +} + + WMFont* WMCreateFontSet(WMScreen *scrPtr, char *fontName) { @@ -112,17 +157,19 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName) char **missing; int nmissing = 0; char *defaultString; + char *fname; XFontSetExtents *extents; - font = WMHashGet(scrPtr->fontSetCache, fontName); + fname = xlfdFromFontName(fontName, False); + + font = WMHashGet(scrPtr->fontSetCache, fname); if (font) { - WMRetainFont(font); + WMRetainFont(font); + wfree(fname); return font; } - font = malloc(sizeof(WMFont)); - if (!font) - return NULL; + font = wmalloc(sizeof(WMFont)); memset(font, 0, sizeof(WMFont)); font->notFontSet = 0; @@ -130,13 +177,12 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName) font->screen = scrPtr; - font->font.set = W_CreateFontSetWithGuess(display, fontName, &missing, + font->font.set = W_CreateFontSetWithGuess(display, fname, &missing, &nmissing, &defaultString); if (nmissing > 0 && font->font.set) { int i; - wwarning(_("the following character sets are missing in %s:"), - fontName); + wwarning(_("the following character sets are missing in %s:"), fname); for (i = 0; i < nmissing; i++) { wwarning(missing[i]); } @@ -146,7 +192,8 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName) defaultString); } if (!font->font.set) { - wfree(font); + wfree(font); + wfree(fname); return NULL; } @@ -157,7 +204,7 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName) font->refCount = 1; - font->name = wstrdup(fontName); + font->name = fname; assert(WMHashInsert(scrPtr->fontSetCache, font->name, font)==NULL); @@ -173,6 +220,8 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName) Display *display = scrPtr->display; char *fname, *ptr; + fontName = xlfdFromFontName(fontName, False); + if ((ptr = strchr(fontName, ','))) { fname = wmalloc(ptr - fontName + 1); strncpy(fname, fontName, ptr - fontName); @@ -181,6 +230,8 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName) fname = wstrdup(fontName); } + wfree(fontName); + font = WMHashGet(scrPtr->fontCache, fname); if (font) { WMRetainFont(font); @@ -188,11 +239,7 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName) return font; } - font = malloc(sizeof(WMFont)); - if (!font) { - wfree(fname); - return NULL; - } + font = wmalloc(sizeof(WMFont)); memset(font, 0, sizeof(WMFont)); font->notFontSet = 1; @@ -220,13 +267,18 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName) WMFont* -WMCreateAAFont(WMScreen *scrPtr, char *fontName) +WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName) { #ifdef XFT WMFont *font; Display *display = scrPtr->display; char *fname, *ptr; + if (!scrPtr->hasXftSupport) + return NULL; + + fontName = xlfdFromFontName(fontName, True); + if ((ptr = strchr(fontName, ','))) { fname = wmalloc(ptr - fontName + 1); strncpy(fname, fontName, ptr - fontName); @@ -235,18 +287,16 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName) fname = wstrdup(fontName); } - font = WMHashGet(scrPtr->fontCache, fname); + wfree(fontName); + + font = WMHashGet(scrPtr->xftFontCache, fname); if (font) { WMRetainFont(font); wfree(fname); return font; } - font = malloc(sizeof(WMFont)); - if (!font) { - wfree(fname); - return NULL; - } + font = wmalloc(sizeof(WMFont)); memset(font, 0, sizeof(WMFont)); font->notFontSet = 1; @@ -254,7 +304,9 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName) font->screen = scrPtr; - /* // Xft sux */ +#if 0 + /* // Xft sux. Loading a font that doesn't exist will load the default + * defined in XftConfig without any warning or error */ font->font.normal = XLoadQueryFont(display, fname); if (!font->font.normal) { wfree(font); @@ -262,6 +314,7 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName) return NULL; } XFreeFont(display, font->font.normal); +#endif font->font.xft = XftFontOpenXlfd(display, scrPtr->screen, fname); if (!font->font.xft) { @@ -276,7 +329,7 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName) font->name = fname; - assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL); + assert(WMHashInsert(scrPtr->xftFontCache, font->name, font)==NULL); return font; #else @@ -286,27 +339,48 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName) WMFont* -WMCreateNonAAFont(WMScreen *scrPtr, char *fontName) +WMCreateFont(WMScreen *scrPtr, char *fontName) { - if (scrPtr->useMultiByte) { - return WMCreateFontSet(scrPtr, fontName); - } else { - return WMCreateNormalFont(scrPtr, fontName); - } + return WMCreateFontWithFlags(scrPtr, fontName, WFDefaultFont); } WMFont* -WMCreateFont(WMScreen *scrPtr, char *fontName) +WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags) { - if (scrPtr->useMultiByte) { - return WMCreateFontSet(scrPtr, fontName); - } else if (scrPtr->antialiasedText) { - WMFont *font = WMCreateAAFont(scrPtr, fontName); - return font ? font : WMCreateNormalFont(scrPtr, fontName); + Bool multiByte = scrPtr->useMultiByte; + Bool antialiased = scrPtr->antialiasedText; + WMFont *font; + + if (flags & WFFontSet) { + multiByte = True; + } else if (flags & WFNormalFont) { + multiByte = False; + } + if (flags & WFAntialiased) { + antialiased = True; + } else if (flags & WFNotAntialiased) { + antialiased = False; + } + + /* Multibyte with antialiasing is not implemented. To avoid problems, + * if both multiByte and antialiasing are enabled, ignore antialiasing + * and return a FontSet. + */ + if (multiByte) { + font = WMCreateFontSet(scrPtr, fontName); + } else if (antialiased) { + font = WMCreateAntialiasedFont(scrPtr, fontName); + /* If we cannot create an antialiased font and antialiasing is + * not explicitly requested in flags, fallback to normal font */ + if (!font && (flags & WFAntialiased)==0) { + font = WMCreateNormalFont(scrPtr, fontName); + } } else { - return WMCreateNormalFont(scrPtr, fontName); + font = WMCreateNormalFont(scrPtr, fontName); } + + return font; } @@ -341,8 +415,10 @@ WMReleaseFont(WMFont *font) } else { XFreeFontSet(font->screen->display, font->font.set); } - if (font->name) { - if (font->notFontSet) { + if (font->name) { + if (font->antialiased) { + WMHashRemove(font->screen->xftFontCache, font->name); + } else if (font->notFontSet) { WMHashRemove(font->screen->fontCache, font->name); } else { WMHashRemove(font->screen->fontSetCache, font->name); @@ -355,7 +431,21 @@ WMReleaseFont(WMFont *font) Bool -WMIsAAFont(WMFont *font) +WMHasAntialiasingSupport(WMScreen *scrPtr) +{ + return scrPtr->hasXftSupport; +} + + +Bool +WMIsAntialiasingEnabled(WMScreen *scrPtr) +{ + return scrPtr->antialiasedText; +} + + +Bool +WMIsAntialiasedFont(WMFont *font) { return font->antialiased; } @@ -388,22 +478,22 @@ static WMFont* makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold) { WMFont *font; - char *fontSpec, *aaFontSpec; + char *fontSpec, *xftFontSpec; #define WConf WINGsConfiguration if (bold) { fontSpec = makeFontSetOfSize(WConf.boldSystemFont, size); - aaFontSpec = makeFontSetOfSize(WConf.antialiasedBoldSystemFont, size); + xftFontSpec = makeFontSetOfSize(WConf.antialiasedBoldSystemFont, size); } else { fontSpec = makeFontSetOfSize(WConf.systemFont, size); - aaFontSpec = makeFontSetOfSize(WConf.antialiasedSystemFont, size); + xftFontSpec = makeFontSetOfSize(WConf.antialiasedSystemFont, size); } #undef WConf if (scrPtr->useMultiByte) { font = WMCreateFontSet(scrPtr, fontSpec); } else if (scrPtr->antialiasedText) { - font = WMCreateAAFont(scrPtr, aaFontSpec); + font = WMCreateAntialiasedFont(scrPtr, xftFontSpec); } else { font = WMCreateNormalFont(scrPtr, fontSpec); } @@ -416,11 +506,11 @@ makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold) font = WMCreateFontSet(scrPtr, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*"); } } else if (scrPtr->antialiasedText) { - wwarning(_("could not load font %s. Trying arial."), aaFontSpec); + wwarning(_("could not load font %s. Trying arial."), xftFontSpec); if (bold) { - font = WMCreateAAFont(scrPtr, "-*-arial-bold-r-normal-*-12-*-*-*-*-*-*-*"); + font = WMCreateAntialiasedFont(scrPtr, "-*-arial-bold-r-normal-*-12-*-*-*-*-*-*-*"); } else { - font = WMCreateAAFont(scrPtr, "-*-arial-medium-r-normal-*-12-*-*-*-*-*-*-*"); + font = WMCreateAntialiasedFont(scrPtr, "-*-arial-medium-r-normal-*-12-*-*-*-*-*-*-*"); } if (!font) { wwarning(_("could not load antialiased fonts. Reverting to normal fonts.")); @@ -437,12 +527,12 @@ makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold) if (!font) { wwarning(_("could not load fixed font!")); wfree(fontSpec); - wfree(aaFontSpec); + wfree(xftFontSpec); return NULL; } } wfree(fontSpec); - wfree(aaFontSpec); + wfree(xftFontSpec); return font; } @@ -682,6 +772,7 @@ WMFont* WMNormalizeFont(WMScreen *scr, WMFont *font) { char fname[256]; + WMFontFlags flag; if (!scr || !font) return NULL; @@ -689,10 +780,8 @@ WMNormalizeFont(WMScreen *scr, WMFont *font) snprintf(fname, 255, "%s", font->name); changeFontProp(fname, "medium", 2); changeFontProp(fname, "r", 3); - if (font->antialiased) - return WMCreateAAFont(scr, fname); - else - return WMCreateNonAAFont(scr, fname); + flag = (font->antialiased ? WFAntialiased : WFNotAntialiased); + return WMCreateFontWithFlags(scr, fname, flag); } @@ -700,16 +789,15 @@ WMFont* WMStrengthenFont(WMScreen *scr, WMFont *font) { char fname[256]; + WMFontFlags flag; if (!scr || !font) return NULL; snprintf(fname, 255, "%s", font->name); changeFontProp(fname, "bold", 2); - if (font->antialiased) - return WMCreateAAFont(scr, fname); - else - return WMCreateNonAAFont(scr, fname); + flag = (font->antialiased ? WFAntialiased : WFNotAntialiased); + return WMCreateFontWithFlags(scr, fname, flag); } @@ -717,16 +805,15 @@ WMFont* WMUnstrengthenFont(WMScreen *scr, WMFont *font) { char fname[256]; + WMFontFlags flag; if (!scr || !font) return NULL; snprintf(fname, 255, "%s", font->name); changeFontProp(fname, "medium", 2); - if (font->antialiased) - return WMCreateAAFont(scr, fname); - else - return WMCreateNonAAFont(scr, fname); + flag = (font->antialiased ? WFAntialiased : WFNotAntialiased); + return WMCreateFontWithFlags(scr, fname, flag); } @@ -734,6 +821,7 @@ WMFont* WMEmphasizeFont(WMScreen *scr, WMFont *font) { char fname[256]; + WMFontFlags flag; if (!scr || !font) return NULL; @@ -744,10 +832,8 @@ WMEmphasizeFont(WMScreen *scr, WMFont *font) else changeFontProp(fname, "o", 3); - if (font->antialiased) - return WMCreateAAFont(scr, fname); - else - return WMCreateNonAAFont(scr, fname); + flag = (font->antialiased ? WFAntialiased : WFNotAntialiased); + return WMCreateFontWithFlags(scr, fname, flag); } @@ -755,16 +841,15 @@ WMFont* WMUnemphasizeFont(WMScreen *scr, WMFont *font) { char fname[256]; + WMFontFlags flag; if (!scr || !font) return NULL; snprintf(fname, 255, "%s", font->name); changeFontProp(fname, "r", 3); - if (font->antialiased) - return WMCreateAAFont(scr, fname); - else - return WMCreateNonAAFont(scr, fname); + flag = (font->antialiased ? WFAntialiased : WFNotAntialiased); + return WMCreateFontWithFlags(scr, fname, flag); } diff --git a/WINGs/wframe.c b/WINGs/wframe.c index c095c50e..af3ac63b 100644 --- a/WINGs/wframe.c +++ b/WINGs/wframe.c @@ -197,7 +197,7 @@ paintFrame(Frame *fPtr) if (drawTitle) { /* can't draw AA text over and over again because it gets messed */ - // TODO create the dbl buffer pixmap when create/set frame title + /* // TODO create the dbl buffer pixmap when create/set frame title */ if (font->antialiased) { Drawable d; diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 282c36eb..25578a17 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -622,9 +622,13 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context) scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); + scrPtr->xftFontCache = WMCreateHashTable(WMStringPointerHashCallbacks); + scrPtr->fontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks); #ifdef XFT + scrPtr->hasXftSupport = XftDefaultHasRender(scrPtr->display); + scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr), scrPtr->visual, scrPtr->colormap); #endif @@ -680,7 +684,7 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context) ShiftMask,LockMask,ControlMask,Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; - unsigned int numLockMask, scrollLockMask; + unsigned int numLockMask=0, scrollLockMask=0; nlock = XKeysymToKeycode(display, XK_Num_Lock); slock = XKeysymToKeycode(display, XK_Scroll_Lock); @@ -757,7 +761,16 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context) scrPtr->useMultiByte = WINGsConfiguration.useMultiByte; - scrPtr->antialiasedText = WINGsConfiguration.antialiasedText; + if (scrPtr->hasXftSupport) { + scrPtr->antialiasedText = WINGsConfiguration.antialiasedText; + } else { + if (WINGsConfiguration.antialiasedText) { + wwarning(_("Text antialiasing is enabled in the configuration but" + " the X server doesn't have the required capabilities " + "(missing RENDER extension). Disabling text antialiasing.")); + } + scrPtr->antialiasedText = False; + } scrPtr->normalFont = WMSystemFontOfSize(scrPtr, WINGsConfiguration.defaultFontSize); diff --git a/WINGs/wlist.c b/WINGs/wlist.c index b8b09182..911b434d 100644 --- a/WINGs/wlist.c +++ b/WINGs/wlist.c @@ -303,8 +303,6 @@ WMSetListUserDrawProc(WMList *lPtr, WMListDrawProc *proc) void WMSetListUserDrawItemHeight(WMList *lPtr, unsigned short height) { - W_Screen *scr = lPtr->view->screen; - assert(height > 0); lPtr->flags.userItemHeight = 1; @@ -1234,7 +1232,6 @@ static void didResizeList(W_ViewDelegate *self, WMView *view) { WMList *lPtr = (WMList*)view->self; - W_Screen *scr = view->screen; WMResizeWidget(lPtr->vScroller, 1, view->size.height-2); diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index e318bc68..71a5b2cb 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -757,6 +757,7 @@ paintCursor(TextField *tPtr) tPtr->view->size.height - 2*tPtr->offsetWidth - 1); printf("%d %d\n",cx,tPtr->cursorPosition); */ + XDrawLine(screen->display, tPtr->view->window, screen->xorGC, cx, tPtr->offsetWidth, cx, tPtr->view->size.height - tPtr->offsetWidth - 1); @@ -1553,7 +1554,7 @@ handleTextFieldActionEvents(XEvent *event, void *data) <= WINGsConfiguration.doubleClickDelay) { tPtr->selection.position = 0; tPtr->selection.count = tPtr->textLen; - paintTextField(tPtr); + paintTextField(tPtr); if (!tPtr->flags.ownsSelection) { tPtr->flags.ownsSelection = diff --git a/WINGs/wview.c b/WINGs/wview.c index 05ab0009..62cf1402 100644 --- a/WINGs/wview.c +++ b/WINGs/wview.c @@ -481,12 +481,12 @@ void W_MoveView(W_View *view, int x, int y) { assert(view->flags.root==0); - //TODO move this after the test pos==oldpos + if (view->delegate && view->delegate->willMove) { (*view->delegate->willMove)(view->delegate, view, &x, &y); } - if (view->pos.x == x && view->pos.y == y) + if (view->pos.x == x && view->pos.y == y) return; if (view->flags.realized) { @@ -504,8 +504,8 @@ W_MoveView(W_View *view, int x, int y) void W_ResizeView(W_View *view, unsigned int width, unsigned int height) { - int shrinked; - // TODO move this after the test size==oldsize + /*int shrinked;*/ + if (view->delegate && view->delegate->willResize) { (*view->delegate->willResize)(view->delegate, view, &width, &height); } @@ -515,9 +515,9 @@ W_ResizeView(W_View *view, unsigned int width, unsigned int height) if (view->size.width == width && view->size.height == height) return; - - shrinked = width < view->size.width || height < view->size.height; - + + /*shrinked = width < view->size.width || height < view->size.height;*/ + if (view->flags.realized) { XResizeWindow(view->screen->display, view->window, width, height); } @@ -528,6 +528,7 @@ W_ResizeView(W_View *view, unsigned int width, unsigned int height) (*view->delegate->didResize)(view->delegate, view); } + /* // TODO. replace in WINGs code, with the didResize delegate */ if (view->flags.notifySizeChanged) WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL); } diff --git a/WindowMaker/Defaults/WMGLOBAL b/WindowMaker/Defaults/WMGLOBAL index da171924..cbad1350 100644 --- a/WindowMaker/Defaults/WMGLOBAL +++ b/WindowMaker/Defaults/WMGLOBAL @@ -4,7 +4,7 @@ AntialiasedSystemFont = "-*-trebuchet ms-medium-r-normal-*-%d-*-*-*-*-*-*-*"; AntialiasedBoldSystemFont = "-*-trebuchet ms-bold-r-normal-*-%d-*-*-*-*-*-*-*"; DefaultFontSize = 12; - AntialiasedText = NO; + AntialiasedText = No; MultiByteText = AUTO; FloppyPath = "/floppy"; DoubleClickTime = 250; diff --git a/src/dialog.c b/src/dialog.c index 4e7d9f60..4ece8359 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -62,6 +62,8 @@ #include "defaults.h" #include "xinerama.h" + + extern WPreferences wPreferences; @@ -844,6 +846,7 @@ typedef struct { WMLabel *logoL; WMLabel *name1L; + WMFrame *lineF; WMLabel *name2L; WMLabel *versionL; @@ -906,53 +909,6 @@ destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event) } -WMPixmap* -renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to) -{ - WMPixmap *wpix = NULL; - Pixmap grad = None; - Pixmap mask = None; - RContext *rc = WMScreenRContext(scr); - XFontStruct *f = NULL; - int w, h; - GC gc = None; - - f = XLoadQueryFont(dpy, font); - if (!f) - return NULL; - - w = XTextWidth(f, text, strlen(text)); - h = f->ascent+f->descent; - - mask = XCreatePixmap(dpy, rc->drawable, w, h, 1); - gc = XCreateGC(dpy, mask, 0, NULL); - XSetForeground(dpy, gc, 0); - XSetFont(dpy, gc, f->fid); - XFillRectangle(dpy, mask, gc, 0, 0, w, h); - - XSetForeground(dpy, gc, 1); - XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text)); - XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter); - XDrawLine(dpy, mask, gc, 0, h-2, w, h-2); - - grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth); - { - WMColor *color; - - color = WMBlackColor(scr); - XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h); - WMReleaseColor(color); - } - - wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth); - - if (gc) - XFreeGC(dpy, gc); - XFreeFont(dpy, f); - - return wpix; -} - #ifdef SILLYNESS extern WMPixmap *DoXThing(); @@ -1221,7 +1177,7 @@ handleLogoPush(XEvent *event, void *data) /* Alternatively we can draw text in a pixmap and scroll it smoothly */ if ((panel->oldFont = WMGetLabelFont(panel->versionL))!=NULL) WMRetainFont(panel->oldFont); - font = WMCreateFont(WMWidgetScreen(panel->versionL), "-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*"); + font = WMCreateFont(WMWidgetScreen(panel->versionL), "-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*"); if (font) { WMSetLabelFont(panel->versionL, font); WMReleaseFont(font); @@ -1269,9 +1225,8 @@ wShowInfoPanel(WScreen *scr) char buffer[256]; Window parent; WWindow *wwin; - RColor color1, color2; char **strl; - int i; + int i, width, sepWidth; char *visuals[] = { "StaticGray", "GrayScale", @@ -1296,7 +1251,7 @@ wShowInfoPanel(WScreen *scr) panel->scr = scr; panel->win = WMCreateWindow(scr->wmscreen, "info"); - WMResizeWidget(panel->win, 382, 230); + WMResizeWidget(panel->win, 390, 230); logo = WMCreateApplicationIconBlendedPixmap(scr->wmscreen, (RColor*)NULL); if (!logo) { @@ -1316,30 +1271,31 @@ wShowInfoPanel(WScreen *scr) WMReleasePixmap(logo); } + sepWidth = 3; panel->name1L = WMCreateLabel(panel->win); - WMResizeWidget(panel->name1L, 240, 30); + WMResizeWidget(panel->name1L, 240, 30 - sepWidth); WMMoveWidget(panel->name1L, 100, 30); - color1.red = 0; - color1.green = 0; - color1.blue = 0; - color2.red = 0x50; - color2.green = 0x50; - color2.blue = 0x70; - logo = renderText(scr->wmscreen, "Window Maker", - "-*-utopia-*-r-*-*-25-*", &color1, &color2); - if (logo) { - WMSetLabelImagePosition(panel->name1L, WIPImageOnly); - WMSetLabelImage(panel->name1L, logo); - WMReleasePixmap(logo); + + if (WMIsAntialiasingEnabled(scr->wmscreen)) { + font = WMBoldSystemFontOfSize(scr->wmscreen, 24); } else { - font = WMBoldSystemFontOfSize(scr->wmscreen, 20); - if (font) { - WMSetLabelFont(panel->name1L, font); - WMReleaseFont(font); - } - WMSetLabelTextAlignment(panel->name1L, WACenter); - WMSetLabelText(panel->name1L, "Window Maker"); + font = WMCreateFont(scr->wmscreen, "-*-utopia-*-r-*-*-25-*"); + font = font ? font : WMBoldSystemFontOfSize(scr->wmscreen, 24); } + strbuf = "Window Maker"; + if (font) { + width = WMWidthOfString(font, strbuf, strlen(strbuf)); + WMSetLabelFont(panel->name1L, font); + WMReleaseFont(font); + } + WMSetLabelTextAlignment(panel->name1L, WACenter); + WMSetLabelText(panel->name1L, strbuf); + + panel->lineF = WMCreateFrame(panel->win); + WMResizeWidget(panel->lineF, width, sepWidth); + WMMoveWidget(panel->lineF, 100+(240-width)/2, 60 - sepWidth); + WMSetFrameRelief(panel->lineF, WRSimple); + WMSetWidgetBackgroundColor(panel->lineF, scr->black); panel->name2L = WMCreateLabel(panel->win); WMResizeWidget(panel->name2L, 240, 24); @@ -1353,7 +1309,6 @@ wShowInfoPanel(WScreen *scr) WMSetLabelTextAlignment(panel->name2L, WACenter); WMSetLabelText(panel->name2L, _("Window Manager for X")); - snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION); panel->versionL = WMCreateLabel(panel->win); WMResizeWidget(panel->versionL, 310, 16); @@ -1363,12 +1318,12 @@ wShowInfoPanel(WScreen *scr) WMSetLabelWraps(panel->versionL, False); panel->copyrL = WMCreateLabel(panel->win); - WMResizeWidget(panel->copyrL, 340, 40); + WMResizeWidget(panel->copyrL, 360, 40); WMMoveWidget(panel->copyrL, 15, 185); WMSetLabelTextAlignment(panel->copyrL, WALeft); WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT); - /* we want the (c) character in the helvetica font */ - font = WMCreateNormalFont(scr->wmscreen, HELVETICA10_FONT); + /* we want the (c) character in the font, so don't use a FontSet here */ + font = WMCreateFontWithFlags(scr->wmscreen, "SystemFont-11", WFNormalFont); if (font) { WMSetLabelFont(panel->copyrL, font); WMReleaseFont(font); @@ -1461,7 +1416,7 @@ wShowInfoPanel(WScreen *scr) WMResizeWidget(panel->infoL, 350, 75); WMMoveWidget(panel->infoL, 15, 115); WMSetLabelText(panel->infoL, strbuf); - font = WMCreateFont(scr->wmscreen, HELVETICA10_FONT); + font = WMSystemFontOfSize(scr->wmscreen, 11); if (font) { WMSetLabelFont(panel->infoL, font); WMReleaseFont(font); diff --git a/src/moveres.c b/src/moveres.c index 06b7109a..b8238ae6 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -226,10 +226,11 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) ty = y1 + wwin->frame->top_width; by = y2 - wwin->frame->bottom_width; - fw = WMWidthOfString(scr->info_text_font, "8888", 4); - fh = WMFontHeight(scr->info_text_font); if (wPreferences.size_display == WDIS_NEW) { + fw = WMWidthOfString(scr->tech_draw_font, "8888", 4); + fh = WMFontHeight(scr->tech_draw_font); + XSetForeground(dpy, gc, scr->line_pixel); /* vertical geometry */ @@ -280,7 +281,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) snprintf(num, sizeof(num), "%i", (by - ty - wwin->normal_hints->base_height) / wwin->normal_hints->height_inc); - fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); + fw = WMWidthOfString(scr->tech_draw_font, num, strlen(num)); /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */ @@ -293,7 +294,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) /* // ugly hack */ color->color.pixel = scr->line_pixel; scr->wmscreen->drawStringGC = gc; - WMDrawString(scr->wmscreen, root, color, scr->info_text_font, + WMDrawString(scr->wmscreen, root, color, scr->tech_draw_font, x - s + 3 - fw/2, my - fh/2 + 1, num, strlen(num)); scr->wmscreen->drawStringGC = saveGC; color->color.pixel = pixel; @@ -310,7 +311,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) mx = x1 + (x2 - x1)/2; snprintf(num, sizeof(num), "%i", (x2 - x1 - wwin->normal_hints->base_width) / wwin->normal_hints->width_inc); - fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); + fw = WMWidthOfString(scr->tech_draw_font, num, strlen(num)); /* left arrow */ /* end bar */ @@ -354,7 +355,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) /* // ugly hack */ color->color.pixel = scr->line_pixel; scr->wmscreen->drawStringGC = gc; - WMDrawString(scr->wmscreen, root, color, scr->info_text_font, + WMDrawString(scr->wmscreen, root, color, scr->tech_draw_font, mx - fw/2 + 1, y - s - fh/2 + 1, num, strlen(num)); scr->wmscreen->drawStringGC = saveGC; color->color.pixel = pixel; diff --git a/src/screen.c b/src/screen.c index 96a849e2..940449d9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -818,6 +818,9 @@ wScreenInit(int screen_number) scr->info_text_font = WMBoldSystemFontOfSize(scr->wmscreen, 12); + scr->tech_draw_font = WMCreateFontWithFlags(scr->wmscreen, + "BoldSystemFont-12", + WFNotAntialiased); scr->gview = WCreateGeometryView(scr->wmscreen); WMRealizeWidget(scr->gview); diff --git a/src/screen.h b/src/screen.h index 83486307..bc5129a3 100644 --- a/src/screen.h +++ b/src/screen.h @@ -161,6 +161,8 @@ typedef struct _WScreen { WMFont *clip_title_font; /* for clip titles */ WMFont *info_text_font; /* text on things like geometry * hint boxes */ + WMFont *tech_draw_font; + WMFont *workspace_name_font; WMColor *select_color; diff --git a/src/wconfig.h.in b/src/wconfig.h.in index 82af3f6a..30f5305d 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -295,8 +295,6 @@ #define DEF_WORKSPACE_NAME_FONT "\"-*-lucida-bold-r-*-*-24-*-*-*-*-*-*-*\"" #endif /* !I18N */ -#define HELVETICA10_FONT "-*-helvetica-medium-r-normal-*-10-*-*-*-*-*-*-*" - #define DEF_FRAME_THICKNESS 1 /* linewidth of the move/resize frame */ #define DEF_WINDOW_TITLE_EXTEND_SPACE "0" -- 2.11.4.GIT