diff options
| author | Richard M. Stallman | 1995-04-07 03:39:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-04-07 03:39:07 +0000 |
| commit | bd3a4da28367777535de354eb7e4917339db23eb (patch) | |
| tree | 730db1d65ced88a0dea5e3e5a79d585c89f43a0a | |
| parent | 8217c647680d17e71725fbb6fc43fc3dde571e80 (diff) | |
| download | emacs-bd3a4da28367777535de354eb7e4917339db23eb.tar.gz emacs-bd3a4da28367777535de354eb7e4917339db23eb.zip | |
(frame_vector): New static variable.
(syms_of_xmenu): staticpro it.
(frame_vector_add_frame): New function.
(set_frame_menubar): Use frame_vector; use index as the widget id.
(free_frame_menubar): Likewise. Remove the frame from frame_vector.
(menubar_selection_callback): Use frame_vector to turn id into frame.
| -rw-r--r-- | src/xmenu.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index 02b66b1b85b..f6e593044ce 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -151,6 +151,47 @@ static int menu_items_submenu_depth; | |||
| 151 | Xt on behalf of one of the widget sets. */ | 151 | Xt on behalf of one of the widget sets. */ |
| 152 | static int popup_activated_flag; | 152 | static int popup_activated_flag; |
| 153 | 153 | ||
| 154 | /* This holds a Lisp vector | ||
| 155 | which contains frames that have menu bars. | ||
| 156 | Each frame that has a menu bar is found at some index in this vector | ||
| 157 | and the menu bar widget refers to the frame through that index. */ | ||
| 158 | static Lisp_Object frame_vector; | ||
| 159 | |||
| 160 | /* Return the index of FRAME in frame_vector. | ||
| 161 | If FRAME isn't in frame_vector yet, put it in, | ||
| 162 | lengthening the vector if necessary. */ | ||
| 163 | |||
| 164 | static int | ||
| 165 | frame_vector_add_frame (f) | ||
| 166 | FRAME_PTR *f; | ||
| 167 | { | ||
| 168 | int length = XVECTOR (frame_vector)->size; | ||
| 169 | int i, empty = -1; | ||
| 170 | Lisp_Object new, frame; | ||
| 171 | |||
| 172 | XSETFRAME (frame, f); | ||
| 173 | |||
| 174 | for (i = 0; i < length; i++) | ||
| 175 | { | ||
| 176 | if (EQ (frame, XVECTOR (frame_vector)->contents[i])) | ||
| 177 | return i; | ||
| 178 | if (NILP (XVECTOR (frame_vector)->contents[i])) | ||
| 179 | empty = i; | ||
| 180 | } | ||
| 181 | |||
| 182 | if (empty >= 0) | ||
| 183 | { | ||
| 184 | XVECTOR (frame_vector)->contents[empty] = frame; | ||
| 185 | return empty; | ||
| 186 | } | ||
| 187 | |||
| 188 | new = Fmake_vector (make_number (length * 2), Qnil); | ||
| 189 | bcopy (XVECTOR (frame_vector)->contents, | ||
| 190 | XVECTOR (new)->contents, sizeof (Lisp_Object) * length); | ||
| 191 | |||
| 192 | XVECTOR (frame_vector)->contents[length] = frame; | ||
| 193 | return length; | ||
| 194 | } | ||
| 154 | 195 | ||
| 155 | /* Initialize the menu_items structure if we haven't already done so. | 196 | /* Initialize the menu_items structure if we haven't already done so. |
| 156 | Also mark it as currently empty. */ | 197 | Also mark it as currently empty. */ |
| @@ -1060,7 +1101,7 @@ menubar_selection_callback (widget, id, client_data) | |||
| 1060 | XtPointer client_data; | 1101 | XtPointer client_data; |
| 1061 | { | 1102 | { |
| 1062 | Lisp_Object prefix; | 1103 | Lisp_Object prefix; |
| 1063 | FRAME_PTR f = (FRAME_PTR) id; | 1104 | FRAME_PTR f = XFRAME (XVECTOR (frame_vector)->contents[id]); |
| 1064 | Lisp_Object vector; | 1105 | Lisp_Object vector; |
| 1065 | Lisp_Object *subprefix_stack; | 1106 | Lisp_Object *subprefix_stack; |
| 1066 | int submenu_depth = 0; | 1107 | int submenu_depth = 0; |
| @@ -1378,10 +1419,12 @@ set_frame_menubar (f, first_time) | |||
| 1378 | int first_time; | 1419 | int first_time; |
| 1379 | { | 1420 | { |
| 1380 | Widget menubar_widget = f->display.x->menubar_widget; | 1421 | Widget menubar_widget = f->display.x->menubar_widget; |
| 1381 | int id = (int) f; | 1422 | Lisp_Object tail, items, frame; |
| 1382 | Lisp_Object tail, items; | ||
| 1383 | widget_value *wv, *first_wv, *prev_wv = 0; | 1423 | widget_value *wv, *first_wv, *prev_wv = 0; |
| 1384 | int i; | 1424 | int i; |
| 1425 | int id; | ||
| 1426 | |||
| 1427 | id = frame_vector_add_frame (f); | ||
| 1385 | 1428 | ||
| 1386 | BLOCK_INPUT; | 1429 | BLOCK_INPUT; |
| 1387 | 1430 | ||
| @@ -1493,12 +1536,13 @@ free_frame_menubar (f) | |||
| 1493 | int id; | 1536 | int id; |
| 1494 | 1537 | ||
| 1495 | menubar_widget = f->display.x->menubar_widget; | 1538 | menubar_widget = f->display.x->menubar_widget; |
| 1496 | id = (int) f; | ||
| 1497 | 1539 | ||
| 1498 | if (menubar_widget) | 1540 | if (menubar_widget) |
| 1499 | { | 1541 | { |
| 1542 | id = frame_vector_add_frame (f); | ||
| 1500 | BLOCK_INPUT; | 1543 | BLOCK_INPUT; |
| 1501 | lw_destroy_all_widgets (id); | 1544 | lw_destroy_all_widgets (id); |
| 1545 | XVECTOR (frame_vector)->contents[id] = Qnil; | ||
| 1502 | UNBLOCK_INPUT; | 1546 | UNBLOCK_INPUT; |
| 1503 | } | 1547 | } |
| 1504 | } | 1548 | } |
| @@ -2352,6 +2396,9 @@ syms_of_xmenu () | |||
| 2352 | widget_id_tick = (1<<16); | 2396 | widget_id_tick = (1<<16); |
| 2353 | #endif | 2397 | #endif |
| 2354 | 2398 | ||
| 2399 | staticpro (&frame_vector); | ||
| 2400 | frame_vector = Fmake_vector (make_number (10), Qnil); | ||
| 2401 | |||
| 2355 | defsubr (&Sx_popup_menu); | 2402 | defsubr (&Sx_popup_menu); |
| 2356 | defsubr (&Sx_popup_dialog); | 2403 | defsubr (&Sx_popup_dialog); |
| 2357 | } | 2404 | } |