mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 10:47:57 +08:00
v2.3.36 Fixed Chinese input and gtk3 issues for linux packagin,
And Windows Drag Region
This commit is contained in:
parent
1847ebc4e5
commit
f4b36bedf5
@ -112,6 +112,7 @@ func (m *browserWindow) OnFormCreate(sender lcl.IObject) {
|
||||
}
|
||||
}
|
||||
})
|
||||
m.cwcap = new(customWindowCaption)
|
||||
}
|
||||
|
||||
func (m *browser) MainWindow() IBrowserWindow {
|
||||
|
@ -38,31 +38,30 @@ 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 //
|
||||
windowResize TNotifyEvent //
|
||||
onActivate TNotifyEvent //
|
||||
onShow 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.TForm //
|
||||
chromium IChromium //
|
||||
browser *ICefBrowser //
|
||||
windowParent ITCefWindowParent //
|
||||
windowProperty *WindowProperty //
|
||||
windowId int32 //
|
||||
windowType consts.WINDOW_TYPE //窗口类型
|
||||
isClosing bool //
|
||||
canClose bool //
|
||||
onResize TNotifyEvent //
|
||||
windowResize TNotifyEvent //
|
||||
onActivate TNotifyEvent //
|
||||
onShow TNotifyEvent //
|
||||
onClose TCloseEvent //
|
||||
onCloseQuery TCloseQueryEvent //
|
||||
onActivateAfter lcl.TNotifyEvent //
|
||||
isFormCreate bool //是否创建完成 WindowForm
|
||||
isChromiumCreate bool //是否创建完成 Chromium
|
||||
frames TCEFFrame //当前浏览器下的所有frame
|
||||
auxTools *auxTools //辅助工具
|
||||
tray ITray //托盘
|
||||
hWnd types.HWND //
|
||||
windowsState types.TWindowState //
|
||||
cwcap *customWindowCaption //自定义窗口标题栏
|
||||
}
|
||||
|
||||
//创建一个 LCL 带有 chromium 窗口
|
||||
@ -96,6 +95,7 @@ func NewLCLWindow(windowProperty *WindowProperty, owner ...lcl.IComponent) *LCLB
|
||||
//lcl.Application.CreateForm(&window)
|
||||
}
|
||||
window.windowProperty = windowProperty
|
||||
window.cwcap = new(customWindowCaption)
|
||||
window.SetDoubleBuffered(true)
|
||||
window.FormCreate()
|
||||
window.SetShowInTaskBar()
|
||||
@ -862,7 +862,7 @@ func (m *LCLBrowserWindow) registerDefaultEvent() {
|
||||
if bwEvent.onDraggableRegionsChanged != nil {
|
||||
bwEvent.onDraggableRegionsChanged(sender, browser, frame, regions)
|
||||
}
|
||||
m.regions = regions
|
||||
m.cwcap.regions = regions
|
||||
m.setDraggableRegions()
|
||||
})
|
||||
}
|
||||
@ -935,6 +935,7 @@ func (m *LCLBrowserWindow) registerDefaultChromiumCloseEvent() {
|
||||
logger.Debug("chromium.onClose => windowParent.Free")
|
||||
})
|
||||
}
|
||||
m.cwcap.free()
|
||||
if bwEvent.onClose != nil {
|
||||
bwEvent.onClose(sender, browser, aAction)
|
||||
}
|
||||
|
@ -44,19 +44,38 @@ func (m *LCLBrowserWindow) HideTitle() {
|
||||
|
||||
}
|
||||
|
||||
//windows 窗口标题栏管理
|
||||
var wdrs = &windowCaption{}
|
||||
|
||||
type windowCaption struct {
|
||||
canCaption bool
|
||||
type customWindowCaption struct {
|
||||
canCaption bool //当前鼠标是否在标题栏区域
|
||||
regions *TCefDraggableRegions //窗口内html拖拽区域
|
||||
rgn *HRGN //
|
||||
}
|
||||
|
||||
func (m *windowCaption) toPoint(message *types.TMessage) (x, y int32) {
|
||||
func (m *customWindowCaption) freeRgn() {
|
||||
if m.rgn != nil {
|
||||
WinSetRectRgn(m.rgn, 0, 0, 0, 0)
|
||||
WinDeleteObject(m.rgn)
|
||||
m.rgn.Free()
|
||||
}
|
||||
}
|
||||
func (m *customWindowCaption) freeRegions() {
|
||||
if m.regions != nil {
|
||||
m.regions.regions = nil
|
||||
m.regions = nil
|
||||
}
|
||||
}
|
||||
func (m *customWindowCaption) free() {
|
||||
if m != nil {
|
||||
m.freeRgn()
|
||||
m.freeRegions()
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customWindowCaption) toPoint(message *types.TMessage) (x, y int32) {
|
||||
return int32(message.LParam & 0xFFFF), int32(message.LParam & 0xFFFF0000 >> 16)
|
||||
}
|
||||
|
||||
//鼠标在标题栏区域
|
||||
func (m *windowCaption) isCaption(hWND types.HWND, rgn *HRGN, message *types.TMessage) (x, y int32, caption bool) {
|
||||
func (m *customWindowCaption) isCaption(hWND types.HWND, rgn *HRGN, message *types.TMessage) (x, y int32, caption bool) {
|
||||
dx, dy := m.toPoint(message)
|
||||
p := &types.TPoint{
|
||||
X: dx,
|
||||
@ -68,13 +87,13 @@ func (m *windowCaption) isCaption(hWND types.HWND, rgn *HRGN, message *types.TMe
|
||||
}
|
||||
|
||||
func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
|
||||
if m.regions != nil && m.regions.RegionsCount() > 0 {
|
||||
if m.cwcap.regions != nil && m.cwcap.regions.RegionsCount() > 0 {
|
||||
switch message.Msg {
|
||||
case WM_NCLBUTTONDBLCLK: /*-- NC l d click --*/
|
||||
if !m.WindowProperty().CanCaptionDClkMaximize {
|
||||
return
|
||||
}
|
||||
if m.rgn != nil && wdrs.canCaption {
|
||||
if m.cwcap.rgn != nil && m.cwcap.canCaption {
|
||||
//SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); // 最大化
|
||||
//SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); // 最小化
|
||||
//SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); // 关闭
|
||||
@ -91,28 +110,28 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
|
||||
rtl.SendMessage(m.Handle(), WM_NCLBUTTONUP, HTCAPTION, 0)
|
||||
}
|
||||
case WM_NCLBUTTONDOWN: //nc l down
|
||||
if m.rgn != nil && wdrs.canCaption {
|
||||
if m.cwcap.rgn != nil && m.cwcap.canCaption {
|
||||
*lResult = HTCAPTION
|
||||
*aHandled = true
|
||||
win.ReleaseCapture()
|
||||
rtl.PostMessage(m.Handle(), WM_NCLBUTTONDOWN, HTCAPTION, 0)
|
||||
}
|
||||
case WM_NCLBUTTONUP: //nc l up
|
||||
if m.rgn != nil && wdrs.canCaption {
|
||||
if m.cwcap.rgn != nil && m.cwcap.canCaption {
|
||||
*lResult = HTCAPTION
|
||||
*aHandled = true
|
||||
}
|
||||
case WM_NCRBUTTONDOWN: //nc r down
|
||||
if m.rgn != nil && wdrs.canCaption {
|
||||
if m.cwcap.rgn != nil && m.cwcap.canCaption {
|
||||
}
|
||||
case WM_NCRBUTTONUP: //nc r up
|
||||
if m.rgn != nil && wdrs.canCaption {
|
||||
if m.cwcap.rgn != nil && m.cwcap.canCaption {
|
||||
}
|
||||
case WM_NCHITTEST: /*-- NCHITTEST --*/
|
||||
if m.rgn != nil {
|
||||
_, _, caption := wdrs.isCaption(m.Handle(), m.rgn, message)
|
||||
if m.cwcap.rgn != nil {
|
||||
_, _, caption := m.cwcap.isCaption(m.Handle(), m.cwcap.rgn, message)
|
||||
//设置鼠标坐标是否在标题区域
|
||||
wdrs.canCaption = caption
|
||||
m.cwcap.canCaption = caption
|
||||
if caption {
|
||||
//如果光标在一个可拖动区域内,返回HTCAPTION允许拖动。
|
||||
*lResult = HTCAPTION
|
||||
@ -124,13 +143,10 @@ func (m *LCLBrowserWindow) doOnRenderCompMsg(message *types.TMessage, lResult *t
|
||||
}
|
||||
|
||||
func (m *LCLBrowserWindow) setDraggableRegions() {
|
||||
if m.regions.RegionsCount() > 0 {
|
||||
if m.rgn != nil {
|
||||
WinDeleteObject(m.rgn)
|
||||
m.rgn.Free()
|
||||
}
|
||||
m.rgn = WinCreateRectRgn(0, 0, 0, 0)
|
||||
WinSetDraggableRegions(m.rgn, m.regions.Regions())
|
||||
if m.cwcap.regions.RegionsCount() > 0 {
|
||||
m.cwcap.freeRgn()
|
||||
m.cwcap.rgn = WinCreateRectRgn(0, 0, 0, 0)
|
||||
WinSetDraggableRegions(m.cwcap.rgn, m.cwcap.regions.Regions())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user