1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-07 08:45:48 +01:00

- Check whether libXft is at least version 2.1.2 else refuse to compile.

- Fixed bug in icon chooser dialog that could cause a segmentation fault
  in some cases (Pascal Hofstee <caelian@gmail.com>)
- Fixed crash in asm code in wrlib, with new versions of gcc.
- Fixed bug in the x86_PseudoColor_32_to_8() function which incorrectly
  used the r, g, b fields in the conversion.
- Fixed x86 ASM code in wrlib to work on 64 bit architectures.
- Fixed the focus flicker seen with some apps (notably gtk2)
  (Alexey Spiridonov <snarkmaster@gmail.com>)
- Fixed all crashing bugs that were generated by wmaker starting with the
  WMState file missing.
- Added NetWM support (a modified version of the patch originaly written
  by Peter Zijlstra <a.p.zijlstra@chello.nl>)
- Applied patch to enhance the Virtual Desktop behaviour, and to integrate
  it with the NetWM code (Peter Zijlstra <a.p.zijlstra@chello.nl>)
- Applied a few xinerama and placement fixes (Peter Zijlstra
    <a.p.zijlstra@chello.nl>)
- Fixed memory leak in dock code.
- Fixed and enhanced the text wrapping in WINGs.
- Fixed the layout of some elements in WPrefs.app
- Added workaround for aplications that don't set the required hints on the
  client leader window, but they set them on normal windows (observer with
  KDE 3.3.0 mainly). This will allow these apps to get an appicon again.
  (they should be fixed still)
- Added workaround for applications that do not set a command with
  XSetCommand(), but instead they set the _NET_WM_PID property. This works
  with operating systems that offer a /proc interface similar to what linux
  has. (This also is to fix problems with KDE 3.3.0 apps, but not only them).
- Fixed bug with autostart and exit scripts not being executed if user
  GNUstep path was different from ~/GNUstep (when setting GNUSTEP_USER_ROOT)
- Added utf8 support in WINGs (removed old X core font code)
- Added utility to convert old font names to new font names in style files
This commit is contained in:
dan
2004-10-12 01:34:32 +00:00
parent c7c68c6fe7
commit 9aca0d5f6e
88 changed files with 6638 additions and 3497 deletions

View File

@@ -1,8 +1,8 @@
Changes since wmaker 0.80.1:
............................
- added WMSetConnectionShutdownOnClose()
- added an extra member to the ConnectionDelegate: canResumeSending
- Added WMSetConnectionShutdownOnClose()
- Added an extra member to the ConnectionDelegate: canResumeSending
see NEWS for details.
- WMDrawString() and WMDrawImageString() now take WMColor instead of GC as
arguments. WMDrawImageString() receives 2 colors (text & background).
@@ -49,12 +49,13 @@ Changes since wmaker 0.80.1:
- Fixed a memleak in the file panel.
- Double/triple-click selection in text widgets
(Vitaly Ovtchinnikov <ov@rbcmail.ru>)
- fixed bug in tableview (clicked row callback got incorrect row)
- Fixed bug in tableview (clicked row callback got incorrect row)
(Carlos Torres <vlaadbrain@operamail.com>)
- Fixed bug in resizing a scrollview
- Fixed bug with wrong text wrapping (Alexey Voinov <voins@voins.program.ru>)
- Added wmkrect()
- Added xdnd v3 support (Sylvain Reynal <sreynal@nerim.net>)
- Fixed and enhanced text wrapping.
Changes since wmaker 0.80.0:

View File

@@ -21,7 +21,8 @@ int MoveCount;
int WinSize = 120;
Bool CheckWin(void)
Bool
CheckWin(void)
{
int i;
@@ -34,15 +35,17 @@ Bool CheckWin(void)
}
void MoveButton(int button, int x, int y)
void
MoveButton(int button, int x, int y)
{
WMMoveWidget(Button[button], x*(WinSize/Size), y*(WinSize/Size));
}
Bool SlideButton(int button)
Bool
SlideButton(int button)
{
int x, y, done = 0;
int x=0, y=0, done = 0;
/* locate the button */
for (y = 0; y < Size; y++) {

View File

@@ -22,6 +22,7 @@ libExtraWINGs_a_SOURCES = \
wtableview.h \
wtabledelegates.h
AM_CFLAGS = -fno-strict-aliasing
INCLUDES = -I$(top_srcdir)/wrlib -I$(top_srcdir)/WINGs \
-DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG

View File

@@ -108,7 +108,9 @@ libWUtil_a_SOURCES = \
wutil.c
AM_CPPFLAGS = @CPPFLAGS@ -DLOCALEDIR=\"$(NLSDIR)\"
AM_CPPFLAGS = -DLOCALEDIR=\"$(NLSDIR)\"
AM_CFLAGS = -fno-strict-aliasing
INCLUDES = -I$(top_srcdir)/WINGs/WINGs -I$(top_srcdir)/wrlib -I$(top_srcdir)/src \
-DRESOURCE_PATH=\"$(datadir)/WINGs\" @XFTFLAGS@ @HEADER_SEARCH_PATH@ -DDEBUG

View File

@@ -116,14 +116,14 @@ testFrame(WMScreen *scr)
}
static void
/*static void
resizedWindow(void *self, WMNotification *notif)
{
WMView *view = (WMView*)WMGetNotificationObject(notif);
WMSize size = WMGetViewSize(view);
WMResizeWidget((WMWidget*)self, size.width, size.height);
}
}*/
void
testBox(WMScreen *scr)
@@ -609,7 +609,8 @@ testText(WMScreen *scr)
WMFont *font, *ifont;
font = WMDefaultSystemFont(scr);
ifont = WMCopyFontWithStyle(scr, font, WFSEmphasized);
//ifont = WMCopyFontWithStyle(scr, font, WFSEmphasized);
ifont = WMCreateFont(scr, "verdana,sans:pixelsize=12:italic");
if (ifont) {
WMSetTextDefaultFont(text, ifont);
WMReleaseFont(ifont);
@@ -619,7 +620,7 @@ testText(WMScreen *scr)
WMReleaseFont(font);
}
if(file) {
if (file) {
char buf[1024];
WMFreezeText(text);
@@ -1042,6 +1043,7 @@ main(int argc, char **argv)
testColorPanel(scr);
testFrame(scr);
#if 0
testBox(scr);

View File

@@ -1834,12 +1834,11 @@ void WMShowFontPanel(WMFontPanel *panel);
void WMHideFontPanel(WMFontPanel *panel);
void WMFreeFontPanel(WMFontPanel *panel);
void WMSetFontPanelAction(WMFontPanel *panel, WMAction2 *action, void *data);
void WMSetFontPanelFont(WMFontPanel *panel, WMFont *font);
/* you can free the returned string */
char* WMGetFontPanelFontName(WMFontPanel *panel);
void WMSetFontPanelFont(WMFontPanel *panel, char *fontName);
WMFont* WMGetFontPanelFont(WMFontPanel *panel);

View File

@@ -22,19 +22,14 @@
extern "C" {
#endif /* __cplusplus */
#define DOUBLE_BUFFER
#define DOUBLE_BUFFER 1
#define WC_UserWidget 128
#define SCROLLER_WIDTH 20
#define SCROLLER_WIDTH 20
#define XDND_VERSION 4
#define XDND_VERSION 4
typedef struct W_Application {

View File

@@ -14,10 +14,6 @@ _WINGsConfiguration WINGsConfiguration;
#define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*"
#define XFTSYSTEM_FONT "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*"
#define XFTBOLD_SYSTEM_FONT "-*-arial-bold-r-normal-*-%d-*-*-*-*-*-*-*"
#define FLOPPY_PATH "/floppy"
@@ -45,6 +41,7 @@ getButtonWithName(const char *name, unsigned defaultButton)
}
// fix this
static Bool
missingOrInvalidXLFD(char *xlfd)
{

View File

@@ -193,14 +193,15 @@ W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event)
WMDraggingInfo *info = &scr->dragInfo;
Atom messageType = event->message_type;
char* msgTypeName = XGetAtomName(scr->display, messageType);
#ifdef XDND_DEBUG
{
char* msgTypeName = XGetAtomName(scr->display, messageType);
if (msgTypeName != NULL)
printf("event type = %s\n", msgTypeName);
else
printf("pb with event type !\n");
if (msgTypeName != NULL)
printf("event type = %s\n", msgTypeName);
else
printf("pb with event type !\n");
}
#endif

View File

@@ -79,7 +79,7 @@ createDropDataArray(WMArray *requiredTypes)
static WMArray*
getTypesFromTypeList(WMScreen *scr, Window sourceWin)
{
WMDraggingInfo *info = &scr->dragInfo;
/* // WMDraggingInfo *info = &scr->dragInfo;*/
Atom dataType;
Atom* typeAtomList;
WMArray* typeList;
@@ -365,7 +365,6 @@ W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info,
WMView *toplevel, XClientMessageEvent *event)
{
WMScreen *scr = W_VIEW_SCREEN(toplevel);
int i,j, typesCount;
if (XDND_DEST_INFO(info) == NULL)
initDestinationDragInfo(info);
@@ -609,7 +608,7 @@ static void
sendAllowedAction(WMView *destView, Atom action)
{
WMScreen *scr = W_VIEW_SCREEN(destView);
WMPoint destPos = WMGetViewScreenPosition(destView);
/* // WMPoint destPos = WMGetViewScreenPosition(destView); */
WMSize destSize = WMGetViewSize(destView);
int destX, destY;
Window foo;

View File

@@ -425,6 +425,8 @@ sendEnterMessage(WMDraggingInfo *info)
}
// this functon doesn't return something in all cases.
// control reaches end of non-void function. fix this -Dan
static Bool
sendPositionMessage(WMDraggingInfo *info, WMPoint *mousePos)
{
@@ -740,7 +742,6 @@ isXdndAware(WMScreen *scr, Window win)
int format;
unsigned long count, remain;
unsigned char *winXdndVersion;
unsigned char *proxy;
if (win == None)
return False;
@@ -876,7 +877,7 @@ initMotionProcess(WMView *view, WMDraggingInfo *info,
static void
processMotion(WMDraggingInfo *info, Window windowUnderDrag, WMPoint *mousePos)
{
WMScreen *scr = sourceScreen(info);
/* // WMScreen *scr = sourceScreen(info); */
Window newDestination = findDestination(info, mousePos);
W_DragSourceStopTimer();
@@ -1058,6 +1059,7 @@ traceStatusMsg(Display *dpy, XClientMessageEvent *statusEvent)
#endif
static void
storeDropAction(WMDraggingInfo *info, Atom destAction)
{
WMView* sourceView = XDND_SOURCE_VIEW(info);

View File

@@ -26,10 +26,11 @@ class WMTimer:
self._o = wings.pyWMAddPersistentTimerHandler(milliseconds, (callback, cdata))
else:
self._o = wings.pyWMAddTimerHandler(milliseconds, (callback, cdata))
self.__WMDeleteTimerHandler = wings.pyWMDeleteTimerHandler
def __del__(self):
wings.pyWMDeleteTimerHandler(self._o)
#delete = __del__
self.__WMDeleteTimerHandler(self._o)
class WMPersistentTimer(WMTimer):
def __init__(self, milliseconds, callback, cdata=None):
@@ -87,14 +88,15 @@ class WMView:
class WMWidget(WMView):
def __init__(self):
self._o = None
if self.__class__ == WMWidget:
raise Error, "a WMWidget can't be instantiated directly"
self._o = None
self.__WMDestroyWidget = wings.WMDestroyWidget
def __del__(self):
if (self._o != None):
wings.WMDestroyWidget(self._o)
if self._o is not None:
self.__WMDestroyWidget(self._o)
def resize(self, width, height):
wings.WMResizeWidget(self._o, width, height)

View File

@@ -272,7 +272,7 @@ WMGetStandardUserDefaults(void)
defaults = wmalloc(sizeof(WMUserDefaults));
memset(defaults, 0, sizeof(WMUserDefaults));
defaults->defaults = WMCreatePLDictionary(NULL, NULL, NULL);
defaults->defaults = WMCreatePLDictionary(NULL, NULL);
defaults->searchList = wmalloc(sizeof(WMPropList*)*3);
@@ -293,7 +293,7 @@ WMGetStandardUserDefaults(void)
domain = WMReadPropListFromFile(path);
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
domain = WMCreatePLDictionary(NULL, NULL);
if (path)
wfree(path);
@@ -314,7 +314,7 @@ WMGetStandardUserDefaults(void)
wfree(path);
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
domain = WMCreatePLDictionary(NULL, NULL);
if (domain)
WMPutInPLDictionary(defaults->defaults, key, domain);
@@ -367,7 +367,7 @@ WMGetDefaultsFromPath(char *path)
defaults = wmalloc(sizeof(WMUserDefaults));
memset(defaults, 0, sizeof(WMUserDefaults));
defaults->defaults = WMCreatePLDictionary(NULL, NULL, NULL);
defaults->defaults = WMCreatePLDictionary(NULL, NULL);
defaults->searchList = wmalloc(sizeof(WMPropList*)*2);
@@ -387,7 +387,7 @@ WMGetDefaultsFromPath(char *path)
domain = WMReadPropListFromFile(path);
if (!domain)
domain = WMCreatePLDictionary(NULL, NULL, NULL);
domain = WMCreatePLDictionary(NULL, NULL);
defaults->path = wstrdup(path);

View File

@@ -66,8 +66,8 @@ static WMEventHook *extraEventHandler=NULL;
*
*/
void
WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
void *clientData)
WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
void *clientData)
{
W_EventHandler *hPtr;
WMArrayIterator iter;

File diff suppressed because it is too large Load Diff

769
WINGs/wfont_noxft.c Normal file
View File

@@ -0,0 +1,769 @@
#include "wconfig.h"
#ifndef XFT
#include "WINGsP.h"
#include <wraster.h>
#include <assert.h>
#include <X11/Xlocale.h>
static char *makeFontSetOfSize(char *fontset, int size);
/* XLFD pattern matching */
static char*
getElementFromXLFD(const char *xlfd, int index)
{
const char *p = xlfd;
while (*p != 0) {
if (*p == '-' && --index == 0) {
const char *end = strchr(p + 1, '-');
char *buf;
size_t len;
if (end == 0) end = p + strlen(p);
len = end - (p + 1);
buf = wmalloc(len);
memcpy(buf, p + 1, len);
buf[len] = 0;
return buf;
}
p++;
}
return strdup("*");
}
/* XLFD pattern matching */
static char*
generalizeXLFD(const char *xlfd)
{
char *buf;
int len;
char *weight = getElementFromXLFD(xlfd, 3);
char *slant = getElementFromXLFD(xlfd, 4);
char *pxlsz = getElementFromXLFD(xlfd, 7);
#define Xstrlen(A) ((A)?strlen(A):0)
len = Xstrlen(xlfd)+Xstrlen(weight)+Xstrlen(slant)+Xstrlen(pxlsz)*2+60;
#undef Xstrlen
buf = wmalloc(len + 1);
snprintf(buf, len + 1, "%s,-*-*-%s-%s-*-*-%s-*-*-*-*-*-*-*,"
"-*-*-*-*-*-*-%s-*-*-*-*-*-*-*,*",
xlfd, weight, slant, pxlsz, pxlsz);
wfree(pxlsz);
wfree(slant);
wfree(weight);
return buf;
}
/* XLFD pattern matching */
static XFontSet
W_CreateFontSetWithGuess(Display *dpy, char *xlfd, char ***missing,
int *nmissing, char **def_string)
{
XFontSet fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
if (fs != NULL && *nmissing == 0) return fs;
/* for non-iso8859-1 language and iso8859-1 specification
(this fontset is only for pattern analysis) */
if (fs == NULL) {
if (*nmissing != 0) XFreeStringList(*missing);
setlocale(LC_CTYPE, "C");
fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
setlocale(LC_CTYPE, "");
}
/* make XLFD font name for pattern analysis */
if (fs != NULL) {
XFontStruct **fontstructs;
char **fontnames;
if (XFontsOfFontSet(fs, &fontstructs, &fontnames) > 0)
xlfd = fontnames[0];
}
xlfd = generalizeXLFD(xlfd);
if (*nmissing != 0) XFreeStringList(*missing);
if (fs != NULL) XFreeFontSet(dpy, fs);
fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
wfree(xlfd);
return fs;
}
static char*
xlfdFromFontName(char *fontName)
{
char *systemFont, *boldSystemFont;
char *font;
int size;
systemFont = WINGsConfiguration.systemFont;
boldSystemFont = WINGsConfiguration.boldSystemFont;
size = WINGsConfiguration.defaultFontSize;
if (strcmp(fontName, "SystemFont")==0) {
font = systemFont;
} 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;
} 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)
{
WMFont *font;
Display *display = scrPtr->display;
char **missing;
int nmissing = 0;
char *defaultString;
char *fname;
XFontSetExtents *extents;
fname = xlfdFromFontName(fontName);
font = WMHashGet(scrPtr->fontSetCache, fname);
if (font) {
WMRetainFont(font);
wfree(fname);
return font;
}
font = wmalloc(sizeof(WMFont));
memset(font, 0, sizeof(WMFont));
font->notFontSet = 0;
font->screen = scrPtr;
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:"), fname);
for (i = 0; i < nmissing; i++) {
wwarning(missing[i]);
}
XFreeStringList(missing);
if (defaultString)
wwarning(_("the string \"%s\" will be used in place of any characters from those sets."),
defaultString);
}
if (!font->font.set) {
wfree(font);
wfree(fname);
return NULL;
}
extents = XExtentsOfFontSet(font->font.set);
font->height = extents->max_logical_extent.height;
font->y = font->height - (font->height + extents->max_logical_extent.y);
font->refCount = 1;
font->name = fname;
assert(WMHashInsert(scrPtr->fontSetCache, font->name, font)==NULL);
return font;
}
WMFont*
WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
{
WMFont *font;
Display *display = scrPtr->display;
char *fname, *ptr;
fontName = xlfdFromFontName(fontName);
if ((ptr = strchr(fontName, ','))) {
fname = wmalloc(ptr - fontName + 1);
strncpy(fname, fontName, ptr - fontName);
fname[ptr - fontName] = 0;
} else {
fname = wstrdup(fontName);
}
wfree(fontName);
font = WMHashGet(scrPtr->fontCache, fname);
if (font) {
WMRetainFont(font);
wfree(fname);
return font;
}
font = wmalloc(sizeof(WMFont));
memset(font, 0, sizeof(WMFont));
font->notFontSet = 1;
font->screen = scrPtr;
font->font.normal = XLoadQueryFont(display, fname);
if (!font->font.normal) {
wfree(font);
wfree(fname);
return NULL;
}
font->height = font->font.normal->ascent+font->font.normal->descent;
font->y = font->font.normal->ascent;
font->refCount = 1;
font->name = fname;
assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL);
return font;
}
WMFont*
WMCreateFont(WMScreen *scrPtr, char *fontName)
{
return WMCreateFontWithFlags(scrPtr, fontName, WFDefaultFont);
}
WMFont*
WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags)
{
Bool multiByte = scrPtr->useMultiByte;
WMFont *font;
if (flags & WFFontSet) {
multiByte = True;
} else if (flags & WFNormalFont) {
multiByte = False;
}
} else if (multiByte) {
font = WMCreateFontSet(scrPtr, fontName);
} else {
font = WMCreateNormalFont(scrPtr, fontName);
}
return font;
}
WMFont*
WMRetainFont(WMFont *font)
{
wassertrv(font!=NULL, NULL);
font->refCount++;
return font;
}
void
WMReleaseFont(WMFont *font)
{
wassertr(font!=NULL);
font->refCount--;
if (font->refCount < 1) {
if (font->notFontSet) {
XFreeFont(font->screen->display, font->font.normal);
} else {
XFreeFontSet(font->screen->display, font->font.set);
}
if (font->name) {
if (font->notFontSet) {
WMHashRemove(font->screen->fontCache, font->name);
} else {
WMHashRemove(font->screen->fontSetCache, font->name);
}
wfree(font->name);
}
wfree(font);
}
}
Bool
WMIsAntialiasingEnabled(WMScreen *scrPtr)
{
return False;
}
unsigned int
WMFontHeight(WMFont *font)
{
wassertrv(font!=NULL, 0);
return font->height;
}
char*
WMGetFontName(WMFont *font)
{
wassertrv(font!=NULL, NULL);
return font->name;
}
WMFont*
WMDefaultSystemFont(WMScreen *scrPtr)
{
return WMRetainFont(scrPtr->normalFont);
}
WMFont*
WMDefaultBoldSystemFont(WMScreen *scrPtr)
{
return WMRetainFont(scrPtr->boldFont);
}
static WMFont*
makeSystemFontOfSize(WMScreen *scrPtr, int size, Bool bold)
{
WMFont *font;
char *fontSpec;
#define WConf WINGsConfiguration
if (bold) {
fontSpec = makeFontSetOfSize(WConf.boldSystemFont, size);
} else {
fontSpec = makeFontSetOfSize(WConf.systemFont, size);
}
#undef WConf
if (scrPtr->useMultiByte) {
font = WMCreateFontSet(scrPtr, fontSpec);
} else {
font = WMCreateNormalFont(scrPtr, fontSpec);
}
if (!font) {
if (scrPtr->useMultiByte) {
wwarning(_("could not load font set %s. Trying fixed."), fontSpec);
font = WMCreateFontSet(scrPtr, "fixed");
if (!font) {
font = WMCreateFontSet(scrPtr, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*");
}
} else {
wwarning(_("could not load font %s. Trying fixed."), fontSpec);
font = WMCreateNormalFont(scrPtr, "fixed");
}
if (!font) {
wwarning(_("could not load fixed font!"));
wfree(fontSpec);
return NULL;
}
}
wfree(fontSpec);
return font;
}
WMFont*
WMSystemFontOfSize(WMScreen *scrPtr, int size)
{
return makeSystemFontOfSize(scrPtr, size, False);
}
WMFont*
WMBoldSystemFontOfSize(WMScreen *scrPtr, int size)
{
return makeSystemFontOfSize(scrPtr, size, True);
}
XFontSet
WMGetFontFontSet(WMFont *font)
{
wassertrv(font!=NULL, NULL);
if (!font->notFontSet && !font->antialiased)
return font->font.set;
return NULL;
}
int
WMWidthOfString(WMFont *font, char *text, int length)
{
wassertrv(font!=NULL, 0);
wassertrv(text!=NULL, 0);
if (font->notFontSet) {
return XTextWidth(font->font.normal, text, length);
} else {
XRectangle rect;
XRectangle AIXsucks;
XmbTextExtents(font->font.set, text, length, &AIXsucks, &rect);
return rect.width;
}
}
void
WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
int x, int y, char *text, int length)
{
wassertr(font!=NULL);
if (font->notFontSet) {
XSetFont(scr->display, scr->drawStringGC, font->font.normal->fid);
XSetForeground(scr->display, scr->drawStringGC, W_PIXEL(color));
XDrawString(scr->display, d, scr->drawStringGC, x, y + font->y,
text, length);
} else {
XSetForeground(scr->display, scr->drawStringGC, W_PIXEL(color));
XmbDrawString(scr->display, d, font->font.set, scr->drawStringGC,
x, y + font->y, text, length);
}
}
void
WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background,
WMFont *font, int x, int y, char *text, int length)
{
wassertr(font!=NULL);
if (font->notFontSet) {
XSetForeground(scr->display, scr->drawImStringGC, W_PIXEL(color));
XSetBackground(scr->display, scr->drawImStringGC, W_PIXEL(background));
XSetFont(scr->display, scr->drawImStringGC, font->font.normal->fid);
XDrawImageString(scr->display, d, scr->drawImStringGC,
x, y + font->y, text, length);
} else {
XSetForeground(scr->display, scr->drawImStringGC, W_PIXEL(color));
XSetBackground(scr->display, scr->drawImStringGC, W_PIXEL(background));
XmbDrawImageString(scr->display, d, font->font.set, scr->drawImStringGC,
x, y + font->y, text, length);
}
}
static char*
makeFontSetOfSize(char *fontset, int size)
{
char font[300], *f;
char *newfs = NULL;
char *ptr;
do {
char *tmp;
int end;
f = fontset;
ptr = strchr(fontset, ',');
if (ptr) {
int count = ptr-fontset;
if (count > 255) {
wwarning(_("font description %s is too large."), fontset);
} else {
memcpy(font, fontset, count);
font[count] = 0;
f = (char*)font;
}
}
if (newfs)
end = strlen(newfs);
else
end = 0;
tmp = wmalloc(end + strlen(f) + 8);
if (end != 0) {
sprintf(tmp, "%s,", newfs);
sprintf(tmp + end + 1, f, size);
} else {
sprintf(tmp + end, f, size);
}
if (newfs)
wfree(newfs);
newfs = tmp;
fontset = ptr+1;
} while (ptr!=NULL);
return newfs;
}
#define FONT_PROPS 14
typedef struct {
char *props[FONT_PROPS];
} W_FontAttributes;
static void
changeFontProp(char *buf, char *newprop, int position)
{
char buf2[512];
char *ptr, *pptr, *rptr;
int count;
if (buf[0]!='-') {
/* // remove warning later. or maybe not */
wwarning(_("Invalid font specification: '%s'\n"), buf);
return;
}
ptr = pptr = rptr = buf;
count = 0;
while (*ptr && *ptr!=',') {
if (*ptr == '-') {
count++;
if (count-1==position+1) {
rptr = ptr;
break;
}
if (count-1==position) {
pptr = ptr+1;
}
}
ptr++;
}
if (position==FONT_PROPS-1) {
rptr = ptr;
}
*pptr = 0;
snprintf(buf2, 512, "%s%s%s", buf, newprop, rptr);
strcpy(buf, buf2);
}
static WMArray*
getOptions(char *options)
{
char *ptr, *ptr2, *str;
WMArray *result;
int count;
result = WMCreateArrayWithDestructor(2, (WMFreeDataProc*)wfree);
ptr = options;
while (1) {
ptr2 = strchr(ptr, ',');
if (!ptr2) {
WMAddToArray(result, wstrdup(ptr));
break;
} else {
count = ptr2 - ptr;
str = wmalloc(count+1);
memcpy(str, ptr, count);
str[count] = 0;
WMAddToArray(result, str);
ptr = ptr2 + 1;
}
}
return result;
}
#define WFAUnchanged (NULL)
/* Struct for font change operations */
typedef struct WMFontAttributes {
char *foundry;
char *family;
char *weight;
char *slant;
char *setWidth;
char *addStyle;
char *pixelSize;
char *pointSize;
char *resolutionX;
char *resolutionY;
char *spacing;
char *averageWidth;
char *registry;
char *encoding;
} WMFontAttributes;
WMFont*
WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
const WMFontAttributes *changes)
{
int index[FONT_PROPS], count[FONT_PROPS];
int totalProps, i, j, carry;
char fname[512];
WMFontFlags fFlags;
WMBag *props;
WMArray *options;
WMFont *result;
char *prop;
snprintf(fname, 512, "%s", font->name);
fFlags = (font->antialiased ? WFAntialiased : WFNotAntialiased);
fFlags |= (font->notFontSet ? WFNormalFont : WFFontSet);
props = WMCreateBagWithDestructor(1, (WMFreeDataProc*)WMFreeArray);
totalProps = 0;
for (i=0; i<FONT_PROPS; i++) {
prop = ((W_FontAttributes*)changes)->props[i];
count[i] = index[i] = 0;
if (!prop) {
/* No change for this property */
continue;
} else if (strchr(prop, ',')==NULL) {
/* Simple option */
changeFontProp(fname, prop, i);
} else {
/* Option with fallback alternatives */
if ((changes==WFAEmphasized || changes==WFABoldEmphasized) &&
font->antialiased && strcmp(prop, "o,i")==0) {
options = getOptions("i,o");
} else {
options = getOptions(prop);
}
WMInsertInBag(props, i, options);
count[i] = WMGetArrayItemCount(options);
if (totalProps==0)
totalProps = 1;
totalProps = totalProps * count[i];
}
}
if (totalProps == 0) {
/* No options with fallback alternatives at all */
WMFreeBag(props);
return WMCreateFontWithFlags(scrPtr, fname, fFlags);
}
for (i=0; i<totalProps; i++) {
for (j=0; j<FONT_PROPS; j++) {
if (count[j]!=0) {
options = WMGetFromBag(props, j);
prop = WMGetFromArray(options, index[j]);
if (prop) {
changeFontProp(fname, prop, j);
}
}
}
result = WMCreateFontWithFlags(scrPtr, fname, fFlags);
if (result) {
WMFreeBag(props);
return result;
}
for (j=FONT_PROPS-1, carry=1; j>=0; j--) {
if (count[j]!=0) {
index[j] += carry;
carry = (index[j]==count[j]);
index[j] %= count[j];
}
}
}
WMFreeBag(props);
return NULL;
}
// should WFANormal also set "normal" or leave it alone?
static const WMFontAttributes W_FANormal = {
WFAUnchanged, WFAUnchanged, "medium,normal,regular", "r", "normal",
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
static const WMFontAttributes W_FABold = {
WFAUnchanged, WFAUnchanged, "bold", WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
static const WMFontAttributes W_FANotBold = {
WFAUnchanged, WFAUnchanged, "medium,normal,regular", WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
static const WMFontAttributes W_FAEmphasized = {
WFAUnchanged, WFAUnchanged, WFAUnchanged, "o,i",
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
static const WMFontAttributes W_FANotEmphasized = {
WFAUnchanged, WFAUnchanged, WFAUnchanged, "r",
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
static const WMFontAttributes W_FABoldEmphasized = {
WFAUnchanged, WFAUnchanged, "bold", "o,i",
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged,
WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged, WFAUnchanged
};
const WMFontAttributes *WFANormal = &W_FANormal;
const WMFontAttributes *WFABold = &W_FABold;
const WMFontAttributes *WFANotBold = &W_FANotBold;
const WMFontAttributes *WFAEmphasized = &W_FAEmphasized;
const WMFontAttributes *WFANotEmphasized = &W_FANotEmphasized;
const WMFontAttributes *WFABoldEmphasized = &W_FABoldEmphasized;
#endif

599
WINGs/wfont_wchar.c Normal file
View File

@@ -0,0 +1,599 @@
#include "wconfig.h"
#ifdef XFT
#include <X11/Xft/Xft.h>
#include <fontconfig/fontconfig.h>
#if defined(HAVE_MBSNRTOWCS)
# define __USE_GNU
#endif
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
#include <stdlib.h>
#include "WINGsP.h"
#include <wraster.h>
#include <assert.h>
#include <X11/Xlocale.h>
// && defined(HAVE_MBSTATE_T___COUNT)
// in configure.ac use AC_CHECK_MEMBER(struct mbstate_t.__count,
// have=1, have=0, [#include <wchar.h>])
#if defined(HAVE_MBSNRTOWCS)
static size_t
wmbsnrtowcs(wchar_t *dest, const char **src, size_t nbytes, size_t len)
{
mbstate_t ps;
size_t n;
memset(&ps, 0, sizeof(mbstate_t));
n = mbsnrtowcs(dest, src, nbytes, len, &ps);
if (n!=(size_t)-1 && *src) {
*src -= ps.__count;
}
return n;
}
#elif defined(HAVE_MBRTOWC)
// This is 8 times slower than the version above.
static size_t
wmbsnrtowcs(wchar_t *dest, const char **src, size_t nbytes, size_t len)
{
mbstate_t ps;
const char *ptr;
size_t n;
int nb;
if (nbytes==0)
return 0;
memset(&ps, 0, sizeof(mbstate_t));
if (dest == NULL) {
for (ptr=*src, n=0; nbytes>0; n++) {
nb = mbrtowc(NULL, ptr, nbytes, &ps);
if (nb == -1) {
return ((size_t)-1);
} else if (nb==0 || nb==-2) {
return n;
}
ptr += nb;
nbytes -= nb;
}
}
for (ptr=*src, n=0; n<len && nbytes>0; n++, dest++) {
nb = mbrtowc(dest, ptr, nbytes, &ps);
if (nb == -2) {
*src = ptr;
return n;
} else if (nb == -1) {
*src = ptr;
return ((size_t)-1);
} else if (nb == 0) {
*src = NULL;
return n;
}
ptr += nb;
nbytes -= nb;
}
*src = ptr;
return n;
}
#else
// Not only 8 times slower than the version based on mbsnrtowcs
// but also this version is not thread safe nor reentrant
static size_t
wmbsnrtowcs(wchar_t *dest, const char **src, size_t nbytes, size_t len)
{
const char *ptr;
size_t n;
int nb;
if (nbytes==0)
return 0;
mbtowc(NULL, NULL, 0); /* reset shift state */
if (dest == NULL) {
for (ptr=*src, n=0; nbytes>0; n++) {
nb = mbtowc(NULL, ptr, nbytes);
if (nb == -1) {
mbtowc(NULL, NULL, 0);
nb = mbtowc(NULL, ptr, strlen(ptr));
return (nb == -1 ? (size_t)-1 : n);
} else if (nb==0) {
return n;
}
ptr += nb;
nbytes -= nb;
}
}
for (ptr=*src, n=0; n<len && nbytes>0; n++, dest++) {
nb = mbtowc(dest, ptr, nbytes);
if (nb == -1) {
mbtowc(NULL, NULL, 0);
nb = mbtowc(NULL, ptr, strlen(ptr));
*src = ptr;
return (nb == -1 ? (size_t)-1 : n);
} else if (nb == 0) {
*src = NULL;
return n;
}
ptr += nb;
nbytes -= nb;
}
*src = ptr;
return n;
}
#endif
#define DEFAULT_SIZE 12
static char*
fixXLFD(char *xlfd, int size)
{
char *fname, *ptr;
fname = wmalloc(strlen(xlfd) + 20);
if (strstr(xlfd, "%d")!=NULL)
sprintf(fname, xlfd, size ? size : DEFAULT_SIZE);
else
strcpy(fname, xlfd);
if ((ptr = strchr(fname, ','))) {
*ptr = 0;
}
return fname;
}
static Bool
hasProperty(FcPattern *pattern, const char *property)
{
FcValue val;
if (FcPatternGet(pattern, property, 0, &val)==FcResultMatch) {
return True;
}
return False;
}
static Bool
hasPropertyWithStringValue(FcPattern *pattern, const char *object, char *value)
{
FcChar8 *str;
int id;
if (!value || value[0]==0)
return True;
id = 0;
while (FcPatternGetString(pattern, object, id, &str)==FcResultMatch) {
if (strcasecmp(value, (char*)str) == 0) {
return True;
}
id++;
}
return False;
}
// also handle an xlfd with %d for size?
static char*
makeFontOfSize(char *font, int size, char *fallback)
{
FcPattern *pattern;
char *result;
if (font[0]=='-') {
char *fname;
fname = fixXLFD(font, size);
pattern = XftXlfdParse(fname, False, False);
wfree(fname);
} else {
pattern = FcNameParse(font);
}
//FcPatternPrint(pattern);
if (size > 0) {
FcPatternDel(pattern, "pixelsize");
FcPatternAddDouble(pattern, "pixelsize", (double)size);
} else if (size==0 && !hasProperty(pattern, "size") &&
!hasProperty(pattern, "pixelsize")) {
FcPatternAddDouble(pattern, "pixelsize", (double)DEFAULT_SIZE);
}
if (fallback && !hasPropertyWithStringValue(pattern, "family", fallback)) {
FcPatternAddString(pattern, "family", fallback);
}
result = FcNameUnparse(pattern);
FcPatternDestroy(pattern);
return result;
}
WMFont*
WMCreateFont(WMScreen *scrPtr, char *fontName)
{
WMFont *font;
Display *display = scrPtr->display;
char *fname, *ptr;
/* This is for back-compat (to allow reading of old xlfd descriptions) */
if (fontName[0]=='-' && (ptr = strchr(fontName, ','))) {
// warn for deprecation
fname = wmalloc(ptr - fontName + 1);
strncpy(fname, fontName, ptr - fontName);
fname[ptr - fontName] = 0;
} else {
fname = wstrdup(fontName);
}
font = WMHashGet(scrPtr->fontCache, fname);
if (font) {
WMRetainFont(font);
wfree(fname);
return font;
}
font = wmalloc(sizeof(WMFont));
memset(font, 0, sizeof(WMFont));
font->screen = scrPtr;
// remove
printf("WMCreateFont: %s\n", fname);
if (fname[0] == '-') {
// Backward compat thing. Remove in a later version
font->font = XftFontOpenXlfd(display, scrPtr->screen, fname);
} else {
font->font = XftFontOpenName(display, scrPtr->screen, fname);
}
if (!font->font) {
wfree(font);
wfree(fname);
return NULL;
}
font->height = font->font->ascent+font->font->descent;
font->y = font->font->ascent;
font->refCount = 1;
font->name = fname;
assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL);
return font;
}
WMFont*
WMRetainFont(WMFont *font)
{
wassertrv(font!=NULL, NULL);
font->refCount++;
return font;
}
void
WMReleaseFont(WMFont *font)
{
wassertr(font!=NULL);
font->refCount--;
if (font->refCount < 1) {
XftFontClose(font->screen->display, font->font);
if (font->name) {
WMHashRemove(font->screen->fontCache, font->name);
wfree(font->name);
}
wfree(font);
}
}
Bool
WMIsAntialiasingEnabled(WMScreen *scrPtr)
{
return scrPtr->antialiasedText;
}
unsigned int
WMFontHeight(WMFont *font)
{
wassertrv(font!=NULL, 0);
return font->height;
}
char*
WMGetFontName(WMFont *font)
{
wassertrv(font!=NULL, NULL);
return font->name;
}
WMFont*
WMDefaultSystemFont(WMScreen *scrPtr)
{
return WMRetainFont(scrPtr->normalFont);
}
WMFont*
WMDefaultBoldSystemFont(WMScreen *scrPtr)
{
return WMRetainFont(scrPtr->boldFont);
}
WMFont*
WMSystemFontOfSize(WMScreen *scrPtr, int size)
{
WMFont *font;
char *fontSpec;
fontSpec = makeFontOfSize(WINGsConfiguration.systemFont, size, "sans");
font = WMCreateFont(scrPtr, fontSpec);
if (!font) {
wwarning(_("could not load font %s."), fontSpec);
}
wfree(fontSpec);
return font;
}
WMFont*
WMBoldSystemFontOfSize(WMScreen *scrPtr, int size)
{
WMFont *font;
char *fontSpec;
fontSpec = makeFontOfSize(WINGsConfiguration.boldSystemFont, size, "sans");
font = WMCreateFont(scrPtr, fontSpec);
if (!font) {
wwarning(_("could not load font %s."), fontSpec);
}
wfree(fontSpec);
return font;
}
int
WMWidthOfString(WMFont *font, char *text, int length)
{
XGlyphInfo extents;
wassertrv(font!=NULL, 0);
wassertrv(text!=NULL, 0);
if (font->screen->useWideChar) {
wchar_t *wtext;
const char *mtext;
int len;
wtext = (wchar_t *)wmalloc(sizeof(wchar_t)*(length+1));
mtext = text;
len = wmbsnrtowcs(wtext, &mtext, length, length);
if (len>0) {
wtext[len] = L'\0'; /* not really necessary here */
XftTextExtents32(font->screen->display, font->font,
(XftChar32 *)wtext, len, &extents);
} else {
if (len==-1) {
wwarning(_("Conversion to widechar failed (possible "
"invalid multibyte sequence): '%s':(pos %d)\n"),
text, mtext-text+1);
}
extents.xOff = 0;
}
wfree(wtext);
} else if (font->screen->useMultiByte) {
XftTextExtentsUtf8(font->screen->display, font->font,
(XftChar8 *)text, length, &extents);
} else {
XftTextExtents8(font->screen->display, font->font,
(XftChar8 *)text, length, &extents);
}
return extents.xOff; /* don't ask :P */
}
void
WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
int x, int y, char *text, int length)
{
XftColor xftcolor;
wassertr(font!=NULL);
xftcolor.color.red = color->color.red;
xftcolor.color.green = color->color.green;
xftcolor.color.blue = color->color.blue;
xftcolor.color.alpha = color->alpha;;
xftcolor.pixel = W_PIXEL(color);
XftDrawChange(scr->xftdraw, d);
if (font->screen->useWideChar) {
wchar_t *wtext;
const char *mtext;
int len;
wtext = (wchar_t *)wmalloc(sizeof(wchar_t)*(length+1));
mtext = text;
len = wmbsnrtowcs(wtext, &mtext, length, length);
if (len>0) {
XftDrawString32(scr->xftdraw, &xftcolor, font->font,
x, y + font->y, (XftChar32*)wtext, len);
} else if (len==-1) {
wwarning(_("Conversion to widechar failed (possible invalid "
"multibyte sequence): '%s':(pos %d)\n"),
text, mtext-text+1);
/* we can draw normal text, or we can draw as much widechar
* text as was already converted until the error. go figure */
/*XftDrawString8(scr->xftdraw, &xftcolor, font->font,
x, y + font->y, (XftChar8*)text, length);*/
}
wfree(wtext);
} else if (font->screen->useMultiByte) {
XftDrawStringUtf8(scr->xftdraw, &xftcolor, font->font,
x, y + font->y, (XftChar8*)text, length);
} else {
XftDrawString8(scr->xftdraw, &xftcolor, font->font,
x, y + font->y, (XftChar8*)text, length);
}
}
void
WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background,
WMFont *font, int x, int y, char *text, int length)
{
XftColor textColor;
XftColor bgColor;
wassertr(font!=NULL);
textColor.color.red = color->color.red;
textColor.color.green = color->color.green;
textColor.color.blue = color->color.blue;
textColor.color.alpha = color->alpha;;
textColor.pixel = W_PIXEL(color);
bgColor.color.red = background->color.red;
bgColor.color.green = background->color.green;
bgColor.color.blue = background->color.blue;
bgColor.color.alpha = background->alpha;;
bgColor.pixel = W_PIXEL(background);
XftDrawChange(scr->xftdraw, d);
XftDrawRect(scr->xftdraw, &bgColor, x, y,
WMWidthOfString(font, text, length),
font->height);
if (font->screen->useWideChar) {
wchar_t *wtext;
const char *mtext;
int len;
mtext = text;
wtext = (wchar_t *)wmalloc(sizeof(wchar_t)*(length+1));
len = wmbsnrtowcs(wtext, &mtext, length, length);
if (len>0) {
XftDrawString32(scr->xftdraw, &textColor, font->font,
x, y + font->y, (XftChar32*)wtext, len);
} else if (len==-1) {
wwarning(_("Conversion to widechar failed (possible invalid "
"multibyte sequence): '%s':(pos %d)\n"),
text, mtext-text+1);
/* we can draw normal text, or we can draw as much widechar
* text as was already converted until the error. go figure */
/*XftDrawString8(scr->xftdraw, &textColor, font->font,
x, y + font->y, (XftChar8*)text, length);*/
}
wfree(wtext);
} else if (font->screen->useMultiByte) {
XftDrawStringUtf8(scr->xftdraw, &textColor, font->font,
x, y + font->y, (XftChar8*)text, length);
} else {
XftDrawString8(scr->xftdraw, &textColor, font->font,
x, y + font->y, (XftChar8*)text, length);
}
}
WMFont*
WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style)
{
FcPattern *pattern;
WMFont *copy;
char *name;
if (!font)
return NULL;
pattern = FcNameParse(WMGetFontName(font));
switch (style) {
case WFSNormal:
FcPatternDel(pattern, "weight");
FcPatternDel(pattern, "slant");
FcPatternAddString(pattern, "weight", "regular");
FcPatternAddString(pattern, "weight", "medium");
FcPatternAddString(pattern, "slant", "roman");
break;
case WFSBold:
FcPatternDel(pattern, "weight");
FcPatternAddString(pattern, "weight", "bold");
break;
case WFSEmphasized:
FcPatternDel(pattern, "slant");
FcPatternAddString(pattern, "slant", "italic");
FcPatternAddString(pattern, "slant", "oblique");
break;
case WFSBoldEmphasized:
FcPatternDel(pattern, "weight");
FcPatternDel(pattern, "slant");
FcPatternAddString(pattern, "weight", "bold");
FcPatternAddString(pattern, "slant", "italic");
FcPatternAddString(pattern, "slant", "oblique");
break;
}
name = FcNameUnparse(pattern);
copy = WMCreateFont(scrPtr, name);
FcPatternDestroy(pattern);
wfree(name);
return copy;
}
#endif /* XFT */

File diff suppressed because it is too large Load Diff

View File

@@ -149,6 +149,7 @@ paintFrame(Frame *fPtr)
drawTitle = True;
} else {
tw = tx = 0;
drawTitle = False;
}
@@ -160,6 +161,11 @@ paintFrame(Frame *fPtr)
region = XCreateRegion();
rect.x = 0;
rect.y = 0;
rect.width = view->size.width;
rect.height = view->size.height;
XUnionRectWithRegion(&rect, region, region);
if (drawTitle) {
tmp = XCreateRegion();
rect.x = tx;
@@ -167,13 +173,6 @@ paintFrame(Frame *fPtr)
rect.width = tw;
rect.height = th;
XUnionRectWithRegion(&rect, tmp, tmp);
}
rect.x = 0;
rect.y = 0;
rect.width = view->size.width;
rect.height = view->size.height;
XUnionRectWithRegion(&rect, region, region);
if (drawTitle) {
XSubtractRegion(region, tmp, region);
XDestroyRegion(tmp);
}

View File

@@ -12,6 +12,8 @@
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <X11/Xlocale.h>
/********** data ************/
@@ -591,6 +593,7 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
"WM_STATE"
};
Atom atoms[sizeof(atomNames)/sizeof(char*)];
char *locale;
int i;
if (!initialized) {
@@ -756,16 +759,20 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->stipple = stipple;
scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
scrPtr->useMultiByte = 0;
scrPtr->useWideChar = 1;
locale = setlocale(LC_CTYPE, NULL);
//printf("LC_CTYPE=%s\n", locale);
if (!locale || strcmp(locale, "C")==0 || strcmp(locale, "POSIX")==0)
scrPtr->useWideChar = 0;
else
scrPtr->useWideChar = 1;
scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;
scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
WINGsConfiguration.defaultFontSize);
scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0);
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr,
WINGsConfiguration.defaultFontSize);
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0);
if (!scrPtr->boldFont)
scrPtr->boldFont = scrPtr->normalFont;

View File

@@ -22,7 +22,8 @@ typedef struct W_ICContext {
Bool W_InitIMStuff(WMScreen *scr)
Bool
W_InitIMStuff(WMScreen *scr)
{
WMIMContext *ctx;
@@ -38,7 +39,8 @@ Bool W_InitIMStuff(WMScreen *scr)
}
void W_CloseIMStuff(WMScreen *scr)
void
W_CloseIMStuff(WMScreen *scr)
{
if (!scr->imctx)
return;
@@ -51,7 +53,8 @@ void W_CloseIMStuff(WMScreen *scr)
WMICContext *W_CreateIC(WMView *view)
WMICContext*
W_CreateIC(WMView *view)
{
WMScreen *scr = W_VIEW_SCREEN(view);
WMICContext *ctx;
@@ -60,11 +63,12 @@ WMICContext *W_CreateIC(WMView *view)
ctx->next = scr->imctx->icList;
if (scr->imctx->icList)
scr->imctx->icList->prev = ctx;
scr->imctx = ctx;
//scr->imctx = ctx;
}
void W_DestroyIC(WMICContext *ctx)
void
W_DestroyIC(WMICContext *ctx)
{
XDestroyIC(ctx->xic);
@@ -72,8 +76,9 @@ void W_DestroyIC(WMICContext *ctx)
}
int W_LookupString(WMView *view, XKeyEvent *event,
char buffer, int bufsize, KeySym ksym)
int
W_LookupString(WMView *view, XKeyEvent *event,
char buffer, int bufsize, KeySym ksym)
{
}

View File

@@ -30,26 +30,26 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
case WRSimple:
XDrawRectangle(dpy, d, black, x, y, width-1, height-1);
return;
case WRRaised:
bgc = black;
dgc = dark;
wgc = white;
lgc = light;
break;
case WRSunken:
wgc = dark;
lgc = black;
bgc = white;
dgc = light;
break;
case WRPushed:
lgc = wgc = black;
dgc = bgc = white;
break;
case WRRidge:
lgc = bgc = dark;
dgc = wgc = white;
@@ -59,7 +59,7 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
wgc = dgc = dark;
lgc = bgc = white;
break;
default:
return;
}
@@ -68,12 +68,12 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
if (width > 2 && relief != WRRaised && relief!=WRPushed) {
XDrawLine(dpy, d, lgc, x+1, y+1, x+width-3, y+1);
}
XDrawLine(dpy, d, wgc, x, y, x, y+height-1);
if (height > 2 && relief != WRRaised && relief!=WRPushed) {
XDrawLine(dpy, d, lgc, x+1, y+1, x+1, y+height-3);
}
/* bottom right */
XDrawLine(dpy, d, bgc, x, y+height-1, x+width-1, y+height-1);
if (width > 2 && relief!=WRPushed) {
@@ -87,22 +87,82 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
}
static int
findNextWord(char *text, int limit)
{
int pos, len;
len = strcspn(text, " \t\n\r");
pos = len + strspn(text+len, " \t\n\r");
if (pos > limit)
pos = limit;
return pos;
}
static int
fitText(char *text, WMFont *font, int width, int wrap)
{
int i, w, beforecrlf, word1, word2;
/* text length before first cr/lf */
beforecrlf = strcspn(text, "\n\r");
if (!wrap || beforecrlf==0)
return beforecrlf;
w = WMWidthOfString(font, text, beforecrlf);
if (w <= width) {
/* text up to first crlf fits */
return beforecrlf;
}
word1 = 0;
while (1) {
word2 = word1 + findNextWord(text+word1, beforecrlf-word1);
if (word2 >= beforecrlf)
break;
w = WMWidthOfString(font, text, word2);
if (w > width)
break;
word1 = word2;
}
for (i=word1; i<word2; i++) {
w = WMWidthOfString(font, text, i);
if (w > width) {
break;
}
}
/* keep words complete if possible */
if (!isspace(text[i]) && word1>0) {
i = word1;
} else if (isspace(text[i]) && i<beforecrlf) {
/* keep space on current row, so new row has next word in column 1 */
i++;
}
return i;
}
#ifdef OLD_CODE
static int
fitText(char *text, WMFont *font, int width, int wrap)
{
int i, j;
int w;
if (text[0]==0)
return 0;
i = 0;
if (wrap) {
if (text[0]=='\n')
return 0;
do {
i++;
w = WMWidthOfString(font, text, i);
@@ -110,7 +170,7 @@ fitText(char *text, WMFont *font, int width, int wrap)
if (text[i]=='\n')
return i;
/* keep words complete */
if (!isspace(text[i])) {
j = i;
@@ -120,11 +180,11 @@ fitText(char *text, WMFont *font, int width, int wrap)
i = j;
}
} else {
while (text[i]!='\n' && text[i]!=0)
i++;
i = strcspn(text, "\n\r");
}
return i;
}
#endif
int
@@ -203,7 +263,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
#ifdef DOUBLE_BUFFER
d = XCreatePixmap(screen->display, view->window,
d = XCreatePixmap(screen->display, view->window,
view->size.width, view->size.height, screen->depth);
#endif
@@ -215,7 +275,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
#ifndef DOUBLE_BUFFER
XClearWindow(screen->display, d);
#else
XSetForeground(screen->display, screen->copyGC,
XSetForeground(screen->display, screen->copyGC,
view->attribs.background_pixel);
XFillRectangle(screen->display, d, screen->copyGC, 0, 0,
view->size.width, view->size.height);
@@ -232,7 +292,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
x = 1;
y = 1;
w = view->size.width - 3;
h = view->size.height - 3;
h = view->size.height - 3;
}
/* calc. image alignment */
@@ -247,7 +307,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
y = 0;
*/
break;
case WIPLeft:
ix = x;
iy = y + (h - image->height) / 2;
@@ -255,20 +315,20 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
y = 0;
w -= image->width + 5;
break;
case WIPRight:
ix = view->size.width - image->width - x;
iy = y + (h - image->height) / 2;
w -= image->width + 5;
break;
case WIPBelow:
ix = (view->size.width - image->width) / 2;
iy = h - image->height;
y = 0;
h -= image->height;
break;
default:
case WIPAbove:
ix = (view->size.width - image->width) / 2;
@@ -277,7 +337,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
h -= image->height;
break;
}
ix += ofs;
iy += ofs;
@@ -295,7 +355,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
/* draw text */
if (position != WIPImageOnly && text!=NULL) {
int textHeight;
textHeight = W_GetTextHeight(font, text, w-8, wrap);
W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8,
alignment, textColor, wrap, text, strlen(text));
@@ -314,26 +374,26 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
WMPoint
WMPoint
wmkpoint(int x, int y)
{
WMPoint point;
point.x = x;
point.y = y;
return point;
}
WMSize
WMSize
wmksize(unsigned int width, unsigned int height)
{
WMSize size;
size.width = width;
size.height = height;
return size;
}

View File

@@ -306,10 +306,9 @@ paintArrow(WMScroller *sPtr, Drawable d, int part)
gc = scr->whiteGC;
#endif
}
if (sPtr->flags.horizontal) {
/* paint button */
#ifndef DOUBLE_BUFFER
XFillRectangle(scr->display, d, gc,
@@ -326,7 +325,7 @@ paintArrow(WMScroller *sPtr, Drawable d, int part)
XSetClipOrigin(scr->display, scr->clipGC,
ofs + (BUTTON_SIZE - arrow->width) / 2,
2 + (BUTTON_SIZE - arrow->height) / 2);
XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC,
0, 0, arrow->width, arrow->height,
ofs + (BUTTON_SIZE - arrow->width) / 2,

View File

@@ -2026,7 +2026,7 @@ insertTextInteractively(Text *tPtr, char *text, int len)
int s = tb->used - tPtr->tpos;
if (!tb->blank && nlen>0) {
char *save;
char *save=NULL;
if (s > 0) {
save = wmalloc(s);