From 05b7c570b155f167e5a7f1b804e10b870bbc762c Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Fri, 14 Nov 2003 16:49:23 +0000 Subject: XFree86 4.3.0.1 --- Logo.c | 262 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------- Logo.h | 9 +++ LogoP.h | 17 +++- xlogo.c | 53 +++++++------ xlogo.man | 17 +++- 5 files changed, 292 insertions(+), 66 deletions(-) diff --git a/Logo.c b/Logo.c index 757c7ef..f4e738a 100644 --- a/Logo.c +++ b/Logo.c @@ -26,30 +26,59 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xlogo/Logo.c,v 1.6 2002/05/23 23:53:59 keithp Exp $ */ #include #include +#include #include "LogoP.h" #include +#ifdef XRENDER +#include "RenderLogo.h" +#endif + static XtResource resources[] = { - {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), - XtOffsetOf(LogoRec,logo.fgpixel), XtRString, - (XtPointer) XtDefaultForeground}, {XtNshapeWindow, XtCShapeWindow, XtRBoolean, sizeof (Boolean), XtOffsetOf(LogoRec,logo.shape_window), XtRImmediate, (XtPointer) FALSE}, +#ifdef XRENDER + {XtNrender, XtCBoolean, XtRBoolean, sizeof(Boolean), + XtOffsetOf(LogoRec,logo.render), XtRImmediate, + (XtPointer) FALSE }, + {XtNsharp, XtCBoolean, XtRBoolean, sizeof(Boolean), + XtOffsetOf(LogoRec,logo.sharp), XtRImmediate, + (XtPointer) FALSE }, + {XtNforeground, XtCForeground, XtRXftColor, sizeof(XftColor), + XtOffsetOf(LogoRec, logo.fg), XtRString, + (XtPointer) XtDefaultForeground}, + {XtNbackground, XtCForeground, XtRXftColor, sizeof(XftColor), + XtOffsetOf(LogoRec, logo.bg), XtRString, + (XtPointer) XtDefaultBackground}, +#else + {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), + XtOffsetOf(LogoRec,logo.fgpixel), XtRString, + (XtPointer) XtDefaultForeground}, +#endif }; -static void Initialize(), Realize(), Destroy(), Redisplay(), Resize(); -static Boolean SetValues(); +static void ClassInitialize ( void ); +static void Initialize ( Widget request, Widget new, ArgList args, + Cardinal *num_args ); +static void Destroy ( Widget gw ); +static void Realize ( Widget gw, XtValueMask *valuemaskp, + XSetWindowAttributes *attr ); +static void Resize ( Widget gw ); +static void Redisplay ( Widget gw, XEvent *event, Region region ); +static Boolean SetValues ( Widget gcurrent, Widget grequest, Widget gnew, + ArgList args, Cardinal *num_args ); LogoClassRec logoClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "Logo", /* widget_size */ sizeof(LogoRec), - /* class_initialize */ NULL, + /* class_initialize */ ClassInitialize, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, @@ -96,19 +125,23 @@ WidgetClass logoWidgetClass = (WidgetClass) &logoClassRec; * * *****************************************************************************/ -static void create_gcs (w) - LogoWidget w; +static void +create_gcs(LogoWidget w) { XGCValues v; +#ifdef XRENDER + w->logo.fgpixel = w->logo.fg.pixel; +#endif + v.foreground = w->logo.fgpixel; w->logo.foreGC = XtGetGC ((Widget) w, GCForeground, &v); v.foreground = w->core.background_pixel; w->logo.backGC = XtGetGC ((Widget) w, GCForeground, &v); } -static void check_shape (w) - LogoWidget w; +static void +check_shape(LogoWidget w) { if (w->logo.shape_window) { int event_base, error_base; @@ -119,8 +152,8 @@ static void check_shape (w) } /* ARGSUSED */ -static void unset_shape (w) - LogoWidget w; +static void +unset_shape(LogoWidget w) { XSetWindowAttributes attr; unsigned long mask; @@ -141,8 +174,8 @@ static void unset_shape (w) w->logo.need_shaping = w->logo.shape_window; } -static void set_shape (w) - LogoWidget w; +static void +set_shape(LogoWidget w) { GC ones, zeros; Display *dpy = XtDisplay ((Widget) w); @@ -187,14 +220,151 @@ static void set_shape (w) * * *****************************************************************************/ +#ifdef XRENDER + +static void +RenderPrepare (LogoWidget w) +{ + if (!w->logo.draw) + { + w->logo.draw = XftDrawCreate (XtDisplay (w), XtWindow (w), + DefaultVisual (XtDisplay (w), + DefaultScreen(XtDisplay (w))), + w->core.colormap); + } +} + +XtConvertArgRec xftColorConvertArgs[] = { + {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen), + sizeof(Screen *)}, + {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap), + sizeof(Colormap)} +}; + +#define donestr(type, value, tstr) \ + { \ + if (toVal->addr != NULL) { \ + if (toVal->size < sizeof(type)) { \ + toVal->size = sizeof(type); \ + XtDisplayStringConversionWarning(dpy, \ + (char*) fromVal->addr, tstr); \ + return False; \ + } \ + *(type*)(toVal->addr) = (value); \ + } \ + else { \ + static type static_val; \ + static_val = (value); \ + toVal->addr = (XPointer)&static_val; \ + } \ + toVal->size = sizeof(type); \ + return True; \ + } + +static void +XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure, + XrmValuePtr args, Cardinal *num_args) +{ + Screen *screen; + Colormap colormap; + XftColor *color; + + if (*num_args != 2) + { + XtAppErrorMsg (app, + "freeXftColor", "wrongParameters", + "XtToolkitError", + "Freeing an XftColor requires screen and colormap arguments", + (String *) NULL, (Cardinal *)NULL); + return; + } + + screen = *((Screen **) args[0].addr); + colormap = *((Colormap *) args[1].addr); + color = (XftColor *) toVal->addr; + XftColorFree (DisplayOfScreen (screen), + DefaultVisual (DisplayOfScreen (screen), + XScreenNumberOfScreen (screen)), + colormap, color); +} + +static Boolean +XmuCvtStringToXftColor(Display *dpy, + XrmValue *args, Cardinal *num_args, + XrmValue *fromVal, XrmValue *toVal, + XtPointer *converter_data) +{ + char *spec; + XRenderColor renderColor; + XftColor xftColor; + Screen *screen; + Colormap colormap; + + if (*num_args != 2) + { + XtAppErrorMsg (XtDisplayToApplicationContext (dpy), + "cvtStringToXftColor", "wrongParameters", + "XtToolkitError", + "String to render color conversion needs screen and colormap arguments", + (String *) NULL, (Cardinal *)NULL); + return False; + } + + screen = *((Screen **) args[0].addr); + colormap = *((Colormap *) args[1].addr); + + spec = (char *) fromVal->addr; + if (strcasecmp (spec, XtDefaultForeground) == 0) + { + renderColor.red = 0; + renderColor.green = 0; + renderColor.blue = 0; + renderColor.alpha = 0xffff; + } + else if (strcasecmp (spec, XtDefaultBackground) == 0) + { + renderColor.red = 0xffff; + renderColor.green = 0xffff; + renderColor.blue = 0xffff; + renderColor.alpha = 0xffff; + } + else if (!XRenderParseColor (dpy, spec, &renderColor)) + return False; + if (!XftColorAllocValue (dpy, + DefaultVisual (dpy, + XScreenNumberOfScreen (screen)), + colormap, + &renderColor, + &xftColor)) + return False; + + donestr (XftColor, xftColor, XtRXftColor); +} + + +#endif + +static void +ClassInitialize(void) +{ +#ifdef XRENDER + XtSetTypeConverter (XtRString, XtRXftColor, + XmuCvtStringToXftColor, + xftColorConvertArgs, XtNumber(xftColorConvertArgs), + XtCacheByDisplay, XmuFreeXftColor); +#endif +} + /* ARGSUSED */ -static void Initialize (request, new, args, num_args) - Widget request, new; - ArgList args; - Cardinal *num_args; +static void +Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args) { LogoWidget w = (LogoWidget)new; +#ifdef XRENDER + w->logo.draw = 0; + w->logo.fgpixel = w->logo.fg.pixel; +#endif if (w->core.width < 1) w->core.width = 100; if (w->core.height < 1) w->core.height = 100; @@ -204,8 +374,8 @@ static void Initialize (request, new, args, num_args) w->logo.need_shaping = w->logo.shape_window; } -static void Destroy (gw) - Widget gw; +static void +Destroy(Widget gw) { LogoWidget w = (LogoWidget) gw; if (w->logo.foreGC) { @@ -218,10 +388,8 @@ static void Destroy (gw) } } -static void Realize (gw, valuemaskp, attr) - Widget gw; - XtValueMask *valuemaskp; - XSetWindowAttributes *attr; +static void +Realize(Widget gw, XtValueMask *valuemaskp, XSetWindowAttributes *attr) { LogoWidget w = (LogoWidget) gw; @@ -234,8 +402,8 @@ static void Realize (gw, valuemaskp, attr) (gw, valuemaskp, attr); } -static void Resize (gw) - Widget gw; +static void +Resize(Widget gw) { LogoWidget w = (LogoWidget) gw; @@ -243,27 +411,45 @@ static void Resize (gw) } /* ARGSUSED */ -static void Redisplay (gw, event, region) - Widget gw; - XEvent *event; /* unused */ - Region region; /* unused */ +static void +Redisplay(Widget gw, XEvent *event, Region region) { LogoWidget w = (LogoWidget) gw; if (w->logo.shape_window) { if (w->logo.need_shaping) set_shape (w); /* may change shape flag */ } - if (!w->logo.shape_window) - XmuDrawLogo(XtDisplay(w), XtWindow(w), w->logo.foreGC, w->logo.backGC, - 0, 0, (unsigned int) w->core.width, - (unsigned int) w->core.height); + if (!w->logo.shape_window) { +#ifdef XRENDER + if (w->logo.render) + { + RenderPrepare (w); + + XClearWindow (XtDisplay(w), XtWindow(w)); + RenderLogo (XtDisplay(w), PictOpOver, + XftDrawSrcPicture (w->logo.draw, &w->logo.fg), + XftDrawPicture (w->logo.draw), + XRenderFindStandardFormat (XtDisplay (w), + w->logo.sharp ? + PictStandardA1: + PictStandardA8), + 0, 0, (unsigned int) w->core.width, + (unsigned int) w->core.height); + } + else +#endif + { + XmuDrawLogo (XtDisplay(w), XtWindow(w), w->logo.foreGC, w->logo.backGC, + 0, 0, (unsigned int) w->core.width, + (unsigned int) w->core.height); + } + } } /* ARGSUSED */ -static Boolean SetValues (gcurrent, grequest, gnew, args, num_args) - Widget gcurrent, grequest, gnew; - ArgList args; - Cardinal *num_args; +static Boolean +SetValues (Widget gcurrent, Widget grequest, Widget gnew, + ArgList args, Cardinal *num_args) { LogoWidget current = (LogoWidget) gcurrent; LogoWidget new = (LogoWidget) gnew; diff --git a/Logo.h b/Logo.h index 81b98fc..601591a 100644 --- a/Logo.h +++ b/Logo.h @@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xlogo/Logo.h,v 1.4 2002/07/01 02:26:04 tsi Exp $ */ #ifndef _XawLogo_h #define _XawLogo_h @@ -51,6 +52,14 @@ from The Open Group. #define XtNshapeWindow "shapeWindow" #define XtCShapeWindow "ShapeWindow" +#define XtNrender "render" +#define XtCRender "Render" + +#define XtRXftColor "XftColor" + +#define XtNsharp "sharp" +#define XtCSharp "Sharp" + typedef struct _LogoRec *LogoWidget; typedef struct _LogoClassRec *LogoWidgetClass; diff --git a/LogoP.h b/LogoP.h index 0038ee1..eda21c2 100644 --- a/LogoP.h +++ b/LogoP.h @@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ - +/* $XFree86: xc/programs/xlogo/LogoP.h,v 1.4 2002/07/01 02:26:04 tsi Exp $ */ #ifndef _XawLogoP_h #define _XawLogoP_h @@ -34,12 +34,25 @@ from The Open Group. #include "Logo.h" #include +#ifdef XRENDER +#include +#include +#endif + typedef struct { - Pixel fgpixel; + Pixel fgpixel; GC foreGC; GC backGC; Boolean shape_window; Boolean need_shaping; +#ifdef XRENDER + Boolean render; + Boolean sharp; + XftDraw *draw; + XRenderPictFormat *mask_format; + XftColor fg; + XftColor bg; +#endif } LogoPart; typedef struct _LogoRec { diff --git a/xlogo.c b/xlogo.c index 44cc029..7e6c77f 100644 --- a/xlogo.c +++ b/xlogo.c @@ -25,6 +25,9 @@ in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/xlogo/xlogo.c,v 3.9 2002/05/23 23:53:59 keithp Exp $ */ + +#include #include #include #include "Logo.h" @@ -32,12 +35,17 @@ in this Software without prior written authorization from The Open Group. #ifdef XKB #include #endif +#include -extern void exit(); -static void quit(); +static void quit(Widget w, XEvent *event, String *params, + Cardinal *num_params); static XrmOptionDescRec options[] = { { "-shape", "*shapeWindow", XrmoptionNoArg, (XPointer) "on" }, +#ifdef XRENDER +{"-render", "*render",XrmoptionNoArg, "TRUE"}, +{"-sharp", "*sharp", XrmoptionNoArg, "TRUE"}, +#endif }; static XtActionsRec actions[] = { @@ -52,17 +60,15 @@ String fallback_resources[] = { NULL, }; -static void die(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; +static void +die(Widget w, XtPointer client_data, XtPointer call_data) { XCloseDisplay(XtDisplay(w)); exit(0); } -static void save(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; +static void +save(Widget w, XtPointer client_data, XtPointer call_data) { return; } @@ -71,21 +77,25 @@ static void save(w, client_data, call_data) * Report the syntax for calling xlogo. */ -static void Syntax(toplevel, call) - Widget toplevel; - char *call; +static void +Syntax(Widget toplevel, char *call) { Arg arg; SmcConn connection; - String reasons[6]; - int i, num_reasons = 6; + String reasons[7]; + int i, num_reasons = 7; reasons[0] = "Usage: "; reasons[1] = call; reasons[2] = " [-fg ] [-bg ] [-rv] [-bw ] [-bd ]\n"; reasons[3] = " [-d []:[]]\n"; reasons[4] = " [-g [][x][<+->[<+->]]]\n"; - reasons[5] = " [-shape]\n\n"; +#ifdef XRENDER + reasons[5] = " [-render] [-sharp]\n"; +#else + reasons[5] = ""; +#endif + reasons[6] = " [-shape]\n\n"; XtSetArg(arg, XtNconnection, &connection); XtGetValues(toplevel, &arg, (Cardinal)1); @@ -98,10 +108,8 @@ static void Syntax(toplevel, call) exit(1); } -void -main(argc, argv) -int argc; -char **argv; +int +main(int argc, char *argv[]) { Widget toplevel; XtAppContext app_con; @@ -126,14 +134,12 @@ char **argv; (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), &wm_delete_window, 1); XtAppMainLoop(app_con); + exit(0); } /*ARGSUSED*/ -static void quit(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; - Cardinal *num_params; +static void +quit(Widget w, XEvent *event, String *params, Cardinal *num_params) { Arg arg; @@ -151,3 +157,4 @@ static void quit(w, event, params, num_params) die(w, NULL, NULL); } } + diff --git a/xlogo.man b/xlogo.man index 6ba4903..64bce98 100644 --- a/xlogo.man +++ b/xlogo.man @@ -22,7 +22,10 @@ .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. -.TH XLOGO 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/xlogo/xlogo.man,v 1.10 2002/10/12 16:06:48 herrb Exp $ +.\" +.TH XLOGO 1 __xorgversion__ .SH NAME xlogo - X Window System logo .SH SYNOPSIS @@ -35,6 +38,12 @@ The \fIxlogo\fP program displays the X Window System logo. accepts all of the standard X Toolkit command line options, as well as the following: .TP 8 +.B \-render +This option indicates that the logo should be drawn with anti-aliased edges using the RENDER extension. +.TP 8 +.B \-shape +If -render is also specified, this forces the edges to be rendered in sharp mode, (ie. 1-bit alpha channel). +.TP 8 .B \-shape This option indicates that the logo window should be shaped rather than rectangular. @@ -73,9 +82,11 @@ to get the default host and display number. to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. .SH FILES -/lib/X11/app-defaults/XLogo - specifies required resources +.TP +.I __apploaddir__/XLogo +specifies required resources .SH SEE ALSO -X(1), xrdb(1) +X(__miscmansuffix__), xrdb(1) .SH AUTHORS Ollie Jones of Apollo Computer and Jim Fulton of the MIT X Consortium wrote the logo graphics routine, based on a graphic design by Danny -- cgit v1.2.3