1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

- 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.
This commit is contained in:
dan
2002-11-13 15:13:48 +00:00
parent d597c61cb7
commit c2ec1cfe8a
25 changed files with 434 additions and 303 deletions

View File

@@ -12,20 +12,23 @@ Changes since wmaker 0.80.1:
WMCreateRGBAColor() and WMSetColorAlpha() WMCreateRGBAColor() and WMSetColorAlpha()
- Miscelaneous code cleanups in wtext.c - Miscelaneous code cleanups in wtext.c
- Added Xft support in WINGs (for drawing antialiased fonts with transparency). - Added Xft support in WINGs (for drawing antialiased fonts with transparency).
- Added a new function: WMCreateAAFont() to create a font which will be - Added a new function: WMCreateAntialiasedFont() to create a font which will
drawn antialiased using Xft (if available, else function returns NULL) be drawn antialiased using Xft (if available, else function returns NULL)
- New options in WMGLOBAL: AntialiasedText, AASystemFont and AABoldSystemFont. - New options in WMGLOBAL: AntialiasedText, AntialiasedSystemFont and
Check NEWS for details. AntialiasedBoldSystemFont. Check NEWS for details.
- Fixed some improper calls to snprintf in wfont.c - Fixed some improper calls to snprintf in wfont.c
- Added double buffering when drawing a WMFrame title with an AA font to avoid - Added double buffering when drawing a WMFrame title with an antialiased font
flickering. to avoid flickering.
- Added double buffering when drawing WMList items 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 Double buffering for list also works for user drawn lists. Read NEWS for
details and incompatibilities introduced by this change. 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 WMGetColorAlpha(WMColor *color)
- Added WMCreateNonAAFont()
- Better outline when drawing balloons. - 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: Changes since wmaker 0.80.0:

View File

@@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>

View File

@@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>

View File

@@ -130,7 +130,7 @@ You need at least Xfree86 version 4.0.x for this but at least 4.1.x is
recommended. recommended.
For Xft support there is a new function to create a font that will render 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 Passing such a font to WMDrawString() or WMDrawImageString() will result
in antialiased text displayed on screen. Modifying the alpha value for the in antialiased text displayed on screen. Modifying the alpha value for the
WMColor passed to WMDrawString() or WMDrawImageString() will result in text 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 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 font is required. They operate in a similar way as SystemFont and
BoldSystemFont, just they are used when antialiased fonts are requested. BoldSystemFont, just they are used when antialiased fonts are requested.
They are named AASystemFont respectively AABoldSystemFont. They are kept They are named AntialiasedSystemFont respectively AntialiasedBoldSystemFont.
separate from SystemFont and BoldSystemFont because the same fonts don't They are kept separate from SystemFont and BoldSystemFont because the same
render well as both normal and antialiased if they are not TrueType fonts. fonts don't render well as both normal and antialiased if they are not
Even though you can specify any font in the XLFD format for these new TrueType fonts. Even though you can specify any font in the XLFD format for
options, it is recomended to use TrueType fonts for the antialiased case these new options, it is recomended to use TrueType fonts for the antialiased
since other fonts (standard X fonts) don't render well and give ugly case since other fonts (standard X fonts) don't render well and give ugly
results. results.
The third option is an option that globally controls if WINGs uses or not 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(), fonts if not possible. Note that this applies if WMCreateFont(),
WMSystemFont(), WMSystemFontOfSize(), WMBoldSystemFont() or WMSystemFont(), WMSystemFontOfSize(), WMBoldSystemFont() or
WMBoldSystemFontOFize() are used. If any of the direct creation functions WMBoldSystemFontOFize() are used. If any of the direct creation functions
are used, such as WMCreateAAFont() or WMCreateNormalFont(), then that kind are used, such as WMCreateAntialiasedFont() or WMCreateNormalFont(), then
of font is returned independently of the value of AntialiasedText. 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 (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 no compiled into WINGs, even if you call WMCreateAntialiasedFont() directly.
case WMCreateAAFont() will always return NULL) 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.

View File

@@ -1,6 +1,7 @@
#include <WINGs/WINGs.h> #include <WINGs/WINGs.h>
#include <stdlib.h>
#include "mywidget.h" #include "mywidget.h"

View File

@@ -17,6 +17,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "logo.xpm" #include "logo.xpm"

View File

@@ -8,6 +8,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "logo.xpm" #include "logo.xpm"

View File

@@ -5,7 +5,7 @@
#include <WINGs/WINGs.h> #include <WINGs/WINGs.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
/* /*
@@ -1293,6 +1293,8 @@ main(int argc, char **argv)
testDragAndDrop(scr); testDragAndDrop(scr);
testText(scr); testText(scr);
testFontPanel(scr);
#if 0 #if 0
testColorPanel(scr); testColorPanel(scr);
testScrollView(scr); testScrollView(scr);

View File

@@ -85,58 +85,83 @@ enum {
/* button types */ /* button types */
typedef enum { typedef enum {
/* 0 is reserved for internal use */ /* 0 is reserved for internal use */
WBTMomentaryPush = 1, WBTMomentaryPush = 1,
WBTPushOnPushOff = 2, WBTPushOnPushOff = 2,
WBTToggle = 3, WBTToggle = 3,
WBTSwitch = 4, WBTSwitch = 4,
WBTRadio = 5, WBTRadio = 5,
WBTMomentaryChange = 6, WBTMomentaryChange = 6,
WBTOnOff = 7, WBTOnOff = 7,
WBTMomentaryLight = 8 WBTMomentaryLight = 8
} WMButtonType; } WMButtonType;
/* button behaviour masks */ /* button behaviour masks */
enum { enum {
WBBSpringLoadedMask = (1 << 0), WBBSpringLoadedMask = (1 << 0),
WBBPushInMask = (1 << 1), WBBPushInMask = (1 << 1),
WBBPushChangeMask = (1 << 2), WBBPushChangeMask = (1 << 2),
WBBPushLightMask = (1 << 3), WBBPushLightMask = (1 << 3),
WBBStateLightMask = (1 << 5), WBBStateLightMask = (1 << 5),
WBBStateChangeMask = (1 << 6), WBBStateChangeMask = (1 << 6),
WBBStatePushMask = (1 << 7) 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 */ /* frame title positions */
typedef enum { typedef enum {
WTPNoTitle, WTPNoTitle,
WTPAboveTop, WTPAboveTop,
WTPAtTop, WTPAtTop,
WTPBelowTop, WTPBelowTop,
WTPAboveBottom, WTPAboveBottom,
WTPAtBottom, WTPAtBottom,
WTPBelowBottom WTPBelowBottom
} WMTitlePosition; } WMTitlePosition;
/* relief types */ /* relief types */
typedef enum { typedef enum {
WRFlat, WRFlat,
WRSimple, WRSimple,
WRRaised, WRRaised,
WRSunken, WRSunken,
WRGroove, WRGroove,
WRRidge, WRRidge,
WRPushed WRPushed
} WMReliefType; } WMReliefType;
/* alignment types */ /* alignment types */
typedef enum { typedef enum {
WALeft, WALeft,
WACenter, WACenter,
WARight, WARight,
WAJustified /* not valid for textfields */ WAJustified /* not valid for textfields */
} WMAlignment; } WMAlignment;
@@ -155,58 +180,58 @@ typedef enum {
/* scroller arrow position */ /* scroller arrow position */
typedef enum { typedef enum {
WSAMaxEnd, WSAMaxEnd,
WSAMinEnd, WSAMinEnd,
WSANone WSANone
} WMScrollArrowPosition; } WMScrollArrowPosition;
/* scroller parts */ /* scroller parts */
typedef enum { typedef enum {
WSNoPart, WSNoPart,
WSDecrementPage, WSDecrementPage,
WSIncrementPage, WSIncrementPage,
WSDecrementLine, WSDecrementLine,
WSIncrementLine, WSIncrementLine,
WSDecrementWheel, WSDecrementWheel,
WSIncrementWheel, WSIncrementWheel,
WSKnob, WSKnob,
WSKnobSlot WSKnobSlot
} WMScrollerPart; } WMScrollerPart;
/* usable scroller parts */ /* usable scroller parts */
typedef enum { typedef enum {
WSUNoParts, WSUNoParts,
WSUOnlyArrows, WSUOnlyArrows,
WSUAllParts WSUAllParts
} WMUsableScrollerParts; } WMUsableScrollerParts;
/* matrix types */ /* matrix types */
typedef enum { typedef enum {
WMRadioMode, WMRadioMode,
WMHighlightMode, WMHighlightMode,
WMListMode, WMListMode,
WMTrackMode WMTrackMode
} WMMatrixTypes; } WMMatrixTypes;
typedef enum { typedef enum {
WTTopTabsBevelBorder, WTTopTabsBevelBorder,
WTNoTabsBevelBorder, WTNoTabsBevelBorder,
WTNoTabsLineBorder, WTNoTabsLineBorder,
WTNoTabsNoBorder WTNoTabsNoBorder
} WMTabViewType; } WMTabViewType;
/* text movement types */ /* text movement types */
enum { enum {
WMIllegalTextMovement, WMIllegalTextMovement,
WMReturnTextMovement, WMReturnTextMovement,
WMEscapeTextMovement, WMEscapeTextMovement,
WMTabTextMovement, WMTabTextMovement,
WMBacktabTextMovement, WMBacktabTextMovement,
WMLeftTextMovement, WMLeftTextMovement,
WMRightTextMovement, WMRightTextMovement,
WMUpTextMovement, WMUpTextMovement,
WMDownTextMovement WMDownTextMovement
}; };
/* text field special events */ /* text field special events */
@@ -233,13 +258,13 @@ typedef enum {
typedef enum { typedef enum {
WMGrayModeColorPanel = 1, WMGrayModeColorPanel = 1,
WMRGBModeColorPanel = 2, WMRGBModeColorPanel = 2,
WMCMYKModeColorPanel = 3, WMCMYKModeColorPanel = 3,
WMHSBModeColorPanel = 4, WMHSBModeColorPanel = 4,
WMCustomPaletteModeColorPanel = 5, WMCustomPaletteModeColorPanel = 5,
WMColorListModeColorPanel = 6, WMColorListModeColorPanel = 6,
WMWheelModeColorPanel = 7 WMWheelModeColorPanel = 7
} WMColorPanelMode; } WMColorPanelMode;
@@ -260,17 +285,17 @@ typedef enum {
enum { enum {
WLDSSelected = (1 << 16), WLDSSelected = (1 << 16),
WLDSDisabled = (1 << 17), WLDSDisabled = (1 << 17),
WLDSFocused = (1 << 18), WLDSFocused = (1 << 18),
WLDSIsBranch = (1 << 19) WLDSIsBranch = (1 << 19)
}; };
/* alert panel return values */ /* alert panel return values */
enum { enum {
WAPRDefault = 0, WAPRDefault = 0,
WAPRAlternate = 1, WAPRAlternate = 1,
WAPROther = -1, WAPROther = -1,
WAPRError = -2 WAPRError = -2
}; };
@@ -278,8 +303,8 @@ enum {
/* types of input observers */ /* types of input observers */
enum { enum {
WIReadMask = (1 << 0), WIReadMask = (1 << 0),
WIWriteMask = (1 << 1), WIWriteMask = (1 << 1),
WIExceptMask = (1 << 2) WIExceptMask = (1 << 2)
}; };
@@ -314,7 +339,7 @@ enum {
typedef struct W_WidgetType { typedef struct W_WidgetType {
W_Class widgetClass; W_Class widgetClass;
struct W_View *view; struct W_View *view;
} W_WidgetType; } 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* WMCreateFontSet(WMScreen *scrPtr, char *fontName);
WMFont* WMCreateNormalFont(WMScreen *scrPtr, char *fontName); WMFont* WMCreateNormalFont(WMScreen *scrPtr, char *fontName);
WMFont* WMCreateAAFont(WMScreen *scrPtr, char *fontName); WMFont* WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName);
WMFont* WMCreateNonAAFont(WMScreen *scrPtr, char *fontName);
WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName); WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName);
WMFont* WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags);
WMFont* WMRetainFont(WMFont *font); WMFont* WMRetainFont(WMFont *font);
void WMReleaseFont(WMFont *font); void WMReleaseFont(WMFont *font);
unsigned int WMFontHeight(WMFont *font); unsigned int WMFontHeight(WMFont *font);
Bool WMIsAAFont(WMFont *font); Bool WMIsAntialiasedFont(WMFont *font);
/* /*
WMFont* WMUserFontOfSize(WMScreen *scrPtr, int size); WMFont* WMUserFontOfSize(WMScreen *scrPtr, int size);

View File

@@ -131,14 +131,16 @@ typedef struct W_Screen {
Window rootWin; Window rootWin;
struct _XftDraw *xftdraw;
struct W_View *rootView; struct W_View *rootView;
RContext *rcontext; RContext *rcontext;
struct W_IMContext *imctx; struct W_IMContext *imctx;
struct _XftDraw *xftdraw; /* shared XftDraw */
Bool hasXftSupport; /* if it can antialias text */
/* application related */ /* application related */
W_FocusInfo *focusInfo; W_FocusInfo *focusInfo;
@@ -198,6 +200,8 @@ typedef struct W_Screen {
WMHashTable *fontCache; WMHashTable *fontCache;
WMHashTable *xftFontCache;
WMHashTable *fontSetCache; WMHashTable *fontSetCache;
Bool useMultiByte; Bool useMultiByte;

View File

@@ -14,9 +14,9 @@ _WINGsConfiguration WINGsConfiguration;
#define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*" #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" #define FLOPPY_PATH "/floppy"
@@ -140,10 +140,10 @@ W_ReadConfigurations(void)
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT; WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
} }
if (!WINGsConfiguration.antialiasedSystemFont) { if (!WINGsConfiguration.antialiasedSystemFont) {
WINGsConfiguration.antialiasedSystemFont = AASYSTEM_FONT; WINGsConfiguration.antialiasedSystemFont = XFTSYSTEM_FONT;
} }
if (!WINGsConfiguration.antialiasedBoldSystemFont) { if (!WINGsConfiguration.antialiasedBoldSystemFont) {
WINGsConfiguration.antialiasedBoldSystemFont = AABOLD_SYSTEM_FONT; WINGsConfiguration.antialiasedBoldSystemFont = XFTBOLD_SYSTEM_FONT;
} }
if (!WINGsConfiguration.floppyPath) { if (!WINGsConfiguration.floppyPath) {
WINGsConfiguration.floppyPath = FLOPPY_PATH; WINGsConfiguration.floppyPath = FLOPPY_PATH;

View File

@@ -39,6 +39,7 @@ static UserDefaults *sharedUserDefaults = NULL;
char *WMUserDefaultsDidChangeNotification = "WMUserDefaultsDidChangeNotification"; char *WMUserDefaultsDidChangeNotification = "WMUserDefaultsDidChangeNotification";
static void synchronizeUserDefaults(void *foo);
extern char *WMGetApplicationName(); extern char *WMGetApplicationName();
@@ -93,19 +94,14 @@ wdefaultspathfordomain(char *domain)
static void static void
#ifndef HAVE_ATEXIT #ifdef HAVE_ATEXIT
saveDefaultsChanges(int foo, void *bar)
#else
saveDefaultsChanges(void) saveDefaultsChanges(void)
#else
saveDefaultsChanges(int foo, void *bar)
#endif #endif
{ {
/* save the user defaults databases */ /* save the user defaults databases */
UserDefaults *tmp = sharedUserDefaults; synchronizeUserDefaults(NULL);
while (tmp) {
WMSynchronizeUserDefaults(tmp);
tmp = tmp->next;
}
} }
@@ -116,10 +112,10 @@ registerSaveOnExit(void)
static Bool registeredSaveOnExit = False; static Bool registeredSaveOnExit = False;
if (!registeredSaveOnExit) { if (!registeredSaveOnExit) {
#ifndef HAVE_ATEXIT #ifdef HAVE_ATEXIT
on_exit(saveDefaultsChanges, (void*)NULL);
#else
atexit(saveDefaultsChanges); atexit(saveDefaultsChanges);
#else
on_exit(saveDefaultsChanges, (void*)NULL);
#endif #endif
registeredSaveOnExit = True; registeredSaveOnExit = True;
} }
@@ -136,7 +132,6 @@ synchronizeUserDefaults(void *foo)
WMSynchronizeUserDefaults(database); WMSynchronizeUserDefaults(database);
database = database->next; database = database->next;
} }
WMAddTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, NULL);
} }
@@ -146,7 +141,8 @@ addSynchronizeTimerHandler(void)
static Bool initialized = False; static Bool initialized = False;
if (!initialized) { if (!initialized) {
WMAddTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults, NULL); WMAddPersistentTimerHandler(UD_SYNC_INTERVAL, synchronizeUserDefaults,
NULL);
initialized = True; initialized = True;
} }
} }
@@ -265,7 +261,7 @@ WMGetStandardUserDefaults(void)
if (sharedUserDefaults) { if (sharedUserDefaults) {
defaults = sharedUserDefaults; defaults = sharedUserDefaults;
while (defaults) { while (defaults) {
/* Trick, path == NULL only for StandardUserDefaults db */ /* path == NULL only for StandardUserDefaults db */
if (defaults->path == NULL) if (defaults->path == NULL)
return defaults; return defaults;
defaults = defaults->next; defaults = defaults->next;
@@ -284,19 +280,18 @@ WMGetStandardUserDefaults(void)
key = WMCreatePLString(WMGetApplicationName()); key = WMCreatePLString(WMGetApplicationName());
defaults->searchList[0] = key; defaults->searchList[0] = key;
/* temporary kluge */ /* temporary kluge. wmaker handles synchronization itself */
if (strcmp(WMGetApplicationName(), "WindowMaker")==0) { if (strcmp(WMGetApplicationName(), "WindowMaker")==0) {
domain = NULL; defaults->dontSync = 1;
path = NULL;
} else {
path = wdefaultspathfordomain(WMGetFromPLString(key));
if (stat(path, &stbuf) >= 0)
defaults->timestamp = stbuf.st_mtime;
domain = WMReadPropListFromFile(path);
} }
path = wdefaultspathfordomain(WMGetFromPLString(key));
if (stat(path, &stbuf) >= 0)
defaults->timestamp = stbuf.st_mtime;
domain = WMReadPropListFromFile(path);
if (!domain) if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL); domain = WMCreatePLDictionary(NULL, NULL, NULL);
@@ -332,7 +327,7 @@ WMGetStandardUserDefaults(void)
i = 0; i = 0;
while (defaults->searchList[i]) { while (defaults->searchList[i]) {
WMAddToPLArray(defaults->searchListArray, WMAddToPLArray(defaults->searchListArray,
defaults->searchList[i]); defaults->searchList[i]);
i++; i++;
} }
@@ -409,7 +404,7 @@ WMGetDefaultsFromPath(char *path)
i = 0; i = 0;
while (defaults->searchList[i]) { while (defaults->searchList[i]) {
WMAddToPLArray(defaults->searchListArray, WMAddToPLArray(defaults->searchListArray,
defaults->searchList[i]); defaults->searchList[i]);
i++; i++;
} }
@@ -669,6 +664,7 @@ WMSetUDSearchList(WMUserDefaults *database, WMPropList *list)
for (i=0; i<c; i++) { for (i=0; i<c; i++) {
database->searchList[i] = WMGetFromPLArray(list, i); database->searchList[i] = WMGetFromPLArray(list, i);
} }
database->searchList[c] = NULL;
database->searchListArray = WMDeepCopyPropList(list); database->searchListArray = WMDeepCopyPropList(list);
} }

View File

@@ -34,19 +34,19 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv)
assert(argc!=NULL); assert(argc!=NULL);
assert(argv!=NULL); assert(argv!=NULL);
assert(applicationName!=NULL); assert(applicationName!=NULL);
/* // TODO: check if to move inside #ifdef I18N */
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
#ifdef I18N #ifdef I18N
if (getenv("NLSPATH")) if (getenv("NLSPATH"))
bindtextdomain("WINGs", getenv("NLSPATH")); bindtextdomain("WINGs", getenv("NLSPATH"));
else else
bindtextdomain("WINGs", LOCALEDIR); bindtextdomain("WINGs", LOCALEDIR);
#endif #endif
_WINGS_progname = argv[0]; _WINGS_progname = argv[0];
WMApplication.applicationName = wstrdup(applicationName); WMApplication.applicationName = wstrdup(applicationName);
WMApplication.argc = *argc; WMApplication.argc = *argc;
@@ -55,7 +55,7 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv)
WMApplication.argv[i] = wstrdup(argv[i]); WMApplication.argv[i] = wstrdup(argv[i]);
} }
WMApplication.argv[i] = NULL; WMApplication.argv[i] = NULL;
/* initialize notification center */ /* initialize notification center */
W_InitNotificationCenter(); W_InitNotificationCenter();
} }

View File

@@ -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* WMFont*
WMCreateFontSet(WMScreen *scrPtr, char *fontName) WMCreateFontSet(WMScreen *scrPtr, char *fontName)
{ {
@@ -112,17 +157,19 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
char **missing; char **missing;
int nmissing = 0; int nmissing = 0;
char *defaultString; char *defaultString;
char *fname;
XFontSetExtents *extents; XFontSetExtents *extents;
font = WMHashGet(scrPtr->fontSetCache, fontName); fname = xlfdFromFontName(fontName, False);
font = WMHashGet(scrPtr->fontSetCache, fname);
if (font) { if (font) {
WMRetainFont(font); WMRetainFont(font);
wfree(fname);
return font; return font;
} }
font = malloc(sizeof(WMFont)); font = wmalloc(sizeof(WMFont));
if (!font)
return NULL;
memset(font, 0, sizeof(WMFont)); memset(font, 0, sizeof(WMFont));
font->notFontSet = 0; font->notFontSet = 0;
@@ -130,13 +177,12 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
font->screen = scrPtr; font->screen = scrPtr;
font->font.set = W_CreateFontSetWithGuess(display, fontName, &missing, font->font.set = W_CreateFontSetWithGuess(display, fname, &missing,
&nmissing, &defaultString); &nmissing, &defaultString);
if (nmissing > 0 && font->font.set) { if (nmissing > 0 && font->font.set) {
int i; int i;
wwarning(_("the following character sets are missing in %s:"), wwarning(_("the following character sets are missing in %s:"), fname);
fontName);
for (i = 0; i < nmissing; i++) { for (i = 0; i < nmissing; i++) {
wwarning(missing[i]); wwarning(missing[i]);
} }
@@ -146,7 +192,8 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
defaultString); defaultString);
} }
if (!font->font.set) { if (!font->font.set) {
wfree(font); wfree(font);
wfree(fname);
return NULL; return NULL;
} }
@@ -157,7 +204,7 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
font->refCount = 1; font->refCount = 1;
font->name = wstrdup(fontName); font->name = fname;
assert(WMHashInsert(scrPtr->fontSetCache, font->name, font)==NULL); assert(WMHashInsert(scrPtr->fontSetCache, font->name, font)==NULL);
@@ -173,6 +220,8 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
Display *display = scrPtr->display; Display *display = scrPtr->display;
char *fname, *ptr; char *fname, *ptr;
fontName = xlfdFromFontName(fontName, False);
if ((ptr = strchr(fontName, ','))) { if ((ptr = strchr(fontName, ','))) {
fname = wmalloc(ptr - fontName + 1); fname = wmalloc(ptr - fontName + 1);
strncpy(fname, fontName, ptr - fontName); strncpy(fname, fontName, ptr - fontName);
@@ -181,6 +230,8 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
fname = wstrdup(fontName); fname = wstrdup(fontName);
} }
wfree(fontName);
font = WMHashGet(scrPtr->fontCache, fname); font = WMHashGet(scrPtr->fontCache, fname);
if (font) { if (font) {
WMRetainFont(font); WMRetainFont(font);
@@ -188,11 +239,7 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
return font; return font;
} }
font = malloc(sizeof(WMFont)); font = wmalloc(sizeof(WMFont));
if (!font) {
wfree(fname);
return NULL;
}
memset(font, 0, sizeof(WMFont)); memset(font, 0, sizeof(WMFont));
font->notFontSet = 1; font->notFontSet = 1;
@@ -220,13 +267,18 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
WMFont* WMFont*
WMCreateAAFont(WMScreen *scrPtr, char *fontName) WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName)
{ {
#ifdef XFT #ifdef XFT
WMFont *font; WMFont *font;
Display *display = scrPtr->display; Display *display = scrPtr->display;
char *fname, *ptr; char *fname, *ptr;
if (!scrPtr->hasXftSupport)
return NULL;
fontName = xlfdFromFontName(fontName, True);
if ((ptr = strchr(fontName, ','))) { if ((ptr = strchr(fontName, ','))) {
fname = wmalloc(ptr - fontName + 1); fname = wmalloc(ptr - fontName + 1);
strncpy(fname, fontName, ptr - fontName); strncpy(fname, fontName, ptr - fontName);
@@ -235,18 +287,16 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName)
fname = wstrdup(fontName); fname = wstrdup(fontName);
} }
font = WMHashGet(scrPtr->fontCache, fname); wfree(fontName);
font = WMHashGet(scrPtr->xftFontCache, fname);
if (font) { if (font) {
WMRetainFont(font); WMRetainFont(font);
wfree(fname); wfree(fname);
return font; return font;
} }
font = malloc(sizeof(WMFont)); font = wmalloc(sizeof(WMFont));
if (!font) {
wfree(fname);
return NULL;
}
memset(font, 0, sizeof(WMFont)); memset(font, 0, sizeof(WMFont));
font->notFontSet = 1; font->notFontSet = 1;
@@ -254,7 +304,9 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName)
font->screen = scrPtr; 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); font->font.normal = XLoadQueryFont(display, fname);
if (!font->font.normal) { if (!font->font.normal) {
wfree(font); wfree(font);
@@ -262,6 +314,7 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName)
return NULL; return NULL;
} }
XFreeFont(display, font->font.normal); XFreeFont(display, font->font.normal);
#endif
font->font.xft = XftFontOpenXlfd(display, scrPtr->screen, fname); font->font.xft = XftFontOpenXlfd(display, scrPtr->screen, fname);
if (!font->font.xft) { if (!font->font.xft) {
@@ -276,7 +329,7 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName)
font->name = fname; font->name = fname;
assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL); assert(WMHashInsert(scrPtr->xftFontCache, font->name, font)==NULL);
return font; return font;
#else #else
@@ -286,27 +339,48 @@ WMCreateAAFont(WMScreen *scrPtr, char *fontName)
WMFont* WMFont*
WMCreateNonAAFont(WMScreen *scrPtr, char *fontName) WMCreateFont(WMScreen *scrPtr, char *fontName)
{ {
if (scrPtr->useMultiByte) { return WMCreateFontWithFlags(scrPtr, fontName, WFDefaultFont);
return WMCreateFontSet(scrPtr, fontName);
} else {
return WMCreateNormalFont(scrPtr, fontName);
}
} }
WMFont* WMFont*
WMCreateFont(WMScreen *scrPtr, char *fontName) WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags)
{ {
if (scrPtr->useMultiByte) { Bool multiByte = scrPtr->useMultiByte;
return WMCreateFontSet(scrPtr, fontName); Bool antialiased = scrPtr->antialiasedText;
} else if (scrPtr->antialiasedText) { WMFont *font;
WMFont *font = WMCreateAAFont(scrPtr, fontName);
return font ? font : WMCreateNormalFont(scrPtr, fontName); if (flags & WFFontSet) {
} else { multiByte = True;
return WMCreateNormalFont(scrPtr, fontName); } 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 {
font = WMCreateNormalFont(scrPtr, fontName);
}
return font;
} }
@@ -341,8 +415,10 @@ WMReleaseFont(WMFont *font)
} else { } else {
XFreeFontSet(font->screen->display, font->font.set); XFreeFontSet(font->screen->display, font->font.set);
} }
if (font->name) { if (font->name) {
if (font->notFontSet) { if (font->antialiased) {
WMHashRemove(font->screen->xftFontCache, font->name);
} else if (font->notFontSet) {
WMHashRemove(font->screen->fontCache, font->name); WMHashRemove(font->screen->fontCache, font->name);
} else { } else {
WMHashRemove(font->screen->fontSetCache, font->name); WMHashRemove(font->screen->fontSetCache, font->name);
@@ -355,7 +431,21 @@ WMReleaseFont(WMFont *font)
Bool Bool
WMIsAAFont(WMFont *font) WMHasAntialiasingSupport(WMScreen *scrPtr)
{
return scrPtr->hasXftSupport;
}
Bool
WMIsAntialiasingEnabled(WMScreen *scrPtr)
{
return scrPtr->antialiasedText;
}
Bool
WMIsAntialiasedFont(WMFont *font)
{ {
return font->antialiased; return font->antialiased;
} }
@@ -388,22 +478,22 @@ static WMFont*
makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold) makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold)
{ {
WMFont *font; WMFont *font;
char *fontSpec, *aaFontSpec; char *fontSpec, *xftFontSpec;
#define WConf WINGsConfiguration #define WConf WINGsConfiguration
if (bold) { if (bold) {
fontSpec = makeFontSetOfSize(WConf.boldSystemFont, size); fontSpec = makeFontSetOfSize(WConf.boldSystemFont, size);
aaFontSpec = makeFontSetOfSize(WConf.antialiasedBoldSystemFont, size); xftFontSpec = makeFontSetOfSize(WConf.antialiasedBoldSystemFont, size);
} else { } else {
fontSpec = makeFontSetOfSize(WConf.systemFont, size); fontSpec = makeFontSetOfSize(WConf.systemFont, size);
aaFontSpec = makeFontSetOfSize(WConf.antialiasedSystemFont, size); xftFontSpec = makeFontSetOfSize(WConf.antialiasedSystemFont, size);
} }
#undef WConf #undef WConf
if (scrPtr->useMultiByte) { if (scrPtr->useMultiByte) {
font = WMCreateFontSet(scrPtr, fontSpec); font = WMCreateFontSet(scrPtr, fontSpec);
} else if (scrPtr->antialiasedText) { } else if (scrPtr->antialiasedText) {
font = WMCreateAAFont(scrPtr, aaFontSpec); font = WMCreateAntialiasedFont(scrPtr, xftFontSpec);
} else { } else {
font = WMCreateNormalFont(scrPtr, fontSpec); font = WMCreateNormalFont(scrPtr, fontSpec);
} }
@@ -416,11 +506,11 @@ makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold)
font = WMCreateFontSet(scrPtr, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*"); font = WMCreateFontSet(scrPtr, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*");
} }
} else if (scrPtr->antialiasedText) { } else if (scrPtr->antialiasedText) {
wwarning(_("could not load font %s. Trying arial."), aaFontSpec); wwarning(_("could not load font %s. Trying arial."), xftFontSpec);
if (bold) { if (bold) {
font = WMCreateAAFont(scrPtr, "-*-arial-bold-r-normal-*-12-*-*-*-*-*-*-*"); font = WMCreateAntialiasedFont(scrPtr, "-*-arial-bold-r-normal-*-12-*-*-*-*-*-*-*");
} else { } else {
font = WMCreateAAFont(scrPtr, "-*-arial-medium-r-normal-*-12-*-*-*-*-*-*-*"); font = WMCreateAntialiasedFont(scrPtr, "-*-arial-medium-r-normal-*-12-*-*-*-*-*-*-*");
} }
if (!font) { if (!font) {
wwarning(_("could not load antialiased fonts. Reverting to normal fonts.")); wwarning(_("could not load antialiased fonts. Reverting to normal fonts."));
@@ -437,12 +527,12 @@ makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold)
if (!font) { if (!font) {
wwarning(_("could not load fixed font!")); wwarning(_("could not load fixed font!"));
wfree(fontSpec); wfree(fontSpec);
wfree(aaFontSpec); wfree(xftFontSpec);
return NULL; return NULL;
} }
} }
wfree(fontSpec); wfree(fontSpec);
wfree(aaFontSpec); wfree(xftFontSpec);
return font; return font;
} }
@@ -682,6 +772,7 @@ WMFont*
WMNormalizeFont(WMScreen *scr, WMFont *font) WMNormalizeFont(WMScreen *scr, WMFont *font)
{ {
char fname[256]; char fname[256];
WMFontFlags flag;
if (!scr || !font) if (!scr || !font)
return NULL; return NULL;
@@ -689,10 +780,8 @@ WMNormalizeFont(WMScreen *scr, WMFont *font)
snprintf(fname, 255, "%s", font->name); snprintf(fname, 255, "%s", font->name);
changeFontProp(fname, "medium", 2); changeFontProp(fname, "medium", 2);
changeFontProp(fname, "r", 3); changeFontProp(fname, "r", 3);
if (font->antialiased) flag = (font->antialiased ? WFAntialiased : WFNotAntialiased);
return WMCreateAAFont(scr, fname); return WMCreateFontWithFlags(scr, fname, flag);
else
return WMCreateNonAAFont(scr, fname);
} }
@@ -700,16 +789,15 @@ WMFont*
WMStrengthenFont(WMScreen *scr, WMFont *font) WMStrengthenFont(WMScreen *scr, WMFont *font)
{ {
char fname[256]; char fname[256];
WMFontFlags flag;
if (!scr || !font) if (!scr || !font)
return NULL; return NULL;
snprintf(fname, 255, "%s", font->name); snprintf(fname, 255, "%s", font->name);
changeFontProp(fname, "bold", 2); changeFontProp(fname, "bold", 2);
if (font->antialiased) flag = (font->antialiased ? WFAntialiased : WFNotAntialiased);
return WMCreateAAFont(scr, fname); return WMCreateFontWithFlags(scr, fname, flag);
else
return WMCreateNonAAFont(scr, fname);
} }
@@ -717,16 +805,15 @@ WMFont*
WMUnstrengthenFont(WMScreen *scr, WMFont *font) WMUnstrengthenFont(WMScreen *scr, WMFont *font)
{ {
char fname[256]; char fname[256];
WMFontFlags flag;
if (!scr || !font) if (!scr || !font)
return NULL; return NULL;
snprintf(fname, 255, "%s", font->name); snprintf(fname, 255, "%s", font->name);
changeFontProp(fname, "medium", 2); changeFontProp(fname, "medium", 2);
if (font->antialiased) flag = (font->antialiased ? WFAntialiased : WFNotAntialiased);
return WMCreateAAFont(scr, fname); return WMCreateFontWithFlags(scr, fname, flag);
else
return WMCreateNonAAFont(scr, fname);
} }
@@ -734,6 +821,7 @@ WMFont*
WMEmphasizeFont(WMScreen *scr, WMFont *font) WMEmphasizeFont(WMScreen *scr, WMFont *font)
{ {
char fname[256]; char fname[256];
WMFontFlags flag;
if (!scr || !font) if (!scr || !font)
return NULL; return NULL;
@@ -744,10 +832,8 @@ WMEmphasizeFont(WMScreen *scr, WMFont *font)
else else
changeFontProp(fname, "o", 3); changeFontProp(fname, "o", 3);
if (font->antialiased) flag = (font->antialiased ? WFAntialiased : WFNotAntialiased);
return WMCreateAAFont(scr, fname); return WMCreateFontWithFlags(scr, fname, flag);
else
return WMCreateNonAAFont(scr, fname);
} }
@@ -755,16 +841,15 @@ WMFont*
WMUnemphasizeFont(WMScreen *scr, WMFont *font) WMUnemphasizeFont(WMScreen *scr, WMFont *font)
{ {
char fname[256]; char fname[256];
WMFontFlags flag;
if (!scr || !font) if (!scr || !font)
return NULL; return NULL;
snprintf(fname, 255, "%s", font->name); snprintf(fname, 255, "%s", font->name);
changeFontProp(fname, "r", 3); changeFontProp(fname, "r", 3);
if (font->antialiased) flag = (font->antialiased ? WFAntialiased : WFNotAntialiased);
return WMCreateAAFont(scr, fname); return WMCreateFontWithFlags(scr, fname, flag);
else
return WMCreateNonAAFont(scr, fname);
} }

View File

@@ -197,7 +197,7 @@ paintFrame(Frame *fPtr)
if (drawTitle) { if (drawTitle) {
/* can't draw AA text over and over again because it gets messed */ /* 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) { if (font->antialiased) {
Drawable d; Drawable d;

View File

@@ -622,9 +622,13 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
scrPtr->xftFontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
scrPtr->fontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks); scrPtr->fontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks);
#ifdef XFT #ifdef XFT
scrPtr->hasXftSupport = XftDefaultHasRender(scrPtr->display);
scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr), scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr),
scrPtr->visual, scrPtr->colormap); scrPtr->visual, scrPtr->colormap);
#endif #endif
@@ -680,7 +684,7 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
ShiftMask,LockMask,ControlMask,Mod1Mask, ShiftMask,LockMask,ControlMask,Mod1Mask,
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
}; };
unsigned int numLockMask, scrollLockMask; unsigned int numLockMask=0, scrollLockMask=0;
nlock = XKeysymToKeycode(display, XK_Num_Lock); nlock = XKeysymToKeycode(display, XK_Num_Lock);
slock = XKeysymToKeycode(display, XK_Scroll_Lock); slock = XKeysymToKeycode(display, XK_Scroll_Lock);
@@ -757,7 +761,16 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->useMultiByte = WINGsConfiguration.useMultiByte; 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, scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
WINGsConfiguration.defaultFontSize); WINGsConfiguration.defaultFontSize);

View File

@@ -303,8 +303,6 @@ WMSetListUserDrawProc(WMList *lPtr, WMListDrawProc *proc)
void void
WMSetListUserDrawItemHeight(WMList *lPtr, unsigned short height) WMSetListUserDrawItemHeight(WMList *lPtr, unsigned short height)
{ {
W_Screen *scr = lPtr->view->screen;
assert(height > 0); assert(height > 0);
lPtr->flags.userItemHeight = 1; lPtr->flags.userItemHeight = 1;
@@ -1234,7 +1232,6 @@ static void
didResizeList(W_ViewDelegate *self, WMView *view) didResizeList(W_ViewDelegate *self, WMView *view)
{ {
WMList *lPtr = (WMList*)view->self; WMList *lPtr = (WMList*)view->self;
W_Screen *scr = view->screen;
WMResizeWidget(lPtr->vScroller, 1, view->size.height-2); WMResizeWidget(lPtr->vScroller, 1, view->size.height-2);

View File

@@ -757,6 +757,7 @@ paintCursor(TextField *tPtr)
tPtr->view->size.height - 2*tPtr->offsetWidth - 1); tPtr->view->size.height - 2*tPtr->offsetWidth - 1);
printf("%d %d\n",cx,tPtr->cursorPosition); printf("%d %d\n",cx,tPtr->cursorPosition);
*/ */
XDrawLine(screen->display, tPtr->view->window, screen->xorGC, XDrawLine(screen->display, tPtr->view->window, screen->xorGC,
cx, tPtr->offsetWidth, cx, cx, tPtr->offsetWidth, cx,
tPtr->view->size.height - tPtr->offsetWidth - 1); tPtr->view->size.height - tPtr->offsetWidth - 1);
@@ -1553,7 +1554,7 @@ handleTextFieldActionEvents(XEvent *event, void *data)
<= WINGsConfiguration.doubleClickDelay) { <= WINGsConfiguration.doubleClickDelay) {
tPtr->selection.position = 0; tPtr->selection.position = 0;
tPtr->selection.count = tPtr->textLen; tPtr->selection.count = tPtr->textLen;
paintTextField(tPtr); paintTextField(tPtr);
if (!tPtr->flags.ownsSelection) { if (!tPtr->flags.ownsSelection) {
tPtr->flags.ownsSelection = tPtr->flags.ownsSelection =

View File

@@ -481,12 +481,12 @@ void
W_MoveView(W_View *view, int x, int y) W_MoveView(W_View *view, int x, int y)
{ {
assert(view->flags.root==0); assert(view->flags.root==0);
//TODO move this after the test pos==oldpos
if (view->delegate && view->delegate->willMove) { if (view->delegate && view->delegate->willMove) {
(*view->delegate->willMove)(view->delegate, view, &x, &y); (*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; return;
if (view->flags.realized) { if (view->flags.realized) {
@@ -504,8 +504,8 @@ W_MoveView(W_View *view, int x, int y)
void void
W_ResizeView(W_View *view, unsigned int width, unsigned int height) W_ResizeView(W_View *view, unsigned int width, unsigned int height)
{ {
int shrinked; /*int shrinked;*/
// TODO move this after the test size==oldsize
if (view->delegate && view->delegate->willResize) { if (view->delegate && view->delegate->willResize) {
(*view->delegate->willResize)(view->delegate, view, &width, &height); (*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) if (view->size.width == width && view->size.height == height)
return; return;
shrinked = width < view->size.width || height < view->size.height; /*shrinked = width < view->size.width || height < view->size.height;*/
if (view->flags.realized) { if (view->flags.realized) {
XResizeWindow(view->screen->display, view->window, width, height); 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); (*view->delegate->didResize)(view->delegate, view);
} }
/* // TODO. replace in WINGs code, with the didResize delegate */
if (view->flags.notifySizeChanged) if (view->flags.notifySizeChanged)
WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL); WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL);
} }

View File

@@ -4,7 +4,7 @@
AntialiasedSystemFont = "-*-trebuchet ms-medium-r-normal-*-%d-*-*-*-*-*-*-*"; AntialiasedSystemFont = "-*-trebuchet ms-medium-r-normal-*-%d-*-*-*-*-*-*-*";
AntialiasedBoldSystemFont = "-*-trebuchet ms-bold-r-normal-*-%d-*-*-*-*-*-*-*"; AntialiasedBoldSystemFont = "-*-trebuchet ms-bold-r-normal-*-%d-*-*-*-*-*-*-*";
DefaultFontSize = 12; DefaultFontSize = 12;
AntialiasedText = NO; AntialiasedText = No;
MultiByteText = AUTO; MultiByteText = AUTO;
FloppyPath = "/floppy"; FloppyPath = "/floppy";
DoubleClickTime = 250; DoubleClickTime = 250;

View File

@@ -62,6 +62,8 @@
#include "defaults.h" #include "defaults.h"
#include "xinerama.h" #include "xinerama.h"
extern WPreferences wPreferences; extern WPreferences wPreferences;
@@ -844,6 +846,7 @@ typedef struct {
WMLabel *logoL; WMLabel *logoL;
WMLabel *name1L; WMLabel *name1L;
WMFrame *lineF;
WMLabel *name2L; WMLabel *name2L;
WMLabel *versionL; 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 #ifdef SILLYNESS
extern WMPixmap *DoXThing(); extern WMPixmap *DoXThing();
@@ -1221,7 +1177,7 @@ handleLogoPush(XEvent *event, void *data)
/* Alternatively we can draw text in a pixmap and scroll it smoothly */ /* Alternatively we can draw text in a pixmap and scroll it smoothly */
if ((panel->oldFont = WMGetLabelFont(panel->versionL))!=NULL) if ((panel->oldFont = WMGetLabelFont(panel->versionL))!=NULL)
WMRetainFont(panel->oldFont); WMRetainFont(panel->oldFont);
font = WMCreateFont(WMWidgetScreen(panel->versionL), "-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*"); font = WMCreateFont(WMWidgetScreen(panel->versionL), "-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*");
if (font) { if (font) {
WMSetLabelFont(panel->versionL, font); WMSetLabelFont(panel->versionL, font);
WMReleaseFont(font); WMReleaseFont(font);
@@ -1269,9 +1225,8 @@ wShowInfoPanel(WScreen *scr)
char buffer[256]; char buffer[256];
Window parent; Window parent;
WWindow *wwin; WWindow *wwin;
RColor color1, color2;
char **strl; char **strl;
int i; int i, width, sepWidth;
char *visuals[] = { char *visuals[] = {
"StaticGray", "StaticGray",
"GrayScale", "GrayScale",
@@ -1296,7 +1251,7 @@ wShowInfoPanel(WScreen *scr)
panel->scr = scr; panel->scr = scr;
panel->win = WMCreateWindow(scr->wmscreen, "info"); panel->win = WMCreateWindow(scr->wmscreen, "info");
WMResizeWidget(panel->win, 382, 230); WMResizeWidget(panel->win, 390, 230);
logo = WMCreateApplicationIconBlendedPixmap(scr->wmscreen, (RColor*)NULL); logo = WMCreateApplicationIconBlendedPixmap(scr->wmscreen, (RColor*)NULL);
if (!logo) { if (!logo) {
@@ -1316,30 +1271,31 @@ wShowInfoPanel(WScreen *scr)
WMReleasePixmap(logo); WMReleasePixmap(logo);
} }
sepWidth = 3;
panel->name1L = WMCreateLabel(panel->win); panel->name1L = WMCreateLabel(panel->win);
WMResizeWidget(panel->name1L, 240, 30); WMResizeWidget(panel->name1L, 240, 30 - sepWidth);
WMMoveWidget(panel->name1L, 100, 30); WMMoveWidget(panel->name1L, 100, 30);
color1.red = 0;
color1.green = 0; if (WMIsAntialiasingEnabled(scr->wmscreen)) {
color1.blue = 0; font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
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);
} else { } else {
font = WMBoldSystemFontOfSize(scr->wmscreen, 20); font = WMCreateFont(scr->wmscreen, "-*-utopia-*-r-*-*-25-*");
if (font) { font = font ? font : WMBoldSystemFontOfSize(scr->wmscreen, 24);
WMSetLabelFont(panel->name1L, font);
WMReleaseFont(font);
}
WMSetLabelTextAlignment(panel->name1L, WACenter);
WMSetLabelText(panel->name1L, "Window Maker");
} }
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); panel->name2L = WMCreateLabel(panel->win);
WMResizeWidget(panel->name2L, 240, 24); WMResizeWidget(panel->name2L, 240, 24);
@@ -1353,7 +1309,6 @@ wShowInfoPanel(WScreen *scr)
WMSetLabelTextAlignment(panel->name2L, WACenter); WMSetLabelTextAlignment(panel->name2L, WACenter);
WMSetLabelText(panel->name2L, _("Window Manager for X")); WMSetLabelText(panel->name2L, _("Window Manager for X"));
snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION); snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION);
panel->versionL = WMCreateLabel(panel->win); panel->versionL = WMCreateLabel(panel->win);
WMResizeWidget(panel->versionL, 310, 16); WMResizeWidget(panel->versionL, 310, 16);
@@ -1363,12 +1318,12 @@ wShowInfoPanel(WScreen *scr)
WMSetLabelWraps(panel->versionL, False); WMSetLabelWraps(panel->versionL, False);
panel->copyrL = WMCreateLabel(panel->win); panel->copyrL = WMCreateLabel(panel->win);
WMResizeWidget(panel->copyrL, 340, 40); WMResizeWidget(panel->copyrL, 360, 40);
WMMoveWidget(panel->copyrL, 15, 185); WMMoveWidget(panel->copyrL, 15, 185);
WMSetLabelTextAlignment(panel->copyrL, WALeft); WMSetLabelTextAlignment(panel->copyrL, WALeft);
WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT); WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
/* we want the (c) character in the helvetica font */ /* we want the (c) character in the font, so don't use a FontSet here */
font = WMCreateNormalFont(scr->wmscreen, HELVETICA10_FONT); font = WMCreateFontWithFlags(scr->wmscreen, "SystemFont-11", WFNormalFont);
if (font) { if (font) {
WMSetLabelFont(panel->copyrL, font); WMSetLabelFont(panel->copyrL, font);
WMReleaseFont(font); WMReleaseFont(font);
@@ -1461,7 +1416,7 @@ wShowInfoPanel(WScreen *scr)
WMResizeWidget(panel->infoL, 350, 75); WMResizeWidget(panel->infoL, 350, 75);
WMMoveWidget(panel->infoL, 15, 115); WMMoveWidget(panel->infoL, 15, 115);
WMSetLabelText(panel->infoL, strbuf); WMSetLabelText(panel->infoL, strbuf);
font = WMCreateFont(scr->wmscreen, HELVETICA10_FONT); font = WMSystemFontOfSize(scr->wmscreen, 11);
if (font) { if (font) {
WMSetLabelFont(panel->infoL, font); WMSetLabelFont(panel->infoL, font);
WMReleaseFont(font); WMReleaseFont(font);

View File

@@ -226,10 +226,11 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction)
ty = y1 + wwin->frame->top_width; ty = y1 + wwin->frame->top_width;
by = y2 - wwin->frame->bottom_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) { 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); XSetForeground(dpy, gc, scr->line_pixel);
/* vertical geometry */ /* 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) / snprintf(num, sizeof(num), "%i", (by - ty - wwin->normal_hints->base_height) /
wwin->normal_hints->height_inc); 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])); */ /* 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 */ /* // ugly hack */
color->color.pixel = scr->line_pixel; color->color.pixel = scr->line_pixel;
scr->wmscreen->drawStringGC = gc; 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)); x - s + 3 - fw/2, my - fh/2 + 1, num, strlen(num));
scr->wmscreen->drawStringGC = saveGC; scr->wmscreen->drawStringGC = saveGC;
color->color.pixel = pixel; 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; mx = x1 + (x2 - x1)/2;
snprintf(num, sizeof(num), "%i", (x2 - x1 - wwin->normal_hints->base_width) / snprintf(num, sizeof(num), "%i", (x2 - x1 - wwin->normal_hints->base_width) /
wwin->normal_hints->width_inc); 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 */ /* left arrow */
/* end bar */ /* end bar */
@@ -354,7 +355,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction)
/* // ugly hack */ /* // ugly hack */
color->color.pixel = scr->line_pixel; color->color.pixel = scr->line_pixel;
scr->wmscreen->drawStringGC = gc; 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)); mx - fw/2 + 1, y - s - fh/2 + 1, num, strlen(num));
scr->wmscreen->drawStringGC = saveGC; scr->wmscreen->drawStringGC = saveGC;
color->color.pixel = pixel; color->color.pixel = pixel;

View File

@@ -818,6 +818,9 @@ wScreenInit(int screen_number)
scr->info_text_font = WMBoldSystemFontOfSize(scr->wmscreen, 12); scr->info_text_font = WMBoldSystemFontOfSize(scr->wmscreen, 12);
scr->tech_draw_font = WMCreateFontWithFlags(scr->wmscreen,
"BoldSystemFont-12",
WFNotAntialiased);
scr->gview = WCreateGeometryView(scr->wmscreen); scr->gview = WCreateGeometryView(scr->wmscreen);
WMRealizeWidget(scr->gview); WMRealizeWidget(scr->gview);

View File

@@ -161,6 +161,8 @@ typedef struct _WScreen {
WMFont *clip_title_font; /* for clip titles */ WMFont *clip_title_font; /* for clip titles */
WMFont *info_text_font; /* text on things like geometry WMFont *info_text_font; /* text on things like geometry
* hint boxes */ * hint boxes */
WMFont *tech_draw_font;
WMFont *workspace_name_font; WMFont *workspace_name_font;
WMColor *select_color; WMColor *select_color;

View File

@@ -295,8 +295,6 @@
#define DEF_WORKSPACE_NAME_FONT "\"-*-lucida-bold-r-*-*-24-*-*-*-*-*-*-*\"" #define DEF_WORKSPACE_NAME_FONT "\"-*-lucida-bold-r-*-*-24-*-*-*-*-*-*-*\""
#endif /* !I18N */ #endif /* !I18N */
#define HELVETICA10_FONT "-*-helvetica-medium-r-normal-*-10-*-*-*-*-*-*-*"
#define DEF_FRAME_THICKNESS 1 /* linewidth of the move/resize frame */ #define DEF_FRAME_THICKNESS 1 /* linewidth of the move/resize frame */
#define DEF_WINDOW_TITLE_EXTEND_SPACE "0" #define DEF_WINDOW_TITLE_EXTEND_SPACE "0"