roxane 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/roxane/ffi.rb +7 -0
- data/lib/roxane/version.rb +1 -1
- data/lib/roxane/webkit.rb +38 -0
- data/lib/roxane/window.rb +26 -0
- data/lib/roxane.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0ef9393493008dcc4763293fa6ebd36ebb6fdd891b1e2358100eb442ed729ec
|
|
4
|
+
data.tar.gz: 1fbfe739d81d37b48fcaf9ac428db7d60319c864a63e6b3a9ef9819cb305a65f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a84c3f0dc6f20488b7d1bfea51a327fafa1b77e4cd393685645b64e843dc8609c3eeb2a5fc6ab7cff8ec810610cd36afafc8766860003732073b8111464e11f
|
|
7
|
+
data.tar.gz: 100d61215f9c9c821da5c76648ac6bebd4b59a19aabf342f8928246fe8530243730a73128c013cdb094d3555f4d9933e5bb5e1ff115b2506dcbdcb4891bb4a8c
|
data/lib/roxane/ffi.rb
CHANGED
|
@@ -15,6 +15,12 @@ module Roxane
|
|
|
15
15
|
HINT_MAX = 2
|
|
16
16
|
HINT_FIXED = 3
|
|
17
17
|
|
|
18
|
+
# webview_native_handle_kind_t — BROWSER_CONTROLLER is the engine view
|
|
19
|
+
# (WebKitWebView* on GTK), the door to engine calls webview doesn't wrap.
|
|
20
|
+
NATIVE_HANDLE_UI_WINDOW = 0
|
|
21
|
+
NATIVE_HANDLE_UI_WIDGET = 1
|
|
22
|
+
NATIVE_HANDLE_BROWSER_CONTROLLER = 2
|
|
23
|
+
|
|
18
24
|
begin
|
|
19
25
|
ffi_lib Roxane.library_path
|
|
20
26
|
|
|
@@ -31,6 +37,7 @@ module Roxane
|
|
|
31
37
|
attach_function :webview_set_html, [:pointer, :string], :int
|
|
32
38
|
attach_function :webview_init, [:pointer, :string], :int
|
|
33
39
|
attach_function :webview_eval, [:pointer, :string], :int
|
|
40
|
+
attach_function :webview_get_native_handle, [:pointer, :int], :pointer
|
|
34
41
|
|
|
35
42
|
callback :bind_fn, [:string, :string, :pointer], :void
|
|
36
43
|
attach_function :webview_bind, [:pointer, :string, :bind_fn, :pointer], :int
|
data/lib/roxane/version.rb
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Roxane
|
|
4
|
+
# Direct WebKitGTK bindings for the few affordances the webview C API doesn't
|
|
5
|
+
# wrap (today: full-content zoom). On Linux the library is already linked into
|
|
6
|
+
# the process by libwebview — we bind the soname libwebview itself links (4.1,
|
|
7
|
+
# falling back to 4.0). Where neither loads (macOS/Windows — their engines get
|
|
8
|
+
# their own bindings later), AVAILABLE is false and callers no-op gracefully.
|
|
9
|
+
module WebKit
|
|
10
|
+
extend ::FFI::Library
|
|
11
|
+
|
|
12
|
+
begin
|
|
13
|
+
ffi_lib ["libwebkit2gtk-4.1.so.0", "libwebkit2gtk-4.0.so.37"]
|
|
14
|
+
attach_function :webkit_web_view_set_zoom_level, [:pointer, :double], :void
|
|
15
|
+
attach_function :webkit_web_view_get_zoom_level, [:pointer], :double
|
|
16
|
+
AVAILABLE = true
|
|
17
|
+
rescue LoadError, ::FFI::NotFoundError
|
|
18
|
+
AVAILABLE = false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# GLib main-loop scheduling. g_idle_add is thread-safe and runs the callback
|
|
23
|
+
# as a TOP-LEVEL main-loop iteration — a clean stack, never nested inside a
|
|
24
|
+
# webview dispatch callback (layout-triggering WebKit calls made from inside
|
|
25
|
+
# one can reenter the engine and crash; see the zoom work, 2026-07-03).
|
|
26
|
+
module GLib
|
|
27
|
+
extend ::FFI::Library
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
ffi_lib "libglib-2.0.so.0"
|
|
31
|
+
callback :g_source_func, [:pointer], :int
|
|
32
|
+
attach_function :g_idle_add, [:g_source_func, :pointer], :uint
|
|
33
|
+
AVAILABLE = true
|
|
34
|
+
rescue LoadError, ::FFI::NotFoundError
|
|
35
|
+
AVAILABLE = false
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/roxane/window.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Roxane
|
|
|
26
26
|
@on_close = nil
|
|
27
27
|
@server = nil
|
|
28
28
|
@ui_queue = Queue.new # procs to run on the UI thread
|
|
29
|
+
@zoom = 1.0
|
|
29
30
|
|
|
30
31
|
@w = FFI.webview_create(debug ? 1 : 0, nil)
|
|
31
32
|
raise Error, "could not create webview" if @w.null?
|
|
@@ -83,6 +84,31 @@ module Roxane
|
|
|
83
84
|
self
|
|
84
85
|
end
|
|
85
86
|
|
|
87
|
+
# Full-content zoom, like a browser's Ctrl+± (1.0 = natural size). Backed by
|
|
88
|
+
# the engine's native zoom (WebKitGTK today); where that binding isn't
|
|
89
|
+
# available the setter no-ops and the reader reports the last requested
|
|
90
|
+
# level. Safe from any thread: scheduled with g_idle_add, which runs on the
|
|
91
|
+
# UI thread as a TOP-LEVEL loop iteration — never nested inside a webview
|
|
92
|
+
# dispatch callback, where a layout-triggering WebKit call can reenter the
|
|
93
|
+
# engine mid-resolve and crash it. Rapid calls coalesce (each application
|
|
94
|
+
# reads the latest requested level; extra idles are harmless).
|
|
95
|
+
def zoom
|
|
96
|
+
@zoom
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def zoom=(factor)
|
|
100
|
+
@zoom = Float(factor)
|
|
101
|
+
return unless WebKit::AVAILABLE && GLib::AVAILABLE
|
|
102
|
+
|
|
103
|
+
@apply_zoom ||= ::FFI::Function.new(:int, [:pointer]) do |_data|
|
|
104
|
+
view = FFI.webview_get_native_handle(@w, FFI::NATIVE_HANDLE_BROWSER_CONTROLLER)
|
|
105
|
+
WebKit.webkit_web_view_set_zoom_level(view, @zoom) unless view.null?
|
|
106
|
+
0 # G_SOURCE_REMOVE
|
|
107
|
+
end
|
|
108
|
+
@callbacks << @apply_zoom unless @callbacks.include?(@apply_zoom)
|
|
109
|
+
GLib.g_idle_add(@apply_zoom, nil)
|
|
110
|
+
end
|
|
111
|
+
|
|
86
112
|
def on_close(&block)
|
|
87
113
|
@on_close = block
|
|
88
114
|
self
|
data/lib/roxane.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roxane
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BKK Riese
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -41,6 +41,7 @@ files:
|
|
|
41
41
|
- lib/roxane/ffi.rb
|
|
42
42
|
- lib/roxane/static_server.rb
|
|
43
43
|
- lib/roxane/version.rb
|
|
44
|
+
- lib/roxane/webkit.rb
|
|
44
45
|
- lib/roxane/window.rb
|
|
45
46
|
homepage: https://github.com/quarterstack/roxane
|
|
46
47
|
licenses:
|