提交 13528a2a 编写于 作者: yanghye's avatar yanghye

v2.3.26 Fixed Chinese input and gtk3 issues for linux packagin,

And Windows Drag Region
上级 f908c6d1
......@@ -169,7 +169,7 @@ func (m *browserWindow) OnFormCreate(sender lcl.IObject) {
BrowserWindow.browserEvent.chromium = m.chromium
BrowserWindow.Config.browserWindowOnEventCallback(BrowserWindow.browserEvent, &m.LCLBrowserWindow)
}
//browserWindowOnEventCallback 执行完后,注册windows消息事件
//browserWindowOnEventCallback 执行完后,注册CompMsgEvent
m.registerWindowsCompMsgEvent()
//主进程(主窗口)启动后回调函数事件
......
......@@ -38,31 +38,31 @@ type IBaseWindow interface {
//
//该窗口使用CEF和LCL组件实现,CEF<=1.106.xx版本 在windows、MacOSX可正常使用, Linux无法输入中文, CEF>=2.107.xx版本linux强制使用 ViewsFrameworkBrowserWindow 窗口组件
type LCLBrowserWindow struct {
*lcl.TForm //
chromium IChromium //
browser *ICefBrowser //
windowParent ITCefWindowParent //
windowProperty *WindowProperty //
windowId int32 //
windowType consts.WINDOW_TYPE //窗口类型
isClosing bool //
canClose bool //
onResize TNotifyEvent //
onActivate TNotifyEvent //
onShow TNotifyEvent //
onClose TCloseEvent //
onCloseQuery TCloseQueryEvent //
onActivateAfter lcl.TNotifyEvent //
onConstrainedResizeEvent lcl.TConstrainedResizeEvent //
isFormCreate bool //是否创建完成 WindowForm
isChromiumCreate bool //是否创建完成 Chromium
frames TCEFFrame //当前浏览器下的所有frame
auxTools *auxTools //辅助工具
tray ITray //托盘
regions *TCefDraggableRegions //窗口内html拖拽区域
rgn *HRGN //
hWnd types.HWND //
windowsState types.TWindowState //
*lcl.TForm //
chromium IChromium //
browser *ICefBrowser //
windowParent ITCefWindowParent //
windowProperty *WindowProperty //
windowId int32 //
windowType consts.WINDOW_TYPE //窗口类型
isClosing bool //
canClose bool //
onResize TNotifyEvent //
onActivate TNotifyEvent //
onShow TNotifyEvent //
onPaint TNotifyEvent //
onClose TCloseEvent //
onCloseQuery TCloseQueryEvent //
onActivateAfter lcl.TNotifyEvent //
isFormCreate bool //是否创建完成 WindowForm
isChromiumCreate bool //是否创建完成 Chromium
frames TCEFFrame //当前浏览器下的所有frame
auxTools *auxTools //辅助工具
tray ITray //托盘
regions *TCefDraggableRegions //窗口内html拖拽区域
rgn *HRGN //
hWnd types.HWND //
windowsState types.TWindowState //
}
//创建一个 LCL 带有 chromium 窗口
......@@ -470,27 +470,32 @@ func (m *LCLBrowserWindow) EnableAllDefaultEvent() {
m.defaultChromiumEvent()
}
// 添加OnResize事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
// SetOnPaint 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnPaint(fn TNotifyEvent) {
m.onPaint = fn
}
// SetOnResize 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnResize(fn TNotifyEvent) {
m.onResize = fn
}
// 添加OnActivate事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
// SetOnActivate 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnActivate(fn TNotifyEvent) {
m.onActivate = fn
}
// 添加OnShow事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
// SetOnShow 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnShow(fn TNotifyEvent) {
m.onShow = fn
}
// 添加OnClose事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
// SetOnClose 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnClose(fn TCloseEvent) {
m.onClose = fn
}
// 添加OnCloseQuery事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
// SetOnCloseQuery 事件,不会覆盖默认事件,返回值:false继续执行默认事件, true跳过默认事件
func (m *LCLBrowserWindow) SetOnCloseQuery(fn TCloseQueryEvent) {
m.onCloseQuery = fn
}
......@@ -720,10 +725,6 @@ func (m *LCLBrowserWindow) show(sender lcl.IObject) {
}
}
func (m *LCLBrowserWindow) SetOnConstrainedResize(fn lcl.TConstrainedResizeEvent) {
m.onConstrainedResizeEvent = fn
}
func (m *LCLBrowserWindow) resize(sender lcl.IObject) {
var ret bool
if m.onResize != nil {
......
......@@ -24,12 +24,14 @@ var ov = version.OSVersion
//显示标题栏
func (m *LCLBrowserWindow) ShowTitle() {
m.WindowProperty()._CanHideCaption = false
win.SetWindowLong(m.Handle(), win.GWL_STYLE, uintptr(win.GetWindowLong(m.Handle(), win.GWL_STYLE)|win.WS_CAPTION))
win.SetWindowPos(m.Handle(), m.Handle(), 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED)
}
//隐藏标题栏
func (m *LCLBrowserWindow) HideTitle() {
m.WindowProperty()._CanHideCaption = true
win.SetWindowLong(m.Handle(), win.GWL_STYLE, uintptr(win.GetWindowLong(m.Handle(), win.GWL_STYLE)&^win.WS_CAPTION))
win.SetWindowPos(m.Handle(), m.Handle(), 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED)
}
......@@ -65,7 +67,7 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
fmt.Println("l up", wdrs.canCaption)
case WM_NCLBUTTONDBLCLK: /*-- NC --*/
if !m.WindowProperty().CanCaptionDClkMaximize {
break
return
}
fmt.Println("nc ld click", m.windowsState, m.WindowState())
if m.rgn != nil && wdrs.canCaption {
......@@ -85,7 +87,6 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
rtl.SendMessage(m.Handle(), WM_SYSCOMMAND, SC_RESTORE, 0)
}
rtl.SendMessage(m.Handle(), WM_NCLBUTTONUP, 0, 0)
return
}
case WM_NCLBUTTONDOWN:
fmt.Println("nc l down", wdrs.canCaption)
......@@ -95,20 +96,21 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
win.ReleaseCapture()
rtl.PostMessage(m.Handle(), WM_NCLBUTTONDOWN, HTCAPTION, 0)
rtl.SendMessage(m.Handle(), WM_NCLBUTTONUP, 0, 0)
return
}
case WM_NCLBUTTONUP:
fmt.Println("nc l up", wdrs.canCaption)
if m.rgn != nil && wdrs.canCaption {
//WinDefWindowProc(m.Handle(), message.Msg, message.WParam, message.LParam)
*lResult = HTCAPTION
*aHandled = true
return
}
case WM_NCRBUTTONDOWN:
fmt.Println("nc r down", wdrs.canCaption)
if m.rgn != nil && wdrs.canCaption {
}
case WM_NCRBUTTONUP:
fmt.Println("nc r up", wdrs.canCaption)
if m.rgn != nil && wdrs.canCaption {
*lResult = HTCAPTION
*aHandled = true
}
case WM_NCHITTEST: /*-- NCHITTEST --*/
if m.rgn != nil {
_, _, caption := wdrs.isCaption(m.Handle(), m.rgn, message)
......@@ -118,14 +120,13 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
//如果光标在一个可拖动区域内,返回HTCAPTION允许拖动。
*lResult = HTCAPTION
*aHandled = true
return
}
}
}
}
}
// 默认事件注册 windows 消息事件
// 默认事件注册 windows CompMsgEvent
func (m *LCLBrowserWindow) registerWindowsCompMsgEvent() {
var bwEvent = BrowserWindow.browserEvent
if m.WindowProperty().CanWebkitAppRegion {
......@@ -137,23 +138,30 @@ func (m *LCLBrowserWindow) registerWindowsCompMsgEvent() {
m.doOnRenderCompMsg(message, lResult, aHandled)
}
})
m.TForm.SetOnConstrainedResize(func(sender lcl.IObject, minWidth, minHeight, maxWidth, maxHeight *int32) {
//m.windowsState = m.WindowState()
if m.onConstrainedResizeEvent != nil {
m.onConstrainedResizeEvent(sender, minWidth, minHeight, maxWidth, maxHeight)
}
})
m.TForm.SetOnPaint(func(sender lcl.IObject) {
fmt.Println("OnPaint", m.WindowState()) //TODO test
//m.chromium.NotifyMoveOrResizeStarted()
//m.windowParent.UpdateSize()
var ret bool
if m.onPaint != nil {
ret = m.onPaint(sender)
}
if !ret {
if m.WindowState() == types.WsMaximized && m.WindowProperty()._CanHideCaption {
var monitor = m.Monitor().WorkareaRect()
m.SetBounds(monitor.Left, monitor.Top, monitor.Right-monitor.Left, monitor.Bottom-monitor.Top)
m.SetWindowState(types.WsMaximized)
//rtl.PostMessage(m.Handle(), WM_NCLBUTTONDOWN, HTCAPTION, 0) //WM_PAINT
}
}
})
} else {
if bwEvent.onRenderCompMsg != nil {
m.chromium.SetOnRenderCompMsg(bwEvent.onRenderCompMsg)
}
if m.onConstrainedResizeEvent != nil {
m.TForm.SetOnConstrainedResize(m.onConstrainedResizeEvent)
if m.onPaint != nil {
m.TForm.SetOnPaint(func(sender lcl.IObject) {
m.onPaint(sender)
})
}
}
}
......@@ -17,6 +17,7 @@ import (
//显示标题栏
func (m *ViewsFrameworkBrowserWindow) ShowTitle() {
m.WindowProperty()._CanHideCaption = false
handle := m.WindowComponent().WindowHandle()
win.SetWindowLong(handle.ToPtr(), win.GWL_STYLE, uintptr(win.GetWindowLong(handle.ToPtr(), win.GWL_STYLE)|win.WS_CAPTION))
win.SetWindowPos(handle.ToPtr(), 0, 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED)
......@@ -24,6 +25,7 @@ func (m *ViewsFrameworkBrowserWindow) ShowTitle() {
//隐藏标题栏
func (m *ViewsFrameworkBrowserWindow) HideTitle() {
m.WindowProperty()._CanHideCaption = true
handle := m.WindowComponent().WindowHandle()
win.SetWindowLong(handle.ToPtr(), win.GWL_STYLE, uintptr(win.GetWindowLong(handle.ToPtr(), win.GWL_STYLE)&^win.WS_CAPTION))
win.SetWindowPos(handle.ToPtr(), 0, 0, 0, 0, 0, win.SWP_NOSIZE|win.SWP_NOMOVE|win.SWP_NOZORDER|win.SWP_NOACTIVATE|win.SWP_FRAMECHANGED)
......
......@@ -30,6 +30,8 @@ type auxTools struct {
}
//窗口属性配置器
//
//部分属性配置并不支持所有平台
type WindowProperty struct {
IsShowModel bool //是否以模态窗口显示
WindowState types.TWindowState //窗口 状态
......@@ -37,6 +39,7 @@ type WindowProperty struct {
Url string //默认打开URL
Icon string //窗口图标 加载本地图标 local > /app/resources/icon.ico
IconFS string //窗口图标 加载emfs内置图标 emfs > resources/icon.ico
_CanHideCaption bool //窗口 是否隐藏标题栏
CanMinimize bool //窗口 是否启用最小化 default: true
CanMaximize bool //窗口 是否启用最大化 default: true
CanResize bool //窗口 是否允许调整大小 default: true
......
......@@ -6,18 +6,6 @@
<style>
</style>
<script type="application/javascript">
function divMnmousedown(e) {
windowDrag.mousedown(e.clientX, e.clientY);
document.onmousemove = function (e) {
e.preventDefault()
windowDrag.mousemove(e.clientX, e.clientY);
}
document.onmouseup = function () {
windowDrag.mouseup();
document.onmousemove = null;
document.onmouseup = null;
};
}
</script>
</head>
<body style="overflow: hidden;margin: 0px;padding: 0px;">
......@@ -29,10 +17,7 @@
<span href="javascript:void(0)" target="_blank">新窗口百度-此处点不到</span>&nbsp;
<a href="https://www.baidu.com" style="-webkit-app-region:no-drag">百度</a>&nbsp;
<a href="/" target="_blank" style="-webkit-app-region:no-drag">新窗口</a>
<div style="position: absolute;width: 100px;height: 100px;-webkit-app-region: drag; border: 1px solid red;left: 0;top: 0;"></div>
<div style="position: absolute;width: 200px;height: 100px;border: 1px solid red;left: 100px;top: 100px;" onmousedown="divMnmousedown(event)">
这里是鼠标事件onmousedown="onmousedown(event)"
</div>
<div style="position: absolute;width: 100px;height: 100px;-webkit-app-region: drag; border: 1px solid red;left: 0;top: 30px;"></div>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册