+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & TW_EVENT) && evl) {
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ fds[count].fd = ev->data.fev.fd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ }
+ }
+#endif
+
+ result = poll(fds, (unsigned) count, milliseconds);
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & TW_EVENT) && evl) {
+ int c;
+
+ if (!result)
+ count = 0;
+
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ ev->data.fev.result = 0;
+ for (c = 0; c < count; c++)
+ if (fds[c].fd == ev->data.fev.fd
+ && fds[c].revents & POLLIN) {
+ ev->data.fev.result |= _NC_EVENT_FILE_READABLE;
+ evl->result_flags |= _NC_EVENT_FILE_READABLE;
+ }
+ } else if (ev->type == _NC_EVENT_TIMEOUT_MSEC
+ && !result && timeout_is_event) {
+ evl->result_flags |= _NC_EVENT_TIMEOUT_MSEC;
+ }
+ }
+ }
+
+ if (fds != fd_list)
+ free((char *) fds);
+
+#endif