summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@herrb.eu>2016-09-04 19:55:37 +0100
committerMatthieu Herrb <matthieu@herrb.eu>2016-09-04 19:55:37 +0100
commitdf25a1c5a2f433198915a4350eb3223665d53b21 (patch)
tree9cc111912b00c4f65d9f6294016fcb3b433eda46
parent93199a5240a48f6eb79cb91bd89a7bbc289f2b56 (diff)
Unifdef XFT
-rw-r--r--configure.ac16
-rw-r--r--greeter/Login.c123
-rw-r--r--greeter/LoginP.h23
3 files changed, 6 insertions, 156 deletions
diff --git a/configure.ac b/configure.ac
index b7b6ecd..8eac455 100644
--- a/configure.ac
+++ b/configure.ac
@@ -220,19 +220,9 @@ PKG_CHECK_EXISTS(xinerama, [
])
# Xft text drawing for the greeter screen
-AC_ARG_WITH(xft,
- AS_HELP_STRING([--with-xft],
- [Use Xft to draw text (default is YES if installed)]),
- [USE_XFT="$withval"],
- PKG_CHECK_EXISTS(xft xrender, [USE_XFT="yes"], [USE_XFT="no"]))
-
-if test "x$USE_XFT" = "xyes" ; then
- PKG_CHECK_MODULES(XFT, xft xrender)
- GREETER_CFLAGS="$GREETER_CFLAGS $XFT_CFLAGS"
- GREETER_LIBS="$GREETER_LIBS $XFT_LIBS"
- AC_DEFINE([USE_XFT], 1,
- [Define to 1 to use Xft for text on greeter screen])
-fi
+PKG_CHECK_MODULES(XFT, xft xrender)
+GREETER_CFLAGS="$GREETER_CFLAGS $XFT_CFLAGS"
+GREETER_LIBS="$GREETER_LIBS $XFT_LIBS"
# XPM logos for the greeter screen
PKG_CHECK_MODULES(XPM, xpm)
diff --git a/greeter/Login.c b/greeter/Login.c
index f1aa4e7..468c0e3 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -84,9 +84,7 @@ from The Open Group.
# include <X11/extensions/Xinerama.h>
#endif
-#ifdef USE_XFT
-# include <X11/extensions/Xrender.h>
-#endif
+#include <X11/extensions/Xrender.h>
#ifndef DEBUG
# define XDM_ASSERT(a) /* do nothing */
@@ -120,16 +118,6 @@ static XtResource resources[] = {
goffset(x), XtRImmediate, (XtPointer) -1},
{XtNy, XtCY, XtRPosition, sizeof (Position),
goffset(y), XtRImmediate, (XtPointer) -1},
-#ifndef USE_XFT
- {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(textpixel), XtRString, XtDefaultForeground},
- {XtNpromptColor, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(promptpixel), XtRString, XtDefaultForeground},
- {XtNgreetColor, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(greetpixel), XtRString, XtDefaultForeground},
- {XtNfailColor, XtCForeground, XtRPixel, sizeof (Pixel),
- offset(failpixel), XtRString, XtDefaultForeground},
-#endif
#ifdef DANCING
/* added by Caolan McNamara */
@@ -162,16 +150,6 @@ static XtResource resources[] = {
offset(sepwidth), XtRImmediate, (XtPointer) 1},
/* end (amit) */
-#ifndef USE_XFT
- {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
- offset (textFont), XtRString, "*-new century schoolbook-medium-r-normal-*-180-*"},
- {XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
- offset (promptFont), XtRString, "*-new century schoolbook-bold-r-normal-*-180-*"},
- {XtNgreetFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
- offset (greetFont), XtRString, "*-new century schoolbook-bold-i-normal-*-240-*"},
- {XtNfailFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
- offset (failFont), XtRString, "*-new century schoolbook-bold-r-normal-*-180-*"},
-#else /* USE_XFT */
{XtNface, XtCFace, XtRXftFont, sizeof (XftFont *),
offset (textFace), XtRString, "Serif-18"},
{XtNpromptFace, XtCFace, XtRXftFont, sizeof (XftFont *),
@@ -188,7 +166,7 @@ static XtResource resources[] = {
offset(greetcolor), XtRString, XtDefaultForeground},
{XtNfailColor, XtCForeground, XtRXftColor, sizeof (XftColor),
offset(failcolor), XtRString, XtDefaultForeground},
-#endif
+
{XtNgreeting, XtCGreeting, XtRString, sizeof (char *),
offset(greeting), XtRString, "X Window System"},
{XtNunsecureGreeting, XtCGreeting, XtRString, sizeof (char *),
@@ -227,15 +205,9 @@ static XtResource resources[] = {
#undef offset
#undef goffset
-#ifdef USE_XFT
# define F_MAX_WIDTH(f) ((w)->login.f##Face->max_advance_width)
# define F_ASCENT(f) ((w)->login.f##Face->ascent)
# define F_DESCENT(f) ((w)->login.f##Face->descent)
-#else
-# define F_MAX_WIDTH(f) ((w)->login.f##Font->max_bounds.width)
-# define F_ASCENT(f) ((w)->login.f##Font->max_bounds.ascent)
-# define F_DESCENT(f) ((w)->login.f##Font->max_bounds.descent)
-#endif
#define TEXT_X_INC(w) F_MAX_WIDTH(text)
#define TEXT_Y_INC(w) (F_ASCENT(text) + F_DESCENT(text))
@@ -266,8 +238,6 @@ static XtResource resources[] = {
#define CUR_PROMPT_TEXT(w, n) (PROMPT_TEXT(w,n) != NULL ? \
PROMPT_TEXT(w,n) : DEF_PROMPT_TEXT(w,n))
-#ifdef USE_XFT
-
# define TEXT_COLOR(f) (w->login.f##color.pixel)
# define TEXT_WIDTH(f, m, l) XmuXftTextWidth(XtDisplay (w), \
@@ -280,18 +250,6 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len);
XftDrawString8 (w->login.draw, &w->login.f##color, w->login.f##Face, \
x, y, (FcChar8 *) m, l)
-#else
-
-# define TEXT_COLOR(f) (w->login.f##pixel)
-
-# define TEXT_WIDTH(f, m, l) (XTextWidth (w->login.f##Font, m, l))
-
-# define DRAW_STRING(f, x, y, m, l) \
- XDrawString (XtDisplay (w), XtWindow (w), w->login.f##GC, x, y, m, l)
-
-#endif
-
-
#define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s))
/* Padded width of logo image, if compiled with XPM support */
@@ -522,17 +480,8 @@ realizeCursor (LoginWidget w, GC gc)
static void
EraseFail (LoginWidget w)
{
-#ifdef USE_XFT
w->login.failUp = 0;
RedrawFail(w);
-#else
- XSetForeground (XtDisplay (w), w->login.failGC,
- w->core.background_pixel);
- RedrawFail(w);
- w->login.failUp = 0;
- XSetForeground (XtDisplay (w), w->login.failGC,
- TEXT_COLOR(fail));
-#endif
}
static void
@@ -584,9 +533,6 @@ RedrawFail (LoginWidget w)
int y = FAIL_Y(w);
int maxw = w->core.width - PAD_X(w);
-#ifndef USE_XFT
- if (w->login.failUp)
-#endif
{
Debug("RedrawFail('%s', %d)\n", w->login.fail, w->login.failUp);
if (ERROR_W(w, w->login.fail) > maxw) {
@@ -619,12 +565,10 @@ RedrawFail (LoginWidget w)
} while ((next != NULL) && ERROR_W(w, start) < maxw);
x = ERROR_X(w, start);
-#ifdef USE_XFT
if (w->login.failUp == 0) {
XClearArea(XtDisplay(w), XtWindow(w), x, y - F_ASCENT(fail),
ERROR_W(w, start), FAIL_Y_INC(w), False);
} else
-#endif
DRAW_STRING (fail, x, y, start, strlen(start));
if (next != NULL) {
@@ -640,12 +584,10 @@ RedrawFail (LoginWidget w)
LogOutOfMem("RedrawFail");
}
-#ifdef USE_XFT
if (w->login.failUp == 0) {
XClearArea(XtDisplay(w), XtWindow(w), x, y - F_ASCENT(fail),
ERROR_W(w, w->login.fail), FAIL_Y_INC(w), False);
} else
-#endif
DRAW_STRING (fail, x, y, w->login.fail, strlen (w->login.fail));
}
}
@@ -1449,7 +1391,6 @@ InsertChar (
/**** Copied from xclock.c - original author: Keith Packard ****/
-#ifdef USE_XFT
static XtConvertArgRec xftColorConvertArgs[] = {
{XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
sizeof(Screen *)},
@@ -1630,12 +1571,9 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len)
return extents.xOff;
}
-#endif /* USE_XFT */
-
static void
ClassInitialize(void)
{
-#ifdef USE_XFT
XtSetTypeConverter (XtRString, XtRXftColor,
XmuCvtStringToXftColor,
xftColorConvertArgs, XtNumber(xftColorConvertArgs),
@@ -1644,7 +1582,6 @@ ClassInitialize(void)
XmuCvtStringToXftFont,
xftFontConvertArgs, XtNumber(xftFontConvertArgs),
XtCacheByDisplay, XmuFreeXftFont);
-#endif /* USE_XFT */
}
/**** End of portion borrowed from xclock ****/
@@ -1684,12 +1621,6 @@ static void Initialize (
myXGCV.foreground = TEXT_COLOR(text);
myXGCV.background = w->core.background_pixel;
valuemask = GCForeground | GCBackground;
-#ifndef USE_XFT
- if (w->login.textFont) {
- myXGCV.font = w->login.textFont->fid;
- valuemask |= GCFont;
- }
-#endif
w->login.textGC = XtGetGC(gnew, valuemask, &myXGCV);
myXGCV.foreground = w->login.inppixel;
w->login.bgGC = XtGetGC(gnew, valuemask, &myXGCV);
@@ -1699,46 +1630,6 @@ static void Initialize (
xvaluemask = valuemask | GCFunction;
w->login.xorGC = XtGetGC (gnew, xvaluemask, &myXGCV);
-#ifndef USE_XFT
- /*
- * Note that the second argument is a GCid -- QueryFont accepts a GCid and
- * returns the curently contained font.
- */
-
- if (w->login.textFont == NULL)
- w->login.textFont = XQueryFont (XtDisplay (w),
- XGContextFromGC (XDefaultGCOfScreen (XtScreen (w))));
-
- xvaluemask = valuemask;
- if (w->login.promptFont == NULL)
- w->login.promptFont = w->login.textFont;
- else
- xvaluemask |= GCFont;
-
- myXGCV.foreground = TEXT_COLOR(prompt);
- myXGCV.font = w->login.promptFont->fid;
- w->login.promptGC = XtGetGC (gnew, xvaluemask, &myXGCV);
-
- xvaluemask = valuemask;
- if (w->login.greetFont == NULL)
- w->login.greetFont = w->login.textFont;
- else
- xvaluemask |= GCFont;
-
- myXGCV.foreground = TEXT_COLOR(greet);
- myXGCV.font = w->login.greetFont->fid;
- w->login.greetGC = XtGetGC (gnew, xvaluemask, &myXGCV);
-
- xvaluemask = valuemask;
- if (w->login.failFont == NULL)
- w->login.failFont = w->login.textFont;
- else
- xvaluemask |= GCFont;
- myXGCV.foreground = TEXT_COLOR(fail);
- myXGCV.font = w->login.failFont->fid;
- w->login.failGC = XtGetGC (gnew, xvaluemask, &myXGCV);
-#endif /* USE_XFT */
-
w->login.logoValid = False;
if (NULL != w->login.logoFileName)
@@ -1867,13 +1758,10 @@ static void Realize (
*valueMask, attrs );
InitI18N(gw);
-#ifdef USE_XFT
w->login.draw = XftDrawCreate (XtDisplay (w), XtWindow(w),
DefaultVisual (XtDisplay (w), DefaultScreen(XtDisplay (w))),
w->core.colormap);
-#endif
-
cursor = XCreateFontCursor(XtDisplay(gw), XC_left_ptr);
XDefineCursor(XtDisplay(gw), DefaultRootWindow(XtDisplay(gw)), cursor);
@@ -1933,21 +1821,14 @@ static void Destroy (Widget gw)
if (PROMPT_TEXT(w,1) != NULL)
XtFree(PROMPT_TEXT(w,1));
-#ifdef USE_XFT
if (w->login.draw) {
XftDrawDestroy(w->login.draw);
w->login.draw = NULL;
}
-#endif
XtReleaseGC(gw, w->login.textGC);
XtReleaseGC(gw, w->login.bgGC);
XtReleaseGC(gw, w->login.xorGC);
-#ifndef USE_XFT
- XtReleaseGC(gw, w->login.promptGC);
- XtReleaseGC(gw, w->login.greetGC);
- XtReleaseGC(gw, w->login.failGC);
-#endif
XtReleaseGC(gw, w->login.hiGC);
XtReleaseGC(gw, w->login.shdGC);
XtReleaseGC(gw, w->login.inpGC);
diff --git a/greeter/LoginP.h b/greeter/LoginP.h
index ccd0edf..abe0d8c 100644
--- a/greeter/LoginP.h
+++ b/greeter/LoginP.h
@@ -60,9 +60,7 @@ from The Open Group.
# include <X11/IntrinsicP.h>
# include <X11/CoreP.h>
# include <X11/Xlib.h>
-# ifdef USE_XFT
-# include <X11/Xft/Xft.h>
-# endif
+# include <X11/Xft/Xft.h>
# define INITIALIZING 0
# define PROMPTING 1
@@ -87,23 +85,12 @@ typedef struct {
/* New fields for the login widget instance record */
typedef struct {
-# ifndef USE_XFT
- Pixel textpixel; /* foreground pixel */
- Pixel promptpixel; /* prompt pixel */
- Pixel greetpixel; /* greeting pixel */
- Pixel failpixel; /* failure pixel */
-# endif
Pixel hipixel; /* frame hilite pixel */
Pixel shdpixel; /* shadow frame pixel */
Pixel inppixel; /* input field bg pixel */
GC textGC; /* pointer to GraphicsContext */
GC bgGC; /* pointer to GraphicsContext */
GC xorGC; /* pointer to GraphicsContext */
-# ifndef USE_XFT
- GC promptGC;
- GC greetGC;
- GC failGC;
-# endif
GC hiGC; /* for hilight part of frame */
GC shdGC; /* for shaded part of frame */
GC inpGC; /* for input field of frame */
@@ -114,12 +101,6 @@ typedef struct {
char *failMsg; /* failure message */
char *fail; /* current error message */
char *passwdChangeMsg; /* message when passwd expires */
-# ifndef USE_XFT
- XFontStruct *textFont; /* font for text */
- XFontStruct *promptFont; /* font for prompts */
- XFontStruct *greetFont; /* font for greeting */
- XFontStruct *failFont; /* font for failure message */
-# endif /* USE_XFT */
int state; /* state */
int activePrompt; /* which prompt is active */
int failUp; /* failure message displayed */
@@ -156,7 +137,6 @@ typedef struct {
Window logoWindow;
Boolean useShape, logoValid;
Pixmap logoPixmap, logoMask;
-# ifdef USE_XFT
XftDraw *draw;
XftFont *textFace; /* font for text */
XftFont *promptFace; /* font for prompts */
@@ -166,7 +146,6 @@ typedef struct {
XftColor promptcolor; /* prompt color */
XftColor greetcolor; /* greeting color */
XftColor failcolor; /* failure color */
-# endif
} LoginPart;
/* Full instance record declaration */