From 9d90b26020af83d11ec0900117495901d445e907 Mon Sep 17 00:00:00 2001 From: Daniel Lundqvist Date: Fri, 26 Dec 2014 02:37:52 +0100 Subject: Allow focus on the Qt render widget By default widgets are set to the focus policy Qt::NoFocus which disallows manually focusing it. Changing the policy to allow clicking the widget to set focus to it allows for keyboard input when not rendering to a popout window. This commit also sets focus to the widget when showing it. Fixes issue #158. --- src/citra_qt/bootmanager.cpp | 3 +++ src/citra_qt/main.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 6d08d6afc..d44ddb096 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -123,6 +123,9 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); setWindowTitle(QString::fromStdString(window_title)); + // Allow manually setting focus to the widget. + setFocusPolicy(Qt::ClickFocus); + keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 23d4925b8..9fc8705e6 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -170,6 +170,7 @@ void GMainWindow::BootGame(std::string filename) render_window->GetEmuThread().start(); render_window->show(); + render_window->setFocus(); OnStartGame(); } -- cgit v1.2.3 From ba4ca041f4be1285185a56ba37ae2023c27a326b Mon Sep 17 00:00:00 2001 From: Daniel Lundqvist Date: Fri, 26 Dec 2014 19:42:27 +0100 Subject: Allow focus only when in popout mode Only allow manually setting focus to the rendering widget when in Single Window mode. Apply this behavior to when changing the mode while an app is running. --- src/citra_qt/bootmanager.cpp | 3 --- src/citra_qt/main.cpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index d44ddb096..6d08d6afc 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -123,9 +123,6 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); setWindowTitle(QString::fromStdString(window_title)); - // Allow manually setting focus to the widget. - setFocusPolicy(Qt::ClickFocus); - keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9fc8705e6..37d69ac13 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -170,7 +170,13 @@ void GMainWindow::BootGame(std::string filename) render_window->GetEmuThread().start(); render_window->show(); - render_window->setFocus(); + + // Allow manually setting focus to the render widget if not using popout mode. + if (!ui.action_Popout_Window_Mode->isChecked()) { + render_window->setFocusPolicy(Qt::ClickFocus); + render_window->setFocus(); + } + OnStartGame(); } @@ -231,12 +237,15 @@ void GMainWindow::ToggleWindowMode() render_window->setParent(nullptr); render_window->setVisible(true); render_window->RestoreGeometry(); + render_window->setFocusPolicy(Qt::NoFocus); } else if (!enable && render_window->parent() == nullptr) { render_window->BackupGeometry(); ui.horizontalLayout->addWidget(render_window); render_window->setVisible(true); + render_window->setFocusPolicy(Qt::ClickFocus); + render_window->setFocus(); } } -- cgit v1.2.3 From 7e3f62a367856ef5e6b449abeb3a7ce45e619533 Mon Sep 17 00:00:00 2001 From: Daniel Lundqvist Date: Fri, 26 Dec 2014 20:12:11 +0100 Subject: Remove duplicate work --- src/citra_qt/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 37d69ac13..b12e6a02b 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -170,13 +170,6 @@ void GMainWindow::BootGame(std::string filename) render_window->GetEmuThread().start(); render_window->show(); - - // Allow manually setting focus to the render widget if not using popout mode. - if (!ui.action_Popout_Window_Mode->isChecked()) { - render_window->setFocusPolicy(Qt::ClickFocus); - render_window->setFocus(); - } - OnStartGame(); } -- cgit v1.2.3