static bool MainCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data) { t_gmx *gmx; int nsel, width, height; bool result; result = false; gmx = (t_gmx *)data; switch (event->type) { case ButtonRelease: hide_pd(x11, gmx->pd); break; case ConfigureNotify: width = event->xconfigure.width; height = event->xconfigure.height; if ((width != gmx->wd->width) || (height != gmx->wd->height)) { move_gmx(x11, gmx, width, height, true); } break; case ClientMessage: hide_pd(x11, gmx->pd); nsel = event->xclient.data.l[0]; result = HandleClient(x11, nsel, gmx); break; default: break; } return result; }
static bool PDCallBack(t_x11 *x11, XEvent *event, Window w, void *data) { t_pulldown *pd; int i, x, x1, y, nsel; pd = (t_pulldown *)data; y = pd->wd.height; switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, x11->fg); XDrawLine(x11->disp, w, x11->gc, 0, y-1, pd->wd.width, y-1); for (i = 0; (i < pd->nmenu); i++) { XDrawString(x11->disp, pd->wd.self, x11->gc, pd->xpos[i], x11->font->ascent, pd->title[i], std::strlen(pd->title[i])); } break; case ButtonPress: if (pd->nsel == -1) { x = event->xbutton.x; for (nsel = 0; (pd->xpos[nsel+1] < x) && (nsel < pd->nmenu-1); nsel++) { ; } pd->nsel = nsel; x1 = std::max(0, std::min(pd_width(pd)-menu_width(pd->m[nsel]), pd->xpos[nsel])); show_menu(x11, pd->m[nsel], x1, y+1, false); } break; case ButtonRelease: hide_pd(x11, pd); break; default: break; } return false; }