void gui_poll(bool active) { LOG(("GUI poll in")); nsfb_event_t event; int timeout; /* timeout in miliseconds */ LOG(("schedule run")); /* run the scheduler and discover how long to wait for the next event */ timeout = schedule_run(); /* if active do not wait for event, return immediately */ if (active) timeout = 0; LOG(("redraw pending")); /* if redraws are pending do not wait for event, return immediately */ if (fbtk_get_redraw_pending(fbtk)) timeout = 0; LOG(("fbtk event")); if (fbtk_event(fbtk, &event, timeout)) { if ((event.type == NSFB_EVENT_CONTROL) && (event.value.controlcode == NSFB_CONTROL_QUIT)) netsurf_quit = true; } LOG(("fbtk redraw")); fbtk_redraw(fbtk); LOG(("GUI poll out success")); }
static void framebuffer_poll(bool active) { nsfb_event_t event; int timeout; /* timeout in miliseconds */ /* run the scheduler and discover how long to wait for the next event */ timeout = schedule_run(); /* if active do not wait for event, return immediately */ if (active) timeout = 0; /* if redraws are pending do not wait for event, return immediately */ if (fbtk_get_redraw_pending(fbtk)) timeout = 0; if (fbtk_event(fbtk, &event, timeout)) { if ((event.type == NSFB_EVENT_CONTROL) && (event.value.controlcode == NSFB_CONTROL_QUIT)) netsurf_quit = true; } fbtk_redraw(fbtk); }
/** * Run the gtk event loop. * * The same as the standard gtk_main loop except this ensures active * FD are added to the gtk poll event set. */ static void nsgtk_main(void) { fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count; while (!nsgtk_complete) { max_fd = -1; fd_count = 0; FD_ZERO(&read_fd_set); FD_ZERO(&write_fd_set); FD_ZERO(&exc_fd_set); fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); for (int i = 0; i <= max_fd; i++) { if (FD_ISSET(i, &read_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } if (FD_ISSET(i, &write_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_OUT | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } if (FD_ISSET(i, &exc_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } } schedule_run(); gtk_main_iteration(); for (unsigned int i = 0; i != fd_count; i++) { g_main_context_remove_poll(0, fd_list[i]); free(fd_list[i]); } } }
void nsbeos_gui_poll(void) { fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; struct timeval timeout; unsigned int fd_count = 0; bigtime_t next_schedule = 0; /* get any active fetcher fd */ fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); /* run the scheduler */ schedule_run(); // our own event pipe FD_SET(sEventPipe[0], &read_fd_set); // max of all the fds in the set, plus one for select() max_fd = MAX(max_fd, sEventPipe[0]) + 1; // compute schedule timeout if (earliest_callback_timeout != B_INFINITE_TIMEOUT) { next_schedule = earliest_callback_timeout - system_time(); } else { next_schedule = earliest_callback_timeout; } // we're quite late already... if (next_schedule < 0) next_schedule = 0; timeout.tv_sec = (long)(next_schedule / 1000000LL); timeout.tv_usec = (long)(next_schedule % 1000000LL); //LOG("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule); fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set, &timeout); //LOG("select: %d\n", fd_count); if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) { BMessage *message; int len = read(sEventPipe[0], &message, sizeof(void *)); //LOG("gui_poll: BMessage ? %d read", len); if (len == sizeof(void *)) { //LOG("gui_poll: BMessage.what %-4.4s\n", &(message->what)); nsbeos_dispatch_event(message); } } }
void gui_poll(bool active) { CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count = 0; bool block = true; schedule_run(); if (browser_reformat_pending) block = false; if (active) { FD_ZERO(&read_fd_set); FD_ZERO(&write_fd_set); FD_ZERO(&exc_fd_set); code = curl_multi_fdset(fetch_curl_multi, &read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); assert(code == CURLM_OK); LOG(("maxfd from curl is %d", max_fd)); for (int i = 0; i <= max_fd; i++) { if (FD_ISSET(i, &read_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; LOG(("Want to read %d", i)); } if (FD_ISSET(i, &write_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_OUT | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; LOG(("Want to write %d", i)); } if (FD_ISSET(i, &exc_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; LOG(("Want to check %d", i)); } } } LOG(("Iterate %sactive %sblocking", active?"":"in", block?"":"non-")); if (block) { fprintf(stdout, "GENERIC POLL BLOCKING\n"); } g_main_context_iteration(g_main_context_default(), block); for (unsigned int i = 0; i != fd_count; i++) { g_main_context_remove_poll(0, fd_list[i]); free(fd_list[i]); } schedule_run(); if (browser_reformat_pending) monkey_window_process_reformats(); }
void gui_poll(bool active) { CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count = 0; bool block = true; schedule_run(); if (browser_reformat_pending) block = false; if (active) { FD_ZERO(&read_fd_set); FD_ZERO(&write_fd_set); FD_ZERO(&exc_fd_set); code = curl_multi_fdset(fetch_curl_multi, &read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); assert(code == CURLM_OK); for (int i = 0; i <= max_fd; i++) { if (FD_ISSET(i, &read_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } if (FD_ISSET(i, &write_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_OUT | G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } if (FD_ISSET(i, &exc_fd_set)) { GPollFD *fd = malloc(sizeof *fd); fd->fd = i; fd->events = G_IO_ERR; g_main_context_add_poll(0, fd, 0); fd_list[fd_count++] = fd; } } } gtk_main_iteration_do(block); for (unsigned int i = 0; i != fd_count; i++) { g_main_context_remove_poll(0, fd_list[i]); free(fd_list[i]); } schedule_run(); if (browser_reformat_pending) nsgtk_window_process_reformats(); }
static void gui_poll(bool active) { CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd = 0; struct timeval timeout; unsigned int fd_count = 0; bool block = true; bigtime_t next_schedule = 0; // handle early deadlines schedule_run(); FD_ZERO(&read_fd_set); FD_ZERO(&write_fd_set); FD_ZERO(&exc_fd_set); if (active) { code = curl_multi_fdset(fetch_curl_multi, &read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); assert(code == CURLM_OK); } // our own event pipe FD_SET(sEventPipe[0], &read_fd_set); max_fd = MAX(max_fd, sEventPipe[0] + 1); // If there are pending events elsewhere, we should not be blocking if (!browser_reformat_pending) { if (earliest_callback_timeout != B_INFINITE_TIMEOUT) { next_schedule = earliest_callback_timeout - system_time(); block = false; } // we're quite late already... if (next_schedule < 0) next_schedule = 0; } else //we're not allowed to sleep, there is other activity going on. block = false; /* LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld" " next_schedule:%Ld block:%d ", browser_reformat_pending, earliest_callback_timeout, next_schedule, block)); */ timeout.tv_sec = (long)(next_schedule / 1000000LL); timeout.tv_usec = (long)(next_schedule % 1000000LL); //LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule)); fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set, block ? NULL : &timeout); //LOG(("select: %d\n", fd_count)); if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) { BMessage *message; int len = read(sEventPipe[0], &message, sizeof(void *)); //LOG(("gui_poll: BMessage ? %d read", len)); if (len == sizeof(void *)) { //LOG(("gui_poll: BMessage.what %-4.4s\n", &(message->what))); nsbeos_dispatch_event(message); } } schedule_run(); if (browser_reformat_pending) nsbeos_window_process_reformats(); }
void gui_poll(bool active) { struct gui_window *tmp; short mx, my, dummy; unsigned short nkc = 0; aes_event_in.emi_tlow = schedule_run(); if(active || rendering) aes_event_in.emi_tlow = 0; if(aes_event_in.emi_tlow < 0) { aes_event_in.emi_tlow = 10000; printf("long poll!\n"); } struct gui_window * g; if( !active ) { if(input_window && input_window->root->redraw_slots.areas_used > 0) { window_process_redraws(input_window->root); } } graf_mkstate(&mx, &my, &dummy, &dummy); aes_event_in.emi_m1.g_x = mx; aes_event_in.emi_m1.g_y = my; evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); if(!gemtk_wm_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out)) { if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { LOG(("WM: %d\n", aes_msg_out[0])); switch(aes_msg_out[0]) { case MN_SELECTED: LOG(("Menu Item: %d\n",aes_msg_out[4])); deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); break; default: break; } } if((aes_event_out.emo_events & MU_KEYBD) != 0) { uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta, (short)aes_event_out.emo_kreturn); deskmenu_dispatch_keypress(aes_event_out.emo_kreturn, aes_event_out.emo_kmeta, nkc); } } tmp = window_list; while(tmp){ if(tmp->root->redraw_slots.areas_used > 0){ window_process_redraws(tmp->root); } tmp = tmp->next; } if(hl.tv->redraw){ atari_treeview_redraw(hl.tv); } if(gl_history.tv->redraw){ atari_treeview_redraw(gl_history.tv); } }
/** * Core atari event processing. */ static void atari_poll(void) { struct gui_window *tmp; short mx, my, dummy; aes_event_in.emi_tlow = schedule_run(); if(rendering){ aes_event_in.emi_tlow = nsoption_int(atari_gui_poll_timeout); } if(aes_event_in.emi_tlow < 0) { aes_event_in.emi_tlow = 10000; printf("long poll!\n"); } if(input_window && input_window->root->redraw_slots.areas_used > 0) { window_process_redraws(input_window->root); } graf_mkstate(&mx, &my, &dummy, &dummy); aes_event_in.emi_m1.g_x = mx; aes_event_in.emi_m1.g_y = my; evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); if(gemtk_wm_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out) == 0) { if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { LOG("WM: %d\n", aes_msg_out[0]); switch(aes_msg_out[0]) { case MN_SELECTED: LOG("Menu Item: %d\n", aes_msg_out[4]); deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); break; case AP_TERM: atari_quit = true; break; default: break; } } if((aes_event_out.emo_events & MU_KEYBD) != 0) { uint16_t nkc = gem_to_norm( (short)aes_event_out.emo_kmeta, (short)aes_event_out.emo_kreturn); deskmenu_dispatch_keypress(aes_event_out.emo_kreturn, aes_event_out.emo_kmeta, nkc); } } tmp = window_list; while(tmp){ if(tmp->root->redraw_slots.areas_used > 0){ window_process_redraws(tmp->root); } tmp = tmp->next; } /** @todo implement generic treeview redraw function. */ /** @todo rename hl to atari_hotlist or create getter for it... */ atari_treeview_flush_redraws(); }