xeyes.c revision 2ddb6cf1
1a1d141d5Smrg/* $XConsortium: xeyes.c,v 1.16 94/04/17 20:45:23 rws Exp $ */ 2a1d141d5Smrg/* 3a1d141d5Smrg 4a1d141d5SmrgCopyright (c) 1991 X Consortium 5a1d141d5Smrg 6a1d141d5SmrgPermission is hereby granted, free of charge, to any person obtaining 7a1d141d5Smrga copy of this software and associated documentation files (the 8a1d141d5Smrg"Software"), to deal in the Software without restriction, including 9a1d141d5Smrgwithout limitation the rights to use, copy, modify, merge, publish, 10a1d141d5Smrgdistribute, sublicense, and/or sell copies of the Software, and to 11a1d141d5Smrgpermit persons to whom the Software is furnished to do so, subject to 12a1d141d5Smrgthe following conditions: 13a1d141d5Smrg 14a1d141d5SmrgThe above copyright notice and this permission notice shall be included 15a1d141d5Smrgin all copies or substantial portions of the Software. 16a1d141d5Smrg 17a1d141d5SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18a1d141d5SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19a1d141d5SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20a1d141d5SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 21a1d141d5SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22a1d141d5SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23a1d141d5SmrgOTHER DEALINGS IN THE SOFTWARE. 24a1d141d5Smrg 25a1d141d5SmrgExcept as contained in this notice, the name of the X Consortium shall 26a1d141d5Smrgnot be used in advertising or otherwise to promote the sale, use or 27a1d141d5Smrgother dealings in this Software without prior written authorization 28a1d141d5Smrgfrom the X Consortium. 29a1d141d5Smrg 30a1d141d5Smrg*/ 31a1d141d5Smrg/* $XFree86: xc/programs/xeyes/xeyes.c,v 1.3 2000/02/17 14:00:35 dawes Exp $ */ 32a1d141d5Smrg 332ddb6cf1Smrg#ifdef HAVE_CONFIG_H 342ddb6cf1Smrg# include "config.h" 352ddb6cf1Smrg#endif 362ddb6cf1Smrg 37a1d141d5Smrg#include <X11/Intrinsic.h> 38a1d141d5Smrg#include <X11/StringDefs.h> 39a1d141d5Smrg#include <X11/Shell.h> 40a1d141d5Smrg#include "Eyes.h" 41a1d141d5Smrg#include <stdio.h> 42a1d141d5Smrg#include <stdlib.h> 43a1d141d5Smrg#include "eyes.bit" 44a1d141d5Smrg#include "eyesmask.bit" 45a1d141d5Smrg 46a1d141d5Smrg/* Exit with message describing command line format */ 47a1d141d5Smrg 48a1d141d5Smrgstatic void 49a1d141d5Smrgusage(void) 50a1d141d5Smrg{ 51a1d141d5Smrg fprintf(stderr, 52a1d141d5Smrg"usage: xeyes\n"); 53a1d141d5Smrg fprintf (stderr, 54a1d141d5Smrg" [-geometry [{width}][x{height}][{+-}{xoff}[{+-}{yoff}]]] [-display [{host}]:[{vs}]]\n"); 55a1d141d5Smrg fprintf(stderr, 56a1d141d5Smrg" [-fg {color}] [-bg {color}] [-bd {color}] [-bw {pixels}]"); 57a1d141d5Smrg fprintf(stderr, " [-shape | +shape]"); 58a1d141d5Smrg fprintf(stderr, "\n"); 59a1d141d5Smrg fprintf(stderr, 602ddb6cf1Smrg" [-outline {color}] [-center {color}] [-backing {backing-store}] [-distance]\n"); 612ddb6cf1Smrg#ifdef XRENDER 622ddb6cf1Smrg fprintf(stderr, 632ddb6cf1Smrg" [-render | +render]\n"); 642ddb6cf1Smrg#endif 65a1d141d5Smrg exit(1); 66a1d141d5Smrg} 67a1d141d5Smrg 68a1d141d5Smrg/* Command line options table. Only resources are entered here...there is a 69a1d141d5Smrg pass over the remaining options after XtParseCommand is let loose. */ 70a1d141d5Smrg 71a1d141d5Smrgstatic XrmOptionDescRec options[] = { 72a1d141d5Smrg{"-outline", "*eyes.outline", XrmoptionSepArg, NULL}, 73a1d141d5Smrg{"-center", "*eyes.center", XrmoptionSepArg, NULL}, 74a1d141d5Smrg{"-backing", "*eyes.backingStore", XrmoptionSepArg, NULL}, 75a1d141d5Smrg{"-shape", "*eyes.shapeWindow", XrmoptionNoArg, "TRUE"}, 76a1d141d5Smrg{"+shape", "*eyes.shapeWindow", XrmoptionNoArg, "FALSE"}, 772ddb6cf1Smrg#ifdef XRENDER 782ddb6cf1Smrg{"-render", "*eyes.render", XrmoptionNoArg, "TRUE"}, 792ddb6cf1Smrg{"+render", "*eyes.render", XrmoptionNoArg, "FALSE"}, 802ddb6cf1Smrg#endif 812ddb6cf1Smrg{"-distance", "*eyes.distance", XrmoptionNoArg, "TRUE"}, 82a1d141d5Smrg}; 83a1d141d5Smrg 84a1d141d5Smrgstatic Atom wm_delete_window; 85a1d141d5Smrg 86a1d141d5Smrg/*ARGSUSED*/ 87a1d141d5Smrgstatic void 88a1d141d5Smrgquit(Widget w, XEvent *event, String *params, Cardinal *num_params) 89a1d141d5Smrg{ 90a1d141d5Smrg if (event->type == ClientMessage && 91a1d141d5Smrg event->xclient.data.l[0] != wm_delete_window) { 92a1d141d5Smrg XBell(XtDisplay(w), 0); 93a1d141d5Smrg } else { 94a1d141d5Smrg XtDestroyApplicationContext(XtWidgetToApplicationContext(w)); 95a1d141d5Smrg exit(0); 96a1d141d5Smrg } 97a1d141d5Smrg} 98a1d141d5Smrg 99a1d141d5Smrgstatic XtActionsRec actions[] = { 100a1d141d5Smrg {"quit", quit} 101a1d141d5Smrg}; 102a1d141d5Smrg 103a1d141d5Smrgint 104a1d141d5Smrgmain(int argc, char **argv) 105a1d141d5Smrg{ 106a1d141d5Smrg XtAppContext app_context; 107a1d141d5Smrg Widget toplevel; 108a1d141d5Smrg Arg arg[2]; 109a1d141d5Smrg Cardinal i; 110a1d141d5Smrg 111a1d141d5Smrg XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); 112a1d141d5Smrg 113a1d141d5Smrg toplevel = XtAppInitialize(&app_context, "XEyes", 114a1d141d5Smrg options, XtNumber(options), &argc, argv, 115a1d141d5Smrg NULL, arg, (Cardinal) 0); 116a1d141d5Smrg if (argc != 1) usage(); 117a1d141d5Smrg 118a1d141d5Smrg wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", 119a1d141d5Smrg False); 120a1d141d5Smrg XtAppAddActions(app_context, actions, XtNumber(actions)); 121a1d141d5Smrg XtOverrideTranslations 122a1d141d5Smrg (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); 123a1d141d5Smrg 124a1d141d5Smrg i = 0; 125a1d141d5Smrg XtSetArg (arg[i], XtNiconPixmap, 126a1d141d5Smrg XCreateBitmapFromData (XtDisplay(toplevel), 127a1d141d5Smrg XtScreen(toplevel)->root, 128a1d141d5Smrg (char *)eyes_bits, eyes_width, eyes_height)); 129a1d141d5Smrg i++; 130a1d141d5Smrg XtSetArg (arg[i], XtNiconMask, 131a1d141d5Smrg XCreateBitmapFromData (XtDisplay(toplevel), 132a1d141d5Smrg XtScreen(toplevel)->root, 133a1d141d5Smrg (char *)eyesmask_bits, 134a1d141d5Smrg eyesmask_width, eyesmask_height)); 135a1d141d5Smrg i++; 136a1d141d5Smrg XtSetValues (toplevel, arg, i); 137a1d141d5Smrg 138a1d141d5Smrg (void) XtCreateManagedWidget ("eyes", eyesWidgetClass, toplevel, NULL, 0); 139a1d141d5Smrg XtRealizeWidget (toplevel); 140a1d141d5Smrg (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), 141a1d141d5Smrg &wm_delete_window, 1); 142a1d141d5Smrg XtAppMainLoop(app_context); 143a1d141d5Smrg 144a1d141d5Smrg return 0; 145a1d141d5Smrg} 146