mirror of
https://github.com/cmosher01/Epple-II.git
synced 2025-01-13 06:29:50 +00:00
fix new sdl panel on gtk
This commit is contained in:
parent
f7fc5e47e9
commit
9457f167ab
@ -88,6 +88,7 @@ emulator.cpp
|
||||
filterchroma.cpp
|
||||
filterluma.cpp
|
||||
firmwarecard.cpp
|
||||
gtkutil.cpp
|
||||
gui.cpp
|
||||
keyboardbuffermode.cpp
|
||||
keyboard.cpp
|
||||
@ -193,6 +194,13 @@ find_package(wxWidgets REQUIRED COMPONENTS base core xrc qa)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
target_link_libraries(${APP_NAME} PRIVATE ${wxWidgets_LIBRARIES})
|
||||
|
||||
if(NOT (APPLE OR WIN32))
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTKMM REQUIRED gtk+-3.0)
|
||||
target_include_directories(${APP_NAME} PRIVATE ${GTKMM_INCLUDE_DIRS})
|
||||
target_link_libraries(${APP_NAME} PRIVATE ${GTKMM_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
configure_file(src/config.h.in config.h)
|
||||
|
15
src/gtkutil.cpp
Normal file
15
src/gtkutil.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "gtkutil.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.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);
|
||||
}
|
17
src/gtkutil.h
Normal file
17
src/gtkutil.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* File: gtkutil.h
|
||||
* Author: user
|
||||
*
|
||||
* Created on January 4, 2023, 7:18 AM
|
||||
*/
|
||||
|
||||
#ifndef GTKUTIL_H
|
||||
#define GTKUTIL_H
|
||||
|
||||
#ifdef __WXGTK__
|
||||
|
||||
void *get_gtk_native_window_handle(void *widget);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* GTKUTIL_H */
|
@ -21,8 +21,10 @@
|
||||
#include "e2const.h"
|
||||
#include "applentsc.h"
|
||||
#include "card.h"
|
||||
#include "gtkutil.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <wx/menu.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/gdicmn.h>
|
||||
@ -74,6 +76,7 @@ ScreenImage::ScreenImage(KeyEventHandler &k) :
|
||||
cassOutName(32, ' '),
|
||||
keyEventHandler(k) {
|
||||
createScreen();
|
||||
Center();
|
||||
Show();
|
||||
Bind(wxEVT_IDLE, &ScreenImage::OnIdle, this);
|
||||
}
|
||||
@ -120,19 +123,27 @@ void ScreenImage::createScreen() {
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
void ScreenImage::createSdlTexture() {
|
||||
WXWidget nativeSdl = this->sdl->GetHandle();
|
||||
// TODO: do we need special gtk handling here, to get xid using:
|
||||
// GtkWidget* widget = panel->GetHandle();
|
||||
// gtk_widget_realize(widget);
|
||||
// Window xid = GDK_WINDOW_XWINDOW(widget->window);
|
||||
static void *get_native_window_handle(wxWindowBase *panel) {
|
||||
void *vn = static_cast<void*>(panel->GetHandle());
|
||||
#ifdef __WXGTK__
|
||||
vn = get_gtk_native_window_handle(vn);
|
||||
#endif
|
||||
return vn;
|
||||
}
|
||||
|
||||
this->window = SDL_CreateWindowFrom(static_cast<void*>(nativeSdl));
|
||||
void ScreenImage::createSdlTexture() {
|
||||
void *nativeSdl = get_native_window_handle(this->sdl);
|
||||
|
||||
this->window = SDL_CreateWindowFrom(nativeSdl);
|
||||
if (this->window == NULL) {
|
||||
printf("Unable to create window: %s\n", SDL_GetError());
|
||||
throw ScreenException();
|
||||
}
|
||||
|
||||
#ifdef __WXGTK__
|
||||
SDL_SetWindowSize(this->window, SCRW, SCRH*ASPECT_RATIO);
|
||||
#endif
|
||||
|
||||
this->renderer = SDL_CreateRenderer(this->window, -1, 0);
|
||||
if (this->renderer == NULL) {
|
||||
std::cerr << SDL_GetError() << std::endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user