boolean MenuWindowEventHandler(void *arg, XEvent* event) { XlibMenu* menu = (XlibMenu*) arg; FcitxXlibWindow* window = arg; FcitxClassicUI* classicui = window->owner; if (event->xany.window == window->wId) { switch (event->type) { case Expose: FcitxXlibWindowPaint(&menu->parent); break; case LeaveNotify: { int x = event->xcrossing.x_root; int y = event->xcrossing.y_root; if (!IsMouseInOtherMenu(menu, x, y)) { CloseAllSubMenuWindow(menu); } } break; case MotionNotify: { int offseth = 0; int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth); boolean flag = ReverseColor(menu, i); FcitxMenuItem *item = GetMenuItem(menu->menushell, i); if (!flag) { XlibMenuShow(menu); if (item && item->type == MENUTYPE_SUBMENU && item->subMenu) { XlibMenu* subxlibmenu = (XlibMenu*) item->subMenu->uipriv[classicui->isfallback]; CloseOtherSubMenuWindow(menu, subxlibmenu); XlibMenuMoveSubMenu(subxlibmenu, menu, offseth); XlibMenuShow(subxlibmenu); } } if (item == NULL) CloseOtherSubMenuWindow(menu, NULL); } break; case ButtonPress: { switch (event->xbutton.button) { case Button1: { int offseth; int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth); if (menu->menushell->MenuAction) { if (menu->menushell->MenuAction(menu->menushell, i)) CloseAllMenuWindow(classicui); } } break; case Button3: CloseAllMenuWindow(classicui); break; } } break; } return true; } return false; }
boolean MenuWindowEventHandler(void *arg, XEvent* event) { XlibMenu* menu = (XlibMenu*) arg; if (event->xany.window == menu->menuWindow) { switch (event->type) { case MapNotify: UpdateMenuShell(menu->menushell); break; case Expose: DrawXlibMenu(menu); break; case LeaveNotify: { int x = event->xcrossing.x_root; int y = event->xcrossing.y_root; if (!IsMouseInOtherMenu(menu, x, y)) { CloseAllSubMenuWindow(menu); } } break; case MotionNotify: { int offseth = 0; GetMenuSize(menu); int i=SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth); boolean flag = ReverseColor(menu,i); if (!flag) { DrawXlibMenu(menu); } MenuShell *shell = GetMenuShell(menu->menushell, i); if (shell && shell->type == MENUTYPE_SUBMENU && shell->subMenu) { XlibMenu* subxlibmenu = (XlibMenu*) shell->subMenu->uipriv; CloseOtherSubMenuWindow(menu, subxlibmenu); MoveSubMenu(subxlibmenu, menu, offseth); DrawXlibMenu(subxlibmenu); XMapRaised(menu->owner->dpy, subxlibmenu->menuWindow); } if (shell == NULL) CloseOtherSubMenuWindow(menu, NULL); } break; case ButtonPress: { switch (event->xbutton.button) { case Button1: { int offseth; int i=SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth); if (menu->menushell->MenuAction) { if (menu->menushell->MenuAction(menu->menushell, i)) CloseAllMenuWindow(menu->owner); } } break; case Button3: CloseAllMenuWindow(menu->owner); break; } } break; } return true; } return false; }