Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
43deb13e
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
43deb13e
编写于
7月 23, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
U: window state
A: default window attribute configuration
上级
5bd100bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
92 addition
and
14 deletion
+92
-14
cef/browser-window-drag_windows.go
cef/browser-window-drag_windows.go
+21
-6
cef/browser-window-lcl.go
cef/browser-window-lcl.go
+40
-3
cef/browser-window-lcl_windows.go
cef/browser-window-lcl_windows.go
+24
-5
cef/browser-window.go
cef/browser-window.go
+7
-0
未找到文件。
cef/browser-window-drag_windows.go
浏览文件 @
43deb13e
...
...
@@ -38,7 +38,16 @@ func dragExtensionHandler() {
}
energyExtensionHandler
:=
V8HandlerRef
.
New
()
energyExtensionHandler
.
Execute
(
func
(
name
string
,
object
*
ICefV8Value
,
arguments
*
TCefV8ValueArray
,
retVal
*
ResultV8Value
,
exception
*
ResultString
)
bool
{
if
name
==
mouseUp
||
name
==
mouseDown
{
if
name
==
mouseDown
{
return
true
}
else
if
name
==
mouseUp
{
message
:=
&
ipcArgument
.
List
{
Id
:
-
1
,
BId
:
ipc
.
RenderChan
()
.
BrowserId
(),
Name
:
internalIPCDRAG
,
Data
:
&
drag
{
T
:
dragUp
},
}
ipc
.
RenderChan
()
.
IPC
()
.
Send
(
message
.
Bytes
())
return
true
}
else
if
name
==
mouseMove
{
message
:=
&
ipcArgument
.
List
{
...
...
@@ -85,13 +94,15 @@ func dragExtensionHandler() {
mouseMove();
}
energyExtension.drag.mouseUp = function (e) {
if (!energyExtension.drag.enableDrag
|| !energyExtension.drag.shouldDrag
) {
if (!energyExtension.drag.enableDrag) {
return
}
energyExtension.drag.shouldDrag = false;
//document.body.style.cursor = "default";
native function mouseUp();
mouseUp();
if (energyExtension.drag.war(e)) {
e.preventDefault();
native function mouseUp();
mouseUp();
}
}
energyExtension.drag.mouseDown = function (e) {
if (!energyExtension.drag.enableDrag || ((e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight))) {
...
...
@@ -123,5 +134,9 @@ func dragExtensionHandler() {
}
func
(
m
*
drag
)
drag
()
{
if
m
.
T
==
dragUp
{
if
m
.
window
.
IsLCL
()
{
m
.
window
.
AsLCLBrowserWindow
()
.
BrowserWindow
()
.
cwcap
.
canCaption
=
false
}
}
}
cef/browser-window-lcl.go
浏览文件 @
43deb13e
...
...
@@ -114,7 +114,7 @@ func (m *LCLBrowserWindow) setProperty() {
}
if
wp
.
EnableCenterWindow
{
m
.
SetSize
(
wp
.
Width
,
wp
.
Height
)
m
.
Set
Position
(
types
.
PoDesktopCenter
)
// TODO 多显示器时有bug
m
.
Set
CenterWindow
(
true
)
}
else
{
m
.
SetPosition
(
types
.
PoDesigned
)
m
.
SetBounds
(
wp
.
X
,
wp
.
Y
,
wp
.
Width
,
wp
.
Height
)
...
...
@@ -148,10 +148,33 @@ func (m *LCLBrowserWindow) setProperty() {
}
// 只有隐藏窗口标题时才全屏 TODO 拖拽时的问题不还原窗口
if
wp
.
EnableHideCaption
&&
wp
.
WindowInitState
==
types
.
WsFullScreen
{
m
.
SetBoundsRect
(
m
.
Monitor
()
.
BoundsRect
()
)
m
.
FullScreen
(
)
}
else
{
m
.
SetWindowState
(
wp
.
WindowInitState
)
}
// 当前窗口状态
m
.
setCurrentProperty
()
}
// FullScreen 窗口全屏
func
(
m
*
LCLBrowserWindow
)
FullScreen
()
bool
{
if
m
.
WindowProperty
()
.
EnableHideCaption
{
m
.
WindowProperty
()
.
current
.
ws
=
types
.
WsFullScreen
m
.
setCurrentProperty
()
m
.
SetBoundsRect
(
m
.
Monitor
()
.
BoundsRect
())
return
true
}
return
false
}
// ExitFullScreen 窗口退出全屏
func
(
m
*
LCLBrowserWindow
)
ExitFullScreen
()
{
wp
:=
m
.
WindowProperty
()
if
wp
.
EnableHideCaption
&&
wp
.
current
.
ws
==
types
.
WsFullScreen
{
wp
.
current
.
ws
=
types
.
WsNormal
m
.
SetWindowState
(
types
.
WsNormal
)
m
.
SetBounds
(
wp
.
current
.
x
,
wp
.
current
.
y
,
wp
.
current
.
w
,
wp
.
current
.
h
)
}
}
// Handle 窗口句柄
...
...
@@ -191,7 +214,7 @@ func (m *LCLBrowserWindow) AsLCLBrowserWindow() ILCLBrowserWindow {
return
m
}
// SetCenterWindow 窗口居中
// SetCenterWindow 窗口居中
// TODO 多显示器时有bug
func
(
m
*
LCLBrowserWindow
)
SetCenterWindow
(
value
bool
)
{
if
m
.
TForm
==
nil
{
return
...
...
@@ -728,6 +751,7 @@ func (m *LCLBrowserWindow) resize(sender lcl.IObject) {
if
m
.
isClosing
{
return
}
m
.
setCurrentProperty
()
if
m
.
windowResize
!=
nil
{
m
.
windowResize
(
sender
)
}
...
...
@@ -740,6 +764,18 @@ func (m *LCLBrowserWindow) resize(sender lcl.IObject) {
}
}
// 在窗口坐标、大小、全屏时保存当前窗口属性
func
(
m
*
LCLBrowserWindow
)
setCurrentProperty
()
{
if
m
.
WindowProperty
()
.
current
.
ws
==
types
.
WsFullScreen
{
return
}
boundRect
:=
m
.
BoundsRect
()
m
.
WindowProperty
()
.
current
.
x
=
boundRect
.
Left
m
.
WindowProperty
()
.
current
.
y
=
boundRect
.
Top
m
.
WindowProperty
()
.
current
.
w
=
boundRect
.
Width
()
m
.
WindowProperty
()
.
current
.
h
=
boundRect
.
Height
()
}
// activate 内部调用
func
(
m
*
LCLBrowserWindow
)
activate
(
sender
lcl
.
IObject
)
{
var
ret
bool
...
...
@@ -1079,6 +1115,7 @@ func (m *LCLBrowserWindow) onFormMessages() {
}
})
m
.
setOnWMMove
(
func
(
message
*
t
.
TMove
)
{
m
.
setCurrentProperty
()
if
m
.
Chromium
()
!=
nil
{
m
.
Chromium
()
.
NotifyMoveOrResizeStarted
()
}
...
...
cef/browser-window-lcl_windows.go
浏览文件 @
43deb13e
...
...
@@ -180,18 +180,22 @@ func (m *customWindowCaption) onCanBorder(x, y int32, rect *types.TRect) (int, b
// onNCLButtonDown NC 鼠标左键按下
func
(
m
*
customWindowCaption
)
onNCLButtonDown
(
hWND
types
.
HWND
,
message
*
types
.
TMessage
,
lResult
*
types
.
LRESULT
,
aHandled
*
bool
)
{
if
m
.
canCaption
{
// 标题栏
x
,
y
:=
m
.
toPoint
(
message
)
*
lResult
=
messages
.
HTCAPTION
m
.
borderMD
=
true
*
aHandled
=
true
//全屏时不能移动窗口
if
m
.
bw
.
WindowProperty
()
.
current
.
ws
==
types
.
WsFullScreen
{
return
}
x
,
y
:=
m
.
toPoint
(
message
)
m
.
borderMD
=
true
if
win
.
ReleaseCapture
()
{
win
.
PostMessage
(
hWND
,
messages
.
WM_NCLBUTTONDOWN
,
messages
.
HTCAPTION
,
rtl
.
MakeLParam
(
uint16
(
x
),
uint16
(
y
)))
}
}
else
if
m
.
canBorder
{
// 边框
x
,
y
:=
m
.
toPoint
(
message
)
*
lResult
=
types
.
LRESULT
(
m
.
borderHT
)
m
.
borderMD
=
true
*
aHandled
=
true
m
.
borderMD
=
true
if
win
.
ReleaseCapture
()
{
win
.
PostMessage
(
hWND
,
messages
.
WM_SYSCOMMAND
,
uintptr
(
messages
.
SC_SIZE
|
m
.
borderWMSZ
),
rtl
.
MakeLParam
(
uint16
(
x
),
uint16
(
y
)))
}
...
...
@@ -263,6 +267,10 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
*
lResult
=
messages
.
HTCAPTION
*
aHandled
=
true
}
else
if
m
.
WindowProperty
()
.
EnableHideCaption
&&
m
.
WindowProperty
()
.
EnableResize
&&
m
.
WindowState
()
==
types
.
WsNormal
{
//1.窗口隐藏标题栏 2.启用了调整窗口大小 3.非最大化、最小化、全屏状态
//全屏时不能调整窗口大小
if
m
.
WindowProperty
()
.
current
.
ws
==
types
.
WsFullScreen
{
return
}
rect
:=
m
.
BoundsRect
()
if
result
,
handled
:=
m
.
cwcap
.
onCanBorder
(
x
,
y
,
&
rect
);
handled
{
*
lResult
=
types
.
LRESULT
(
result
)
...
...
@@ -362,7 +370,18 @@ func (m *LCLBrowserWindow) Maximize() {
func
(
m
*
LCLBrowserWindow
)
doDrag
()
{
// Windows Drag Window
if
win
.
ReleaseCapture
()
{
win
.
PostMessage
(
m
.
Handle
(),
messages
.
WM_NCLBUTTONDOWN
,
messages
.
HTCAPTION
,
0
)
// m.drag != nil 时,这里处理的是 up 事件, 给标题栏标记为false
if
m
.
drag
!=
nil
{
m
.
drag
.
drag
()
}
else
{
// 全屏时不能拖拽窗口
if
m
.
WindowProperty
()
.
current
.
ws
==
types
.
WsFullScreen
{
return
}
// 此时是 down 事件, 拖拽窗口
if
win
.
ReleaseCapture
()
{
win
.
PostMessage
(
m
.
Handle
(),
messages
.
WM_NCLBUTTONDOWN
,
messages
.
HTCAPTION
,
0
)
m
.
cwcap
.
canCaption
=
true
}
}
}
cef/browser-window.go
浏览文件 @
43deb13e
...
...
@@ -25,6 +25,12 @@ type auxTools struct {
viewSourceWindow
IBrowserWindow
//viewSource
}
// 窗口当前属性
type
windowCurrentProperty
struct
{
ws
types
.
TWindowState
x
,
y
,
w
,
h
int32
}
// WindowProperty
// 提供部分窗口属性配置,初始化时生效
// 如需更多属性配置或自定义窗口行为请在`SetBrowserInit`回调函数中使用
...
...
@@ -52,6 +58,7 @@ type WindowProperty struct {
MinHeight
types
.
TConstraintSize
// 窗口 最小高, EnableResize = true 与 MinWidth > 0 生效
MaxWidth
types
.
TConstraintSize
// 窗口 最大宽, EnableResize = true 与 MaxHeight > 0 生效
MaxHeight
types
.
TConstraintSize
// 窗口 最大高, EnableResize = true 与 MaxWidth > 0 生效
current
windowCurrentProperty
// 窗口 当前属性
}
// IBrowserWindow
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录