-
-
Notifications
You must be signed in to change notification settings - Fork 491
#1070 Can check if the current window is the first one. #1282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
arduino-ide-extension/src/browser/theia/core/browser-window-module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service'; | ||
import { ContainerModule } from '@theia/core/shared/inversify'; | ||
import { DefaultWindowService } from './default-window-service'; | ||
import { WindowServiceExt } from './window-service-ext'; | ||
|
||
export default new ContainerModule((bind, unbind, isBound, rebind) => { | ||
bind(DefaultWindowService).toSelf().inSingletonScope(); | ||
rebind(TheiaDefaultWindowService).toService(DefaultWindowService); | ||
bind(WindowServiceExt).toService(DefaultWindowService); | ||
}); |
17 changes: 17 additions & 0 deletions
arduino-ide-extension/src/browser/theia/core/default-window-service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DefaultWindowService as TheiaDefaultWindowService } from '@theia/core/lib/browser/window/default-window-service'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { WindowServiceExt } from './window-service-ext'; | ||
|
||
@injectable() | ||
export class DefaultWindowService | ||
extends TheiaDefaultWindowService | ||
implements WindowServiceExt | ||
{ | ||
/** | ||
* The default implementation always resolves to `true`. | ||
* IDE2 does not use it. It's currently an electron-only app. | ||
*/ | ||
async isFirstWindow(): Promise<boolean> { | ||
return true; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
arduino-ide-extension/src/browser/theia/core/window-service-ext.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const WindowServiceExt = Symbol('WindowServiceExt'); | ||
export interface WindowServiceExt { | ||
/** | ||
* Returns with a promise that resolves to `true` if the current window is the first window. | ||
*/ | ||
isFirstWindow(): Promise<boolean>; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
arduino-ide-extension/src/electron-browser/theia/core/electron-window-module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { WindowService } from '@theia/core/lib/browser/window/window-service'; | ||
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider'; | ||
import { ContainerModule } from '@theia/core/shared/inversify'; | ||
import { WindowServiceExt } from '../../../browser/theia/core/window-service-ext'; | ||
import { | ||
ElectronMainWindowServiceExt, | ||
electronMainWindowServiceExtPath, | ||
} from '../../../electron-common/electron-main-window-service-ext'; | ||
import { | ||
SplashService, | ||
splashServicePath, | ||
} from '../../../electron-common/splash-service'; | ||
import { ElectronWindowService } from './electron-window-service'; | ||
|
||
export default new ContainerModule((bind, unbind, isBound, rebind) => { | ||
bind(ElectronWindowService).toSelf().inSingletonScope(); | ||
rebind(WindowService).toService(ElectronWindowService); | ||
bind(WindowServiceExt).toService(ElectronWindowService); | ||
bind(ElectronMainWindowServiceExt) | ||
.toDynamicValue(({ container }) => | ||
ElectronIpcConnectionProvider.createProxy( | ||
container, | ||
electronMainWindowServiceExtPath | ||
) | ||
) | ||
.inSingletonScope(); | ||
bind(SplashService) | ||
.toDynamicValue(({ container }) => | ||
ElectronIpcConnectionProvider.createProxy(container, splashServicePath) | ||
) | ||
.inSingletonScope(); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
arduino-ide-extension/src/electron-common/electron-main-window-service-ext.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const electronMainWindowServiceExtPath = '/services/electron-window-ext'; | ||
export const ElectronMainWindowServiceExt = Symbol( | ||
'ElectronMainWindowServiceExt' | ||
); | ||
export interface ElectronMainWindowServiceExt { | ||
isFirstWindow(windowId: number): Promise<boolean>; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
arduino-ide-extension/src/electron-main/electron-main-window-service-ext-impl.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { ElectronMainWindowServiceExt } from '../electron-common/electron-main-window-service-ext'; | ||
import { ElectronMainApplication } from './theia/electron-main-application'; | ||
|
||
@injectable() | ||
export class ElectronMainWindowServiceExtImpl | ||
implements ElectronMainWindowServiceExt | ||
{ | ||
@inject(ElectronMainApplication) | ||
private readonly app: ElectronMainApplication; | ||
|
||
async isFirstWindow(windowId: number): Promise<boolean> { | ||
return this.app.firstWindowId === windowId; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.