void CPpcMainWnd::OnToolHoldDisp() { UnregisterHotKeys(); m_fHold = !m_fHold; EnableWindow(m_hWnd, !m_fHold); RegisterHotKeys(); if (!m_fActive) SetForegroundWindow(m_hWnd); KillTimer(m_hWnd, ID_TIMER_HOLD); m_fDrawHold = TRUE; SetTimer(m_hWnd, ID_TIMER_HOLD, TIMER_HOLD_INTERVAL, NULL); UpdateTitle(); if (m_fHold) { TurnOffDisplay(); m_fDisplay = FALSE; } else { TurnOnDisplay(); m_fDisplay = TRUE; InvalidateRect(m_hWnd, NULL, TRUE); UpdateWindow(m_hWnd); } }
// assumes UnregisterHotKeys was called before static int RegisterHotKeys() { hMessageWindow = CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc); int count = GetProfileCount(0, 0); for ( int i=0; i < count; i++ ) { if (!db_get_b(NULL, MODULENAME, OptName(i, SETTING_REGHOTKEY), 0)) continue; WORD wHotKey = db_get_w(NULL, MODULENAME, OptName(i, SETTING_HOTKEY), 0); hkInfo = ( HKINFO* )realloc(hkInfo, (hkiCount+1)*sizeof(HKINFO)); if (hkInfo == NULL) return -1; char atomname[255]; mir_snprintf(atomname, _countof(atomname), "StatusProfile_%d", i); hkInfo[hkiCount].id = GlobalAddAtomA(atomname); if (hkInfo[hkiCount].id == 0) continue; hkInfo[hkiCount].profile = i; hkiCount ++; RegisterHotKey(hMessageWindow, (int)hkInfo[hkiCount-1].id, GetFsModifiers(wHotKey), LOBYTE(wHotKey)); } if (hkiCount == 0) UnregisterHotKeys(); return 0; }
void CPpcMainWnd::OnToolOption() { if (m_fHold) return; SetForegroundWindow(m_hWnd); UnregisterHotKeys(); CMainWnd::OnToolOption(); RegisterHotKeys(); }
void CPpcMainWnd::OnToolKeyCtrl() { RECT rc; GetWindowRect(m_hwndLV, &rc); UnregisterHotKeys(); CPpcKeyCtrlDlg dlg; dlg.ShowKeyCtrlDlg(m_hWnd, &rc, ((CPpcSkin*)m_pSkin)->GetColor2(COLOR2_PLAYLISTBACK), ((CPpcSkin*)m_pSkin)->GetColor2(COLOR2_PLAYLISTTEXT)); RegisterHotKeys(); }
int LoadMainOptions() { if (hTTBModuleLoadedHook) { RemoveTopToolbarButtons(); CreateTopToolbarButtons(0,0); } UnregisterHotKeys(); RegisterHotKeys(); return 0; }
void CPpcMainWnd::OnToolHold() { UnregisterHotKeys(); m_fHold = !m_fHold; EnableWindow(m_hWnd, !m_fHold); RegisterHotKeys(); if (!m_fActive) SetForegroundWindow(m_hWnd); KillTimer(m_hWnd, ID_TIMER_HOLD); m_fDrawHold = TRUE; SetTimer(m_hWnd, ID_TIMER_HOLD, TIMER_HOLD_INTERVAL, NULL); UpdateTitle(); }
void CPpcMainWnd::OnActivate(int nActive, BOOL fMinimized, HWND hwndPrevious) { m_fActive = nActive == WA_INACTIVE ? FALSE : TRUE; if (!m_pOptions) return; if (((CPpcOptions*)m_pOptions)->m_fReleaseKeyMap && !m_fHold) { if (nActive == WA_INACTIVE) UnregisterHotKeys(); else RegisterHotKeys(); } SHHandleWMActivate(m_hWnd, MAKELONG(nActive, fMinimized), (LONG)hwndPrevious, &m_sai, FALSE); }
int DeinitProfilesModule() { for ( int i=0; i < mcount; i++ ) DestroyServiceFunction(hProfileServices[i]); if ( pce ) { for ( int i=0; i < pceCount; i++ ) free( pce[i].szProto ); free( pce ); } UnregisterHotKeys(); RemoveTopToolbarButtons(); DestroyServiceFunction(hLoadAndSetProfileService); return 0; }
static LRESULT CALLBACK SASWindowProc( IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PWLSESSION Session = (PWLSESSION)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (uMsg) { case WM_HOTKEY: { switch (lParam) { case MAKELONG(MOD_CONTROL | MOD_ALT, VK_DELETE): { TRACE("SAS: CONTROL+ALT+DELETE\n"); if (!Session->Gina.UseCtrlAltDelete) break; PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_CTRL_ALT_DEL, 0); return TRUE; } case MAKELONG(MOD_CONTROL | MOD_SHIFT, VK_ESCAPE): { TRACE("SAS: CONTROL+SHIFT+ESCAPE\n"); if (Session->LogonState == STATE_LOGGED_ON) DoGenericAction(Session, WLX_SAS_ACTION_TASKLIST); return TRUE; } } break; } case WM_CREATE: { /* Get the session pointer from the create data */ Session = (PWLSESSION)((LPCREATESTRUCT)lParam)->lpCreateParams; /* Save the Session pointer */ SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)Session); if (GetSetupType()) return TRUE; return RegisterHotKeys(Session, hwndDlg); } case WM_DESTROY: { if (!GetSetupType()) UnregisterHotKeys(Session, hwndDlg); return TRUE; } case WM_SETTINGCHANGE: { UINT uiAction = (UINT)wParam; if (uiAction == SPI_SETSCREENSAVETIMEOUT || uiAction == SPI_SETSCREENSAVEACTIVE) { SetEvent(Session->hScreenSaverParametersChanged); } return TRUE; } case WM_LOGONNOTIFY: { switch(wParam) { case LN_MESSAGE_BEEP: { return HandleMessageBeep(lParam); } case LN_SHELL_EXITED: { /* lParam is the exit code */ if (lParam != 1 && Session->LogonState != STATE_LOGGED_OFF && Session->LogonState != STATE_LOGGED_OFF_SAS) { SetTimer(hwndDlg, 1, 1000, NULL); } break; } case LN_START_SCREENSAVE: { DispatchSAS(Session, WLX_SAS_TYPE_SCRNSVR_TIMEOUT); break; } case LN_LOCK_WORKSTATION: { DoGenericAction(Session, WLX_SAS_ACTION_LOCK_WKSTA); break; } case LN_LOGOFF: { UINT Flags = (UINT)lParam; UINT Action = Flags & EWX_ACTION_MASK; DWORD wlxAction; TRACE("\tFlags : 0x%lx\n", lParam); /* * Our caller (USERSRV) should have added the shutdown flag * when setting also poweroff or reboot. */ if (Action & (EWX_POWEROFF | EWX_REBOOT)) { if ((Action & EWX_SHUTDOWN) == 0) { ERR("Missing EWX_SHUTDOWN flag for poweroff or reboot; action 0x%x\n", Action); return STATUS_INVALID_PARAMETER; } /* Now we can locally remove it for performing checks */ Action &= ~EWX_SHUTDOWN; } /* Check parameters */ if (Action & EWX_FORCE) { // FIXME! ERR("FIXME: EWX_FORCE present for Winlogon, what to do?\n"); Action &= ~EWX_FORCE; } switch (Action) { case EWX_LOGOFF: wlxAction = WLX_SAS_ACTION_LOGOFF; break; case EWX_SHUTDOWN: wlxAction = WLX_SAS_ACTION_SHUTDOWN; break; case EWX_REBOOT: wlxAction = WLX_SAS_ACTION_SHUTDOWN_REBOOT; break; case EWX_POWEROFF: wlxAction = WLX_SAS_ACTION_SHUTDOWN_POWER_OFF; break; default: { ERR("Invalid ExitWindows action 0x%x\n", Action); return STATUS_INVALID_PARAMETER; } } TRACE("In LN_LOGOFF, exit_in_progress == %s\n", ExitReactOSInProgress ? "true" : "false"); /* * In case a parallel shutdown request is done (while we are * being to shut down) and it was not done by Winlogon itself, * then just stop here. */ #if 0 // This code is commented at the moment (even if it's correct) because // our log-offs do not really work: the shell is restarted, no app is killed // etc... and as a result you just get explorer opening "My Documents". And // if you try now a shut down, it won't work because winlogon thinks it is // still in the middle of a shutdown. // Maybe we also need to reset ExitReactOSInProgress somewhere else?? if (ExitReactOSInProgress && (lParam & EWX_CALLER_WINLOGON) == 0) { break; } #endif /* Now do the shutdown action proper */ DoGenericAction(Session, wlxAction); return 1; } case LN_LOGOFF_CANCELED: { ERR("Logoff canceled!!, before: exit_in_progress == %s, after will be false\n", ExitReactOSInProgress ? "true" : "false"); ExitReactOSInProgress = FALSE; return 1; } default: { ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam); } } return 0; } case WM_TIMER: { if (wParam == 1) { KillTimer(hwndDlg, 1); StartUserShell(Session); } break; } case WLX_WM_SAS: { DispatchSAS(Session, (DWORD)wParam); return TRUE; } } return DefWindowProc(hwndDlg, uMsg, wParam, lParam); }
void CPpcMainWnd::OnClose() { KillTimer(m_hWnd, ID_TIMER_DISPCHECK); UnregisterHotKeys(); CMainWnd::OnClose(); }