ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/menubar.C
(Generate patch)

Comparing rxvt-unicode/src/menubar.C (file contents):
Revision 1.8 by pcg, Fri Feb 13 12:16:21 2004 UTC vs.
Revision 1.12 by pcg, Wed Mar 3 04:07:52 2004 UTC

21 * refer.html (or refer.txt) contains up-to-date documentation. The 21 * refer.html (or refer.txt) contains up-to-date documentation. The
22 * summary that appears at the end of this file was taken from there. 22 * summary that appears at the end of this file was taken from there.
23 *----------------------------------------------------------------------*/ 23 *----------------------------------------------------------------------*/
24 24
25#include "../config.h" /* NECESSARY */ 25#include "../config.h" /* NECESSARY */
26
27#include <stdlib.h>
28#include <wchar.h>
29
26#include "rxvt.h" /* NECESSARY */ 30#include "rxvt.h" /* NECESSARY */
27#ifdef MENUBAR 31#ifdef MENUBAR
28#include "version.h" 32#include "version.h"
29#include "menubar.h" 33#include "menubar.h"
30#include "menubar.intpro" /* PROTOS for internal routines */ 34#include "menubar.intpro" /* PROTOS for internal routines */
43 { 'd', "\003\033[B" }, 47 { 'd', "\003\033[B" },
44 { 'r', "\003\033[C" } 48 { 'r', "\003\033[C" }
45 }; 49 };
46 50
47/*}}} */ 51/*}}} */
52
53static void
54draw_string (rxvt_drawable &d, GC gc, rxvt_fontset *fs, int x, int y, char *str, int len)
55{
56 mbstate mbs;
57
58 while (len)
59 {
60 wchar_t w;
61 int l = mbrtowc (&w, str, len, mbs);
62
63 if (l <= 0)
64 break;
65
66 len -= l;
67 str += l;
68
69 rxvt_font *font = (*fs)[fs->find_font (w)];
70 text_t ch = w;
71 font->draw (d, x, y, &ch, 1, Color_bg, Color_scroll);
72
73 x += font->width * wcwidth (w);
74 }
75}
48 76
49/* 77/*
50 * find an item called NAME in MENU 78 * find an item called NAME in MENU
51 */ 79 */
52menuitem_t * 80menuitem_t *
328 unsigned int len; 356 unsigned int len;
329 357
330 if (!parse[i].len) 358 if (!parse[i].len)
331 continue; 359 continue;
332 360
333 str = rxvt_malloc (parse[i].len + xtra_len + 1); 361 str = (unsigned char *) rxvt_malloc (parse[i].len + xtra_len + 1);
334 362
335 len = 0; 363 len = 0;
336 if (beg.len) 364 if (beg.len)
337 { 365 {
338 STRNCPY (str + len, beg.str, beg.len); 366 STRNCPY (str + len, beg.str, beg.len);
406 434
407 item->len2 = 0; 435 item->len2 = 0;
408 item->name2 = NULL; 436 item->name2 = NULL;
409 437
410 len = STRLEN (name); 438 len = STRLEN (name);
411 item->name = rxvt_malloc (len + 1); 439 item->name = (char *)rxvt_malloc (len + 1);
412 STRCPY (item->name, name); 440 STRCPY (item->name, name);
413 if (name[0] == '.' && name[1] != '.') 441 if (name[0] == '.' && name[1] != '.')
414 len = 0; /* hidden menu name */ 442 len = 0; /* hidden menu name */
415 item->len = len; 443 item->len = len;
416 444
434 len = STRLEN (name2); 462 len = STRLEN (name2);
435 if (len == 0) 463 if (len == 0)
436 item->name2 = NULL; 464 item->name2 = NULL;
437 else 465 else
438 { 466 {
439 item->name2 = rxvt_malloc (len + 1); 467 item->name2 = (char *)rxvt_malloc (len + 1);
440 STRCPY (item->name2, name2); 468 STRCPY (item->name2, name2);
441 } 469 }
442 item->len2 = len; 470 item->len2 = len;
443 } 471 }
444 item->entry.type = MenuLabel; 472 item->entry.type = MenuLabel;
449 action = item->name2; 477 action = item->name2;
450 len = item->len2; 478 len = item->len2;
451 } 479 }
452 if (len) 480 if (len)
453 { 481 {
454 unsigned char *str = rxvt_malloc (len + 1); 482 unsigned char *str = (unsigned char *)rxvt_malloc (len + 1);
455 483
456 STRCPY (str, action); 484 STRCPY (str, action);
457 485
458 if (rxvt_action_type (& (item->entry.action), str) < 0) 486 if (rxvt_action_type (& (item->entry.action), str) < 0)
459 free (str); 487 free (str);
491 { 519 {
492 p++; 520 p++;
493 if (*p == '/') 521 if (*p == '/')
494 path = p; 522 path = p;
495 } 523 }
524
496 if (path[0] == '/') 525 if (path[0] == '/')
497 { 526 {
498 path++; 527 path++;
499 *menu = NULL; 528 *menu = NULL;
500 } 529 }
530
501 while ((p = STRCHR (path, '/')) != NULL) 531 while ((p = STRCHR (path, '/')) != NULL)
502 { 532 {
503 p[0] = '\0'; 533 p[0] = '\0';
504 if (path[0] == '\0') 534 if (path[0] == '\0')
505 return NULL; 535 return NULL;
536
506 if (!STRCMP (path, DOT)) 537 if (!STRCMP (path, DOT))
507 { 538 {
508 /* nothing to do */ 539 /* nothing to do */
509 } 540 }
510 else if (!STRCMP (path, DOTS)) 541 else if (!STRCMP (path, DOTS))
523 } 554 }
524 555
525 path = (p + 1); 556 path = (p + 1);
526 } 557 }
527 } 558 }
559
528 if (!STRCMP (path, DOTS)) 560 if (!STRCMP (path, DOTS))
529 { 561 {
530 path += STRLEN (DOTS); 562 path += STRLEN (DOTS);
531 if (*menu != NULL) 563 if (*menu != NULL)
532 *menu = (*menu)->parent; 564 *menu = (*menu)->parent;
533 return path; 565 return path;
534 } 566 }
567
535 /* find this menu */ 568 /* find this menu */
536 if (*menu == NULL) 569 if (*menu == NULL)
537 { 570 {
538 for (m = CurrentBar->tail; m != NULL; m = m->prev) 571 for (m = CurrentBar->tail; m != NULL; m = m->prev)
539 {
540 if (!STRCMP (path, m->name)) 572 if (!STRCMP (path, m->name))
541 break; 573 break;
542 }
543 } 574 }
544 else 575 else
545 { 576 {
546 /* find this menu */ 577 /* find this menu */
547 for (item = (*menu)->tail; item != NULL; item = item->prev) 578 for (item = (*menu)->tail; item != NULL; item = item->prev)
552 m = (item->entry.submenu.menu); 583 m = (item->entry.submenu.menu);
553 break; 584 break;
554 } 585 }
555 } 586 }
556 } 587 }
588
557 if (m != NULL) 589 if (m != NULL)
558 { 590 {
559 *menu = m; 591 *menu = m;
560 path += STRLEN (path); 592 path += STRLEN (path);
561 } 593 }
594
562 return path; 595 return path;
563} 596}
564 597
565/* 598/*
566 * delete this entire menu 599 * delete this entire menu
568menu_t * 601menu_t *
569rxvt_term::menu_delete (menu_t *menu) 602rxvt_term::menu_delete (menu_t *menu)
570{ 603{
571 menu_t *parent = NULL, *prev, *next; 604 menu_t *parent = NULL, *prev, *next;
572 menuitem_t *item; 605 menuitem_t *item;
573 bar_t *CurrentBar = CurrentBar;
574 606
575#ifdef DEBUG_STRICT 607#ifdef DEBUG_STRICT
576 assert (CurrentBar != NULL); 608 assert (CurrentBar != NULL);
577#endif 609#endif
578 610
618 } 650 }
619 651
620 item = menu->tail; 652 item = menu->tail;
621 while (item != NULL) 653 while (item != NULL)
622 { 654 {
623 menuitem_t *p = item->prev; 655 menuitem_t *p = item->prev;
624 656
625 menuitem_free (menu, item); 657 menuitem_free (menu, item);
626 item = p; 658 item = p;
627 } 659 }
628 660
629 if (menu->name != NULL)
630 free (menu->name); 661 free (menu->name);
631 free (menu); 662 free (menu);
632 663
633 return parent; 664 return parent;
634} 665}
635 666
636menu_t * 667menu_t *
637rxvt_term::menu_add (menu_t *parent, char *path) 668rxvt_term::menu_add (menu_t *parent, char *path)
638{ 669{
639 menu_t *menu; 670 menu_t *menu;
640 bar_t *CurrentBar = CurrentBar;
641 671
642#ifdef DEBUG_STRICT 672#ifdef DEBUG_STRICT
643 assert (CurrentBar != NULL); 673 assert (CurrentBar != NULL);
644#endif 674#endif
645 675
646 if (STRCHR (path, '/') != NULL) 676 if (STRCHR (path, '/') != NULL)
647 { 677 {
648 char *p; 678 char *p;
649 679
650 if (path[0] == '/') 680 if (path[0] == '/')
651 { 681 {
652 /* shouldn't happen */ 682 /* shouldn't happen */
653 path++; 683 path++;
673 menu = (menu_t *) rxvt_malloc (sizeof (menu_t)); 703 menu = (menu_t *) rxvt_malloc (sizeof (menu_t));
674 704
675 menu->width = 0; 705 menu->width = 0;
676 menu->parent = parent; 706 menu->parent = parent;
677 menu->len = STRLEN (path); 707 menu->len = STRLEN (path);
678 menu->name = rxvt_malloc ((menu->len + 1)); 708 menu->name = (char *)rxvt_malloc ((menu->len + 1));
679 STRCPY (menu->name, path); 709 STRCPY (menu->name, path);
680 710
681 /* initialize head/tail */ 711 /* initialize head/tail */
682 menu->head = menu->tail = NULL; 712 menu->head = menu->tail = NULL;
683 menu->prev = menu->next = NULL; 713 menu->prev = menu->next = NULL;
684 714
685 menu->win = None; 715 menu->win = None;
716 menu->drawable = 0;
686 menu->x = menu->y = menu->w = menu->h = 0; 717 menu->x = menu->y = menu->w = menu->h = 0;
687 menu->item = NULL; 718 menu->item = NULL;
688 719
689 /* add to tail of list */ 720 /* add to tail of list */
690 if (parent == NULL) 721 if (parent == NULL)
779 w = Height2Pixel (1) - 2 * SHADOW; 810 w = Height2Pixel (1) - 2 * SHADOW;
780 811
781 x -= SHADOW + (3 * w / 2); 812 x -= SHADOW + (3 * w / 2);
782 y += SHADOW * 3; 813 y += SHADOW * 3;
783 814
784 rxvt_Draw_Triangle (display->display, ActiveMenu->win, top, bot, x, y, w, 815 rxvt_Draw_Triangle (display->display, ActiveMenu->win, top, bot, x, y, w, 'r');
785 'r');
786} 816}
787 817
788void 818void
789rxvt_term::drawbox_menuitem (int y, int state) 819rxvt_term::drawbox_menuitem (int y, int state)
790{ 820{
822 if (menu == NULL) 852 if (menu == NULL)
823 { 853 {
824 fprintf (stderr, "Top Level menu\n"); 854 fprintf (stderr, "Top Level menu\n");
825 return; 855 return;
826 } 856 }
857
827 fprintf (stderr, "menu %s ", menu->name); 858 fprintf (stderr, "menu %s ", menu->name);
828 if (menu->parent != NULL) 859 if (menu->parent != NULL)
829 { 860 {
830 menuitem_t *item; 861 menuitem_t *item;
831 862
835 && item->entry.submenu.menu == menu) 866 && item->entry.submenu.menu == menu)
836 { 867 {
837 break; 868 break;
838 } 869 }
839 } 870 }
871
840 if (item == NULL) 872 if (item == NULL)
841 { 873 {
842 fprintf (stderr, "is an orphan!\n"); 874 fprintf (stderr, "is an orphan!\n");
843 return; 875 return;
844 } 876 }
845 } 877 }
878
846 fprintf (stderr, "\n"); 879 fprintf (stderr, "\n");
847 rxvt_print_menu_ancestors (menu->parent); 880 rxvt_print_menu_ancestors (menu->parent);
848} 881}
849 882
850void 883void
893 926
894/* pop up/down the current menu and redraw the menuBar button */ 927/* pop up/down the current menu and redraw the menuBar button */
895void 928void
896rxvt_term::menu_show () 929rxvt_term::menu_show ()
897{ 930{
898 int x, y, xright; 931 int x, y, xright;
899 menu_t *ActiveMenu = ActiveMenu;
900 menuitem_t *item; 932 menuitem_t *item;
901 933
902 if (ActiveMenu == NULL) 934 if (ActiveMenu == NULL)
903 return; 935 return;
904 936
905 x = ActiveMenu->x; 937 x = ActiveMenu->x;
920 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next) 952 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next)
921 h += isSeparator (item->name) ? HEIGHT_SEPARATOR 953 h += isSeparator (item->name) ? HEIGHT_SEPARATOR
922 : HEIGHT_TEXT + 2 * SHADOW; 954 : HEIGHT_TEXT + 2 * SHADOW;
923 ActiveMenu->h = h + 2 * SHADOW; 955 ActiveMenu->h = h + 2 * SHADOW;
924 } 956 }
957
925 if (ActiveMenu->win == None) 958 if (ActiveMenu->win == None)
926 { 959 {
927 ActiveMenu->win = XCreateSimpleWindow (display->display, TermWin.vt, 960 ActiveMenu->win = XCreateSimpleWindow (display->display, TermWin.vt,
928 x, ActiveMenu->y, 961 x, ActiveMenu->y,
929 ActiveMenu->w, ActiveMenu->h, 962 ActiveMenu->w, ActiveMenu->h,
930 0, 963 0,
931 PixColors[Color_fg], 964 PixColors[Color_fg],
932 PixColors[Color_scroll]); 965 PixColors[Color_scroll]);
966 ActiveMenu->drawable = new rxvt_drawable (display, ActiveMenu->win);
933 XMapWindow (display->display, ActiveMenu->win); 967 XMapWindow (display->display, ActiveMenu->win);
934 } 968 }
969
935 rxvt_Draw_Shadow (display->display, ActiveMenu->win, 970 rxvt_Draw_Shadow (display->display, ActiveMenu->win,
936 topShadowGC, botShadowGC, 971 topShadowGC, botShadowGC,
937 0, 0, ActiveMenu->w, ActiveMenu->h); 972 0, 0, ActiveMenu->w, ActiveMenu->h);
938 973
939 /* determine the correct right-alignment */ 974 /* determine the correct right-alignment */
941 if (item->len2 > xright) 976 if (item->len2 > xright)
942 xright = item->len2; 977 xright = item->len2;
943 978
944 for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next) 979 for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next)
945 { 980 {
946 const int xoff = (SHADOW + Width2Pixel (HSPACE) / 2); 981 const int xoff = (SHADOW + Width2Pixel (HSPACE) / 2);
947 register int h; 982 register int h;
948 GC gc = menubarGC; 983 GC gc = menubarGC;
949 984
950 if (isSeparator (item->name)) 985 if (isSeparator (item->name))
951 { 986 {
952 rxvt_Draw_Shadow (display->display, ActiveMenu->win, 987 rxvt_Draw_Shadow (display->display, ActiveMenu->win,
953 topShadowGC, botShadowGC, 988 topShadowGC, botShadowGC,
959 { 994 {
960 char *name = item->name; 995 char *name = item->name;
961 int len = item->len; 996 int len = item->len;
962 997
963 if (item->entry.type == MenuLabel) 998 if (item->entry.type == MenuLabel)
964 {
965 gc = botShadowGC; 999 gc = botShadowGC;
966 }
967 else if (item->entry.type == MenuSubMenu) 1000 else if (item->entry.type == MenuSubMenu)
968 { 1001 {
969 int x1, y1; 1002 int x1, y1;
970 menuitem_t *it; 1003 menuitem_t *it;
971 menu_t *menu = item->entry.submenu.menu; 1004 menu_t *menu = item->entry.submenu.menu;
1003 } 1036 }
1004 else if (item->name2 && !STRCMP (name, item->name2)) 1037 else if (item->name2 && !STRCMP (name, item->name2))
1005 name = NULL; 1038 name = NULL;
1006 1039
1007 if (len && name) 1040 if (len && name)
1008 { 1041 draw_string (*ActiveMenu->drawable, gc, TermWin.fontset,
1009#ifdef USE_XIM
1010 if (TermWin.fontset)
1011 XmbDrawString (display->display,
1012 ActiveMenu->win, TermWin.fontset,
1013 gc, xoff,
1014 2 * SHADOW + y + TermWin.font->ascent + 1,
1015 name, len);
1016 else
1017#endif
1018 XDrawString (display->display, ActiveMenu->win, gc, xoff,
1019 2 * SHADOW + y + TermWin.font->ascent + 1,
1020 name, len); 1042 xoff, 2 * SHADOW + y, name, len);
1021 }
1022 1043
1023 len = item->len2; 1044 len = item->len2;
1024 name = item->name2; 1045 name = item->name2;
1046
1025 if (len && name) 1047 if (len && name)
1026 { 1048 draw_string (*ActiveMenu->drawable, gc, TermWin.fontset,
1027#ifdef USE_XIM
1028 if (TermWin.fontset)
1029 XmbDrawString (display->display,
1030 ActiveMenu->win, TermWin.fontset,
1031 gc,
1032 ActiveMenu->w - (xoff + Width2Pixel (xright)),
1033 2 * SHADOW + y + TermWin.font->ascent + 1,
1034 name, len);
1035 else
1036#endif
1037 XDrawString (display->display, ActiveMenu->win, gc,
1038 ActiveMenu->w - (xoff + Width2Pixel (xright)), 1049 ActiveMenu->w - (xoff + Width2Pixel (xright)), 2 * SHADOW + y, name, len);
1039 2 * SHADOW + y + TermWin.font->ascent + 1, 1050
1040 name, len);
1041 }
1042 h = HEIGHT_TEXT + 2 * SHADOW; 1051 h = HEIGHT_TEXT + 2 * SHADOW;
1043 } 1052 }
1044 y += h; 1053 y += h;
1045 } 1054 }
1046} 1055}
1047 1056
1048void 1057void
1049rxvt_term::menu_display (void (*update) (rxvt_t *)) 1058rxvt_term::menu_display (void (rxvt_term::*update) ())
1050{ 1059{
1051 menu_t *ActiveMenu = ActiveMenu;
1052
1053 if (ActiveMenu == NULL) 1060 if (ActiveMenu == NULL)
1054 return; 1061 return;
1062
1063 delete ActiveMenu->drawable;
1055 if (ActiveMenu->win != None) 1064 if (ActiveMenu->win != None)
1056 XDestroyWindow (display->display, ActiveMenu->win); 1065 XDestroyWindow (display->display, ActiveMenu->win);
1057 ActiveMenu->win = None; 1066 ActiveMenu->win = None;
1058 ActiveMenu->item = NULL; 1067 ActiveMenu->item = NULL;
1059 1068
1060 if (ActiveMenu->parent == NULL) 1069 if (ActiveMenu->parent == NULL)
1061 drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1); 1070 drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1);
1071
1062 ActiveMenu = ActiveMenu->parent; 1072 ActiveMenu = ActiveMenu->parent;
1063 update (r); 1073 (this->*update) ();
1064} 1074}
1065 1075
1066void 1076void
1067rxvt_term::menu_hide_all () 1077rxvt_term::menu_hide_all ()
1068{ 1078{
1069 menu_display (rxvt_menu_hide_all); 1079 menu_display (&rxvt_term::menu_hide_all);
1070} 1080}
1071 1081
1072void 1082void
1073rxvt_term::menu_hide () 1083rxvt_term::menu_hide ()
1074{ 1084{
1075 menu_display (rxvt_menu_show); 1085 menu_display (&rxvt_term::menu_show);
1076} 1086}
1077 1087
1078void 1088void
1079rxvt_term::menu_clear (menu_t *menu) 1089rxvt_term::menu_clear (menu_t *menu)
1080{ 1090{
1081 if (menu != NULL) 1091 if (menu != NULL)
1082 { 1092 {
1083 menuitem_t *item = menu->tail; 1093 menuitem_t *item = menu->tail;
1084 1094
1085 while (item != NULL) 1095 while (item != NULL)
1086 { 1096 {
1087 menuitem_free (menu, item); 1097 menuitem_free (menu, item);
1088 /* it didn't get freed ... why? */ 1098 /* it didn't get freed ... why? */
1095} 1105}
1096 1106
1097void 1107void
1098rxvt_term::menubar_clear () 1108rxvt_term::menubar_clear ()
1099{ 1109{
1100 bar_t *CurrentBar = CurrentBar;
1101
1102 if (CurrentBar != NULL) 1110 if (CurrentBar != NULL)
1103 { 1111 {
1104 menu_t *menu = CurrentBar->tail; 1112 menu_t *menu = CurrentBar->tail;
1105 1113
1106 while (menu != NULL) 1114 while (menu != NULL)
1107 { 1115 {
1108 menu_t *prev = menu->prev; 1116 menu_t *prev = menu->prev;
1109 1117
1110 menu_delete (menu); 1118 menu_delete (menu);
1111 menu = prev; 1119 menu = prev;
1112 } 1120 }
1113 CurrentBar->head = CurrentBar->tail = NULL; 1121 CurrentBar->head = CurrentBar->tail = NULL;
1115 if (CurrentBar->title) 1123 if (CurrentBar->title)
1116 { 1124 {
1117 free (CurrentBar->title); 1125 free (CurrentBar->title);
1118 CurrentBar->title = NULL; 1126 CurrentBar->title = NULL;
1119 } 1127 }
1128
1120 menuarrow_free (0); /* remove all arrow functions */ 1129 menuarrow_free (0); /* remove all arrow functions */
1121 } 1130 }
1131
1122 ActiveMenu = NULL; 1132 ActiveMenu = NULL;
1123} 1133}
1124 1134
1125#if (MENUBAR_MAX > 1) 1135#if (MENUBAR_MAX > 1)
1126/* find if menu already exists */ 1136/* find if menu already exists */
1127bar_t * 1137bar_t *
1128rxvt_term::menubar_find (const char *name) 1138rxvt_term::menubar_find (const char *name)
1129{ 1139{
1130 bar_t *bar = CurrentBar; 1140 bar_t *bar = CurrentBar;
1131 1141
1132#ifdef DEBUG_MENUBAR_STACKING 1142#ifdef DEBUG_MENUBAR_STACKING
1133 fprintf (stderr, "looking for [menu:%s] ...", name ? name : " (nil)"); 1143 fprintf (stderr, "looking for [menu:%s] ...", name ? name : " (nil)");
1134#endif 1144#endif
1135 if (bar == NULL || name == NULL) 1145 if (bar == NULL || name == NULL)
1159} 1169}
1160 1170
1161int 1171int
1162rxvt_term::menubar_push (const char *name) 1172rxvt_term::menubar_push (const char *name)
1163{ 1173{
1164 int ret = 1; 1174 int ret = 1;
1165 bar_t *bar; 1175 bar_t *bar;
1166 1176
1167 if (CurrentBar == NULL) 1177 if (CurrentBar == NULL)
1168 { 1178 {
1169 /* allocate first one */ 1179 /* allocate first one */
1170 bar = (bar_t *) rxvt_malloc (sizeof (bar_t)); 1180 bar = (bar_t *) rxvt_malloc (sizeof (bar_t));
1218 Nbars++; 1228 Nbars++;
1219 } 1229 }
1220 CurrentBar = bar; 1230 CurrentBar = bar;
1221 1231
1222 } 1232 }
1233
1223 menubar_clear (); 1234 menubar_clear ();
1224 } 1235 }
1225 } 1236 }
1226 1237
1227 /* give menubar this name */ 1238 /* give menubar this name */
1272} 1283}
1273 1284
1274void 1285void
1275rxvt_action_decode (FILE *fp, action_t *act) 1286rxvt_action_decode (FILE *fp, action_t *act)
1276{ 1287{
1277 unsigned char *str; 1288 unsigned char *str;
1278 short len; 1289 short len;
1279 1290
1280 if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL) 1291 if (act == NULL || (len = act->len) == 0 || (str = act->str) == NULL)
1281 return; 1292 return;
1282 1293
1283 if (act->type == MenuTerminalAction) 1294 if (act->type == MenuTerminalAction)
1306 str++; 1317 str++;
1307 len--; 1318 len--;
1308 break; 1319 break;
1309 } 1320 }
1310 } 1321 }
1322
1311 /* 1323 /*
1312 * control character form is preferred, since backslash-escaping 1324 * control character form is preferred, since backslash-escaping
1313 * can be really ugly looking when the backslashes themselves also 1325 * can be really ugly looking when the backslashes themselves also
1314 * have to be escaped to avoid Shell (or whatever scripting 1326 * have to be escaped to avoid Shell (or whatever scripting
1315 * language) interpretation 1327 * language) interpretation
1341 fprintf (fp, "\\%o", ch); 1353 fprintf (fp, "\\%o", ch);
1342 else 1354 else
1343 fprintf (fp, "%c", ch); 1355 fprintf (fp, "%c", ch);
1344 break; 1356 break;
1345 } 1357 }
1358
1346 len--; 1359 len--;
1347 } 1360 }
1361
1348 fprintf (fp, "\n"); 1362 fprintf (fp, "\n");
1349} 1363}
1350 1364
1351void 1365void
1352rxvt_menu_dump (FILE *fp, menu_t *menu) 1366rxvt_menu_dump (FILE *fp, menu_t *menu)
1394 if (bar == NULL || fp == NULL) 1408 if (bar == NULL || fp == NULL)
1395 return; 1409 return;
1396 time (&t); 1410 time (&t);
1397 1411
1398 fprintf (fp, 1412 fprintf (fp,
1399 "# " APL_SUBCLASS " (%s) Pid: %u\n# Date: %s\n\n", 1413 "# " RESCLASS " (%s) Pid: %u\n# Date: %s\n\n",
1400 rs[Rs_name], (unsigned int)getpid (), ctime (&t)); 1414 rs[Rs_name], (unsigned int)getpid (), ctime (&t));
1401 1415
1402 /* dump in reverse order */ 1416 /* dump in reverse order */
1403 bar = CurrentBar->prev; 1417 bar = CurrentBar->prev;
1404 do 1418 do
1458 char *p, *file, *tag = NULL; 1472 char *p, *file, *tag = NULL;
1459 1473
1460 file = (char *)rxvt_File_find (filename, ".menu", rs[Rs_path]); 1474 file = (char *)rxvt_File_find (filename, ".menu", rs[Rs_path]);
1461 if (file == NULL) 1475 if (file == NULL)
1462 return; 1476 return;
1477
1463 fp = fopen (file, "rb"); 1478 fp = fopen (file, "rb");
1464 free (file); 1479 free (file);
1465 if (fp == NULL) 1480 if (fp == NULL)
1466 return; 1481 return;
1467 1482
1573 * user interface for building/deleting and otherwise managing menus 1588 * user interface for building/deleting and otherwise managing menus
1574 */ 1589 */
1575void 1590void
1576rxvt_term::menubar_dispatch (char *str) 1591rxvt_term::menubar_dispatch (char *str)
1577{ 1592{
1578 int n, cmd; 1593 int n, cmd;
1579 char *path, *name, *name2; 1594 char *path, *name, *name2;
1580 1595
1581 if (menubar_visible (r) && ActiveMenu != NULL) 1596 if (menubar_visible () && ActiveMenu != NULL)
1582 menubar_expose (); 1597 menubar_expose ();
1583 else 1598 else
1584 ActiveMenu = NULL; 1599 ActiveMenu = NULL;
1585 1600
1586 cmd = *str; 1601 cmd = *str;
1674 str += n; 1689 str += n;
1675 if (CurrentBar != NULL && !menu_readonly) 1690 if (CurrentBar != NULL && !menu_readonly)
1676 { 1691 {
1677 if (*str) 1692 if (*str)
1678 { 1693 {
1679 name = rxvt_realloc (CurrentBar->title, 1694 name = (char *)rxvt_realloc (CurrentBar->title, STRLEN (str) + 1);
1680 STRLEN (str) + 1);
1681 if (name != NULL) 1695 if (name != NULL)
1682 { 1696 {
1683 STRCPY (name, str); 1697 STRCPY (name, str);
1684 CurrentBar->title = name; 1698 CurrentBar->title = name;
1685 } 1699 }
1741 FILE *fp; 1755 FILE *fp;
1742 1756
1743 /* enough space to hold the results */ 1757 /* enough space to hold the results */
1744 char buffer[32]; 1758 char buffer[32];
1745 1759
1746 sprintf (buffer, "/tmp/" APL_SUBCLASS "-%u", 1760 sprintf (buffer, "/tmp/" RESCLASS "-%u",
1747 (unsigned int)getpid ()); 1761 (unsigned int)getpid ());
1748 1762
1749 if ((fp = fopen (buffer, "wb")) != NULL) 1763 if ((fp = fopen (buffer, "wb")) != NULL)
1750 { 1764 {
1751 xterm_seq (XTerm_title, buffer, CHAR_ST); 1765 xterm_seq (XTerm_title, buffer, CHAR_ST);
1996 if (!Arrows_x) 2010 if (!Arrows_x)
1997 return; 2011 return;
1998 2012
1999 for (i = 0; i < NARROWS; i++) 2013 for (i = 0; i < NARROWS; i++)
2000 { 2014 {
2001 const int w = Width2Pixel (1); 2015 const int w = Width2Pixel (1);
2002 const int y = (menuBar_TotalHeight () - w) / 2; 2016 const int y = (menuBar_TotalHeight () - w) / 2;
2003 int x = Arrows_x + (5 * Width2Pixel (i)) / 4; 2017 int x = Arrows_x + (5 * Width2Pixel (i)) / 4;
2004 2018
2005 if (!name || name == Arrows[i].name) 2019 if (!name || name == Arrows[i].name)
2006 rxvt_Draw_Triangle (display->display, menuBar.win, top, bot, x, y, w, 2020 rxvt_Draw_Triangle (display->display, menuBar.win, top, bot, x, y, w,
2007 Arrows[i].name); 2021 Arrows[i].name);
2008 } 2022 }
2010} 2024}
2011 2025
2012void 2026void
2013rxvt_term::menubar_expose () 2027rxvt_term::menubar_expose ()
2014{ 2028{
2015 menu_t *menu; 2029 menu_t *menu;
2016 int x; 2030 int x;
2017 2031
2018 if (!menubar_visible (r) || menuBar.win == 0) 2032 if (!menubar_visible () || menuBar.win == 0)
2019 return; 2033 return;
2020 2034
2021 if (menubarGC == None) 2035 if (menubarGC == None)
2022 { 2036 {
2023 /* Create the graphics context */ 2037 /* Create the graphics context */
2024 XGCValues gcvalue; 2038 XGCValues gcvalue;
2025
2026 gcvalue.font = TermWin.font->fid;
2027 2039
2028 gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg] 2040 gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg]
2029 : PixColors[Color_Black]); 2041 : PixColors[Color_Black]);
2030 menubarGC = XCreateGC (display->display, menuBar.win, 2042 menubarGC = XCreateGC (display->display, menuBar.win,
2031 GCForeground | GCFont, &gcvalue); 2043 GCForeground, &gcvalue);
2032 2044
2033 } 2045 }
2034 /* make sure the font is correct */ 2046 /* make sure the font is correct */
2035 XSetFont (display->display, menubarGC, TermWin.font->fid);
2036 XSetFont (display->display, botShadowGC, TermWin.font->fid);
2037 XClearWindow (display->display, menuBar.win); 2047 XClearWindow (display->display, menuBar.win);
2038 2048
2039 menu_hide_all (); 2049 menu_hide_all ();
2040 2050
2041 x = 0; 2051 x = 0;
2053 2063
2054 if (x >= TermWin.ncol) 2064 if (x >= TermWin.ncol)
2055 len = (TermWin.ncol - (menu->x + HSPACE)); 2065 len = (TermWin.ncol - (menu->x + HSPACE));
2056 2066
2057 drawbox_menubar (menu->x, len, +1); 2067 drawbox_menubar (menu->x, len, +1);
2058#ifdef USE_XIM 2068 draw_string (*menuBar.drawable, menubarGC, TermWin.fontset,
2059 if (TermWin.fontset)
2060 XmbDrawString (display->display,
2061 menuBar.win, TermWin.fontset,
2062 menubarGC,
2063 (Width2Pixel (menu->x) + Width2Pixel (HSPACE) / 2),
2064 menuBar_height () - SHADOW, menu->name, len);
2065 else
2066#endif
2067 XDrawString (display->display, menuBar.win, menubarGC,
2068 (Width2Pixel (menu->x) + Width2Pixel (HSPACE) / 2), 2069 (Width2Pixel (menu->x) + Width2Pixel (HSPACE) / 2),
2069 menuBar_height () - SHADOW, menu->name, len); 2070 SHADOW, menu->name, len);
2070 2071
2071 if (x >= TermWin.ncol) 2072 if (x >= TermWin.ncol)
2072 break; 2073 break;
2073 } 2074 }
2074 } 2075 }
2125 } 2126 }
2126 title[len] = '\0'; 2127 title[len] = '\0';
2127 2128
2128 ncol -= (x + len + HSPACE); 2129 ncol -= (x + len + HSPACE);
2129 if (len > 0 && ncol >= 0) 2130 if (len > 0 && ncol >= 0)
2130 { 2131 draw_string (*menuBar.drawable, menubarGC, TermWin.fontset,
2131#ifdef USE_XIM
2132 if (TermWin.fontset)
2133 XmbDrawString (display->display,
2134 menuBar.win, TermWin.fontset,
2135 menubarGC,
2136 Width2Pixel (x) + Width2Pixel (ncol + HSPACE) / 2,
2137 menuBar_height () - SHADOW, title, len);
2138 else
2139#endif
2140 XDrawString (display->display, menuBar.win, menubarGC,
2141 Width2Pixel (x) + Width2Pixel (ncol + HSPACE) / 2, 2132 Width2Pixel (x) + Width2Pixel (ncol + HSPACE) / 2,
2142 menuBar_height () - SHADOW, title, len); 2133 SHADOW, title, len);
2143 }
2144 } 2134 }
2145} 2135}
2146 2136
2147int 2137int
2148rxvt_term::menubar_mapping (int map) 2138rxvt_term::menubar_mapping (int map)
2149{ 2139{
2150 int change = 0; 2140 int change = 0;
2151 2141
2152 if (map && !menubar_visible (r)) 2142 if (map && !menubar_visible ())
2153 { 2143 {
2154 menuBar.state = 1; 2144 menuBar.state = 1;
2155 if (menuBar.win == 0) 2145 if (menuBar.win == 0)
2156 return 0; 2146 return 0;
2157 XMapWindow (display->display, menuBar.win); 2147 XMapWindow (display->display, menuBar.win);
2158 change = 1; 2148 change = 1;
2159 } 2149 }
2160 else if (!map && menubar_visible (r)) 2150 else if (!map && menubar_visible ())
2161 { 2151 {
2162 menubar_expose (); 2152 menubar_expose ();
2163 menuBar.state = 0; 2153 menuBar.state = 0;
2164 XUnmapWindow (display->display, menuBar.win); 2154 XUnmapWindow (display->display, menuBar.win);
2165 change = 1; 2155 change = 1;
2169 2159
2170 return change; 2160 return change;
2171} 2161}
2172 2162
2173int 2163int
2174rxvt_term::menu_select (XButtonEvent *ev) 2164rxvt_term::menu_select (XButtonEvent &ev)
2175{ 2165{
2176 menuitem_t *thisitem, *item = NULL; 2166 menuitem_t *thisitem, *item = NULL;
2177 int this_y, y; 2167 int this_y, y;
2178 menu_t *ActiveMenu = ActiveMenu;
2179 2168
2180 Window unused_root, unused_child; 2169 Window unused_root, unused_child;
2181 int unused_root_x, unused_root_y; 2170 int unused_root_x, unused_root_y;
2182 unsigned int unused_mask; 2171 unsigned int unused_mask;
2183 2172
2184 if (ActiveMenu == NULL) 2173 if (ActiveMenu == NULL)
2185 return 0; 2174 return 0;
2186 2175
2187 XQueryPointer (display->display, ActiveMenu->win, 2176 XQueryPointer (display->display, ActiveMenu->win,
2188 &unused_root, &unused_child, 2177 &unused_root, &unused_child,
2189 &unused_root_x, &unused_root_y, 2178 &unused_root_x, &unused_root_y,
2190 & (ev->x), & (ev->y), &unused_mask); 2179 &ev.x, &ev.y, &unused_mask);
2191 2180
2192 if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0)) 2181 if (ActiveMenu->parent != NULL && (ev.x < 0 || ev.y < 0))
2193 { 2182 {
2194 menu_hide (); 2183 menu_hide ();
2195 return 1; 2184 return 1;
2196 } 2185 }
2186
2197 /* determine the menu item corresponding to the Y index */ 2187 /* determine the menu item corresponding to the Y index */
2198 y = SHADOW; 2188 y = SHADOW;
2199 if (ev->x >= 0 && ev->x <= (ActiveMenu->w - SHADOW)) 2189 if (ev.x >= 0 && ev.x <= (ActiveMenu->w - SHADOW))
2200 { 2190 {
2201 for (item = ActiveMenu->head; item != NULL; item = item->next) 2191 for (item = ActiveMenu->head; item != NULL; item = item->next)
2202 { 2192 {
2203 int h = HEIGHT_TEXT + 2 * SHADOW; 2193 int h = HEIGHT_TEXT + 2 * SHADOW;
2204 2194
2205 if (isSeparator (item->name)) 2195 if (isSeparator (item->name))
2206 h = HEIGHT_SEPARATOR; 2196 h = HEIGHT_SEPARATOR;
2207 else if (ev->y >= y && ev->y < (y + h)) 2197 else if (ev.y >= y && ev.y < (y + h))
2208 break; 2198 break;
2199
2209 y += h; 2200 y += h;
2210 } 2201 }
2211 } 2202 }
2203
2212 if (item == NULL && ev->type == ButtonRelease) 2204 if (item == NULL && ev.type == ButtonRelease)
2213 { 2205 {
2214 menu_hide_all (); 2206 menu_hide_all ();
2215 return 0; 2207 return 0;
2216 } 2208 }
2209
2217 thisitem = item; 2210 thisitem = item;
2218 this_y = y - SHADOW; 2211 this_y = y - SHADOW;
2219 2212
2220 /* erase the last item */ 2213 /* erase the last item */
2221 if (ActiveMenu->item != NULL) 2214 if (ActiveMenu->item != NULL)
2222 { 2215 {
2223 if (ActiveMenu->item != thisitem) 2216 if (ActiveMenu->item != thisitem)
2224 { 2217 {
2225 for (y = 0, item = ActiveMenu->head; item != NULL; 2218 for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next)
2226 item = item->next)
2227 { 2219 {
2228 int h; 2220 int h;
2229 2221
2230 if (isSeparator (item->name)) 2222 if (isSeparator (item->name))
2231 h = HEIGHT_SEPARATOR; 2223 h = HEIGHT_SEPARATOR;
2232 else if (item == ActiveMenu->item) 2224 else if (item == ActiveMenu->item)
2233 { 2225 {
2234 /* erase old menuitem */ 2226 /* erase old menuitem */
2235 drawbox_menuitem (y, 0); /* No Shadow */ 2227 drawbox_menuitem (y, 0); /* No Shadow */
2236 if (item->entry.type == MenuSubMenu) 2228 if (item->entry.type == MenuSubMenu)
2237 drawtriangle (ActiveMenu->w, y, +1); 2229 drawtriangle (ActiveMenu->w, y, +1);
2230
2238 break; 2231 break;
2239 } 2232 }
2240 else 2233 else
2241 h = HEIGHT_TEXT + 2 * SHADOW; 2234 h = HEIGHT_TEXT + 2 * SHADOW;
2235
2242 y += h; 2236 y += h;
2243 } 2237 }
2244 } 2238 }
2245 else 2239 else
2246 { 2240 {
2247 switch (ev->type) 2241 switch (ev.type)
2248 { 2242 {
2249 case ButtonRelease: 2243 case ButtonRelease:
2250 switch (item->entry.type) 2244 switch (item->entry.type)
2251 { 2245 {
2252 case MenuLabel: 2246 case MenuLabel:
2254 menu_hide_all (); 2248 menu_hide_all ();
2255 break; 2249 break;
2256 2250
2257 case MenuAction: 2251 case MenuAction:
2258 case MenuTerminalAction: 2252 case MenuTerminalAction:
2259 drawbox_menuitem (_y, -1); 2253 drawbox_menuitem (this_y, -1);
2260 {
2261#ifdef HAVE_NANOSLEEP 2254#ifdef HAVE_NANOSLEEP
2262 struct timespec rqt; 2255 struct timespec rqt;
2263 2256
2264 rqt.tv_sec = 0; 2257 rqt.tv_sec = 0;
2265 rqt.tv_nsec = MENU_DELAY_USEC * 1000; 2258 rqt.tv_nsec = MENU_DELAY_USEC * 1000;
2266 nanosleep (&rqt, NULL); 2259 nanosleep (&rqt, NULL);
2267#else 2260#else
2268 /* use select for timing */ 2261 /* use select for timing */
2269 struct timeval tv; 2262 struct timeval tv;
2270 2263
2271 tv.tv_sec = 0; 2264 tv.tv_sec = 0;
2272 tv.tv_usec = MENU_DELAY_USEC; 2265 tv.tv_usec = MENU_DELAY_USEC;
2273 select (0, NULL, NULL, NULL, &tv); 2266 select (0, NULL, NULL, NULL, &tv);
2274#endif 2267#endif
2275
2276 }
2277 /* remove menu before sending keys to the application */ 2268 /* remove menu before sending keys to the application */
2278 menu_hide_all (); 2269 menu_hide_all ();
2279#ifndef DEBUG_MENU 2270#ifndef DEBUG_MENU
2280 action_dispatch (& (item->entry.action)); 2271 action_dispatch (& (item->entry.action));
2281#else /* DEBUG_MENU */ 2272#else /* DEBUG_MENU */
2292 break; 2283 break;
2293 } 2284 }
2294 return 0; 2285 return 0;
2295 } 2286 }
2296 } 2287 }
2288
2297DoMenu: 2289DoMenu:
2298 ActiveMenu->item = thisitem; 2290 ActiveMenu->item = thisitem;
2299 y = this_y; 2291 y = this_y;
2292
2300 if (item != NULL) 2293 if (thisitem != NULL)
2301 { 2294 {
2302 item = ActiveMenu->item; 2295 item = ActiveMenu->item;
2303 if (item->entry.type != MenuLabel) 2296 if (item->entry.type != MenuLabel)
2304 drawbox_menuitem (y, +1); 2297 drawbox_menuitem (y, +1);
2298
2305 if (item->entry.type == MenuSubMenu) 2299 if (item->entry.type == MenuSubMenu)
2306 { 2300 {
2307 int x; 2301 int x;
2308 2302
2309 drawtriangle (ActiveMenu->w, y, -1); 2303 drawtriangle (ActiveMenu->w, y, -1);
2310 2304
2311 x = ev->x + (ActiveMenu->parent 2305 x = ev.x + (ActiveMenu->parent
2312 ? ActiveMenu->x 2306 ? ActiveMenu->x
2313 : Width2Pixel (ActiveMenu->x)); 2307 : Width2Pixel (ActiveMenu->x));
2314 2308
2315 if (x >= item->entry.submenu.menu->x) 2309 if (x >= item->entry.submenu.menu->x)
2316 { 2310 {
2322 } 2316 }
2323 return 0; 2317 return 0;
2324} 2318}
2325 2319
2326void 2320void
2327rxvt_term::menubar_select (XButtonEvent *ev) 2321rxvt_term::menubar_select (XButtonEvent &ev)
2328{ 2322{
2329 menu_t *menu = NULL; 2323 menu_t *menu = NULL;
2330 2324
2331 /* determine the pulldown menu corresponding to the X index */ 2325 /* determine the pulldown menu corresponding to the X index */
2332 if (ev->y >= 0 && ev->y <= menuBar_height () && CurrentBar != NULL) 2326 if (ev.y >= 0 && ev.y <= menuBar_height () && CurrentBar != NULL)
2333 { 2327 {
2334 for (menu = CurrentBar->head; menu != NULL; menu = menu->next) 2328 for (menu = CurrentBar->head; menu != NULL; menu = menu->next)
2335 { 2329 {
2336 int x = Width2Pixel (menu->x); 2330 int x = Width2Pixel (menu->x);
2337 int w = Width2Pixel (menu->len + HSPACE); 2331 int w = Width2Pixel (menu->len + HSPACE);
2338 2332
2339 if ((ev->x >= x && ev->x < x + w)) 2333 if ((ev.x >= x && ev.x < x + w))
2340 break; 2334 break;
2341 } 2335 }
2342 } 2336 }
2343 switch (ev->type) 2337 switch (ev.type)
2344 { 2338 {
2345 case ButtonRelease: 2339 case ButtonRelease:
2346 menu_hide_all (); 2340 menu_hide_all ();
2347 break; 2341 break;
2348 2342
2349 case ButtonPress: 2343 case ButtonPress:
2350 if (menu == NULL && Arrows_x && ev->x >= Arrows_x) 2344 if (menu == NULL && Arrows_x && ev.x >= Arrows_x)
2351 { 2345 {
2352 int i; 2346 int i;
2353 2347
2354 for (i = 0; i < NARROWS; i++) 2348 for (i = 0; i < NARROWS; i++)
2355 { 2349 {
2356 if (ev->x >= (Arrows_x + (Width2Pixel (4 * i + i)) / 4) 2350 if (ev.x >= (Arrows_x + (Width2Pixel (4 * i + i)) / 4)
2357 && ev->x < (Arrows_x 2351 && ev.x < (Arrows_x
2358 + (Width2Pixel (4 * i + i + 4)) / 4)) 2352 + (Width2Pixel (4 * i + i + 4)) / 4))
2359 { 2353 {
2360 draw_Arrows (Arrows[i].name, -1); 2354 draw_Arrows (Arrows[i].name, -1);
2361 { 2355 {
2362#ifdef HAVE_NANOSLEEP 2356#ifdef HAVE_NANOSLEEP
2392 { 2386 {
2393 fprintf (stderr, "%s\n", 2387 fprintf (stderr, "%s\n",
2394 CurrentBar->arrows[i].str); 2388 CurrentBar->arrows[i].str);
2395 } 2389 }
2396#else /* DEBUG_MENUARROWS */ 2390#else /* DEBUG_MENUARROWS */
2397 if (CurrentBar == NULL 2391 if (CurrentBar == NULL || action_dispatch (&CurrentBar->arrows[i]))
2398 || rxvt_action_dispatch (r,
2399 & (CurrentBar->arrows[i]))
2400 )
2401 { 2392 {
2402 if (Arrows[i].str != NULL && Arrows[i].str[0] != 0) 2393 if (Arrows[i].str != NULL && Arrows[i].str[0] != 0)
2403 tt_write ((Arrows[i].str + 1), 2394 tt_write ((Arrows[i].str + 1),
2404 Arrows[i].str[0]); 2395 Arrows[i].str[0]);
2405 } 2396 }
2427/* 2418/*
2428 * general dispatch routine, 2419 * general dispatch routine,
2429 * it would be nice to have `sticky' menus 2420 * it would be nice to have `sticky' menus
2430 */ 2421 */
2431void 2422void
2432rxvt_term::menubar_control (XButtonEvent *ev) 2423rxvt_term::menubar_control (XButtonEvent &ev)
2433{ 2424{
2434 switch (ev->type) 2425 switch (ev.type)
2435 { 2426 {
2436 case ButtonPress: 2427 case ButtonPress:
2437 if (ev->button == Button1) 2428 if (ev.button == Button1)
2438 menubar_select (ev); 2429 menubar_select (ev);
2439 break; 2430 break;
2440 2431
2441 case ButtonRelease: 2432 case ButtonRelease:
2442 if (ev->button == Button1) 2433 if (ev.button == Button1)
2443 menu_select (ev); 2434 menu_select (ev);
2444 break; 2435 break;
2445 2436
2446 case MotionNotify: 2437 case MotionNotify:
2447 while (XCheckTypedWindowEvent (display->display, TermWin.parent[0], 2438 while (XCheckTypedWindowEvent (display->display, TermWin.parent[0],
2448 MotionNotify, (XEvent *) ev)) ; 2439 MotionNotify, (XEvent *)&ev)) ;
2449 2440
2450 if (ActiveMenu) 2441 if (ActiveMenu)
2451 while (menu_select (ev)) ; 2442 while (menu_select (ev)) ;
2452 else 2443 else
2453 ev->y = -1; 2444 ev.y = -1;
2454 if (ev->y < 0) 2445 if (ev.y < 0)
2455 { 2446 {
2456 Window unused_root, unused_child; 2447 Window unused_root, unused_child;
2457 int unused_root_x, unused_root_y; 2448 int unused_root_x, unused_root_y;
2458 unsigned int unused_mask; 2449 unsigned int unused_mask;
2459 2450
2460 XQueryPointer (display->display, menuBar.win, 2451 XQueryPointer (display->display, menuBar.win,
2461 &unused_root, &unused_child, 2452 &unused_root, &unused_child,
2462 &unused_root_x, &unused_root_y, 2453 &unused_root_x, &unused_root_y,
2463 & (ev->x), & (ev->y), &unused_mask); 2454 &ev.x, &ev.y, &unused_mask);
2464 menubar_select (ev); 2455 menubar_select (ev);
2465 } 2456 }
2466 break; 2457 break;
2467 } 2458 }
2468} 2459}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines