summaryrefslogtreecommitdiff
path: root/lib/wx/c_src/wxe_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wx/c_src/wxe_impl.cpp')
-rw-r--r--lib/wx/c_src/wxe_impl.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index fd71fed4aa..a32e09db01 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -33,6 +33,10 @@
#include <wx/dcbuffer.h>
#undef private
+#ifdef HAVE_GLIB
+ #include <glib.h>
+#endif
+
#include "wxe_impl.h"
#include "wxe_events.h"
#include "wxe_return.h"
@@ -135,6 +139,23 @@ void print_cmd(wxeCommand& event)
* Init WxeApp the application emulator
* ************************************************************/
+#ifdef HAVE_GLIB
+static GLogWriterOutput wxe_log_glib(GLogLevelFlags log_level,
+ const GLogField *fields,
+ gsize n_fields,
+ gpointer user_data)
+{
+ for (gsize i = 0; i < n_fields; i++) {
+ if(strcmp(fields[i].key, "MESSAGE") == 0) {
+ wxString msg;
+ msg.Printf(wxT("GTK: %s"), (char *) fields[i].value);
+ send_msg("debug", &msg);
+ }
+ }
+ return G_LOG_WRITER_HANDLED;
+}
+#endif
+
bool WxeApp::OnInit()
{
@@ -167,6 +188,10 @@ bool WxeApp::OnInit()
(wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close);
#endif
+#ifdef HAVE_GLIB
+ g_log_set_writer_func(wxe_log_glib, NULL, NULL);
+#endif
+
SetExitOnFrameDelete(false);
enif_mutex_lock(wxe_status_m);
@@ -199,6 +224,18 @@ void WxeApp::MacReopenApp() {
wxString empty;
send_msg("reopen_app", &empty);
}
+
+// See: https://github.com/wxWidgets/wxWidgets/blob/v3.1.5/src/osx/cocoa/utils.mm#L76:L93
+bool WxeApp::OSXIsGUIApplication() {
+ char val_buf[8];
+ size_t val_len = 7;
+ int res = enif_getenv("WX_MACOS_NON_GUI_APP", val_buf, &val_len);
+ if (res == 0) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
#endif
void WxeApp::shutdown(wxeMetaCommand& Ecmd) {
@@ -634,7 +671,7 @@ void WxeApp::destroyMemEnv(wxeMetaCommand &Ecmd)
delete refd;
ptr2ref.erase(it);
} // overridden allocs deletes meta-data in clearPtr
- } else { // Not alloced in erl just delete references
+ } else { // Not allocated in erl just delete references
if(refd->ref >= global_me->next) { // if it is not part of global ptrs
delete refd;
ptr2ref.erase(it);