-static void event_handle_menu(ObClient *client, XEvent *e)
-{
- static ObMenuEntry *over = NULL;
- ObMenuEntry *entry;
- ObMenu *top;
- GList *it = NULL;
-
- top = g_list_nth_data(menu_visible, 0);
-
- ob_debug("EVENT %d\n", e->type);
- switch (e->type) {
- case KeyPress:
- if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
- over = menu_control_keyboard_nav(over, OB_KEY_DOWN);
- else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
- over = menu_control_keyboard_nav(over, OB_KEY_UP);
- else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN))
- over = menu_control_keyboard_nav(over, OB_KEY_RETURN);
- else if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
- over = menu_control_keyboard_nav(over, OB_KEY_ESCAPE);
- else {
- if (over) {
- if (over->parent->mouseover)
- over->parent->mouseover(over, FALSE);
- else
- menu_control_mouseover(over, FALSE);
- menu_entry_render(over);
- over = NULL;
- }
-/*
- if (top->hide)
- top->hide(top);
- else
-*/
- menu_hide(top);
- }
- break;
- case ButtonPress:
- if (e->xbutton.button > 3) break;
-
- ob_debug("BUTTON PRESS\n");
- break;
- case ButtonRelease:
- if (e->xbutton.button > 3) break;
-
- ob_debug("BUTTON RELEASED\n");
-
- for (it = menu_visible; it; it = g_list_next(it)) {
- ObMenu *m = it->data;
- if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth &&
- e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth &&
- e->xbutton.x_root < m->location.x + m->size.width +
- ob_rr_theme->bwidth &&
- e->xbutton.y_root < m->location.y + m->size.height +
- ob_rr_theme->bwidth) {
- if ((entry = menu_find_entry_by_pos(it->data,
- e->xbutton.x_root -
- m->location.x,
- e->xbutton.y_root -
- m->location.y))) {
- if (over) {
- if (over->parent->mouseover)
- over->parent->mouseover(over, FALSE);
- else
- menu_control_mouseover(over, FALSE);
- menu_entry_render(over);
- over = NULL;
- /* this hides the menu */
- menu_entry_fire(entry);
- }
- }
- break;
- }
- }
- if (!it) {
- if (over) {
- if (over->parent->mouseover)
- over->parent->mouseover(over, FALSE);
- else
- menu_control_mouseover(over, FALSE);
- menu_entry_render(over);
- over = NULL;
- }
-/*
- if (top->hide)
- top->hide(top);
- else
-*/
- menu_hide(top);
- }
-
- break;
- case MotionNotify:
- ob_debug("motion\n");
- for (it = menu_visible; it; it = g_list_next(it)) {
- ObMenu *m = it->data;
- if ((entry = menu_find_entry_by_pos(it->data,
- e->xmotion.x_root -
- m->location.x,
- e->xmotion.y_root -
- m->location.y))) {
- if (over && entry != over) {
- if (over->parent->mouseover)
- over->parent->mouseover(over, FALSE);
- else
- menu_control_mouseover(over, FALSE);
- menu_entry_render(over);
- }
-
- over = entry;
- if (over->parent->mouseover)
- over->parent->mouseover(over, TRUE);
- else
- menu_control_mouseover(over, TRUE);
- menu_entry_render(over);
- break;
- }
- }
- if (!it && over) {
- if (over->parent->mouseover)
- over->parent->mouseover(over, FALSE);
- else
- menu_control_mouseover(over, FALSE);
- menu_entry_render(over);
- over = NULL;
- }
- break;
- }
-}
-
-void event_add_fd_handler(event_fd_handler *h) {
- g_datalist_id_set_data(&fd_handler_list, h->fd, h);
- FD_SET(h->fd, &allset);
- max_fd = MAX(max_fd, h->fd);
-}
-
-static void find_max_fd_foreach(GQuark n, gpointer data, gpointer max)
-{
- *((unsigned int *)max) = MAX(*((unsigned int *)max), n);
-}
-
-static void find_max_fd()
-{
- int tmpmax = -1;
- g_datalist_foreach(&fd_handler_list, find_max_fd_foreach,
- (gpointer)&tmpmax);
- max_fd = MAX(x_fd, tmpmax);
-#ifdef USE_SM
- max_fd = MAX(ice_fd, tmpmax);
-#endif
-}
-
-void event_remove_fd(int n)
-{
- FD_CLR(n, &allset);
- g_datalist_id_remove_data(&fd_handler_list, (GQuark)n);
- find_max_fd();
-}
-
-static void fd_event_handle_foreach(GQuark n, gpointer data, gpointer user_data)
-{
- if (FD_ISSET( (int)n, &selset)) {
- event_fd_handler *h = (event_fd_handler *)data;
- g_assert(h->fd == (int)n);
- h->handler(h->fd, h->data);
- }
-}
-
-static void fd_event_handle()
-{
- g_datalist_foreach(&fd_handler_list, fd_event_handle_foreach, NULL);
-}
-