This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
src/GitHub.VisualStudio.UI/Views/Dialog Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . ComponentModel . Composition ;
3+ using System . Diagnostics ;
34using System . Reactive . Disposables ;
45using System . Reactive . Linq ;
6+ using System . Runtime . InteropServices ;
57using System . Windows ;
68using System . Windows . Input ;
79using GitHub . Controls ;
@@ -46,7 +48,7 @@ public LoginCredentialsView()
4648 this . WhenAnyObservable (
4749 x => x . ViewModel . GitHubLogin . LoginViaOAuth ,
4850 x => x . ViewModel . EnterpriseLogin . LoginViaOAuth )
49- . Subscribe ( _ => Application . Current . MainWindow ? . Activate ( ) ) ;
51+ . Subscribe ( _ => SwitchToThisWindow ( ) ) ;
5052
5153 hostTabControl . SelectionChanged += ( s , e ) =>
5254 {
@@ -122,5 +124,20 @@ void SetupSelectedTabBindings(Action<IDisposable> d)
122124 . Where ( x => x == true )
123125 . BindTo ( this , v => v . enterpriseTab . IsSelected ) ) ;
124126 }
127+
128+ static void SwitchToThisWindow ( )
129+ {
130+ var hWnd = Process . GetCurrentProcess ( ) . MainWindowHandle ;
131+ if ( hWnd != IntPtr . Zero )
132+ {
133+ NativeMethods . SwitchToThisWindow ( hWnd , true ) ;
134+ }
135+ }
136+
137+ class NativeMethods
138+ {
139+ [ DllImport ( "user32.dll" ) ]
140+ internal static extern void SwitchToThisWindow ( IntPtr hWnd , bool fAltTab ) ;
141+ }
125142 }
126143}
You can’t perform that action at this time.
0 commit comments