static int process_event(XEvent* event) { KeySym sym; WindowInfo* info = find_handle(event->xany.window); if (!info) return 1; if (event->type == ClientMessage) { if ((Atom)event->xclient.data.l[0] == s_wm_delete_window) { info->update = 0; mfb_close(info); return 0; } } switch (event->type) { case KeyPress: { sym = XLookupKeysym(&event->xkey, 0); if (handle_special_keys(info, event, 1)) break; if (info->key_callback) info->key_callback(info->rust_data, sym, 1); if (info->char_callback) { unsigned int t = keySym2Unicode(sym); if (t != -1) info->char_callback(info->rust_data, t); } break; } case KeyRelease: { if (handle_special_keys(info, event, 0)) break; sym = XLookupKeysym(&event->xkey, 0); if (info->key_callback) info->key_callback(info->rust_data, sym, 0); break; } case ButtonPress: { if (!info->shared_data) break; if (event->xbutton.button == Button1) info->shared_data->state[0] = 1; else if (event->xbutton.button == Button2) info->shared_data->state[1] = 1; else if (event->xbutton.button == Button3) info->shared_data->state[2] = 1; else if (event->xbutton.button == Button4) info->shared_data->scroll_y = 10.0f; else if (event->xbutton.button == Button5) info->shared_data->scroll_y = -10.0f; else if (event->xbutton.button == Button6) info->shared_data->scroll_x = 10.0f; else if (event->xbutton.button == Button7) info->shared_data->scroll_y = -10.0f; break; } case ButtonRelease: { if (!info->shared_data) break; if (event->xbutton.button == Button1) info->shared_data->state[0] = 0; else if (event->xbutton.button == Button2) info->shared_data->state[1] = 0; else if (event->xbutton.button == Button3) info->shared_data->state[2] = 0; break; } case ConfigureNotify: { info->width = event->xconfigure.width; info->height = event->xconfigure.height; break; } } return 1; }