1
/* $Xorg: TMaction.c,v 1.5 2001/02/09 02:03:58 xorgcvs Exp $ */
4
/***********************************************************
5
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
6
Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
10
Permission to use, copy, modify, and distribute this software and its
11
documentation for any purpose and without fee is hereby granted,
12
provided that the above copyright notice appear in all copies and that
13
both that copyright notice and this permission notice appear in
14
supporting documentation, and that the names of Digital or Sun not be
15
used in advertising or publicity pertaining to distribution of the
16
software without specific, written prior permission.
18
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
19
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
20
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
21
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
23
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
26
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
27
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
28
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
29
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
30
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
31
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
33
THE USE OR PERFORMANCE OF THIS SOFTWARE.
35
******************************************************************/
39
Copyright 1987, 1988, 1998 The Open Group
41
Permission to use, copy, modify, distribute, and sell this software and its
42
documentation for any purpose is hereby granted without fee, provided that
43
the above copyright notice appear in all copies and that both that
44
copyright notice and this permission notice appear in supporting
47
The above copyright notice and this permission notice shall be included in
48
all copies or substantial portions of the Software.
50
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
54
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
55
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57
Except as contained in this notice, the name of The Open Group shall not be
58
used in advertising or otherwise to promote the sale, use or other dealings
59
in this Software without prior written authorization from The Open Group.
62
/* $XFree86: xc/lib/Xt/TMaction.c,v 3.7 2001/12/14 19:56:30 dawes Exp $ */
64
/* TMaction.c -- maintains the state table of actions for the translation
68
#include "IntrinsicI.h"
69
#include "StringDefs.h"
71
#if defined(__STDC__) && !defined(NORCONST)
77
static String XtNtranslationError = "translationError";
79
typedef struct _CompiledAction{
82
}CompiledAction, *CompiledActionTable;
85
#define GetClassActions(wc) \
86
((wc->core_class.actions) \
87
? (((TMClassCache)wc->core_class.actions)->actions) \
90
static CompiledActionTable CompileActionTable(actions, count, stat, perm)
91
register struct _XtActionsRec *actions;
92
register Cardinal count; /* may be 0 */
93
Boolean stat; /* if False, copy before compiling in place */
94
Boolean perm; /* if False, use XrmStringToQuark */
96
register CompiledActionTable cActions;
99
CompiledActionTable cTableHold;
103
return (CompiledActionTable) NULL;
104
func = (perm ? XrmPermStringToQuark : XrmStringToQuark);
107
cTableHold = cActions = (CompiledActionTable)
108
__XtMalloc(count * sizeof(CompiledAction));
110
for (i=count; --i >= 0; cActions++, actions++) {
111
cActions->proc = actions->proc;
112
cActions->signature = (*func)(actions->string);
115
cTableHold = (CompiledActionTable) actions;
117
for (i=count; --i >= 0; actions++)
118
((CompiledActionTable) actions)->signature =
119
(*func)(actions->string);
121
cActions = cTableHold;
123
/* Insertion sort. Whatever sort is used, it must be stable. */
124
for (i=1; i <= count - 1; i++) {
128
while (j && cActions[j-1].signature > hold.signature) {
129
cActions[j] = cActions[j-1];
139
typedef struct _ActionListRec *ActionList;
140
typedef struct _ActionListRec {
142
CompiledActionTable table;
146
static void ReportUnboundActions(xlations, bindData)
147
XtTranslations xlations;
150
TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
151
Cardinal num_unbound = 0;
152
Cardinal num_params = 1;
154
char messagebuf[1000];
156
register Cardinal num_chars = 0;
157
register Cardinal i, j;
160
for (i=0; i < xlations->numStateTrees; i++) {
161
if (bindData->simple.isComplex)
162
procs = TMGetComplexBindEntry(bindData, i)->procs;
164
procs = TMGetSimpleBindEntry(bindData, i)->procs;
166
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
167
for (j=0; j < stateTree->numQuarks; j++) {
168
if (procs[j] == NULL) {
169
String s = XrmQuarkToString(stateTree->quarkTbl[j]);
170
if (num_unbound != 0)
172
num_chars += strlen(s);
177
if (num_unbound == 0)
179
message = XtStackAlloc (num_chars + 1, messagebuf);
180
if (message != NULL) {
183
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
184
for (i=0; i < xlations->numStateTrees; i++) {
185
if (bindData->simple.isComplex)
186
procs = TMGetComplexBindEntry(bindData, i)->procs;
188
procs = TMGetSimpleBindEntry(bindData, i)->procs;
190
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
191
for (j=0; j < stateTree->numQuarks; j++) {
192
if (procs[j] == NULL) {
193
String s = XrmQuarkToString(stateTree->quarkTbl[j]);
194
if (num_unbound != 0)
195
(void) strcat(message, ", ");
196
(void) strcat(message, s);
201
message[num_chars] = '\0';
203
XtWarningMsg(XtNtranslationError,"unboundActions",XtCXtToolkitError,
204
"Actions not found: %s",
205
params, &num_params);
206
XtStackFree (message, messagebuf);
211
static CompiledAction *SearchActionTable(signature, actionTable, numActions)
213
CompiledActionTable actionTable;
216
register int i, left, right;
219
right = numActions - 1;
220
while (left <= right) {
221
i = (left + right) >> 1;
222
if (signature < actionTable[i].signature)
224
else if (signature > actionTable[i].signature)
227
while (i && actionTable[i - 1].signature == signature)
229
return &actionTable[i];
232
return (CompiledAction *) NULL;
235
static int BindActions(stateTree, procs, compiledActionTable, numActions, ndxP)
236
TMSimpleStateTree stateTree;
238
CompiledActionTable compiledActionTable;
239
TMShortCard numActions;
242
register int unbound = stateTree->numQuarks - *ndxP;
243
CompiledAction* action;
244
register Cardinal ndx;
245
register Boolean savedNdx = False;
247
for (ndx = *ndxP; ndx < stateTree->numQuarks; ndx++) {
248
if (procs[ndx] == NULL) {
249
/* attempt to bind it */
250
XrmQuark q = stateTree->quarkTbl[ndx];
252
action = SearchActionTable(q, compiledActionTable, numActions);
254
procs[ndx] = action->proc;
256
} else if (!savedNdx) {
261
/* already bound, leave it alone */
268
typedef struct _TMBindCacheStatusRec{
269
unsigned int boundInClass:1;
270
unsigned int boundInHierarchy:1;
271
unsigned int boundInContext:1;
272
unsigned int notFullyBound:1;
273
unsigned int refCount:28;
274
}TMBindCacheStatusRec, *TMBindCacheStatus;
276
typedef struct _TMBindCacheRec{
277
struct _TMBindCacheRec *next;
278
TMBindCacheStatusRec status;
279
TMStateTree stateTree;
281
WidgetClass widgetClass;
282
#endif /* TRACE_TM */
283
XtActionProc procs[1]; /* variable length */
284
}TMBindCacheRec, *TMBindCache;
286
typedef struct _TMClassCacheRec {
287
CompiledActionTable actions;
288
TMBindCacheRec *bindCache;
289
}TMClassCacheRec, *TMClassCache;
291
#define IsPureClassBind(bc) \
292
(bc->status.boundInClass && \
293
!(bc->status.boundInHierarchy || \
294
bc->status.boundInContext || \
295
bc->status.notFullyBound))
297
#define GetClassCache(w) \
298
((TMClassCache)w->core.widget_class->core_class.actions)
301
static int BindProcs(widget, stateTree, procs, bindStatus)
303
TMSimpleStateTree stateTree;
305
TMBindCacheStatus bindStatus;
307
register WidgetClass class;
308
register ActionList actionList;
309
int unbound = -1, newUnbound = -1;
315
class = w->core.widget_class;
317
if (class->core_class.actions != NULL)
319
BindActions(stateTree,
321
GetClassActions(class),
322
class->core_class.num_actions,
324
class = class->core_class.superclass;
325
} while (unbound != 0 && class != NULL);
326
if (unbound < (int)stateTree->numQuarks)
327
bindStatus->boundInClass = True;
329
bindStatus->boundInClass = False;
330
if (newUnbound == -1)
331
newUnbound = unbound;
333
} while (unbound != 0 && w != NULL);
335
if (newUnbound > unbound)
336
bindStatus->boundInHierarchy = True;
338
bindStatus->boundInHierarchy = False;
341
XtAppContext app = XtWidgetToApplicationContext(widget);
342
newUnbound = unbound;
343
for (actionList = app->action_table;
344
unbound != 0 && actionList != NULL;
345
actionList = actionList->next) {
346
unbound = BindActions(stateTree,
352
if (newUnbound > unbound)
353
bindStatus->boundInContext = True;
355
bindStatus->boundInContext = False;
362
static XtActionProc *TryBindCache(widget, stateTree)
364
TMStateTree stateTree;
366
TMClassCache classCache;
369
classCache = GetClassCache(widget);
371
if (classCache == NULL)
373
WidgetClass wc = XtClass(widget);
375
wc->core_class.actions = (XtActionList)
376
_XtInitializeActionData(NULL, 0, True);
380
TMBindCache bindCache =
381
(TMBindCache)(classCache->bindCache);
382
for (; bindCache; bindCache = bindCache->next)
384
if (IsPureClassBind(bindCache) &&
385
(stateTree == bindCache->stateTree))
387
bindCache->status.refCount++;
389
return &bindCache->procs[0];
400
* The class record actions field will point to the bind cache header
401
* after this call is made out of coreClassPartInit.
403
#if NeedFunctionPrototypes
404
XtPointer _XtInitializeActionData(
405
register struct _XtActionsRec *actions,
406
register Cardinal count,
410
XtPointer _XtInitializeActionData(actions, count, inPlace)
411
register struct _XtActionsRec *actions;
412
register Cardinal count;
416
TMClassCache classCache;
418
classCache = XtNew(TMClassCacheRec);
419
classCache->actions = CompileActionTable(actions, count, inPlace, True);
420
classCache->bindCache = NULL;
421
return (XtPointer)classCache;
425
#define TM_BIND_CACHE_REALLOC 2
427
static XtActionProc *EnterBindCache(w, stateTree, procs, bindStatus)
429
TMSimpleStateTree stateTree;
431
TMBindCacheStatus bindStatus;
433
TMClassCache classCache;
434
TMBindCache* bindCachePtr;
435
TMShortCard procsSize;
436
TMBindCache bindCache;
439
classCache = GetClassCache(w);
440
bindCachePtr = &classCache->bindCache;
441
procsSize = stateTree->numQuarks * sizeof(XtActionProc);
443
for (bindCache = *bindCachePtr;
445
bindCachePtr = &(*bindCachePtr)->next, bindCache = *bindCachePtr)
447
TMBindCacheStatus cacheStatus = &bindCache->status;
449
if ((bindStatus->boundInClass == cacheStatus->boundInClass) &&
450
(bindStatus->boundInHierarchy == cacheStatus->boundInHierarchy) &&
451
(bindStatus->boundInContext == cacheStatus->boundInContext) &&
452
(bindCache->stateTree == (TMStateTree)stateTree) &&
453
!XtMemcmp(&bindCache->procs[0], procs, procsSize))
455
bindCache->status.refCount++;
459
if (*bindCachePtr == NULL)
462
bindCache = (TMBindCache)
463
__XtMalloc(sizeof(TMBindCacheRec) +
464
(procsSize - sizeof(XtActionProc)));
465
bindCache->next = NULL;
466
bindCache->status = *bindStatus;
467
bindCache->status.refCount = 1;
468
bindCache->stateTree = (TMStateTree)stateTree;
470
bindCache->widgetClass = XtClass(w);
471
if (_XtGlobalTM.numBindCache == _XtGlobalTM.bindCacheTblSize)
473
_XtGlobalTM.bindCacheTblSize += 16;
474
_XtGlobalTM.bindCacheTbl = (TMBindCache *)
475
XtRealloc((char *)_XtGlobalTM.bindCacheTbl,
476
((_XtGlobalTM.bindCacheTblSize) *
477
sizeof(TMBindCache)));
479
_XtGlobalTM.bindCacheTbl[_XtGlobalTM.numBindCache++] = bindCache;
480
#endif /* TRACE_TM */
481
XtMemmove((XtPointer)&bindCache->procs[0],
482
(XtPointer)procs, procsSize);
485
return &bindCache->procs[0];
488
static void RemoveFromBindCache(w,procs)
492
TMClassCache classCache;
493
TMBindCache* bindCachePtr;
494
TMBindCache bindCache;
495
XtAppContext app = XtWidgetToApplicationContext (w);
498
classCache = GetClassCache(w);
499
bindCachePtr = (TMBindCache *)&classCache->bindCache;
501
for (bindCache = *bindCachePtr;
503
bindCachePtr = &(*bindCachePtr)->next, bindCache = *bindCachePtr)
505
if (&bindCache->procs[0] == procs)
507
if (--bindCache->status.refCount == 0)
511
Boolean found = False;
512
TMBindCache *tbl = _XtGlobalTM.bindCacheTbl;
514
for (j = 0; j < _XtGlobalTM.numBindCache; j++) {
517
if (tbl[j] == bindCache)
521
XtWarning("where's the action ??? ");
523
_XtGlobalTM.numBindCache--;
524
#endif /* TRACE_TM */
525
*bindCachePtr = bindCache->next;
526
bindCache->next = app->free_bindings;
527
app->free_bindings = bindCache;
536
static void RemoveAccelerators(widget,closure,data)
538
XtPointer closure, data;
540
Widget destination = (Widget)closure;
541
TMComplexBindProcs bindProcs;
542
XtTranslations stackXlations[16];
543
XtTranslations *xlationsList, destXlations;
544
TMShortCard i, numXlations = 0;
546
if ((destXlations = destination->core.tm.translations) == NULL) {
547
XtAppWarningMsg(XtWidgetToApplicationContext(widget),
548
XtNtranslationError,"nullTable",XtCXtToolkitError,
549
"Can't remove accelerators from NULL table",
550
(String *)NULL, (Cardinal *)NULL);
554
xlationsList = (XtTranslations *)
555
XtStackAlloc((destXlations->numStateTrees * sizeof(XtTranslations)),
558
for (i = 0, bindProcs = TMGetComplexBindEntry(destination->core.tm.proc_table, i);
559
i < destXlations->numStateTrees;
561
if (bindProcs->widget == widget) {
563
* if it's being destroyed don't do all the work
565
if (destination->core.being_destroyed) {
566
bindProcs->procs = NULL;
569
xlationsList[numXlations] = bindProcs->aXlations;
574
if (numXlations == 0)
575
XtAppWarningMsg(XtWidgetToApplicationContext(widget),
576
XtNtranslationError,"nullTable",XtCXtToolkitError,
577
"Tried to remove nonexistent accelerators",
578
(String *)NULL, (Cardinal *)NULL);
580
if (!destination->core.being_destroyed)
581
for (i = 0; i < numXlations; i++)
582
_XtUnmergeTranslations(destination, xlationsList[i]);
584
XtStackFree((char *)xlationsList, stackXlations);
587
void _XtBindActions(widget, tm)
591
XtTranslations xlations = tm->translations;
592
TMSimpleStateTree stateTree;
593
int globalUnbound = 0;
595
TMBindData bindData = (TMBindData)tm->proc_table;
596
TMSimpleBindProcs simpleBindProcs = NULL;
597
TMComplexBindProcs complexBindProcs = NULL;
598
XtActionProc *newProcs;
601
if ((xlations == NULL) || widget->core.being_destroyed)
604
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0];
606
for (i = 0; i < xlations->numStateTrees; i++)
608
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
609
if (bindData->simple.isComplex) {
610
complexBindProcs = TMGetComplexBindEntry(bindData, i);
611
if (complexBindProcs->widget) {
612
bindWidget = complexBindProcs->widget;
614
if (bindWidget->core.destroy_callbacks != NULL)
615
_XtAddCallbackOnce((InternalCallbackList *)
616
&bindWidget->core.destroy_callbacks,
620
_XtAddCallback((InternalCallbackList *)
621
&bindWidget->core.destroy_callbacks,
629
simpleBindProcs = TMGetSimpleBindEntry(bindData, i);
633
TryBindCache(bindWidget,(TMStateTree)stateTree)) == NULL)
635
XtActionProc *procs, stackProcs[256];
637
TMBindCacheStatusRec bcStatusRec;
639
procs = (XtActionProc *)
640
XtStackAlloc(stateTree->numQuarks * sizeof(XtActionProc),
642
XtBZero((XtPointer)procs,
643
stateTree->numQuarks * sizeof(XtActionProc));
645
localUnbound = BindProcs(bindWidget,
651
bcStatusRec.notFullyBound = True;
653
bcStatusRec.notFullyBound = False;
656
EnterBindCache(bindWidget,
660
XtStackFree((XtPointer)procs, (XtPointer)stackProcs);
661
globalUnbound += localUnbound;
663
if (bindData->simple.isComplex)
664
complexBindProcs->procs = newProcs;
666
simpleBindProcs->procs = newProcs;
669
ReportUnboundActions(xlations,
670
(TMBindData)tm->proc_table);
674
void _XtUnbindActions(widget, xlations, bindData)
676
XtTranslations xlations;
683
if ((xlations == NULL) || !XtIsRealized(widget)) return;
685
for (i = 0; i < xlations->numStateTrees; i++) {
686
if (bindData->simple.isComplex) {
687
TMComplexBindProcs complexBindProcs;
689
complexBindProcs = TMGetComplexBindEntry(bindData, i);
691
if (complexBindProcs->widget) {
693
* check for this being an accelerator binding whose
694
* source is gone ( set by RemoveAccelerators)
696
if (complexBindProcs->procs == NULL)
699
XtRemoveCallback(complexBindProcs->widget,
703
bindWidget = complexBindProcs->widget;
707
procs = complexBindProcs->procs;
708
complexBindProcs->procs = NULL;
711
TMSimpleBindProcs simpleBindProcs;
712
simpleBindProcs = TMGetSimpleBindEntry(bindData,i);
713
procs = simpleBindProcs->procs;
714
simpleBindProcs->procs = NULL;
717
RemoveFromBindCache(bindWidget, procs);
722
void _XtRemoveBindProcsByIndex(w, bindData, ndx)
728
TMBindProcs bindProcs = (TMBindProcs)&bindData->bindTbl[0];
730
RemoveFromBindCache(bindProcs->widget ? bindProcs->widget : w,
733
for (; i < bindData->bindTblSize; i++)
734
bindProcs[i] = bindProcs[i+1];
739
* used to free all copied action tables, called from DestroyAppContext
741
void _XtFreeActions(actions)
744
ActionList curr, next;
746
for (curr = actions; curr;) {
748
XtFree((char *)curr->table);
749
XtFree((char *)curr);
754
void XtAddActions(actions, num_actions)
755
XtActionList actions;
756
Cardinal num_actions;
758
XtAppAddActions(_XtDefaultAppContext(), actions, num_actions);
761
void XtAppAddActions(app, actions, num_actions)
763
XtActionList actions;
764
Cardinal num_actions;
766
register ActionList rec;
769
rec = XtNew(ActionListRec);
770
rec->next = app->action_table;
771
app->action_table = rec;
772
rec->table = CompileActionTable(actions, num_actions, False, False);
773
rec->count = num_actions;
777
void XtGetActionList(widget_class, actions_return, num_actions_return)
778
WidgetClass widget_class;
779
XtActionList* actions_return;
780
Cardinal* num_actions_return;
783
CompiledActionTable table;
786
*actions_return = NULL;
787
*num_actions_return = 0;
790
if (! widget_class->core_class.class_inited) {
794
if (! (widget_class->core_class.class_inited & WidgetClassFlag)) {
798
*num_actions_return = widget_class->core_class.num_actions;
799
if (*num_actions_return) {
800
list = *actions_return = (XtActionList)
801
__XtMalloc(*num_actions_return * sizeof(XtActionsRec));
802
table = GetClassActions(widget_class);
803
for (i= (*num_actions_return); --i >= 0; list++, table++) {
804
list->string = XrmQuarkToString(table->signature);
805
list->proc = table->proc;
811
/***********************************************************************
813
* Pop-up and Grab stuff
815
***********************************************************************/
817
static Widget _XtFindPopup(widget, name)
825
q = XrmStringToQuark(name);
827
for (w=widget; w != NULL; w=w->core.parent)
828
for (i=0; i<w->core.num_popups; i++)
829
if (w->core.popup_list[i]->core.xrm_name == q)
830
return w->core.popup_list[i];
835
void XtMenuPopupAction(widget, event, params, num_params)
839
Cardinal *num_params;
841
Boolean spring_loaded;
842
register Widget popup_shell;
843
XtAppContext app = XtWidgetToApplicationContext(widget);
846
if (*num_params != 1) {
848
"invalidParameters","xtMenuPopupAction",XtCXtToolkitError,
849
"MenuPopup wants exactly one argument",
850
(String *)NULL, (Cardinal *)NULL);
855
if (event->type == ButtonPress)
856
spring_loaded = True;
857
else if (event->type == KeyPress || event->type == EnterNotify)
858
spring_loaded = False;
861
"invalidPopup","unsupportedOperation",XtCXtToolkitError,
862
"Pop-up menu creation is only supported on ButtonPress, KeyPress or EnterNotify events.",
863
(String *)NULL, (Cardinal *)NULL);
868
popup_shell = _XtFindPopup(widget, params[0]);
869
if (popup_shell == NULL) {
871
"invalidPopup","xtMenuPopup",XtCXtToolkitError,
872
"Can't find popup widget \"%s\" in XtMenuPopup",
878
if (spring_loaded) _XtPopup(popup_shell, XtGrabExclusive, TRUE);
879
else _XtPopup(popup_shell, XtGrabNonexclusive, FALSE);
885
static void _XtMenuPopdownAction(widget, event, params, num_params)
889
Cardinal *num_params;
893
if (*num_params == 0) {
895
} else if (*num_params == 1) {
896
popup_shell = _XtFindPopup(widget, params[0]);
897
if (popup_shell == NULL) {
898
XtAppWarningMsg(XtWidgetToApplicationContext(widget),
899
"invalidPopup","xtMenuPopdown",XtCXtToolkitError,
900
"Can't find popup widget \"%s\" in XtMenuPopdown",
904
XtPopdown(popup_shell);
906
XtAppWarningMsg(XtWidgetToApplicationContext(widget),
907
"invalidParameters","xtMenuPopdown",XtCXtToolkitError,
908
"XtMenuPopdown called with num_params != 0 or 1",
909
(String *)NULL, (Cardinal *)NULL);
913
static XtActionsRec RConst tmActions[] = {
914
{"XtMenuPopup", XtMenuPopupAction},
915
{"XtMenuPopdown", _XtMenuPopdownAction},
916
{"MenuPopup", XtMenuPopupAction}, /* old & obsolete */
917
{"MenuPopdown", _XtMenuPopdownAction}, /* ditto */
919
{"XtDisplayTranslations", _XtDisplayTranslations},
920
{"XtDisplayAccelerators", _XtDisplayAccelerators},
921
{"XtDisplayInstalledAccelerators", _XtDisplayInstalledAccelerators},
926
void _XtPopupInitialize(app)
929
register ActionList rec;
932
* The _XtGlobalTM.newMatchSemantics flag determines whether
933
* we support old or new matching
934
* behavior. This is mainly an issue of whether subsequent lhs will
935
* get pushed up in the match table if a lhs containing thier initial
936
* sequence has already been encountered. Currently inited to False;
939
_XtGlobalTM.newMatchSemantics = True;
941
_XtGlobalTM.newMatchSemantics = False;
944
rec = XtNew(ActionListRec);
945
rec->next = app->action_table;
946
app->action_table = rec;
948
rec->table = CompileActionTable(tmActions, XtNumber(tmActions), False,
950
rec->count = XtNumber(tmActions);
952
_XtGrabInitialize(app);
956
#if NeedFunctionPrototypes
957
void XtCallActionProc(
959
_Xconst char* action,
965
void XtCallActionProc(widget, action, event, params, num_params)
973
CompiledAction* actionP;
974
XrmQuark q = XrmStringToQuark(action);
976
XtAppContext app = XtWidgetToApplicationContext(widget);
977
ActionList actionList;
981
XtCheckSubclass(widget, coreWidgetClass,
982
"XtCallActionProc first argument is not a subclass of Core");
985
WidgetClass class = XtClass(w);
987
if ((actionP = GetClassActions(class)) != NULL)
989
i < class->core_class.num_actions;
992
if (actionP->signature == q) {
993
ActionHook hook = app->action_hook_list;
994
while (hook != NULL) {
995
(*hook->proc)( widget,
1005
(widget, event, params, &num_params);
1011
class = class->core_class.superclass;
1012
} while (class != NULL);
1014
} while (w != NULL);
1017
for (actionList = app->action_table;
1019
actionList = actionList->next) {
1021
for (i = 0, actionP = actionList->table;
1022
i < actionList->count;
1024
if (actionP->signature == q) {
1025
ActionHook hook = app->action_hook_list;
1026
while (hook != NULL) {
1027
(*hook->proc)( widget,
1037
(widget, event, params, &num_params);
1047
Cardinal num_params = 2;
1048
params[0] = (String)action;
1049
params[1] = XtName(widget);
1050
XtAppWarningMsg(app,
1051
"noActionProc", "xtCallActionProc", XtCXtToolkitError,
1052
"No action proc named \"%s\" is registered for widget \"%s\"",
1059
void _XtDoFreeBindings(app)
1064
while (app->free_bindings) {
1065
bcp = app->free_bindings->next;
1066
XtFree ((char *) app->free_bindings);
1067
app->free_bindings = bcp;