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()
- 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:

View File

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

View File

@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.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.
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.

View File

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

View File

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

View File

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

View File

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

View File

@@ -107,6 +107,31 @@ enum {
};
/* 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,
@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {
defaults->dontSync = 1;
}
path = wdefaultspathfordomain(WMGetFromPLString(key));
if (stat(path, &stbuf) >= 0)
defaults->timestamp = stbuf.st_mtime;
domain = WMReadPropListFromFile(path);
}
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
@@ -669,6 +664,7 @@ WMSetUDSearchList(WMUserDefaults *database, WMPropList *list)
for (i=0; i<c; i++) {
database->searchList[i] = WMGetFromPLArray(list, i);
}
database->searchList[c] = NULL;
database->searchListArray = WMDeepCopyPropList(list);
}

View File

@@ -35,7 +35,7 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv)
assert(argv!=NULL);
assert(applicationName!=NULL);
/* // TODO: check if to move inside #ifdef I18N */
setlocale(LC_ALL, "");
#ifdef I18N

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*
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);
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]);
}
@@ -147,6 +193,7 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
}
if (!font->font.set) {
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);
} else {
return 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 {
font = WMCreateNormalFont(scrPtr, fontName);
}
return font;
}
@@ -342,7 +416,9 @@ WMReleaseFont(WMFont *font)
XFreeFontSet(font->screen->display, font->font.set);
}
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);
} 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);
}

View File

@@ -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;

View File

@@ -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;
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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -481,7 +481,7 @@ 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);
}
@@ -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);
}
@@ -516,7 +516,7 @@ 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);
}

View File

@@ -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;

View File

@@ -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);
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, "Window Maker");
}
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);

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;
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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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"