+
+static void event_handle_menu(ObClient *client, XEvent *e)
+{
+ 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:
+ menu_control_keyboard_nav(e->xkey.keycode);
+ break;
+ case ButtonPress:
+ ob_debug("BUTTON PRESS\n");
+
+ break;
+ case ButtonRelease:
+ 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))) {
+ m->selected(entry, e->xbutton.button,
+ e->xbutton.x_root,
+ e->xbutton.y_root);
+ break;
+ }
+ break;
+ }
+ }
+
+ /* will call the menu_hide() for each submenu as well */
+ if (!it)
+ menu_hide(menu_visible->data);
+
+ 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 (m->over && m->over->data != entry)
+ m->mouseover(m->over->data, FALSE);
+
+ m->mouseover(entry, TRUE);
+ break;
+ }
+ }
+
+ 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);
+}
+
+static void event_handle_dock(ObDock *s, XEvent *e)
+{
+ switch (e->type) {
+ case ButtonPress:
+ stacking_raise(DOCK_AS_WINDOW(s));
+ break;
+ case EnterNotify:
+ dock_hide(FALSE);
+ break;
+ case LeaveNotify:
+ dock_hide(TRUE);
+ break;
+ }
+}
+
+static void event_handle_dockapp(ObDockApp *app, XEvent *e)
+{
+ switch (e->type) {
+ case MotionNotify:
+ dock_app_drag(app, &e->xmotion);
+ break;
+ case UnmapNotify:
+ if (app->ignore_unmaps) {
+ app->ignore_unmaps--;
+ break;
+ }
+ dock_remove(app, TRUE);
+ break;
+ case DestroyNotify:
+ dock_remove(app, FALSE);
+ break;
+ case ReparentNotify:
+ dock_remove(app, FALSE);
+ break;
+ case ConfigureNotify:
+ dock_app_configure(app, e->xconfigure.width, e->xconfigure.height);
+ break;
+ }
+}