163 Commits

Author SHA1 Message Date
John Chadwick
9716212d70 hiro/qt: HexEdit: Match scroll logic with ares
I didn't realize that some of the Qt deprecations were already fixed in
ares. In this case, the change was handled a bit differently, always
considering the y component of scrolling even when the scroll operation
is mostly horizontal. This should work just fine, so we may as well just
adopt that behavior, especially since bsnes doesn't even currently use a
HexEdit.

Backported from ares from:
ffe97222a1

Co-authored-by: Stefan Schlosser <bsdcode@disroot.org>
2025-09-02 18:09:42 +10:00
John Chadwick
27fdd39e5c hiro/qt: Fix missing overrides
There are a handful of spots in hiro/qt where methods override Qt
virtual methods, but they are not declared as such.

These are backported from ares from:
960d8a8dcb

Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
b3ce74253e hiro/qt: Explicitly use nall string in call to Font::size
This is back-ported from ares:
0d131bf4d8

Co-authored-by: invertego <invertego@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
64a433a644 hiro/qt: Fix incorrect argument to nall::image::scale
The `linear` parameter to `image::scale` is a boolean, not an
enumeration.

This is a back port from ares:
960d8a8dcb

Also, remove the blob of commented code. This was removed in ares v117.

Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
d3a3280f90 hiro/qt: Silence missing override warning in Clang for moc code
With Qt 6 maybe it is possible to finally start cleaning that issue up
in the first place, but for now it's probably better for bsnes and ares
to align closer.

This is backported from the following ares commits:
0d131bf4d8
960d8a8dcb

Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
Co-authored-by: invertego <invertego@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
924fa315dc hiro/qt: Unify Monitor implementation with ares
Some of the work I'd done was duplicating existing work. Let's unify to
get the best of both works.

This mostly comes from:
ffe97222a1

Co-authored-by: Stefan Schlosser <bsdcode@disroot.org>
2025-09-02 18:09:42 +10:00
John Chadwick
50ac621430 hiro/qt: Better fix for QFontMetrics::width deprecation
The desired size was probably the boundingRect width and not the advance
width, so the fix from bsdcode is better than mine.

This is backported from ares:
ffe97222a1

Co-authored-by: Stefan Schlosser <bsdcode@disroot.org>
2025-09-02 18:09:42 +10:00
John Chadwick
b424c4b2f7 hiro/qt: Fixes in Application::initialize
- Call XInitThreads at initialization
- Remove spaces from screensaver window name
- Restore LC_NUMERIC after Qt clobbers it

This is sourced from ares v116r07, and:
6cd4470562

Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
ad259a55c0 hiro/qt: Silence xdg-screensaver output
Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
f83bc75270 hiro/qt: Add #if guards to X11 code
This is a backport from ares:
b85395fe7b

Co-authored-by: invertego <invertego@users.noreply.github.com>
2025-09-02 18:09:42 +10:00
John Chadwick
ec8aed3f3b hiro/qt: Add support for compiling with Qt 6 2025-09-02 18:02:58 +10:00
Tim Allen
b7678f5261 hiro/gtk: Remove pendingEvents here too.
Now that pApplication::pendingEvents() has been removed from hiro/core, it
should be removed from the GTK+ backend too.
2025-09-02 01:13:17 +10:00
John Chadwick
08e6de3186 hiro/qt: Remove pendingEvents, add timeout to processEvents
Qt 6 no longer allows us to poll for the status of the event loop.
However, Qt 6 does still have a processEvents function, and the version
with the timeout actually spins the event loop and returns as early as
there are no more events in it. That's basically what we want to do. We
could run this with a really huge timeout, but that would just make it
more likely that hiro freezes up, so instead let's mirror hiro/gtk3 and
use a 50ms timeout.
2025-09-02 01:13:17 +10:00
John Chadwick
aec384b4b0 hiro/core: Remove Application::pendingEvents
This does not seem to be used anywhere in bsnes, higan or ares. It's not
really possible to implement with Qt 6, which has stop exposing this
detail of the event loop. It turns out this is actually OK, since we
don't *really* need it anyway, and in the case of hiro/qt, the
replacement should be more robust anyways.
2025-09-02 01:13:17 +10:00
John Chadwick
253075bfd8 hiro/qt: Use QScreen for Monitor
Qt 5 introduces QScreen, which can be used to implement most of the
functionality needed by Monitor, although some of it probably won't make
sense when using Wayland.
2025-09-02 01:01:04 +10:00
John Chadwick
88de1f11f1 hiro/qt: Fix deprecated QWheelEvent->{delta,orientation}() usage
The orientation() and delta() methods of QWheelEvent were deprecated in
Qt 5.0 in favor of angleDelta(), which expresses higher-fidelity data
for devices like trackpads. In order to keep the behavior 100%
identical, the code used to calculate the orientation() and delta()
values in Qt 5.15 is inlined instead. That logic can be seen here:

https://github.com/qt/qtbase/blob/v5.15.17-lts-lgpl/src/gui/kernel/qevent.cpp#L876-L884

Following this logic, we also break the tie for orientation in favor of
vertical scrolling.

Since there is no actual HexEdit usage in bsnes, I tested it by putting
a dummy HexEdit widget inside the bsnes Presentation window. Scrolling
seemed to work as expected.
2025-09-02 00:52:37 +10:00
John Chadwick
a4f0b478ea hiro/qt: QPalette::Background -> QPalette::Window 2025-09-02 00:36:36 +10:00
John Chadwick
a6db3d6013 hiro/qt: QLayout::setMargin -> QLayout::setContentsMargins
setMargin has been obsolete since Qt 4.3!
2025-09-02 00:36:36 +10:00
John Chadwick
fb09f52093 hiro/qt: QFontMetrics::width -> QFontMetrics::horizontalAdvance
QFontMetrics::width was deprecated in Qt 5.11 in favor of Qt
QFontMetrics::horizontalAdvance. Because QFontMetrics::horizontalAdvance
was introduced in Qt 5.11, it poses the most risk of breaking an
existing user of almost any of the deprecation changes, but Qt 5.11 is
fairly old by now (2018) and has been EOL for a while, so I still opted
to just move to the new function rather than use a version guard.
2025-09-02 00:36:36 +10:00
John Chadwick
58694a2935 hiro/qt: Update deprecated MidButton enumeration
This enum was deprecated in Qt 4.8 and removed in Qt 6.0.
2025-09-02 00:36:36 +10:00
John Chadwick
f05dd784fd Use QScreen for Desktop::{size,workspace}
Qt 5.0 adds the QScreen API, which exposes enough information that
Desktop::{size,workspace} no longer needs to fall back to Win32/Xlib. I
manually tested that this seems to give the same exact answers as the
Xlib path (though it technically goes a different route for
Desktop::size.)
2025-08-31 01:48:26 +10:00
John Chadwick
8011051eea Remove Qt 4 support.
Qt 4.8 LTS was released on December 15th, 2011. It hit its official
end-of-life on December 31st, 2015. It has been dead for nearly 10
years. Qt 4 is now so old, that it has been removed from Debian long
enough that "qt4" doesn't show up in *any* of the indexed package suites
in Debian's online package search service.

With that in mind, I think we can safely say nobody is using this,
nobody will miss this, and it is beyond time to get rid of it (and
probably add Qt 6 support some day.)
2025-08-31 01:31:10 +10:00
Tim Allen
2b7bc3b08e Build bsnes with GTK+3 on Ubuntu and FreeBSD.
The latest version of Ubuntu no longer provides the GTK+2 libs that bsnes
requires.
2023-11-13 21:12:18 +11:00
Rasim Labibov
3f93cd4393 hiro: Force Gtk3 to use X11 backend 2023-11-13 21:12:18 +11:00
Tim Allen
83e76c87eb hiro: Disable padding for the GTK+3 backend.
GTK+3 is designed for automatic layout, where widgets are automatically sized
and positioned according to the size of their contents. However, hiro has to be
compatible with Windows, which lacks an automatic layout system, so hiro apps
tend to position widgets manually.

Unfortunately, the GTK+3 default theme uses much bigger widgets than GTK+2 or
Windows, so hiro apps using the GTK+3 backend tend to have ugly, overlapping
widgets. To make GTK+3 behave more like other hiro targets, we add custom CSS
and override the default theme at runtime.

Fixes #168.
2021-04-03 19:24:31 +11:00
Tim Allen
73b275a7d0 hiro: Remove gtksourceview dependency.
The GTK2 and GTK3 backends for hiro implement a source-code editing widget
based on gtksourceview. gtksourceview2 in particular is quite old and
unmaintained, and Linux distros are keen to drop it, so removing the dependency
helps keep bsnes portable to future platforms -- especially since bsnes doesn't
*use* the source-editing widget anywhere. It's only used by Near's text-editor,
amethyst.

We could just rip out the gtksourceview-related code and be done with it,
but since Near is still around and still working on his own copy of hiro, I
asked him to contribute his implementation so that it will be easier to merge
any future changes too.

This adds two new hiro targets, "gtk2-se" and "gtk3-se" which include the
source-code editing widget and the gtksourceview dependency. Since bsnes
defaults to "gtk2" (without the dependency) we no longer need that package
installed to build bsnes.

Fixes #137.
2021-03-04 20:29:51 +11:00
Tim Allen
67d8586720 hiro: Fix screensaver suspension under GNOME on X11.
On X11, hiro uses the xdg-screensaver helper tool to disable the screensaver,
which detects the screensaver that is running and uses the appropriate
mechanism to communicate with it. The tool's API expects an X11 window ID,
but at least some screensavers ignore it, so it can be set up however. The
GNOME backend *does* care about the window ID, but its expectations are not
documented anywhere, so byuu spent a frustrating few days trying things
at random to get it working, and failing.

It turns out, GNOME does *not* require the window to be mapped, but it *does*
require the window to have a name. Using XStoreName() to name the window fixes
screensaver suspension for me under GNOME 3.38.

Note: while XStoreName is technically deprecated, it's not going to go away
while X11 is still around, and the reason it's deprecated is because it doesn't
include character encoding data. We don't care — no user should ever see the
window name, and it's plain ASCII so it should be fine.

Fixes #102.
2020-11-12 20:56:40 +11:00
Sintendo
0a9d15a978 hiro/cocoa: Implement Application::setScreenSaver
Based on code from Dolphin and SDL2.

908d6f8fa0/Source/Core/UICommon/UICommon.cpp (L416)
cf1c192936/src/video/cocoa/SDL_cocoaevents.m (L514)
2020-11-09 20:25:35 +11:00
Tim Allen
f09c45f3e4 Fix region auto-detection when using native file dialogs.
hiro has two confusingly-named file-picker dialogs. "BrowserDialog" is the
custom dialog built entirely with hiro widgets, "BrowserWindow" is a wrapper
around the native file-picker. bsnes is built for BrowserDialog, but if you tick
"Use native file picker" in the Emulator options, when it needs a file it will
construct a BrowserDialog, copy the relevant config options across to a new
BrowserWindow and invoke that.

Unfortunately, BrowserDialog and BrowserWindow have different capabilities.
Specifically, BrowserDialog includes an "options" list which bsnes uses to let
the user override region detection when loading a game. BrowserWindow has no
such widget. Thus, when using a BrowserDialog the options list worked as intended,
but when using a BrowserWindow the options list was never initialised and no
option was ever chosen. As a result, when opening a game with the native file-
picker, bsnes always used NTSC emulation mode, instead of auto-detecting.

Previously, constructing a BrowserDialog and calling setOptions would leave the
BrowserDialog in an inconsistent state (with no option selected). This was OK if
you immediately displayed the dialog to the user (this would complete the
initialisation and choose a default), but bsnes also used BrowserDialog as an
*interface* typee, to represent the parameters and results of a file-picker
operation that was implemented elsewhere. For this use-case, the inconsistent
state caused problems.

Therefore, BrowserDialog has been changed:

  - setting the list of options always chooses a default, maintaining the
    invariant that `.options()` always returns one of the available options.
  - The internal BrowserDialogWindow class now takes a reference to a Response
    object, instead of constructing one from scratch and having to duplicate
    the "set .option to a reasonable value" code.

Fixes #44.
2020-10-27 23:20:56 +11:00
Tim Allen
24503fc922 hiro: qt.moc should be generated, not committed to the repo. 2020-09-18 22:31:17 +10:00
Zeno Sebastian Endemann
d383f0e883 Use pkg-config instead of hardcoded path to Qt5 moc 2020-09-18 22:31:17 +10:00
Kawa-oneechan
882e5d292f Fix QT pWindow::setModal
As in higan, not my code.
2020-04-07 20:32:45 +02:00
byuu
64d20a062a Windows compilation fix. 2020-02-23 21:03:24 +09:00
byuu
d2211d8818 v114.5
* improved appended firmware detection [devinacker]
* added dynamic rate control support to ALSA and PulseAudio drivers [RedDwarf]
* added option to use native file dialogs
2020-02-23 20:23:25 +09:00
byuu
5a4b667eae v110.3
Added hotfix for bug in "The Hurricanes" (happens on a real SNES)
Added scanline override for NHL '94
Added fix for entering folder names into BrowserDialog filename box
2019-09-27 10:26:55 +09:00
byuu
18d2ab6435 v109.4
Rename hiro::Property to hiro::Attribute
Disable XChaCha20 CSPRNG on Android for now due to compilation issues
Add macOS IOKit joypad support [Sintendo]
2019-09-17 03:37:03 +09:00
byuu
56c9a5195e v109
Keep focus on the panel list when changing settings / tools panels.
Fixed Windows combo box flickering when changing panels.
Suppress Alt+F4 on Windows in fullscreen mode.
2019-09-06 23:19:44 +09:00
byuu
ab25877af4 macOS fixes. 2019-08-17 23:53:21 +09:00
byuu
5ba538ee39 v108.10
* provide actual display device names in ruby::Video::hasMonitors()
* macOS: fixed LineEdit::onChange (fixes state manager state naming)
* macOS: fixed RadioLabel height to not clip off bottom of radio icons
* macOS: fixed RadioLabel initial check states (fixed input settings
focus mode options)
* macOS: fixed TableViewItem::setSelected (fixes initial selection on
settings/tools windows)
* macOS: fixed TextEdit geometry (fixed manifest viewer)
* macOS: don't allow multiple TableViewItems to be selected in
single-selection mode
** (fixes settings/tools windows selecting multiple items via menubar
options)
2019-08-17 23:41:44 +09:00
byuu
0b088b6b55 v108.9
* multi-monitor support
* improved pause/frame advance support
* added option to disable video dimming when idle
2019-08-16 19:44:16 +09:00
byuu
216b472418 Cirrus CI update, Cocoa compilation fix (hopefully.) 2019-08-01 03:15:52 +09:00
byuu
bc7456246c v108.3
* add support for TableView::onActivate(TableViewCell) to Windows, macOS
** allows the new input/hotkey mapping panels to work on Windows, macOS
* polish BrowserDialog behavior
2019-08-01 02:40:35 +09:00
byuu
f65b7a8528 v108.1
* added CPU and SA1 overclocking support
* added fast forward speed limiting
* added option to mute during fast forwarding and rewinding
* lowered volume when not muting during FF/rewind
* reformatted settings/tools windows from tabs to lists
* moved focus settings to input settings panel
* redesigned input and hotkey settings panels to be easier to use
* fixed offscreen placement issue with path settings panel
* added hotkey combinational logic option (AND / OR mode setting)
* added search support to file browser dialog
* fixed --fullscreen command-line option
2019-07-31 06:57:31 +09:00
byuu
296f2c094d v107.18
* fix EXLOROM detection
* fix new CPU masking error
2019-07-28 06:44:38 +09:00
byuu
6b284bb247 Minor cleanups. 2019-07-28 06:13:48 +09:00
byuu
4d2244ed5f More macOS Cocoa improvements. 2019-07-27 01:27:56 +09:00
byuu
cdf4784468 macOS Cocoa improvements. 2019-07-27 00:52:29 +09:00
byuu
30c606fdc8 About screen improvements. 2019-07-23 03:01:29 +09:00
byuu
601b749e50 Compile-time corrections for SameBoy and hiro/cocoa. 2019-07-18 19:34:23 +09:00
byuu
903d1e4012 v107.8
* GB: integrated SameBoy v0.12.1 by Lior Halphon
* SFC: added HG51B169 (Cx4) math tables into bsnes binary
2019-07-17 21:11:46 +09:00