Ejemplo n.º 1
0
void setKeepAwake(bool awake)
{
    if (awake){
        #if defined(Q_OS_WIN)
            SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
            
        #elif defined(Q_OS_MAC)
            if(success == kIOReturnSuccess) {
            	
            }else{
                success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, 
                                                    kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
            }
        #endif
    }else{
        #if defined(Q_OS_WIN)
            SetThreadExecutionState(ES_CONTINUOUS);
            
        #elif defined(Q_OS_MAC)
            if(success == kIOReturnSuccess) {
                IOPMAssertionRelease(assertionID);
                success = kIOReturnError;
                
            }else{
            	
            }
        #endif
    }
}
Ejemplo n.º 2
0
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.
	SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);

    HACCEL hAccelTable = LoadAccelerators(hInstance, NULL);

    MSG msg;

    // Main message loop:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

	SetThreadExecutionState(ES_CONTINUOUS);

    return (int) msg.wParam;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: jkniiv/burp
int client(struct conf *conf, enum action action, int vss_restore, int json)
{
	enum cliret ret=CLIENT_OK;
	
#ifdef HAVE_WIN32
	// prevent sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#endif
	
	switch((ret=do_client(conf, action, vss_restore, json)))
	{
		case CLIENT_RECONNECT:
			logp("Re-opening connection to server\n");
			sleep(5);
			ret=do_client(conf, action, vss_restore, json);
		default:
			break;
	}
	
#ifdef HAVE_WIN32
	// allow sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS);
#endif

	// See enum cliret for return codes.
	return (int)ret;
}
Ejemplo n.º 4
0
/*
 *  Set The Desired Thread Execution State
 */
void setExecState( HWND inHwnd, int stateType )
{
//    char** msg = new char*[3]
//    {
//        "1", "2", "3"
//    };
    switch ( stateType )
    {
        case 0:     // Defaults
            SetThreadExecutionState(ES_CONTINUOUS);
            break;
        case 1:     // Keep System active
            SetThreadExecutionState(
                        ES_SYSTEM_REQUIRED |
                        ES_CONTINUOUS);
            break;
        case 2:     // Keep System and Display active
            SetThreadExecutionState(
                        ES_SYSTEM_REQUIRED |
                        ES_DISPLAY_REQUIRED |
                        ES_CONTINUOUS);
            break;

    }
//    MessageBox(inHwnd, msg[stateType],
//                "standByChBox Status", MB_OK | MB_ICONINFORMATION);
}
Ejemplo n.º 5
0
void EnableScreenSaver(bool enable)
#endif
{
// Inhibit the screensaver. Depending on the operating system this may also
// disable low-power states and/or screen dimming.

#if defined(HAVE_X11) && HAVE_X11
  if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
  {
    X11Utils::InhibitScreensaver(win, !enable);
  }
#endif

#ifdef _WIN32
  // Prevents Windows from sleeping, turning off the display, or idling
  if (enable)
  {
    SetThreadExecutionState(ES_CONTINUOUS);
  }
  else
  {
    EXECUTION_STATE should_screen_save =
        Config::Get(Config::MAIN_DISABLE_SCREENSAVER) ? ES_DISPLAY_REQUIRED : 0;
    SetThreadExecutionState(ES_CONTINUOUS | should_screen_save | ES_SYSTEM_REQUIRED);
  }
#endif

#ifdef __APPLE__
  static IOPMAssertionID s_power_assertion = kIOPMNullAssertionID;

  if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
  {
    if (enable)
    {
      if (s_power_assertion != kIOPMNullAssertionID)
      {
        IOPMAssertionRelease(s_power_assertion);
        s_power_assertion = kIOPMNullAssertionID;
      }
    }
    else
    {
      CFStringRef reason_for_activity = CFSTR("Emulation Running");
      if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
                                      kIOPMAssertionLevelOn, reason_for_activity,
                                      &s_power_assertion) != kIOReturnSuccess)
      {
        s_power_assertion = kIOPMNullAssertionID;
      }
    }
  }
#endif
}
Ejemplo n.º 6
0
void PerformanceMonitor::BlockShutdown() {
  if (block_)
    return;

  block_ = true;

  if (!SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED |
                               ES_AWAYMODE_REQUIRED) &&
      !SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED))
    ATLTRACE2(L"Failed to set thread execution state.\n");

  CString text;
  text.LoadString(IDS_NETWORK_ACTIVE);
  ShutdownBlockReasonCreate(message_window_, text);
}
Ejemplo n.º 7
0
int vo_w32_control(struct vo *vo, int *events, int request, void *arg)
{
    struct vo_w32_state *w32 = vo->w32;
    switch (request) {
    case VOCTRL_CHECK_EVENTS:
        *events |= vo_w32_check_events(vo);
        return VO_TRUE;
    case VOCTRL_FULLSCREEN:
        vo_w32_fullscreen(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_ONTOP:
        vo_w32_ontop(vo);
        return VO_TRUE;
    case VOCTRL_BORDER:
        vo_w32_border(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_UPDATE_SCREENINFO:
        w32_update_xinerama_info(vo);
        return VO_TRUE;
    case VOCTRL_SET_CURSOR_VISIBILITY:
        w32->cursor_visible = *(bool *)arg;

        if (vo_w32_is_cursor_in_client(vo)) {
            if (w32->cursor_visible)
                SetCursor(LoadCursor(NULL, IDC_ARROW));
            else
                SetCursor(NULL);
        }
        return VO_TRUE;
    case VOCTRL_KILL_SCREENSAVER:
        w32->disable_screensaver = true;
        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
        return VO_TRUE;
    case VOCTRL_RESTORE_SCREENSAVER:
        w32->disable_screensaver = false;
        SetThreadExecutionState(ES_CONTINUOUS);
        return VO_TRUE;
    case VOCTRL_UPDATE_WINDOW_TITLE: {
        wchar_t *title = mp_from_utf8(NULL, (char *)arg);
        SetWindowTextW(w32->window, title);
        talloc_free(title);
        return VO_TRUE;
    }
    }
    return VO_NOTIMPL;
}
Ejemplo n.º 8
0
JNIEXPORT void JNICALL Java_sage_PowerManagement_setPowerState0
  (JNIEnv *env, jobject jo, jint powerState)
{
	EXECUTION_STATE es = 0;
	if (powerState & sage_PowerManagement_SYSTEM_POWER)
		es |= ES_SYSTEM_REQUIRED;
	if (powerState & sage_PowerManagement_DISPLAY_POWER)
		es |= ES_DISPLAY_REQUIRED;
	// This one will reset the idle timer so we'll be up for the PM timeout; which is good for when there's user activity
	if (powerState & sage_PowerManagement_USER_ACTIVITY)
		SetThreadExecutionState(es);
	// This one doesn't involve timeouts; it just tells the system if we need display or system power
	es |= ES_CONTINUOUS;
	SetThreadExecutionState(es);

	// See if we need to enable the SS
	if (disabledSS && ((powerState & sage_PowerManagement_DISPLAY_POWER) == 0))
	{
		// Enable the SS
		SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,
		     TRUE,
             0,
             SPIF_SENDWININICHANGE);
		disabledSS = FALSE;
		slog((env, "Enabled SS\r\n"));
	}
	else if (!disabledSS && ((powerState & sage_PowerManagement_DISPLAY_POWER) != 0))
	{
		// Check if the screen saver is enabled, disable it if it is
		BOOL pvParam = 0;
		SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,
                         0,
                         &pvParam,
                         0
                       );
		if (pvParam)
		{
			if (SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,
		         FALSE,
                 0,
                 SPIF_SENDWININICHANGE))
			{
				slog((env, "Disabled SS\r\n"));
				disabledSS = TRUE;
			}
		}
	}
}
Ejemplo n.º 9
0
INT WorkerStop()
{
    SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, Worker.prevScreenSaver, NULL, 0);
    SetThreadExecutionState(Worker.prevExecState);

    return TerminateThread(Worker.hThread, 0);
}
Ejemplo n.º 10
0
CPowerRequest::~CPowerRequest() {
	if (m_Request != INVALID_HANDLE_VALUE) {
		CloseHandle(m_Request);
	} else {
		if (m_bDisplay || m_bSystem) SetThreadExecutionState(ES_CONTINUOUS);
	}
}
Ejemplo n.º 11
0
void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
{
  // If we're running, only start a new game once we've stopped the last.
  if (Core::GetState() != Core::State::Uninitialized)
  {
    if (!RequestStop())
      return;

    // As long as the shutdown isn't complete, we can't boot, so let's boot later
    m_pending_boot = std::move(parameters);
    return;
  }
  // Boot up, show an error if it fails to load the game.
  if (!BootManager::BootCore(std::move(parameters)))
  {
    QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
    return;
  }
  ShowRenderWidget();

#ifdef Q_OS_WIN
  // Prevents Windows from sleeping, turning off the display, or idling
  EXECUTION_STATE shouldScreenSave =
      SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0;
  SetThreadExecutionState(ES_CONTINUOUS | shouldScreenSave | ES_SYSTEM_REQUIRED);
#endif
}
Ejemplo n.º 12
0
LRESULT CIdlePreventDlg::SendWakeEvent(WPARAM wparam, LPARAM lparam)
{
    // This ensures we only send wake events while the machine isn't locked. Seems Windows queues some events and sometimes they happen at once as soon as you unlock the computer.
	HDESK test = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, TRUE,DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |DESKTOP_SWITCHDESKTOP |GENERIC_WRITE);
	if (test != NULL)
	{
        if(RDPFriendlyWakeEnabled) 
        {      
            keybd_event(VK_RSHIFT,0xB6, KEYEVENTF_KEYUP,  0);
        }
        else
        {
            INPUT mouseInput[1];
            mouseInput[0].mi.dx = 0;
            mouseInput[0].mi.dy = 0;
            mouseInput[0].mi.mouseData = 0;
            mouseInput[0].mi.dwFlags = MOUSEEVENTF_MOVE;
            mouseInput[0].mi.time = 0;
            mouseInput[0].mi.dwExtraInfo = NULL;
            SendInput(1, mouseInput, sizeof(mouseInput));
            SetThreadExecutionState(ES_DISPLAY_REQUIRED);
        }
	}
	CloseDesktop(test);
	return 0;
}
Ejemplo n.º 13
0
void ScreensaverAllow(bool allow)
{
    EXECUTION_STATE flags = ES_CONTINUOUS;
    if (!allow)
        flags |= ES_DISPLAY_REQUIRED;
    SetThreadExecutionState(flags);
}
Ejemplo n.º 14
0
/* See Porting Layer Definition - p. 6 */
void
winBlockHandler(ScreenPtr pScreen, void *pTimeout)
{
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    winScreenPriv(pScreen);
#endif

#ifndef HAS_DEVWINDOWS
    struct timeval **tvp = pTimeout;

    if (*tvp != NULL) {
      if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) {
        /* If there are still messages to process on the Windows message
           queue, make sure select() just polls rather than blocking.
        */
        (*tvp)->tv_sec = 0;
        (*tvp)->tv_usec = 0;
      }
      else {
        /* Otherwise, lacking /dev/windows, we must wake up again in
           a reasonable time to check the Windows message queue. without
           noticeable delay.
         */
        (*tvp)->tv_sec = 0;
        (*tvp)->tv_usec = 100;
      }
    }
#endif

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    /* Signal threaded modules to begin */
    if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) {
        int iReturn;

        winDebug("winBlockHandler - pthread_mutex_unlock()\n");

        /* Flag that modules are to be started */
        pScreenPriv->fServerStarted = TRUE;

        /* Unlock the mutex for threaded modules */
        iReturn = pthread_mutex_unlock(&pScreenPriv->pmServerStarted);
        if (iReturn != 0) {
            ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
                   iReturn);
        }
        else {
            winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
        }
    }
#endif

  /*
    At least one X client has asked to suspend the screensaver, so
    reset Windows' display idle timer
  */
#ifdef SCREENSAVER
  if (screenSaverSuspended)
    SetThreadExecutionState(ES_DISPLAY_REQUIRED);
#endif
}
Ejemplo n.º 15
0
// Windows GUI thread to prevent screen savers or hibernation, and prevent the cursor from getting lost.
int GenericSLMWindowsGUIThread::svc(void)
{
   long i=0;
   while(!stop_)
   {

      ++i;

      if ((i % 900) == 0) {  // Every 30 seconds or so ...
         // ... reset idle clocks to prevent screensaver or hibernation (would appear on SLM).
         SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
      }

      if ((i % 30) == 0)
      {
         //FixWindows(hwnd_); // This seems to be too slow. Run in separate thread?
         //SetWindowPos(hwnd_, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // This seems to be too slow.
      }


      RestrictCursor();

      Sleep(30);
   }

   return 0;
}
void SystemEventsManager::prevent(int event, bool prevent) {
	if (prevent) {
		prepareLoop();
#if VERSIONWIN
		if (event == SYSTEM_SLEEP)
			SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#endif
	}
    events[event].prevent(prevent);
	if (!prevent) {
		stopLoop();
#if VERSIONWIN
		if (event == SYSTEM_SLEEP)
			SetThreadExecutionState(ES_CONTINUOUS);
#endif
	}
}
Ejemplo n.º 17
0
HANDLE WorkerStart()
{
    Worker.prevExecState = SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
    SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &Worker.prevScreenSaver, 0);
    SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, FALSE, NULL, 0);

    return (Worker.hThread = CreateThread(NULL, 0, WorkerThread, NULL, 0, NULL));
}
Ejemplo n.º 18
0
void UIDirect3D9Window::MainLoop(void)
{
    quint64 timestamp = StartFrame();

    CheckForNewTheme();
    UpdateImages();

    if (m_d3dDevice)
    {
        HRESULT result = m_d3dDevice->TestCooperativeLevel();

        if (SUCCEEDED(result))
        {
            m_d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);

            if (m_theme && m_d3dDevice && SUCCEEDED(m_d3dDevice->BeginScene()))
            {
                m_theme->Refresh(timestamp);
                m_theme->Draw(timestamp, this, 0.0, 0.0);

                m_d3dDevice->EndScene();
                m_d3dDevice->Present(NULL, NULL, NULL, NULL);
                SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
            }
        }
        else
        {
            switch (result)
            {
                case D3DERR_DEVICELOST:
                    if (D3DERR_DEVICELOST != m_deviceState)
                        LOG(VB_GENERAL, LOG_ERR, "Device lost");
                    m_deviceState = D3DERR_DEVICELOST;
                    break;
                case D3DERR_DRIVERINTERNALERROR:
                    LOG(VB_GENERAL, LOG_ERR, "Driver error - quiting");
                    m_deviceState = D3DERR_DRIVERINTERNALERROR;
                    qApp->exit();
                    break;
                case D3DERR_DEVICENOTRESET:
                    if (D3DERR_DEVICENOTRESET != m_deviceState)
                        LOG(VB_GENERAL, LOG_ERR, "Device needs reset");
                     m_deviceState = D3DERR_DEVICENOTRESET;
                     HandleDeviceReset();
                default:
                    break;
            }
        }
    }

    FinishDrawing();

    if (m_timer)
    {
        m_timer->Wait();
        m_timer->Start();
    }
}
Ejemplo n.º 19
0
void PerformanceMonitor::UnblockShutdown() {
  if (!block_)
    return;

  block_ = false;

  SetThreadExecutionState(ES_CONTINUOUS);
  ShutdownBlockReasonDestroy(message_window_);
}
void WindowsIdleHandler::Uninhibit() {
  previous_state_ = 
      SetThreadExecutionState(ES_CONTINUOUS | previous_state_);
  if (previous_state_ != 0) {
    is_inhibit_ = false;
  } else {
    qLog(Warning) << "Failed to uninhibit screensaver/suspend";
  }
}
Ejemplo n.º 21
0
void
enable_screensaver()
{
    #if __APPLE__
    IOReturn success = IOPMAssertionRelease(assertionID);
    #elif _WIN32
    SetThreadExecutionState(ES_CONTINUOUS);
    #endif
}
Ejemplo n.º 22
0
static void __cdecl ac3_thread(void *p)
{
 ac3_decode *ac3=(ac3_decode *)p;

 ac3->done=CreateEvent(NULL,0,0,0);
 ac3->out_done=CreateEvent(NULL,0,0,0);
 ac3->in_done=CreateEvent(NULL,0,0,0);

 if(SetThreadPriority((HANDLE)ac3->thread,THREAD_PRIORITY_HIGHEST)==0)
 {
  debug("kxmixer: error setting thread priority [%x]\n",GetLastError());
 }
 // else debug("kxmixer: set thread priority to highest [%x]\n",ac3->thread);

 if(SetThreadExecutionState(ES_SYSTEM_REQUIRED)==NULL)
 {
  debug("kxmixer: cannot set execution thread state -- might cause problems with APM...\n");
 }

 if(ac3->done && ac3->in_done && ac3->out_done)
 {
  // debug("kxmixer: thread created and active...starting rec...\n");

  waveInStart(ac3->wave_in);

  ac3->last_out_buffer=1;
  ac3->last_in_buffer=1;
  
  while(1)
  {
   // WaitForMultipleObject including 'done' event...
   HANDLE list[3];
   list[0]=ac3->done; list[1]=ac3->out_done; list[2]=ac3->in_done;
   int ret=WaitForMultipleObjects(3,list,0,INFINITE);
   if(ret==WAIT_OBJECT_0) // done
   {
    break;
   }
   if(ret==WAIT_OBJECT_0+1) // out
   {
   }
   if(ret==WAIT_OBJECT_0+2) // in
   {
     	waveOutWrite(ac3->wave_out,&ac3->out_buffer[ac3->last_out_buffer-1],sizeof(WAVEHDR));

     	ac3->last_out_buffer++;
     	if(ac3->last_out_buffer>TOTAL_BUFFERS)
         ac3->last_out_buffer=1;
   }
  }

  waveInStop(ac3->wave_in);

  debug("kxmixer: thread exited...\n");
 } else debug("kxmixer: error creating thread events\n");
}
Ejemplo n.º 23
0
bool win32_suppress_screensaver(void *data, bool enable)
{
#ifdef _XBOX
   return false;
#else

   if(enable)
   {
      int major, minor;
      char tmp[PATH_MAX_LENGTH];
      const frontend_ctx_driver_t *frontend = frontend_get_ptr();

      if (!frontend)
         return false;

      frontend->get_os(tmp, sizeof(tmp), &major, &minor);

      if (major*100+minor >= 601)
      {
         /* Windows 7, 8, 10 codepath */
         typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
         typedef BOOL   (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
               POWER_REQUEST_TYPE RequestType);
         HMODULE kernel32 = GetModuleHandle("kernel32.dll");
         PowerCreateRequestPtr powerCreateRequest =
            (PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest");
         PowerSetRequestPtr    powerSetRequest =
            (PowerSetRequestPtr)GetProcAddress(kernel32, "PowerSetRequest");

         if(powerCreateRequest && powerSetRequest)
         {
            POWER_REQUEST_CONTEXT RequestContext;
            HANDLE Request;

            RequestContext.Version = POWER_REQUEST_CONTEXT_VERSION;
            RequestContext.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING;
            RequestContext.Reason.SimpleReasonString = (LPWSTR)L"RetroArch running";

            Request = powerCreateRequest(&RequestContext);

            powerSetRequest( Request, PowerRequestDisplayRequired);
            return true;
         }
      }
      else
      {
         /* XP / Vista codepath */
         SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
         return true;
      }
   }

   return false;
#endif
}
Ejemplo n.º 24
0
bool MainWindow::RequestStop()
{
  if (!Core::IsRunning())
  {
    Core::QueueHostJob([this] { OnStopComplete(); }, true);
    return true;
  }

  if (SConfig::GetInstance().bConfirmStop)
  {
    const Core::State state = Core::GetState();

    // Only pause the game, if NetPlay is not running
    bool pause = Settings::Instance().GetNetPlayClient() != nullptr;

    if (pause)
      Core::SetState(Core::State::Paused);

    QMessageBox::StandardButton confirm;
    confirm = QMessageBox::question(m_render_widget, tr("Confirm"),
                                    m_stop_requested ?
                                        tr("A shutdown is already in progress. Unsaved data "
                                           "may be lost if you stop the current emulation "
                                           "before it completes. Force stop?") :
                                        tr("Do you want to stop the current emulation?"));

    if (pause)
      Core::SetState(state);

    if (confirm != QMessageBox::Yes)
      return false;
  }

  // TODO: Add Movie shutdown
  // TODO: Add Debugger shutdown

  if (!m_stop_requested && UICommon::TriggerSTMPowerEvent())
  {
    m_stop_requested = true;

    // Unpause because gracefully shutting down needs the game to actually request a shutdown.
    // TODO: Do not unpause in debug mode to allow debugging until the complete shutdown.
    if (Core::GetState() == Core::State::Paused)
      Core::SetState(Core::State::Running);

    return true;
  }

  ForceStop();
#ifdef Q_OS_WIN
  // Allow windows to idle or turn off display again
  SetThreadExecutionState(ES_CONTINUOUS);
#endif
  return true;
}
void WindowsIdleHandler::Inhibit(const char*) {
  switch (IdleHandler::inbtr_) {
    case IdleHandler::Screensaver :
      // resetting the display idle timer.
      previous_state_ =
          SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
      break;
    case IdleHandler::Suspend :
      // resetting the system idle timer.
      previous_state_ =
          SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
      break;
  }

  if (previous_state_ != 0) {
    is_inhibit_ = true;
  } else {
    qLog(Warning) << "Failed to inhibit screensaver/suspend";
  }
}
Ejemplo n.º 26
0
bool os_inhibit_sleep_set_active(os_inhibit_t *info, bool active)
{
	if (!info)
		return false;
	if (info->active == active)
		return false;

	if (active) {
		SetThreadExecutionState(
				ES_CONTINUOUS |
				ES_SYSTEM_REQUIRED |
				ES_AWAYMODE_REQUIRED |
				ES_DISPLAY_REQUIRED);
	} else {
		SetThreadExecutionState(ES_CONTINUOUS);
	}

	info->active = active;
	return true;
}
Ejemplo n.º 27
0
/**
 * \brief Uninitialize w32_common framework.
 *
 * Should be called last in video driver's uninit function. First release
 * anything built on top of the created window e.g. rendering context inside
 * and call vo_w32_uninit at the end.
 */
void vo_w32_uninit(struct vo *vo)
{
    struct vo_w32_state *w32 = vo->w32;
    MP_VERBOSE(vo, "win32: uninit\n");
    if (!w32)
        return;
    SetThreadExecutionState(ES_CONTINUOUS);
    DestroyWindow(w32->window);
    UnregisterClassW(classname, 0);
    talloc_free(w32);
    vo->w32 = NULL;
}
Ejemplo n.º 28
0
void
disable_screensaver()
{
    #if __APPLE__
    CFStringRef reasonForActivity = CFSTR("Slic3r");
    IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, 
        kIOPMAssertionLevelOn, reasonForActivity, &assertionID); 
    // ignore result: success == kIOReturnSuccess
    #elif _WIN32
    SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
    #endif
}
Ejemplo n.º 29
0
int client(struct config *conf, enum action act, int vss_restore, int json)
{
	int ret=0;
	
#if defined(HAVE_WIN32)
	// prevent sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#endif
	
	if((ret=do_client(conf, act, vss_restore, json))==1)
	{
		logp("Re-opening connection to server\n");
		sleep(5);
		ret=do_client(conf, act, vss_restore, json);
	}
	
#if defined(HAVE_WIN32)
	// allow sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS);
#endif
	
	return ret;
}
Ejemplo n.º 30
0
void StressTest::Finished(bool success)
{
    win->stressTest = NULL;
    SetThreadExecutionState(ES_CONTINUOUS);

    if (success) {
        int secs = SecsSinceSystemTime(stressStartTime);
        ScopedMem<TCHAR> tm(FormatTime(secs));
        ScopedMem<TCHAR> s(str::Format(_T("Stress test complete, rendered %d files in %s"), filesCount, tm));
        ShowNotification(win, s, false, false, NG_STRESS_TEST_SUMMARY);
    }

    CloseWindow(win, false, false);
    delete this;
}