[1809] in testers
dash and console changes
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Thu Aug 8 05:40:52 1991
To: vanharen@ATHENA.MIT.EDU
Cc: testers@ATHENA.MIT.EDU
From: jfc@ATHENA.MIT.EDU
Date: Thu, 08 Aug 91 05:40:28 EDT
I have made changes to dash and console so that the console will appear in
the correct position whether or not the user is running dash. Also, dash
uses a property on the root window to find an existing dash process instead
of searching all windows to find one named "dash".
This change requires that a resource be added to the app-defaults file.
This resource is named "rootPropName", the value is the name of the menubar
window. This line:
*rootPropName: menuTree/window
works with the current app-defaults file (the form of the name is a
/-separated path of widget names starting at the root). The ID of the named
window is placed in the "ATHENA_DASH" property on the root window.
The console, unless started with the "-noprop" option, places a property on
the root window. The property name is "ATHENA_CONSOLE", the value is the
window ID of the console. dash looks for this property when it starts. If
it finds the property, the window ID in the property (or its parent, if the
parent is not the root) is moved down so that it does not overlap the
menubar.
Also included in the following patch is some code cleanup. Debugging code
is #ifdef DEBUG; unused code is removed.
The following new options should be documented:
dash -force delete the ATHENA_DASH property and
start a new dash
console -noprop don't set the ATHENA_CONSOLE property
dash -move do move ATHENA_CONSOLE (default)
The following new resources should be documented:
console.setProp set the ATHENA_CONSOLE property (default True)
dash.rootPropName name of window to put in ATHENA_DASH
property (default none)
dash.moveConsole move ATHENA_CONSOLE (default true)
*** ref/console.c Mon Aug 5 09:42:59 1991
--- console.c Thu Aug 8 05:13:21 1991
***************
*** 14,20 ****
"$Header: $";
#endif lint
- #include "mit-copyright.h"
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
--- 14,19 ----
***************
*** 33,43 ****
#include "TextDisplay.h"
#include "Icon.h"
#include <X11/Xresource.h>
#ifndef CONSOLEDEFAULTS
! #define CONSOLEDEFAULTS "/etc/athena/login/Console"
#endif
static XrmOptionDescRec opTable[] = {
{"+rv", "*reverseVideo", XrmoptionNoArg, (caddr_t) "off"},
{"-background", "*background", XrmoptionSepArg, (caddr_t) NULL},
--- 32,46 ----
#include "TextDisplay.h"
#include "Icon.h"
#include <X11/Xresource.h>
+ #include <X11/Xatom.h>
#ifndef CONSOLEDEFAULTS
! #define CONSOLEDEFAULTS "/usr/athena/lib/X11/app-defaults/Console"
#endif
+ #define DASH_ATOM "ATHENA_DASH"
+ #define CONS_ATOM "ATHENA_CONSOLE"
+
static XrmOptionDescRec opTable[] = {
{"+rv", "*reverseVideo", XrmoptionNoArg, (caddr_t) "off"},
{"-background", "*background", XrmoptionSepArg, (caddr_t) NULL},
***************
*** 67,78 ****
{"-iconic", "*window.iconic", XrmoptionNoArg, (caddr_t) "True"},
{"+iconic", "*window.iconic", XrmoptionNoArg, (caddr_t) "False"},
{"-notimestamp",".timestamp", XrmoptionNoArg, (caddr_t) "False"},
};
typedef struct _MyResources {
int frequency, autoUnmap;
char *input;
! Boolean timestamp;
} MyResources;
typedef struct _MyResources *MyResourcesPtr;
--- 70,82 ----
{"-iconic", "*window.iconic", XrmoptionNoArg, (caddr_t) "True"},
{"+iconic", "*window.iconic", XrmoptionNoArg, (caddr_t) "False"},
{"-notimestamp",".timestamp", XrmoptionNoArg, (caddr_t) "False"},
+ {"-noprop", ".setProp", XrmoptionNoArg, (caddr_t) "False"},
};
typedef struct _MyResources {
int frequency, autoUnmap;
char *input;
! Boolean timestamp, setProp;
} MyResources;
typedef struct _MyResources *MyResourcesPtr;
***************
*** 79,84 ****
--- 83,90 ----
MyResources parms;
+ static Atom cons_atom;
+
#define offset(field) XjOffset(MyResourcesPtr,field)
static XjResource appResources[] =
***************
*** 91,96 ****
--- 97,104 ----
offset(input), XjRString, (caddr_t)"" },
{ "timestamp", "Timestamp", XjRBoolean, sizeof(Boolean),
offset(timestamp), XjRBoolean, (caddr_t) True },
+ { "setProp", "SetProp", XjRBoolean, sizeof(Boolean),
+ offset(setProp), XjRBoolean, (caddr_t) True },
};
#undef offset
***************
*** 108,114 ****
#define FPE 1
#define USR1 2
#define USR2 3
! #define NUMSIGS 4
int sigflags[NUMSIGS];
#if defined(ultrix) || defined(_AIX) || defined(sun) || defined(_AUX_SOURCE)
--- 116,123 ----
#define FPE 1
#define USR1 2
#define USR2 3
! #define INT 4
! #define NUMSIGS 5
int sigflags[NUMSIGS];
#if defined(ultrix) || defined(_AIX) || defined(sun) || defined(_AUX_SOURCE)
***************
*** 262,270 ****
caddr_t data;
{
XjDestroyJet(fromJet);
XCloseDisplay(root->core.display);
exit(0);
- return 0; /* For linting... */
}
int hide(fromJet, what, data)
--- 271,281 ----
caddr_t data;
{
XjDestroyJet(fromJet);
+ if (cons_atom)
+ XDeleteProperty(root->core.display, DefaultRootWindow(root->core.display),
+ cons_atom);
XCloseDisplay(root->core.display);
exit(0);
}
int hide(fromJet, what, data)
***************
*** 474,479 ****
--- 485,494 ----
case SIGHUP:
sigflags[HUP] = 1;
break;
+ case SIGINT:
+ case SIGTERM:
+ sigflags[INT] = 1;
+ break;
case SIGFPE:
sigflags[FPE] = 1;
break;
***************
*** 557,567 ****
--- 572,598 ----
}
}
+ if (sigflags[INT])
+ {
+ sigs++;
+ sigflags[INT] = 0;
+ if (cons_atom)
+ XDeleteProperty(root->core.display,
+ DefaultRootWindow(root->core.display),
+ cons_atom);
+ XCloseDisplay(root->core.display);
+ exit(0);
+ }
+
if (sigflags[HUP])
{
sigs++;
sigflags[HUP] = 0;
saveFile(CONSOLEFILE, text, length);
+ if (cons_atom)
+ XDeleteProperty(root->core.display,
+ DefaultRootWindow(root->core.display),
+ cons_atom);
XCloseDisplay(root->core.display);
exit(0);
}
***************
*** 589,594 ****
--- 620,627 ----
sigflags[i] = 0;
(void)signal(SIGHUP, sighandler);
+ (void)signal(SIGINT, sighandler);
+ (void)signal(SIGTERM, sighandler);
(void)signal(SIGFPE, sighandler);
(void)signal(SIGUSR1, sighandler);
(void)signal(SIGUSR2, sighandler);
***************
*** 639,644 ****
--- 672,684 ----
tj = XjVaCreateJet("textDisplay", textDisplayJetClass, w2, NULL, NULL);
XjRealizeJet(w);
+
+ if (parms.setProp)
+ {
+ cons_atom = XInternAtom(display, CONS_ATOM, False);
+ XChangeProperty(display, DefaultRootWindow(display), cons_atom, XA_WINDOW,
+ 32, PropModeReplace, (unsigned char *)&w->core.window, 1);
+ }
text = XjMalloc(BUFSIZE);
text[0] = '\0';
*** ref/dash.c Mon Aug 5 23:23:41 1991
--- dash.c Thu Aug 8 05:03:19 1991
***************
*** 14,20 ****
"$Header: $";
#endif lint
- #include "mit-copyright.h"
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
--- 14,19 ----
***************
*** 38,45 ****
#include "AClock.h"
#include "Form.h"
#include "Tree.h"
- /* #include "Drawing.h" */
- /* #include "StripChart.h" */
#include "warn.h"
#include "dash.h"
--- 37,42 ----
***************
*** 50,58 ****
extern int sys_nerr;
#endif
- extern int DEBUG;
-
#define MAX_X_REQUEST 16384L
#ifndef DASHDEFAULTS
--- 47,56 ----
extern int sys_nerr;
#endif
+ #ifdef DEBUG
+ int debug;
+ #endif
#define MAX_X_REQUEST 16384L
#ifndef DASHDEFAULTS
***************
*** 63,70 ****
#endif
#endif
- #define LOADST "/usr/athena/lib/gnuemacs/etc/loadst"
-
#define DASH "Dash"
#define DASH_NOP (char)0x00
#define DASH_DEBUG (char)0x01
--- 61,66 ----
***************
*** 76,83 ****
#define DASH_CREATEORMAP (char)0x07
#define DASH_RESTART (char)0x08
! Atom dashAtom;
! #define DASH_ATOM "_ATHENA_DASH"
Jet root;
/*
--- 72,84 ----
#define DASH_CREATEORMAP (char)0x07
#define DASH_RESTART (char)0x08
! /* This Atom is used in two ways.
! The root window gets a property with this name; the value is the Window
! ID of the dash menubar.
! This atom is also used for communication among different dash processes. */
! static Atom dashAtom;
! #define DASH_ATOM "ATHENA_DASH"
! #define CONS_ATOM "ATHENA_CONSOLE"
Jet root;
/*
***************
*** 124,129 ****
--- 125,132 ----
{"-restart", ".restart", XrmoptionNoArg, (caddr_t) "true"},
{"-debug", ".debug", XrmoptionNoArg, (caddr_t) "true"},
{"-nofork", ".nofork", XrmoptionNoArg, (caddr_t) "true"},
+ {"-force", ".forceNew", XrmoptionNoArg, (caddr_t) "true"},
+ {"-move", ".moveConsole", XrmoptionNoArg, (caddr_t) "true"},
#ifdef KERBEROS
{"-nochecktickets", ".checkTickets", XrmoptionNoArg, (caddr_t) "false"},
#endif /* KERBEROS */
***************
*** 157,162 ****
--- 160,171 ----
{ "checkTickets", "CheckTickets", XjRBoolean, sizeof(Boolean),
offset(checkTickets), XjRBoolean, (caddr_t) True },
#endif /* KERBEROS */
+ { "rootPropName", "RootPropName", XjRString, sizeof(char *),
+ offset(rootProp), XjRString, (caddr_t) NULL},
+ { "forceNew", "ForceNew", XjRBoolean, sizeof(Boolean),
+ offset(forceNew), XjRBoolean, (caddr_t)False},
+ { "moveConsole", "MoveConsole", XjRBoolean, sizeof(Boolean),
+ offset(moveConsole), XjRBoolean, (caddr_t)True}
};
#undef offset
***************
*** 975,980 ****
--- 984,993 ----
int argc = 0;
char *argv[100];
+ XDeleteProperty(root->core.display,
+ DefaultRootWindow(root->core.display), dashAtom);
+ XSync(root->core.display, 0);
+
setupEnvironment();
if (what != NULL &&
***************
*** 1198,1208 ****
int what;
caddr_t data;
{
exit(what);
- return 0; /* For linting... */
}
! int debug(fromJet, what, data)
caddr_t fromJet;
char *what;
caddr_t data;
--- 1211,1223 ----
int what;
caddr_t data;
{
+ Display *display = root->core.display;
+ XDeleteProperty(display, DefaultRootWindow(display), dashAtom);
+ XCloseDisplay(display);
exit(what);
}
! int debug_fn(fromJet, what, data)
caddr_t fromJet;
char *what;
caddr_t data;
***************
*** 1261,1267 ****
return 0;
NAME = "logout";
- /*return exec(NULL, "/usr/athena/end_session", NULL);*/
return exec(NULL, "end_session", NULL);
}
--- 1276,1281 ----
***************
*** 1268,1277 ****
--- 1282,1330 ----
fatal(display)
Display *display;
{
+ /* Can't delete dashAtom property after I/O error. */
+ fprintf (stderr, "Fatal X error.\n");
exit(-1);
}
+ Window findDASH(display)
+ Display *display;
+ {
+ int actual_format;
+ unsigned long nitems;
+ unsigned char *dashWindow;
+ Atom actual_type;
+ unsigned long bytes_after;
+ Window dash_w;
+
+ if (Success != XGetWindowProperty(display, DefaultRootWindow(display),
+ dashAtom, 0L, 1L, False, XA_WINDOW,
+ &actual_type, &actual_format, &nitems,
+ &bytes_after, &dashWindow))
+ {
+ #ifdef DEBUG
+ if (debug)
+ fprintf (stderr, "XGetWindowProperty returned error.\n");
+ #endif
+ return 0;
+ }
+ if (actual_format != 32 || actual_type != XA_WINDOW)
+ {
+ #ifdef DEBUG
+ if (debug)
+ fprintf (stderr,
+ "XGetWindowProperty returned bad type/format %ld/%ld (wanted %ld/32).\n",
+ actual_type, actual_format, XA_WINDOW);
+ #endif
+ return 0;
+ }
+ dash_w = *(Window *)dashWindow;
+ XFree(dashWindow);
+ return dash_w;
+ }
+
static int (*def_handler)();
+ static int bad_window;
int handler(display, error)
Display *display;
***************
*** 1279,1347 ****
{
if (error->error_code != BadWindow)
def_handler(display, error);
return 0;
}
! Window findDASH(display)
Display *display;
{
! Window empty, *children, check;
! unsigned int num_children;
! XTextProperty wm_class;
! char **stringList;
! int numStrings, i;
! char errtext[100];
! if (!XQueryTree(display,
! DefaultRootWindow(display),
! &empty, &empty,
! &children, &num_children))
! {
! sprintf(errtext, "XQueryTree failed");
! XjWarning(errtext);
! return NULL;
! }
! def_handler = XSetErrorHandler(handler);
! for (i = 0; i < num_children; i++)
{
! check = XmuClientWindow(display, children[i]);
! if (!XGetTextProperty(display, check, &wm_class, XA_WM_CLASS))
! wm_class.nitems = 0;
! /* isn't there anything to free from this call? not documented */
! if (wm_class.nitems != 0)
{
! if (!XTextPropertyToStringList(&wm_class,
! &stringList,
! &numStrings))
{
! sprintf(errtext, "XTextPropertyToStringList failed");
! XjWarning(errtext);
! XFree((char *)children);
! return NULL;
}
!
! if (numStrings > 1 &&
! !strcmp(stringList[1], DASH) &&
! !strcmp(stringList[0], programName))
{
! XFreeStringList(stringList);
! XFree((char *)children);
! return check;
}
!
! XFreeStringList(stringList);
}
}
- (void) XSetErrorHandler(def_handler);
-
- XFree((char *)children);
- return NULL;
- }
-
Status sendEvent(display, window, opcode, data)
Display *display;
Window window;
--- 1332,1424 ----
{
if (error->error_code != BadWindow)
def_handler(display, error);
+ bad_window = 1;
+ #ifdef DEBUG
+ if (debug)
+ fprintf(stderr, "Bad Window error ignored.\n");
+ #endif
return 0;
}
! static Jet menubar_jet;
!
! void move_console(display)
Display *display;
{
! int actual_format;
! unsigned long nitems;
! unsigned char *consWindow;
! Atom actual_type;
! unsigned long bytes_after;
! Window cons_w, root_w, frame_w, *children;
! unsigned int nchildren;
! unsigned int w,h,bw,depth;
! int x,y;
! if (!menubar_jet)
! return;
! if (Success != XGetWindowProperty(display, DefaultRootWindow(display),
! XInternAtom (display, CONS_ATOM, False),
! 0L, 1L, False, XA_WINDOW,
! &actual_type, &actual_format, &nitems,
! &bytes_after, &consWindow))
{
! #ifdef DEBUG
! if (debug)
! fprintf (stderr, "XGetWindowProperty returned error.\n");
! #endif
! return;
! }
! if (actual_format != 32 || actual_type != XA_WINDOW)
{
! #ifdef DEBUG
! if (debug)
! fprintf (stderr,
! "XGetWindowProperty returned bad type/format %ld/%ld (wanted %ld/32).\n",
! actual_type, actual_format, XA_WINDOW);
! #endif
! return;
! }
! cons_w = *(Window *)consWindow;
! XFree(consWindow);
! bad_window = 0;
! def_handler = XSetErrorHandler(handler);
! if (!XQueryTree(display, cons_w, &root_w, &frame_w, &children, &nchildren) ||
! bad_window)
{
! XSetErrorHandler(def_handler);
! return;
}
! if (frame_w == root_w)
! frame_w = cons_w;
! if (!XGetGeometry(display, frame_w, &root_w, &x, &y, &w, &h, &bw, &depth) ||
! bad_window)
{
! XSetErrorHandler(def_handler);
! return;
}
! #ifdef DEBUG
! if (debug)
! fprintf(stderr, "window %x at (%d,%d). menu bar y,h = %d,%d\n",
! cons_w, x, y, menubar_jet->core.y, menubar_jet->core.height);
! #endif
! if (y < menubar_jet->core.y + menubar_jet->core.height)
! {
! #ifdef DEBUG
! if (debug)
! fprintf (stderr, "Move console (%x) from (%d,%d) to (%d,%d)\n",
! cons_w, x, y, x, menubar_jet->core.y + menubar_jet->core.height);
! #endif
! XMoveWindow(display, cons_w, x,
! menubar_jet->core.y + menubar_jet->core.height);
}
+ XSetErrorHandler(def_handler);
+ return;
}
Status sendEvent(display, window, opcode, data)
Display *display;
Window window;
***************
*** 1360,1369 ****
if (data)
strcpy(&e.xclient.data.b[1], data);
if (s = XSendEvent(display, window, False, NoEventMask, &e))
! XFlush(display);
! return s;
}
int delete(fromJet, what, data)
--- 1437,1455 ----
if (data)
strcpy(&e.xclient.data.b[1], data);
+ /* The following code does conservative error checking.
+ The first XSync() is probably not needed. */
+
+ XSync(display, 0);
+ bad_window = 0;
+ def_handler = XSetErrorHandler(handler);
+
if (s = XSendEvent(display, window, False, NoEventMask, &e))
! XSync(display, 0);
! XSetErrorHandler(def_handler);
!
! return !bad_window && s;
}
int delete(fromJet, what, data)
***************
*** 1398,1407 ****
case DASH_NOP:
break;
case DASH_DEBUG:
! DEBUG = !DEBUG;
printTree(NULL, NULL, NULL);
break;
case DASH_KILL:
exit(0);
break;
case DASH_CREATE:
--- 1484,1498 ----
case DASH_NOP:
break;
case DASH_DEBUG:
! #ifdef DEBUG
! debug = !debug;
printTree(NULL, NULL, NULL);
+ #endif
break;
case DASH_KILL:
+ XDeleteProperty(root->core.display,
+ DefaultRootWindow(root->core.display), dashAtom);
+ XCloseDisplay(info->window->core.display);
exit(0);
break;
case DASH_CREATE:
***************
*** 1441,1524 ****
return 0;
}
! /*
! struct loadInfo {
! FILE *f;
! StripChartJet who;
! };
!
! void getLoad(fd, info)
! int fd;
! struct loadInfo *info;
{
! char s[40];
! int l1, l2, l3;
! fscanf(info->f, "%s %d.%d[%d]\n", s, &l1, &l2, &l3);
! XjStripChartData(info->who, 100*l1+l2);
! }
! int load(init, foo, data)
! StripChartInit *init;
! int foo;
! caddr_t data;
! {
! FILE *loadFile;
! char command[80];
! struct loadInfo *info;
! sprintf(command, "%s %d", LOADST, init->interval/1000);
! loadFile = popen(command, "r");
! info = (struct loadInfo *)XjMalloc(sizeof(struct loadInfo));
! info->who = init->j;
! info->f = loadFile;
!
! XjReadCallback((XjCallbackProc)getLoad, fileno(loadFile), info);
! return 0;
}
- int cpu(where)
- int *where;
- {
- double l;
-
- getcpu(NULL, NULL, &l);
- *where = (int)(l * 100.0);
- return 0;
- }
-
- int pstat(where)
- int *where;
- {
- FILE *ps;
- static int Pused, Ptext, Pfree, Pwasted, Pmissing;
- static int Pnum[6], Psize[6];
- static struct timeval last = { 0, 0 };
- struct timeval now;
-
- gettimeofday(&now, NULL);
- if (now.tv_sec - last.tv_sec > 60)
- {
- last = now;
-
- ps = popen("/etc/pstat -s", "r");
-
- fscanf(ps, "%dk used (%dk text), %dk free, %dk wasted, %dk missing\n",
- &Pused, &Ptext, &Pfree, &Pwasted, &Pmissing);
- fscanf(ps, "avail: %d*%dk %d*%dk %d*%dk %d*%dk %d*%dk %d*%dk\n",
- &Pnum[0], &Psize[0], &Pnum[1], &Psize[1], &Pnum[2], &Psize[2],
- &Pnum[3], &Psize[3], &Pnum[4], &Psize[4], &Pnum[5], &Psize[5]);
-
- pclose(ps);
- }
-
- *where = 100 * Pused / (Pused + Pfree + Pwasted + Pmissing);
-
- return 0;
- }
- */
-
-
XjCallbackRec callbacks[] =
{
/* tree operations */
--- 1532,1559 ----
return 0;
}
! /* Recursively search for a window other than w. */
! static Window
! findWindow(w, j)
! Window w;
! Jet j;
{
! Window w2;
! Jet child;
! /* First see if any children have windows. */
! for (child = j->core.child; child; child = child->core.sibling)
! if (child->core.window != w)
! return child->core.window;
! /* Now try recursive. */
! for (child = j->core.child; child; child = child->core.sibling)
! if (w2 = findWindow (w, child))
! return w2;
! return None;
}
XjCallbackRec callbacks[] =
{
/* tree operations */
***************
*** 1542,1548 ****
{ "sh", sh },
{ "toggleHelp", toggleHelp },
{ "toggleVerify", toggleVerify },
! { "debug", debug },
{ "usage", usage },
{ "logout", logout },
{ "delete", delete },
--- 1577,1583 ----
{ "sh", sh },
{ "toggleHelp", toggleHelp },
{ "toggleVerify", toggleVerify },
! { "debug", debug_fn },
{ "usage", usage },
{ "logout", logout },
{ "delete", delete },
***************
*** 1576,1583 ****
Set *tmp, *list;
char *nameOptions[50];
int i, numOptions = 0;
! int count, sign = 1;
! Status e;
home = (char *) getenv("HOME");
if (home != NULL)
--- 1611,1618 ----
Set *tmp, *list;
char *nameOptions[50];
int i, numOptions = 0;
! int sign = 1;
! int created_window;
home = (char *) getenv("HOME");
if (home != NULL)
***************
*** 1586,1593 ****
home = userFile;
}
- /* setenv("XENVIRONMENT", DASHDEFAULTS, 0); */
-
(void)XSetIOErrorHandler(fatal);
root = XjCreateRoot(&argc, argv, DASH, home,
--- 1621,1626 ----
***************
*** 1603,1610 ****
display = root->core.display;
- dashAtom = XInternAtom(display, DASH_ATOM, False);
-
/*
* Parse special creation options out of command line.
*/
--- 1636,1641 ----
***************
*** 1641,1695 ****
numOptions = 1;
}
! if (!parms.run) /* don't get a handle if we don't care */
! handle = findDASH(display);
! if (!handle && (parms.send || parms.kill || parms.debug))
{
! /* try harder... */
! count = 3;
! while (!handle && count)
{
- sleep(10);
handle = findDASH(display);
- count--;
}
! if (!handle)
{
! char errtext[100];
sprintf(errtext, "couldn't find a running %s", programName);
XjWarning(errtext);
exit(1);
}
- }
- #if 0
/*
- * -kill/-restart
- */
- if (handle && (parms.kill || parms.restart))
- {
- if (sendEvent(display, handle, DASH_KILL, NULL))
- {
- if (parms.kill)
- exit(0);
- handle = NULL;
- }
- else
- XjFatalError("sendEvent failed");
- }
- #else
- /*
* -kill
*/
if (handle && parms.kill)
{
! if (sendEvent(display, handle, DASH_KILL, NULL))
! exit(0);
! else
! XjFatalError("sendEvent failed");
}
/*
--- 1672,1706 ----
numOptions = 1;
}
! dashAtom = XInternAtom(display, DASH_ATOM, False);
! if (parms.forceNew)
{
! XDeleteProperty(display, DefaultRootWindow(display), dashAtom);
! XSync(display, 0);
! }
! else if (!parms.run) /* don't get a handle if we don't care */
{
handle = findDASH(display);
}
! if (!handle && (parms.send || parms.kill || parms.debug))
{
! char errtext[256];
sprintf(errtext, "couldn't find a running %s", programName);
XjWarning(errtext);
exit(1);
}
/*
* -kill
*/
if (handle && parms.kill)
{
! /* A failure here probably means there wasn't a dash to kill,
! so don't print an error if the kill fails. */
! exit (!sendEvent(display, handle, DASH_KILL, NULL));
}
/*
***************
*** 1697,1708 ****
*/
if (handle && parms.restart)
{
if (sendEvent(display, handle, DASH_RESTART, NULL))
exit(0);
! else
! XjFatalError("sendEvent failed");
}
- #endif
/*
* -debug
--- 1708,1718 ----
*/
if (handle && parms.restart)
{
+ /* If this fails, then fall through and start dash normally. */
if (sendEvent(display, handle, DASH_RESTART, NULL))
exit(0);
! handle = None;
}
/*
* -debug
***************
*** 1720,1727 ****
*/
if (handle)
{
! for (i = 0; i < numOptions; i++)
{
if (cd[i] == 0)
e = sendEvent(display, handle, DASH_UNMAP, nameOptions[i]);
else
--- 1730,1751 ----
*/
if (handle)
{
! Status e;
!
! if (numOptions == 0)
! exit (0);
!
! /* If this send returns 0, there probably wasn't really an existing
! dash process. */
! if (cd[0] == 0)
! e = sendEvent(display, handle, DASH_UNMAP, nameOptions[0]);
! else
! e = sendEvent(display, handle, DASH_CREATEORMAP, nameOptions[0]);
!
! if (e)
{
+ for (i = 1; i < numOptions; i++)
+ {
if (cd[i] == 0)
e = sendEvent(display, handle, DASH_UNMAP, nameOptions[i]);
else
***************
*** 1731,1736 ****
--- 1755,1771 ----
}
exit(0);
}
+ else if (parms.send)
+ {
+ XjFatalError("sendEvent failed");
+ }
+ else
+ {
+ XjWarning("unable to send request to existing dash");
+ XDeleteProperty(root->core.display,
+ DefaultRootWindow(root->core.display), dashAtom);
+ }
+ }
if (!parms.nofork)
{
***************
*** 1739,1745 ****
case 0: /* child */
break;
case -1: /* error */
! perror ("Can't fork");
exit(-1);
default: /* parent */
exit(0);
--- 1774,1780 ----
case 0: /* child */
break;
case -1: /* error */
! perror ("dash: can't fork");
exit(-1);
default: /* parent */
exit(0);
***************
*** 1751,1764 ****
--- 1786,1805 ----
XjRegisterCallbacks(callbacks, XjNumber(callbacks));
+ created_window = 0;
for (i = 0; i < numOptions; i++)
{
tmp = resolveName(nameOptions[i], NULL);
if (cd[i] == 1)
+ {
+ created_window = 1;
for (list = tmp; list != NULL; list = list->next)
(void)XjVaCreateJet(list->name, treeJetClass, root, NULL, NULL);
+ }
freeSet(tmp);
}
+ if (created_window == 0)
+ exit (0);
XjRealizeJet(root);
***************
*** 1768,1773 ****
--- 1809,1856 ----
if (parms.checkTickets)
checkTkts();
#endif /* KERBEROS */
+
+ if (parms.rootProp)
+ {
+ char *name = parms.rootProp, *nextslash;
+ Jet j = root;
+
+ /* Warning: if the window name in parms.rootProp is a compiled
+ default it may be read-only. In this case it should be copied
+ to temporary storage before modification. */
+ do
+ {
+ if (nextslash = index(name, '/'))
+ *nextslash = 0;
+ j = XjFindJet(name, j);
+ name = nextslash + 1;
+ }
+ while (nextslash && j);
+
+ if (j)
+ {
+ Display *dpy = j->core.display;
+ menubar_jet = j;
+ XChangeProperty(dpy, DefaultRootWindow(dpy), dashAtom, XA_WINDOW,
+ 32, PropModeReplace,
+ (unsigned char *)&j->core.window, 1);
+ if (parms.moveConsole)
+ move_console(root->core.display);
+ }
+ else
+ {
+ Window w = findWindow(root->core.window, root);
+ Display *dpy = root->core.display;
+ fprintf (stderr, "Couldn't find Jet named \"%s\".\n", parms.rootProp);
+ if (w == None)
+ {
+ fprintf (stderr, "dash: no sets created windows; exiting.\n");
+ exit (2);
+ }
+ XChangeProperty(dpy, DefaultRootWindow(dpy), dashAtom, XA_WINDOW,
+ 32, PropModeReplace, (unsigned char *)&w, 1);
+ }
+ }
XjEventLoop(root);
}
*** ref/Drawing.c Wed Jul 17 11:52:15 1991
--- Drawing.c Thu Aug 8 03:37:07 1991
***************
*** 19,26 ****
#include "Jets.h"
#include "Drawing.h"
- extern int DEBUG;
-
#define offset(field) XjOffset(DrawingJet,field)
static XjResource resources[] = {
--- 19,24 ----
*** ref/Window.c Tue Aug 6 13:09:06 1991
--- Window.c Thu Aug 8 03:08:02 1991
***************
*** 28,34 ****
static Boolean got_wm_delete = 0;
static Atom wm_delete_window;
! extern int DEBUG;
#define offset(field) XjOffset(WindowJet,field)
--- 28,36 ----
static Boolean got_wm_delete = 0;
static Atom wm_delete_window;
! #ifdef DEBUG
! extern int debug;
! #endif
#define offset(field) XjOffset(WindowJet,field)
***************
*** 111,118 ****
WindowJet me;
XjSize *size;
{
! if (DEBUG)
printf ("QS(window)");
if (me->core.child)
XjQuerySize(me->core.child, size);
--- 113,122 ----
WindowJet me;
XjSize *size;
{
! #ifdef DEBUG
! if (debug)
printf ("QS(window)");
+ #endif
if (me->core.child)
XjQuerySize(me->core.child, size);
***************
*** 122,129 ****
WindowJet me;
int x, y;
{
! if (DEBUG)
printf ("MV(window)");
me->core.x = x;
me->core.y = y;
--- 126,135 ----
WindowJet me;
int x, y;
{
! #ifdef DEBUG
! if (debug)
printf ("MV(window)");
+ #endif
me->core.x = x;
me->core.y = y;
***************
*** 138,145 ****
{
Jet child;
! if (DEBUG)
printf ("RSZ(window)");
me->core.width = (size->width) ? size->width : 1;
me->core.height = (size->height) ? size->height : 1;
--- 144,153 ----
{
Jet child;
! #ifdef DEBUG
! if (debug)
printf ("RSZ(window)");
+ #endif
me->core.width = (size->width) ? size->width : 1;
me->core.height = (size->height) ? size->height : 1;
***************
*** 485,498 ****
{
case GraphicsExpose:
case Expose:
! if (DEBUG)
printf("Window:event_handler expose_count: %d\n",
event->xexpose.count);
for (child = me->core.child; child != (Jet) NULL;
child = child->core.sibling)
{
! if (DEBUG)
{
printf("name: %s need: %d overlap: %d\n",
child->core.name, child->core.need_expose,
--- 493,509 ----
{
case GraphicsExpose:
case Expose:
! #ifdef DEBUG
! if (debug)
printf("Window:event_handler expose_count: %d\n",
event->xexpose.count);
+ #endif
for (child = me->core.child; child != (Jet) NULL;
child = child->core.sibling)
{
! #ifdef DEBUG
! if (debug)
{
printf("name: %s need: %d overlap: %d\n",
child->core.name, child->core.need_expose,
***************
*** 500,505 ****
--- 511,517 ----
printf("exp: %d,%d %d,%d jet: %d,%d %d,%d\n",
X1,Y1,X2,Y2, X3,Y3,X4,Y4);
}
+ #endif
if (!child->core.need_expose
&& child->core.classRec->core_class.expose != NULL
&& OVERLAP(X1,Y1,X2,Y2, X3,Y3,X4,Y4))
*** ref/Label.c Mon Jul 1 15:06:45 1991
--- Label.c Thu Aug 8 03:06:54 1991
***************
*** 19,25 ****
#include "Jets.h"
#include "Label.h"
! extern int DEBUG;
#define offset(field) XjOffset(LabelJet,field)
--- 19,27 ----
#include "Jets.h"
#include "Label.h"
! #ifdef DEBUG
! extern int debug;
! #endif
#define offset(field) XjOffset(LabelJet,field)
***************
*** 123,130 ****
LabelJet me;
XjSize *size;
{
! if (DEBUG)
printf ("QS(label) '%s'\n", me->label.label);
size->width = XTextWidth(me->label.font,
me->label.label,
--- 125,134 ----
LabelJet me;
XjSize *size;
{
! #ifdef DEBUG
! if (debug)
printf ("QS(label) '%s'\n", me->label.label);
+ #endif
size->width = XTextWidth(me->label.font,
me->label.label,
***************
*** 137,144 ****
LabelJet me;
int x, y;
{
! if (DEBUG)
printf ("MV(label) '%s'\n", me->label.label);
me->label.x += (x - me->core.x);
me->label.y += (y - me->core.y);
--- 141,150 ----
LabelJet me;
int x, y;
{
! #ifdef DEBUG
! if (debug)
printf ("MV(label) '%s'\n", me->label.label);
+ #endif
me->label.x += (x - me->core.x);
me->label.y += (y - me->core.y);
***************
*** 151,158 ****
LabelJet me;
XjSize *size;
{
! if (DEBUG)
printf ("RSZ(label) '%s'\n", me->label.label);
if (me->core.width != size->width
|| me->core.height != size->height)
--- 157,166 ----
LabelJet me;
XjSize *size;
{
! #ifdef DEBUG
! if (debug)
printf ("RSZ(label) '%s'\n", me->label.label);
+ #endif
if (me->core.width != size->width
|| me->core.height != size->height)
***************
*** 187,194 ****
LabelJet me;
XEvent *event;
{
! if (DEBUG)
printf ("EXP(label) '%s'\n", me->label.label);
XDrawString(me->core.display, me->core.window,
me->label.gc,
--- 195,204 ----
LabelJet me;
XEvent *event;
{
! #ifdef DEBUG
! if (debug)
printf ("EXP(label) '%s'\n", me->label.label);
+ #endif
XDrawString(me->core.display, me->core.window,
me->label.gc,
*** ref/Jets.c Tue Aug 6 13:44:24 1991
--- Jets.c Thu Aug 8 03:06:10 1991
***************
*** 23,29 ****
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/ioctl.h>
- #include <X11/X.h> /* For DEBUG */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
--- 23,28 ----
***************
*** 39,45 ****
#define BITMAPDIR "/usr/lib/X11/bitmaps"
#endif
! int DEBUG = 0;
static XjCallbackProc checkSignals = NULL;
--- 38,46 ----
#define BITMAPDIR "/usr/lib/X11/bitmaps"
#endif
! #ifdef DEBUG
! int debug = 0;
! #endif
static XjCallbackProc checkSignals = NULL;
***************
*** 949,955 ****
}
#ifdef DEBUG
! if (XCNOENT != XFindContext(jet->core.display, window,
registerContext, (caddr_t *)&eventJet))
fprintf(stdout, "%s usurped window from %s\n",
jet->core.name, eventJet->core.name);
--- 950,956 ----
}
#ifdef DEBUG
! if (debug && XCNOENT != XFindContext(jet->core.display, window,
registerContext, (caddr_t *)&eventJet))
fprintf(stdout, "%s usurped window from %s\n",
jet->core.name, eventJet->core.name);
*** ref/Icon.c Mon Jul 1 15:06:23 1991
--- Icon.c Thu Aug 8 03:05:13 1991
***************
*** 19,25 ****
#include "Jets.h"
#include "Icon.h"
! extern int DEBUG;
#define offset(field) XjOffset(IconJet,field)
--- 19,27 ----
#include "Jets.h"
#include "Icon.h"
! #ifdef DEBUG
! extern int debug;
! #endif
#define offset(field) XjOffset(IconJet,field)
***************
*** 174,199 ****
IconJet me;
XEvent *event;
{
! if (DEBUG)
printf("Icon expose on: %s\n", me->core.name);
if (me->icon.pixmap)
{
- /*
- int x = MAX(0, event->xexpose.x - me->icon.x);
- int y = MAX(0, event->xexpose.y - me->icon.y);
-
- XCopyPlane(me->core.display,
- me->icon.pixmap->pixmap,
- me->core.window,
- (me->icon.inverted) ? me->icon.gc : me->icon.reversegc,
- x, y,
- MIN(event->xexpose.width, me->icon.pixmap->width - x),
- MIN(event->xexpose.height, me->icon.pixmap->height - y),
- MAX(me->icon.x, event->xexpose.x),
- MAX(me->icon.y, event->xexpose.y),
- 1);
- */
XCopyPlane(me->core.display,
me->icon.pixmap->pixmap,
me->core.window,
--- 176,188 ----
IconJet me;
XEvent *event;
{
! #ifdef DEBUG
! if (debug)
printf("Icon expose on: %s\n", me->core.name);
+ #endif
if (me->icon.pixmap)
{
XCopyPlane(me->core.display,
me->icon.pixmap->pixmap,
me->core.window,
*** ref/Button.c Wed Jul 17 11:52:30 1991
--- Button.c Thu Aug 8 03:04:36 1991
***************
*** 19,25 ****
#include "Jets.h"
#include "Button.h"
! extern int DEBUG;
#define offset(field) XjOffset(ButtonJet,field)
--- 19,27 ----
#include "Jets.h"
#include "Button.h"
! #ifdef DEBUG
! extern int debug;
! #endif
#define offset(field) XjOffset(ButtonJet,field)
***************
*** 162,169 ****
ButtonJet me;
XjSize *size;
{
! if (DEBUG)
printf ("QS(button)");
if (me->core.child != NULL)
XjQuerySize(me->core.child, size);
--- 164,173 ----
ButtonJet me;
XjSize *size;
{
! #ifdef DEBUG
! if (debug)
printf ("QS(button)");
+ #endif
if (me->core.child != NULL)
XjQuerySize(me->core.child, size);
***************
*** 181,188 ****
ButtonJet me;
int x, y;
{
! if (DEBUG)
printf ("MV(button)");
me->core.x = x;
me->core.y = y;
--- 185,194 ----
ButtonJet me;
int x, y;
{
! #ifdef DEBUG
! if (debug)
printf ("MV(button)");
+ #endif
me->core.x = x;
me->core.y = y;
***************
*** 200,208 ****
XjSize *size;
{
XjSize childSize;
!
! if (DEBUG)
printf ("RSZ(button)");
me->core.width = size->width;
me->core.height = size->height;
--- 206,215 ----
XjSize *size;
{
XjSize childSize;
! #ifdef DEBUG
! if (debug)
printf ("RSZ(button)");
+ #endif
me->core.width = size->width;
me->core.height = size->height;
*** ref/AClock.c Wed Aug 7 01:09:58 1991
--- AClock.c Thu Aug 8 03:04:01 1991
***************
*** 30,36 ****
#include "sintable.h"
! extern int DEBUG;
#define offset(field) XjOffset(AClockJet,field)
--- 30,38 ----
#include "sintable.h"
! #ifdef DEBUG
! extern int debug;
! #endif
#define offset(field) XjOffset(AClockJet,field)
***************
*** 282,289 ****
AClockJet me;
int x, y;
{
! if (DEBUG)
printf ("MV(aClock)x=%d,y=%d\n", x, y);
me->core.x = x;
me->core.y = y;
--- 284,293 ----
AClockJet me;
int x, y;
{
! #ifdef DEBUG
! if (debug)
printf ("MV(aClock)x=%d,y=%d\n", x, y);
+ #endif
me->core.x = x;
me->core.y = y;
***************
*** 295,302 ****
AClockJet me;
XjSize *size;
{
! if (DEBUG)
printf ("RSZ(aClock)w=%d,h=%d\n", size->width, size->height);
if (me->aClock.keepRound)
{
--- 299,308 ----
AClockJet me;
XjSize *size;
{
! #ifdef DEBUG
! if (debug)
printf ("RSZ(aClock)w=%d,h=%d\n", size->width, size->height);
+ #endif
if (me->aClock.keepRound)
{