1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 05:18:06 +01:00

- Added double buffering when drawing a WMFrame title with an AA font to avoid

flickering.
- Added double buffering when drawing WMList items to avoid flickering
- Shared xft drawable
- Renamed AASystemFont and AABoldSystemFont to AntialiasedSystemFont
  respectively AntialiasedBoldSystemFont in WMGLOBAL
- WMCreateFont falls back to normal fonts if antialiased fonts cannot be
  created (even if enabled)
This commit is contained in:
dan
2002-10-13 18:25:36 +00:00
parent 17f26077b0
commit 2b2fecac12
17 changed files with 173 additions and 107 deletions

View File

@@ -16,6 +16,9 @@ Changes since wmaker 0.80.1:
- New options in WMGLOBAL: AntialiasedText, AASystemFont and AABoldSystemFont.
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 WMList items to avoid flickering
Changes since wmaker 0.80.0:

View File

@@ -240,7 +240,7 @@ testList(WMScreen *scr)
list = WMCreateList(win);
/*WMSetListAllowEmptySelection(list, True);*/
WMMoveWidget(list, 10, 40);
for (i=0; i<50; i++) {
for (i=0; i<14050; i++) {
sprintf(text, "Item %i", i);
WMAddListItem(list, text);
}
@@ -248,7 +248,7 @@ testList(WMScreen *scr)
WMSetListAllowMultipleSelection(mlist, True);
/*WMSetListAllowEmptySelection(mlist, True);*/
WMMoveWidget(mlist, 210, 40);
for (i=0; i<135; i++) {
for (i=0; i<14135; i++) {
sprintf(text, "Item %i", i);
WMAddListItem(mlist, text);
}
@@ -1293,6 +1293,7 @@ main(int argc, char **argv)
testDragAndDrop(scr);
testText(scr);
testFontPanel(scr);
testList(scr);
#if 0
testColorPanel(scr);
testScrollView(scr);

View File

@@ -131,6 +131,8 @@ typedef struct W_Screen {
Window rootWin;
struct _XftDraw *xftdraw;
struct W_View *rootView;
RContext *rcontext;
@@ -408,8 +410,8 @@ typedef struct W_EventHandler {
typedef struct _WINGsConfiguration {
char *systemFont;
char *boldSystemFont;
char *aaSystemFont;
char *aaBoldSystemFont;
char *antialiasedSystemFont;
char *antialiasedBoldSystemFont;
int defaultFontSize;
Bool antialiasedText;
Bool useMultiByte;

View File

@@ -65,11 +65,11 @@ W_ReadConfigurations(void)
WINGsConfiguration.boldSystemFont =
WMGetUDStringForKey(defaults, "BoldSystemFont");
WINGsConfiguration.aaSystemFont =
WMGetUDStringForKey(defaults, "AASystemFont");
WINGsConfiguration.antialiasedSystemFont =
WMGetUDStringForKey(defaults, "AntialiasedSystemFont");
WINGsConfiguration.aaBoldSystemFont =
WMGetUDStringForKey(defaults, "AABoldSystemFont");
WINGsConfiguration.antialiasedBoldSystemFont =
WMGetUDStringForKey(defaults, "AntialiasedBoldSystemFont");
#ifdef XFT
WINGsConfiguration.antialiasedText =
@@ -139,11 +139,11 @@ W_ReadConfigurations(void)
if (!WINGsConfiguration.boldSystemFont) {
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
}
if (!WINGsConfiguration.aaSystemFont) {
WINGsConfiguration.aaSystemFont = AASYSTEM_FONT;
if (!WINGsConfiguration.antialiasedSystemFont) {
WINGsConfiguration.antialiasedSystemFont = AASYSTEM_FONT;
}
if (!WINGsConfiguration.aaBoldSystemFont) {
WINGsConfiguration.aaBoldSystemFont = AABOLD_SYSTEM_FONT;
if (!WINGsConfiguration.antialiasedBoldSystemFont) {
WINGsConfiguration.antialiasedBoldSystemFont = AABOLD_SYSTEM_FONT;
}
if (!WINGsConfiguration.floppyPath) {
WINGsConfiguration.floppyPath = FLOPPY_PATH;

View File

@@ -540,28 +540,39 @@ willResizeBrowser(W_ViewDelegate *self, WMView *view,
static void
paintItem(WMList *lPtr, int index, Drawable d, char *text, int state,
WMRect *rect)
paintItem(WMList *lPtr, int index, Drawable drawable, char *text, int state,
WMRect *rect)
{
WMView *view = W_VIEW(lPtr);
W_Screen *scr = view->screen;
int width, height, x, y;
Display *display = scr->display;
WMFont *font = ((state & WLDSIsBranch) ? scr->boldFont : scr->normalFont);
int width, height, x, y, textLen;
Drawable d = drawable;
width = rect->size.width;
height = rect->size.height;
x = rect->pos.x;
y = rect->pos.y;
textLen = strlen(text);
#ifdef DOUBLE_BUFFER_no
x = y = 0;
d = XCreatePixmap(display, drawable, width, height, scr->depth);
if (state & WLDSSelected)
XFillRectangle(scr->display, d, WMColorGC(scr->white), x, y,
width, height);
XFillRectangle(display, d, WMColorGC(scr->white), 0, 0, width, height);
else
XClearArea(scr->display, d, x, y, width, height, False);
XFillRectangle(display, d, WMColorGC(view->backColor), 0, 0, width, height);
#else
if (state & WLDSSelected)
XFillRectangle(display, d, WMColorGC(scr->white), x, y, width, height);
else
//XFillRectangle(display, d, WMColorGC(view->backColor), x, y, width, height);
XClearArea(display, d, x, y, width, height, False);
#endif
if (text) {
/* Avoid overlaping... */
WMFont *font = (state & WLDSIsBranch) ? scr->boldFont : scr->normalFont;
int textLen = strlen(text);
int widthC = (state & WLDSIsBranch) ? width-20 : width-8;
if (WMWidthOfString(font, text, textLen) > widthC) {
char *textBuf = createTruncatedString(font, text, &textLen, widthC);
@@ -575,17 +586,23 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state,
}
if (state & WLDSIsBranch) {
XDrawLine(scr->display, d, WMColorGC(scr->darkGray), x+width-11, y+3,
XDrawLine(display, d, WMColorGC(scr->darkGray), x+width-11, y+3,
x+width-6, y+height/2);
if (state & WLDSSelected)
XDrawLine(scr->display, d,WMColorGC(scr->gray), x+width-11, y+height-5,
XDrawLine(display, d,WMColorGC(scr->gray), x+width-11, y+height-5,
x+width-6, y+height/2);
else
XDrawLine(scr->display, d,WMColorGC(scr->white), x+width-11, y+height-5,
XDrawLine(display, d,WMColorGC(scr->white), x+width-11, y+height-5,
x+width-6, y+height/2);
XDrawLine(scr->display, d, WMColorGC(scr->black), x+width-12, y+3,
XDrawLine(display, d, WMColorGC(scr->black), x+width-12, y+3,
x+width-12, y+height-5);
}
#ifdef DOUBLE_BUFFER_no
XCopyArea(display, d, drawable, scr->copyGC, 0, 0, width, height,
rect->pos.x, rect->pos.y);
XFreePixmap(display, d);
#endif
}

View File

@@ -291,8 +291,8 @@ WMCreateFont(WMScreen *scrPtr, char *fontName)
if (scrPtr->useMultiByte) {
return WMCreateFontSet(scrPtr, fontName);
} else if (scrPtr->antialiasedText) {
/*// should revert to normal if this fails? */
return WMCreateAAFont(scrPtr, fontName);
WMFont *font = WMCreateAAFont(scrPtr, fontName);
return font ? font : WMCreateNormalFont(scrPtr, fontName);
} else {
return WMCreateNormalFont(scrPtr, fontName);
}
@@ -373,13 +373,15 @@ makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold)
WMFont *font;
char *fontSpec, *aaFontSpec;
#define WConf WINGsConfiguration
if (bold) {
fontSpec = makeFontSetOfSize(WINGsConfiguration.boldSystemFont, size);
aaFontSpec = makeFontSetOfSize(WINGsConfiguration.aaBoldSystemFont, size);
fontSpec = makeFontSetOfSize(WConf.boldSystemFont, size);
aaFontSpec = makeFontSetOfSize(WConf.antialiasedBoldSystemFont, size);
} else {
fontSpec = makeFontSetOfSize(WINGsConfiguration.systemFont, size);
aaFontSpec = makeFontSetOfSize(WINGsConfiguration.aaSystemFont, size);
fontSpec = makeFontSetOfSize(WConf.systemFont, size);
aaFontSpec = makeFontSetOfSize(WConf.antialiasedSystemFont, size);
}
#undef WConf
if (scrPtr->useMultiByte) {
font = WMCreateFontSet(scrPtr, fontSpec);
@@ -497,7 +499,6 @@ WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
if (font->antialiased) {
#ifdef XFT
XftColor xftcolor;
XftDraw *xftdraw;
xftcolor.color.red = color->color.red;
xftcolor.color.green = color->color.green;
@@ -505,13 +506,10 @@ WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
xftcolor.color.alpha = color->alpha;;
xftcolor.pixel = W_PIXEL(color);
/* //share if possible */
xftdraw = XftDrawCreate(scr->display, d, scr->visual, scr->colormap);
XftDrawChange(scr->xftdraw, d);
XftDrawString8(xftdraw, &xftcolor, font->font.xft,
XftDrawString8(scr->xftdraw, &xftcolor, font->font.xft,
x, y + font->y, text, length);
XftDrawDestroy(xftdraw);
#else
assert(False);
#endif
@@ -540,7 +538,6 @@ WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background
#ifdef XFT
XftColor textColor;
XftColor bgColor;
XftDraw *xftdraw;
textColor.color.red = color->color.red;
textColor.color.green = color->color.green;
@@ -554,16 +551,14 @@ WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background
bgColor.color.alpha = background->alpha;;
bgColor.pixel = W_PIXEL(background);
/* //share if possible */
xftdraw = XftDrawCreate(scr->display, d, scr->visual, scr->colormap);
XftDrawRect(xftdraw, &bgColor, x, y,
XftDrawChange(scr->xftdraw, d);
XftDrawRect(scr->xftdraw, &bgColor, x, y,
WMWidthOfString(font, text, length), font->height);
XftDrawString8(xftdraw, &textColor, font->font.xft, x, y + font->y,
text, length);
XftDrawDestroy(xftdraw);
XftDrawString8(scr->xftdraw, &textColor, font->font.xft,
x, y + font->y, text, length);
#else
assert(False);
#endif

View File

@@ -82,14 +82,18 @@ paintFrame(Frame *fPtr)
{
W_View *view = fPtr->view;
W_Screen *scrPtr = view->screen;
int tx, ty, tw, th;
WMFont *font = scrPtr->normalFont;
Display *display = scrPtr->display;
int tx, ty, tw, th, tlen;
int fy, fh;
Bool drawTitle;
if (fPtr->caption!=NULL)
th = WMFontHeight(scrPtr->normalFont);
else {
th = 0;
if (fPtr->caption!=NULL) {
th = WMFontHeight(font);
tlen = strlen(fPtr->caption);
} else {
th = 0;
tlen = 0;
}
fh = view->size.height;
@@ -139,12 +143,11 @@ paintFrame(Frame *fPtr)
}
if (fPtr->caption!=NULL && fPtr->flags.titlePosition!=WTPNoTitle) {
tw = WMWidthOfString(scrPtr->normalFont, fPtr->caption,
strlen(fPtr->caption));
tw = WMWidthOfString(font, fPtr->caption, tlen);
tx = (view->size.width - tw) / 2;
tx = (view->size.width - tw) / 2;
drawTitle = True;
drawTitle = True;
} else {
drawTitle = False;
}
@@ -180,7 +183,7 @@ paintFrame(Frame *fPtr)
gc[3] = WMColorGC(scrPtr->white);
for (i = 0; i < 4; i++) {
XSetRegion(scrPtr->display, gc[i], region);
XSetRegion(display, gc[i], region);
}
XDestroyRegion(region);
@@ -188,13 +191,31 @@ paintFrame(Frame *fPtr)
fPtr->flags.relief, gc[0], gc[1], gc[2], gc[3]);
for (i = 0; i < 4; i++) {
XSetClipMask(scrPtr->display, gc[i], None);
XSetClipMask(display, gc[i], None);
}
}
if (drawTitle) {
WMDrawString(scrPtr, view->window, scrPtr->black, scrPtr->normalFont,
tx, ty, fPtr->caption, strlen(fPtr->caption));
/* can't draw AA text over and over again because it gets messed */
if (font->antialiased) {
#ifdef DOUBLE_BUFFER
Drawable d;
d = XCreatePixmap(display, view->window, tw, th, scrPtr->depth);
XFillRectangle(display, d, WMColorGC(view->backColor), 0, 0, tw, th);
WMDrawString(scrPtr, d, scrPtr->black, font, 0, 0, fPtr->caption, tlen);
XCopyArea(display, d, view->window, scrPtr->copyGC, 0, 0, tw, th, tx, ty);
XFreePixmap(display, d);
#else
XClearArea(display, view->window, tx, ty, tw, th, False);
WMDrawString(scrPtr, view->window, scrPtr->black, font, tx, ty,
fPtr->caption, tlen);
#endif
} else {
WMDrawString(scrPtr, view->window, scrPtr->black, font, tx, ty,
fPtr->caption, tlen);
}
}
}

View File

@@ -3,6 +3,10 @@
#include "WINGsP.h"
#include "wconfig.h"
#ifdef XFT
# include <X11/Xft/Xft.h>
#endif
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
@@ -620,6 +624,10 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->fontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks);
#ifdef XFT
scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr),
scrPtr->visual, scrPtr->colormap);
#endif
/* create input method stuff */
W_InitIMStuff(scrPtr);

View File

@@ -491,7 +491,8 @@ paintItem(List *lPtr, int index)
{
WMView *view = lPtr->view;
W_Screen *scr = view->screen;
int width, height, x, y;
Display *display = scr->display;
int width, height, x, y, tlen;
WMListItem *itemPtr;
itemPtr = WMGetFromArray(lPtr->items, index);
@@ -500,11 +501,14 @@ paintItem(List *lPtr, int index)
height = lPtr->itemHeight;
x = 19;
y = 2 + (index-lPtr->topItem) * lPtr->itemHeight + 1;
tlen = strlen(itemPtr->text);
if (lPtr->flags.userDrawn) {
WMRect rect;
Drawable d = view->window;
int flags;
rect.size.width = width;
rect.size.height = height;
rect.pos.x = x;
@@ -518,20 +522,41 @@ paintItem(List *lPtr, int index)
if (itemPtr->isBranch)
flags |= WLDSIsBranch;
#ifdef DOUBLE_BUFFER_no
d = XCreatePixmap(display, view->window, view->size.width,
view->size.height, scr->depth);
#endif
if (lPtr->draw)
(*lPtr->draw)(lPtr, index, view->window, itemPtr->text, flags,
&rect);
(*lPtr->draw)(lPtr, index, d, itemPtr->text, flags, &rect);
#ifdef DOUBLE_BUFFER_no
XCopyArea(display, d, view->window, scr->copyGC, x, y, width, height, x, y);
XFreePixmap(display, d);
#endif
} else {
#ifdef DOUBLE_BUFFER
WMColor *back = (itemPtr->selected ? scr->white : view->backColor);
Drawable d;
d = XCreatePixmap(display, view->window, width, height, scr->depth);
XFillRectangle(display, d, WMColorGC(back), 0, 0, width, height);
W_PaintText(view, d, scr->normalFont, 4, 0, width, WALeft, scr->black,
False, itemPtr->text, tlen);
XCopyArea(display, d, view->window, scr->copyGC, 0, 0, width, height, x, y);
XFreePixmap(display, d);
#else
if (itemPtr->selected) {
XFillRectangle(scr->display, view->window, WMColorGC(scr->white),
XFillRectangle(display, view->window, WMColorGC(scr->white),
x, y, width, height);
} else {
XClearArea(scr->display, view->window, x, y, width, height, False);
XClearArea(display, view->window, x, y, width, height, False);
}
W_PaintText(view, view->window, scr->normalFont, x+4, y, width,
WALeft, scr->black, False,
itemPtr->text, strlen(itemPtr->text));
WALeft, scr->black, False, itemPtr->text, tlen);
#endif
}
if ((index-lPtr->topItem+lPtr->fullFitLines)*lPtr->itemHeight >

View File

@@ -208,24 +208,19 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
#endif
/* background */
#ifndef DOUBLE_BUFFER
if (backColor) {
XFillRectangle(screen->display, d, WMColorGC(backColor),
0, 0, view->size.width, view->size.height);
} else {
#ifndef DOUBLE_BUFFER
XClearWindow(screen->display, d);
}
#else
if (backColor)
XFillRectangle(screen->display, d, WMColorGC(backColor), 0, 0,
view->size.width, view->size.height);
else {
XSetForeground(screen->display, screen->copyGC,
view->attribs.background_pixel);
XFillRectangle(screen->display, d, screen->copyGC, 0, 0,
view->size.width, view->size.height);
}
#endif
}
if (relief == WRFlat) {

View File

@@ -440,10 +440,10 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state,
y = rect->pos.y;
if (state & WLDSSelected)
XFillRectangle(dpy, d, WMColorGC(panel->white), x, y, width,
height);
XFillRectangle(dpy, d, WMColorGC(panel->white), x, y, width, height);
else
XClearArea(dpy, d, x, y, width, height, False);
//XClearArea(dpy, d, x, y, width, height, False);
XFillRectangle(dpy, d, WMColorGC(WMGrayColor(scr)), x, y, width, height);
if (panel->shortcuts[index]) {
WMPixmap *pix = WMGetSystemPixmap(scr, WSICheckMark);

View File

@@ -1,8 +1,8 @@
{
SystemFont = "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*";
BoldSystemFont = "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-normal-*-%d-*,-*-*-medium-r-normal-*-*-*";
AASystemFont = "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*";
AABoldSystemFont = "-*-arial-bold-r-normal-*-%d-*-*-*-*-*-*-*";
AntialiasedSystemFont = "-*-trebuchet ms-medium-r-normal-*-%d-*-*-*-*-*-*-*";
AntialiasedBoldSystemFont = "-*-trebuchet ms-bold-r-normal-*-%d-*-*-*-*-*-*-*";
DefaultFontSize = 12;
AntialiasedText = NO;
MultiByteText = AUTO;

View File

@@ -85,7 +85,7 @@ with a .po extension, reconfigure WindowMaker and run
make install.
To update an already translated message file use the msgmerge command. As in:
msgmerge WindowMaker.pot pt.po > pt.po.new
msgmerge pt.po WindowMaker.pot > pt.po.new
If you use an older version of gettext, the command is tupdate, instead
of msgmerge.

View File

@@ -115,8 +115,8 @@ INCLUDES = \
wmaker_LDADD = \
$(top_builddir)/WINGs/libWINGs.a\
$(top_builddir)/wrlib/libwraster.la\
@XLIBS@ \
@XFTLIBS@ \
@XLIBS@ \
@INTLIBS@ \
@DLLIBS@

View File

@@ -650,7 +650,8 @@ wGNOMERemoveClient(WWindow *wwin)
static void observer(void *self, WMNotification *notif)
static void
observer(void *self, WMNotification *notif)
{
WWindow *wwin = (WWindow*)WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
@@ -668,7 +669,9 @@ static void observer(void *self, WMNotification *notif)
}
}
static void wsobserver(void *self, WMNotification *notif)
static void
wsobserver(void *self, WMNotification *notif)
{
WScreen *scr = (WScreen*)WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
@@ -681,8 +684,6 @@ static void wsobserver(void *self, WMNotification *notif)
wGNOMEUpdateWorkspaceNamesHint(scr);
} else if (strcmp(name, WMNWorkspaceChanged) == 0) {
wGNOMEUpdateCurrentWorkspaceHint(scr);
} else if (strcmp(name, WMNResetStacking) == 0) {
}

View File

@@ -352,6 +352,9 @@ wOLWMCheckClientHints(WWindow *wwin)
menuType = MT_LIMITED;
/* this is a transient-like window */
wwin->client_flags.olwm_transient = 1;
} else if (hints.winType == WT_NOTICE) {
decoration = OL_DECORATION_ICONNAME;
@@ -397,11 +400,6 @@ wOLWMCheckClientHints(WWindow *wwin)
else
wwin->flags.olwm_limit_menu = 1;
/* this is a transient-like window */
if (hints.winType == WT_CMD) {
wwin->client_flags.olwm_transient = 1;
}
/*
* Emulate olwm pushpin.
* If the initial state of the pin is in, then put the normal close