From 4635d9bf767f8ac4601405bd357138ffb1569c24 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 30 Nov 2013 13:10:34 +0100 Subject: [PATCH] Make sure splash screen gets focus. Also better key press/release handling in working banner. --- src/Config.h | 2 +- src/Dialog_SplashScreen.cpp | 4 +++- src/Dialog_WorkingBanner.cpp | 4 ++-- src/Global.h | 1 + src/Global_Win32.cpp | 28 ++++++++++++++++++++++++++-- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/Config.h b/src/Config.h index cb4af1ca..57f52214 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 9 -#define VER_LAMEXP_BUILD 1490 +#define VER_LAMEXP_BUILD 1495 #define VER_LAMEXP_CONFG 1348 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Dialog_SplashScreen.cpp b/src/Dialog_SplashScreen.cpp index 2584641a..e9c44278 100644 --- a/src/Dialog_SplashScreen.cpp +++ b/src/Dialog_SplashScreen.cpp @@ -126,7 +126,7 @@ void SplashScreen::showSplash(QThread *thread) //Wait for window to show QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - splashScreen->repaint(); + splashScreen->repaint(); lamexp_bring_to_front(splashScreen); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); //Connect thread signals @@ -181,6 +181,7 @@ void SplashScreen::updateHandler(void) else { setWindowOpacity(1.0); + lamexp_bring_to_front(this); m_timer->stop(); m_status = STATUS_WAIT; } @@ -209,6 +210,7 @@ void SplashScreen::threadComplete(void) { m_timer->start(FADE_DELAY); } + lamexp_bring_to_front(this); } //////////////////////////////////////////////////////////// diff --git a/src/Dialog_WorkingBanner.cpp b/src/Dialog_WorkingBanner.cpp index 98484035..d7414f83 100644 --- a/src/Dialog_WorkingBanner.cpp +++ b/src/Dialog_WorkingBanner.cpp @@ -236,12 +236,12 @@ void WorkingBanner::keyPressEvent(QKeyEvent *event) QTimer::singleShot(0, parent(), SLOT(showMinimized())); } - event->ignore(); + QDialog::keyPressEvent(event); } void WorkingBanner::keyReleaseEvent(QKeyEvent *event) { - event->ignore(); + QDialog::keyReleaseEvent(event); } void WorkingBanner::closeEvent(QCloseEvent *event) diff --git a/src/Global.h b/src/Global.h index 7a4a35d0..efa16dcd 100644 --- a/src/Global.h +++ b/src/Global.h @@ -149,6 +149,7 @@ const QStringList &lamexp_arguments(void); QStringList lamexp_available_codepages(bool noAliases = true); bool lamexp_beep(int beepType); void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150); +bool lamexp_block_window_move(void *message); bool lamexp_bring_process_to_front(const unsigned long pid); bool lamexp_bring_to_front(const QWidget *win); bool lamexp_broadcast(int eventType, bool onlyToVisible); diff --git a/src/Global_Win32.cpp b/src/Global_Win32.cpp index 7c75868f..c187001f 100644 --- a/src/Global_Win32.cpp +++ b/src/Global_Win32.cpp @@ -1496,6 +1496,26 @@ int lamexp_system_message(const wchar_t *text, int beepType) } /* + * Block window "move" message + */ +bool lamexp_block_window_move(void *message) +{ + if(message) + { + MSG *msg = reinterpret_cast(message); + if((msg->message == WM_SYSCOMMAND) && (msg->wParam == SC_MOVE)) + { + return true; + } + if((msg->message == WM_NCLBUTTONDOWN) && (msg->wParam == HTCAPTION)) + { + return true; + } + } + return false; +} + +/* * Suspend calling thread for N milliseconds */ inline void lamexp_sleep(const unsigned int delay) @@ -1745,8 +1765,12 @@ bool lamexp_bring_to_front(const QWidget *window) if(window) { - ret = (SetForegroundWindow(window->winId()) == TRUE); - SwitchToThisWindow(window->winId(), TRUE); + for(int i = 0; (i < 5) && (!ret); i++) + { + ret = (SetForegroundWindow(window->winId()) != FALSE); + SwitchToThisWindow(window->winId(), TRUE); + } + LockSetForegroundWindow(LSFW_LOCK); } return ret; -- 2.11.0