diff options
-rw-r--r-- | Logo.c | 299 | ||||
-rw-r--r-- | Logo.h | 59 | ||||
-rw-r--r-- | LogoP.h | 61 | ||||
-rw-r--r-- | XLogo-color.ad | 5 | ||||
-rw-r--r-- | XLogo.ad | 1 | ||||
-rw-r--r-- | xlogo.c | 153 | ||||
-rw-r--r-- | xlogo.man | 82 |
7 files changed, 660 insertions, 0 deletions
@@ -0,0 +1,299 @@ +/* $Xorg: Logo.c,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $ */ +/* + +Copyright 1988, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +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. + +*/ + +#include <X11/StringDefs.h> +#include <X11/IntrinsicP.h> +#include "LogoP.h" +#include <X11/extensions/shape.h> + +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}, +}; + +static void Initialize(), Realize(), Destroy(), Redisplay(), Resize(); +static Boolean SetValues(); + +LogoClassRec logoClassRec = { + { /* core fields */ + /* superclass */ (WidgetClass) &simpleClassRec, + /* class_name */ "Logo", + /* widget_size */ sizeof(LogoRec), + /* class_initialize */ NULL, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ NULL, + /* num_actions */ 0, + /* resources */ resources, + /* resource_count */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ Destroy, + /* resize */ Resize, + /* expose */ Redisplay, + /* set_values */ SetValues, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback_private */ NULL, + /* tm_table */ NULL, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + { /* simple fields */ + /* change_sensitive */ XtInheritChangeSensitive + }, + { /* logo fields */ + /* ignore */ 0 + } +}; + +WidgetClass logoWidgetClass = (WidgetClass) &logoClassRec; + + +/***************************************************************************** + * * + * private utility routines * + * * + *****************************************************************************/ + +static void create_gcs (w) + LogoWidget w; +{ + XGCValues v; + + 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; +{ + if (w->logo.shape_window) { + int event_base, error_base; + + if (!XShapeQueryExtension (XtDisplay (w), &event_base, &error_base)) + w->logo.shape_window = FALSE; + } +} + +/* ARGSUSED */ +static void unset_shape (w) + LogoWidget w; +{ + XSetWindowAttributes attr; + unsigned long mask; + Display *dpy = XtDisplay ((Widget) w); + Window win = XtWindow ((Widget) w); + + if (w->core.background_pixmap != None && + w->core.background_pixmap != XtUnspecifiedPixmap) { + attr.background_pixmap = w->core.background_pixmap; + mask = CWBackPixmap; + } else { + attr.background_pixel = w->core.background_pixel; + mask = CWBackPixel; + } + XChangeWindowAttributes (dpy, win, mask, &attr); + XShapeCombineMask (dpy, win, ShapeBounding, 0, 0, None, ShapeSet); + if (!w->logo.foreGC) create_gcs (w); + w->logo.need_shaping = w->logo.shape_window; +} + +static void set_shape (w) + LogoWidget w; +{ + GC ones, zeros; + Display *dpy = XtDisplay ((Widget) w); + Window win = XtWindow ((Widget) w); + unsigned int width = (unsigned int) w->core.width; + unsigned int height = (unsigned int) w->core.height; + Pixmap pm = XCreatePixmap (dpy, win, width, height, (unsigned int) 1); + XGCValues v; + + v.foreground = (Pixel) 1; + v.background = (Pixel) 0; + ones = XCreateGC (dpy, pm, (GCForeground | GCBackground), &v); + v.foreground = (Pixel) 0; + v.background = (Pixel) 1; + zeros = XCreateGC (dpy, pm, (GCForeground | GCBackground), &v); + + if (pm && ones && zeros) { + int x = 0, y = 0; + Widget parent; + + XmuDrawLogo (dpy, pm, ones, zeros, 0, 0, width, height); + for (parent = (Widget) w; XtParent(parent); + parent = XtParent(parent)) { + x += parent->core.x + parent->core.border_width; + y += parent->core.y + parent->core.border_width; + } + XShapeCombineMask (dpy, XtWindow (parent), ShapeBounding, + x, y, pm, ShapeSet); + w->logo.need_shaping = FALSE; + } else { + unset_shape (w); + } + if (ones) XFreeGC (dpy, ones); + if (zeros) XFreeGC (dpy, zeros); + if (pm) XFreePixmap (dpy, pm); +} + + +/***************************************************************************** + * * + * class methods * + * * + *****************************************************************************/ + +/* ARGSUSED */ +static void Initialize (request, new, args, num_args) + Widget request, new; + ArgList args; + Cardinal *num_args; +{ + LogoWidget w = (LogoWidget)new; + + if (w->core.width < 1) w->core.width = 100; + if (w->core.height < 1) w->core.height = 100; + + w->logo.foreGC = (GC) NULL; + w->logo.backGC = (GC) NULL; + check_shape (w); + w->logo.need_shaping = w->logo.shape_window; +} + +static void Destroy (gw) + Widget gw; +{ + LogoWidget w = (LogoWidget) gw; + if (w->logo.foreGC) { + XtReleaseGC (gw, w->logo.foreGC); + w->logo.foreGC = (GC) NULL; + } + if (w->logo.backGC) { + XtReleaseGC (gw, w->logo.backGC); + w->logo.backGC = (GC) NULL; + } +} + +static void Realize (gw, valuemaskp, attr) + Widget gw; + XtValueMask *valuemaskp; + XSetWindowAttributes *attr; +{ + LogoWidget w = (LogoWidget) gw; + + if (w->logo.shape_window) { + attr->background_pixel = w->logo.fgpixel; /* going to shape */ + *valuemaskp |= CWBackPixel; + } else + create_gcs (w); + (*logoWidgetClass->core_class.superclass->core_class.realize) + (gw, valuemaskp, attr); +} + +static void Resize (gw) + Widget gw; +{ + LogoWidget w = (LogoWidget) gw; + + if (w->logo.shape_window && XtIsRealized(gw)) set_shape (w); +} + +/* ARGSUSED */ +static void Redisplay (gw, event, region) + Widget gw; + XEvent *event; /* unused */ + Region region; /* unused */ +{ + 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); +} + +/* ARGSUSED */ +static Boolean SetValues (gcurrent, grequest, gnew, args, num_args) + Widget gcurrent, grequest, gnew; + ArgList args; + Cardinal *num_args; +{ + LogoWidget current = (LogoWidget) gcurrent; + LogoWidget new = (LogoWidget) gnew; + Boolean redisplay = FALSE; + + if (new->logo.shape_window && + new->logo.shape_window != current->logo.shape_window) + check_shape (new); /* validate shape_window */ + + if ((new->logo.fgpixel != current->logo.fgpixel) || + (new->core.background_pixel != current->core.background_pixel)) { + Destroy (gnew); + if (!new->logo.shape_window) create_gcs (new); + redisplay = TRUE; + } + + if (new->logo.shape_window != current->logo.shape_window) { + if (new->logo.shape_window) { + Destroy (gnew); + if (XtIsRealized(gnew)) + set_shape (new); + else + new->logo.need_shaping = True; + redisplay = FALSE; + } else { + if (XtIsRealized(gnew)) + unset_shape (new); /* creates new GCs */ + redisplay = TRUE; + } + } + + return (redisplay); +} @@ -0,0 +1,59 @@ +/* $Xorg: Logo.h,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $ */ +/* + +Copyright 1988, 1990, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +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. + +*/ + +#ifndef _XawLogo_h +#define _XawLogo_h + +/* Parameters: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background Pixel XtDefaultBackground + border BorderColor Pixel XtDefaultForeground + borderWidth BorderWidth Dimension 1 + destroyCallback Callback Pointer NULL + foreground Foreground Pixel XtDefaultForeground + height Height Dimension 100 + mappedWhenManaged MappedWhenManaged Boolean True + shapeWindow ShapeWindow Boolean False + width Width Dimension 100 + x Position Position 0 + y Position Position 0 + +*/ + +#define XtNshapeWindow "shapeWindow" +#define XtCShapeWindow "ShapeWindow" + +typedef struct _LogoRec *LogoWidget; +typedef struct _LogoClassRec *LogoWidgetClass; + +extern WidgetClass logoWidgetClass; + +#endif /* _XawLogo_h */ @@ -0,0 +1,61 @@ +/* $Xorg: LogoP.h,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $ */ +/* + +Copyright 1988, 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +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. + +*/ + + +#ifndef _XawLogoP_h +#define _XawLogoP_h + +#include "Logo.h" +#include <X11/Xaw/SimpleP.h> + +typedef struct { + Pixel fgpixel; + GC foreGC; + GC backGC; + Boolean shape_window; + Boolean need_shaping; + } LogoPart; + +typedef struct _LogoRec { + CorePart core; + SimplePart simple; + LogoPart logo; + } LogoRec; + +typedef struct {int dummy;} LogoClassPart; + +typedef struct _LogoClassRec { + CoreClassPart core_class; + SimpleClassPart simple_class; + LogoClassPart logo_class; + } LogoClassRec; + +extern LogoClassRec logoClassRec; + +#endif /* _XawLogoP_h */ diff --git a/XLogo-color.ad b/XLogo-color.ad new file mode 100644 index 0000000..add98cc --- /dev/null +++ b/XLogo-color.ad @@ -0,0 +1,5 @@ +! $Xorg: XLogo-co.ad,v 1.3 2000/08/17 19:54:52 cpqbld Exp $ +#include "XLogo" +! MIT colors are Cardinal Red (Pantone 201c) and Silver Grey (Pantone 421c) +XLogo*background: rgb:d2/22/32 +XLogo*foreground: rgb:d7/d7/d7 diff --git a/XLogo.ad b/XLogo.ad new file mode 100644 index 0000000..202a098 --- /dev/null +++ b/XLogo.ad @@ -0,0 +1 @@ +XLogo.input: false @@ -0,0 +1,153 @@ +/* + * $Xorg: xlogo.c,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $ + * +Copyright 1989, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall 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. + * + */ + +#include <X11/Intrinsic.h> +#include <X11/Shell.h> +#include "Logo.h" +#include <X11/Xaw/Cardinals.h> +#ifdef XKB +#include <X11/extensions/XKBbells.h> +#endif + +extern void exit(); +static void quit(); + +static XrmOptionDescRec options[] = { +{ "-shape", "*shapeWindow", XrmoptionNoArg, (XPointer) "on" }, +}; + +static XtActionsRec actions[] = { + {"quit", quit} +}; + +static Atom wm_delete_window; + +String fallback_resources[] = { + "*iconPixmap: xlogo32", + "*iconMask: xlogo32", + NULL, +}; + +static void die(w, client_data, call_data) + Widget w; + XtPointer client_data, call_data; +{ + XCloseDisplay(XtDisplay(w)); + exit(0); +} + +static void save(w, client_data, call_data) + Widget w; + XtPointer client_data, call_data; +{ + return; +} + +/* + * Report the syntax for calling xlogo. + */ + +static void Syntax(toplevel, call) + Widget toplevel; + char *call; +{ + Arg arg; + SmcConn connection; + String reasons[6]; + int i, num_reasons = 6; + + reasons[0] = "Usage: "; + reasons[1] = call; + reasons[2] = " [-fg <color>] [-bg <color>] [-rv] [-bw <pixels>] [-bd <color>]\n"; + reasons[3] = " [-d [<host>]:[<vs>]]\n"; + reasons[4] = " [-g [<width>][x<height>][<+-><xoff>[<+-><yoff>]]]\n"; + reasons[5] = " [-shape]\n\n"; + + XtSetArg(arg, XtNconnection, &connection); + XtGetValues(toplevel, &arg, (Cardinal)1); + if (connection) + SmcCloseConnection(connection, num_reasons, reasons); + else { + for (i=0; i < num_reasons; i++) + printf(reasons[i]); + } + exit(1); +} + +void +main(argc, argv) +int argc; +char **argv; +{ + Widget toplevel; + XtAppContext app_con; + + toplevel = XtOpenApplication(&app_con, "XLogo", + options, XtNumber(options), + &argc, argv, fallback_resources, + sessionShellWidgetClass, NULL, ZERO); + if (argc != 1) + Syntax(toplevel, argv[0]); + + XtAddCallback(toplevel, XtNsaveCallback, save, NULL); + XtAddCallback(toplevel, XtNdieCallback, die, NULL); + XtAppAddActions + (XtWidgetToApplicationContext(toplevel), actions, XtNumber(actions)); + XtOverrideTranslations + (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); + XtCreateManagedWidget("xlogo", logoWidgetClass, toplevel, NULL, ZERO); + XtRealizeWidget(toplevel); + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), + &wm_delete_window, 1); + XtAppMainLoop(app_con); +} + +/*ARGSUSED*/ +static void quit(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; +{ + Arg arg; + + if (event->type == ClientMessage && + event->xclient.data.l[0] != wm_delete_window) { +#ifdef XKB + XkbStdBell(XtDisplay(w), XtWindow(w), 0, XkbBI_BadValue); +#else + XBell(XtDisplay(w), 0); +#endif + } else { + /* resign from the session */ + XtSetArg(arg, XtNjoinSession, False); + XtSetValues(w, &arg, ONE); + die(w, NULL, NULL); + } +} diff --git a/xlogo.man b/xlogo.man new file mode 100644 index 0000000..6ba4903 --- /dev/null +++ b/xlogo.man @@ -0,0 +1,82 @@ +.\" $Xorg: xlogo.man,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $ +.\" Copyright 1988, 1994, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +.\" OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of The Open Group shall +.\" 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" +.SH NAME +xlogo - X Window System logo +.SH SYNOPSIS +.B xlogo +[-\fItoolkitoption\fP ...] +.SH DESCRIPTION +The \fIxlogo\fP program displays the X Window System logo. +.SH OPTIONS +.I Xlogo +accepts all of the standard X Toolkit command line options, as well as the +following: +.TP 8 +.B \-shape +This option indicates that the logo window should be shaped rather than +rectangular. +.SH RESOURCES +The default width and the default height are each 100 pixels. +This program uses the \fILogo\fP widget in the Athena widget set. It +understands all of the Simple widget resource names and classes as well as: +.TP 8 +.B foreground (\fPclass\fB Foreground) +Specifies the color for the logo. The default is depends on whether +\fIreverseVideo\fP is specified. If \fIreverseVideo\fP is specified +the default is \fIXtDefaultForeground\fP, otherwise the default is +\fIXtDefaultBackground\fP. +.TP 8 +.B shapeWindow (\fPclass\fB ShapeWindow) +Specifies that the window is shaped to the X logo. The default is False. +.SH WIDGETS +In order to specify resources, it is useful to know the hierarchy of +the widgets which compose \fIxlogo\fR. In the notation below, +indentation indicates hierarchical structure. The widget class name +is given first, followed by the widget instance name. +.sp +.nf +.TA .5i +.ta .5i +XLogo xlogo + Logo xlogo +.fi +.sp +.SH ENVIRONMENT +.TP 8 +.B DISPLAY +to get the default host and display number. +.TP 8 +.B XENVIRONMENT +to get the name of a resource file that overrides the global resources +stored in the RESOURCE_MANAGER property. +.SH FILES +<XRoot>/lib/X11/app-defaults/XLogo - specifies required resources +.SH SEE ALSO +X(1), 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 +Chong and Ross Chapman of Apollo Computer. |