mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 09:45:23 +02:00
Fix Window.setFocus() unsetting focus if Interface has focus
This commit is contained in:
parent
d888e7fd95
commit
287ea8eff2
3 changed files with 12 additions and 3 deletions
|
@ -7329,6 +7329,16 @@ bool Application::hasFocus() const {
|
|||
return (QApplication::activeWindow() != nullptr);
|
||||
}
|
||||
|
||||
void Application::setFocus() {
|
||||
// Note: Windows doesn't allow a user focus to be taken away from another application. Instead, it changes the color of and
|
||||
// flashes the taskbar icon.
|
||||
auto window = qApp->getWindow();
|
||||
window->activateWindow();
|
||||
|
||||
// Do NOT do the following because it takes focus away from the _displayPlugin.
|
||||
//window->setFocus();
|
||||
}
|
||||
|
||||
void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||
if (maxOctreePPS != _maxOctreePPS) {
|
||||
_maxOctreePPS = maxOctreePPS;
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
QRect getRecommendedHUDRect() const;
|
||||
glm::vec2 getDeviceSize() const;
|
||||
bool hasFocus() const;
|
||||
void setFocus();
|
||||
|
||||
void showCursor(const Cursor::Icon& cursor);
|
||||
|
||||
|
|
|
@ -74,9 +74,7 @@ QScriptValue WindowScriptingInterface::hasFocus() {
|
|||
void WindowScriptingInterface::setFocus() {
|
||||
// It's forbidden to call focus() from another thread.
|
||||
qApp->postLambdaEvent([] {
|
||||
auto window = qApp->getWindow();
|
||||
window->activateWindow();
|
||||
window->setFocus();
|
||||
qApp->setFocus();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue