fix new sdl panel on gtk
This commit is contained in:
parent
f7fc5e47e9
commit
9457f167ab
|
@ -88,6 +88,7 @@ emulator.cpp
|
||||||
filterchroma.cpp
|
filterchroma.cpp
|
||||||
filterluma.cpp
|
filterluma.cpp
|
||||||
firmwarecard.cpp
|
firmwarecard.cpp
|
||||||
|
gtkutil.cpp
|
||||||
gui.cpp
|
gui.cpp
|
||||||
keyboardbuffermode.cpp
|
keyboardbuffermode.cpp
|
||||||
keyboard.cpp
|
keyboard.cpp
|
||||||
|
@ -193,6 +194,13 @@ find_package(wxWidgets REQUIRED COMPONENTS base core xrc qa)
|
||||||
include(${wxWidgets_USE_FILE})
|
include(${wxWidgets_USE_FILE})
|
||||||
target_link_libraries(${APP_NAME} PRIVATE ${wxWidgets_LIBRARIES})
|
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)
|
configure_file(src/config.h.in config.h)
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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 "e2const.h"
|
||||||
#include "applentsc.h"
|
#include "applentsc.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
#include "gtkutil.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#include <wx/menu.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
@ -74,6 +76,7 @@ ScreenImage::ScreenImage(KeyEventHandler &k) :
|
||||||
cassOutName(32, ' '),
|
cassOutName(32, ' '),
|
||||||
keyEventHandler(k) {
|
keyEventHandler(k) {
|
||||||
createScreen();
|
createScreen();
|
||||||
|
Center();
|
||||||
Show();
|
Show();
|
||||||
Bind(wxEVT_IDLE, &ScreenImage::OnIdle, this);
|
Bind(wxEVT_IDLE, &ScreenImage::OnIdle, this);
|
||||||
}
|
}
|
||||||
|
@ -120,19 +123,27 @@ void ScreenImage::createScreen() {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenImage::createSdlTexture() {
|
static void *get_native_window_handle(wxWindowBase *panel) {
|
||||||
WXWidget nativeSdl = this->sdl->GetHandle();
|
void *vn = static_cast<void*>(panel->GetHandle());
|
||||||
// TODO: do we need special gtk handling here, to get xid using:
|
#ifdef __WXGTK__
|
||||||
// GtkWidget* widget = panel->GetHandle();
|
vn = get_gtk_native_window_handle(vn);
|
||||||
// gtk_widget_realize(widget);
|
#endif
|
||||||
// Window xid = GDK_WINDOW_XWINDOW(widget->window);
|
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) {
|
if (this->window == NULL) {
|
||||||
printf("Unable to create window: %s\n", SDL_GetError());
|
printf("Unable to create window: %s\n", SDL_GetError());
|
||||||
throw ScreenException();
|
throw ScreenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
SDL_SetWindowSize(this->window, SCRW, SCRH*ASPECT_RATIO);
|
||||||
|
#endif
|
||||||
|
|
||||||
this->renderer = SDL_CreateRenderer(this->window, -1, 0);
|
this->renderer = SDL_CreateRenderer(this->window, -1, 0);
|
||||||
if (this->renderer == NULL) {
|
if (this->renderer == NULL) {
|
||||||
std::cerr << SDL_GetError() << std::endl;
|
std::cerr << SDL_GetError() << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue