diff --git a/Makefile.in b/Makefile.in index 91313b3c09..2f2e6008d8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -883,6 +883,7 @@ ALL_BASE_SOURCES = \ src/osx/carbon/utils.cpp \ src/osx/carbon/uma.cpp \ src/osx/cocoa/utils.mm \ + src/osx/cocoa/power.mm \ src/msw/main.cpp \ src/msw/volume.cpp \ src/common/fs_inet.cpp \ @@ -4519,7 +4520,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS = \ monodll_dlmsw.o \ monodll_evtloopconsole.o \ monodll_msw_mimetype.o \ - monodll_power.o \ + monodll_msw_power.o \ monodll_regconf.o \ monodll_registry.o \ monodll_msw_snglinst.o \ @@ -4539,7 +4540,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS = \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \ @COND_TOOLKIT_OSX_CARBON@ = monodll_carbon_utils.o monodll_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS \ -@COND_TOOLKIT_OSX_COCOA@ = monodll_osx_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = monodll_osx_cocoa_utils.o monodll_cocoa_power.o @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS \ @COND_PLATFORM_MACOSX_1@ = monodll_socketiohandler.o monodll_sockunix.o \ @COND_PLATFORM_MACOSX_1@ monodll_sockosx.o @@ -6867,7 +6868,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 = \ monolib_dlmsw.o \ monolib_evtloopconsole.o \ monolib_msw_mimetype.o \ - monolib_power.o \ + monolib_msw_power.o \ monolib_regconf.o \ monolib_registry.o \ monolib_msw_snglinst.o \ @@ -6887,7 +6888,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 = \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \ @COND_TOOLKIT_OSX_CARBON@ = monolib_carbon_utils.o monolib_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_1 \ -@COND_TOOLKIT_OSX_COCOA@ = monolib_osx_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = monolib_osx_cocoa_utils.o monolib_cocoa_power.o @COND_PLATFORM_MACOSX_1@__NET_PLATFORM_SRC_OBJECTS_1 \ @COND_PLATFORM_MACOSX_1@ = monolib_socketiohandler.o monolib_sockunix.o \ @COND_PLATFORM_MACOSX_1@ monolib_sockosx.o @@ -9268,7 +9269,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2 = \ basedll_dlmsw.o \ basedll_evtloopconsole.o \ basedll_msw_mimetype.o \ - basedll_power.o \ + basedll_msw_power.o \ basedll_regconf.o \ basedll_registry.o \ basedll_msw_snglinst.o \ @@ -9288,7 +9289,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2 = \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_2 \ @COND_TOOLKIT_OSX_CARBON@ = basedll_carbon_utils.o basedll_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_2 \ -@COND_TOOLKIT_OSX_COCOA@ = basedll_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = basedll_cocoa_utils.o basedll_cocoa_power.o COND_MONOLITHIC_0_SHARED_0___baselib___depname = \ $(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) @COND_MONOLITHIC_0_SHARED_0@__baselib___depname = $(COND_MONOLITHIC_0_SHARED_0___baselib___depname) @@ -9356,7 +9357,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3 = \ baselib_dlmsw.o \ baselib_evtloopconsole.o \ baselib_msw_mimetype.o \ - baselib_power.o \ + baselib_msw_power.o \ baselib_regconf.o \ baselib_registry.o \ baselib_msw_snglinst.o \ @@ -9376,7 +9377,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3 = \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_3 \ @COND_TOOLKIT_OSX_CARBON@ = baselib_carbon_utils.o baselib_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_3 \ -@COND_TOOLKIT_OSX_COCOA@ = baselib_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = baselib_cocoa_utils.o baselib_cocoa_power.o @COND_SHARED_1@____wxbase_namedll_DEP = $(__basedll___depname) @COND_SHARED_0@____wxbase_namelib_DEP = $(__baselib___depname) COND_MONOLITHIC_0_SHARED_1___netdll___depname = \ @@ -9548,7 +9549,7 @@ COND_USE_SOVERSOLARIS_1___coredll___so_symlinks_uninst_cmd = rm -f \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_4 \ @COND_TOOLKIT_OSX_CARBON@ = coredll_carbon_utils.o coredll_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_4 \ -@COND_TOOLKIT_OSX_COCOA@ = coredll_osx_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = coredll_osx_cocoa_utils.o coredll_power.o COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ $(__LOWLEVEL_SRC_OBJECTS_4) \ $(__PLATFORM_SRC_OBJECTS_8) \ @@ -11317,7 +11318,7 @@ COND_MONOLITHIC_0_SHARED_0_USE_GUI_1___corelib___depname = \ @COND_TOOLKIT_OSX_CARBON@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_5 \ @COND_TOOLKIT_OSX_CARBON@ = corelib_carbon_utils.o corelib_uma.o @COND_TOOLKIT_OSX_COCOA@__BASE_AND_GUI_TOOLKIT_SRC_OBJECTS_5 \ -@COND_TOOLKIT_OSX_COCOA@ = corelib_osx_cocoa_utils.o +@COND_TOOLKIT_OSX_COCOA@ = corelib_osx_cocoa_utils.o corelib_power.o COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ $(__LOWLEVEL_SRC_OBJECTS_6) \ $(__PLATFORM_SRC_OBJECTS_9) \ @@ -17552,7 +17553,7 @@ monodll_evtloopconsole.o: $(srcdir)/src/msw/evtloopconsole.cpp $(MONODLL_ODEP) monodll_msw_mimetype.o: $(srcdir)/src/msw/mimetype.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/mimetype.cpp -monodll_power.o: $(srcdir)/src/msw/power.cpp $(MONODLL_ODEP) +monodll_msw_power.o: $(srcdir)/src/msw/power.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/power.cpp monodll_regconf.o: $(srcdir)/src/msw/regconf.cpp $(MONODLL_ODEP) @@ -17642,6 +17643,9 @@ monodll_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(MONODLL_ODEP) monodll_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +monodll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + monodll_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp @@ -23414,7 +23418,7 @@ monolib_evtloopconsole.o: $(srcdir)/src/msw/evtloopconsole.cpp $(MONOLIB_ODEP) monolib_msw_mimetype.o: $(srcdir)/src/msw/mimetype.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/mimetype.cpp -monolib_power.o: $(srcdir)/src/msw/power.cpp $(MONOLIB_ODEP) +monolib_msw_power.o: $(srcdir)/src/msw/power.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/power.cpp monolib_regconf.o: $(srcdir)/src/msw/regconf.cpp $(MONOLIB_ODEP) @@ -23504,6 +23508,9 @@ monolib_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(MONOLIB_ODEP) monolib_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +monolib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + monolib_fs_inet.o: $(srcdir)/src/common/fs_inet.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/fs_inet.cpp @@ -29276,7 +29283,7 @@ basedll_evtloopconsole.o: $(srcdir)/src/msw/evtloopconsole.cpp $(BASEDLL_ODEP) basedll_msw_mimetype.o: $(srcdir)/src/msw/mimetype.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/mimetype.cpp -basedll_power.o: $(srcdir)/src/msw/power.cpp $(BASEDLL_ODEP) +basedll_msw_power.o: $(srcdir)/src/msw/power.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/power.cpp basedll_regconf.o: $(srcdir)/src/msw/regconf.cpp $(BASEDLL_ODEP) @@ -29366,6 +29373,9 @@ basedll_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(BASEDLL_ODEP) basedll_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +basedll_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASEDLL_ODEP) + $(CXXC) -c -o $@ $(BASEDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + @COND_PLATFORM_UNIX_1@basedll_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASEDLL_ODEP) @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp @@ -29753,7 +29763,7 @@ baselib_evtloopconsole.o: $(srcdir)/src/msw/evtloopconsole.cpp $(BASELIB_ODEP) baselib_msw_mimetype.o: $(srcdir)/src/msw/mimetype.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/mimetype.cpp -baselib_power.o: $(srcdir)/src/msw/power.cpp $(BASELIB_ODEP) +baselib_msw_power.o: $(srcdir)/src/msw/power.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/power.cpp baselib_regconf.o: $(srcdir)/src/msw/regconf.cpp $(BASELIB_ODEP) @@ -29843,6 +29853,9 @@ baselib_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(BASELIB_ODEP) baselib_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +baselib_cocoa_power.o: $(srcdir)/src/osx/cocoa/power.mm $(BASELIB_ODEP) + $(CXXC) -c -o $@ $(BASELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + @COND_PLATFORM_UNIX_1@baselib_fdiodispatcher.o: $(srcdir)/src/common/fdiodispatcher.cpp $(BASELIB_ODEP) @COND_PLATFORM_UNIX_1@ $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/fdiodispatcher.cpp @@ -30080,6 +30093,9 @@ coredll_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(COREDLL_ODEP) coredll_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +coredll_power.o: $(srcdir)/src/osx/cocoa/power.mm $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + coredll_gtk1_bmpbuttn.o: $(srcdir)/src/gtk1/bmpbuttn.cpp $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk1/bmpbuttn.cpp @@ -34454,6 +34470,9 @@ corelib_uma.o: $(srcdir)/src/osx/carbon/uma.cpp $(CORELIB_ODEP) corelib_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm +corelib_power.o: $(srcdir)/src/osx/cocoa/power.mm $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/power.mm + corelib_gtk1_bmpbuttn.o: $(srcdir)/src/gtk1/bmpbuttn.cpp $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk1/bmpbuttn.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 81af630435..08d10e4cba 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -223,6 +223,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/osx/cocoa/utils.mm + src/osx/cocoa/power.mm diff --git a/build/files b/build/files index a9e82a4f71..44844fc622 100644 --- a/build/files +++ b/build/files @@ -165,6 +165,7 @@ BASE_AND_GUI_OSX_CARBON_SRC = BASE_AND_GUI_OSX_COCOA_SRC = src/osx/cocoa/utils.mm + src/osx/cocoa/power.mm BASE_AND_GUI_OSX_IPHONE_SRC = src/osx/iphone/utils.mm diff --git a/build/osx/wxcocoa.xcodeproj/project.pbxproj b/build/osx/wxcocoa.xcodeproj/project.pbxproj index 8efb67423b..255c3a6d00 100644 --- a/build/osx/wxcocoa.xcodeproj/project.pbxproj +++ b/build/osx/wxcocoa.xcodeproj/project.pbxproj @@ -1768,6 +1768,10 @@ A1A7B833061C35B4AABD093C /* preferencesg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8F06DEA1AA339ED819B3812 /* preferencesg.cpp */; }; A1A7B833061C35B4AABD093D /* preferencesg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8F06DEA1AA339ED819B3812 /* preferencesg.cpp */; }; A1A7B833061C35B4AABD093E /* preferencesg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8F06DEA1AA339ED819B3812 /* preferencesg.cpp */; }; + A1A7C58E276F6F2B247F0813 /* power.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0714536835B5227019E29D06 /* power.mm */; }; + A1A7C58E276F6F2B247F0814 /* power.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0714536835B5227019E29D06 /* power.mm */; }; + A1A7C58E276F6F2B247F0815 /* power.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0714536835B5227019E29D06 /* power.mm */; }; + A1A7C58E276F6F2B247F0816 /* power.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0714536835B5227019E29D06 /* power.mm */; }; A1A7D793B034398B8696EF33 /* utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 789F45D14FF23E248FCFB5FA /* utils.mm */; }; A1A7D793B034398B8696EF34 /* utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 789F45D14FF23E248FCFB5FA /* utils.mm */; }; A1A7D793B034398B8696EF35 /* utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 789F45D14FF23E248FCFB5FA /* utils.mm */; }; @@ -4201,6 +4205,7 @@ 777385D10CCC350C90F02824 /* textentry_osx.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = textentry_osx.cpp; path = ../../src/osx/textentry_osx.cpp; sourceTree = ""; }; 77D6E66F72443765A2FBE263 /* aboutdlgg.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = aboutdlgg.cpp; path = ../../src/generic/aboutdlgg.cpp; sourceTree = ""; }; 77F5E7BCD9B2307D8DBCC052 /* font.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = font.cpp; path = ../../src/osx/carbon/font.cpp; sourceTree = ""; }; + 0714536835B5227019E29D06 /* power.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = power.mm; path = ../../src/osx/cocoa/power.mm; sourceTree = ""; }; 789F45D14FF23E248FCFB5FA /* utils.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = utils.mm; path = ../../src/osx/cocoa/utils.mm; sourceTree = ""; }; 78D7866F95C73A28BB540606 /* LexBash.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LexBash.cxx; path = ../../src/stc/scintilla/lexers/LexBash.cxx; sourceTree = ""; }; 7906BD74118A3B4DAC515BC2 /* odcombo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = odcombo.cpp; path = ../../src/generic/odcombo.cpp; sourceTree = ""; }; @@ -5943,6 +5948,7 @@ C9A305CEC03B3085B159B617 /* fs_mem.cpp */, E968913A9A593B258BD8EACB /* msgout.cpp */, 4188821BBA833CCAA678B234 /* utilscmn.cpp */, + 0714536835B5227019E29D06 /* power.mm */, 789F45D14FF23E248FCFB5FA /* utils.mm */, ); name = base; @@ -7343,6 +7349,7 @@ 131B879180AE3FB481F81CC9 /* fs_mem.cpp in Sources */, 05814571E7A83F5DBFB6E4C6 /* msgout.cpp in Sources */, 80665EEAE8613DF8A93A7986 /* utilscmn.cpp in Sources */, + A1A7C58E276F6F2B247F0815 /* power.mm in Sources */, A1A7D793B034398B8696EF35 /* utils.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -7375,6 +7382,7 @@ 131B879180AE3FB481F81CCA /* fs_mem.cpp in Sources */, 05814571E7A83F5DBFB6E4C7 /* msgout.cpp in Sources */, 80665EEAE8613DF8A93A7987 /* utilscmn.cpp in Sources */, + A1A7C58E276F6F2B247F0816 /* power.mm in Sources */, A1A7D793B034398B8696EF36 /* utils.mm in Sources */, F4C0CEADEDC23610BF6983D8 /* artmac.cpp in Sources */, 296692A7A3783E3A83D005C8 /* brush.cpp in Sources */, @@ -8040,6 +8048,7 @@ 131B879180AE3FB481F81CC8 /* fs_mem.cpp in Sources */, 05814571E7A83F5DBFB6E4C5 /* msgout.cpp in Sources */, 80665EEAE8613DF8A93A7985 /* utilscmn.cpp in Sources */, + A1A7C58E276F6F2B247F0814 /* power.mm in Sources */, A1A7D793B034398B8696EF34 /* utils.mm in Sources */, F4C0CEADEDC23610BF6983D7 /* artmac.cpp in Sources */, 296692A7A3783E3A83D005C7 /* brush.cpp in Sources */, @@ -9225,6 +9234,7 @@ 131B879180AE3FB481F81CC7 /* fs_mem.cpp in Sources */, 05814571E7A83F5DBFB6E4C4 /* msgout.cpp in Sources */, 80665EEAE8613DF8A93A7984 /* utilscmn.cpp in Sources */, + A1A7C58E276F6F2B247F0813 /* power.mm in Sources */, A1A7D793B034398B8696EF33 /* utils.mm in Sources */, F4C0CEADEDC23610BF6983D6 /* artmac.cpp in Sources */, 296692A7A3783E3A83D005C6 /* brush.cpp in Sources */, diff --git a/configure.in b/configure.in index 404420ed4f..64ffdf28a1 100644 --- a/configure.in +++ b/configure.in @@ -7517,7 +7517,7 @@ if test "$wxUSE_GUI" = "yes"; then dnl TODO some samples are never built so far: mfc (requires VC++) SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS artprov controls dialogs drawing \ - erase event exec font image minimal render \ + erase event exec font image minimal power render \ shaped svg taborder vscroll widgets wrapsizer" if test "$wxUSE_MONOLITHIC" != "yes"; then diff --git a/docs/changes.txt b/docs/changes.txt index 9539deaac9..adc5a5656a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -32,6 +32,7 @@ Changes in behaviour which may result in build errors All: +- Add wxPowerResourceBlocker (Tobias Taschner). - Add wxApp::StoreCurrentException() and RethrowStoredException() and implement their functionality by default when using C++11 compiler. - Allow iterating over wxCmdLineParser arguments in order (Armel Asselin). diff --git a/include/wx/power.h b/include/wx/power.h index 17e81b6efb..65b42baf24 100644 --- a/include/wx/power.h +++ b/include/wx/power.h @@ -95,6 +95,49 @@ typedef void (wxEvtHandler::*wxPowerEventFunction)(wxPowerEvent&); #undef wxHAS_POWER_EVENTS #endif // support for power events/no support +// ---------------------------------------------------------------------------- +// wxPowerResourceBlocker +// ---------------------------------------------------------------------------- + +enum wxPowerResourceKind +{ + wxPOWER_RESOURCE_SCREEN, + wxPOWER_RESOURCE_SYSTEM +}; + +class WXDLLIMPEXP_BASE wxPowerResource +{ +public: + static bool Acquire(wxPowerResourceKind kind, + const wxString& reason = wxString()); + static void Release(wxPowerResourceKind kind); +}; + +class wxPowerResourceBlocker +{ +public: + explicit wxPowerResourceBlocker(wxPowerResourceKind kind, + const wxString& reason = wxString()) + : m_kind(kind), + m_acquired(wxPowerResource::Acquire(kind, reason)) + { + } + + bool IsInEffect() const { return m_acquired; } + + ~wxPowerResourceBlocker() + { + if ( m_acquired ) + wxPowerResource::Release(m_kind); + } + +private: + const wxPowerResourceKind m_kind; + const bool m_acquired; + + wxDECLARE_NO_COPY_CLASS(wxPowerResourceBlocker); +}; + // ---------------------------------------------------------------------------- // power management functions // ---------------------------------------------------------------------------- diff --git a/interface/wx/power.h b/interface/wx/power.h index 1b20ce1de4..005a90a36b 100644 --- a/interface/wx/power.h +++ b/interface/wx/power.h @@ -21,6 +21,19 @@ enum wxBatteryState wxBATTERY_UNKNOWN_STATE }; +/** + Possible power resources that can be locked by wxPowerResourceBlocker. + + @since 3.1.0 + */ +enum wxPowerResourceKind +{ + /// Use to prevent automatic display power off. + wxPOWER_RESOURCE_SCREEN, + + /// Use to prevent automatic system suspend. + wxPOWER_RESOURCE_SYSTEM +}; /** @class wxPowerEvent @@ -38,6 +51,11 @@ enum wxBatteryState @beginEventTable{wxPowerEvent} @event{EVT_POWER_SUSPENDING(func)} + @warning This event and the possibility to veto suspend was removed + from MSW systems starting from Windows Vista. wxPowerResourceBlocker + can be used to prevent the system from suspending under both XP and + later systems, use it instead of handling this event. + System is about to be suspended, this event can be vetoed to prevent suspend from taking place. @event{EVT_POWER_SUSPENDED(func)} @@ -80,4 +98,126 @@ wxEventType wxEVT_POWER_SUSPENDED; wxEventType wxEVT_POWER_SUSPEND_CANCEL; wxEventType wxEVT_POWER_RESUME; +/** + Helper functions for acquiring and releasing the given power resource. + If an application performs a long running task without user interaction it + is often necessary to prevent the system from automatically suspending or + powering off the screen and Acquire() method can be used to do this. + + Notice that currently this functionality is only implemented for MSW and + OSX and on the latter only ::wxPOWER_RESOURCE_SYSTEM is supported for + versions earlier than 10.9. + + If possible, use wxPowerResourceBlocker class to ensure that Release() is + called instead of calling it manually. + + @since 3.1.0 + @library{wxbase} + @category{misc} + + @see wxPowerResourceBlocker +*/ +class wxPowerResource +{ +public: + /** + Acquire a power resource for the application. + + If successful, the system will not automatically power of the screen or + suspend until Release() is called. + + Every call to Acquire @b must be matched by a corresponding call to + Release() or the system will not suspend until the application ends, use + wxPowerResourceBlocker to ensure that this happens. + + @param kind Power resource required, either ::wxPOWER_RESOURCE_SCREEN + or ::wxPOWER_RESOURCE_SYSTEM. + @param reason Optional reason may be specified which might be used on + some platforms to inform the user what is preventing power saving. + It should usually describe the operation requiring the resource and + specifying it is strongly recommended. + @return Returns true if the acquisition was successful. + + @see Release() + */ + static bool Acquire(wxPowerResourceKind kind, + const wxString& reason = wxString()); + + /** + Release a previously acquired power resource. + + Release @b must be called for every Acquire() call made to restore + normal power saving behaviour + + @param kind Power resource to be released. + + @see Acquire() + */ + static void Release(wxPowerResourceKind kind); +}; + +/** + Helper RAII class ensuring that power resources are released. + + A wxPowerResourceBlocker object acquires a power resource in the + constructor and releases it in the destructor making it impossible to to + forget to release the power resource (which would prevent suspending or + screen power off until the application ends). + + Example: + @code + void MyWindow::DoSomething() + { + wxPowerResourceBlocker + blocker(wxPOWER_RESOURCE_SYSTEM, "Downloading something important"); + + if ( !blocker.IsInEffect() ) + { + // If the resource could not be acquired, tell the user that he has + // to keep the system alive + wxLogMessage("Warning: system may suspend while downloading."); + } + + // Run an important download and the system will not suspend while downloading + for ( int i = 0; i < download.size(); ++i ) + download.readByte(); + + // wxPOWER_RESOURCE_SYSTEM automatically released here. + } + @endcode + + @since 3.1.0 + @library{wxbase} + @category{misc} + + @see wxPowerResource +*/ +class wxPowerResourceBlocker +{ +public: + /** + Acquires the power resource. + + Uses the same parameters as wxPowerResource::Acquire(). + */ + explicit wxPowerResourceBlocker(wxPowerResourceKind kind, + const wxString& reason = wxString()); + + /** + Returns whether the power resource could be acquired. + + This can be used to inform the user that the application will not + prevent automatic suspending. + + @see wxPowerResource::Acquire() + */ + bool IsInEffect() const; + + /** + Releases the power resource. + + @see wxPowerResource::Release() + */ + ~wxPowerResourceBlocker(); +}; diff --git a/samples/power/power.cpp b/samples/power/power.cpp index 9bdad67250..51d2c27d22 100644 --- a/samples/power/power.cpp +++ b/samples/power/power.cpp @@ -29,6 +29,8 @@ #include "wx/textctrl.h" #include "wx/msgdlg.h" +#include "wx/menu.h" +#include "wx/timer.h" #include "wx/power.h" @@ -47,6 +49,16 @@ public: : wxFrame(NULL, wxID_ANY, wxT("wxWidgets Power Management Sample"), wxDefaultPosition, wxSize(500, 200)) { + m_powerResourceBlocker = NULL; + + wxMenu *fileMenu = new wxMenu; + fileMenu->Append(wxID_NEW, "Start long running task\tCtrl-S"); + fileMenu->Append(wxID_ABORT, "Stop long running task"); + + wxMenuBar* menuBar = new wxMenuBar(); + menuBar->Append(fileMenu, wxT("&Task")); + SetMenuBar(menuBar); + wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); @@ -58,11 +70,20 @@ public: UpdatePowerSettings(wxPOWER_UNKNOWN, wxBATTERY_UNKNOWN_STATE); + StopLongTask(); + Bind(wxEVT_COMMAND_MENU_SELECTED, + &MyFrame::OnStartTaskClicked, this, wxID_NEW); + Bind(wxEVT_COMMAND_MENU_SELECTED, + &MyFrame::OnStopTaskClicked, this, wxID_ABORT); + m_taskTimer.Bind(wxEVT_TIMER, &MyFrame::OnTaskTimer, this); + Show(); } virtual ~MyFrame() { + delete m_powerResourceBlocker; + delete wxLog::SetActiveTarget(m_logOld); } @@ -162,10 +183,67 @@ private: batteryStr.c_str())); } + void OnStartTaskClicked( wxCommandEvent& WXUNUSED(event) ) + { + wxLogMessage("Starting long running task " + "(screen should keep powered on while running)..."); + StartLongTask(); + } + + void OnStopTaskClicked(wxCommandEvent& WXUNUSED(event)) + { + StopLongTask(); + wxLogMessage("Stopped long running task"); + } + + void OnTaskTimer(wxTimerEvent& WXUNUSED(event)) + { + ++m_taskProgress; + + if ( m_taskProgress == 100 ) + { + StopLongTask(); + wxLogMessage("Long running task finished"); + } + else + { + wxLogMessage("Long running task at %d%%...", m_taskProgress); + } + } + + void StartLongTask() + { + m_taskProgress = 0; + m_taskTimer.Start(12000); + GetMenuBar()->Enable(wxID_NEW, false); + GetMenuBar()->Enable(wxID_ABORT, true); + + m_powerResourceBlocker + = new wxPowerResourceBlocker(wxPOWER_RESOURCE_SYSTEM); + + if ( !m_powerResourceBlocker->IsInEffect() ) + { + wxLogMessage("Power resource could not be acquired, " + "user input is required to prevent system standby"); + } + } + + void StopLongTask() + { + GetMenuBar()->Enable(wxID_NEW, true); + GetMenuBar()->Enable(wxID_ABORT, false); + m_taskTimer.Stop(); + + wxDELETE(m_powerResourceBlocker); + } + wxPowerType m_powerType; wxBatteryState m_batteryState; wxLog *m_logOld; + wxTimer m_taskTimer; + wxPowerResourceBlocker *m_powerResourceBlocker; + int m_taskProgress; wxDECLARE_EVENT_TABLE(); }; diff --git a/src/common/powercmn.cpp b/src/common/powercmn.cpp index 40a31aadd7..7e6ca2bba2 100644 --- a/src/common/powercmn.cpp +++ b/src/common/powercmn.cpp @@ -41,6 +41,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxPowerEvent, wxEvent) #endif +// Provide stubs for systems without power resource management functions +#if !defined(__WINDOWS__) && !defined(__APPLE__) + +bool +wxPowerResource::Acquire(wxPowerResourceKind kind, + const wxString& WXUNUSED(reason)) +{ + return false; +} + +void wxPowerResource::Release(wxPowerResourceKind kind) +{ + +} + +#endif // !(__WINDOWS__ || __APPLE__) + // provide stubs for the systems not implementing these functions #if !defined(__WINDOWS__) diff --git a/src/msw/power.cpp b/src/msw/power.cpp index fa74db73aa..3e57d5f1ee 100644 --- a/src/msw/power.cpp +++ b/src/msw/power.cpp @@ -27,6 +27,7 @@ #endif //WX_PRECOMP #include "wx/power.h" +#include "wx/atomic.h" #include "wx/msw/private.h" #if !defined(__WINCE_STANDARDSDK__) @@ -39,6 +40,85 @@ } #endif +// ---------------------------------------------------------------------------- +// wxPowerResource +// ---------------------------------------------------------------------------- + +namespace +{ + +wxAtomicInt g_powerResourceScreenRefCount = 0; +wxAtomicInt g_powerResourceSystemRefCount = 0; + +bool UpdatePowerResourceExecutionState() +{ + EXECUTION_STATE executionState = ES_CONTINUOUS; + if ( g_powerResourceScreenRefCount > 0 ) + executionState |= ES_DISPLAY_REQUIRED; + + if ( g_powerResourceSystemRefCount > 0 ) + executionState |= ES_SYSTEM_REQUIRED; + + if ( ::SetThreadExecutionState(executionState) == NULL ) + { + wxLogLastError(wxT("SetThreadExecutionState()")); + return false; + } + + return true; +} + +} // anonymous namespace + +bool +wxPowerResource::Acquire(wxPowerResourceKind kind, + const wxString& WXUNUSED(reason)) +{ + switch ( kind ) + { + case wxPOWER_RESOURCE_SCREEN: + wxAtomicInc(g_powerResourceScreenRefCount); + break; + + case wxPOWER_RESOURCE_SYSTEM: + wxAtomicInc(g_powerResourceSystemRefCount); + break; + } + + return UpdatePowerResourceExecutionState(); +} + +void wxPowerResource::Release(wxPowerResourceKind kind) +{ + switch ( kind ) + { + case wxPOWER_RESOURCE_SCREEN: + if ( g_powerResourceScreenRefCount > 0 ) + { + wxAtomicDec(g_powerResourceScreenRefCount); + } + else + { + wxFAIL_MSG( "Screen power resource was not acquired" ); + } + break; + + case wxPOWER_RESOURCE_SYSTEM: + if ( g_powerResourceSystemRefCount > 0 ) + { + wxAtomicDec(g_powerResourceSystemRefCount); + } + else + { + wxFAIL_MSG( "System power resource was not acquired" ); + } + break; + } + + UpdatePowerResourceExecutionState(); +} + + // ---------------------------------------------------------------------------- // helper functions // ---------------------------------------------------------------------------- diff --git a/src/osx/cocoa/power.mm b/src/osx/cocoa/power.mm new file mode 100644 index 0000000000..0bfd8c24f7 --- /dev/null +++ b/src/osx/cocoa/power.mm @@ -0,0 +1,129 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/osx/cocoa/power.mm +// Purpose: wxPowerResource implementation for OSX +// Author: Tobias Taschner +// Created: 2014-08-09 +// Copyright: (c) wxWidgets team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "wx/wxprec.h" + +#include "wx/power.h" +#include "wx/atomic.h" +#include "wx/osx/private.h" + +#include + +// ---------------------------------------------------------------------------- +// wxPowerResource +// ---------------------------------------------------------------------------- + +wxAtomicInt g_powerResourceSystemRefCount = 0; + +IOPMAssertionID g_pmAssertionID = 0; +NSObject* g_processInfoActivity = nil; + +bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason) +{ + if ( g_powerResourceSystemRefCount >= 1 ) + { + wxCFStringRef cfreason(reason); + if( reason.IsEmpty()) + cfreason = wxString("User Activity"); + + if ( UMAGetSystemVersion() >= 0x1090 ) + { + // Use NSProcessInfo for 10.9 and newer + if ( !g_processInfoActivity ) + { + NSActivityOptions + options = NSActivityUserInitiated | + NSActivityIdleSystemSleepDisabled; + + if ( kind == wxPOWER_RESOURCE_SCREEN ) + options |= NSActivityIdleDisplaySleepDisabled; + + g_processInfoActivity = [[NSProcessInfo processInfo] + beginActivityWithOptions:options + reason:cfreason.AsNSString()]; + [g_processInfoActivity retain]; + return true; + } + } + else if ( !g_pmAssertionID ) + { + // Use power manager API for < 10.9 systems + IOReturn success = IOPMAssertionCreateWithName + ( + kIOPMAssertionTypeNoIdleSleep, + kIOPMAssertionLevelOn, + cfreason, + &g_pmAssertionID + ); + if ( success == kIOReturnSuccess ) + return true; + } + } + else if ( g_powerResourceSystemRefCount == 0 ) + { + // Release power assertion + if ( UMAGetSystemVersion() >= 0x1090 ) + { + // Use NSProcessInfo for 10.9 and newer + if ( g_processInfoActivity ) + { + [[NSProcessInfo processInfo] + endActivity:(id)g_processInfoActivity]; + g_processInfoActivity = nil; + + return true; + } + } + else if ( g_pmAssertionID ) + { + // Use power manager API for < 10.9 systems + IOReturn success = IOPMAssertionRelease(g_pmAssertionID); + g_pmAssertionID = 0; + if (success == kIOReturnSuccess) + return true; + } + } + + return true; +} + +bool wxPowerResource::Acquire(wxPowerResourceKind kind, const wxString& reason) +{ + wxAtomicInc(g_powerResourceSystemRefCount); + + bool success = UpdatePowerResourceUsage(kind, reason); + if (!success) + wxAtomicDec(g_powerResourceSystemRefCount); + + return success; +} + +void wxPowerResource::Release(wxPowerResourceKind kind) +{ + switch ( kind ) + { + case wxPOWER_RESOURCE_SCREEN: + case wxPOWER_RESOURCE_SYSTEM: + if ( g_powerResourceSystemRefCount > 0 ) + { + wxAtomicDec(g_powerResourceSystemRefCount); + } + else + { + wxFAIL_MSG("Power resource was not acquired"); + } + + UpdatePowerResourceUsage(kind, ""); + break; + } +}