mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-12 15:34:10 +02:00
Update to 20180724 release.
byuu says: I failed to complete a WIP, have five of eight cores updated with some major changes to Emulator::Interface. I'll just post a quick temporary WIP in the off chance someone wants to look over the new interface and comment on it. Also implemented screen saver suppression into hiro/GTK. I should also add ... a plan of mine is to develop target-bsnes into a more generic user interface, with the general idea being that target-higan is for multiple Emulator::Interface cores at the same time, and target-bsnes is for just one Emulator::Interface core. The idea being that if one were to compile target-bsnes with the GBA core, it'd become bgba, for instance. I don't plan on releasing single-core emulators like this, but ... I don't see any downsides to being more flexible.
This commit is contained in:
@@ -99,6 +99,10 @@ static auto Window_keyRelease(GtkWidget* widget, GdkEventKey* event, pWindow* p)
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto Window_realize(GtkWidget* widget, pWindow* p) -> void {
|
||||
p->_setScreenSaver(Application::screenSaver());
|
||||
}
|
||||
|
||||
static auto Window_sizeAllocate(GtkWidget* widget, GtkAllocation* allocation, pWindow* p) -> void {
|
||||
p->_synchronizeState();
|
||||
p->_synchronizeGeometry();
|
||||
@@ -125,6 +129,10 @@ static auto Window_stateEvent(GtkWidget* widget, GdkEvent* event, pWindow* p) ->
|
||||
}
|
||||
}
|
||||
|
||||
static auto Window_unrealize(GtkWidget* widget, pWindow* p) -> void {
|
||||
p->_setScreenSaver(true);
|
||||
}
|
||||
|
||||
auto pWindow::construct() -> void {
|
||||
widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_resizable(GTK_WINDOW(widget), true);
|
||||
@@ -186,6 +194,7 @@ auto pWindow::construct() -> void {
|
||||
g_signal_connect(G_OBJECT(widget), "drag-data-received", G_CALLBACK(Window_drop), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(widget), "key-press-event", G_CALLBACK(Window_keyPress), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(widget), "key-release-event", G_CALLBACK(Window_keyRelease), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(widget), "realize", G_CALLBACK(Window_realize), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(formContainer), "size-allocate", G_CALLBACK(Window_sizeAllocate), (gpointer)this);
|
||||
#if HIRO_GTK==2
|
||||
g_signal_connect(G_OBJECT(formContainer), "size-request", G_CALLBACK(Window_sizeRequest), (gpointer)this);
|
||||
@@ -194,6 +203,7 @@ auto pWindow::construct() -> void {
|
||||
widgetClass->get_preferred_width = Window_getPreferredWidth;
|
||||
widgetClass->get_preferred_height = Window_getPreferredHeight;
|
||||
#endif
|
||||
g_signal_connect(G_OBJECT(widget), "unrealize", G_CALLBACK(Window_unrealize), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(widget), "window-state-event", G_CALLBACK(Window_stateEvent), (gpointer)this);
|
||||
|
||||
g_object_set_data(G_OBJECT(widget), "hiro::window", (gpointer)this);
|
||||
@@ -247,6 +257,18 @@ auto pWindow::frameMargin() const -> Geometry {
|
||||
};
|
||||
}
|
||||
|
||||
auto pWindow::handle() const -> uintptr {
|
||||
#if defined(DISPLAY_WINDOWS)
|
||||
return (uintptr)GDK_WINDOW_HWND(gtk_widget_get_window(widget));
|
||||
#endif
|
||||
|
||||
#if defined(DISPLAY_XORG)
|
||||
return GDK_WINDOW_XID(gtk_widget_get_window(widget));
|
||||
#endif
|
||||
|
||||
return (uintptr)nullptr;
|
||||
}
|
||||
|
||||
auto pWindow::remove(sMenuBar menuBar) -> void {
|
||||
_setMenuVisible(false);
|
||||
}
|
||||
@@ -458,6 +480,19 @@ auto pWindow::_setMenuVisible(bool visible) -> void {
|
||||
gtk_widget_set_visible(gtkMenu, visible);
|
||||
}
|
||||
|
||||
auto pWindow::_setScreenSaver(bool screenSaver) -> void {
|
||||
if(!gtk_widget_get_realized(widget)) return;
|
||||
|
||||
#if defined(DISPLAY_XORG)
|
||||
if(pApplication::xdgScreenSaver) {
|
||||
if(this->screenSaver != screenSaver) {
|
||||
this->screenSaver = screenSaver;
|
||||
execute("xdg-screensaver", screenSaver ? "resume" : "suspend", string{"0x", hex(handle())});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
auto pWindow::_setStatusEnabled(bool enabled) -> void {
|
||||
gtk_widget_set_sensitive(gtkStatus, enabled);
|
||||
}
|
||||
|
Reference in New Issue
Block a user