Update to v106r57 release.

byuu says:

I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.

I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.

I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.

Starting now, I'm feature-freezing bsnes and higan. From this point
forward:

  - polishing up and fixing bugs caused by the ruby/hiro changes
  - adding DRC to XAudio2, and maybe exclusive mode to WGL
  - correcting FEoEZ (English) to load and work again out of the box

Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
This commit is contained in:
Tim Allen
2018-08-08 18:46:58 +10:00
parent 3b4e8b6d75
commit 93a6a1ce7e
121 changed files with 2014 additions and 1310 deletions

View File

@@ -2,8 +2,6 @@
namespace hiro {
XlibDisplay* pApplication::display = nullptr;
auto pApplication::run() -> void {
if(Application::state().onMain) {
while(!Application::state().quit) {
@@ -26,17 +24,37 @@ auto pApplication::processEvents() -> void {
auto pApplication::quit() -> void {
QApplication::quit();
qtApplication = nullptr; //note: deleting QApplication will crash libQtGui
if(state().display) {
if(state().screenSaverXDG && state().screenSaverWindow) {
//this needs to run synchronously, so that XUnmapWindow() won't happen before xdg-screensaver is finished
execute("xdg-screensaver", "resume", string{"0x", hex(state().screenSaverWindow)});
XUnmapWindow(state().display, state().screenSaverWindow);
state().screenSaverWindow = 0;
}
XCloseDisplay(state().display);
state().display = nullptr;
}
}
auto pApplication::setScreenSaver(bool screenSaver) -> void {
//TODO: not implemented
#if defined(DISPLAY_XORG)
if(state().screenSaverXDG && state().screenSaverWindow) {
invoke("xdg-screensaver", screenSaver ? "resume" : "suspend", string{"0x", hex(state().screenSaverWindow)});
}
#endif
}
auto pApplication::state() -> State& {
static State state;
return state;
}
//this is sadly necessary for things like determining window frame geometry
//obviously, it is used as sparingly as possible
auto pApplication::syncX() -> void {
auto pApplication::synchronize() -> void {
for(auto n : range(8)) {
#if HIRO_QT==4
#if HIRO_QT==4 && defined(DISPLAY_XORG)
QApplication::syncX();
#elif HIRO_QT==5
QApplication::sync();
@@ -51,7 +69,28 @@ auto pApplication::initialize() -> void {
setenv("QTCOMPOSE", "/usr/local/lib/X11/locale/", 0);
#endif
display = XOpenDisplay(0);
#if defined(DISPLAY_XORG)
state().display = XOpenDisplay(nullptr);
state().screenSaverXDG = (bool)execute("xdg-screensaver", "--version").output.find("xdg-screensaver");
if(state().screenSaverXDG) {
auto screen = DefaultScreen(state().display);
auto rootWindow = RootWindow(state().display, screen);
XSetWindowAttributes attributes{};
attributes.background_pixel = BlackPixel(state().display, screen);
attributes.border_pixel = 0;
attributes.override_redirect = true;
state().screenSaverWindow = XCreateWindow(state().display, rootWindow,
0, 0, 1, 1, 0, DefaultDepth(state().display, screen),
InputOutput, DefaultVisual(state().display, screen),
CWBackPixel | CWBorderPixel | CWOverrideRedirect, &attributes
);
//note: hopefully xdg-screensaver does not require the window to be mapped ...
//if it does, we're in trouble: a small 1x1 black pixel window will be visible in said case
XMapWindow(state().display, state().screenSaverWindow);
XFlush(state().display);
}
#endif
static auto name = Application::state().name ? Application::state().name : string{"hiro"};

View File

@@ -10,9 +10,17 @@ struct pApplication {
static auto setScreenSaver(bool screenSaver) -> void;
static auto initialize() -> void;
static auto syncX() -> void;
static auto synchronize() -> void;
static XlibDisplay* display;
struct State {
#if defined(DISPLAY_XORG)
XlibDisplay* display = nullptr;
XlibWindow screenSaverWindow = 0;
bool screenSaverXDG = false;
#endif
};
static auto state() -> State&;
};
static QApplication* qtApplication = nullptr;

View File

@@ -3,18 +3,29 @@
namespace hiro {
auto pKeyboard::poll() -> vector<bool> {
if(Application::state().quit) return {};
vector<bool> result;
char state[256];
XQueryKeymap(pApplication::display, state);
#if defined(DISPLAY_XORG)
XQueryKeymap(pApplication::state().display, state);
#endif
for(auto& code : settings.keycodes) {
result.append(_pressed(state, code));
}
return result;
}
auto pKeyboard::pressed(unsigned code) -> bool {
char state[256];
XQueryKeymap(pApplication::display, state);
#if defined(DISPLAY_XORG)
XQueryKeymap(pApplication::state().display, state);
#endif
return _pressed(state, code);
}
@@ -22,22 +33,31 @@ auto pKeyboard::_pressed(const char* state, uint16_t code) -> bool {
uint8_t lo = code >> 0;
uint8_t hi = code >> 8;
#if defined(DISPLAY_XORG)
if(lo && state[lo >> 3] & (1 << (lo & 7))) return true;
if(hi && state[hi >> 3] & (1 << (hi & 7))) return true;
#endif
return false;
}
auto pKeyboard::initialize() -> void {
auto append = [](unsigned lo, unsigned hi = 0) {
lo = lo ? (uint8_t)XKeysymToKeycode(pApplication::display, lo) : 0;
hi = hi ? (uint8_t)XKeysymToKeycode(pApplication::display, hi) : 0;
#if defined(DISPLAY_XORG)
lo = lo ? (uint8_t)XKeysymToKeycode(pApplication::state().display, lo) : 0;
hi = hi ? (uint8_t)XKeysymToKeycode(pApplication::state().display, hi) : 0;
#endif
settings.keycodes.append(lo << 0 | hi << 8);
};
#define map(name, ...) if(key == name) { append(__VA_ARGS__); continue; }
for(auto& key : Keyboard::keys) {
#include <hiro/platform/xorg/keyboard.hpp>
#if defined(DISPLAY_XORG)
#include <hiro/platform/xorg/keyboard.hpp>
#endif
//print("[hiro/qt] warning: unhandled key: ", key, "\n");
append(0);
}
#undef map
}

View File

@@ -13,6 +13,7 @@ auto pSizable::minimumSize() const -> Size {
}
auto pSizable::setGeometry(Geometry geometry) -> void {
self().doSize();
}
}

View File

@@ -25,7 +25,9 @@ auto pWidget::construct() -> void {
qtWidget->setParent(container);
}
setEnabled(self().enabled(true));
setFont(self().font(true));
setToolTip(self().toolTip());
setVisible(self().visible(true));
}
@@ -55,7 +57,12 @@ auto pWidget::setFont(const Font& font) -> void {
auto pWidget::setGeometry(Geometry geometry) -> void {
if(!qtWidget) return;
qtWidget->setGeometry(geometry.x(), geometry.y(), geometry.width(), geometry.height());
self().doSize();
pSizable::setGeometry(geometry);
}
auto pWidget::setToolTip(const string& toolTip) -> void {
if(!qtWidget) return;
qtWidget->setToolTip(QString::fromUtf8(toolTip));
}
auto pWidget::setVisible(bool visible) -> void {

View File

@@ -10,6 +10,7 @@ struct pWidget : pSizable {
auto setFocused() -> void override;
auto setFont(const Font& font) -> void override;
auto setGeometry(Geometry geometry) -> void override;
auto setToolTip(const string& toolTip) -> void;
auto setVisible(bool visible) -> void override;
QWidget* qtWidget = nullptr;

View File

@@ -269,7 +269,7 @@ auto pWindow::_statusTextHeight() const -> uint {
}
auto pWindow::_updateFrameGeometry() -> void {
pApplication::syncX();
pApplication::synchronize();
QRect border = qtWindow->frameGeometry();
QRect client = qtWindow->geometry();
@@ -279,12 +279,12 @@ auto pWindow::_updateFrameGeometry() -> void {
settings.geometry.frameHeight = border.height() - client.height();
if(qtMenuBar->isVisible()) {
pApplication::syncX();
pApplication::synchronize();
settings.geometry.menuHeight = qtMenuBar->height() - _menuTextHeight();
}
if(qtStatusBar->isVisible()) {
pApplication::syncX();
pApplication::synchronize();
settings.geometry.statusHeight = qtStatusBar->height() - _statusTextHeight();
}
}