[Bf-taskforce25] WM_main() (Blender 2.5)
Ton Roosendaal
ton at blender.org
Sat Jun 27 13:17:50 CEST 2009
Hi,
Thanks for the suggestion.
Your idea is correct, but for time being I like to stick to this code
to be fully aware of all queue overhead. Optimize is for later. :)
-Ton-
------------------------------------------------------------------------
Ton Roosendaal Blender Foundation ton at blender.org www.blender.org
Blender Institute Entrepotdok 57A 1018AD Amsterdam The Netherlands
On 27 Jun, 2009, at 2:54, Dietrich Bollmann wrote:
> Hi,
>
> I wonder if it is necessary to go through all window event queues if
> no timer or ghost event has been found?
>
> Here the relevant code:
>
> file: blender2.5/blender/source/blender/windowmanager/intern/wm.c
>
> <code>
>
> void WM_main(bContext *C)
> {
> while(1) {
>
> /* get events from ghost, handle window events, add to window queues
> */
> wm_window_process_events(C);
>
> /* per window, all events to the window, screen, area and region
> handlers */
> wm_event_do_handlers(C);
>
> /* events have left notes about changes, we handle and cache it */
> wm_event_do_notifiers(C);
>
> /* execute cached changes draw */
> wm_draw_update(C);
> }
> }
>
> </code>
>
> file:
> blender2.5/blender/source/blender/windowmanager/intern/wm_window.c
>
> <code>
>
> void wm_window_process_events(const bContext *C)
> {
> int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
>
> if(hasevent)
> GHOST_DispatchEvents(g_system);
>
> hasevent |= wm_window_timer(C);
>
> /* no event, we sleep 5 milliseconds */
> if(hasevent==0)
> PIL_sleep_ms(5);
> }
>
> </code>
>
> - the main loop looks for new ghost or timer events in
> 'wm_window_process_events(C)'
> and sleeps for 5 milliseconds when no new events have been found
> - after it goes through all window event queues
>
> But if no event have been found, is it necessary to call
> 'wm_event_do_handlers(C)', 'wm_event_do_notifiers(C)' and
> 'wm_draw_update(C)'?
>
> How about the following version which only goes through the latter
> functions if new events have been found?
>
> file: blender2.5/blender/source/blender/windowmanager/intern/wm.c
>
> <code>
>
> void WM_main(bContext *C)
> {
> int hasevent;
> while(1) {
>
> /* get events from ghost, handle window events, add to window queues
> */
> hasevent = wm_window_process_events(C);
>
> /* are there new events to process? */
> if (hasevent) {
>
> /* processing new events */
>
> /* per window, all events to the window, screen, area and region
> handlers */
> wm_event_do_handlers(C);
>
> /* events have left notes about changes, we handle and cache it */
> wm_event_do_notifiers(C);
>
> /* execute cached changes draw */
> wm_draw_update(C);
>
> } else {
>
> /* no event, we sleep 5 milliseconds */
> PIL_sleep_ms(5);
> }
> }
> }
>
> </code>
>
> file:
> blender2.5/blender/source/blender/windowmanager/intern/wm_window.c
>
> <code>
>
> int wm_window_process_events(const bContext *C)
> {
> int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
>
> if(hasevent)
> GHOST_DispatchEvents(g_system);
>
> hasevent |= wm_window_timer(C);
>
> return hasevent;
> }
>
> </code>
>
> I attached a diff to the end of this mail. If I should post another
> one
> to the patch tracker please let me know.
>
> Cheers, Dietrich
>
>
> <patch>_______________________________________________
> Bf-taskforce25 mailing list
> Bf-taskforce25 at blender.org
> http://lists.blender.org/mailman/listinfo/bf-taskforce25
More information about the Bf-taskforce25
mailing list