private void OnActionWindowFocusLost(WindowInfo newFocusedWindow) { if (_actionSourceVisible && _currentFocusAction.HideOnFocusLost) { _logger.Write(LogLevel.Info, $"Source Visibility Window focus lost, switching '{_currentFocusAction.SourceName}' visibility to invisible"); _obs.SetSourceRender(_currentFocusAction.SourceName, false, _actionSourceInScene); _actionSourceVisible = false; } else { _logger.Write(LogLevel.Info, $"Source Visibility Window focus lost"); } _currentFocusAction = null; _currentFocusedWindowInfo = null; _actionSourceInScene = null; }
private void OnFocusedWindowTitleChanged(object sender, FocusedWindowTitleChangedEventArgs e) { if (_currentFocusedWindowInfo != null && //Full capture window focus is only lost if we ever had it in focus ( _currentFocusAction.IncludeSubWindows && e.NewFocusedWindow.ProcessId != e.OldFocusedWindow.ProcessId || //If new focused window is no parent of old focused window !_currentFocusAction.IncludeSubWindows && e.NewFocusedWindow.Title != _currentFocusedWindowInfo.Title //If new window title is not old window title )) { OnActionWindowFocusLost(e.NewFocusedWindow); } FocusedWindowSourceVisibilityAction foundChangeAction = _sourceVisibilityActionRepository.GetAll() .FirstOrDefault(a => _windowMatchService.DoesTitleMatch(e.NewFocusedWindow.Title, a.WindowTitle)); if (foundChangeAction == null) { return; } OnActionWindowFocused(foundChangeAction, e.NewFocusedWindow); }
private void OnActionWindowFocused(FocusedWindowSourceVisibilityAction action, WindowInfo newFocusedWindow) { string currentSceneName = _obs.GetCurrentScene().Name; if (action.EnabledForScenes.Count != 0 && !action.EnabledForScenes.Any(s => s == currentSceneName)) { return; } if (action.DisabledForScenes.Count != 0 && action.DisabledForScenes.Any(s => s == currentSceneName)) { return; } _logger.Write(LogLevel.Info, $"Source Visibility Window focused, switching '{action.SourceName}' visibility to visible"); _currentFocusAction = action; _currentFocusedWindowInfo = newFocusedWindow; _actionSourceInScene = currentSceneName; if (!_actionSourceVisible) { _obs.SetSourceRender(action.SourceName, true); _actionSourceVisible = true; } }