mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Merge pull request #4258 from ctrlaltdavid/fix-windows-windowing
Fix maximized Windows window unintentionally changing to windowed
This commit is contained in:
commit
d84398524b
3 changed files with 40 additions and 11 deletions
|
@ -156,18 +156,27 @@ public:
|
||||||
bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE {
|
bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE {
|
||||||
if (eventType == "windows_generic_MSG") {
|
if (eventType == "windows_generic_MSG") {
|
||||||
MSG* message = (MSG*)msg;
|
MSG* message = (MSG*)msg;
|
||||||
|
|
||||||
if (message->message == UWM_IDENTIFY_INSTANCES) {
|
if (message->message == UWM_IDENTIFY_INSTANCES) {
|
||||||
*result = UWM_IDENTIFY_INSTANCES;
|
*result = UWM_IDENTIFY_INSTANCES;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (message->message == WM_SHOWWINDOW) {
|
|
||||||
Application::getInstance()->getWindow()->showNormal();
|
if (message->message == UWM_SHOW_APPLICATION) {
|
||||||
|
MainWindow* applicationWindow = Application::getInstance()->getWindow();
|
||||||
|
if (applicationWindow->isMinimized()) {
|
||||||
|
applicationWindow->showNormal(); // Restores to windowed or maximized state appropriately.
|
||||||
|
}
|
||||||
|
Application::getInstance()->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->message == WM_COPYDATA) {
|
if (message->message == WM_COPYDATA) {
|
||||||
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
|
||||||
QUrl url = QUrl((const char*)(pcds->lpData));
|
QUrl url = QUrl((const char*)(pcds->lpData));
|
||||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
DependencyManager::get<AddressManager>()->handleLookupString(url.toString());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static const UINT UWM_IDENTIFY_INSTANCES =
|
static const UINT UWM_IDENTIFY_INSTANCES =
|
||||||
RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}");
|
RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}");
|
||||||
|
static const UINT UWM_SHOW_APPLICATION =
|
||||||
|
RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
@ -36,7 +37,7 @@ static BOOL CALLBACK enumWindowsCallback(HWND hWnd, LPARAM lParam) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Run only one instance of Interface at a time.
|
// Run only one instance of Interface at a time.
|
||||||
HANDLE mutex = CreateMutex(NULL, FALSE, "High Fidelity Interface");
|
HANDLE mutex = CreateMutex(NULL, FALSE, "High Fidelity Interface");
|
||||||
|
@ -46,15 +47,32 @@ int main(int argc, const char * argv[]) {
|
||||||
HWND otherInstance = NULL;
|
HWND otherInstance = NULL;
|
||||||
EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance);
|
EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance);
|
||||||
if (otherInstance) {
|
if (otherInstance) {
|
||||||
ShowWindow(otherInstance, SW_RESTORE);
|
// Show other instance.
|
||||||
SetForegroundWindow(otherInstance);
|
SendMessage(otherInstance, UWM_SHOW_APPLICATION, 0, 0);
|
||||||
|
|
||||||
QUrl url = QUrl(argv[1]);
|
// Send command line --url value to other instance.
|
||||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
if (argc >= 3) {
|
||||||
COPYDATASTRUCT cds;
|
QStringList arguments;
|
||||||
cds.cbData = strlen(argv[1]) + 1;
|
for (int i = 0; i < argc; i += 1) {
|
||||||
cds.lpData = (PVOID)argv[1];
|
arguments << argv[i];
|
||||||
SendMessage(otherInstance, WM_COPYDATA, 0, (LPARAM)&cds);
|
}
|
||||||
|
|
||||||
|
QCommandLineParser parser;
|
||||||
|
QCommandLineOption urlOption("url", "", "value");
|
||||||
|
parser.addOption(urlOption);
|
||||||
|
parser.process(arguments);
|
||||||
|
|
||||||
|
if (parser.isSet(urlOption)) {
|
||||||
|
QUrl url = QUrl(parser.value(urlOption));
|
||||||
|
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
||||||
|
QByteArray urlBytes = url.toString().toLatin1();
|
||||||
|
const char* urlChars = urlBytes.data();
|
||||||
|
COPYDATASTRUCT cds;
|
||||||
|
cds.cbData = urlBytes.length() + 1;
|
||||||
|
cds.lpData = (PVOID)urlChars;
|
||||||
|
SendMessage(otherInstance, WM_COPYDATA, 0, (LPARAM)&cds);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue