mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 11:47:37 +08:00
v2.2.6 Fixed Chinese input and gtk3 issues for linux packaging
This commit is contained in:
parent
4c05cbd475
commit
6de1e29e74
@ -24,8 +24,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IPC_FN_TYPE_IPCJSEmitGo = 1 // JS fires the Go registerEvent
|
IPC_FN_TYPE_IPCJSEmitGo = 1 // JS fires the Go registerChromiumEvent
|
||||||
IPC_FN_TYPE_IPCGoEmitJSRet = 2 // Go fires the JS registerEvent
|
IPC_FN_TYPE_IPCGoEmitJSRet = 2 // Go fires the JS registerChromiumEvent
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -27,6 +27,7 @@ type ITray interface {
|
|||||||
SetOnMouseUp(fn TMouseEvent) //up事件 linux 和 macos 可能不启作用
|
SetOnMouseUp(fn TMouseEvent) //up事件 linux 和 macos 可能不启作用
|
||||||
SetOnMouseDown(fn lcl.TMouseEvent) //down事件 linux 和 macos 可能不启作用
|
SetOnMouseDown(fn lcl.TMouseEvent) //down事件 linux 和 macos 可能不启作用
|
||||||
SetOnMouseMove(fn lcl.TMouseMoveEvent) //move事件 linux 和 macos 可能不启作用
|
SetOnMouseMove(fn lcl.TMouseMoveEvent) //move事件 linux 和 macos 可能不启作用
|
||||||
|
SetIconFS(iconResourcePath string) //设置托盘图标
|
||||||
SetIcon(iconResourcePath string) //设置托盘图标
|
SetIcon(iconResourcePath string) //设置托盘图标
|
||||||
SetHint(value string) //设置托盘hint(鼠标移动到托盘图标显示的文字)
|
SetHint(value string) //设置托盘hint(鼠标移动到托盘图标显示的文字)
|
||||||
ShowBalloon() //显示托盘气泡
|
ShowBalloon() //显示托盘气泡
|
||||||
@ -103,10 +104,15 @@ func (m *Tray) TrayMenu() *lcl.TPopupMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//设置托盘图标
|
//设置托盘图标
|
||||||
func (m *Tray) SetIcon(iconResourcePath string) {
|
func (m *Tray) SetIconFS(iconResourcePath string) {
|
||||||
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置托盘图标
|
||||||
|
func (m *Tray) SetIcon(iconResourcePath string) {
|
||||||
|
m.trayIcon.Icon().LoadFromFile(iconResourcePath)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Tray) SetHint(value string) {
|
func (m *Tray) SetHint(value string) {
|
||||||
m.trayIcon.SetHint(value)
|
m.trayIcon.SetHint(value)
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func newLCLTrayWindow(owner lcl.IComponent, width, height int32, url string) *tL
|
|||||||
trayForm.w = width
|
trayForm.w = width
|
||||||
trayForm.h = height
|
trayForm.h = height
|
||||||
trayForm.url = url
|
trayForm.url = url
|
||||||
trayForm.onmMouse()
|
trayForm.onMouseEvent()
|
||||||
trayForm.createCefTrayWindow()
|
trayForm.createTrayWindow()
|
||||||
return trayForm
|
return trayForm
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ func (m *tLCLTrayWindow) close() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Hide()
|
m.Hide()
|
||||||
|
m.trayIcon.SetVisible(false)
|
||||||
m.TForm.Close()
|
m.TForm.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ func (m *tLCLTrayWindow) SetTitle(title string) {
|
|||||||
m.TForm.SetCaption(title)
|
m.TForm.SetCaption(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tLCLTrayWindow) onmMouse() {
|
func (m *tLCLTrayWindow) onMouseEvent() {
|
||||||
QueueAsyncCall(func(id int) {
|
QueueAsyncCall(func(id int) {
|
||||||
m.trayIcon.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
m.trayIcon.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||||
var monitor = m.TForm.Monitor()
|
var monitor = m.TForm.Monitor()
|
||||||
@ -160,7 +161,7 @@ func (m *tLCLTrayWindow) ShowBalloon() {
|
|||||||
m.trayIcon.ShowBalloonHint()
|
m.trayIcon.ShowBalloonHint()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tLCLTrayWindow) createCefTrayWindow() {
|
func (m *tLCLTrayWindow) createTrayWindow() {
|
||||||
m.TForm.SetBorderStyle(types.BsNone)
|
m.TForm.SetBorderStyle(types.BsNone)
|
||||||
m.TForm.SetFormStyle(types.FsStayOnTop)
|
m.TForm.SetFormStyle(types.FsStayOnTop)
|
||||||
m.TForm.SetBounds(-(m.w * 2), -(m.h * 2), m.w, m.h)
|
m.TForm.SetBounds(-(m.w * 2), -(m.h * 2), m.w, m.h)
|
||||||
@ -243,6 +244,11 @@ func (m *tLCLTrayWindow) createCefTrayWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//设置托盘图标
|
//设置托盘图标
|
||||||
func (m *tLCLTrayWindow) SetIcon(iconResourcePath string) {
|
func (m *tLCLTrayWindow) SetIconFS(iconResourcePath string) {
|
||||||
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置托盘图标
|
||||||
|
func (m *tLCLTrayWindow) SetIcon(iconResourcePath string) {
|
||||||
|
m.trayIcon.Icon().LoadFromFile(iconResourcePath)
|
||||||
|
}
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
package cef
|
package cef
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"github.com/energye/energy/common/assetserve"
|
||||||
|
"github.com/energye/energy/consts"
|
||||||
|
"github.com/energye/energy/ipc"
|
||||||
|
"github.com/energye/energy/logger"
|
||||||
"github.com/energye/golcl/lcl"
|
"github.com/energye/golcl/lcl"
|
||||||
"github.com/energye/golcl/lcl/types"
|
"github.com/energye/golcl/lcl/types"
|
||||||
)
|
)
|
||||||
@ -27,35 +30,35 @@ type tViewsFrameTrayWindow struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newViewsFrameTray(owner lcl.IComponent, width, height int32, url string) *tViewsFrameTrayWindow {
|
func newViewsFrameTray(owner lcl.IComponent, width, height int32, url string) *tViewsFrameTrayWindow {
|
||||||
var trayForm = &tViewsFrameTrayWindow{}
|
var tray = &tViewsFrameTrayWindow{}
|
||||||
cc := NewChromiumConfig()
|
cc := NewChromiumConfig()
|
||||||
|
cc.SetEnableMenu(false)
|
||||||
wp := NewWindowProperty()
|
wp := NewWindowProperty()
|
||||||
|
wp.Title = ""
|
||||||
wp.Url = url
|
wp.Url = url
|
||||||
wp.Width = width
|
wp.Width = width
|
||||||
wp.Height = height
|
wp.Height = height
|
||||||
wp.X = 100
|
wp.X = -width
|
||||||
wp.Y = 100
|
wp.Y = -height
|
||||||
wp.AlwaysOnTop = true
|
wp.AlwaysOnTop = true
|
||||||
wp.CanMaximize = false
|
wp.CanMaximize = false
|
||||||
wp.CanMinimize = false
|
wp.CanMinimize = false
|
||||||
wp.CanResize = false
|
wp.CanResize = false
|
||||||
wp.CenterWindow = false
|
wp.CenterWindow = false
|
||||||
trayForm.trayWindow = NewViewsFrameworkBrowserWindow(cc, wp, func(event *BrowserEvent, window IBrowserWindow) {
|
tray.trayWindow = NewViewsFrameworkBrowserWindow(cc, wp, func(event *BrowserEvent, window IBrowserWindow) {
|
||||||
fmt.Println("tray.NewViewsFrameworkBrowserWindow")
|
window.Hide()
|
||||||
window.Show()
|
|
||||||
})
|
})
|
||||||
trayForm.trayIcon = lcl.NewTrayIcon(owner)
|
tray.trayWindow.windowId = BrowserWindow.GetNextWindowNum()
|
||||||
trayForm.trayIcon.SetVisible(true)
|
tray.trayWindow.putChromiumWindowInfo()
|
||||||
trayForm.x = wp.X
|
tray.trayIcon = lcl.NewTrayIcon(owner)
|
||||||
trayForm.y = wp.Y
|
tray.trayIcon.SetVisible(true)
|
||||||
trayForm.w = wp.Width
|
tray.x = wp.X
|
||||||
trayForm.h = wp.Height
|
tray.y = wp.Y
|
||||||
trayForm.onmMouse()
|
tray.w = wp.Width
|
||||||
//trayForm.createCefTrayWindow()
|
tray.h = wp.Height
|
||||||
fmt.Println("newViewsFrameTray")
|
tray.registerMouseEvent()
|
||||||
trayForm.trayWindow.CreateTopLevelWindow()
|
tray.registerChromiumEvent()
|
||||||
trayForm.trayWindow.HideTitle()
|
return tray
|
||||||
return trayForm
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) Tray() *Tray {
|
func (m *tViewsFrameTrayWindow) Tray() *Tray {
|
||||||
@ -63,18 +66,18 @@ func (m *tViewsFrameTrayWindow) Tray() *Tray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) Show() {
|
func (m *tViewsFrameTrayWindow) Show() {
|
||||||
if BrowserWindow.mainBrowserWindow.Chromium() == nil || !BrowserWindow.mainBrowserWindow.Chromium().Initialized() {
|
m.trayWindow.Show()
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) Hide() {
|
func (m *tViewsFrameTrayWindow) Hide() {
|
||||||
|
m.trayWindow.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) close() {
|
func (m *tViewsFrameTrayWindow) close() {
|
||||||
if m.isClosing {
|
if m.isClosing {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
m.trayIcon.SetVisible(false)
|
||||||
m.Hide()
|
m.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,36 +116,73 @@ func (m *tViewsFrameTrayWindow) SetHint(value string) {
|
|||||||
func (m *tViewsFrameTrayWindow) SetTitle(title string) {
|
func (m *tViewsFrameTrayWindow) SetTitle(title string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) onmMouse() {
|
func (m *tViewsFrameTrayWindow) registerMouseEvent() {
|
||||||
|
m.trayWindow.WindowComponent().SetOnWindowActivationChanged(func(sender lcl.IObject, window *ICefWindow, active bool) {
|
||||||
|
if active {
|
||||||
|
m.trayWindow.Show()
|
||||||
|
} else {
|
||||||
|
m.trayWindow.Hide()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var IsCreateTopLevelWindow = true
|
||||||
m.trayIcon.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
m.trayIcon.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||||
fmt.Println("SetOnMouseUp")
|
if IsCreateTopLevelWindow {
|
||||||
m.trayWindow.WindowComponent().SetPosition(NewCefPoint(400, 400))
|
IsCreateTopLevelWindow = false
|
||||||
//var monitor = m.TForm.Monitor()
|
m.trayWindow.CreateTopLevelWindow()
|
||||||
//var monitorWidth = monitor.Width()
|
m.trayWindow.HideTitle()
|
||||||
//width, height := m.TForm.Width(), m.TForm.Height()
|
m.trayWindow.SetNotInTaskBar()
|
||||||
//var mx = x + width
|
m.trayWindow.WindowComponent().SetAlwaysOnTop(true)
|
||||||
//var my = y + height
|
}
|
||||||
//if mx < monitorWidth {
|
display := m.trayWindow.WindowComponent().Display()
|
||||||
// mx = x
|
bounds := display.Bounds()
|
||||||
//} else {
|
var monitorWidth = bounds.Width
|
||||||
// mx = x - width
|
width, height := m.w, m.h
|
||||||
//}
|
var mx = x + width
|
||||||
//if my > m.h {
|
var my = y + height
|
||||||
// my = y
|
if mx < monitorWidth {
|
||||||
//}
|
mx = x
|
||||||
//if my > height {
|
} else {
|
||||||
// my = y - height
|
mx = x - width
|
||||||
//}
|
}
|
||||||
//m.TForm.SetBounds(mx, my, width, height)
|
if my > m.h {
|
||||||
//var ret bool
|
my = y
|
||||||
//if m.mouseUp != nil {
|
}
|
||||||
// ret = m.mouseUp(sender, button, shift, x, y)
|
if my > height {
|
||||||
//}
|
my = y - height
|
||||||
//if !ret {
|
}
|
||||||
// if button == types.MbRight {
|
var ret bool
|
||||||
// m.Show()
|
if m.mouseUp != nil {
|
||||||
// }
|
ret = m.mouseUp(sender, button, shift, x, y)
|
||||||
//}
|
}
|
||||||
|
if !ret {
|
||||||
|
if button == types.MbRight {
|
||||||
|
m.trayWindow.WindowComponent().SetBounds(NewCefRect(mx, my, width, height))
|
||||||
|
m.trayWindow.Show()
|
||||||
|
m.trayWindow.BrowserViewComponent().RequestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *tViewsFrameTrayWindow) registerChromiumEvent() {
|
||||||
|
m.trayWindow.Chromium().SetOnBeforeContextMenu(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, model *ICefMenuModel) {
|
||||||
|
model.Clear()
|
||||||
|
})
|
||||||
|
m.trayWindow.Chromium().SetOnBeforeBrowser(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) bool {
|
||||||
|
BrowserWindow.setOrIncNextWindowNum(browser.Identifier() + 1)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
m.trayWindow.Chromium().SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue) {
|
||||||
|
if assetserve.AssetsServerHeaderKeyValue != "" {
|
||||||
|
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
m.trayWindow.Chromium().SetOnBeforeClose(func(sender lcl.IObject, browser *ICefBrowser) {
|
||||||
|
logger.Debug("tray.chromium.onBeforeClose")
|
||||||
|
m.close()
|
||||||
|
})
|
||||||
|
m.trayWindow.Chromium().SetOnProcessMessageReceived(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ipc.ICefProcessMessage) bool {
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,89 +202,12 @@ func (m *tViewsFrameTrayWindow) ShowBalloon() {
|
|||||||
m.trayIcon.ShowBalloonHint()
|
m.trayIcon.ShowBalloonHint()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *tViewsFrameTrayWindow) createCefTrayWindow() {
|
//设置托盘图标
|
||||||
//m.TForm.SetBorderStyle(types.BsNone)
|
func (m *tViewsFrameTrayWindow) SetIconFS(iconResourcePath string) {
|
||||||
//m.TForm.SetFormStyle(types.FsStayOnTop)
|
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
||||||
//m.TForm.SetBounds(-(m.w * 2), -(m.h * 2), m.w, m.h)
|
|
||||||
//m.TForm.SetOnActivate(func(sender lcl.IObject) {
|
|
||||||
// m.chromium.Initialized()
|
|
||||||
// m.chromium.CreateBrowser(m.windowParent)
|
|
||||||
//})
|
|
||||||
//m.TForm.SetOnWndProc(func(msg *types.TMessage) {
|
|
||||||
// m.TForm.InheritedWndProc(msg)
|
|
||||||
// if msg.Msg == 6 && msg.WParam == 0 && msg.LParam == 0 {
|
|
||||||
// QueueAsyncCall(func(id int) {
|
|
||||||
// if m.isClosing {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// m.TForm.Hide()
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//})
|
|
||||||
//m.TForm.SetOnDeactivate(func(sender lcl.IObject) {
|
|
||||||
// if m.isClosing {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// m.TForm.Hide()
|
|
||||||
//})
|
|
||||||
//
|
|
||||||
//m.TForm.SetOnCloseQuery(func(sender lcl.IObject, canClose *bool) {
|
|
||||||
// *canClose = true
|
|
||||||
// logger.Debug("tray.window.onCloseQuery canClose:", *canClose)
|
|
||||||
// if m.isClosing {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// m.isClosing = true
|
|
||||||
// m.Hide()
|
|
||||||
// m.chromium.CloseBrowser(true)
|
|
||||||
// m.trayIcon.Free()
|
|
||||||
//})
|
|
||||||
//m.TForm.SetOnClose(func(sender lcl.IObject, action *types.TCloseAction) {
|
|
||||||
// *action = types.CaFree
|
|
||||||
// logger.Debug("tray.window.onClose action:", *action)
|
|
||||||
//})
|
|
||||||
//m.TForm.SetOnShow(func(sender lcl.IObject) {
|
|
||||||
// if m.windowParent != nil {
|
|
||||||
// QueueAsyncCall(func(id int) {
|
|
||||||
// m.windowParent.UpdateSize()
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//})
|
|
||||||
//m.windowParent = NewCEFWindow(m.TForm)
|
|
||||||
//m.windowParent.SetParent(m.TForm)
|
|
||||||
//m.windowParent.SetAlign(types.AlClient)
|
|
||||||
//m.windowParent.SetAnchors(types.NewSet(types.AkTop, types.AkLeft, types.AkRight, types.AkBottom))
|
|
||||||
//m.chromium = NewChromium(m.windowParent, nil)
|
|
||||||
//m.chromium.SetOnBeforeContextMenu(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, params *ICefContextMenuParams, model *ICefMenuModel) {
|
|
||||||
// model.Clear()
|
|
||||||
//})
|
|
||||||
//m.chromium.SetOnBeforeBrowser(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame) bool {
|
|
||||||
// BrowserWindow.setOrIncNextWindowNum(browser.Identifier() + 1)
|
|
||||||
// return false
|
|
||||||
//})
|
|
||||||
//m.chromium.SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *TCefReturnValue) {
|
|
||||||
// if assetserve.AssetsServerHeaderKeyValue != "" {
|
|
||||||
// request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
|
|
||||||
// }
|
|
||||||
//})
|
|
||||||
//m.chromium.SetOnClose(func(sender lcl.IObject, browser *ICefBrowser, aAction *TCefCloseBrowsesAction) {
|
|
||||||
// logger.Debug("tray.chromium.onClose")
|
|
||||||
// if IsDarwin() {
|
|
||||||
// m.windowParent.DestroyChildWindow()
|
|
||||||
// }
|
|
||||||
// *aAction = CbaClose
|
|
||||||
//})
|
|
||||||
//m.chromium.SetOnBeforeClose(func(sender lcl.IObject, browser *ICefBrowser) {
|
|
||||||
// logger.Debug("tray.chromium.onBeforeClose")
|
|
||||||
//})
|
|
||||||
//m.chromium.SetOnProcessMessageReceived(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, sourceProcess CefProcessId, message *ipc.ICefProcessMessage) bool {
|
|
||||||
// return false
|
|
||||||
//})
|
|
||||||
//m.windowParent.SetChromium(m.chromium, 0)
|
|
||||||
//m.chromium.SetDefaultURL(m.url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置托盘图标
|
//设置托盘图标
|
||||||
func (m *tViewsFrameTrayWindow) SetIcon(iconResourcePath string) {
|
func (m *tViewsFrameTrayWindow) SetIcon(iconResourcePath string) {
|
||||||
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
|
m.trayIcon.Icon().LoadFromFile(iconResourcePath)
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,12 @@ func NewViewsFrameworkBrowserWindow(chromiumConfig *tCefChromiumConfig, windowPr
|
|||||||
browserViewComponent: NewBrowserViewComponent(component),
|
browserViewComponent: NewBrowserViewComponent(component),
|
||||||
}
|
}
|
||||||
m.chromium.SetEnableMultiBrowserMode(true)
|
m.chromium.SetEnableMultiBrowserMode(true)
|
||||||
m.registerPopupEvent()
|
|
||||||
m.windowComponent.SetOnWindowCreated(func(sender lcl.IObject, window *ICefWindow) {
|
m.windowComponent.SetOnWindowCreated(func(sender lcl.IObject, window *ICefWindow) {
|
||||||
if m.chromium.CreateBrowserByBrowserViewComponent(windowProperty.Url, m.browserViewComponent) {
|
if m.chromium.CreateBrowserByBrowserViewComponent(windowProperty.Url, m.browserViewComponent) {
|
||||||
m.windowComponent.AddChildView(m.browserViewComponent)
|
m.windowComponent.AddChildView(m.browserViewComponent)
|
||||||
m.windowComponent.SetTitle(windowProperty.Title)
|
if windowProperty.Title != "" {
|
||||||
|
m.windowComponent.SetTitle(windowProperty.Title)
|
||||||
|
}
|
||||||
if windowProperty.CenterWindow {
|
if windowProperty.CenterWindow {
|
||||||
m.windowComponent.CenterWindow(NewCefSize(windowProperty.Width, windowProperty.Height))
|
m.windowComponent.CenterWindow(NewCefSize(windowProperty.Width, windowProperty.Height))
|
||||||
}
|
}
|
||||||
@ -387,6 +388,28 @@ func (m *ViewsFrameworkBrowserWindow) HideTitle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ViewsFrameworkBrowserWindow) SetDefaultInTaskBar() {
|
||||||
|
if common.IsWindows() {
|
||||||
|
m.SetShowInTaskBar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ViewsFrameworkBrowserWindow) SetShowInTaskBar() {
|
||||||
|
if common.IsWindows() {
|
||||||
|
handle := m.WindowComponent().WindowHandle()
|
||||||
|
win.ShowWindow(handle.ToPtr(), win.SW_SHOW)
|
||||||
|
win.SetWindowLong(handle.ToPtr(), win.GWL_EXSTYLE, win.WS_EX_APPWINDOW)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ViewsFrameworkBrowserWindow) SetNotInTaskBar() {
|
||||||
|
if common.IsWindows() {
|
||||||
|
handle := m.WindowComponent().WindowHandle()
|
||||||
|
win.ShowWindow(handle.ToPtr(), win.SW_HIDE)
|
||||||
|
win.SetWindowLong(handle.ToPtr(), win.GWL_EXSTYLE, uintptr(win.GetWindowLong(handle.ToPtr(), win.GWL_EXSTYLE)|win.WS_EX_TOOLWINDOW&^win.WS_EX_APPWINDOW))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ViewsFrameworkBrowserWindow) Hide() {
|
func (m *ViewsFrameworkBrowserWindow) Hide() {
|
||||||
m.WindowComponent().Hide()
|
m.WindowComponent().Hide()
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,9 @@ type IBrowserWindow interface {
|
|||||||
NewCefTray(width, height int32, url string) ITray
|
NewCefTray(width, height int32, url string) ITray
|
||||||
NewTray() ITray
|
NewTray() ITray
|
||||||
HideTitle()
|
HideTitle()
|
||||||
|
SetDefaultInTaskBar()
|
||||||
|
SetShowInTaskBar()
|
||||||
|
SetNotInTaskBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ILCLBrowserWindow interface {
|
type ILCLBrowserWindow interface {
|
||||||
@ -90,9 +93,6 @@ type ILCLBrowserWindow interface {
|
|||||||
BrowserWindow() *LCLBrowserWindow
|
BrowserWindow() *LCLBrowserWindow
|
||||||
EnableDefaultCloseEvent()
|
EnableDefaultCloseEvent()
|
||||||
EnableAllDefaultEvent()
|
EnableAllDefaultEvent()
|
||||||
SetDefaultInTaskBar()
|
|
||||||
SetShowInTaskBar()
|
|
||||||
SetNotInTaskBar()
|
|
||||||
WindowParent() ITCefWindowParent
|
WindowParent() ITCefWindowParent
|
||||||
DisableTransparent()
|
DisableTransparent()
|
||||||
EnableTransparent(value uint8)
|
EnableTransparent(value uint8)
|
||||||
|
@ -603,4 +603,17 @@ const (
|
|||||||
|
|
||||||
type TCefShowState = types.Int32
|
type TCefShowState = types.Int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
CEF_SHOW_STATE_NORMAL = TCefShowState(1)
|
||||||
|
CEF_SHOW_STATE_MINIMIZED = TCefShowState(2)
|
||||||
|
CEF_SHOW_STATE_MAXIMIZED = TCefShowState(3)
|
||||||
|
CEF_SHOW_STATE_FULLSCREEN = TCefShowState(4)
|
||||||
|
)
|
||||||
|
|
||||||
type TCefChromeToolbarType = types.Int32
|
type TCefChromeToolbarType = types.Int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
CEF_CTT_NONE = TCefChromeToolbarType(1)
|
||||||
|
CEF_CTT_NORMAL = TCefChromeToolbarType(2)
|
||||||
|
CEF_CTT_LOCATION = TCefChromeToolbarType(3)
|
||||||
|
)
|
||||||
|
@ -78,9 +78,9 @@ func cefTray(browserWindow cef.IBrowserWindow) {
|
|||||||
tray := browserWindow.NewCefTray(250, 300, url)
|
tray := browserWindow.NewCefTray(250, 300, url)
|
||||||
tray.SetTitle("任务管理器里显示的标题")
|
tray.SetTitle("任务管理器里显示的标题")
|
||||||
tray.SetHint("这里是文字\n文字啊")
|
tray.SetHint("这里是文字\n文字啊")
|
||||||
tray.SetIcon("resources/icon.ico")
|
tray.SetIconFS("resources/icon.ico")
|
||||||
tray.SetOnClick(func(sender lcl.IObject) {
|
tray.SetOnClick(func(sender lcl.IObject) {
|
||||||
//browserWindow.SetVisible(!browserWindow.Visible())
|
browserWindow.Show()
|
||||||
})
|
})
|
||||||
tray.SetBalloon("气泡标题", "气泡内容", 2000)
|
tray.SetBalloon("气泡标题", "气泡内容", 2000)
|
||||||
ipc.IPC.Browser().On("tray-show-balloon", func(context ipc.IIPCContext) {
|
ipc.IPC.Browser().On("tray-show-balloon", func(context ipc.IIPCContext) {
|
||||||
@ -89,23 +89,15 @@ func cefTray(browserWindow cef.IBrowserWindow) {
|
|||||||
tray.Hide()
|
tray.Hide()
|
||||||
})
|
})
|
||||||
ipc.IPC.Browser().On("tray-show-main-window", func(context ipc.IIPCContext) {
|
ipc.IPC.Browser().On("tray-show-main-window", func(context ipc.IIPCContext) {
|
||||||
//vb := !browserWindow.Visible()
|
browserWindow.Hide()
|
||||||
//browserWindow.SetVisible(vb)
|
|
||||||
//if vb {
|
|
||||||
// if browserWindow.WindowState() == types.WsMinimized {
|
|
||||||
// browserWindow.SetWindowState(types.WsNormal)
|
|
||||||
// }
|
|
||||||
// browserWindow.Focused()
|
|
||||||
//}
|
|
||||||
tray.Hide()
|
tray.Hide()
|
||||||
})
|
})
|
||||||
ipc.IPC.Browser().On("tray-close-main-window", func(context ipc.IIPCContext) {
|
ipc.IPC.Browser().On("tray-close-main-window", func(context ipc.IIPCContext) {
|
||||||
browserWindow.CloseBrowserWindow()
|
browserWindow.CloseBrowserWindow()
|
||||||
})
|
})
|
||||||
ipc.IPC.Browser().On("tray-show-message-box", func(context ipc.IIPCContext) {
|
ipc.IPC.Browser().On("tray-show-message-box", func(context ipc.IIPCContext) {
|
||||||
cef.QueueAsyncCall(func(id int) {
|
//无法使用lcl组件
|
||||||
lcl.ShowMessage("tray-show-message-box 提示消息")
|
//lcl.ShowMessage("提示?") //直接异常退出
|
||||||
})
|
|
||||||
tray.Hide()
|
tray.Hide()
|
||||||
})
|
})
|
||||||
//托盘 end
|
//托盘 end
|
||||||
@ -116,7 +108,7 @@ func tray(browserWindow cef.IBrowserWindow) {
|
|||||||
//托盘 windows linux macos 系统托盘
|
//托盘 windows linux macos 系统托盘
|
||||||
newTray := browserWindow.NewTray()
|
newTray := browserWindow.NewTray()
|
||||||
tray := newTray.Tray()
|
tray := newTray.Tray()
|
||||||
tray.SetIcon("resources/icon.ico")
|
tray.SetIconFS("resources/icon.ico")
|
||||||
tray.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) bool {
|
tray.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) bool {
|
||||||
fmt.Println("SetOnMouseUp", button, shift, x, y)
|
fmt.Println("SetOnMouseUp", button, shift, x, y)
|
||||||
return false
|
return false
|
||||||
|
42
example/browser-linux/resources/min-browser-tray.html
Normal file
42
example/browser-linux/resources/min-browser-tray.html
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
<style type="text/css">
|
||||||
|
a, button {
|
||||||
|
margin: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function trayShowMessageBox() {
|
||||||
|
ipc.emit("tray-show-message-box");
|
||||||
|
}
|
||||||
|
|
||||||
|
function trayShowBalloon() {
|
||||||
|
ipc.emit("tray-show-balloon");
|
||||||
|
}
|
||||||
|
|
||||||
|
function trayShowMainWindow() {
|
||||||
|
ipc.emit("tray-show-main-window");
|
||||||
|
}
|
||||||
|
|
||||||
|
function trayCloseMainWindow() {
|
||||||
|
ipc.emit("tray-close-main-window");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body id="bodyId" style="border: 0; padding: 0;margin:0;overflow-x: hidden;overflow-y: hidden;">
|
||||||
|
<button onclick="trayShowBalloon()">显示托盘汽泡</button>
|
||||||
|
<br>
|
||||||
|
<button onclick="trayShowMainWindow()">显示窗口</button>
|
||||||
|
<br>
|
||||||
|
<button onclick="trayCloseMainWindow()">退出</button>
|
||||||
|
<button onclick="trayShowMessageBox()">显示消息弹窗</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -191,7 +191,7 @@ func AppBrowserInit() {
|
|||||||
//browserWindow.EnableTransparent(100) //窗口透明
|
//browserWindow.EnableTransparent(100) //窗口透明
|
||||||
//设置窗口样式,无标题 ,最大化按钮等
|
//设置窗口样式,无标题 ,最大化按钮等
|
||||||
window := browserWindow.AsLCLBrowserWindow()
|
window := browserWindow.AsLCLBrowserWindow()
|
||||||
browserWindow.HideTitle()
|
//browserWindow.HideTitle()
|
||||||
//window.BrowserWindow().SetBorderStyle(types.BsNone)
|
//window.BrowserWindow().SetBorderStyle(types.BsNone)
|
||||||
//window.BrowserWindow().SetFormStyle(types.FsNormal)
|
//window.BrowserWindow().SetFormStyle(types.FsNormal)
|
||||||
//window.BrowserWindow().SetFormStyle(types.FsSystemStayOnTop)
|
//window.BrowserWindow().SetFormStyle(types.FsSystemStayOnTop)
|
||||||
@ -402,7 +402,7 @@ func cefTray(browserWindow cef.ILCLBrowserWindow) {
|
|||||||
tray := browserWindow.NewCefTray(250, 300, url)
|
tray := browserWindow.NewCefTray(250, 300, url)
|
||||||
tray.SetTitle("任务管理器里显示的标题")
|
tray.SetTitle("任务管理器里显示的标题")
|
||||||
tray.SetHint("这里是文字\n文字啊")
|
tray.SetHint("这里是文字\n文字啊")
|
||||||
tray.SetIcon("resources/icon.ico")
|
tray.SetIconFS("resources/icon.ico")
|
||||||
tray.SetOnClick(func(sender lcl.IObject) {
|
tray.SetOnClick(func(sender lcl.IObject) {
|
||||||
window.SetVisible(!window.Visible())
|
window.SetVisible(!window.Visible())
|
||||||
})
|
})
|
||||||
@ -441,7 +441,7 @@ func tray(browserWindow cef.ILCLBrowserWindow) {
|
|||||||
//托盘 windows linux macos 系统托盘
|
//托盘 windows linux macos 系统托盘
|
||||||
newTray := browserWindow.NewTray()
|
newTray := browserWindow.NewTray()
|
||||||
tray := newTray.Tray()
|
tray := newTray.Tray()
|
||||||
tray.SetIcon("resources/icon.ico")
|
tray.SetIconFS("resources/icon.ico")
|
||||||
menu1 := tray.AddMenuItem("父菜单", nil)
|
menu1 := tray.AddMenuItem("父菜单", nil)
|
||||||
menu1.Add(tray.NewMenuItem("子菜单", func(object lcl.IObject) {
|
menu1.Add(tray.NewMenuItem("子菜单", func(object lcl.IObject) {
|
||||||
lcl.ShowMessage("子菜单点击 提示消息")
|
lcl.ShowMessage("子菜单点击 提示消息")
|
||||||
|
Loading…
Reference in New Issue
Block a user