Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-03-13 16:19:02 +0300
committerbubnikv <bubnikv@gmail.com>2020-03-13 16:19:14 +0300
commit2f6326a2ebe519beb86dde4883f8f1493d0c0a6b (patch)
tree1a42697f0bee006532819775b4adca9fcb6f1269 /src/slic3r/GUI/MainFrame.cpp
parent3684eea53ddaa049a72d958079efc6c05fa33b66 (diff)
Windows specific refactoring of Mouse3DController and RemovableDriveManager.
PrusaSlicer newly registers by Windows operating system for HID USB plug / unplug notifications and for Volume attach / detach notifications, and the background threads of the two respective services are waken up on these Windows notifications. The RemovableDriveManager also wakes up every 30 seconds to cope with the drives ejected from Windows Explorer or from another application, for example Cura, for which Windows OS does not send out notifications.
Diffstat (limited to 'src/slic3r/GUI/MainFrame.cpp')
-rw-r--r--src/slic3r/GUI/MainFrame.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index defd0b53a..1e22359ab 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -31,6 +31,10 @@
#include <fstream>
#include "GUI_App.hpp"
+#ifdef _WIN32
+#include <dbt.h>
+#endif // _WIN32
+
namespace Slic3r {
namespace GUI {
@@ -104,6 +108,31 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
update_title();
// declare events
+ Bind(wxEVT_CREATE, [this](wxWindowCreateEvent& event) {
+
+#ifdef _WIN32
+ //static GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED };
+ //static GUID GUID_DEVINTERFACE_DISK = { 0x53f56307, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b };
+ //static GUID GUID_DEVINTERFACE_VOLUME = { 0x71a27cdd, 0x812a, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f };
+ static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
+
+ // Register USB HID (Human Interface Devices) notifications to trigger the 3DConnexion enumeration.
+ DEV_BROADCAST_DEVICEINTERFACE NotificationFilter = { 0 };
+ NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
+ NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
+ NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_HID;
+ m_hDeviceNotify = ::RegisterDeviceNotification(this->GetHWND(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
+
+// or register for file handle change?
+// DEV_BROADCAST_HANDLE NotificationFilter = { 0 };
+// NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HANDLE);
+// NotificationFilter.dbch_devicetype = DBT_DEVTYP_HANDLE;
+#endif // _WIN32
+
+ // propagate event
+ event.Skip();
+ });
+
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
if (event.CanVeto() && !wxGetApp().check_unsaved_changes()) {
event.Veto();
@@ -131,6 +160,11 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
// Called when closing the application and when switching the application language.
void MainFrame::shutdown()
{
+#ifdef _WIN32
+ ::UnregisterDeviceNotification(HDEVNOTIFY(m_hDeviceNotify));
+ m_hDeviceNotify = nullptr;
+#endif // _WIN32
+
if (m_plater)
m_plater->stop_jobs();