diff --git a/base/applications/screensavers/3dtext/3dtext.c b/base/applications/screensavers/3dtext/3dtext.c index a64e3252ec..f638a09f91 100644 --- a/base/applications/screensavers/3dtext/3dtext.c +++ b/base/applications/screensavers/3dtext/3dtext.c @@ -40,20 +40,17 @@ GLfloat extentY = 0.0f; #define APPNAME _T("3DText") HINSTANCE hInstance; -BOOL fullscreen = FALSE; +#define APP_TIMER 1 +#define APP_TIMER_INTERVAL USER_TIMER_MINIMUM // Build Our Bitmap Font GLvoid BuildFont(GLvoid) { - // Address Buffer For Font Storage - GLYPHMETRICSFLOAT gmf[256]; - // Windows Font Handle - HFONT font; + HFONT font; // Windows Font Handle + GLYPHMETRICSFLOAT gmf[256]; // Address Buffer For Font Storage size_t i; TCHAR c; - GLfloat cellOriginX = 0.0f; - GLfloat stringOriginX; - GLfloat stringExtentX = 0.0f; + GLfloat stringCellX = 0.0f; GLfloat stringExtentY = 0.0f; // Storage For 256 Characters @@ -91,16 +88,13 @@ GLvoid BuildFont(GLvoid) { c = m_Text[i]; - stringOriginX = cellOriginX + gmf[c].gmfptGlyphOrigin.x; - - stringExtentX = stringOriginX + gmf[c].gmfBlackBoxX; if (gmf[c].gmfBlackBoxY > stringExtentY) stringExtentY = gmf[c].gmfBlackBoxY; - cellOriginX = cellOriginX + gmf[c].gmfCellIncX; + stringCellX += gmf[c].gmfCellIncX; } - extentX = stringExtentX; + extentX = stringCellX; extentY = stringExtentY; } @@ -121,7 +115,7 @@ GLvoid glPrint(LPTSTR text) // Pushes The Display List Bits glPushAttrib(GL_LIST_BIT); - // Sets The Base Character to 32 + // Sets The Base Character glListBase(base); // Draws The Display List Text @@ -236,9 +230,9 @@ GLvoid DrawGLScene(GLvoid) 0.0f); // Pulsing Colors Based On The Rotation - glColor3f((1.0f * (GLfloat)(cos(rot / 20.0f))), - (1.0f * (GLfloat)(sin(rot / 25.0f))), - (1.0f - 0.5f * (GLfloat)(cos(rot / 17.0f)))); + glColor3f((1.0f - 0.25f * (GLfloat)(cos(rot / 20.0f))), + (1.0f - 0.25f * (GLfloat)(sin(rot / 25.0f))), + (1.0f - 0.25f * (GLfloat)(cos(rot / 17.0f)))); // Print GL Text To The Screen glPrint(m_Text); @@ -255,6 +249,7 @@ GLvoid DrawGLScene(GLvoid) LRESULT CALLBACK ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + static BOOL fullscreen = FALSE; RECT Screen; // Used Later On To Get The Size Of The Window GLuint PixelFormat; // Pixel Format Storage static PIXELFORMATDESCRIPTOR pfd= // Pixel Format Descriptor @@ -263,7 +258,7 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 1, // Version Number (?) PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, // Must Support Double Buffering + PFD_DOUBLEBUFFER, // Format Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 16, // Select A 16Bit Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored (?) @@ -282,6 +277,8 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_CREATE: + fullscreen = GetParent(hWnd) ? FALSE : TRUE; //Screensaver in fullscreen has no window-owner + LoadSettings(); // Gets A Device Context For The Window @@ -338,6 +335,14 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // Initialize The GL Screen Using Screen Info InitGL(Screen.right, Screen.bottom); + + // When it's not fullscreen we should release DC, + // because each wm_paint call needs its own DC. + if (!fullscreen){ + ReleaseDC(hWnd, hDC); + } + SetTimer(hWnd, APP_TIMER, APP_TIMER_INTERVAL, NULL); + break; case WM_DESTROY: @@ -358,15 +363,35 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_PAINT: + { + PAINTSTRUCT ps; + if (!fullscreen){ + hDC = BeginPaint(hWnd, &ps); //new DC is necessary because screensaver overlaps other windows + wglMakeCurrent(hDC, hRC); //and cant be moved to another place + } + DrawGLScene(); SwapBuffers(hDC); + + if (!fullscreen){ + EndPaint(hWnd, &ps); //don't release DC to support double buffering in fullscreen mode + } else { + ValidateRect(hWnd, NULL); //don't generate wm_paint message till next timer signal + } break; + } case WM_SIZE: // Resizing The Screen // Resize To The New Window Size ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); break; + case WM_TIMER: //timer sets rate of update + { + InvalidateRect(hWnd, NULL, 1); + break; + } + default: // Pass Windows Messages to the default screensaver window procedure return DefScreenSaverProc(hWnd, message, wParam, lParam); diff --git a/base/applications/screensavers/3dtext/settings.c b/base/applications/screensavers/3dtext/settings.c index 7e892ee0ef..1b455ab51b 100644 --- a/base/applications/screensavers/3dtext/settings.c +++ b/base/applications/screensavers/3dtext/settings.c @@ -47,4 +47,10 @@ VOID SaveSettings(VOID) RegSetValueEx(hkey, _T("DisplayString"), 0, REG_SZ, (LPBYTE)m_Text, (_tcslen(m_Text) + 1) * sizeof(TCHAR)); RegCloseKey(hkey); } + if (RegCreateKeyEx(HKEY_USERS, _T(".DEFAULT\\Software\\Microsoft\\ScreenSavers\\Text3D"), 0, + _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS) + { + RegSetValueEx(hkey, _T("DisplayString"), 0, REG_SZ, (LPBYTE)m_Text, (_tcslen(m_Text) + 1) * sizeof(TCHAR)); + RegCloseKey(hkey); + } } diff --git a/dll/cpl/desk/screensaver.c b/dll/cpl/desk/screensaver.c index 02c05c9b65..2d2e9390bf 100644 --- a/dll/cpl/desk/screensaver.c +++ b/dll/cpl/desk/screensaver.c @@ -163,22 +163,18 @@ WaitForSettingsDialog(HWND hwndDlg, QS_ALLINPUT); if (dwResult == WAIT_OBJECT_0 + 1) { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { return FALSE; } - if (IsDialogMessage(hwndDlg, &msg)) + if (!IsDialogMessage(hwndDlg, &msg)) //if true, msg already translated and dispatched { TranslateMessage(&msg); DispatchMessage(&msg); } } - else - { - return FALSE; - } } else if (dwResult == WAIT_OBJECT_0) {