diff options
| author | Jan Djärv | 2006-05-29 07:11:35 +0000 |
|---|---|---|
| committer | Jan Djärv | 2006-05-29 07:11:35 +0000 |
| commit | 22badffeec095599bba694dcf8807b129fd4a07e (patch) | |
| tree | 29c856270ed99238c40a7aa52b40bec3de4552aa /src/xmenu.c | |
| parent | 31c5f81f89f54ffe03dcbe3df26a3f9560d68cbf (diff) | |
| download | emacs-22badffeec095599bba694dcf8807b129fd4a07e.tar.gz emacs-22badffeec095599bba694dcf8807b129fd4a07e.zip | |
(Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Diffstat (limited to 'src/xmenu.c')
| -rw-r--r-- | src/xmenu.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index c740062a82f..90fa1595cd9 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -1301,9 +1301,117 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers) | |||
| 1301 | } | 1301 | } |
| 1302 | } | 1302 | } |
| 1303 | 1303 | ||
| 1304 | DEFUN ("menu-bar-start", Fmenu_bar_start, Smenu_bar_start, 0, 1, "i", | ||
| 1305 | doc: /* Start key navigation of the menu bar in FRAME. | ||
| 1306 | This initially opens the first menu bar item and you can then navigate with the | ||
| 1307 | arrow keys, select a menu entry with the return key or cancel with the | ||
| 1308 | escape key. If FRAME has no menu bar this function does nothing. | ||
| 1309 | |||
| 1310 | If FRAME is nil or not given, use the selected frame. */) | ||
| 1311 | (frame) | ||
| 1312 | Lisp_Object frame; | ||
| 1313 | { | ||
| 1314 | XEvent ev; | ||
| 1315 | FRAME_PTR f = check_x_frame (frame); | ||
| 1316 | Widget menubar; | ||
| 1317 | BLOCK_INPUT; | ||
| 1318 | |||
| 1319 | if (FRAME_EXTERNAL_MENU_BAR (f)) | ||
| 1320 | set_frame_menubar (f, 0, 1); | ||
| 1321 | |||
| 1322 | menubar = FRAME_X_OUTPUT (f)->menubar_widget; | ||
| 1323 | if (menubar) | ||
| 1324 | { | ||
| 1325 | Window child; | ||
| 1326 | int error_p = 0; | ||
| 1327 | |||
| 1328 | x_catch_errors (FRAME_X_DISPLAY (f)); | ||
| 1329 | memset (&ev, 0, sizeof ev); | ||
| 1330 | ev.xbutton.display = FRAME_X_DISPLAY (f); | ||
| 1331 | ev.xbutton.window = XtWindow (menubar); | ||
| 1332 | ev.xbutton.root = FRAME_X_DISPLAY_INFO (f)->root_window; | ||
| 1333 | ev.xbutton.time = XtLastTimestampProcessed (FRAME_X_DISPLAY (f)); | ||
| 1334 | ev.xbutton.button = Button1; | ||
| 1335 | ev.xbutton.x = ev.xbutton.y = FRAME_MENUBAR_HEIGHT (f) / 2; | ||
| 1336 | ev.xbutton.same_screen = True; | ||
| 1337 | |||
| 1338 | #ifdef USE_MOTIF | ||
| 1339 | { | ||
| 1340 | Arg al[2]; | ||
| 1341 | WidgetList list; | ||
| 1342 | Cardinal nr; | ||
| 1343 | XtSetArg (al[0], XtNchildren, &list); | ||
| 1344 | XtSetArg (al[1], XtNnumChildren, &nr); | ||
| 1345 | XtGetValues (menubar, al, 2); | ||
| 1346 | ev.xbutton.window = XtWindow (list[0]); | ||
| 1347 | } | ||
| 1348 | #endif | ||
| 1349 | |||
| 1350 | XTranslateCoordinates (FRAME_X_DISPLAY (f), | ||
| 1351 | /* From-window, to-window. */ | ||
| 1352 | ev.xbutton.window, ev.xbutton.root, | ||
| 1353 | |||
| 1354 | /* From-position, to-position. */ | ||
| 1355 | ev.xbutton.x, ev.xbutton.y, | ||
| 1356 | &ev.xbutton.x_root, &ev.xbutton.y_root, | ||
| 1357 | |||
| 1358 | /* Child of win. */ | ||
| 1359 | &child); | ||
| 1360 | error_p = x_had_errors_p (FRAME_X_DISPLAY (f)); | ||
| 1361 | x_uncatch_errors (); | ||
| 1362 | |||
| 1363 | if (! error_p) | ||
| 1364 | { | ||
| 1365 | ev.type = ButtonPress; | ||
| 1366 | ev.xbutton.state = 0; | ||
| 1367 | |||
| 1368 | XtDispatchEvent (&ev); | ||
| 1369 | ev.xbutton.type = ButtonRelease; | ||
| 1370 | ev.xbutton.state = Button1Mask; | ||
| 1371 | XtDispatchEvent (&ev); | ||
| 1372 | } | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | UNBLOCK_INPUT; | ||
| 1376 | } | ||
| 1304 | #endif /* USE_X_TOOLKIT */ | 1377 | #endif /* USE_X_TOOLKIT */ |
| 1305 | 1378 | ||
| 1379 | |||
| 1306 | #ifdef USE_GTK | 1380 | #ifdef USE_GTK |
| 1381 | DEFUN ("menu-bar-start", Fmenu_bar_start, Smenu_bar_start, 0, 1, "i", | ||
| 1382 | doc: /* Start key navigation of the menu bar in FRAME. | ||
| 1383 | This initially opens the first menu bar item and you can then navigate with the | ||
| 1384 | arrow keys, select a menu entry with the return key or cancel with the | ||
| 1385 | escape key. If FRAME has no menu bar this function does nothing. | ||
| 1386 | |||
| 1387 | If FRAME is nil or not given, use the selected frame. */) | ||
| 1388 | (frame) | ||
| 1389 | Lisp_Object frame; | ||
| 1390 | { | ||
| 1391 | GtkWidget *menubar; | ||
| 1392 | BLOCK_INPUT; | ||
| 1393 | FRAME_PTR f = check_x_frame (frame); | ||
| 1394 | |||
| 1395 | if (FRAME_EXTERNAL_MENU_BAR (f)) | ||
| 1396 | set_frame_menubar (f, 0, 1); | ||
| 1397 | |||
| 1398 | menubar = FRAME_X_OUTPUT (f)->menubar_widget; | ||
| 1399 | if (menubar) | ||
| 1400 | { | ||
| 1401 | /* Activate the first menu. */ | ||
| 1402 | GList *children = gtk_container_get_children (GTK_CONTAINER (menubar)); | ||
| 1403 | |||
| 1404 | gtk_menu_shell_select_item (GTK_MENU_SHELL (menubar), | ||
| 1405 | GTK_WIDGET (children->data)); | ||
| 1406 | |||
| 1407 | popup_activated_flag = 1; | ||
| 1408 | g_list_free (children); | ||
| 1409 | } | ||
| 1410 | UNBLOCK_INPUT; | ||
| 1411 | |||
| 1412 | return Qnil; | ||
| 1413 | } | ||
| 1414 | |||
| 1307 | /* Loop util popup_activated_flag is set to zero in a callback. | 1415 | /* Loop util popup_activated_flag is set to zero in a callback. |
| 1308 | Used for popup menus and dialogs. */ | 1416 | Used for popup menus and dialogs. */ |
| 1309 | 1417 | ||
| @@ -3659,6 +3767,11 @@ The enable predicate for a menu command should check this variable. */); | |||
| 3659 | #endif | 3767 | #endif |
| 3660 | 3768 | ||
| 3661 | defsubr (&Sx_popup_menu); | 3769 | defsubr (&Sx_popup_menu); |
| 3770 | |||
| 3771 | #if defined (USE_GTK) || defined (USE_X_TOOLKIT) | ||
| 3772 | defsubr (&Smenu_bar_start); | ||
| 3773 | #endif | ||
| 3774 | |||
| 3662 | #ifdef HAVE_MENUS | 3775 | #ifdef HAVE_MENUS |
| 3663 | defsubr (&Sx_popup_dialog); | 3776 | defsubr (&Sx_popup_dialog); |
| 3664 | #endif | 3777 | #endif |