delay npapi twirl for a half-second too

This commit is contained in:
David Rose 2011-08-26 22:01:16 +00:00
parent c63ccdf92a
commit e1baabdf26
2 changed files with 26 additions and 16 deletions

View File

@ -343,6 +343,7 @@ set_window(NPWindow *window) {
// Also set a timer to go off every once in a while, to update
// the twirling icon, and also to catch events in case something
// slips through.
_init_time = GetTickCount();
SetTimer(_hwnd, 1, 100, NULL);
}
#endif // _WIN32
@ -1731,6 +1732,9 @@ create_instance() {
}
#endif // __APPLE__
// In the Windows case, we let the timer keep running, because it
// also checks for wayward messages.
P3D_token *tokens = NULL;
if (!_tokens.empty()) {
tokens = &_tokens[0];
@ -2322,23 +2326,28 @@ win_paint_twirl(HWND hwnd, HDC dc) {
FillRect(bdc, &rect, _bg_brush);
if (!_started && !_failed) {
// Which frame are we drawing?
DWORD now = GetTickCount();
int step = (now / 100) % twirl_num_steps;
HBITMAP twirl = _twirl_bitmaps[step];
int left = rect.left + (width - twirl_width) / 2;
int top = rect.top + (height - twirl_height) / 2;
HDC mem_dc = CreateCompatibleDC(bdc);
SelectObject(mem_dc, twirl);
BitBlt(bdc, left, top, twirl_width, twirl_height,
mem_dc, 0, 0, SRCCOPY);
SelectObject(mem_dc, NULL);
DeleteDC(mem_dc);
// Don't draw the twirling icon until at least half a second has
// passed, so we don't distract people by drawing it
// unnecessarily.
if ((now - _init_time) >= 500) {
// Which frame are we drawing?
int step = (now / 100) % twirl_num_steps;
HBITMAP twirl = _twirl_bitmaps[step];
int left = rect.left + (width - twirl_width) / 2;
int top = rect.top + (height - twirl_height) / 2;
HDC mem_dc = CreateCompatibleDC(bdc);
SelectObject(mem_dc, twirl);
BitBlt(bdc, left, top, twirl_width, twirl_height,
mem_dc, 0, 0, SRCCOPY);
SelectObject(mem_dc, NULL);
DeleteDC(mem_dc);
}
}
// Now blit the buffer to the window.

View File

@ -221,6 +221,7 @@ private:
HWND _hwnd;
HBITMAP _twirl_bitmaps[twirl_num_steps];
HBRUSH _bg_brush;
DWORD _init_time;
#endif // _WIN32
#ifdef __APPLE__