Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7fa03813
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,发现更多精彩内容 >>
提交
7fa03813
编写于
12月 10, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
window - have a getter for window being focused or not
上级
b368859a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
12 deletion
+25
-12
src/vs/platform/windows/common/windows.ts
src/vs/platform/windows/common/windows.ts
+4
-2
src/vs/platform/windows/electron-browser/windowService.ts
src/vs/platform/windows/electron-browser/windowService.ts
+11
-1
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
...kbench/browser/parts/notifications/notificationsToasts.ts
+1
-7
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+7
-2
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+2
-0
未找到文件。
src/vs/platform/windows/common/windows.ts
浏览文件 @
7fa03813
...
...
@@ -183,8 +183,10 @@ export interface IWindowService {
_serviceBrand
:
any
;
onDidChangeFocus
:
Event
<
boolean
>
;
onDidChangeMaximize
:
Event
<
boolean
>
;
readonly
onDidChangeFocus
:
Event
<
boolean
>
;
readonly
onDidChangeMaximize
:
Event
<
boolean
>
;
readonly
hasFocus
:
boolean
;
getConfiguration
():
IWindowConfiguration
;
getCurrentWindowId
():
number
;
...
...
src/vs/platform/windows/electron-browser/windowService.ts
浏览文件 @
7fa03813
...
...
@@ -11,25 +11,35 @@ import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import
{
IWorkspaceFolderCreationData
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
WindowService
implements
IWindowService
{
export
class
WindowService
extends
Disposable
implements
IWindowService
{
readonly
onDidChangeFocus
:
Event
<
boolean
>
;
readonly
onDidChangeMaximize
:
Event
<
boolean
>
;
_serviceBrand
:
any
;
private
_hasFocus
:
boolean
;
get
hasFocus
():
boolean
{
return
this
.
_hasFocus
;
}
constructor
(
private
windowId
:
number
,
private
configuration
:
IWindowConfiguration
,
@
IWindowsService
private
windowsService
:
IWindowsService
)
{
super
();
const
onThisWindowFocus
=
mapEvent
(
filterEvent
(
windowsService
.
onWindowFocus
,
id
=>
id
===
windowId
),
_
=>
true
);
const
onThisWindowBlur
=
mapEvent
(
filterEvent
(
windowsService
.
onWindowBlur
,
id
=>
id
===
windowId
),
_
=>
false
);
const
onThisWindowMaximize
=
mapEvent
(
filterEvent
(
windowsService
.
onWindowMaximize
,
id
=>
id
===
windowId
),
_
=>
true
);
const
onThisWindowUnmaximize
=
mapEvent
(
filterEvent
(
windowsService
.
onWindowUnmaximize
,
id
=>
id
===
windowId
),
_
=>
false
);
this
.
onDidChangeFocus
=
anyEvent
(
onThisWindowFocus
,
onThisWindowBlur
);
this
.
onDidChangeMaximize
=
anyEvent
(
onThisWindowMaximize
,
onThisWindowUnmaximize
);
this
.
_hasFocus
=
document
.
hasFocus
();
this
.
isFocused
().
then
(
focused
=>
this
.
_hasFocus
=
focused
);
this
.
_register
(
this
.
onDidChangeFocus
(
focus
=>
this
.
_hasFocus
=
focus
));
}
getCurrentWindowId
():
number
{
...
...
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
浏览文件 @
7fa03813
...
...
@@ -54,7 +54,6 @@ export class NotificationsToasts extends Themable {
private
notificationsToastsContainer
:
HTMLElement
;
private
workbenchDimensions
:
Dimension
;
private
windowHasFocus
:
boolean
;
private
isNotificationsCenterVisible
:
boolean
;
private
mapNotificationToToast
:
Map
<
INotificationViewItem
,
INotificationToast
>
;
private
notificationsToastsVisibleContextKey
:
IContextKey
<
boolean
>
;
...
...
@@ -75,8 +74,6 @@ export class NotificationsToasts extends Themable {
this
.
mapNotificationToToast
=
new
Map
<
INotificationViewItem
,
INotificationToast
>
();
this
.
notificationsToastsVisibleContextKey
=
NotificationsToastsVisibleContext
.
bindTo
(
contextKeyService
);
this
.
windowService
.
isFocused
().
then
(
isFocused
=>
this
.
windowHasFocus
=
isFocused
);
this
.
registerListeners
();
}
...
...
@@ -91,9 +88,6 @@ export class NotificationsToasts extends Themable {
// Update toasts on notification changes
this
.
_register
(
this
.
model
.
onDidNotificationChange
(
e
=>
this
.
onDidNotificationChange
(
e
)));
});
// Track window focus
this
.
windowService
.
onDidChangeFocus
(
hasFocus
=>
this
.
windowHasFocus
=
hasFocus
);
}
private
onCanShowNotifications
():
Thenable
<
void
>
{
...
...
@@ -241,7 +235,7 @@ export class NotificationsToasts extends Themable {
// the timeout again. This prevents an issue where focussing the window
// could immediately hide the notification because the timeout was triggered
// again.
if
((
item
.
sticky
||
item
.
hasPrompt
())
&&
!
this
.
window
H
asFocus
)
{
if
((
item
.
sticky
||
item
.
hasPrompt
())
&&
!
this
.
window
Service
.
h
asFocus
)
{
if
(
!
listener
)
{
listener
=
this
.
windowService
.
onDidChangeFocus
(
focus
=>
{
if
(
focus
)
{
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
7fa03813
...
...
@@ -37,6 +37,7 @@ import { CachedKeyboardMapper, IKeyboardMapper } from 'vs/workbench/services/key
import
{
MacLinuxFallbackKeyboardMapper
}
from
'
vs/workbench/services/keybinding/common/macLinuxFallbackKeyboardMapper
'
;
import
{
IMacLinuxKeyboardMapping
,
MacLinuxKeyboardMapper
,
macLinuxKeyboardMappingEquals
}
from
'
vs/workbench/services/keybinding/common/macLinuxKeyboardMapper
'
;
import
{
IWindowsKeyboardMapping
,
WindowsKeyboardMapper
,
windowsKeyboardMappingEquals
}
from
'
vs/workbench/services/keybinding/common/windowsKeyboardMapper
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
export
class
KeyboardMapperFactory
{
public
static
readonly
INSTANCE
=
new
KeyboardMapperFactory
();
...
...
@@ -266,7 +267,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
@
INotificationService
notificationService
:
INotificationService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IStatusbarService
statusBarService
:
IStatusbarService
,
@
IConfigurationService
configurationService
:
IConfigurationService
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IWindowService
private
windowService
:
IWindowService
)
{
super
(
contextKeyService
,
commandService
,
telemetryService
,
notificationService
,
statusBarService
);
...
...
@@ -367,7 +369,10 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}
protected
_documentHasFocus
():
boolean
{
return
document
.
hasFocus
();
// it is possible that the document has lost focus, but the
// window is still focused, e.g. when a <webview> element
// has focus
return
this
.
windowService
.
hasFocus
;
}
private
_resolveKeybindingItems
(
items
:
IKeybindingItem
[],
isDefault
:
boolean
):
ResolvedKeybindingItem
[]
{
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
7fa03813
...
...
@@ -1002,6 +1002,8 @@ export class TestWindowService implements IWindowService {
onDidChangeFocus
:
Event
<
boolean
>
=
new
Emitter
<
boolean
>
().
event
;
onDidChangeMaximize
:
Event
<
boolean
>
;
hasFocus
=
true
;
isFocused
():
TPromise
<
boolean
>
{
return
TPromise
.
as
(
false
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录