Skip to content

Commit 6d2128a

Browse files
committed
Make Qt shortcuts actually work in fullscreen
Also removes hacks related to fullscreen.
1 parent fd2214f commit 6d2128a

File tree

3 files changed

+28
-36
lines changed

3 files changed

+28
-36
lines changed

src/qt/qt_main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ win_keyboard_handle(uint32_t scancode, int up, int e0, int e1)
194194
it's not an invalid scan code. */
195195
if (scancode != 0xFFFF)
196196
keyboard_input(!up, scancode);
197-
198-
main_window->checkFullscreenHotkey();
199197
}
200198
}
201199

@@ -370,8 +368,6 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
370368
else if ((lpKdhs->scanCode == 0x3e) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
371369
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
372370
ret = TRUE;
373-
else if ((lpKdhs->scanCode == 0x49) && bCtrlDown && !(lpKdhs->flags & LLKHF_UP))
374-
ret = TRUE;
375371
else if ((lpKdhs->scanCode >= 0x5b) && (lpKdhs->scanCode <= 0x5d) && (lpKdhs->flags & LLKHF_EXTENDED))
376372
ret = TRUE;
377373
else if (inhibit_multimedia_keys

src/qt/qt_mainwindow.cpp

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,13 @@ MainWindow::MainWindow(QWidget *parent)
674674
/* Remove default Shift+F10 handler, which unfocuses keyboard input even with no context menu. */
675675
connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, [](){});
676676

677+
auto windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_PageDown), this);
678+
windowedShortcut->setContext(Qt::ShortcutContext::ApplicationShortcut);
679+
connect(windowedShortcut, &QShortcut::activated, this, [this] () {
680+
if (video_fullscreen)
681+
ui->actionFullscreen->trigger();
682+
});
683+
677684
connect(this, &MainWindow::initRendererMonitor, this, &MainWindow::initRendererMonitorSlot);
678685
connect(this, &MainWindow::initRendererMonitorForNonQtThread, this, &MainWindow::initRendererMonitorSlot, Qt::BlockingQueuedConnection);
679686
connect(this, &MainWindow::destroyRendererMonitor, this, &MainWindow::destroyRendererMonitorSlot);
@@ -696,6 +703,22 @@ MainWindow::MainWindow(QWidget *parent)
696703
});
697704
#endif
698705

706+
QTimer::singleShot(0, this, [this]() {
707+
for (auto curObj : this->menuBar()->children()) {
708+
if (qobject_cast<QMenu *>(curObj)) {
709+
auto menu = qobject_cast<QMenu *>(curObj);
710+
for (auto curObj2 : menu->children()) {
711+
if (qobject_cast<QAction *>(curObj2)) {
712+
auto action = qobject_cast<QAction *>(curObj2);
713+
if (!action->shortcut().isEmpty()) {
714+
this->insertAction(nullptr, action);
715+
}
716+
}
717+
}
718+
}
719+
}
720+
});
721+
699722
actGroup = new QActionGroup(this);
700723
actGroup->addAction(ui->actionCursor_Puck);
701724
actGroup->addAction(ui->actionPen);
@@ -833,6 +856,11 @@ MainWindow::initRendererMonitorSlot(int monitor_index)
833856
});
834857
secondaryRenderer->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
835858
secondaryRenderer->setWindowTitle(QObject::tr("86Box Monitor #") + QString::number(monitor_index + 1));
859+
secondaryRenderer->setContextMenuPolicy(Qt::PreventContextMenu);
860+
861+
for (int i = 0; i < this->actions().size(); i++) {
862+
secondaryRenderer->addAction(this->actions()[i]);
863+
}
836864

837865
if (vid_resize == 2)
838866
secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y);
@@ -1360,18 +1388,9 @@ MainWindow::keyPressEvent(QKeyEvent *event)
13601388
#endif
13611389
}
13621390

1363-
checkFullscreenHotkey();
1364-
13651391
if (keyboard_ismsexit())
13661392
plat_mouse_capture(0);
13671393

1368-
if ((video_fullscreen > 0) && (keyboard_recv_ui(0x1D) || keyboard_recv_ui(0x11D))) {
1369-
if (keyboard_recv_ui(0x57))
1370-
ui->actionTake_screenshot->trigger();
1371-
else if (keyboard_recv_ui(0x58))
1372-
pc_send_cad();
1373-
}
1374-
13751394
event->accept();
13761395
}
13771396

@@ -1403,28 +1422,6 @@ MainWindow::keyReleaseEvent(QKeyEvent *event)
14031422
processKeyboardInput(false, event->nativeScanCode());
14041423
#endif
14051424
}
1406-
1407-
checkFullscreenHotkey();
1408-
}
1409-
1410-
void
1411-
MainWindow::checkFullscreenHotkey()
1412-
{
1413-
if (!fs_off_signal && video_fullscreen && keyboard_isfsexit()) {
1414-
/* Signal "exit fullscreen mode". */
1415-
fs_off_signal = true;
1416-
} else if (fs_off_signal && video_fullscreen && keyboard_isfsexit_up()) {
1417-
ui->actionFullscreen->trigger();
1418-
fs_off_signal = false;
1419-
}
1420-
1421-
if (!fs_on_signal && !video_fullscreen && keyboard_isfsenter()) {
1422-
/* Signal "enter fullscreen mode". */
1423-
fs_on_signal = true;
1424-
} else if (fs_on_signal && !video_fullscreen && keyboard_isfsenter_up()) {
1425-
ui->actionFullscreen->trigger();
1426-
fs_on_signal = false;
1427-
}
14281425
}
14291426

14301427
QSize

src/qt/qt_mainwindow.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class MainWindow : public QMainWindow {
3131
void blitToWidget(int x, int y, int w, int h, int monitor_index);
3232
QSize getRenderWidgetSize();
3333
void setSendKeyboardInput(bool enabled);
34-
void checkFullscreenHotkey();
3534
void reloadAllRenderers();
3635

3736
std::array<std::unique_ptr<RendererStack>, 8> renderers;

0 commit comments

Comments
 (0)