cl-delete-duplicates: Parse :if to have cl-if bound
[emacs.git] / oldXMenu / Locate.c
blob1605b4bbb299154674dd671adba1496634ffbf75
1 /* Copyright Massachusetts Institute of Technology 1985 */
3 #include "copyright.h"
6 /*
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuLocate - Return data necessary to position and locate
10 * a menu on the screen.
12 * Author: Tony Della Fera, DEC
13 * January 11, 1985
17 #include "XMenuInt.h"
19 int
20 XMenuLocate(register Display *display, register XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height)
21 /* Previously opened display. */
22 /* Menu object being located. */
23 /* Active pane number. */
24 /* Active selection number. */
25 /* X coordinate of mouse active position. */
26 /* Y coordinate of mouse active position. */
27 /* Returned upper left menu X coordinate. */
28 /* Returned upper left menu Y coordinate. */
29 /* Returned menu width. */
30 /* Returned menu height. */
32 register XMPane *p_ptr; /* XMPane pointer. */
33 register XMSelect *s_ptr; /* XMSelect pointer. */
36 * Are the position arguments positive?
38 if ((x_pos <= 0) || (y_pos <= 0)) {
39 _XMErrorCode = XME_ARG_BOUNDS;
40 return(XM_FAILURE);
44 * Find the right pane.
46 p_ptr = _XMGetPanePtr(menu, p_num);
47 if (p_ptr == NULL) return(XM_FAILURE);
50 * Find the right selection.
52 s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
55 * Check to see that the menu's dependencies have been
56 * recomputed and are up to date. If not, do it now.
58 if (menu->recompute) XMenuRecompute(display, menu);
61 * Compute the new menu origin such that the active point lies
62 * in the center of the desired active pane and selection.
63 * This sets the values of ul_x and ul_y.
65 _XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, ul_x, ul_y);
68 * Set remaining return argument values.
70 *width = menu->width;
71 *height = menu->height;
74 * Return successfully.
76 _XMErrorCode = XME_NO_ERROR;
77 return(XM_SUCCESS);