[Bf-taskforce25] WM_main() (Blender 2.5)
Dietrich Bollmann
diresu at web.de
Sat Jun 27 02:54:49 CEST 2009
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: text/x-patch
Size: 2507 bytes
Desc: not available
Url : http://lists.blender.org/pipermail/bf-taskforce25/attachments/20090627/566f790c/attachment.bin
More information about the Bf-taskforce25
mailing list