bsnes/hiro/gtk/application.cpp
Tim Allen 83f684c66c Update to v094r29 release.
byuu says:

Note: for Windows users, please go to nall/intrinsics.hpp line 60 and
correct the typo from "DISPLAY_WINDOW" to "DISPLAY_WINDOWS" before
compiling, otherwise things won't work at all.

This will be a really major WIP for the core SNES emulation, so please
test as thoroughly as possible.

I rewrote the 65816 CPU core's dispatcher from a jump table to a switch
table. This was so that I could pass class variables as parameters to
opcodes without crazy theatrics.

With that, I killed the regs.r[N] stuff, the flag_t operator|=, &=, ^=
stuff, and all of the template versions of opcodes.

I also removed some stupid pointless flag tests in xcn and pflag that
would always be true.

I sure hope that AWJ is happy with this; because this change was so that
my flag assignments and branch tests won't need to build regs.P into
a full 8-bit variable anymore.

It does of course incur a slight performance hit when you pass in
variables by-value to functions, but it should help with binary size
(and thus cache) by reducing a lot of extra functions. (I know I could
have used template parameters for some things even with a switch table,
but chose not to for the aforementioned reasons.)

Overall, it's about a ~1% speedup from the previous build. The CPU core
instructions were never a bottleneck, but I did want to fix the P flag
building stuff because that really was a dumb mistake v_v'
2015-06-22 23:31:49 +10:00

113 lines
3.0 KiB
C++

#if defined(Hiro_Application)
namespace hiro {
#if defined(DISPLAY_XORG)
XlibDisplay* pApplication::display = nullptr;
#endif
void pApplication::run() {
if(Application::state.onMain) {
while(!Application::state.quit) {
Application::doMain();
processEvents();
}
} else {
gtk_main();
}
}
bool pApplication::pendingEvents() {
return gtk_events_pending();
}
void pApplication::processEvents() {
while(pendingEvents()) gtk_main_iteration_do(false);
}
void pApplication::quit() {
//if gtk_main() was invoked, call gtk_main_quit()
if(gtk_main_level()) gtk_main_quit();
#if defined(DISPLAY_XORG)
//todo: Keyboard::poll() is being called after Application::quit();
//so if display is closed; this causes a segfault
//XCloseDisplay(display);
//display = nullptr;
#endif
}
void pApplication::initialize() {
#if defined(DISPLAY_XORG)
display = XOpenDisplay(nullptr);
#endif
settings = new Settings;
settings->load();
//set WM_CLASS to Application::name()
if(Application::state.name) gdk_set_program_class(Application::state.name);
#if 1
int argc = 1;
char* argv[] = {new char[5], nullptr};
strcpy(argv[0], "hiro");
#else
//--g-fatal-warnings will force a trap on Gtk-CRITICAL errors
//this allows gdb to perform a backtrace to find an error's origin point
int argc = 2;
char* argv[] = {new char[5], new char[19], nullptr};
strcpy(argv[0], "hiro");
strcpy(argv[1], "--g-fatal-warnings");
#endif
char** argvp = argv;
gtk_init(&argc, &argvp);
GtkSettings* gtkSettings = gtk_settings_get_default();
//allow buttons to show icons
g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
g_object_set(gtkSettings, "gtk-button-images", true, nullptr);
#if defined(DISPLAY_WINDOWS)
//there is a serious bug in GTK 2.24 for Windows with the "ime" (Windows IME) input method:
//by default, it will be impossible to type in text fields at all.
//there are various tricks to get around this; but they are unintuitive and unreliable.
//the "ime" method is chosen when various international system locales (eg Japanese) are selected.
//here, we override the default input method to use the "Simple" type instead to avoid the bug.
//obviously, this has a drawback: in-place editing for IMEs will not work in this mode.
g_object_set(gtkSettings, "gtk-im-module", "gtk-im-context-simple", nullptr);
#endif
gtk_rc_parse_string(R"(
style "HiroWindow"
{
GtkWindow::resize-grip-width = 0
GtkWindow::resize-grip-height = 0
}
class "GtkWindow" style "HiroWindow"
style "HiroTreeView"
{
GtkTreeView::vertical-separator = 0
}
class "GtkTreeView" style "HiroTreeView"
style "HiroTabFrameCloseButton"
{
GtkWidget::focus-line-width = 0
GtkWidget::focus-padding = 0
GtkButton::default-border = {0, 0, 0, 0}
GtkButton::default-outer-border = {0, 0, 0, 0}
GtkButton::inner-border = {0, 1, 0, 0}
}
widget_class "*.<GtkNotebook>.<GtkHBox>.<GtkButton>" style "HiroTabFrameCloseButton"
)");
pKeyboard::initialize();
}
}
#endif