minor fixes

This commit is contained in:
Christopher A. Mosher 2024-04-13 17:45:58 -04:00
parent 2749f8ef74
commit 58f9575823
4 changed files with 10 additions and 10 deletions

View File

@ -4,6 +4,7 @@ set -e
if [ -e "$1/CMakeCache.txt" ] ; then
builddir="$1"
shift
else
mkdir -p tmp
builddir=$(mktemp -d tmp/tmp.XXXXXXXXXX)

View File

@ -4,15 +4,14 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gtk-2.0/gtk/gtkwindow.h>
#include <gtk-2.0/gtk/gtkwidget.h>
void *get_gtk_native_window_handle(void *widget) {
GtkWidget *gtk_widget = GTK_WIDGET(widget);
gtk_widget_realize(gtk_widget);
GdkWindow *gdk_window = gtk_widget_get_window(gtk_widget);
Window xid = gdk_x11_window_get_xid(gdk_window);
return reinterpret_cast<void*>(xid);
}

View File

@ -70,6 +70,7 @@ class ScreenException {
ScreenImage::ScreenImage(Emulator &emulator, KeyEventHandler &k) :
wxFrame(nullptr, wxID_ANY, "Emulator"),
emu(emulator),
window(nullptr),
fullscreen(false),
buffer(true),
display(AnalogTV::TV_OLD_COLOR),
@ -92,12 +93,6 @@ ScreenImage::~ScreenImage() {
void ScreenImage::OnIdle(wxIdleEvent &evt) {
// if (!this->FindFocus() || !this->wxPanelEmuScreen->HasFocus()) {
// this->wxPanelEmuScreen->SetFocus();
// }
}
void ScreenImage::HandleUserCloseWindowRequest(wxCloseEvent& event) {
wxGetApp().StopEmulator();
}
@ -167,6 +162,9 @@ void ScreenImage::createSdlTexture() {
}
void ScreenImage::destroyScreen() {
if (!this->window) {
return;
}
SDL_DestroyTexture(this->texture);
SDL_DestroyRenderer(this->renderer);
SDL_DestroyWindow(this->window);
@ -336,6 +334,9 @@ void ScreenImage::drawPower(bool on) {
}
void ScreenImage::notifyObservers() {
if (!this->window) {
return;
}
const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW*sizeof(unsigned int));
if (e) {
std::cerr << SDL_GetError() << std::endl;

View File

@ -57,7 +57,6 @@ private:
void createSdlTexture();
void destroyScreen();
void OnIdle(wxIdleEvent &evt);
void OnKeyDown(wxKeyEvent &evt);
void OnKeyUp(wxKeyEvent &evt);
void HandleUserCloseWindowRequest(wxCloseEvent& event);