Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6987cb0e
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6987cb0e
编写于
7月 20, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
API: window.isFocused, window.onDidChangeWindowFocus
fixes #18263
上级
7f503e89
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
105 addition
and
0 deletion
+105
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+16
-0
src/vs/workbench/api/electron-browser/extensionHost.contribution.ts
...kbench/api/electron-browser/extensionHost.contribution.ts
+2
-0
src/vs/workbench/api/electron-browser/mainThreadWindow.ts
src/vs/workbench/api/electron-browser/mainThreadWindow.ts
+35
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+8
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+10
-0
src/vs/workbench/api/node/extHostWindow.ts
src/vs/workbench/api/node/extHostWindow.ts
+34
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
6987cb0e
...
...
@@ -167,4 +167,20 @@ declare module 'vscode' {
*/
export
function
deleteSecret
(
service
:
string
,
account
:
string
):
Thenable
<
boolean
>
;
}
export
namespace
window
{
/**
* Whether the current window is focused.
*
* @readonly
*/
export
let
isFocused
:
boolean
;
/**
* An [event](#Event) which fires when the focus state of the current window
* changes. The value of the event represents whether the window is focused.
*/
export
const
onDidChangeWindowFocus
:
Event
<
boolean
>
;
}
}
src/vs/workbench/api/electron-browser/extensionHost.contribution.ts
浏览文件 @
6987cb0e
...
...
@@ -37,6 +37,7 @@ import { MainThreadFileSystemEventService } from './mainThreadFileSystemEventSer
import
{
MainThreadTask
}
from
'
./mainThreadTask
'
;
import
{
MainThreadSCM
}
from
'
./mainThreadSCM
'
;
import
{
MainThreadCredentials
}
from
'
./mainThreadCredentials
'
;
import
{
MainThreadWindow
}
from
'
./mainThreadWindow
'
;
// --- other interested parties
import
{
MainThreadDocumentsAndEditors
}
from
'
./mainThreadDocumentsAndEditors
'
;
...
...
@@ -92,6 +93,7 @@ export class ExtHostContribution implements IWorkbenchContribution {
col
.
define
(
MainContext
.
MainThreadSCM
).
set
(
create
(
MainThreadSCM
));
col
.
define
(
MainContext
.
MainThreadTask
).
set
(
create
(
MainThreadTask
));
col
.
define
(
MainContext
.
MainThreadCredentials
).
set
(
create
(
MainThreadCredentials
));
col
.
define
(
MainContext
.
MainThreadWindow
).
set
(
create
(
MainThreadWindow
));
if
(
this
.
extensionService
instanceof
MainProcessExtensionService
)
{
col
.
define
(
MainContext
.
MainProcessExtensionService
).
set
(
<
MainProcessExtensionService
>
this
.
extensionService
);
}
...
...
src/vs/workbench/api/electron-browser/mainThreadWindow.ts
0 → 100644
浏览文件 @
6987cb0e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
MainThreadWindowShape
,
ExtHostWindowShape
,
ExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
export
class
MainThreadWindow
extends
MainThreadWindowShape
{
private
readonly
proxy
:
ExtHostWindowShape
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
@
IThreadService
threadService
:
IThreadService
,
@
IWindowService
private
windowService
:
IWindowService
)
{
super
();
this
.
proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostWindow
);
windowService
.
onDidChangeFocus
(
this
.
proxy
.
$onDidChangeWindowFocus
,
this
.
proxy
,
this
.
disposables
);
}
$getWindowVisibility
():
TPromise
<
boolean
>
{
return
this
.
windowService
.
isFocused
();
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
6987cb0e
...
...
@@ -36,6 +36,7 @@ import { ExtHostApiCommands } from 'vs/workbench/api/node/extHostApiCommands';
import
{
ExtHostTask
}
from
'
vs/workbench/api/node/extHostTask
'
;
import
{
ExtHostDebugService
}
from
'
vs/workbench/api/node/extHostDebugService
'
;
import
{
ExtHostCredentials
}
from
'
vs/workbench/api/node/extHostCredentials
'
;
import
{
ExtHostWindow
}
from
'
vs/workbench/api/node/extHostWindow
'
;
import
*
as
extHostTypes
from
'
vs/workbench/api/node/extHostTypes
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Severity
from
'
vs/base/common/severity
'
;
...
...
@@ -96,6 +97,7 @@ export function createApiFactory(
const
extHostSCM
=
col
.
define
(
ExtHostContext
.
ExtHostSCM
).
set
<
ExtHostSCM
>
(
new
ExtHostSCM
(
threadService
,
extHostCommands
));
const
extHostTask
=
col
.
define
(
ExtHostContext
.
ExtHostTask
).
set
<
ExtHostTask
>
(
new
ExtHostTask
(
threadService
));
const
extHostCredentials
=
col
.
define
(
ExtHostContext
.
ExtHostCredentials
).
set
<
ExtHostCredentials
>
(
new
ExtHostCredentials
(
threadService
));
const
extHostWindow
=
col
.
define
(
ExtHostContext
.
ExtHostWindow
).
set
<
ExtHostWindow
>
(
new
ExtHostWindow
(
threadService
));
col
.
define
(
ExtHostContext
.
ExtHostExtensionService
).
set
(
extensionService
);
col
.
finish
(
false
,
threadService
);
...
...
@@ -308,6 +310,12 @@ export function createApiFactory(
onDidCloseTerminal
(
listener
,
thisArg
?,
disposables
?)
{
return
extHostTerminalService
.
onDidCloseTerminal
(
listener
,
thisArg
,
disposables
);
},
get
isFocused
()
{
return
extHostWindow
.
isFocused
;
},
onDidChangeWindowFocus
:
proposedApiFunction
(
extension
,
(
listener
,
thisArg
?,
disposables
?)
=>
{
return
extHostWindow
.
onDidChangeWindowFocus
(
listener
,
thisArg
,
disposables
);
}),
showInformationMessage
(
message
,
first
,
...
rest
)
{
return
extHostMessageService
.
showMessage
(
Severity
.
Info
,
message
,
first
,
rest
);
},
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
6987cb0e
...
...
@@ -356,6 +356,10 @@ export abstract class MainThreadCredentialsShape {
$deleteSecret
(
service
:
string
,
account
:
string
):
Thenable
<
boolean
>
{
throw
ni
();
}
}
export
abstract
class
MainThreadWindowShape
{
$getWindowVisibility
():
TPromise
<
boolean
>
{
throw
ni
();
}
}
// -- extension host
export
abstract
class
ExtHostCommandsShape
{
...
...
@@ -515,6 +519,10 @@ export abstract class ExtHostDebugServiceShape {
export
abstract
class
ExtHostCredentialsShape
{
}
export
abstract
class
ExtHostWindowShape
{
$onDidChangeWindowFocus
(
value
:
boolean
):
void
{
throw
ni
();
}
}
// --- proxy identifiers
export
const
MainContext
=
{
...
...
@@ -541,6 +549,7 @@ export const MainContext = {
MainThreadSCM
:
createMainId
<
MainThreadSCMShape
>
(
'
MainThreadSCM
'
,
MainThreadSCMShape
),
MainThreadTask
:
createMainId
<
MainThreadTaskShape
>
(
'
MainThreadTask
'
,
MainThreadTaskShape
),
MainThreadCredentials
:
createMainId
<
MainThreadCredentialsShape
>
(
'
MainThreadCredentials
'
,
MainThreadCredentialsShape
),
MainThreadWindow
:
createMainId
<
MainThreadWindowShape
>
(
'
MainThreadWindow
'
,
MainThreadWindowShape
),
};
export
const
ExtHostContext
=
{
...
...
@@ -563,4 +572,5 @@ export const ExtHostContext = {
ExtHostTask
:
createExtId
<
ExtHostTaskShape
>
(
'
ExtHostTask
'
,
ExtHostTaskShape
),
ExtHostWorkspace
:
createExtId
<
ExtHostWorkspaceShape
>
(
'
ExtHostWorkspace
'
,
ExtHostWorkspaceShape
),
ExtHostCredentials
:
createExtId
<
ExtHostCredentialsShape
>
(
'
ExtHostCredentials
'
,
ExtHostCredentialsShape
),
ExtHostWindow
:
createExtId
<
ExtHostWindowShape
>
(
'
ExtHostWindow
'
,
ExtHostWindowShape
),
};
src/vs/workbench/api/node/extHostWindow.ts
0 → 100644
浏览文件 @
6987cb0e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
ExtHostWindowShape
,
MainContext
,
MainThreadWindowShape
}
from
'
./extHost.protocol
'
;
export
class
ExtHostWindow
implements
ExtHostWindowShape
{
private
_proxy
:
MainThreadWindowShape
;
private
_onDidChangeWindowFocus
=
new
Emitter
<
boolean
>
();
get
onDidChangeWindowFocus
():
Event
<
boolean
>
{
return
this
.
_onDidChangeWindowFocus
.
event
;
}
private
_isFocused
=
false
;
get
isFocused
():
boolean
{
return
this
.
_isFocused
;
}
constructor
(
threadService
:
IThreadService
)
{
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadWindow
);
this
.
_proxy
.
$getWindowVisibility
().
then
(
isFocused
=>
this
.
$onDidChangeWindowFocus
(
isFocused
));
}
$onDidChangeWindowFocus
(
isFocused
:
boolean
):
void
{
if
(
isFocused
===
this
.
_isFocused
)
{
return
;
}
this
.
_isFocused
=
isFocused
;
this
.
_onDidChangeWindowFocus
.
fire
(
isFocused
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录