1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
|
/*
* Copyright (c) 1992 The Regents of the University of Texas System.
* Copyright (c) 1993 The Regents of the University of Texas System.
* Copyright (c) 1994 The Regents of the University of Texas System.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted provided
* that the above copyright notice and this paragraph are duplicated in all
* such forms and that any documentation, advertising materials, and other
* materials related to such distribution and use acknowledge that the
* software was developed by the University of Texas. The name of the
* University may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1993 The Regents of the University of Texas System.\n\
All rights reserved.\n";
static char rcsid[] =
"$Id: noop.c,v 1.2 1994/05/20 20:19:10 jones Exp $\n";
static char rcspath[] =
"$Source: /mintaka/u0/xx/ss/jones/jones.old/mftp.src/moxftp-2.0/RCS/noop.c,v $\n";
#endif
/* $Log: noop.c,v $
* Revision 1.2 1994/05/20 20:19:10 jones
* Do not depened on X11R5 NULL XtGetValues trick.
*
* Revision 1.1 1994/03/14 18:55:53 jones
* Initial revision
*
*/
#include "defs.h"
#include "wc.h"
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <ctype.h>
#if defined(MOTIF)
#include <Xm/Xm.h>
#include <Xm/Text.h>
#endif
#if defined(OPENWINDOW)
#include <Xol/OpenLook.h>
#endif
extern XtAppContext App_context;
extern Widget Top;
static int rootwidth = 0;
static int rootheight = 0;
static Cursor Busy = 0;
static struct _noop_flags {
char *action;
int flag;
} noop_flags[] = {
{ "get", NOOP_GET},
{ "put", NOOP_PUT},
{ "dir", NOOP_DIR},
{ "action", NOOP_ACTION},
{ "connect", NOOP_CONNECT},
{ "Sensitive", NOOP_SENSITIVE},
{ "ifsensitive", NOOP_IFSENSITIVE},
{ "notconnected", NOOP_NOTCONN}
};
static struct _noop {
Widget w;
Window Busy;
#if defined(MOTIF)||defined(OPENWINDOW)
int has_focus;
#endif
int flags;
int noop;
} noop[20];
static int NUM_NOOP = 0;
#include "proto/noop.h"
void
Clear_Noop(mode)
int mode;
{
int i;
for(i=0; i<NUM_NOOP; i++) {
if ((NOOP_WAITING&noop[i].flags) && (mode&noop[i].noop) &&
noop[i].w) {
noop[i].noop &= ~mode;
if(noop[i].noop) continue;
if (XtIsRealized(noop[i].w) && noop[i].Busy)
XUnmapWindow(XtDisplay(Top), noop[i].Busy);
if(noop[i].flags & NOOP_SENSITIVE)
WcSetSensitiveCB(noop[i].w, "this", NULL);
#if defined(MOTIF)
else {
XtVaSetValues(noop[i].w, XmNtraversalOn, TRUE, NULL);
}
if (noop[i].has_focus) {
XmProcessTraversal(noop[i].w, XmTRAVERSE_CURRENT);
}
noop[i].has_focus = 0;
#endif
#if defined(OPENWINDOW)
if (noop[i].has_focus) XSetInputFocus(XtDisplay(Top),
XtWindow(noop[i].w),
RevertToNone,
CurrentTime);
noop[i].has_focus = 0;
#endif
noop[i].flags &= ~NOOP_WAITING;
}
}
}
int
Is_Noop(w)
Widget w;
{
int i;
for(i=0; i<NUM_NOOP; i++) {
if (noop[i].w == w && (noop[i].flags & NOOP_WAITING)) return 1;
}
return 0;
}
void
Register_Noop_CallBacks_and_Actions()
{
RACCT("Clear_noop" , clear_noop_act);
RCALL("Clear_noop" , clear_noop_cb);
RCALL("noop" , noop_cb);
RCALL("Set_noop" , set_noop_cb);
}
void
Set_Noop(mode)
int mode;
{
int i;
unsigned long valuemask;
XSetWindowAttributes attributes;
int hasfocus = 0;
if(!Busy) {
Busy = XCreateFontCursor (XtDisplay(Top), XC_watch);
#if defined(sgi)&&defined(MOTIF)
for(i=0; i<NUM_NOOP; i++) {
if(noop[i].w == WcFullNameToWidget(Top, "*ftp")) {
noop[i].flags |= NOOP_SENSITIVE;
break;
}
}
#endif
}
if(!rootwidth) {
rootwidth = WidthOfScreen(XtScreen(Top));
rootheight = HeightOfScreen(XtScreen(Top));
}
for(i=0; i<NUM_NOOP; i++) {
if ((mode&noop[i].flags) && noop[i].w) {
if (!noop[i].noop && !XtIsSensitive(noop[i].w) &&
(noop[i].flags&NOOP_IFSENSITIVE)) continue;
noop[i].noop |= mode;
if (noop[i].flags & NOOP_WAITING) continue;
if (XtIsRealized(noop[i].w) && !noop[i].Busy) {
valuemask = CWDontPropagate | CWCursor;
attributes.do_not_propagate_mask =
(KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
Button1MotionMask|
Button2MotionMask|Button3MotionMask);
attributes.cursor = Busy;
noop[i].Busy =
XCreateWindow(XtDisplay(noop[i].w),
XtWindow(noop[i].w), 0, 0,
rootwidth, rootheight,
(unsigned int) 0, CopyFromParent,
InputOnly, CopyFromParent, valuemask,
&attributes);
}
if(noop[i].Busy) {
#if defined(MOTIF)||defined(OPENWINDOW)
if (hasfocus = Has_Focus(noop[i].w)) {
int j;
for(j=0; j<NUM_NOOP; j++) if (noop[j].has_focus) break;
if (j == NUM_NOOP) noop[i].has_focus = 1;
}
#endif
XMapWindow(XtDisplay(Top), noop[i].Busy);
#if defined(OPENWINDOW)
if (hasfocus) XSetInputFocus(XtDisplay(Top),
None,
RevertToNone,
CurrentTime);
#endif
}
if(noop[i].flags & NOOP_SENSITIVE) {
WcSetInsensitiveCB(noop[i].w, "this", NULL);
}
#if defined(MOTIF)
else {
/*
* If this widget has focus move
* focus. Older motifs will core dump if you
* turn off XmNtraversalOn and the widget has focus.
*/
if (hasfocus) {
XtSetKeyboardFocus(Top, None);
}
XtVaSetValues(noop[i].w, XmNtraversalOn, FALSE, NULL);
}
#endif
noop[i].flags |= NOOP_WAITING;
}
}
XSync(XtDisplay(Top), FALSE);
while(XtAppPending(App_context) & XtIMXEvent)
XtAppProcessEvent(App_context, XtIMXEvent);
}
static void
clear_noop_act(w, event, params, num_params)
Widget w;
XEvent * event;
String * params;
Cardinal * num_params;
{
if(*num_params == 1) clear_noop_xx(w, params[0]);
}
static void
clear_noop_cb(w, stuff, unused)
Widget w;
char *stuff;
caddr_t unused;
{
clear_noop_xx(w, stuff);
}
static void
clear_noop_xx(w, stuff)
Widget w;
char *stuff;
{
char *token;
char *cp = stuff;
int i;
token = XtMalloc(strlen(cp)+1);
while (cp && *cp) {
cp = Next_Token(cp, token);
for (i=0; i<(sizeof(noop_flags)/sizeof(struct _noop_flags)); i++) {
if (strcmp(noop_flags[i].action, token) == 0) {
Clear_Noop(noop_flags[i].flag);
break;
}
}
}
XtFree(token);
}
static void
noop_cb(w, stuff, unused)
Widget w;
char *stuff;
caddr_t unused;
{
char *cp = stuff;
char *token;
int i;
if (NUM_NOOP >= (sizeof(noop)/sizeof(struct _noop))) {
fprintf(stderr,"Too many widgets to noop %d\n", NUM_NOOP);
return;
}
noop[NUM_NOOP].w = w;
token = XtMalloc(strlen(cp)+1);
while (cp && *cp) {
cp = Next_Token(cp, token);
for (i=0; i<(sizeof(noop_flags)/sizeof(struct _noop_flags)); i++) {
if (strcmp(noop_flags[i].action, token) == 0) {
noop[NUM_NOOP].flags |= noop_flags[i].flag;
break;
}
}
}
XtFree(token);
NUM_NOOP++;
}
static void
set_noop_cb(w, stuff, unused)
Widget w;
char *stuff;
caddr_t unused;
{
char *token;
char *cp = stuff;
int i;
token = XtMalloc(strlen(cp)+1);
while (cp && *cp) {
cp = Next_Token(cp, token);
for (i=0; i<(sizeof(noop_flags)/sizeof(struct _noop_flags)); i++) {
if (strcmp(noop_flags[i].action, token) == 0) {
Set_Noop(noop_flags[i].flag);
break;
}
}
}
XtFree(token);
}
|