v2.2.3 Fixed Chinese input and gtk3 issues for linux packaging

This commit is contained in:
杨红岩 2023-01-06 21:42:29 +08:00
parent 05c4895457
commit 301fd110f3
7 changed files with 48 additions and 44 deletions

View File

@ -18,6 +18,7 @@ type TMouseEvent func(sender lcl.IObject, button types.TMouseButton, shift types
type ITray interface {
SetTitle(title string) //设置标题
SetVisible(v bool) //显示和隐藏托盘图标
Visible() bool //
Show() //显示托盘菜单窗口 windows有效
Hide() //隐藏托盘菜单窗口 windows有效
close() //关闭托盘菜单窗口 windows有效
@ -35,17 +36,16 @@ type ITray interface {
//系统托盘
type Tray struct {
owner lcl.IWinControl
owner lcl.IComponent
trayIcon *lcl.TTrayIcon
popupMenu *lcl.TPopupMenu
}
//创建系统托盘
func newTray(owner lcl.IWinControl) *Tray {
func newTray(owner lcl.IComponent) *Tray {
trayIcon := lcl.NewTrayIcon(owner)
popupMenu := lcl.NewPopupMenu(owner)
popupMenu := lcl.NewPopupMenu(trayIcon)
trayIcon.SetPopupMenu(popupMenu)
trayIcon.SetHint(owner.Caption())
trayIcon.SetVisible(true)
return &Tray{
owner: owner,
@ -62,11 +62,18 @@ func (m *Tray) SetVisible(v bool) {
m.trayIcon.SetVisible(v)
}
func (m *Tray) Visible() bool {
return m.trayIcon.Visible()
}
func (m *Tray) Show() {
m.SetVisible(true)
}
func (m *Tray) Hide() {
m.SetVisible(false)
}
func (m *Tray) close() {}
func (m *Tray) SetOnDblClick(fn lcl.TNotifyEvent) {
@ -123,7 +130,7 @@ func (m *Tray) ShowBalloon() {
//创建一个菜单,还未添加到托盘
func (m *Tray) NewMenuItem(caption string, onClick func(lcl.IObject)) *lcl.TMenuItem {
item := lcl.NewMenuItem(m.owner)
item := lcl.NewMenuItem(m.trayIcon)
item.SetCaption(caption)
if onClick != nil {
item.SetOnClick(onClick)

View File

@ -22,7 +22,7 @@ import (
)
//Cef托盘
type tCefTrayForm struct {
type tLCLCefTrayForm struct {
*lcl.TForm
owner lcl.IComponent
trayIcon *lcl.TTrayIcon
@ -34,8 +34,8 @@ type tCefTrayForm struct {
url string
}
func newCefTray(owner lcl.IComponent, width, height int32, url string) *tCefTrayForm {
var trayForm *tCefTrayForm
func newLCLCefTray(owner lcl.IComponent, width, height int32, url string) *tLCLCefTrayForm {
var trayForm *tLCLCefTrayForm
lcl.Application.CreateForm(&trayForm)
trayForm.trayIcon = lcl.NewTrayIcon(owner)
trayForm.trayIcon.SetVisible(true)
@ -50,26 +50,26 @@ func newCefTray(owner lcl.IComponent, width, height int32, url string) *tCefTray
return trayForm
}
func (m *tCefTrayForm) OnFormCreate(sender lcl.IObject) {
func (m *tLCLCefTrayForm) OnFormCreate(sender lcl.IObject) {
m.SetShowInTaskBar(types.StNever)
}
func (m *tCefTrayForm) Tray() *Tray {
func (m *tLCLCefTrayForm) Tray() *Tray {
return nil
}
func (m *tCefTrayForm) Show() {
func (m *tLCLCefTrayForm) Show() {
if BrowserWindow.mainBrowserWindow.Chromium() == nil || !BrowserWindow.mainBrowserWindow.Chromium().Initialized() {
return
}
m.TForm.Show()
}
func (m *tCefTrayForm) Hide() {
func (m *tLCLCefTrayForm) Hide() {
m.TForm.Hide()
}
func (m *tCefTrayForm) close() {
func (m *tLCLCefTrayForm) close() {
if m.isClosing {
return
}
@ -77,41 +77,41 @@ func (m *tCefTrayForm) close() {
m.TForm.Close()
}
func (m *tCefTrayForm) SetOnDblClick(fn lcl.TNotifyEvent) {
func (m *tLCLCefTrayForm) SetOnDblClick(fn lcl.TNotifyEvent) {
m.trayIcon.SetOnDblClick(fn)
}
func (m *tCefTrayForm) SetOnClick(fn lcl.TNotifyEvent) {
func (m *tLCLCefTrayForm) SetOnClick(fn lcl.TNotifyEvent) {
m.trayIcon.SetOnClick(fn)
}
func (m *tCefTrayForm) SetOnMouseUp(fn TMouseEvent) {
func (m *tLCLCefTrayForm) SetOnMouseUp(fn TMouseEvent) {
m.mouseUp = fn
}
func (m *tCefTrayForm) SetOnMouseDown(fn lcl.TMouseEvent) {
func (m *tLCLCefTrayForm) SetOnMouseDown(fn lcl.TMouseEvent) {
m.trayIcon.SetOnMouseDown(fn)
}
func (m *tCefTrayForm) SetOnMouseMove(fn lcl.TMouseMoveEvent) {
func (m *tLCLCefTrayForm) SetOnMouseMove(fn lcl.TMouseMoveEvent) {
m.trayIcon.SetOnMouseMove(fn)
}
func (m *tCefTrayForm) Visible() bool {
func (m *tLCLCefTrayForm) Visible() bool {
return m.TForm.Visible()
}
func (m *tCefTrayForm) SetVisible(v bool) {
func (m *tLCLCefTrayForm) SetVisible(v bool) {
m.trayIcon.SetVisible(v)
}
func (m *tCefTrayForm) SetHint(value string) {
func (m *tLCLCefTrayForm) SetHint(value string) {
m.trayIcon.SetHint(value)
}
func (m *tCefTrayForm) SetTitle(title string) {
func (m *tLCLCefTrayForm) SetTitle(title string) {
m.TForm.SetCaption(title)
}
func (m *tCefTrayForm) onmMouse() {
func (m *tLCLCefTrayForm) onmMouse() {
QueueAsyncCall(func(id int) {
m.trayIcon.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
var monitor = m.TForm.Monitor()
@ -148,7 +148,7 @@ func (m *tCefTrayForm) onmMouse() {
//title 气泡标题
//content 气泡内容
//timeout 显示时间(毫秒)
func (m *tCefTrayForm) SetBalloon(title, content string, timeout int32) ITray {
func (m *tLCLCefTrayForm) SetBalloon(title, content string, timeout int32) ITray {
m.trayIcon.SetBalloonTitle(title)
m.trayIcon.SetBalloonHint(content)
m.trayIcon.SetBalloonTimeout(timeout)
@ -156,11 +156,11 @@ func (m *tCefTrayForm) SetBalloon(title, content string, timeout int32) ITray {
}
//显示托盘气泡
func (m *tCefTrayForm) ShowBalloon() {
func (m *tLCLCefTrayForm) ShowBalloon() {
m.trayIcon.ShowBalloonHint()
}
func (m *tCefTrayForm) createCefTrayWindow() {
func (m *tLCLCefTrayForm) createCefTrayWindow() {
m.TForm.SetBorderStyle(types.BsNone)
m.TForm.SetFormStyle(types.FsStayOnTop)
m.TForm.SetBounds(-(m.w * 2), -(m.h * 2), m.w, m.h)
@ -249,6 +249,6 @@ func (m *tCefTrayForm) createCefTrayWindow() {
}
//设置托盘图标
func (m *tCefTrayForm) SetIcon(iconResourcePath string) {
func (m *tLCLCefTrayForm) SetIcon(iconResourcePath string) {
m.trayIcon.Icon().LoadFromFSFile(iconResourcePath)
}

View File

@ -10,11 +10,8 @@ package cef
//适用于 windows linux macos 系统托盘
func (m *LCLBrowserWindow) NewTray() ITray {
return newTray(m)
}
//适用于 windows linux macos 系统托盘
func (m *ViewsFrameworkBrowserWindow) NewTray() ITray {
if m.tray == nil {
m.tray = newTray(m.TForm)
}
return m.tray
}

View File

@ -13,13 +13,13 @@ package cef
//只适用于windows的无菜单托盘
func (m *LCLBrowserWindow) NewCefTray(width, height int32, url string) ITray {
if BrowserWindow.mainBrowserWindow.AsLCLBrowserWindow() == nil {
if m == nil {
return nil
}
if BrowserWindow.mainBrowserWindow.AsLCLBrowserWindow().BrowserWindow().tray == nil {
BrowserWindow.mainBrowserWindow.AsLCLBrowserWindow().BrowserWindow().tray = newCefTray(m, width, height, url)
if m.tray == nil {
m.tray = newLCLCefTray(m, width, height, url)
}
return BrowserWindow.mainBrowserWindow.AsLCLBrowserWindow().BrowserWindow().tray
return m.tray
}
//只适用于windows的无菜单托盘
@ -28,7 +28,7 @@ func (m *ViewsFrameworkBrowserWindow) NewCefTray(width, height int32, url string
return nil
}
if m.tray == nil {
//m.tray = newCefTray(m.windowComponent, width, height, url)
m.tray = newLCLCefTray(m.component, width, height, url)
}
return m.tray
}

View File

@ -81,7 +81,6 @@ type IBrowserWindow interface {
SetBounds(ALeft int32, ATop int32, AWidth int32, AHeight int32)
SetCenterWindow(value bool)
NewCefTray(width, height int32, url string) ITray
NewTray() ITray
}
type ILCLBrowserWindow interface {
@ -99,6 +98,7 @@ type ILCLBrowserWindow interface {
DisableHelp()
EnableSystemMenu()
EnableHelp()
NewTray() ITray
}
type IViewsFrameworkBrowserWindow interface {

View File

@ -40,7 +40,7 @@ func main() {
popupWindow.SetCenterWindow(true)
return false
})
cefTray(window.AsViewsFrameworkBrowserWindow().BrowserWindow())
cefTray(window)
})
//在主进程启动成功之后执行
//在这里启动内置http服务

View File

@ -387,15 +387,15 @@ func AppBrowserInit() {
//在这里创建 一些子窗口 子组件 等
//托盘
if common.IsWindows() {
cefTray(browserWindow)
cefTray(browserWindow.AsLCLBrowserWindow())
} else {
tray(browserWindow.AsLCLBrowserWindow().BrowserWindow())
tray(browserWindow.AsLCLBrowserWindow())
}
})
}
// 托盘 只适用 windows 的系统托盘, 基于html 和 ipc 实现功能
func cefTray(browserWindow cef.IBrowserWindow) {
func cefTray(browserWindow cef.ILCLBrowserWindow) {
window := browserWindow.AsLCLBrowserWindow().BrowserWindow()
var url = "http://localhost:22022/min-browser-tray.html"
tray := browserWindow.NewCefTray(250, 300, url)
@ -435,7 +435,7 @@ func cefTray(browserWindow cef.IBrowserWindow) {
}
// 托盘 系统原生 windows linux macos
func tray(browserWindow cef.IBrowserWindow) {
func tray(browserWindow cef.ILCLBrowserWindow) {
window := browserWindow.AsLCLBrowserWindow().BrowserWindow()
//托盘 windows linux macos 系统托盘
newTray := browserWindow.NewTray()