From 0309e8379148c23bc5fb6e68fcf5ae4e8be44d8d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 27 Jul 2012 19:08:41 +0000 Subject: [PATCH] - attempt to have windows screen come to forefront sooner --- .../include/platform/sdl/platform_util.h | 2 +- .../sources/platform/sdl/window.cpp | 3 +++ .../sources/platform/win32/platform_util.cpp | 26 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/source/shared_lib/include/platform/sdl/platform_util.h b/source/shared_lib/include/platform/sdl/platform_util.h index b48153d6..d4d547cf 100644 --- a/source/shared_lib/include/platform/sdl/platform_util.h +++ b/source/shared_lib/include/platform/sdl/platform_util.h @@ -104,7 +104,7 @@ void exceptionMessage(const exception &excp); string getCommandLine(); void init_win32(); void done_win32(); - +void ontop_win32(int width, int height); // The following is used for stacking tracing for windows based exceptions #if !defined(_DEBUG) && !defined(__GNUC__) diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index b5fdc713..9d5ccece 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -401,6 +401,9 @@ void Window::setStyle(WindowStyle windowStyle) { void Window::create() { // nothing here +#ifdef WIN32 + ontop_win32(this->w,this->h); +#endif } void Window::destroy() { diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index 0d4bc0d3..b0b96471 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -395,8 +395,7 @@ void init_win32() { SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version) - if (SDL_GetWMInfo(&wminfo) != 1) - { + if (SDL_GetWMInfo(&wminfo) != 1) { // error: wrong SDL version } @@ -412,11 +411,26 @@ void init_win32() { ::SetClassLong(hwnd, GCL_HICON, iconPtr); #endif - SetWindowLong(hwnd, GWL_EXSTYLE, 0); - SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); - //SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, fsWidth, fsHeight, SWP_SHOWWINDOW); + ontop_win32(0, 0); } + +void ontop_win32(int width, int height) { + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version) + if (SDL_GetWMInfo(&wminfo) != 1) { + // error: wrong SDL version + } + + HWND hwnd = wminfo.window; + + SetWindowLong(hwnd, GWL_EXSTYLE, 0); + SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); + if(width > 0 && height > 0) { + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, width, height, SWP_SHOWWINDOW); + } +} + void done_win32() { ::DestroyIcon(icon); }