Disable screensaver while projecting (untested on Windows)
This commit is contained in:
parent
366b364996
commit
e2b203ba8d
6 changed files with 84 additions and 3 deletions
|
@ -595,6 +595,8 @@ sub current_layer_height {
|
|||
sub start_print {
|
||||
my ($self) = @_;
|
||||
|
||||
Slic3r::GUI::disable_screensaver();
|
||||
|
||||
{
|
||||
$self->sender(Slic3r::GCode::Sender->new);
|
||||
my $res = $self->sender->connect(
|
||||
|
@ -632,15 +634,25 @@ sub stop_print {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->is_printing(0);
|
||||
Slic3r::GUI::enable_screensaver();
|
||||
$self->timer->Stop;
|
||||
$self->_timer_cb(undef);
|
||||
$self->screen->project_layers(undef);
|
||||
}
|
||||
|
||||
sub print_completed {
|
||||
my ($self) = @_;
|
||||
|
||||
# send custom end G-code
|
||||
if ($self->sender) {
|
||||
$self->sender->send($_, 1) for grep !/^;/, split /\n/, $self->config->end_gcode;
|
||||
$self->sender->disconnect;
|
||||
}
|
||||
|
||||
$self->on_print_completed->()
|
||||
if $self->is_printing && $self->on_print_completed;
|
||||
|
||||
$self->stop_print;
|
||||
}
|
||||
|
||||
sub is_projecting {
|
||||
|
@ -667,8 +679,7 @@ sub project_next_layer {
|
|||
$self->_layer_num($self->_layer_num + 1);
|
||||
Slic3r::debugf "projecting layer %d\n", $self->_layer_num;
|
||||
if ($self->_layer_num >= $self->layer_count) {
|
||||
$self->on_print_completed->()
|
||||
if $self->is_printing && $self->on_print_completed;
|
||||
$self->print_completed;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@ use Module::Build::WithXSpp;
|
|||
# NOGDI : prevents inclusion of wingdi.h which defines functions Polygon() and Polyline() in global namespace
|
||||
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
|
||||
my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE);
|
||||
my @ldflags = ();
|
||||
if ($^O eq 'darwin') {
|
||||
push @ldflags, qw(-framework IOKit -framework CoreFoundation);
|
||||
}
|
||||
|
||||
my @INC = qw();
|
||||
my @LIBS = qw();
|
||||
|
@ -117,7 +121,7 @@ my $build = Module::Build::WithXSpp->new(
|
|||
Module::Build::WithXSpp 0.13
|
||||
)},
|
||||
extra_compiler_flags => [ @INC, @cflags ],
|
||||
extra_linker_flags => \@LIBS,
|
||||
extra_linker_flags => [ @LIBS, @ldflags ],
|
||||
|
||||
# Provides extra C typemaps that are auto-merged
|
||||
extra_typemap_modules => {
|
||||
|
|
|
@ -38,6 +38,8 @@ src/libslic3r/GCodeWriter.cpp
|
|||
src/libslic3r/GCodeWriter.hpp
|
||||
src/libslic3r/Geometry.cpp
|
||||
src/libslic3r/Geometry.hpp
|
||||
src/libslic3r/GUI/GUI.cpp
|
||||
src/libslic3r/GUI/GUI.hpp
|
||||
src/libslic3r/GUI/3DScene.cpp
|
||||
src/libslic3r/GUI/3DScene.hpp
|
||||
src/libslic3r/Layer.cpp
|
||||
|
@ -132,6 +134,7 @@ xsp/GCodeSender.xsp
|
|||
xsp/GCode.xsp
|
||||
xsp/GCodeWriter.xsp
|
||||
xsp/Geometry.xsp
|
||||
xsp/GUI.xsp
|
||||
xsp/GUI_3DScene.xsp
|
||||
xsp/Layer.xsp
|
||||
xsp/Line.xsp
|
||||
|
|
37
xs/src/libslic3r/GUI/GUI.cpp
Normal file
37
xs/src/libslic3r/GUI/GUI.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "GUI.hpp"
|
||||
|
||||
#if __APPLE__
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#elif _WIN32
|
||||
#include <Windows.h>
|
||||
#pragma comment(lib, "user32.lib")
|
||||
#endif
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
IOPMAssertionID assertionID;
|
||||
|
||||
void
|
||||
disable_screensaver()
|
||||
{
|
||||
#if __APPLE__
|
||||
CFStringRef reasonForActivity = CFSTR("Slic3r");
|
||||
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
|
||||
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
|
||||
// ignore result: success == kIOReturnSuccess
|
||||
#elif _WIN32
|
||||
SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
enable_screensaver()
|
||||
{
|
||||
#if __APPLE__
|
||||
IOReturn success = IOPMAssertionRelease(assertionID);
|
||||
#elif _WIN32
|
||||
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
} }
|
11
xs/src/libslic3r/GUI/GUI.hpp
Normal file
11
xs/src/libslic3r/GUI/GUI.hpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef slic3r_GUI_hpp_
|
||||
#define slic3r_GUI_hpp_
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void disable_screensaver();
|
||||
void enable_screensaver();
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
15
xs/xsp/GUI.xsp
Normal file
15
xs/xsp/GUI.xsp
Normal file
|
@ -0,0 +1,15 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "libslic3r/GUI/GUI.hpp"
|
||||
%}
|
||||
|
||||
|
||||
%package{Slic3r::GUI};
|
||||
|
||||
void disable_screensaver()
|
||||
%code{% Slic3r::GUI::disable_screensaver(); %};
|
||||
|
||||
void enable_screensaver()
|
||||
%code{% Slic3r::GUI::enable_screensaver(); %};
|
Loading…
Reference in a new issue