Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 334898c5a5 | |||
| 67a5f1bb0b |
@ -92,5 +92,5 @@ check_release:
|
|||||||
refs:
|
refs:
|
||||||
- master
|
- master
|
||||||
script:
|
script:
|
||||||
- apt-get -y install git python3
|
- apt-get install git python3
|
||||||
- (head -n 1 ./debian/changelog && git tag) | ./debian/check_release.py
|
- (head -n 1 ./debian/changelog && git tag) | ./debian/check_release.py
|
||||||
|
|||||||
84
Cargo.lock
generated
84
Cargo.lock
generated
@ -2,10 +2,10 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.8"
|
version = "0.7.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -15,7 +15,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ dependencies = [
|
|||||||
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -44,7 +44,7 @@ dependencies = [
|
|||||||
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -89,7 +89,7 @@ dependencies = [
|
|||||||
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ dependencies = [
|
|||||||
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -115,7 +115,7 @@ dependencies = [
|
|||||||
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ dependencies = [
|
|||||||
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -146,7 +146,7 @@ dependencies = [
|
|||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -156,7 +156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ dependencies = [
|
|||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -177,7 +177,7 @@ name = "glib-sys"
|
|||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ version = "0.7.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ dependencies = [
|
|||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ dependencies = [
|
|||||||
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -239,7 +239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.66"
|
version = "0.2.67"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -254,7 +254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.3.2"
|
version = "2.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -262,7 +262,7 @@ name = "memmap"
|
|||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ dependencies = [
|
|||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.8"
|
version = "1.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -306,10 +306,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -317,16 +317,16 @@ name = "regex"
|
|||||||
version = "1.1.9"
|
version = "1.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aho-corasick 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex-syntax 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.6.14"
|
version = "0.6.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -363,9 +363,9 @@ name = "serde_derive"
|
|||||||
version = "1.0.104"
|
version = "1.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -381,11 +381,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.14"
|
version = "1.0.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ name = "xkbcommon"
|
|||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811"
|
"checksum aho-corasick 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d5e63fd144e18ba274ae7095c0197a870a7b9468abc801dd62f190d80817d2ec"
|
||||||
"checksum atk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7017e53393e713212aed7aea336b6553be4927f58c37070a56c2fe3d107e489"
|
"checksum atk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7017e53393e713212aed7aea336b6553be4927f58c37070a56c2fe3d107e489"
|
||||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||||
"checksum cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd940f0d609699e343ef71c4af5f66423afbf30d666f796dabd8fd15229cf5b6"
|
"checksum cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd940f0d609699e343ef71c4af5f66423afbf30d666f796dabd8fd15229cf5b6"
|
||||||
@ -478,22 +478,22 @@ dependencies = [
|
|||||||
"checksum gtk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a6b30f194f09a17bb7ffa95c3ecdb405abd3b75ff981f831b1f6d18fe115ff"
|
"checksum gtk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a6b30f194f09a17bb7ffa95c3ecdb405abd3b75ff981f831b1f6d18fe115ff"
|
||||||
"checksum gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d487d333a4b87072e6bf9f2e55befa0ebef01b9496c2e263c0f4a1ff3d6c04b1"
|
"checksum gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d487d333a4b87072e6bf9f2e55befa0ebef01b9496c2e263c0f4a1ff3d6c04b1"
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
|
||||||
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
|
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
|
||||||
"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||||
"checksum memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53445de381a1f436797497c61d851644d0e8e88e6140f22872ad33a704933978"
|
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||||
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
||||||
"checksum pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c2cb169402a3eb1ba034a7cc7d95b8b1c106e9be5ba4be79a5a93dc1a2795f4"
|
"checksum pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c2cb169402a3eb1ba034a7cc7d95b8b1c106e9be5ba4be79a5a93dc1a2795f4"
|
||||||
"checksum pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6eb49268e69dd0c1da5d3001a61aac08e2e9d2bfbe4ae4b19b9963c998f6453"
|
"checksum pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6eb49268e69dd0c1da5d3001a61aac08e2e9d2bfbe4ae4b19b9963c998f6453"
|
||||||
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
|
||||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||||
"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad"
|
"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad"
|
||||||
"checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06"
|
"checksum regex-syntax 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1"
|
||||||
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
|
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
|
||||||
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
|
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
|
||||||
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
|
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
|
||||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
"checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
|
||||||
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
|
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
|
||||||
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
||||||
"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
|
"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
|
||||||
|
|||||||
20
debian/changelog
vendored
20
debian/changelog
vendored
@ -1,3 +1,23 @@
|
|||||||
|
squeekboard (1.9.1) amber-phone; urgency=medium
|
||||||
|
|
||||||
|
[ Dorota Czaplejewicz ]
|
||||||
|
* layout: Improve press handling
|
||||||
|
* settings: Handle empty settings
|
||||||
|
* Variant: Use proper pointer conversion between C and Rust
|
||||||
|
* meta: Add doap file
|
||||||
|
* modifiers: Support Control and Alt
|
||||||
|
* CI: Test that any bump to changelog has a corresponding tag
|
||||||
|
* docs: Add the guiding principle
|
||||||
|
* hacking: Move into docs/
|
||||||
|
|
||||||
|
[ &t ]
|
||||||
|
* Fix minor comment typos
|
||||||
|
|
||||||
|
[ Dorota Czaplejewicz ]
|
||||||
|
* cargo: Bump package versions before release
|
||||||
|
|
||||||
|
-- Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Sun, 08 Mar 2020 10:04:29 +0000
|
||||||
|
|
||||||
squeekboard (1.9.0) amber-phone; urgency=medium
|
squeekboard (1.9.0) amber-phone; urgency=medium
|
||||||
|
|
||||||
[ Dorota Czaplejewicz ]
|
[ Dorota Czaplejewicz ]
|
||||||
|
|||||||
@ -41,15 +41,23 @@
|
|||||||
#include "src/layout.h"
|
#include "src/layout.h"
|
||||||
#include "src/submission.h"
|
#include "src/submission.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
/* since 2.91.5 GDK_DRAWABLE was removed and gdk_cairo_create takes
|
||||||
|
GdkWindow as the argument */
|
||||||
|
#ifndef GDK_DRAWABLE
|
||||||
|
#define GDK_DRAWABLE(x) (x)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _EekGtkKeyboardPrivate
|
typedef struct _EekGtkKeyboardPrivate
|
||||||
{
|
{
|
||||||
EekRenderer *renderer; // owned, nullable
|
EekRenderer *renderer;
|
||||||
LayoutHolder *eekboard_context; // unowned reference
|
EekboardContextService *eekboard_context; // unowned reference
|
||||||
struct submission *submission; // unowned reference
|
struct submission *submission; // unowned reference
|
||||||
|
LevelKeyboard *keyboard; // unowned reference; it's kept in server-context (FIXME)
|
||||||
struct squeek_layout_state *layout; // unowned
|
|
||||||
LevelKeyboard *keyboard; // unowned reference; it's kept in server-context
|
|
||||||
|
|
||||||
GdkEventSequence *sequence; // unowned reference
|
GdkEventSequence *sequence; // unowned reference
|
||||||
} EekGtkKeyboardPrivate;
|
} EekGtkKeyboardPrivate;
|
||||||
@ -80,59 +88,30 @@ eek_gtk_keyboard_real_draw (GtkWidget *self,
|
|||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
gtk_widget_get_allocation (self, &allocation);
|
gtk_widget_get_allocation (self, &allocation);
|
||||||
|
|
||||||
if (!priv->keyboard) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!priv->renderer) {
|
if (!priv->renderer) {
|
||||||
PangoContext *pcontext = gtk_widget_get_pango_context (self);
|
PangoContext *pcontext = gtk_widget_get_pango_context (self);
|
||||||
|
|
||||||
priv->renderer = eek_renderer_new (
|
priv->renderer = eek_renderer_new (priv->keyboard, pcontext);
|
||||||
priv->keyboard,
|
|
||||||
pcontext);
|
|
||||||
|
|
||||||
eek_renderer_set_allocation_size (priv->renderer,
|
eek_renderer_set_allocation_size (priv->renderer,
|
||||||
priv->keyboard->layout,
|
|
||||||
allocation.width,
|
allocation.width,
|
||||||
allocation.height);
|
allocation.height);
|
||||||
eek_renderer_set_scale_factor (priv->renderer,
|
eek_renderer_set_scale_factor (priv->renderer,
|
||||||
gtk_widget_get_scale_factor (self));
|
gtk_widget_get_scale_factor (self));
|
||||||
}
|
}
|
||||||
|
eek_renderer_render_keyboard (priv->renderer, priv->submission, cr);
|
||||||
eek_renderer_render_keyboard (priv->renderer, priv->submission, cr, priv->keyboard);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Units of pixel size
|
|
||||||
static enum squeek_arrangement_kind get_type(uint32_t width, uint32_t height) {
|
|
||||||
(void)height;
|
|
||||||
if (width < 1080) {
|
|
||||||
return ARRANGEMENT_KIND_BASE;
|
|
||||||
}
|
|
||||||
return ARRANGEMENT_KIND_WIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_gtk_keyboard_real_size_allocate (GtkWidget *self,
|
eek_gtk_keyboard_real_size_allocate (GtkWidget *self,
|
||||||
GtkAllocation *allocation)
|
GtkAllocation *allocation)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv =
|
EekGtkKeyboardPrivate *priv =
|
||||||
eek_gtk_keyboard_get_instance_private (EEK_GTK_KEYBOARD (self));
|
eek_gtk_keyboard_get_instance_private (EEK_GTK_KEYBOARD (self));
|
||||||
uint32_t scale = (uint32_t)gtk_widget_get_scale_factor(self);
|
|
||||||
// check if the change would switch types
|
|
||||||
enum squeek_arrangement_kind new_type = get_type(
|
|
||||||
(uint32_t)(allocation->width - allocation->x) * scale,
|
|
||||||
(uint32_t)(allocation->height - allocation->y) * scale);
|
|
||||||
if (priv->layout->arrangement != new_type) {
|
|
||||||
struct squeek_layout_state layout = *priv->layout;
|
|
||||||
layout.arrangement = new_type;
|
|
||||||
|
|
||||||
eek_layout_holder_use_layout(priv->eekboard_context, &layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->renderer)
|
if (priv->renderer)
|
||||||
eek_renderer_set_allocation_size (priv->renderer,
|
eek_renderer_set_allocation_size (priv->renderer,
|
||||||
priv->keyboard->layout,
|
|
||||||
allocation->width,
|
allocation->width,
|
||||||
allocation->height);
|
allocation->height);
|
||||||
|
|
||||||
@ -144,9 +123,7 @@ static void depress(EekGtkKeyboard *self,
|
|||||||
gdouble x, gdouble y, guint32 time)
|
gdouble x, gdouble y, guint32 time)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||||
if (!priv->keyboard) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
squeek_layout_depress(priv->keyboard->layout,
|
squeek_layout_depress(priv->keyboard->layout,
|
||||||
priv->submission,
|
priv->submission,
|
||||||
x, y, eek_renderer_get_transformation(priv->renderer), time, self);
|
x, y, eek_renderer_get_transformation(priv->renderer), time, self);
|
||||||
@ -156,10 +133,7 @@ static void drag(EekGtkKeyboard *self,
|
|||||||
gdouble x, gdouble y, guint32 time)
|
gdouble x, gdouble y, guint32 time)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||||
if (!priv->keyboard) {
|
squeek_layout_drag(priv->keyboard->layout,
|
||||||
return;
|
|
||||||
}
|
|
||||||
squeek_layout_drag(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout,
|
|
||||||
priv->submission,
|
priv->submission,
|
||||||
x, y, eek_renderer_get_transformation(priv->renderer), time,
|
x, y, eek_renderer_get_transformation(priv->renderer), time,
|
||||||
priv->eekboard_context, self);
|
priv->eekboard_context, self);
|
||||||
@ -168,10 +142,8 @@ static void drag(EekGtkKeyboard *self,
|
|||||||
static void release(EekGtkKeyboard *self, guint32 time)
|
static void release(EekGtkKeyboard *self, guint32 time)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||||
if (!priv->keyboard) {
|
|
||||||
return;
|
squeek_layout_release(priv->keyboard->layout,
|
||||||
}
|
|
||||||
squeek_layout_release(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout,
|
|
||||||
priv->submission,
|
priv->submission,
|
||||||
eek_renderer_get_transformation(priv->renderer), time,
|
eek_renderer_get_transformation(priv->renderer), time,
|
||||||
priv->eekboard_context, self);
|
priv->eekboard_context, self);
|
||||||
@ -291,7 +263,7 @@ eek_gtk_keyboard_dispose (GObject *object)
|
|||||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||||
|
|
||||||
if (priv->renderer) {
|
if (priv->renderer) {
|
||||||
eek_renderer_free(priv->renderer);
|
g_object_unref (priv->renderer);
|
||||||
priv->renderer = NULL;
|
priv->renderer = NULL;
|
||||||
priv->renderer = NULL;
|
priv->renderer = NULL;
|
||||||
}
|
}
|
||||||
@ -338,46 +310,26 @@ eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
|||||||
(void)self;
|
(void)self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
on_notify_keyboard (GObject *object,
|
|
||||||
GParamSpec *spec,
|
|
||||||
EekGtkKeyboard *self) {
|
|
||||||
(void)spec;
|
|
||||||
EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (self);
|
|
||||||
priv->keyboard = eek_layout_holder_get_keyboard(LAYOUT_HOLDER(object));
|
|
||||||
if (priv->renderer) {
|
|
||||||
eek_renderer_free(priv->renderer);
|
|
||||||
}
|
|
||||||
priv->renderer = NULL;
|
|
||||||
gtk_widget_queue_draw(GTK_WIDGET(self));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* eek_gtk_keyboard_new:
|
||||||
|
* @keyboard: an #EekKeyboard
|
||||||
|
*
|
||||||
* Create a new #GtkWidget displaying @keyboard.
|
* Create a new #GtkWidget displaying @keyboard.
|
||||||
* Returns: a #GtkWidget
|
* Returns: a #GtkWidget
|
||||||
*/
|
*/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
eek_gtk_keyboard_new (LayoutHolder *eekservice,
|
eek_gtk_keyboard_new (LevelKeyboard *keyboard, EekboardContextService *eekservice,
|
||||||
struct submission *submission,
|
struct submission *submission)
|
||||||
struct squeek_layout_state *layout)
|
|
||||||
{
|
{
|
||||||
EekGtkKeyboard *ret = EEK_GTK_KEYBOARD(g_object_new (EEK_TYPE_GTK_KEYBOARD, NULL));
|
EekGtkKeyboard *ret = EEK_GTK_KEYBOARD(g_object_new (EEK_TYPE_GTK_KEYBOARD, NULL));
|
||||||
EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (ret);
|
EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (ret);
|
||||||
|
priv->keyboard = keyboard;
|
||||||
priv->eekboard_context = eekservice;
|
priv->eekboard_context = eekservice;
|
||||||
priv->submission = submission;
|
priv->submission = submission;
|
||||||
priv->layout = layout;
|
|
||||||
priv->renderer = NULL;
|
|
||||||
g_signal_connect (eekservice,
|
|
||||||
"notify::keyboard",
|
|
||||||
G_CALLBACK(on_notify_keyboard),
|
|
||||||
ret);
|
|
||||||
on_notify_keyboard(G_OBJECT(eekservice), NULL, ret);
|
|
||||||
/* TODO: this is how a compound keyboard
|
|
||||||
* made out of a layout and a suggestion bar could start.
|
|
||||||
* GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
|
|
||||||
GtkEntry *fill = GTK_ENTRY(gtk_entry_new());
|
|
||||||
gtk_box_pack_start(box, GTK_WIDGET(fill), FALSE, FALSE, 0);
|
|
||||||
gtk_box_pack_start(box, GTK_WIDGET(ret), TRUE, TRUE, 0);
|
|
||||||
return GTK_WIDGET(box);*/
|
|
||||||
return GTK_WIDGET(ret);
|
return GTK_WIDGET(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EekRenderer *eek_gtk_keyboard_get_renderer(EekGtkKeyboard *self) {
|
||||||
|
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||||
|
return priv->renderer;
|
||||||
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#include "eek/eek-types.h"
|
#include "eek/eek-types.h"
|
||||||
|
|
||||||
struct submission;
|
struct submission;
|
||||||
struct squeek_layout_state;
|
typedef struct _LevelKeyboard LevelKeyboard; // including causes weird bugs
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define EEK_TYPE_GTK_KEYBOARD (eek_gtk_keyboard_get_type())
|
#define EEK_TYPE_GTK_KEYBOARD (eek_gtk_keyboard_get_type())
|
||||||
@ -48,7 +48,7 @@ struct _EekGtkKeyboardClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
GType eek_gtk_keyboard_get_type (void) G_GNUC_CONST;
|
GType eek_gtk_keyboard_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget *eek_gtk_keyboard_new (LayoutHolder *eekservice, struct submission *submission, struct squeek_layout_state *layout);
|
GtkWidget *eek_gtk_keyboard_new (LevelKeyboard *keyboard, EekboardContextService *eekservice, struct submission *submission);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEK_GTK_KEYBOARD_H */
|
#endif /* EEK_GTK_KEYBOARD_H */
|
||||||
|
|||||||
@ -38,8 +38,10 @@ void level_keyboard_free(LevelKeyboard *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LevelKeyboard*
|
LevelKeyboard*
|
||||||
level_keyboard_new (struct squeek_layout *layout)
|
level_keyboard_new (const gchar *keyboard_type,
|
||||||
|
enum squeek_arrangement_kind t)
|
||||||
{
|
{
|
||||||
|
struct squeek_layout *layout = squeek_load_layout(keyboard_type, t);
|
||||||
LevelKeyboard *keyboard = g_new0(LevelKeyboard, 1);
|
LevelKeyboard *keyboard = g_new0(LevelKeyboard, 1);
|
||||||
|
|
||||||
if (!keyboard) {
|
if (!keyboard) {
|
||||||
|
|||||||
@ -47,7 +47,8 @@ gchar * eek_keyboard_get_keymap
|
|||||||
(LevelKeyboard *keyboard);
|
(LevelKeyboard *keyboard);
|
||||||
|
|
||||||
LevelKeyboard*
|
LevelKeyboard*
|
||||||
level_keyboard_new (struct squeek_layout *layout);
|
level_keyboard_new (const gchar *keyboard_type,
|
||||||
|
enum squeek_arrangement_kind t);
|
||||||
void level_keyboard_free(LevelKeyboard *self);
|
void level_keyboard_free(LevelKeyboard *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -28,6 +28,27 @@
|
|||||||
#include "eek-renderer.h"
|
#include "eek-renderer.h"
|
||||||
#include "src/style.h"
|
#include "src/style.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_PCONTEXT,
|
||||||
|
PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _EekRendererPrivate
|
||||||
|
{
|
||||||
|
LevelKeyboard *keyboard; // unowned
|
||||||
|
PangoContext *pcontext; // owned
|
||||||
|
GtkCssProvider *css_provider; // owned
|
||||||
|
GtkStyleContext *view_context; // owned
|
||||||
|
GtkStyleContext *button_context; // TODO: maybe move a copy to each button
|
||||||
|
|
||||||
|
gdouble allocation_width;
|
||||||
|
gdouble allocation_height;
|
||||||
|
gint scale_factor; /* the outputs scale factor */
|
||||||
|
struct transformation widget_to_layout;
|
||||||
|
} EekRendererPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE (EekRenderer, eek_renderer, G_TYPE_OBJECT)
|
||||||
|
|
||||||
/* eek-keyboard-drawing.c */
|
/* eek-keyboard-drawing.c */
|
||||||
static void render_button_label (cairo_t *cr, GtkStyleContext *ctx,
|
static void render_button_label (cairo_t *cr, GtkStyleContext *ctx,
|
||||||
@ -117,7 +138,9 @@ eek_render_button (EekRenderer *self,
|
|||||||
gboolean pressed,
|
gboolean pressed,
|
||||||
gboolean locked)
|
gboolean locked)
|
||||||
{
|
{
|
||||||
GtkStyleContext *ctx = self->button_context;
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||||
|
|
||||||
|
GtkStyleContext *ctx = priv->button_context;
|
||||||
/* Set the name of the button on the widget path, using the name obtained
|
/* Set the name of the button on the widget path, using the name obtained
|
||||||
from the button's symbol. */
|
from the button's symbol. */
|
||||||
g_autoptr (GtkWidgetPath) path = NULL;
|
g_autoptr (GtkWidgetPath) path = NULL;
|
||||||
@ -137,7 +160,7 @@ eek_render_button (EekRenderer *self,
|
|||||||
}
|
}
|
||||||
gtk_style_context_add_class(ctx, outline_name);
|
gtk_style_context_add_class(ctx, outline_name);
|
||||||
|
|
||||||
render_button_in_context(self->scale_factor, cr, ctx, button);
|
render_button_in_context(priv->scale_factor, cr, ctx, button);
|
||||||
|
|
||||||
// Save and restore functions don't work if gtk_render_* was used in between
|
// Save and restore functions don't work if gtk_render_* was used in between
|
||||||
gtk_style_context_set_state(ctx, GTK_STATE_FLAG_NORMAL);
|
gtk_style_context_set_state(ctx, GTK_STATE_FLAG_NORMAL);
|
||||||
@ -195,42 +218,116 @@ render_button_label (cairo_t *cr,
|
|||||||
void
|
void
|
||||||
eek_renderer_render_keyboard (EekRenderer *self,
|
eek_renderer_render_keyboard (EekRenderer *self,
|
||||||
struct submission *submission,
|
struct submission *submission,
|
||||||
cairo_t *cr,
|
cairo_t *cr)
|
||||||
LevelKeyboard *keyboard)
|
|
||||||
{
|
{
|
||||||
g_return_if_fail (self->allocation_width > 0.0);
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||||
g_return_if_fail (self->allocation_height > 0.0);
|
|
||||||
|
g_return_if_fail (priv->keyboard);
|
||||||
|
g_return_if_fail (priv->allocation_width > 0.0);
|
||||||
|
g_return_if_fail (priv->allocation_height > 0.0);
|
||||||
|
|
||||||
/* Paint the background covering the entire widget area */
|
/* Paint the background covering the entire widget area */
|
||||||
gtk_render_background (self->view_context,
|
gtk_render_background (priv->view_context,
|
||||||
cr,
|
cr,
|
||||||
0, 0,
|
0, 0,
|
||||||
self->allocation_width, self->allocation_height);
|
priv->allocation_width, priv->allocation_height);
|
||||||
|
|
||||||
cairo_save(cr);
|
cairo_save(cr);
|
||||||
cairo_translate (cr, self->widget_to_layout.origin_x, self->widget_to_layout.origin_y);
|
cairo_translate (cr, priv->widget_to_layout.origin_x, priv->widget_to_layout.origin_y);
|
||||||
cairo_scale (cr, self->widget_to_layout.scale, self->widget_to_layout.scale);
|
cairo_scale (cr, priv->widget_to_layout.scale, priv->widget_to_layout.scale);
|
||||||
|
|
||||||
squeek_draw_layout_base_view(keyboard->layout, self, cr);
|
squeek_draw_layout_base_view(priv->keyboard->layout, self, cr);
|
||||||
squeek_layout_draw_all_changed(keyboard->layout, self, cr, submission);
|
squeek_layout_draw_all_changed(priv->keyboard->layout, self, cr, submission);
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
eek_renderer_free (EekRenderer *self)
|
eek_renderer_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
if (self->pcontext) {
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (
|
||||||
g_object_unref (self->pcontext);
|
EEK_RENDERER(object));
|
||||||
self->pcontext = NULL;
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PCONTEXT:
|
||||||
|
priv->pcontext = g_value_get_object (value);
|
||||||
|
g_object_ref (priv->pcontext);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
g_object_unref(self->css_provider);
|
}
|
||||||
g_object_unref(self->view_context);
|
|
||||||
g_object_unref(self->button_context);
|
static void
|
||||||
|
eek_renderer_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
(void)value;
|
||||||
|
switch (prop_id) {
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eek_renderer_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
EekRenderer *self = EEK_RENDERER (object);
|
||||||
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||||
|
|
||||||
|
if (priv->keyboard) {
|
||||||
|
priv->keyboard = NULL;
|
||||||
|
}
|
||||||
|
if (priv->pcontext) {
|
||||||
|
g_object_unref (priv->pcontext);
|
||||||
|
priv->pcontext = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// this is where renderer-specific surfaces would be released
|
// this is where renderer-specific surfaces would be released
|
||||||
|
|
||||||
free(self);
|
G_OBJECT_CLASS (eek_renderer_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eek_renderer_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
EekRenderer *self = EEK_RENDERER(object);
|
||||||
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||||
|
|
||||||
|
g_object_unref(priv->css_provider);
|
||||||
|
g_object_unref(priv->view_context);
|
||||||
|
g_object_unref(priv->button_context);
|
||||||
|
G_OBJECT_CLASS (eek_renderer_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eek_renderer_class_init (EekRendererClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
|
gobject_class->set_property = eek_renderer_set_property;
|
||||||
|
gobject_class->get_property = eek_renderer_get_property;
|
||||||
|
gobject_class->dispose = eek_renderer_dispose;
|
||||||
|
gobject_class->finalize = eek_renderer_finalize;
|
||||||
|
|
||||||
|
pspec = g_param_spec_object ("pango-context",
|
||||||
|
"Pango Context",
|
||||||
|
"Pango Context",
|
||||||
|
PANGO_TYPE_CONTEXT,
|
||||||
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PCONTEXT,
|
||||||
|
pspec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static GType new_type(char *name) {
|
static GType new_type(char *name) {
|
||||||
GTypeInfo info = {0};
|
GTypeInfo info = {0};
|
||||||
info.class_size = sizeof(GtkWidgetClass);
|
info.class_size = sizeof(GtkWidgetClass);
|
||||||
@ -258,75 +355,81 @@ static GType button_type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
renderer_init (EekRenderer *self)
|
eek_renderer_init (EekRenderer *self)
|
||||||
{
|
{
|
||||||
self->pcontext = NULL;
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||||
self->allocation_width = 0.0;
|
|
||||||
self->allocation_height = 0.0;
|
priv->keyboard = NULL;
|
||||||
self->scale_factor = 1;
|
priv->pcontext = NULL;
|
||||||
|
priv->allocation_width = 0.0;
|
||||||
|
priv->allocation_height = 0.0;
|
||||||
|
priv->scale_factor = 1;
|
||||||
|
|
||||||
GtkIconTheme *theme = gtk_icon_theme_get_default ();
|
GtkIconTheme *theme = gtk_icon_theme_get_default ();
|
||||||
|
|
||||||
gtk_icon_theme_add_resource_path (theme, "/sm/puri/squeekboard/icons");
|
gtk_icon_theme_add_resource_path (theme, "/sm/puri/squeekboard/icons");
|
||||||
|
|
||||||
self->css_provider = squeek_load_style();
|
priv->css_provider = squeek_load_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
EekRenderer *
|
EekRenderer *
|
||||||
eek_renderer_new (LevelKeyboard *keyboard,
|
eek_renderer_new (LevelKeyboard *keyboard,
|
||||||
PangoContext *pcontext)
|
PangoContext *pcontext)
|
||||||
{
|
{
|
||||||
EekRenderer *renderer = calloc(1, sizeof(EekRenderer));
|
EekRenderer *renderer = g_object_new (EEK_TYPE_RENDERER,
|
||||||
renderer_init(renderer);
|
"pango-context", pcontext,
|
||||||
renderer->pcontext = pcontext;
|
NULL);
|
||||||
g_object_ref (renderer->pcontext);
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
|
priv->keyboard = keyboard;
|
||||||
|
|
||||||
/* Create a style context for the layout */
|
/* Create a style context for the layout */
|
||||||
GtkWidgetPath *path = gtk_widget_path_new();
|
GtkWidgetPath *path = gtk_widget_path_new();
|
||||||
gtk_widget_path_append_type(path, view_type());
|
gtk_widget_path_append_type(path, view_type());
|
||||||
|
|
||||||
renderer->view_context = gtk_style_context_new();
|
priv->view_context = gtk_style_context_new();
|
||||||
gtk_style_context_set_path(renderer->view_context, path);
|
gtk_style_context_set_path(priv->view_context, path);
|
||||||
gtk_widget_path_unref(path);
|
gtk_widget_path_unref(path);
|
||||||
if (squeek_layout_get_kind(keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
if (squeek_layout_get_kind(priv->keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||||
gtk_style_context_add_class(renderer->view_context, "wide");
|
gtk_style_context_add_class(priv->view_context, "wide");
|
||||||
}
|
}
|
||||||
gtk_style_context_add_provider (renderer->view_context,
|
gtk_style_context_add_provider (priv->view_context,
|
||||||
GTK_STYLE_PROVIDER(renderer->css_provider),
|
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||||
|
|
||||||
/* Create a style context for the buttons */
|
/* Create a style context for the buttons */
|
||||||
path = gtk_widget_path_new();
|
path = gtk_widget_path_new();
|
||||||
gtk_widget_path_append_type(path, view_type());
|
gtk_widget_path_append_type(path, view_type());
|
||||||
if (squeek_layout_get_kind(keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
if (squeek_layout_get_kind(priv->keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||||
gtk_widget_path_iter_add_class(path, -1, "wide");
|
gtk_widget_path_iter_add_class(path, -1, "wide");
|
||||||
}
|
}
|
||||||
gtk_widget_path_append_type(path, button_type());
|
gtk_widget_path_append_type(path, button_type());
|
||||||
renderer->button_context = gtk_style_context_new ();
|
priv->button_context = gtk_style_context_new ();
|
||||||
gtk_style_context_set_path(renderer->button_context, path);
|
gtk_style_context_set_path(priv->button_context, path);
|
||||||
gtk_widget_path_unref(path);
|
gtk_widget_path_unref(path);
|
||||||
gtk_style_context_set_parent(renderer->button_context, renderer->view_context);
|
gtk_style_context_set_parent(priv->button_context, priv->view_context);
|
||||||
gtk_style_context_set_state (renderer->button_context, GTK_STATE_FLAG_NORMAL);
|
gtk_style_context_set_state (priv->button_context, GTK_STATE_FLAG_NORMAL);
|
||||||
gtk_style_context_add_provider (renderer->button_context,
|
gtk_style_context_add_provider (priv->button_context,
|
||||||
GTK_STYLE_PROVIDER(renderer->css_provider),
|
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eek_renderer_set_allocation_size (EekRenderer *renderer,
|
eek_renderer_set_allocation_size (EekRenderer *renderer,
|
||||||
struct squeek_layout *layout,
|
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (width > 0.0 && height > 0.0);
|
g_return_if_fail (width > 0.0 && height > 0.0);
|
||||||
|
|
||||||
renderer->allocation_width = width;
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
renderer->allocation_height = height;
|
|
||||||
|
|
||||||
renderer->widget_to_layout = squeek_layout_calculate_transformation(
|
priv->allocation_width = width;
|
||||||
layout,
|
priv->allocation_height = height;
|
||||||
renderer->allocation_width, renderer->allocation_height);
|
|
||||||
|
priv->widget_to_layout = squeek_layout_calculate_transformation(
|
||||||
|
priv->keyboard->layout,
|
||||||
|
priv->allocation_width, priv->allocation_height);
|
||||||
|
|
||||||
// This is where size-dependent surfaces would be released
|
// This is where size-dependent surfaces would be released
|
||||||
}
|
}
|
||||||
@ -334,7 +437,10 @@ eek_renderer_set_allocation_size (EekRenderer *renderer,
|
|||||||
void
|
void
|
||||||
eek_renderer_set_scale_factor (EekRenderer *renderer, gint scale)
|
eek_renderer_set_scale_factor (EekRenderer *renderer, gint scale)
|
||||||
{
|
{
|
||||||
renderer->scale_factor = scale;
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
|
|
||||||
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
|
priv->scale_factor = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
@ -363,5 +469,9 @@ eek_renderer_get_icon_surface (const gchar *icon_name,
|
|||||||
|
|
||||||
struct transformation
|
struct transformation
|
||||||
eek_renderer_get_transformation (EekRenderer *renderer) {
|
eek_renderer_get_transformation (EekRenderer *renderer) {
|
||||||
return renderer->widget_to_layout;
|
struct transformation failed = {0};
|
||||||
|
g_return_val_if_fail (EEK_IS_RENDERER(renderer), failed);
|
||||||
|
|
||||||
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
|
return priv->widget_to_layout;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,34 +27,30 @@
|
|||||||
#include "eek-types.h"
|
#include "eek-types.h"
|
||||||
#include "src/submission.h"
|
#include "src/submission.h"
|
||||||
|
|
||||||
struct squeek_layout;
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/// Renders LevelKayboards
|
#define EEK_TYPE_RENDERER (eek_renderer_get_type())
|
||||||
/// It cannot adjust styles at runtime.
|
G_DECLARE_DERIVABLE_TYPE (EekRenderer, eek_renderer, EEK, RENDERER, GObject)
|
||||||
typedef struct EekRenderer
|
|
||||||
|
struct _EekRendererClass
|
||||||
{
|
{
|
||||||
PangoContext *pcontext; // owned
|
GObjectClass parent_class;
|
||||||
GtkCssProvider *css_provider; // owned
|
|
||||||
GtkStyleContext *view_context; // owned
|
|
||||||
GtkStyleContext *button_context; // TODO: maybe move a copy to each button
|
|
||||||
/// Style class for rendering the view and button CSS.
|
|
||||||
gchar *extra_style; // owned
|
|
||||||
|
|
||||||
// Mutable state
|
cairo_surface_t *(* get_icon_surface) (EekRenderer *self,
|
||||||
/// Background extents
|
const gchar *icon_name,
|
||||||
gdouble allocation_width;
|
gint size,
|
||||||
gdouble allocation_height;
|
gint scale);
|
||||||
gint scale_factor; /* the outputs scale factor */
|
|
||||||
/// Coords transformation
|
|
||||||
struct transformation widget_to_layout;
|
|
||||||
} EekRenderer;
|
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
/* padding */
|
||||||
|
gpointer pdummy[23];
|
||||||
|
};
|
||||||
|
|
||||||
GType eek_renderer_get_type (void) G_GNUC_CONST;
|
GType eek_renderer_get_type (void) G_GNUC_CONST;
|
||||||
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
||||||
PangoContext *pcontext);
|
PangoContext *pcontext);
|
||||||
void eek_renderer_set_allocation_size
|
void eek_renderer_set_allocation_size
|
||||||
(EekRenderer *renderer, struct squeek_layout *layout,
|
(EekRenderer *renderer,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height);
|
gdouble height);
|
||||||
void eek_renderer_set_scale_factor (EekRenderer *renderer,
|
void eek_renderer_set_scale_factor (EekRenderer *renderer,
|
||||||
@ -65,9 +61,7 @@ cairo_surface_t *eek_renderer_get_icon_surface(const gchar *icon_name,
|
|||||||
gint scale);
|
gint scale);
|
||||||
|
|
||||||
void eek_renderer_render_keyboard (EekRenderer *renderer, struct submission *submission,
|
void eek_renderer_render_keyboard (EekRenderer *renderer, struct submission *submission,
|
||||||
cairo_t *cr, LevelKeyboard *keyboard);
|
cairo_t *cr);
|
||||||
void
|
|
||||||
eek_renderer_free (EekRenderer *self);
|
|
||||||
|
|
||||||
struct transformation
|
struct transformation
|
||||||
eek_renderer_get_transformation (EekRenderer *renderer);
|
eek_renderer_get_transformation (EekRenderer *renderer);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct _EekBounds EekBounds;
|
typedef struct _EekBounds EekBounds;
|
||||||
|
|
||||||
typedef struct _LayoutHolder LayoutHolder;
|
typedef struct _EekboardContextService EekboardContextService;
|
||||||
typedef struct _ServerContextService ServerContextService;
|
typedef struct _ServerContextService ServerContextService;
|
||||||
typedef struct _LevelKeyboard LevelKeyboard;
|
typedef struct _LevelKeyboard LevelKeyboard;
|
||||||
|
|
||||||
|
|||||||
@ -35,17 +35,34 @@ enum {
|
|||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LAYOUT_HOLDER_GET_PRIVATE(obj) \
|
enum {
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, LayoutHolderPrivate))
|
DESTROYED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
struct _LayoutHolderPrivate {
|
static guint signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
|
#define EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServicePrivate))
|
||||||
|
|
||||||
|
struct _EekboardContextServicePrivate {
|
||||||
LevelKeyboard *keyboard; // currently used keyboard
|
LevelKeyboard *keyboard; // currently used keyboard
|
||||||
|
GHashTable *keyboard_hash; // a table of available keyboards, per layout
|
||||||
|
|
||||||
|
char *overlay;
|
||||||
|
|
||||||
|
GSettings *settings; // Owned reference
|
||||||
|
uint32_t hint;
|
||||||
|
uint32_t purpose;
|
||||||
|
|
||||||
|
// Maybe TODO: it's used only for fetching layout type.
|
||||||
|
// Maybe let UI push the type to this structure?
|
||||||
|
ServerContextService *ui; // unowned reference
|
||||||
/// Needed for keymap changes after keyboard updates
|
/// Needed for keymap changes after keyboard updates
|
||||||
struct submission *submission; // unowned
|
struct submission *submission; // unowned
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (LayoutHolder, layout_holder, G_TYPE_OBJECT);
|
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_service_set_property (GObject *object,
|
eekboard_context_service_set_property (GObject *object,
|
||||||
@ -62,12 +79,12 @@ eekboard_context_service_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
layout_holder_get_property (GObject *object,
|
eekboard_context_service_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
LayoutHolder *context = LAYOUT_HOLDER(object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_KEYBOARD:
|
case PROP_KEYBOARD:
|
||||||
@ -79,12 +96,23 @@ layout_holder_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eekboard_context_service_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
|
|
||||||
|
if (context->priv->keyboard_hash) {
|
||||||
|
g_hash_table_destroy (context->priv->keyboard_hash);
|
||||||
|
context->priv->keyboard_hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (eekboard_context_service_parent_class)->
|
||||||
|
dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
settings_get_layout(GSettings *settings, char **type, char **layout)
|
settings_get_layout(GSettings *settings, char **type, char **layout)
|
||||||
{
|
{
|
||||||
if (!settings) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GVariant *inputs = g_settings_get_value(settings, "sources");
|
GVariant *inputs = g_settings_get_value(settings, "sources");
|
||||||
if (g_variant_n_children(inputs) == 0) {
|
if (g_variant_n_children(inputs) == 0) {
|
||||||
g_warning("No system layout present");
|
g_warning("No system layout present");
|
||||||
@ -98,33 +126,39 @@ settings_get_layout(GSettings *settings, char **type, char **layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *state) {
|
eekboard_context_service_update_layout(EekboardContextService *context, enum squeek_arrangement_kind t)
|
||||||
*context->layout = *state;
|
{
|
||||||
gchar *layout_name = state->overlay_name;
|
g_autofree gchar *keyboard_layout = NULL;
|
||||||
|
if (context->priv->overlay) {
|
||||||
|
keyboard_layout = g_strdup(context->priv->overlay);
|
||||||
|
} else {
|
||||||
|
g_autofree gchar *keyboard_type = NULL;
|
||||||
|
settings_get_layout(context->priv->settings,
|
||||||
|
&keyboard_type, &keyboard_layout);
|
||||||
|
}
|
||||||
|
|
||||||
if (layout_name == NULL) {
|
if (!keyboard_layout) {
|
||||||
layout_name = state->layout_name;
|
keyboard_layout = g_strdup("us");
|
||||||
|
}
|
||||||
|
|
||||||
switch (state->purpose) {
|
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER:
|
|
||||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE:
|
|
||||||
layout_name = "number";
|
|
||||||
break;
|
|
||||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL:
|
|
||||||
layout_name = "terminal";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layout_name == NULL) {
|
switch (priv->purpose) {
|
||||||
layout_name = "us";
|
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER:
|
||||||
}
|
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE:
|
||||||
|
g_free(keyboard_layout);
|
||||||
|
keyboard_layout = g_strdup("number");
|
||||||
|
break;
|
||||||
|
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL:
|
||||||
|
g_free(keyboard_layout);
|
||||||
|
keyboard_layout = g_strdup("terminal");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic part follows
|
// generic part follows
|
||||||
struct squeek_layout *layout = squeek_load_layout(layout_name, state->arrangement);
|
LevelKeyboard *keyboard = level_keyboard_new(keyboard_layout, t);
|
||||||
LevelKeyboard *keyboard = level_keyboard_new(layout);
|
|
||||||
// set as current
|
// set as current
|
||||||
LevelKeyboard *previous_keyboard = context->priv->keyboard;
|
LevelKeyboard *previous_keyboard = context->priv->keyboard;
|
||||||
context->priv->keyboard = keyboard;
|
context->priv->keyboard = keyboard;
|
||||||
@ -134,7 +168,6 @@ eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *
|
|||||||
submission_set_keyboard(context->priv->submission, keyboard);
|
submission_set_keyboard(context->priv->submission, keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update UI
|
|
||||||
g_object_notify (G_OBJECT(context), "keyboard");
|
g_object_notify (G_OBJECT(context), "keyboard");
|
||||||
|
|
||||||
// replacing the keyboard above will cause the previous keyboard to get destroyed from the UI side (eek_gtk_keyboard_dispose)
|
// replacing the keyboard above will cause the previous keyboard to get destroyed from the UI side (eek_gtk_keyboard_dispose)
|
||||||
@ -143,22 +176,67 @@ eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void update_layout_and_type(EekboardContextService *context) {
|
||||||
layout_holder_init (LayoutHolder *self) {
|
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||||
self->priv = LAYOUT_HOLDER_GET_PRIVATE(self);
|
enum squeek_arrangement_kind layout_kind = ARRANGEMENT_KIND_BASE;
|
||||||
|
if (priv->ui) {
|
||||||
|
layout_kind = server_context_service_get_layout_type(priv->ui);
|
||||||
|
}
|
||||||
|
eekboard_context_service_update_layout(context, layout_kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
settings_handle_layout_changed(GSettings *s,
|
||||||
|
gpointer keys, gint n_keys,
|
||||||
|
gpointer user_data) {
|
||||||
|
(void)s;
|
||||||
|
(void)keys;
|
||||||
|
(void)n_keys;
|
||||||
|
EekboardContextService *context = user_data;
|
||||||
|
g_free(context->priv->overlay);
|
||||||
|
context->priv->overlay = NULL;
|
||||||
|
update_layout_and_type(context);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
layout_holder_class_init (LayoutHolderClass *klass)
|
eekboard_context_service_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
|
||||||
|
update_layout_and_type(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
|
|
||||||
|
gobject_class->constructed = eekboard_context_service_constructed;
|
||||||
gobject_class->set_property = eekboard_context_service_set_property;
|
gobject_class->set_property = eekboard_context_service_set_property;
|
||||||
gobject_class->get_property = layout_holder_get_property;
|
gobject_class->get_property = eekboard_context_service_get_property;
|
||||||
|
gobject_class->dispose = eekboard_context_service_dispose;
|
||||||
|
/**
|
||||||
|
* EekboardContextService::destroyed:
|
||||||
|
* @context: an #EekboardContextService
|
||||||
|
*
|
||||||
|
* Emitted when @context is destroyed.
|
||||||
|
*/
|
||||||
|
signals[DESTROYED] =
|
||||||
|
g_signal_new (I_("destroyed"),
|
||||||
|
G_TYPE_FROM_CLASS(gobject_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(EekboardContextServiceClass, destroyed),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An #LevelKeyboard currently active in this context.
|
* EekboardContextService:keyboard:
|
||||||
|
*
|
||||||
|
* An #EekKeyboard currently active in this context.
|
||||||
*/
|
*/
|
||||||
pspec = g_param_spec_pointer("keyboard",
|
pspec = g_param_spec_pointer("keyboard",
|
||||||
"Keyboard",
|
"Keyboard",
|
||||||
@ -169,115 +247,92 @@ layout_holder_class_init (LayoutHolderClass *klass)
|
|||||||
pspec);
|
pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
eekboard_context_service_init (EekboardContextService *self)
|
||||||
|
{
|
||||||
|
self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
self->priv->keyboard_hash =
|
||||||
|
g_hash_table_new_full (g_direct_hash,
|
||||||
|
g_direct_equal,
|
||||||
|
NULL,
|
||||||
|
(GDestroyNotify)g_object_unref);
|
||||||
|
|
||||||
|
self->priv->settings = g_settings_new ("org.gnome.desktop.input-sources");
|
||||||
|
gulong conn_id = g_signal_connect(self->priv->settings, "change-event",
|
||||||
|
G_CALLBACK(settings_handle_layout_changed),
|
||||||
|
self);
|
||||||
|
if (conn_id == 0) {
|
||||||
|
g_warning ("Could not connect to gsettings updates, layout"
|
||||||
|
" changing unavailable");
|
||||||
|
}
|
||||||
|
|
||||||
|
self->priv->overlay = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* eekboard_context_service_destroy:
|
||||||
|
* @context: an #EekboardContextService
|
||||||
|
*
|
||||||
|
* Destroy @context.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
eekboard_context_service_destroy (EekboardContextService *context)
|
||||||
|
{
|
||||||
|
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||||
|
|
||||||
|
g_free(context->priv->overlay);
|
||||||
|
g_signal_emit (context, signals[DESTROYED], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eekboard_context_service_get_keyboard:
|
||||||
|
* @context: an #EekboardContextService
|
||||||
|
*
|
||||||
* Get keyboard currently active in @context.
|
* Get keyboard currently active in @context.
|
||||||
* Returns: (transfer none): a LevelKeyboard
|
* Returns: (transfer none): an #EekKeyboard
|
||||||
*/
|
*/
|
||||||
LevelKeyboard *
|
LevelKeyboard *
|
||||||
eek_layout_holder_get_keyboard (LayoutHolder *context)
|
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
return context->priv->keyboard;
|
return context->priv->keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eekboard_context_service_set_hint_purpose(LayoutHolder *context,
|
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
||||||
uint32_t hint, uint32_t purpose)
|
uint32_t hint, uint32_t purpose)
|
||||||
{
|
{
|
||||||
if (context->layout->hint != hint || context->layout->purpose != purpose) {
|
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||||
context->layout->hint = hint;
|
|
||||||
context->layout->purpose = purpose;
|
if (priv->hint != hint || priv->purpose != purpose) {
|
||||||
eek_layout_holder_use_layout(context, context->layout);
|
priv->hint = hint;
|
||||||
|
priv->purpose = purpose;
|
||||||
|
update_layout_and_type(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_context_service_set_overlay(LayoutHolder *context, const char* name) {
|
eekboard_context_service_set_overlay(EekboardContextService *context, const char* name) {
|
||||||
if (g_strcmp0(context->layout->overlay_name, name)) {
|
context->priv->overlay = g_strdup(name);
|
||||||
g_free(context->layout->overlay_name);
|
update_layout_and_type(context);
|
||||||
context->layout->overlay_name = g_strdup(name);
|
|
||||||
eek_layout_holder_use_layout(context, context->layout);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
eekboard_context_service_get_overlay(LayoutHolder *context) {
|
eekboard_context_service_get_overlay(EekboardContextService *context) {
|
||||||
return context->layout->overlay_name;
|
return context->priv->overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutHolder *eek_layout_holder_new(struct squeek_layout_state *state)
|
EekboardContextService *eekboard_context_service_new(void)
|
||||||
{
|
{
|
||||||
LayoutHolder *context = g_object_new (EEKBOARD_TYPE_LAYOUT_HOLDER, NULL);
|
return g_object_new (EEKBOARD_TYPE_CONTEXT_SERVICE, NULL);
|
||||||
context->layout = state;
|
|
||||||
eek_layout_holder_use_layout(context, context->layout);
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eek_layout_holder_set_submission(LayoutHolder *context, struct submission *submission) {
|
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) {
|
||||||
context->priv->submission = submission;
|
context->priv->submission = submission;
|
||||||
if (context->priv->submission) {
|
if (context->priv->submission) {
|
||||||
submission_set_keyboard(context->priv->submission, context->priv->keyboard);
|
submission_set_keyboard(context->priv->submission, context->priv->keyboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_update_layout(struct gsettings_tracker *self) {
|
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) {
|
||||||
// The layout in the param must be the same layout as held by context.
|
context->priv->ui = ui;
|
||||||
g_autofree gchar *keyboard_layout = NULL;
|
|
||||||
g_autofree gchar *keyboard_type = NULL;
|
|
||||||
settings_get_layout(self->gsettings,
|
|
||||||
&keyboard_type, &keyboard_layout);
|
|
||||||
|
|
||||||
if (g_strcmp0(self->layout->layout_name, keyboard_layout) != 0 || self->layout->overlay_name) {
|
|
||||||
g_free(self->layout->overlay_name);
|
|
||||||
self->layout->overlay_name = NULL;
|
|
||||||
if (keyboard_layout) {
|
|
||||||
g_free(self->layout->layout_name);
|
|
||||||
self->layout->layout_name = g_strdup(keyboard_layout);
|
|
||||||
}
|
|
||||||
// This must actually update the UI.
|
|
||||||
eek_layout_holder_use_layout(self->context, self->layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
handle_layout_changed(GSettings *s,
|
|
||||||
gpointer keys, gint n_keys,
|
|
||||||
gpointer user_data) {
|
|
||||||
(void)s;
|
|
||||||
(void)keys;
|
|
||||||
(void)n_keys;
|
|
||||||
struct gsettings_tracker *self = user_data;
|
|
||||||
settings_update_layout(self);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eek_gsettings_tracker_init(struct gsettings_tracker *tracker, LayoutHolder *context, struct squeek_layout_state *layout)
|
|
||||||
{
|
|
||||||
tracker->layout = layout;
|
|
||||||
tracker->context = context;
|
|
||||||
|
|
||||||
const char *schema_name = "org.gnome.desktop.input-sources";
|
|
||||||
GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
|
|
||||||
if (ssrc) {
|
|
||||||
GSettingsSchema *schema = g_settings_schema_source_lookup(ssrc,
|
|
||||||
schema_name,
|
|
||||||
TRUE);
|
|
||||||
if (schema) {
|
|
||||||
// Not referencing the found schema directly,
|
|
||||||
// because it's not clear how...
|
|
||||||
tracker->gsettings = g_settings_new (schema_name);
|
|
||||||
gulong conn_id = g_signal_connect(tracker->gsettings, "change-event",
|
|
||||||
G_CALLBACK(handle_layout_changed),
|
|
||||||
tracker);
|
|
||||||
if (conn_id == 0) {
|
|
||||||
g_warning ("Could not connect to gsettings updates, "
|
|
||||||
"automatic layout changing unavailable");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
g_warning("Gsettings schema %s is not installed on the system. "
|
|
||||||
"Layout switching unavailable", schema_name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
g_warning("No gsettings schemas installed. Layout switching unavailable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
settings_update_layout(tracker);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,60 +30,74 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define EEKBOARD_TYPE_LAYOUT_HOLDER (layout_holder_get_type())
|
#define EEKBOARD_CONTEXT_SERVICE_PATH "/org/fedorahosted/Eekboard/Context_%d"
|
||||||
#define LAYOUT_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, LayoutHolder))
|
#define EEKBOARD_CONTEXT_SERVICE_INTERFACE "org.fedorahosted.Eekboard.Context"
|
||||||
|
|
||||||
|
#define EEKBOARD_TYPE_CONTEXT_SERVICE (eekboard_context_service_get_type())
|
||||||
|
#define EEKBOARD_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextService))
|
||||||
#define EEKBOARD_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
|
#define EEKBOARD_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
|
||||||
#define EEKBOARD_IS_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE))
|
#define EEKBOARD_IS_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE))
|
||||||
#define EEKBOARD_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE))
|
#define EEKBOARD_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE))
|
||||||
#define EEKBOARD_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
|
#define EEKBOARD_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _LayoutHolderClass LayoutHolderClass;
|
typedef struct _EekboardContextServiceClass EekboardContextServiceClass;
|
||||||
typedef struct _LayoutHolderPrivate LayoutHolderPrivate;
|
typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles layout state, and virtual-keyboard.
|
* EekboardContextService:
|
||||||
|
*
|
||||||
|
* Handles layout state, gsettings, and virtual-keyboard.
|
||||||
*
|
*
|
||||||
* TODO: Restrict to managing keyboard layouts, and maybe button repeats,
|
* TODO: Restrict to managing keyboard layouts, and maybe button repeats,
|
||||||
* and the virtual keyboard protocol.
|
* and the virtual keyboard protocol.
|
||||||
|
*
|
||||||
|
* The #EekboardContextService structure contains only private data
|
||||||
|
* and should only be accessed using the provided API.
|
||||||
*/
|
*/
|
||||||
struct _LayoutHolder {
|
struct _EekboardContextService {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
LayoutHolderPrivate *priv;
|
|
||||||
struct squeek_layout_state *layout; // Unowned
|
EekboardContextServicePrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _LayoutHolderClass {
|
/**
|
||||||
|
* EekboardContextServiceClass:
|
||||||
|
* @create_keyboard: virtual function for create a keyboard from string
|
||||||
|
* @enabled: class handler for #EekboardContextService::enabled signal
|
||||||
|
* @disabled: class handler for #EekboardContextService::disabled signal
|
||||||
|
*/
|
||||||
|
struct _EekboardContextServiceClass {
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
/*< public >*/
|
||||||
|
struct squeek_view *(*create_keyboard) (EekboardContextService *self,
|
||||||
|
const gchar *keyboard_type);
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
void (*destroyed) (EekboardContextService *self);
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* padding */
|
/* padding */
|
||||||
gpointer pdummy[24];
|
gpointer pdummy[24];
|
||||||
};
|
};
|
||||||
|
|
||||||
GType layout_holder_get_type(void) G_GNUC_CONST;
|
GType eekboard_context_service_get_type
|
||||||
|
(void) G_GNUC_CONST;
|
||||||
|
EekboardContextService *eekboard_context_service_new(void);
|
||||||
|
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission);
|
||||||
|
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui);
|
||||||
|
void eekboard_context_service_destroy (EekboardContextService *context);
|
||||||
|
LevelKeyboard *eekboard_context_service_get_keyboard(EekboardContextService *context);
|
||||||
|
|
||||||
/// Handles gsettings os-level keyboard layout switches.
|
void eekboard_context_service_set_keymap(EekboardContextService *context,
|
||||||
struct gsettings_tracker {
|
|
||||||
GSettings *gsettings; // Owned reference
|
|
||||||
LayoutHolder *context; // Unowned
|
|
||||||
struct squeek_layout_state *layout; // Unowned
|
|
||||||
};
|
|
||||||
|
|
||||||
void eek_gsettings_tracker_init(struct gsettings_tracker* tracker, LayoutHolder *context, struct squeek_layout_state *layout);
|
|
||||||
|
|
||||||
LayoutHolder *eek_layout_holder_new(struct squeek_layout_state *state);
|
|
||||||
void eek_layout_holder_set_submission(LayoutHolder *context, struct submission *submission);
|
|
||||||
LevelKeyboard *eek_layout_holder_get_keyboard(LayoutHolder *context);
|
|
||||||
|
|
||||||
void eekboard_context_service_set_keymap(LayoutHolder *context,
|
|
||||||
const LevelKeyboard *keyboard);
|
const LevelKeyboard *keyboard);
|
||||||
|
|
||||||
void eekboard_context_service_set_hint_purpose(LayoutHolder *context,
|
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
||||||
uint32_t hint,
|
uint32_t hint,
|
||||||
uint32_t purpose);
|
uint32_t purpose);
|
||||||
void
|
void
|
||||||
eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *layout);
|
eekboard_context_service_update_layout(EekboardContextService *context, enum squeek_arrangement_kind t);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEKBOARD_CONTEXT_SERVICE_H */
|
#endif /* EEKBOARD_CONTEXT_SERVICE_H */
|
||||||
|
|||||||
@ -26,7 +26,7 @@ static const struct zwp_input_method_v2_listener input_method_listener = {
|
|||||||
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
|
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
|
||||||
struct zwp_virtual_keyboard_manager_v1 *vkmanager,
|
struct zwp_virtual_keyboard_manager_v1 *vkmanager,
|
||||||
struct wl_seat *seat,
|
struct wl_seat *seat,
|
||||||
LayoutHolder *state) {
|
EekboardContextService *state) {
|
||||||
struct zwp_input_method_v2 *im = NULL;
|
struct zwp_input_method_v2 *im = NULL;
|
||||||
if (immanager) {
|
if (immanager) {
|
||||||
im = zwp_input_method_manager_v2_get_input_method(immanager, seat);
|
im = zwp_input_method_manager_v2_get_input_method(immanager, seat);
|
||||||
|
|||||||
13
src/layout.h
13
src/layout.h
@ -9,21 +9,12 @@
|
|||||||
#include "eek/eek-types.h"
|
#include "eek/eek-types.h"
|
||||||
#include "src/submission.h"
|
#include "src/submission.h"
|
||||||
#include "virtual-keyboard-unstable-v1-client-protocol.h"
|
#include "virtual-keyboard-unstable-v1-client-protocol.h"
|
||||||
#include "text-input-unstable-v3-client-protocol.h"
|
|
||||||
|
|
||||||
enum squeek_arrangement_kind {
|
enum squeek_arrangement_kind {
|
||||||
ARRANGEMENT_KIND_BASE = 0,
|
ARRANGEMENT_KIND_BASE = 0,
|
||||||
ARRANGEMENT_KIND_WIDE = 1,
|
ARRANGEMENT_KIND_WIDE = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct squeek_layout_state {
|
|
||||||
enum squeek_arrangement_kind arrangement;
|
|
||||||
enum zwp_text_input_v3_content_purpose purpose;
|
|
||||||
enum zwp_text_input_v3_content_hint hint;
|
|
||||||
char *layout_name;
|
|
||||||
char *overlay_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct squeek_layout;
|
struct squeek_layout;
|
||||||
|
|
||||||
EekBounds squeek_button_get_bounds(const struct squeek_button*);
|
EekBounds squeek_button_get_bounds(const struct squeek_button*);
|
||||||
@ -47,7 +38,7 @@ void squeek_layout_release(struct squeek_layout *layout,
|
|||||||
struct submission *submission,
|
struct submission *submission,
|
||||||
struct transformation widget_to_layout,
|
struct transformation widget_to_layout,
|
||||||
uint32_t timestamp,
|
uint32_t timestamp,
|
||||||
LayoutHolder *manager,
|
EekboardContextService *manager,
|
||||||
EekGtkKeyboard *ui_keyboard);
|
EekGtkKeyboard *ui_keyboard);
|
||||||
void squeek_layout_release_all_only(struct squeek_layout *layout,
|
void squeek_layout_release_all_only(struct squeek_layout *layout,
|
||||||
struct submission *submission,
|
struct submission *submission,
|
||||||
@ -61,7 +52,7 @@ void squeek_layout_drag(struct squeek_layout *layout,
|
|||||||
struct submission *submission,
|
struct submission *submission,
|
||||||
double x_widget, double y_widget,
|
double x_widget, double y_widget,
|
||||||
struct transformation widget_to_layout,
|
struct transformation widget_to_layout,
|
||||||
uint32_t timestamp, LayoutHolder *manager,
|
uint32_t timestamp, EekboardContextService *manager,
|
||||||
EekGtkKeyboard *ui_keyboard);
|
EekGtkKeyboard *ui_keyboard);
|
||||||
void squeek_layout_draw_all_changed(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr, struct submission *submission);
|
void squeek_layout_draw_all_changed(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr, struct submission *submission);
|
||||||
void squeek_draw_layout_base_view(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr);
|
void squeek_draw_layout_base_view(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr);
|
||||||
|
|||||||
@ -35,6 +35,5 @@ mod style;
|
|||||||
mod submission;
|
mod submission;
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
mod ui_manager;
|
|
||||||
mod vkeyboard;
|
mod vkeyboard;
|
||||||
mod xdg;
|
mod xdg;
|
||||||
|
|||||||
@ -15,7 +15,6 @@ sources = [
|
|||||||
'dbus.c',
|
'dbus.c',
|
||||||
'imservice.c',
|
'imservice.c',
|
||||||
'server-context-service.c',
|
'server-context-service.c',
|
||||||
'ui_manager.c',
|
|
||||||
'wayland.c',
|
'wayland.c',
|
||||||
'../eek/eek.c',
|
'../eek/eek.c',
|
||||||
'../eek/eek-element.c',
|
'../eek/eek-element.c',
|
||||||
|
|||||||
@ -4,14 +4,10 @@
|
|||||||
#include "wayland-client-protocol.h"
|
#include "wayland-client-protocol.h"
|
||||||
|
|
||||||
struct squeek_outputs;
|
struct squeek_outputs;
|
||||||
struct squeek_output_handle {
|
|
||||||
struct wl_output *output;
|
|
||||||
struct squeek_outputs *outputs;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct squeek_outputs *squeek_outputs_new();
|
struct squeek_outputs *squeek_outputs_new();
|
||||||
void squeek_outputs_free(struct squeek_outputs*);
|
void squeek_outputs_free(struct squeek_outputs*);
|
||||||
void squeek_outputs_register(struct squeek_outputs*, struct wl_output *output);
|
void squeek_outputs_register(struct squeek_outputs*, struct wl_output *output);
|
||||||
struct squeek_output_handle squeek_outputs_get_current(struct squeek_outputs*);
|
struct wl_output *squeek_outputs_get_current(struct squeek_outputs*);
|
||||||
int32_t squeek_outputs_get_perceptual_width(struct squeek_outputs*, struct wl_output *output);
|
int32_t squeek_outputs_get_perceptual_width(struct squeek_outputs*, struct wl_output *output);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
251
src/outputs.rs
251
src/outputs.rs
@ -1,10 +1,5 @@
|
|||||||
/* Copyright (C) 2019-2020 Purism SPC
|
|
||||||
* SPDX-License-Identifier: GPL-3.0+
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! Managing Wayland outputs */
|
/*! Managing Wayland outputs */
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use ::logging;
|
use ::logging;
|
||||||
|
|
||||||
@ -22,7 +17,7 @@ pub mod c {
|
|||||||
// Defined in C
|
// Defined in C
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, PartialEq, Copy, Hash)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct WlOutput(*const c_void);
|
pub struct WlOutput(*const c_void);
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -68,7 +63,7 @@ pub mod c {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Map to `wl_output.transform` values
|
/// Map to `wl_output.transform` values
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone)]
|
||||||
pub enum Transform {
|
pub enum Transform {
|
||||||
Normal = 0,
|
Normal = 0,
|
||||||
Rotated90 = 1,
|
Rotated90 = 1,
|
||||||
@ -108,29 +103,7 @@ pub mod c {
|
|||||||
) -> i32;
|
) -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type COutputs = ::util::c::Wrapped<Outputs>;
|
type COutputs = ::util::c::Wrapped<Outputs>;
|
||||||
|
|
||||||
/// A stable reference to an output.
|
|
||||||
#[derive(Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct OutputHandle {
|
|
||||||
wl_output: WlOutput,
|
|
||||||
outputs: COutputs,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OutputHandle {
|
|
||||||
// Cannot return an Output reference
|
|
||||||
// because COutputs is too deeply wrapped
|
|
||||||
pub fn get_state(&self) -> Option<OutputState> {
|
|
||||||
let outputs = self.outputs.clone_ref();
|
|
||||||
let outputs = outputs.borrow();
|
|
||||||
find_output(&outputs, self.wl_output.clone()).map(|o| o.current.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_id(&self) -> OutputId {
|
|
||||||
OutputId { wl_output: self.wl_output }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defined in Rust
|
// Defined in Rust
|
||||||
|
|
||||||
@ -138,7 +111,7 @@ pub mod c {
|
|||||||
outputs: COutputs,
|
outputs: COutputs,
|
||||||
wl_output: WlOutput,
|
wl_output: WlOutput,
|
||||||
_x: i32, _y: i32,
|
_x: i32, _y: i32,
|
||||||
phys_width: i32, phys_height: i32,
|
_phys_width: i32, _phys_height: i32,
|
||||||
_subpixel: i32,
|
_subpixel: i32,
|
||||||
_make: *const c_char, _model: *const c_char,
|
_make: *const c_char, _model: *const c_char,
|
||||||
transform: i32,
|
transform: i32,
|
||||||
@ -154,23 +127,8 @@ pub mod c {
|
|||||||
let output_state: Option<&mut OutputState>
|
let output_state: Option<&mut OutputState>
|
||||||
= find_output_mut(&mut collection, wl_output)
|
= find_output_mut(&mut collection, wl_output)
|
||||||
.map(|o| &mut o.pending);
|
.map(|o| &mut o.pending);
|
||||||
|
|
||||||
match output_state {
|
match output_state {
|
||||||
Some(state) => {
|
Some(state) => { state.transform = Some(transform) },
|
||||||
state.transform = Some(transform);
|
|
||||||
state.phys_size = {
|
|
||||||
if (phys_width > 0) & (phys_height > 0) {
|
|
||||||
Some(SizeMM { width: phys_width, height: phys_height })
|
|
||||||
} else {
|
|
||||||
log_print!(
|
|
||||||
logging::Level::Surprise,
|
|
||||||
"Impossible physical dimensions: {}mm × {}mm",
|
|
||||||
phys_width, phys_height,
|
|
||||||
);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => log_print!(
|
None => log_print!(
|
||||||
logging::Level::Warning,
|
logging::Level::Warning,
|
||||||
"Got geometry on unknown output",
|
"Got geometry on unknown output",
|
||||||
@ -211,27 +169,19 @@ pub mod c {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern fn outputs_handle_done(
|
extern fn outputs_handle_done(
|
||||||
outputs_raw: COutputs,
|
outputs: COutputs,
|
||||||
wl_output: WlOutput,
|
wl_output: WlOutput,
|
||||||
) {
|
) {
|
||||||
let outputs = outputs_raw.clone_ref();
|
let outputs = outputs.clone_ref();
|
||||||
{
|
let mut collection = outputs.borrow_mut();
|
||||||
let mut collection = RefCell::borrow_mut(&outputs);
|
let output = find_output_mut(&mut collection, wl_output);
|
||||||
let output = find_output_mut(&mut collection, wl_output);
|
match output {
|
||||||
match output {
|
Some(output) => { output.current = output.pending.clone(); }
|
||||||
Some(output) => { output.current = output.pending.clone(); }
|
None => log_print!(
|
||||||
None => log_print!(
|
logging::Level::Warning,
|
||||||
logging::Level::Warning,
|
"Got done on unknown output",
|
||||||
"Got done on unknown output",
|
),
|
||||||
),
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
let collection = RefCell::borrow(&outputs);
|
|
||||||
if let Some(ref cb) = &collection.update_cb {
|
|
||||||
let mut cb = RefCell::borrow_mut(cb);
|
|
||||||
let cb = Box::as_mut(&mut cb);
|
|
||||||
cb(OutputHandle { wl_output, outputs: outputs_raw });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn outputs_handle_scale(
|
extern fn outputs_handle_scale(
|
||||||
@ -256,10 +206,7 @@ pub mod c {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C"
|
pub extern "C"
|
||||||
fn squeek_outputs_new() -> COutputs {
|
fn squeek_outputs_new() -> COutputs {
|
||||||
COutputs::new(Outputs {
|
COutputs::new(Outputs { outputs: Vec::new() })
|
||||||
outputs: Vec::new(),
|
|
||||||
update_cb: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -293,15 +240,46 @@ pub mod c {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C"
|
pub extern "C"
|
||||||
fn squeek_outputs_get_current(raw_collection: COutputs) -> OutputHandle {
|
fn squeek_outputs_get_current(raw_collection: COutputs) -> WlOutput {
|
||||||
let collection = raw_collection.clone_ref();
|
let collection = raw_collection.clone_ref();
|
||||||
let collection = collection.borrow();
|
let collection = collection.borrow();
|
||||||
OutputHandle {
|
collection.outputs[0].output.clone()
|
||||||
wl_output: collection.outputs[0].output.clone(),
|
|
||||||
outputs: raw_collection.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C"
|
||||||
|
fn squeek_outputs_get_perceptual_width(
|
||||||
|
raw_collection: COutputs,
|
||||||
|
wl_output: WlOutput,
|
||||||
|
) -> i32 {
|
||||||
|
let collection = raw_collection.clone_ref();
|
||||||
|
let collection = collection.borrow();
|
||||||
|
|
||||||
|
let output_state = find_output(&collection, wl_output)
|
||||||
|
.map(|o| &o.current);
|
||||||
|
match output_state {
|
||||||
|
Some(OutputState {
|
||||||
|
current_mode: Some(super::Mode { width, height } ),
|
||||||
|
transform: Some(transform),
|
||||||
|
scale,
|
||||||
|
}) => {
|
||||||
|
match transform {
|
||||||
|
Transform::Normal
|
||||||
|
| Transform::Rotated180
|
||||||
|
| Transform::Flipped
|
||||||
|
| Transform::FlippedRotated180 => width / scale,
|
||||||
|
_ => height / scale,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
log_print!(
|
||||||
|
logging::Level::Surprise,
|
||||||
|
"Not enough info received on output",
|
||||||
|
);
|
||||||
|
0
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: handle unregistration
|
// TODO: handle unregistration
|
||||||
|
|
||||||
fn find_output(
|
fn find_output(
|
||||||
@ -327,112 +305,27 @@ pub mod c {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generic size
|
#[derive(Clone)]
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Size {
|
|
||||||
pub width: u32,
|
|
||||||
pub height: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
pub struct SizeMM {
|
|
||||||
pub width: i32,
|
|
||||||
pub height: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// wl_output mode
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
struct Mode {
|
struct Mode {
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone)]
|
||||||
pub struct OutputState {
|
pub struct OutputState {
|
||||||
current_mode: Option<Mode>,
|
current_mode: Option<Mode>,
|
||||||
phys_size: Option<SizeMM>,
|
|
||||||
transform: Option<c::Transform>,
|
transform: Option<c::Transform>,
|
||||||
pub scale: i32,
|
scale: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputState {
|
impl OutputState {
|
||||||
// More properly, this would have been a builder kind of struct,
|
|
||||||
// with wl_output gradually adding properties to it
|
|
||||||
// before it reached a fully initialized state,
|
|
||||||
// when it would transform into a struct without all (some?) of the Options.
|
|
||||||
// However, it's not clear which state is fully initialized,
|
|
||||||
// and whether it would make things easier at all anyway.
|
|
||||||
fn uninitialized() -> OutputState {
|
fn uninitialized() -> OutputState {
|
||||||
OutputState {
|
OutputState {
|
||||||
current_mode: None,
|
current_mode: None,
|
||||||
phys_size: None,
|
|
||||||
transform: None,
|
transform: None,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pixel_size(&self) -> Option<Size> {
|
|
||||||
use self::c::Transform;
|
|
||||||
match self {
|
|
||||||
OutputState {
|
|
||||||
current_mode: Some(Mode { width, height } ),
|
|
||||||
transform: Some(transform),
|
|
||||||
phys_size: _,
|
|
||||||
scale: _,
|
|
||||||
} => Some(
|
|
||||||
match transform {
|
|
||||||
Transform::Normal
|
|
||||||
| Transform::Rotated180
|
|
||||||
| Transform::Flipped
|
|
||||||
| Transform::FlippedRotated180 => Size {
|
|
||||||
width: *width as u32,
|
|
||||||
height: *height as u32,
|
|
||||||
},
|
|
||||||
_ => Size {
|
|
||||||
width: *height as u32,
|
|
||||||
height: *width as u32,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns transformed dimensions
|
|
||||||
pub fn get_phys_size(&self) -> Option<Size> {
|
|
||||||
use self::c::Transform;
|
|
||||||
match self {
|
|
||||||
OutputState {
|
|
||||||
current_mode: _,
|
|
||||||
transform: Some(transform),
|
|
||||||
phys_size: Some(SizeMM { width, height }),
|
|
||||||
scale: _,
|
|
||||||
} => Some(
|
|
||||||
match transform {
|
|
||||||
Transform::Normal
|
|
||||||
| Transform::Rotated180
|
|
||||||
| Transform::Flipped
|
|
||||||
| Transform::FlippedRotated180 => Size {
|
|
||||||
width: *width as u32,
|
|
||||||
height: *height as u32,
|
|
||||||
},
|
|
||||||
_ => Size {
|
|
||||||
width: *height as u32,
|
|
||||||
height: *width as u32,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A comparable ID of an output
|
|
||||||
#[derive(Clone, PartialEq, Hash)]
|
|
||||||
pub struct OutputId {
|
|
||||||
// WlOutput is a unique pointer, so it will not repeat
|
|
||||||
// even if there are multiple output managers.
|
|
||||||
wl_output: c::WlOutput,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
@ -441,38 +334,6 @@ pub struct Output {
|
|||||||
current: OutputState,
|
current: OutputState,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The manager of all outputs.
|
|
||||||
// This is the target of several callbacks,
|
|
||||||
// so it should only be used with a stable place in memory, like `Rc<RefCell>`.
|
|
||||||
// It should not be instantiated externally or copied,
|
|
||||||
// or it will not receive those callbacks and be somewhat of an empty shell.
|
|
||||||
// It should be safe to use as long as the fields are not `pub`,
|
|
||||||
// and there's no `Clone`, and this module's API only ever gives out
|
|
||||||
// references wrapped in `Rc<RefCell>`.
|
|
||||||
// For perfectness, it would only ever give out immutable opaque references,
|
|
||||||
// but that's not practical at the moment.
|
|
||||||
// `mem::swap` could replace the value inside,
|
|
||||||
// but as long as the swap is atomic,
|
|
||||||
// that should not cause an inconsistent state.
|
|
||||||
pub struct Outputs {
|
pub struct Outputs {
|
||||||
outputs: Vec<Output>,
|
outputs: Vec<Output>,
|
||||||
// The RefCell is here to let the function be called
|
|
||||||
// while holding only a read-reference to `Outputs`.
|
|
||||||
// Otherwise anything trying to get useful data from OutputHandle
|
|
||||||
// will fail to acquire reference to Outputs.
|
|
||||||
// TODO: Maybe pass only current state along with Outputs and Output hash.
|
|
||||||
// The only reason a full OutputHandle is here
|
|
||||||
// is to be able to track the right Output.
|
|
||||||
update_cb: Option<RefCell<Box<dyn FnMut(c::OutputHandle)>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Outputs {
|
|
||||||
/// The function will get called whenever
|
|
||||||
/// any output changes or is removed or created.
|
|
||||||
/// If output handle doesn't return state, the output just went down.
|
|
||||||
/// It cannot modify anything in Outputs.
|
|
||||||
// FIXME: handle output destruction
|
|
||||||
pub fn set_update_cb(&mut self, callback: Box<dyn FnMut(c::OutputHandle)>) {
|
|
||||||
self.update_cb = Some(RefCell::new(callback));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,40 +132,19 @@ fn make_menu_builder(inputs: Vec<(&str, OwnedTranslation)>) -> gtk::Builder {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_settings(schema_name: &str) -> Option<gio::Settings> {
|
|
||||||
let mut error_handler = logging::Print{};
|
|
||||||
gio::SettingsSchemaSource::get_default()
|
|
||||||
.or_warn(
|
|
||||||
&mut error_handler,
|
|
||||||
logging::Problem::Surprise,
|
|
||||||
"No gsettings schemas installed.",
|
|
||||||
)
|
|
||||||
.and_then(|sss|
|
|
||||||
sss.lookup(schema_name, true)
|
|
||||||
.or_warn(
|
|
||||||
&mut error_handler,
|
|
||||||
logging::Problem::Surprise,
|
|
||||||
&format!("Gsettings schema {} not installed", schema_name),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.map(|_sschema| gio::Settings::new(schema_name))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_layout(kind: String, name: String) {
|
fn set_layout(kind: String, name: String) {
|
||||||
let settings = get_settings("org.gnome.desktop.input-sources");
|
let settings = gio::Settings::new("org.gnome.desktop.input-sources");
|
||||||
if let Some(settings) = settings {
|
let inputs = settings.get_value("sources").unwrap();
|
||||||
let inputs = settings.get_value("sources").unwrap();
|
let current = (kind.clone(), name.clone());
|
||||||
let current = (kind.clone(), name.clone());
|
let inputs = variants::get_tuples(inputs).into_iter()
|
||||||
let inputs = variants::get_tuples(inputs).into_iter()
|
.filter(|t| t != ¤t);
|
||||||
.filter(|t| t != ¤t);
|
let inputs = vec![(kind, name)].into_iter()
|
||||||
let inputs = vec![(kind, name)].into_iter()
|
.chain(inputs).collect();
|
||||||
.chain(inputs).collect();
|
settings.set_value(
|
||||||
settings.set_value(
|
"sources",
|
||||||
"sources",
|
&variants::ArrayPairString(inputs).to_variant(),
|
||||||
&variants::ArrayPairString(inputs).to_variant(),
|
);
|
||||||
);
|
settings.apply();
|
||||||
settings.apply();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A reference to what the user wants to see
|
/// A reference to what the user wants to see
|
||||||
@ -305,13 +284,9 @@ pub fn show(
|
|||||||
let overlay_layouts = resources::get_overlays().into_iter()
|
let overlay_layouts = resources::get_overlays().into_iter()
|
||||||
.map(|name| LayoutId::Local(name.to_string()));
|
.map(|name| LayoutId::Local(name.to_string()));
|
||||||
|
|
||||||
let settings = get_settings("org.gnome.desktop.input-sources");
|
let settings = gio::Settings::new("org.gnome.desktop.input-sources");
|
||||||
let inputs = settings
|
let inputs = settings.get_value("sources").unwrap();
|
||||||
.map(|settings| {
|
let inputs = variants::get_tuples(inputs);
|
||||||
let inputs = settings.get_value("sources").unwrap();
|
|
||||||
variants::get_tuples(inputs)
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| Vec::new());
|
|
||||||
|
|
||||||
let system_layouts: Vec<LayoutId> = inputs.into_iter()
|
let system_layouts: Vec<LayoutId> = inputs.into_iter()
|
||||||
.map(|(kind, name)| LayoutId::System { kind, name })
|
.map(|(kind, name)| LayoutId::System { kind, name })
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_SIZE_CONSTRAINT_LANDSCAPE,
|
||||||
|
PROP_SIZE_CONSTRAINT_PORTRAIT,
|
||||||
PROP_VISIBLE,
|
PROP_VISIBLE,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
@ -39,17 +41,19 @@ typedef struct _ServerContextServiceClass ServerContextServiceClass;
|
|||||||
struct _ServerContextService {
|
struct _ServerContextService {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
LayoutHolder *state; // unowned
|
EekboardContextService *state; // unowned
|
||||||
/// Needed for instantiating the widget
|
/// Needed for instantiating the widget
|
||||||
struct submission *submission; // unowned
|
struct submission *submission; // unowned
|
||||||
struct squeek_layout_state *layout;
|
|
||||||
struct ui_manager *manager; // unowned
|
|
||||||
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
PhoshLayerSurface *window;
|
PhoshLayerSurface *window;
|
||||||
GtkWidget *widget; // nullable
|
GtkWidget *widget; // nullable
|
||||||
guint hiding;
|
guint hiding;
|
||||||
guint last_requested_height;
|
guint last_requested_height;
|
||||||
|
enum squeek_arrangement_kind last_type;
|
||||||
|
|
||||||
|
gdouble size_constraint_landscape[2];
|
||||||
|
gdouble size_constraint_portrait[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ServerContextServiceClass {
|
struct _ServerContextServiceClass {
|
||||||
@ -71,6 +75,27 @@ on_destroy (GtkWidget *widget, gpointer user_data)
|
|||||||
//eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
|
//eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_widget (ServerContextService *context);
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_notify_keyboard (GObject *object,
|
||||||
|
GParamSpec *spec,
|
||||||
|
ServerContextService *context)
|
||||||
|
{
|
||||||
|
/* Recreate the keyboard widget to keep in sync with the keymap. */
|
||||||
|
if (context->window)
|
||||||
|
make_widget(context);
|
||||||
|
|
||||||
|
gboolean visible;
|
||||||
|
g_object_get (context, "visible", &visible, NULL);
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
server_context_service_hide_keyboard(context);
|
||||||
|
server_context_service_show_keyboard(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_notify_map (GObject *object,
|
on_notify_map (GObject *object,
|
||||||
ServerContextService *context)
|
ServerContextService *context)
|
||||||
@ -87,6 +112,26 @@ on_notify_unmap (GObject *object,
|
|||||||
g_object_set (context, "visible", FALSE, NULL);
|
g_object_set (context, "visible", FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t
|
||||||
|
calculate_height(int32_t width)
|
||||||
|
{
|
||||||
|
uint32_t height = 180;
|
||||||
|
if (width < 360 && width > 0) {
|
||||||
|
height = ((unsigned)width * 7 / 12); // to match 360×210
|
||||||
|
} else if (width < 540) {
|
||||||
|
height = 180 + (540 - (unsigned)width) * 30 / 180; // smooth transition
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum squeek_arrangement_kind get_type(uint32_t width, uint32_t height) {
|
||||||
|
(void)height;
|
||||||
|
if (width < 540) {
|
||||||
|
return ARRANGEMENT_KIND_BASE;
|
||||||
|
}
|
||||||
|
return ARRANGEMENT_KIND_WIDE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
|
on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
|
||||||
{
|
{
|
||||||
@ -96,8 +141,14 @@ on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
|
|||||||
"configured-width", &width,
|
"configured-width", &width,
|
||||||
"configured-height", &height,
|
"configured-height", &height,
|
||||||
NULL);
|
NULL);
|
||||||
|
// check if the change would switch types
|
||||||
|
enum squeek_arrangement_kind new_type = get_type((uint32_t)width, (uint32_t)height);
|
||||||
|
if (context->last_type != new_type) {
|
||||||
|
context->last_type = new_type;
|
||||||
|
eekboard_context_service_update_layout(context->state, context->last_type);
|
||||||
|
}
|
||||||
|
|
||||||
guint desired_height = squeek_uiman_get_perceptual_height(context->manager);
|
guint desired_height = calculate_height(width);
|
||||||
guint configured_height = (guint)height;
|
guint configured_height = (guint)height;
|
||||||
// if height was already requested once but a different one was given
|
// if height was already requested once but a different one was given
|
||||||
// (for the same set of surrounding properties),
|
// (for the same set of surrounding properties),
|
||||||
@ -120,14 +171,14 @@ make_window (ServerContextService *context)
|
|||||||
if (context->window)
|
if (context->window)
|
||||||
g_error("Window already present");
|
g_error("Window already present");
|
||||||
|
|
||||||
struct squeek_output_handle output = squeek_outputs_get_current(squeek_wayland->outputs);
|
struct wl_output *output = squeek_outputs_get_current(squeek_wayland->outputs);
|
||||||
squeek_uiman_set_output(context->manager, output);
|
int32_t width = squeek_outputs_get_perceptual_width(squeek_wayland->outputs, output);
|
||||||
uint32_t height = squeek_uiman_get_perceptual_height(context->manager);
|
uint32_t height = calculate_height(width);
|
||||||
|
|
||||||
context->window = g_object_new (
|
context->window = g_object_new (
|
||||||
PHOSH_TYPE_LAYER_SURFACE,
|
PHOSH_TYPE_LAYER_SURFACE,
|
||||||
"layer-shell", squeek_wayland->layer_shell,
|
"layer-shell", squeek_wayland->layer_shell,
|
||||||
"wl-output", output.output,
|
"wl-output", output,
|
||||||
"height", height,
|
"height", height,
|
||||||
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM
|
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM
|
||||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
||||||
@ -139,7 +190,6 @@ make_window (ServerContextService *context)
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
squeek_uiman_set_surface(context->manager, context->window);
|
|
||||||
g_object_connect (context->window,
|
g_object_connect (context->window,
|
||||||
"signal::destroy", G_CALLBACK(on_destroy), context,
|
"signal::destroy", G_CALLBACK(on_destroy), context,
|
||||||
"signal::map", G_CALLBACK(on_notify_map), context,
|
"signal::map", G_CALLBACK(on_notify_map), context,
|
||||||
@ -174,11 +224,14 @@ make_widget (ServerContextService *context)
|
|||||||
gtk_widget_destroy(context->widget);
|
gtk_widget_destroy(context->widget);
|
||||||
context->widget = NULL;
|
context->widget = NULL;
|
||||||
}
|
}
|
||||||
context->widget = eek_gtk_keyboard_new (context->state, context->submission, context->layout);
|
|
||||||
|
LevelKeyboard *keyboard = eekboard_context_service_get_keyboard (context->state);
|
||||||
|
|
||||||
|
context->widget = eek_gtk_keyboard_new (keyboard, context->state, context->submission);
|
||||||
|
|
||||||
gtk_widget_set_has_tooltip (context->widget, TRUE);
|
gtk_widget_set_has_tooltip (context->widget, TRUE);
|
||||||
gtk_container_add (GTK_CONTAINER(context->window), context->widget);
|
gtk_container_add (GTK_CONTAINER(context->window), context->widget);
|
||||||
gtk_widget_show_all(context->widget);
|
gtk_widget_show (context->widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -243,8 +296,21 @@ server_context_service_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
|
ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
|
||||||
|
GVariant *variant;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_SIZE_CONSTRAINT_LANDSCAPE:
|
||||||
|
variant = g_value_get_variant (value);
|
||||||
|
g_variant_get (variant, "(dd)",
|
||||||
|
&context->size_constraint_landscape[0],
|
||||||
|
&context->size_constraint_landscape[1]);
|
||||||
|
break;
|
||||||
|
case PROP_SIZE_CONSTRAINT_PORTRAIT:
|
||||||
|
variant = g_value_get_variant (value);
|
||||||
|
g_variant_get (variant, "(dd)",
|
||||||
|
&context->size_constraint_portrait[0],
|
||||||
|
&context->size_constraint_portrait[1]);
|
||||||
|
break;
|
||||||
case PROP_VISIBLE:
|
case PROP_VISIBLE:
|
||||||
context->visible = g_value_get_boolean (value);
|
context->visible = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
@ -293,6 +359,26 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
|||||||
gobject_class->get_property = server_context_service_get_property;
|
gobject_class->get_property = server_context_service_get_property;
|
||||||
gobject_class->dispose = server_context_service_dispose;
|
gobject_class->dispose = server_context_service_dispose;
|
||||||
|
|
||||||
|
pspec = g_param_spec_variant ("size-constraint-landscape",
|
||||||
|
"Size constraint landscape",
|
||||||
|
"Size constraint landscape",
|
||||||
|
G_VARIANT_TYPE("(dd)"),
|
||||||
|
NULL,
|
||||||
|
G_PARAM_WRITABLE);
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SIZE_CONSTRAINT_LANDSCAPE,
|
||||||
|
pspec);
|
||||||
|
|
||||||
|
pspec = g_param_spec_variant ("size-constraint-portrait",
|
||||||
|
"Size constraint portrait",
|
||||||
|
"Size constraint portrait",
|
||||||
|
G_VARIANT_TYPE("(dd)"),
|
||||||
|
NULL,
|
||||||
|
G_PARAM_WRITABLE);
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SIZE_CONSTRAINT_PORTRAIT,
|
||||||
|
pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate if keyboard is visible or not.
|
* Flag to indicate if keyboard is visible or not.
|
||||||
*/
|
*/
|
||||||
@ -312,12 +398,19 @@ server_context_service_init (ServerContextService *state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerContextService *
|
ServerContextService *
|
||||||
server_context_service_new (LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman)
|
server_context_service_new (EekboardContextService *state, struct submission *submission)
|
||||||
{
|
{
|
||||||
ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL);
|
ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL);
|
||||||
ui->submission = submission;
|
ui->submission = submission;
|
||||||
ui->state = state;
|
ui->state = state;
|
||||||
ui->layout = layout;
|
g_signal_connect (state,
|
||||||
ui->manager = uiman;
|
"notify::keyboard",
|
||||||
|
G_CALLBACK(on_notify_keyboard),
|
||||||
|
ui);
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *service)
|
||||||
|
{
|
||||||
|
return service->last_type;
|
||||||
|
}
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "src/layout.h"
|
#include "src/layout.h"
|
||||||
#include "src/submission.h"
|
#include "src/submission.h"
|
||||||
#include "ui_manager.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ typedef struct _ServerContextService ServerContextService;
|
|||||||
GType server_context_service_get_type
|
GType server_context_service_get_type
|
||||||
(void) G_GNUC_CONST;
|
(void) G_GNUC_CONST;
|
||||||
|
|
||||||
ServerContextService *server_context_service_new(LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman);
|
ServerContextService *server_context_service_new(EekboardContextService *state, struct submission *submission);
|
||||||
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
|
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
|
||||||
void server_context_service_show_keyboard (ServerContextService *context);
|
void server_context_service_show_keyboard (ServerContextService *context);
|
||||||
void server_context_service_hide_keyboard (ServerContextService *context);
|
void server_context_service_hide_keyboard (ServerContextService *context);
|
||||||
|
|||||||
@ -28,11 +28,9 @@
|
|||||||
#include "eek/eek.h"
|
#include "eek/eek.h"
|
||||||
#include "eekboard/eekboard-context-service.h"
|
#include "eekboard/eekboard-context-service.h"
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
#include "layout.h"
|
|
||||||
#include "outputs.h"
|
#include "outputs.h"
|
||||||
#include "submission.h"
|
#include "submission.h"
|
||||||
#include "server-context-service.h"
|
#include "server-context-service.h"
|
||||||
#include "ui_manager.h"
|
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
|
||||||
#include <gdk/gdkwayland.h>
|
#include <gdk/gdkwayland.h>
|
||||||
@ -40,14 +38,11 @@
|
|||||||
|
|
||||||
/// Global application state
|
/// Global application state
|
||||||
struct squeekboard {
|
struct squeekboard {
|
||||||
struct squeek_wayland wayland; // Just hooks.
|
struct squeek_wayland wayland;
|
||||||
DBusHandler *dbus_handler; // Controls visibility of the OSK.
|
DBusHandler *dbus_handler;
|
||||||
LayoutHolder *layout_holder; // Currently used layout & keyboard.
|
EekboardContextService *settings_context;
|
||||||
ServerContextService *ui_context; // mess, includes the entire UI
|
ServerContextService *ui_context;
|
||||||
struct submission *submission; // Wayland text input handling.
|
struct submission *submission;
|
||||||
struct squeek_layout_state layout_choice; // Currently wanted layout.
|
|
||||||
struct ui_manager *ui_manager; // UI shape tracker/chooser. TODO: merge with layuot choice
|
|
||||||
struct gsettings_tracker gsettings_tracker; // Gsettings handling.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -204,10 +199,8 @@ main (int argc, char **argv)
|
|||||||
g_warning("Wayland input method interface not available");
|
g_warning("Wayland input method interface not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.ui_manager = squeek_uiman_new(instance.wayland.outputs);
|
instance.settings_context = eekboard_context_service_new();
|
||||||
|
|
||||||
instance.layout_holder = eek_layout_holder_new(&instance.layout_choice);
|
|
||||||
eek_gsettings_tracker_init(&instance.gsettings_tracker, instance.layout_holder, &instance.layout_choice);
|
|
||||||
// set up dbus
|
// set up dbus
|
||||||
|
|
||||||
// TODO: make dbus errors non-always-fatal
|
// TODO: make dbus errors non-always-fatal
|
||||||
@ -229,9 +222,9 @@ main (int argc, char **argv)
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
if (connection == NULL) {
|
if (connection == NULL) {
|
||||||
g_printerr ("Can't connect to the bus: %s. "
|
g_printerr ("Can't connect to the bus: %s\n", error->message);
|
||||||
"Visibility switching unavailable.", error->message);
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case G_BUS_TYPE_NONE:
|
case G_BUS_TYPE_NONE:
|
||||||
@ -253,42 +246,37 @@ main (int argc, char **argv)
|
|||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
guint owner_id = 0;
|
|
||||||
DBusHandler *service = NULL;
|
|
||||||
if (connection) {
|
|
||||||
service = dbus_handler_new(connection, DBUS_SERVICE_PATH);
|
|
||||||
|
|
||||||
if (service == NULL) {
|
DBusHandler *service = dbus_handler_new(connection, DBUS_SERVICE_PATH);
|
||||||
g_printerr ("Can't create dbus server\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
instance.dbus_handler = service;
|
|
||||||
|
|
||||||
owner_id = g_bus_own_name_on_connection (connection,
|
if (service == NULL) {
|
||||||
DBUS_SERVICE_INTERFACE,
|
g_printerr ("Can't create dbus server\n");
|
||||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
exit (1);
|
||||||
on_name_acquired,
|
}
|
||||||
on_name_lost,
|
instance.dbus_handler = service;
|
||||||
NULL,
|
|
||||||
NULL);
|
guint owner_id = g_bus_own_name_on_connection (connection,
|
||||||
if (owner_id == 0) {
|
DBUS_SERVICE_INTERFACE,
|
||||||
g_printerr ("Can't own the name\n");
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
exit (1);
|
on_name_acquired,
|
||||||
}
|
on_name_lost,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (owner_id == 0) {
|
||||||
|
g_printerr ("Can't own the name\n");
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.submission = get_submission(instance.wayland.input_method_manager,
|
instance.submission = get_submission(instance.wayland.input_method_manager,
|
||||||
instance.wayland.virtual_keyboard_manager,
|
instance.wayland.virtual_keyboard_manager,
|
||||||
instance.wayland.seat,
|
instance.wayland.seat,
|
||||||
instance.layout_holder);
|
instance.settings_context);
|
||||||
|
|
||||||
eek_layout_holder_set_submission(instance.layout_holder, instance.submission);
|
eekboard_context_service_set_submission(instance.settings_context, instance.submission);
|
||||||
|
|
||||||
ServerContextService *ui_context = server_context_service_new(
|
ServerContextService *ui_context = server_context_service_new(
|
||||||
instance.layout_holder,
|
instance.settings_context,
|
||||||
instance.submission,
|
instance.submission);
|
||||||
&instance.layout_choice,
|
|
||||||
instance.ui_manager);
|
|
||||||
if (!ui_context) {
|
if (!ui_context) {
|
||||||
g_error("Could not initialize GUI");
|
g_error("Could not initialize GUI");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -300,6 +288,7 @@ main (int argc, char **argv)
|
|||||||
if (instance.dbus_handler) {
|
if (instance.dbus_handler) {
|
||||||
dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context);
|
dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context);
|
||||||
}
|
}
|
||||||
|
eekboard_context_service_set_ui(instance.settings_context, instance.ui_context);
|
||||||
|
|
||||||
session_register();
|
session_register();
|
||||||
|
|
||||||
@ -307,15 +296,9 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
if (connection) {
|
g_bus_unown_name (owner_id);
|
||||||
if (service) {
|
g_object_unref (service);
|
||||||
if (owner_id != 0) {
|
g_object_unref (connection);
|
||||||
g_bus_unown_name (owner_id);
|
|
||||||
}
|
|
||||||
g_object_unref (service);
|
|
||||||
}
|
|
||||||
g_object_unref (connection);
|
|
||||||
}
|
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
|
||||||
squeek_wayland_deinit (&instance.wayland);
|
squeek_wayland_deinit (&instance.wayland);
|
||||||
|
|||||||
@ -10,10 +10,10 @@ struct submission;
|
|||||||
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
|
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
|
||||||
struct zwp_virtual_keyboard_manager_v1 *vkmanager,
|
struct zwp_virtual_keyboard_manager_v1 *vkmanager,
|
||||||
struct wl_seat *seat,
|
struct wl_seat *seat,
|
||||||
LayoutHolder *state);
|
EekboardContextService *state);
|
||||||
|
|
||||||
// Defined in Rust
|
// Defined in Rust
|
||||||
struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, LayoutHolder *state);
|
struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state);
|
||||||
void submission_set_ui(struct submission *self, ServerContextService *ui_context);
|
void submission_set_ui(struct submission *self, ServerContextService *ui_context);
|
||||||
void submission_set_keyboard(struct submission *self, LevelKeyboard *keyboard);
|
void submission_set_keyboard(struct submission *self, LevelKeyboard *keyboard);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
#include "eek/layersurface.h"
|
|
||||||
|
|
||||||
void squeek_manager_set_surface_height(PhoshLayerSurface *surface, uint32_t desired_height) {
|
|
||||||
phosh_layer_surface_set_size(surface, 0,
|
|
||||||
(gint)desired_height);
|
|
||||||
phosh_layer_surface_set_exclusive_zone(surface, (gint)desired_height);
|
|
||||||
phosh_layer_surface_wl_surface_commit (surface);
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
#ifndef UI_MANAGER__
|
|
||||||
#define UI_MANAGER__
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include "eek/layersurface.h"
|
|
||||||
#include "outputs.h"
|
|
||||||
|
|
||||||
struct ui_manager;
|
|
||||||
|
|
||||||
struct ui_manager *squeek_uiman_new(struct squeek_outputs *outputs);
|
|
||||||
void squeek_uiman_set_output(struct ui_manager *uiman, struct squeek_output_handle output);
|
|
||||||
void squeek_uiman_set_surface(struct ui_manager *uiman, PhoshLayerSurface *surface);
|
|
||||||
uint32_t squeek_uiman_get_perceptual_height(struct ui_manager *uiman);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,241 +0,0 @@
|
|||||||
/* Copyright (C) 2020 Purism SPC
|
|
||||||
* SPDX-License-Identifier: GPL-3.0+
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! Centrally manages the shape of the UI widgets, and the choice of layout.
|
|
||||||
*
|
|
||||||
* Coordinates this based on information collated from all possible sources.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::cmp::min;
|
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use ::logging;
|
|
||||||
use ::outputs::{ OutputId, Outputs, OutputState};
|
|
||||||
use ::outputs::c::OutputHandle;
|
|
||||||
|
|
||||||
// Traits
|
|
||||||
use ::logging::Warn;
|
|
||||||
|
|
||||||
mod c {
|
|
||||||
use super::*;
|
|
||||||
use std::os::raw::c_void;
|
|
||||||
use ::outputs::c::COutputs;
|
|
||||||
use ::util::c::Wrapped;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct PhoshLayerSurface(*const c_void);
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
// Rustc wrongly assumes
|
|
||||||
// that COutputs allows C direct access to the underlying RefCell.
|
|
||||||
#[allow(improper_ctypes)]
|
|
||||||
pub fn squeek_manager_set_surface_height(
|
|
||||||
surface: PhoshLayerSurface,
|
|
||||||
height: u32,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C"
|
|
||||||
fn squeek_uiman_new(outputs: COutputs) -> Wrapped<Manager> {
|
|
||||||
let uiman_raw = Wrapped::new(Manager::new());
|
|
||||||
if !outputs.is_null() {
|
|
||||||
let uiman = uiman_raw.clone_ref();
|
|
||||||
let outputs = outputs.clone_ref();
|
|
||||||
let mut outputs = outputs.borrow_mut();
|
|
||||||
register_output_man(uiman, &mut outputs);
|
|
||||||
}
|
|
||||||
uiman_raw
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Used to size the layer surface containing all the OSK widgets.
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C"
|
|
||||||
fn squeek_uiman_get_perceptual_height(
|
|
||||||
uiman: Wrapped<Manager>,
|
|
||||||
) -> u32 {
|
|
||||||
let uiman = uiman.clone_ref();
|
|
||||||
let uiman = uiman.borrow();
|
|
||||||
// TODO: what to do when there's no output?
|
|
||||||
uiman.state.get_perceptual_height().unwrap_or(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C"
|
|
||||||
fn squeek_uiman_set_output(
|
|
||||||
uiman: Wrapped<Manager>,
|
|
||||||
output: OutputHandle,
|
|
||||||
) {
|
|
||||||
let uiman = uiman.clone_ref();
|
|
||||||
let mut uiman = uiman.borrow_mut();
|
|
||||||
uiman.set_output(output)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C"
|
|
||||||
fn squeek_uiman_set_surface(
|
|
||||||
uiman: Wrapped<Manager>,
|
|
||||||
surface: PhoshLayerSurface,
|
|
||||||
) {
|
|
||||||
let uiman = uiman.clone_ref();
|
|
||||||
let mut uiman = uiman.borrow_mut();
|
|
||||||
// Surface is not state, so doesn't need to propagate updates.
|
|
||||||
uiman.surface = Some(surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stores current state of all things influencing what the UI should look like.
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
pub struct ManagerState {
|
|
||||||
current_output: Option<(OutputId, OutputState)>,
|
|
||||||
//// Pixel size of the surface. Needs explicit updating.
|
|
||||||
//surface_size: Option<Size>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ManagerState {
|
|
||||||
/// The largest ideal heigth for the keyboard as a whole
|
|
||||||
/// judged by the ease of hitting targets within.
|
|
||||||
/// Ideally related to finger size, the crammedness of the layout,
|
|
||||||
/// distance from display, and motor skills of the user.
|
|
||||||
// FIXME: Start by making this aware of display's dpi,
|
|
||||||
// then layout number of rows.
|
|
||||||
fn get_max_target_height(output: &OutputState) -> u32 {
|
|
||||||
let layout_rows = 4; // FIXME: use number from layout.
|
|
||||||
let px_size = output.get_pixel_size();
|
|
||||||
let phys_size = output.get_phys_size();
|
|
||||||
|
|
||||||
let finger_height_px = match (px_size, phys_size) {
|
|
||||||
(Some(px_size), Some(phys_size)) => {
|
|
||||||
// Fudged to result in 420px from the original design.
|
|
||||||
// That gives about 9.5mm per finger height.
|
|
||||||
// Maybe floats are not the best choice here,
|
|
||||||
// but it gets rounded ASAP. Consider rationals.
|
|
||||||
let keyboard_fraction_of_display: f64 = 420. / 1440.;
|
|
||||||
let keyboard_mm = keyboard_fraction_of_display * 130.;
|
|
||||||
let finger_height_mm = keyboard_mm / 4.;
|
|
||||||
// TODO: Take into account target shape/area, not just height.
|
|
||||||
finger_height_mm * px_size.height as f64 / phys_size.height as f64
|
|
||||||
},
|
|
||||||
(_, None) => output.scale as f64 * 52.5, // match total 420px at scale 2 from original design
|
|
||||||
(None, Some(_)) => {
|
|
||||||
log_print!(
|
|
||||||
logging::Level::Surprise,
|
|
||||||
"Output has physical size data but no pixel info",
|
|
||||||
);
|
|
||||||
output.scale as f64 * 52.5
|
|
||||||
},
|
|
||||||
};
|
|
||||||
(layout_rows as f64 * finger_height_px) as u32
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_perceptual_height(&self) -> Option<u32> {
|
|
||||||
let output_info = (&self.current_output).as_ref()
|
|
||||||
.map(|(_id, os)| (
|
|
||||||
os.scale as u32,
|
|
||||||
os.get_pixel_size(),
|
|
||||||
ManagerState::get_max_target_height(&os),
|
|
||||||
));
|
|
||||||
match output_info {
|
|
||||||
Some((scale, Some(px_size), target_height)) => Some({
|
|
||||||
let height = if (px_size.width < 720) & (px_size.width > 0) {
|
|
||||||
px_size.width * 7 / 12 // to match 360×210
|
|
||||||
} else if px_size.width < 1080 {
|
|
||||||
360 + (1080 - px_size.width) * 60 / 360 // smooth transition
|
|
||||||
} else {
|
|
||||||
360
|
|
||||||
};
|
|
||||||
|
|
||||||
// Don't exceed half the display size.
|
|
||||||
let height = min(height, px_size.height / 2);
|
|
||||||
// Don't waste screen space by exceeding best target height.
|
|
||||||
let height = min(height, target_height);
|
|
||||||
height / scale
|
|
||||||
}),
|
|
||||||
Some((scale, None, _)) => Some(360 / scale),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Manager {
|
|
||||||
state: ManagerState,
|
|
||||||
surface: Option<c::PhoshLayerSurface>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Manager {
|
|
||||||
fn new() -> Manager {
|
|
||||||
Manager {
|
|
||||||
state: ManagerState { current_output: None, },
|
|
||||||
surface: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn set_output(&mut self, output: OutputHandle) {
|
|
||||||
let output_state = output.get_state()
|
|
||||||
.or_warn(
|
|
||||||
&mut logging::Print,
|
|
||||||
logging::Problem::Bug,
|
|
||||||
// This is really bad. It only happens when the layer surface
|
|
||||||
// is placed, and it happens once.
|
|
||||||
// The layer surface is on an output that can't be tracked.
|
|
||||||
"Tried to set output that's not known to exist. Ignoring.",
|
|
||||||
);
|
|
||||||
self.state.current_output = output_state.map(
|
|
||||||
|state| (output.get_id(), state)
|
|
||||||
);
|
|
||||||
// TODO: At the time of writing, this function is only used once,
|
|
||||||
// before the layer surface is initialized.
|
|
||||||
// Therefore it doesn't update anything. Maybe it should in the future,
|
|
||||||
// if it sees more use.
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_output_change(&mut self, output: OutputHandle) {
|
|
||||||
let (id, output_state) = match &self.state.current_output {
|
|
||||||
Some((id, state)) => {
|
|
||||||
if *id != output.get_id() { return } // Not the current output.
|
|
||||||
else { (id.clone(), state.clone()) }
|
|
||||||
},
|
|
||||||
None => return, // Keyboard isn't on any output.
|
|
||||||
};
|
|
||||||
if let Some(new_output_state) = output.get_state() {
|
|
||||||
if new_output_state != output_state {
|
|
||||||
let new_state = ManagerState {
|
|
||||||
current_output: Some((id.clone(), new_output_state)),
|
|
||||||
..self.state.clone()
|
|
||||||
};
|
|
||||||
if let Some(surface) = &self.surface {
|
|
||||||
let new_height = new_state.get_perceptual_height();
|
|
||||||
if new_height != self.state.get_perceptual_height() {
|
|
||||||
// TODO: here hard-size the keyboard and suggestion box too.
|
|
||||||
match new_height {
|
|
||||||
Some(new_height) => unsafe {
|
|
||||||
c::squeek_manager_set_surface_height(
|
|
||||||
*surface,
|
|
||||||
new_height,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
None => log_print!(
|
|
||||||
logging::Level::Bug,
|
|
||||||
"Can't calculate new size",
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.state = new_state;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn register_output_man(
|
|
||||||
ui_man: Rc<RefCell<Manager>>,
|
|
||||||
output_man: &mut Outputs,
|
|
||||||
) {
|
|
||||||
let ui_man = ui_man.clone();
|
|
||||||
output_man.set_update_cb(Box::new(move |output: OutputHandle| {
|
|
||||||
let mut ui_man = ui_man.borrow_mut();
|
|
||||||
ui_man.handle_output_change(output)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
@ -94,13 +94,11 @@ pub mod c {
|
|||||||
}
|
}
|
||||||
/// Extracts the reference to the data.
|
/// Extracts the reference to the data.
|
||||||
/// It may cause problems if attempted in more than one place
|
/// It may cause problems if attempted in more than one place
|
||||||
// FIXME: check for null
|
|
||||||
pub unsafe fn unwrap(self) -> Rc<RefCell<T>> {
|
pub unsafe fn unwrap(self) -> Rc<RefCell<T>> {
|
||||||
Rc::from_raw(self.0)
|
Rc::from_raw(self.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new Rc reference to the same data.
|
/// Creates a new Rc reference to the same data
|
||||||
/// Use for accessing the underlying data as a reference.
|
|
||||||
pub fn clone_ref(&self) -> Rc<RefCell<T>> {
|
pub fn clone_ref(&self) -> Rc<RefCell<T>> {
|
||||||
// A bit dangerous: the Rc may be in use elsewhere
|
// A bit dangerous: the Rc may be in use elsewhere
|
||||||
let used_rc = unsafe { Rc::from_raw(self.0) };
|
let used_rc = unsafe { Rc::from_raw(self.0) };
|
||||||
@ -108,10 +106,6 @@ pub mod c {
|
|||||||
Rc::into_raw(used_rc); // prevent dropping the original reference
|
Rc::into_raw(used_rc); // prevent dropping the original reference
|
||||||
rc
|
rc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_null(&self) -> bool {
|
|
||||||
self.0.is_null()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for Wrapped<T> {
|
impl<T> Clone for Wrapped<T> {
|
||||||
@ -136,7 +130,6 @@ pub mod c {
|
|||||||
impl<T> COpaquePtr for Wrapped<T> {}
|
impl<T> COpaquePtr for Wrapped<T> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clones the underlying data structure, like ToOwned.
|
|
||||||
pub trait CloneOwned {
|
pub trait CloneOwned {
|
||||||
type Owned;
|
type Owned;
|
||||||
fn clone_owned(&self) -> Self::Owned;
|
fn clone_owned(&self) -> Self::Owned;
|
||||||
|
|||||||
Reference in New Issue
Block a user