fix: use purego-cef v0.7.3 sized constructors and correct sqlite driver name
CEF 145 rejects structs where Size == 0. Migrate all zero-value struct literals to New*() constructors (NewWindowInfo, NewBrowserSettings, NewKeyEvent, NewScreenInfo) which pre-fill Size automatically. Also fix sqlite driver name mismatch: purego-sqlite registers as "sqlite3", not "sqlite".
- commit
- a5f2194c966989f454337c6d572c40cb449dabec
- author
- brice · · 2026-03-28 08:56 UTC
- parent
- c46cae7
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
6 files · +25 -25
M internal/infrastructure/cef/factory.go +2 -2
| @@ -118,12 +118,12 @@ func (f *WebViewFactory) Create(ctx context.Context) (port.WebView, error) { | |||
| 118 | 118 | wv.client = client | |
| 119 | 119 | ||
| 120 | 120 | // Configure WindowInfo for off-screen rendering (OSR). | |
| 121 | - | windowInfo := purecef.WindowInfo{} | |
| 121 | + | windowInfo := purecef.NewWindowInfo() | |
| 122 | 122 | windowInfo.WindowlessRenderingEnabled = 1 | |
| 123 | 123 | windowInfo.ExternalBeginFrameEnabled = 1 | |
| 124 | 124 | ||
| 125 | 125 | // Configure BrowserSettings. | |
| 126 | - | settings := purecef.BrowserSettings{} | |
| 126 | + | settings := purecef.NewBrowserSettings() | |
| 127 | 127 | settings.WindowlessFrameRate = f.windowlessFrameRate | |
| 128 | 128 | settings.LocalStorage = 1 // CEF_STATE_ENABLED | |
| 129 | 129 | if bg := f.bgColor.Load(); bg != 0 { | |
| @@ -118,12 +118,12 @@ func (f *WebViewFactory) Create(ctx context.Context) (port.WebView, error) { | |||||
| 118 | wv.client = client | 118 | wv.client = client | ||
| 119 | 119 | ||||
| 120 | // Configure WindowInfo for off-screen rendering (OSR). | 120 | // Configure WindowInfo for off-screen rendering (OSR). | ||
| 121 | - | windowInfo := purecef.WindowInfo{} | 121 | + | windowInfo := purecef.NewWindowInfo() |
| 122 | windowInfo.WindowlessRenderingEnabled = 1 | 122 | windowInfo.WindowlessRenderingEnabled = 1 | ||
| 123 | windowInfo.ExternalBeginFrameEnabled = 1 | 123 | windowInfo.ExternalBeginFrameEnabled = 1 | ||
| 124 | 124 | ||||
| 125 | // Configure BrowserSettings. | 125 | // Configure BrowserSettings. | ||
| 126 | - | settings := purecef.BrowserSettings{} | 126 | + | settings := purecef.NewBrowserSettings() |
| 127 | settings.WindowlessFrameRate = f.windowlessFrameRate | 127 | settings.WindowlessFrameRate = f.windowlessFrameRate | ||
| 128 | settings.LocalStorage = 1 // CEF_STATE_ENABLED | 128 | settings.LocalStorage = 1 // CEF_STATE_ENABLED | ||
| 129 | if bg := f.bgColor.Load(); bg != 0 { | 129 | if bg := f.bgColor.Load(); bg != 0 { | ||
M internal/infrastructure/cef/input_bridge.go +11 -12
| @@ -385,12 +385,11 @@ func (ib *inputBridge) onIMCommit(text string) { | |||
| 385 | 385 | continue | |
| 386 | 386 | } | |
| 387 | 387 | ch := uint16(r) | |
| 388 | - | evt := purecef.KeyEvent{ | |
| 389 | - | Type: purecef.KeyEventTypeKeyeventChar, | |
| 390 | - | WindowsKeyCode: int32(ch), | |
| 391 | - | Character: ch, | |
| 392 | - | UnmodifiedCharacter: ch, | |
| 393 | - | } | |
| 388 | + | evt := purecef.NewKeyEvent() | |
| 389 | + | evt.Type = purecef.KeyEventTypeKeyeventChar | |
| 390 | + | evt.WindowsKeyCode = int32(ch) | |
| 391 | + | evt.Character = ch | |
| 392 | + | evt.UnmodifiedCharacter = ch | |
| 394 | 393 | host.SendKeyEvent(&evt) | |
| 395 | 394 | } | |
| 396 | 395 | } | |
| @@ -490,12 +489,12 @@ func buildMouseEvent(x, y float64, gdkMods uint, scale int32) purecef.MouseEvent | |||
| 490 | 489 | } | |
| 491 | 490 | ||
| 492 | 491 | func buildKeyEvent(keyval, keycode, gdkMods uint, eventType purecef.KeyEventType) purecef.KeyEvent { | |
| 493 | - | return purecef.KeyEvent{ | |
| 494 | - | Type: eventType, | |
| 495 | - | WindowsKeyCode: gdkKeyvalToWindowsVK(keyval), | |
| 496 | - | NativeKeyCode: int32(keycode), | |
| 497 | - | Modifiers: translateModifiers(gdkMods), | |
| 498 | - | } | |
| 492 | + | evt := purecef.NewKeyEvent() | |
| 493 | + | evt.Type = eventType | |
| 494 | + | evt.WindowsKeyCode = gdkKeyvalToWindowsVK(keyval) | |
| 495 | + | evt.NativeKeyCode = int32(keycode) | |
| 496 | + | evt.Modifiers = translateModifiers(gdkMods) | |
| 497 | + | return evt | |
| 499 | 498 | } | |
| 500 | 499 | ||
| 501 | 500 | // translateModifiers maps GDK modifier masks to CEF EventFlags values. | |
| @@ -385,12 +385,11 @@ func (ib *inputBridge) onIMCommit(text string) { | |||||
| 385 | continue | 385 | continue | ||
| 386 | } | 386 | } | ||
| 387 | ch := uint16(r) | 387 | ch := uint16(r) | ||
| 388 | - | evt := purecef.KeyEvent{ | 388 | + | evt := purecef.NewKeyEvent() |
| 389 | - | Type: purecef.KeyEventTypeKeyeventChar, | 389 | + | evt.Type = purecef.KeyEventTypeKeyeventChar |
| 390 | - | WindowsKeyCode: int32(ch), | 390 | + | evt.WindowsKeyCode = int32(ch) |
| 391 | - | Character: ch, | 391 | + | evt.Character = ch |
| 392 | - | UnmodifiedCharacter: ch, | 392 | + | evt.UnmodifiedCharacter = ch |
| 393 | - | } | |||
| 394 | host.SendKeyEvent(&evt) | 393 | host.SendKeyEvent(&evt) | ||
| 395 | } | 394 | } | ||
| 396 | } | 395 | } | ||
| @@ -490,12 +489,12 @@ func buildMouseEvent(x, y float64, gdkMods uint, scale int32) purecef.MouseEvent | |||||
| 490 | } | 489 | } | ||
| 491 | 490 | ||||
| 492 | func buildKeyEvent(keyval, keycode, gdkMods uint, eventType purecef.KeyEventType) purecef.KeyEvent { | 491 | func buildKeyEvent(keyval, keycode, gdkMods uint, eventType purecef.KeyEventType) purecef.KeyEvent { | ||
| 493 | - | return purecef.KeyEvent{ | 492 | + | evt := purecef.NewKeyEvent() |
| 494 | - | Type: eventType, | 493 | + | evt.Type = eventType |
| 495 | - | WindowsKeyCode: gdkKeyvalToWindowsVK(keyval), | 494 | + | evt.WindowsKeyCode = gdkKeyvalToWindowsVK(keyval) |
| 496 | - | NativeKeyCode: int32(keycode), | 495 | + | evt.NativeKeyCode = int32(keycode) |
| 497 | - | Modifiers: translateModifiers(gdkMods), | 496 | + | evt.Modifiers = translateModifiers(gdkMods) |
| 498 | - | } | 497 | + | return evt |
| 499 | } | 498 | } | ||
| 500 | 499 | ||||
| 501 | // translateModifiers maps GDK modifier masks to CEF EventFlags values. | 500 | // translateModifiers maps GDK modifier masks to CEF EventFlags values. | ||
M internal/infrastructure/cef/webview.go +2 -2
| @@ -391,8 +391,8 @@ func (wv *WebView) OpenDevTools() { | |||
| 391 | 391 | if host == nil { | |
| 392 | 392 | return | |
| 393 | 393 | } | |
| 394 | - | windowInfo := purecef.WindowInfo{} | |
| 395 | - | settings := purecef.BrowserSettings{} | |
| 394 | + | windowInfo := purecef.NewWindowInfo() | |
| 395 | + | settings := purecef.NewBrowserSettings() | |
| 396 | 396 | host.ShowDevTools(&windowInfo, nil, &settings, nil) | |
| 397 | 397 | } | |
| 398 | 398 | ||
| @@ -391,8 +391,8 @@ func (wv *WebView) OpenDevTools() { | |||||
| 391 | if host == nil { | 391 | if host == nil { | ||
| 392 | return | 392 | return | ||
| 393 | } | 393 | } | ||
| 394 | - | windowInfo := purecef.WindowInfo{} | 394 | + | windowInfo := purecef.NewWindowInfo() |
| 395 | - | settings := purecef.BrowserSettings{} | 395 | + | settings := purecef.NewBrowserSettings() |
| 396 | host.ShowDevTools(&windowInfo, nil, &settings, nil) | 396 | host.ShowDevTools(&windowInfo, nil, &settings, nil) | ||
| 397 | } | 397 | } | ||
| 398 | 398 | ||||
M internal/infrastructure/cef/webview_handlers.go +7 -7
| @@ -145,13 +145,13 @@ func (h *handlerSet) GetScreenInfo(_ purecef.Browser, info *purecef.ScreenInfo) | |||
| 145 | 145 | screenDepthPerComponent = 8 | |
| 146 | 146 | ) | |
| 147 | 147 | r := purecef.Rect{X: 0, Y: 0, Width: w, Height: ht} | |
| 148 | - | *info = purecef.ScreenInfo{ | |
| 149 | - | DeviceScaleFactor: float32(s), | |
| 150 | - | Depth: screenDepth, | |
| 151 | - | DepthPerComponent: screenDepthPerComponent, | |
| 152 | - | Rect: r, | |
| 153 | - | AvailableRect: r, | |
| 154 | - | } | |
| 148 | + | si := purecef.NewScreenInfo() | |
| 149 | + | si.DeviceScaleFactor = float32(s) | |
| 150 | + | si.Depth = screenDepth | |
| 151 | + | si.DepthPerComponent = screenDepthPerComponent | |
| 152 | + | si.Rect = r | |
| 153 | + | si.AvailableRect = r | |
| 154 | + | *info = si | |
| 155 | 155 | if h.wv != nil && h.wv.ctx != nil { | |
| 156 | 156 | logging.FromContext(h.wv.ctx).Debug(). | |
| 157 | 157 | Uint64("screen_info_seq", callSeq). | |
| @@ -145,13 +145,13 @@ func (h *handlerSet) GetScreenInfo(_ purecef.Browser, info *purecef.ScreenInfo) | |||||
| 145 | screenDepthPerComponent = 8 | 145 | screenDepthPerComponent = 8 | ||
| 146 | ) | 146 | ) | ||
| 147 | r := purecef.Rect{X: 0, Y: 0, Width: w, Height: ht} | 147 | r := purecef.Rect{X: 0, Y: 0, Width: w, Height: ht} | ||
| 148 | - | *info = purecef.ScreenInfo{ | 148 | + | si := purecef.NewScreenInfo() |
| 149 | - | DeviceScaleFactor: float32(s), | 149 | + | si.DeviceScaleFactor = float32(s) |
| 150 | - | Depth: screenDepth, | 150 | + | si.Depth = screenDepth |
| 151 | - | DepthPerComponent: screenDepthPerComponent, | 151 | + | si.DepthPerComponent = screenDepthPerComponent |
| 152 | - | Rect: r, | 152 | + | si.Rect = r |
| 153 | - | AvailableRect: r, | 153 | + | si.AvailableRect = r |
| 154 | - | } | 154 | + | *info = si |
| 155 | if h.wv != nil && h.wv.ctx != nil { | 155 | if h.wv != nil && h.wv.ctx != nil { | ||
| 156 | logging.FromContext(h.wv.ctx).Debug(). | 156 | logging.FromContext(h.wv.ctx).Debug(). | ||
| 157 | Uint64("screen_info_seq", callSeq). | 157 | Uint64("screen_info_seq", callSeq). | ||
M internal/infrastructure/cef/webview_handlers_test.go +2 -1
| @@ -83,7 +83,8 @@ func TestGetViewRectUsesDIPCoordinates(t *testing.T) { | |||
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | 85 | func TestGetScreenInfoUsesDIPRectAndScale(t *testing.T) { | |
| 86 | - | info := &purecef.ScreenInfo{} | |
| 86 | + | si := purecef.NewScreenInfo() | |
| 87 | + | info := &si | |
| 87 | 88 | h := &handlerSet{ | |
| 88 | 89 | wv: &WebView{ | |
| 89 | 90 | ctx: context.Background(), | |
| @@ -83,7 +83,8 @@ func TestGetViewRectUsesDIPCoordinates(t *testing.T) { | |||||
| 83 | } | 83 | } | ||
| 84 | 84 | ||||
| 85 | func TestGetScreenInfoUsesDIPRectAndScale(t *testing.T) { | 85 | func TestGetScreenInfoUsesDIPRectAndScale(t *testing.T) { | ||
| 86 | - | info := &purecef.ScreenInfo{} | 86 | + | si := purecef.NewScreenInfo() |
| 87 | + | info := &si | |||
| 87 | h := &handlerSet{ | 88 | h := &handlerSet{ | ||
| 88 | wv: &WebView{ | 89 | wv: &WebView{ | ||
| 89 | ctx: context.Background(), | 90 | ctx: context.Background(), | ||
M internal/infrastructure/persistence/sqlite/connection.go +1 -1
| @@ -27,7 +27,7 @@ func NewConnection(ctx context.Context, dbPath string) (*sql.DB, error) { | |||
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | 29 | // Open database connection | |
| 30 | - | db, err := sql.Open("sqlite", dbPath) | |
| 30 | + | db, err := sql.Open("sqlite3", dbPath) | |
| 31 | 31 | if err != nil { | |
| 32 | 32 | return nil, fmt.Errorf("failed to open database: %w", err) | |
| 33 | 33 | } | |
| @@ -27,7 +27,7 @@ func NewConnection(ctx context.Context, dbPath string) (*sql.DB, error) { | |||||
| 27 | } | 27 | } | ||
| 28 | 28 | ||||
| 29 | // Open database connection | 29 | // Open database connection | ||
| 30 | - | db, err := sql.Open("sqlite", dbPath) | 30 | + | db, err := sql.Open("sqlite3", dbPath) |
| 31 | if err != nil { | 31 | if err != nil { | ||
| 32 | return nil, fmt.Errorf("failed to open database: %w", err) | 32 | return nil, fmt.Errorf("failed to open database: %w", err) | ||
| 33 | } | 33 | } | ||