aboutsummaryrefslogtreecommitdiffstats
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.cpp83
1 files changed, 29 insertions, 54 deletions
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index adfee8da73..8adec4be07 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -23,6 +23,10 @@
#include <wx/wx.h>
+#if defined(_WIN32)
+#include <wx/msw/private.h> // for wxSetInstance
+#endif
+
// Avoid including these in dcbuffer below
#include "wx/dcmemory.h"
#include "wx/dcclient.h"
@@ -31,10 +35,6 @@
#define private public
#include <wx/dcbuffer.h>
-#if defined(__WXMSW__)
- #include <wx/msw/private.h> // for wxSetInstance
-#endif
-
#undef private
#include "wxe_impl.h"
@@ -221,19 +221,18 @@ void *wxe_main_loop(void *vpdl)
driver_pdl_inc_refc(pdl);
- // ErlDrvSysInfo einfo;
- // driver_system_info(&einfo, sizeof(ErlDrvSysInfo));
// Disable floating point execption if they are on.
// This should be done in emulator but it's not in yet.
#ifndef _WIN32
erts_thread_disable_fpe();
-#else
- // Setup that wxWidgets should look for cursors and icons in
- // this dll and not in werl.exe (which is the default)
- HMODULE WXEHandle = GetModuleHandle(_T("wxe_driver"));
- wxSetInstance((HINSTANCE) WXEHandle);
+#else
+ // Setup that wxWidgets should look for cursors and icons in
+ // this dll and not in werl.exe (which is the default)
+ HMODULE WXEHandle = GetModuleHandle(_T("wxe_driver"));
+ wxSetInstance((HINSTANCE) WXEHandle);
#endif
+ wxe_ps_init();
result = wxEntry(argc, argv);
// fprintf(stderr, "WXWidgets quits main loop %d \r\n", result);
if(result >= 0 && wxe_status == WXE_INITIATED) {
@@ -254,68 +253,46 @@ void *wxe_main_loop(void *vpdl)
}
}
-wxFrame * dummy_window;
-
-void create_dummy_window() {
- dummy_window = new wxFrame(NULL,-1, wxT("wx driver"),
- wxPoint(0,0), wxSize(5,5),
- wxFRAME_NO_TASKBAR);
-
- wxMenuBar * menubar = new wxMenuBar();
- dummy_window->SetMenuBar(menubar);
- // wx-2.9 Don't delete the app menubar correctly
- dummy_window->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close);
- dummy_window->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close);
- dummy_window->Show(true);
- // dummy_window->Show(false);
-}
-
-// wxMac really wants a top level window which command-q quits if there are no
-// windows open, and this will kill the thread, so restart the dummy_window each
-// time a we receive a close.
void WxeApp::dummy_close(wxEvent& Ev) {
- if(Ev.GetEventType() == wxEVT_CLOSE_WINDOW) {
- create_dummy_window();
- }
+ // fprintf(stderr, "Dummy Close invoked\r\n");
+ // wxMac really wants a top level window which command-q quits if there are no
+ // windows open, and this will kill the erlang, override default handling
}
// Init wx-widgets thread
bool WxeApp::OnInit()
{
- wxe_ps_init();
global_me = new wxeMemEnv();
wxe_batch = new wxList;
wxe_batch_cb_saved = new wxList;
cb_buff = NULL;
- // wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); Hmm printpreview doesn't work in 2.9 with this
+ wxe_ps_init2();
+ // wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); // Hmm printpreview doesn't work in 2.9 with this
- this->Connect(wxID_ANY, wxEVT_IDLE,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::idle);
- this->Connect(CREATE_PORT, wxeEVT_META_COMMAND,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv);
- this->Connect(DELETE_PORT, wxeEVT_META_COMMAND,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv);
- this->Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND,
- (wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown);
+ Connect(wxID_ANY, wxEVT_IDLE, (wxObjectEventFunction) (wxEventFunction) &WxeApp::idle);
+ Connect(CREATE_PORT, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv);
+ Connect(DELETE_PORT, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv);
+ Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown);
// fprintf(stderr, "Size void* %d: long %d long long %d int64 %d \r\n",
// sizeof(void *), sizeof(long), sizeof(long long), sizeof(wxInt64));
initEventTable();
wxInitAllImageHandlers();
- /* Create a dummy window so wxWidgets don't automagicly quits the main loop
- after the last window */
-#ifdef __DARWIN__
- create_dummy_window();
-#else
- SetExitOnFrameDelete(false);
+#ifdef _MACOSX
+ /* Create a default MenuBar so that we can intercept the quit command */
+ wxMenuBar *macMB = new wxMenuBar;
+ wxMenuBar::MacSetCommonMenuBar(macMB);
+ macMB->MacInstallMenuBar();
+ macMB->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close);
#endif
+ SetExitOnFrameDelete(false);
+
init_nonconsts(global_me, init_caller);
erl_drv_mutex_lock(wxe_status_m);
wxe_status = WXE_INITIATED;
@@ -325,9 +302,6 @@ bool WxeApp::OnInit()
}
void WxeApp::shutdown(wxeMetaCommand& Ecmd) {
-#ifdef __DARWIN__
- delete dummy_window;
-#endif
ExitMainLoop();
}
@@ -367,6 +341,7 @@ void handle_event_callback(ErlDrvPort port, ErlDrvTermData process)
// Called by wx thread
void WxeApp::idle(wxIdleEvent& event) {
+ event.Skip(true);
dispatch_cmds();
}