diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 41e0e478fd..78acfdf46e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2222,71 +2222,8 @@ void GUI_App::init_single_instance_checker(const std::string &name, const std::s m_single_instance_checker = std::make_unique(boost::nowide::widen(name), boost::nowide::widen(path)); } - -#ifdef __APPLE__ -void GUI_App::MacPowerCallBack(void* refcon, io_service_t service, natural_t messageType, void * messageArgument) -{ - BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack messageType:" << messageType; - - DeviceManager* dev_manager = wxGetApp().getDeviceManager(); - - static std::string last_selected_machine; - if (messageType == kIOMessageSystemWillSleep) - { - if (dev_manager) - { - MachineObject* obj = dev_manager->get_selected_machine(); - last_selected_machine = obj ? obj->dev_id : ""; - BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack save selected machine:" << last_selected_machine; - } - - IOAllowPowerChange(service, (long) messageArgument); - } - else if(messageType == kIOMessageSystemHasPoweredOn) - { - if (dev_manager && !last_selected_machine.empty()) - { - dev_manager->set_selected_machine(last_selected_machine, true); - BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack restore selected machine:" << last_selected_machine; - } - }; -} - - -void GUI_App::RegisterMacPowerCallBack() -{ - m_mac_io_service = IORegisterForSystemPower(m_mac_refcon, &m_mac_io_notify_port, MacPowerCallBack, &m_mac_io_obj); - if (m_mac_io_service == 0) - { - BOOST_LOG_TRIVIAL(error) << "RegisterMacPowerCallBack failed"; - return; - } - - CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(m_mac_io_notify_port), kCFRunLoopCommonModes); - m_mac_powercallback_registered = true; - BOOST_LOG_TRIVIAL(error) << "RegisterMacPowerCallBack success"; -} - -void GUI_App::UnRegisterMacPowerCallBack() -{ - if (m_mac_powercallback_registered) - { - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(m_mac_io_notify_port), kCFRunLoopCommonModes); - IODeregisterForSystemPower(&m_mac_io_obj); - IOServiceClose(m_mac_io_service); - IONotificationPortDestroy(m_mac_io_notify_port); - m_mac_powercallback_registered = false; - BOOST_LOG_TRIVIAL(info) << "UnRegisterMacPowerCallBack"; - } -} -#endif - bool GUI_App::OnInit() { -#ifdef __APPLE__ - RegisterMacPowerCallBack(); -#endif - try { return on_init_inner(); } catch (const std::exception& e) { @@ -2298,10 +2235,6 @@ bool GUI_App::OnInit() int GUI_App::OnExit() { -#ifdef __APPLE__ - UnRegisterMacPowerCallBack(); -#endif - stop_sync_user_preset(); if (m_device_manager) { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 2e871af7ec..bcf033c10b 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -29,11 +29,6 @@ #include #include -#ifdef __APPLE__ -#include -#include -#endif - //#define BBL_HAS_FIRST_PAGE 1 #define STUDIO_INACTIVE_TIMEOUT 15*60*1000 #define LOG_FILES_MAX_NUM 30 @@ -716,18 +711,6 @@ private: boost::optional m_last_config_version; bool m_config_corrupted { false }; std::string m_open_method; - -#ifdef __APPLE__ - void RegisterMacPowerCallBack(); - void UnRegisterMacPowerCallBack(); - static void MacPowerCallBack(void* refcon, io_service_t service, natural_t messageType, void * messageArgument); - - bool m_mac_powercallback_registered = false; - void* m_mac_refcon; - IONotificationPortRef m_mac_io_notify_port; - io_object_t m_mac_io_obj; - io_service_t m_mac_io_service; -#endif }; DECLARE_APP(GUI_App)