+ default:
+ ;
+#ifdef SHAPE
+ if (extensions_shape && e->type == extensions_shape_event_basep) {
+ client->shaped = ((XShapeEvent*)e)->shaped;
+ frame_adjust_shape(client->frame);
+ }
+#endif
+ }
+}
+
+static void event_handle_menu(Menu *menu, Client *client, XEvent *e)
+{
+ MenuEntry *entry;
+
+ g_message("EVENT %d", e->type);
+ switch (e->type) {
+ case ButtonPress:
+ g_message("BUTTON PRESS");
+ if (e->xbutton.button == 3)
+ menu_hide(menu);
+ else if (e->xbutton.button == 1) {
+ entry = menu_find_entry(menu, e->xbutton.window);
+ if (!entry)
+ stacking_raise(MENU_AS_WINDOW(menu));
+ }
+ break;
+ case ButtonRelease:
+ g_message("BUTTON RELEASED");
+ if (!menu->shown) break;
+
+/* grab_pointer_window(FALSE, None, menu->frame);*/
+
+ if (e->xbutton.button == 1) {
+ entry = menu_find_entry(menu, e->xbutton.window);
+ if (entry) {
+ int junk;
+ Window wjunk;
+ guint ujunk, b, w, h;
+ XGetGeometry(ob_display, e->xbutton.window,
+ &wjunk, &junk, &junk, &w, &h, &b, &ujunk);
+ if (e->xbutton.x >= (signed)-b &&
+ e->xbutton.y >= (signed)-b &&
+ e->xbutton.x < (signed)(w+b) &&
+ e->xbutton.y < (signed)(h+b)) {
+ menu_entry_fire(entry);
+ }
+ }
+ }
+
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ g_message("enter/leave");
+ entry = menu_find_entry(menu, e->xcrossing.window);
+ if (entry) {
+ if (menu->mouseover)
+ menu->mouseover(entry, e->type == EnterNotify);
+ else
+ menu_control_mouseover(entry, e->type == EnterNotify);
+
+ menu_entry_render(entry);
+ }
+ 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(Dock *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(DockApp *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;