Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ce2cf254b | |||
| 6d7360a230 | |||
| 33039e65cb | |||
| 4007754de9 | |||
| 6abaa36db8 | |||
| 710509a671 | |||
| 16d7fcae7c | |||
| e504154571 | |||
| b19938da01 | |||
| b409df15bb | |||
| 7dd2866b17 | |||
| f6fc6c83dc | |||
| fa5c7c63d9 | |||
| 1093e32325 | |||
| 3d1a641ca3 | |||
| 0466a520f2 | |||
| 9e8aca1cbf | |||
| eb84e52897 | |||
| 0f7ff1636d | |||
| 8ff8e8ac48 | |||
| d4bb9038c5 | |||
| f3caeb8fc6 | |||
| abaaf04b87 | |||
| 2770e1769c | |||
| 3cd170acc3 | |||
| 24f709ab13 | |||
| 784f9127fa | |||
| 22daefba3a | |||
| 4ff9cf087b | |||
| 61e1ab5c5a | |||
| 7fbc9ed56e | |||
| 67cc4f11cf | |||
| 8ac2b5a713 | |||
| 8bae8fe5bb | |||
| b3cfc8a0f3 | |||
| 5a591127a1 | |||
| 8f3d010349 | |||
| 7eb5c6d466 | |||
| 9f6fe8318c | |||
| 92e9d994fe | |||
| c28f07fcfd | |||
| 80919dbc42 | |||
| cc369f6f81 | |||
| 99f2f286e3 | |||
| 46cbaf8e87 | |||
| 53b4466899 | |||
| c0aee5de26 | |||
| 404f94638f | |||
| cb802cfb50 | |||
| 930f5be0c8 | |||
| 7266f539d4 | |||
| da1f480f7a | |||
| 3c3f00ede8 | |||
| 85be855032 | |||
| 3e642fdac7 | |||
| ea288ca62e | |||
| a57a78aa2e | |||
| b441103674 | |||
| 1c3516d6bf | |||
| 41be2747d5 | |||
| c766fae686 | |||
| a0a2e40fa0 | |||
| aadcdbf276 | |||
| 10178d204b | |||
| 0ac8c620fd | |||
| 80e83781bb | |||
| 37e1ed93a6 | |||
| b770511422 | |||
| 2e9b8581e7 | |||
| 1cbc21ad11 | |||
| 416bc6163e | |||
| 40b79f6209 | |||
| 782d80a007 | |||
| a51d91eb53 | |||
| 687a512e5e | |||
| 500c23beec | |||
| 97d8dfe4cb | |||
| 11213ba13a | |||
| 3d6c656c78 | |||
| 258dd9b926 | |||
| b9db00c00c | |||
| 7f32c5cf23 | |||
| a61019c4b7 | |||
| f4f11e5051 | |||
| cd252634bd | |||
| de8aaa1a47 | |||
| 585ed5e97d | |||
| 42cb73cd8c | |||
| d1bc23e9d8 |
@ -84,3 +84,13 @@ test:
|
||||
script:
|
||||
- apt-get -y build-dep .
|
||||
- ninja -C _build test
|
||||
|
||||
check_release:
|
||||
<<: *tags
|
||||
stage: test
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
script:
|
||||
- apt-get -y install git python3
|
||||
- (head -n 1 ./debian/changelog && git tag) | ./debian/check_release.py
|
||||
|
||||
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -2,10 +2,10 @@
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.7"
|
||||
version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -254,7 +254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.0"
|
||||
version = "2.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -317,8 +317,8 @@ name = "regex"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.6.14 (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)",
|
||||
@ -457,7 +457,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744"
|
||||
"checksum aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811"
|
||||
"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 cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd940f0d609699e343ef71c4af5f66423afbf30d666f796dabd8fd15229cf5b6"
|
||||
@ -481,7 +481,7 @@ dependencies = [
|
||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
"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 memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
|
||||
"checksum memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53445de381a1f436797497c61d851644d0e8e88e6140f22872ad33a704933978"
|
||||
"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-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6eb49268e69dd0c1da5d3001a61aac08e2e9d2bfbe4ae4b19b9963c998f6453"
|
||||
|
||||
@ -56,4 +56,4 @@ $ src/squeekboard
|
||||
Developing
|
||||
----------
|
||||
|
||||
See `HACKING.md`
|
||||
See [`docs/hacking.md`](docs/hacking.md) for this copy, or the [official documentation](https://developer.puri.sm/projects/squeekboard/) for the current release.
|
||||
|
||||
@ -45,7 +45,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
|
||||
@ -45,7 +45,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
|
||||
@ -1,16 +1,80 @@
|
||||
---
|
||||
outlines:
|
||||
default: { width: 52, height: 52 }
|
||||
altline: { width: 52, height: 52 }
|
||||
altline: { width: 40, height: 52 }
|
||||
narrow: { width: 22, height: 52 }
|
||||
|
||||
views:
|
||||
base:
|
||||
- "😀 😁 😅 😂 😊 😇 🙃"
|
||||
- "😍 😘 😋 😜 😎 🥳 😔"
|
||||
- "😢 😭 😡 😱 🤔 😬 🙄"
|
||||
- "preferences 🤨 🤓 😴 🤢 🤮 😈"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
two:
|
||||
- "🤩 🤨 🤓 😴 🤢 🤮 😈"
|
||||
- "💩 🙌 👏 👍 👎 👌 👋"
|
||||
- "💪 🖕 🙏 💋 🤦♀️ 🤷♀️ 💃"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
three:
|
||||
- "🐶 🐱 🐯 🙈 🐴 🦄 🌳"
|
||||
- "🍀 🌹 💫 ⭐️ ✨ 💥 🔥"
|
||||
- "🌈 ☀️ 🌤 🌧 ⛄️ ☂️ 🌊"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
four:
|
||||
- "🍎 🍓 🍑 🍍 🍆 🥑 🥦"
|
||||
- "🍕 🎂 🍫 🍿 🍻 🍾 🍽"
|
||||
- "⚽️ 🏀 🏓 🏆 🎹 🎸 🎯"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
five:
|
||||
- "🚗 🚌 🚲 🚄 🚂 ✈️ 🛰"
|
||||
- "🚀 🛸 🚁 🚦 🏝 🏔 ⛺️"
|
||||
- "🏠 🏢 🏥 🏛 🛤 🌅 🎇"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
six:
|
||||
- "⌚️ 📱 💻 🖥 🖨 🕹 ✉️"
|
||||
- "📞 ☎️ ⏰ ⏳ 📈 📉 📌"
|
||||
- "🎁 ❤️ 💕 💯 ✅ ❎ 📢"
|
||||
- "preferences blank 1 2 3 4 5 6 blank BackSpace"
|
||||
|
||||
buttons:
|
||||
1:
|
||||
action:
|
||||
set_view: "base"
|
||||
outline: "altline"
|
||||
label: "1"
|
||||
2:
|
||||
action:
|
||||
set_view: "two"
|
||||
outline: "altline"
|
||||
label: "2"
|
||||
3:
|
||||
action:
|
||||
set_view: "three"
|
||||
outline: "altline"
|
||||
label: "3"
|
||||
4:
|
||||
action:
|
||||
set_view: "four"
|
||||
outline: "altline"
|
||||
label: "4"
|
||||
5:
|
||||
action:
|
||||
set_view: "five"
|
||||
outline: "altline"
|
||||
label: "5"
|
||||
6:
|
||||
action:
|
||||
set_view: "six"
|
||||
outline: "altline"
|
||||
label: "6"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "altline"
|
||||
icon: "keyboard-mode-symbolic"
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: BackSpace
|
||||
blank:
|
||||
outline: "narrow"
|
||||
text: ""
|
||||
|
||||
@ -44,7 +44,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "default"
|
||||
|
||||
@ -39,7 +39,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "altline"
|
||||
|
||||
@ -46,7 +46,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "altline"
|
||||
@ -46,7 +46,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "default"
|
||||
|
||||
@ -195,7 +195,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "wide"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
Return:
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
|
||||
@ -195,7 +195,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "wide"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
Return:
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
|
||||
@ -39,7 +39,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "altline"
|
||||
|
||||
@ -16,7 +16,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
space:
|
||||
outline: spaceline
|
||||
text: " "
|
||||
|
||||
110
data/keyboards/pl.yaml
Normal file
110
data/keyboards/pl.yaml
Normal file
@ -0,0 +1,110 @@
|
||||
---
|
||||
outlines:
|
||||
default: { width: 35.33, height: 52 }
|
||||
altline: { width: 52.67, height: 52 }
|
||||
wide: { width: 59, height: 52 }
|
||||
spaceline: { width: 140, height: 52 }
|
||||
special: { width: 44, height: 52 }
|
||||
|
||||
views:
|
||||
base:
|
||||
- "q w e r t y u i o p"
|
||||
- "a s d f g h j k l"
|
||||
- "Shift_L z x c v b n m BackSpace"
|
||||
- "show_numbers preferences space show_accents Return"
|
||||
upper:
|
||||
- "Q W E R T Y U I O P"
|
||||
- "A S D F G H J K L"
|
||||
- "Shift_L Z X C V B N M BackSpace"
|
||||
- "show_numbers preferences space show_upper_accents Return"
|
||||
numbers:
|
||||
- "1 2 3 4 5 6 7 8 9 0"
|
||||
- "@ # $ % & - _ + ( )"
|
||||
- "show_symbols , \" ' colon ; ! ? BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
symbols:
|
||||
- "~ ` | · √ π τ ÷ × ¶"
|
||||
- "© ® £ € ¥ ^ ° * { }"
|
||||
- "show_numbers_from_symbols \\ / < > = [ ] BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
accents:
|
||||
- "q w ę r t y u i ó p"
|
||||
- "ą ś d f g h j k ł"
|
||||
- "accents_show_upper ż ź ć v b ń m BackSpace"
|
||||
- "show_numbers preferences space show_accents Return"
|
||||
upper_accents:
|
||||
- "Q W Ę R T Y U I Ó P"
|
||||
- "Ą Ś D F G H J K Ł"
|
||||
- "accents_show_upper Ż Ź Ć V B Ń M BackSpace"
|
||||
- "show_numbers preferences space show_upper_accents Return"
|
||||
|
||||
|
||||
buttons:
|
||||
Shift_L:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "upper"
|
||||
unlock_view: "base"
|
||||
outline: "altline"
|
||||
icon: "key-shift"
|
||||
accents_show_upper:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "upper_accents"
|
||||
unlock_view: "accents"
|
||||
outline: "altline"
|
||||
icon: "key-shift"
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
icon: "keyboard-mode-symbolic"
|
||||
show_numbers:
|
||||
action:
|
||||
set_view: "numbers"
|
||||
outline: "wide"
|
||||
label: "123"
|
||||
show_numbers_from_symbols:
|
||||
action:
|
||||
set_view: "numbers"
|
||||
outline: "altline"
|
||||
label: "123"
|
||||
show_letters:
|
||||
action:
|
||||
set_view: "base"
|
||||
outline: "wide"
|
||||
label: "ABC"
|
||||
show_symbols:
|
||||
action:
|
||||
set_view: "symbols"
|
||||
outline: "altline"
|
||||
label: "*/="
|
||||
show_accents:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "accents"
|
||||
unlock_view: "base"
|
||||
outline: "altline"
|
||||
label: "ąę"
|
||||
show_upper_accents:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "upper_accents"
|
||||
unlock_view: "upper"
|
||||
outline: "altline"
|
||||
label: "ĄĘ"
|
||||
period:
|
||||
outline: "altline"
|
||||
text: "."
|
||||
space:
|
||||
outline: "spaceline"
|
||||
text: " "
|
||||
Return:
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
keysym: "Return"
|
||||
colon:
|
||||
text: ":"
|
||||
102
data/keyboards/pl_wide.yaml
Normal file
102
data/keyboards/pl_wide.yaml
Normal file
@ -0,0 +1,102 @@
|
||||
---
|
||||
outlines:
|
||||
default: { width: 54, height: 42 }
|
||||
altline: { width: 81, height: 42 }
|
||||
wide: { width: 100, height: 42 }
|
||||
spaceline: { width: 206, height: 42 }
|
||||
special: { width: 54, height: 42 }
|
||||
|
||||
views:
|
||||
base:
|
||||
- "q w e r t y u i o p"
|
||||
- "a s d f g h j k l"
|
||||
- "Shift_L z x c v b n m BackSpace"
|
||||
- "show_numbers preferences space show_accents Return"
|
||||
upper:
|
||||
- "Q W E R T Y U I O P"
|
||||
- "A S D F G H J K L"
|
||||
- "Shift_L Z X C V B N M BackSpace"
|
||||
- "show_numbers preferences space show_upper_accents Return"
|
||||
numbers:
|
||||
- "1 2 3 4 5 6 7 8 9 0"
|
||||
- "@ # $ % & - _ + ( )"
|
||||
- "show_symbols , \" ' colon ; ! ? BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
symbols:
|
||||
- "~ ` | · √ π τ ÷ × ¶"
|
||||
- "© ® £ € ¥ ^ ° * { }"
|
||||
- "show_numbers_from_symbols \\ / < > = [ ] BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
accents:
|
||||
- "q w ę r t y u i ó p"
|
||||
- "ą ś d f g h j k ł"
|
||||
- "Shift_L ż ź ć v b ń m BackSpace"
|
||||
- "show_numbers preferences space show_accents Return"
|
||||
upper_accents:
|
||||
- "Q W Ę R T Y U I Ó P"
|
||||
- "Ą Ś D F G H J K Ł"
|
||||
- "Shift_L Ż Ź Ć V B Ń M BackSpace"
|
||||
- "show_numbers preferences space show_upper_accents Return"
|
||||
|
||||
buttons:
|
||||
Shift_L:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "upper"
|
||||
unlock_view: "base"
|
||||
outline: "altline"
|
||||
icon: "key-shift"
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
icon: "keyboard-mode-symbolic"
|
||||
show_numbers:
|
||||
action:
|
||||
set_view: "numbers"
|
||||
outline: "wide"
|
||||
label: "123"
|
||||
show_numbers_from_symbols:
|
||||
action:
|
||||
set_view: "numbers"
|
||||
outline: "altline"
|
||||
label: "123"
|
||||
show_letters:
|
||||
action:
|
||||
set_view: "base"
|
||||
outline: "wide"
|
||||
label: "ABC"
|
||||
show_symbols:
|
||||
action:
|
||||
set_view: "symbols"
|
||||
outline: "altline"
|
||||
label: "*/="
|
||||
show_accents:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "accents"
|
||||
unlock_view: "base"
|
||||
outline: "altline"
|
||||
label: "ąę"
|
||||
show_upper_accents:
|
||||
action:
|
||||
locking:
|
||||
lock_view: "upper_accents"
|
||||
unlock_view: "upper"
|
||||
outline: "altline"
|
||||
label: "ĄĘ"
|
||||
period:
|
||||
outline: "altline"
|
||||
text: "."
|
||||
space:
|
||||
outline: "spaceline"
|
||||
text: " "
|
||||
Return:
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
keysym: "Return"
|
||||
colon:
|
||||
text: ":"
|
||||
@ -39,7 +39,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "altline"
|
||||
|
||||
@ -20,13 +20,13 @@ views:
|
||||
- "show_numbers preferences space show_actions Return"
|
||||
numbers:
|
||||
- "1 2 3 4 5 6 7 8 9 0"
|
||||
- "@ # $ % & - _ + ( )"
|
||||
- "* # $ / & - _ + ( )"
|
||||
- "show_symbols , \" ' colon ; ! ? BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
symbols:
|
||||
- "~ ` | · √ π τ ÷ × ¶"
|
||||
- "© ® £ € ¥ ^ ° * { }"
|
||||
- "show_numbers_from_symbols \\ / < > = [ ] BackSpace"
|
||||
- "© ® £ € ¥ ^ ° @ { }"
|
||||
- "show_numbers_from_symbols \\ % < > = [ ] BackSpace"
|
||||
- "show_letters preferences space period Return"
|
||||
actions:
|
||||
- "F1 F2 F3 F4 F5 F6"
|
||||
@ -45,7 +45,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
@ -69,14 +69,14 @@ buttons:
|
||||
action:
|
||||
set_view: "symbols"
|
||||
outline: "altline"
|
||||
label: "*/="
|
||||
label: "τ=\\"
|
||||
show_actions:
|
||||
action:
|
||||
set_view: "actions"
|
||||
outline: "altline"
|
||||
label: ">_"
|
||||
period:
|
||||
outline: "special"
|
||||
outline: "altline"
|
||||
text: "."
|
||||
space:
|
||||
outline: "spaceline"
|
||||
|
||||
@ -39,9 +39,9 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: erase
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
action: show_prefs
|
||||
outline: "special"
|
||||
icon: "keyboard-mode-symbolic"
|
||||
show_numbers:
|
||||
|
||||
@ -39,7 +39,7 @@ buttons:
|
||||
BackSpace:
|
||||
outline: "altline"
|
||||
icon: "edit-clear-symbolic"
|
||||
keysym: "BackSpace"
|
||||
action: "erase"
|
||||
preferences:
|
||||
action: "show_prefs"
|
||||
outline: "special"
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
us Englisch (US)
|
||||
de Deutsch
|
||||
el Griechisch
|
||||
es Spanisch
|
||||
it Italienisch
|
||||
jp+kana Japanisch (Kana)
|
||||
no Norwegisch
|
||||
|
||||
|
||||
@ -1,10 +1,2 @@
|
||||
us English (US)
|
||||
de German
|
||||
el Greek
|
||||
es Spanish
|
||||
fi Finnish
|
||||
it Italian
|
||||
jp+kana Japanese (kana)
|
||||
no Norwegian
|
||||
se Swedish
|
||||
|
||||
emoji Emoji
|
||||
terminal Terminal
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
us 英語 (US)
|
||||
de ドイツ語
|
||||
el ギリシャ語
|
||||
es スペイン語
|
||||
it イタリア語
|
||||
jp+kana 日本語 (かな)
|
||||
nb ノルウェー語
|
||||
|
||||
|
||||
@ -1,9 +1,2 @@
|
||||
us angielski (USA)
|
||||
de niemiecki
|
||||
el grecki
|
||||
es hiszpański
|
||||
fi fiński
|
||||
it włoski
|
||||
jp+kana japoński (kana)
|
||||
no norweski
|
||||
se szwedzki
|
||||
emoji emoji
|
||||
terminal terminal
|
||||
|
||||
90
debian/changelog
vendored
90
debian/changelog
vendored
@ -1,3 +1,93 @@
|
||||
squeekboard (1.9.0) amber-phone; urgency=medium
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
* imservice: Add commit_string method
|
||||
* submission: Handle submitting strings
|
||||
* input_method: Use for erasing
|
||||
* logging: Use in merged functions
|
||||
* translations: Remove redundant ones
|
||||
* translations: Translate builtin layouts
|
||||
* greek: Rename to gr which is used by gnome settings
|
||||
|
||||
[ Sebastian Krzyszkowiak ]
|
||||
* layouts: Add Polish layouts
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
* locks: Draw based on current view
|
||||
* locking: Lock keys statelessly
|
||||
* layouts: Better accented uppercase in PL
|
||||
* emoji: Add more choices
|
||||
* row: Eliminate angle
|
||||
* layout: Center views relative to each other and the layout bounds
|
||||
* drawing: Generalized foreach_visible_button
|
||||
* variant: Fix double-free
|
||||
* variant: Fix leak
|
||||
* keyboard_layout: Fix leak
|
||||
* layout: Improve scoping of locked variable
|
||||
* terminal: Make */ easier to reach
|
||||
|
||||
[ Sebastian Krzyszkowiak ]
|
||||
* layouts: terminal: Use altline outline for dot key
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
* text input: Disable erasing
|
||||
* cargo: Update deps
|
||||
|
||||
-- Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Wed, 19 Feb 2020 14:32:39 +0000
|
||||
|
||||
squeekboard (1.8.1) amber-phone; urgency=medium
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
* action: Rename Level to View
|
||||
* keyboard: Introduce a KeyCode type wrapping u32
|
||||
* layout: Centralize handling key releases
|
||||
* layout: Make handling presses uniform
|
||||
* UI: Drop indirection for show/hide functions
|
||||
* managers: Move visible flag to UI manager
|
||||
* dbus_service: Remove unused function
|
||||
* dbus: Remove unneeded gobjectness
|
||||
* dbus: Rename handler from eekboard_service
|
||||
* context: Moved keymap setting together with its generation
|
||||
* key-emitter: Remove unused
|
||||
* eekboard_context_service: Drop unused enable property
|
||||
* services: Split out layout management from EekboardContextService
|
||||
* submission: Move away from virtual-keyboard
|
||||
* submission: Create a new wrapper over imservice
|
||||
* imservice: Limited scope of unsafe
|
||||
* EekGtkKeyboard: Use a direct reference to EekboardContext
|
||||
* submission: Take over virtual_keyboard handling
|
||||
* keyboard: Cleanups of unused code
|
||||
* levelkeyboard: Drop unused manager references
|
||||
* keyboard: Gather up keymap handling, drop layout
|
||||
* submission: Remove wildcard reexport
|
||||
* imservice: Rename commit_state to done to match protocol
|
||||
* ci: Clean up `..` before it's searched for artifacts
|
||||
* dbus: Log error on dbus exit
|
||||
* logging: Try to improve common operations
|
||||
* imservice: Return something more resembling an Error on failure
|
||||
* logging: Unified to remove random eprint calls
|
||||
* press_key: Use proper logging
|
||||
* number: Fix keysym for Return
|
||||
* build: Strip clap of optional features
|
||||
* layouts: Fix segfault on switching to wide
|
||||
* font: Use font from style context
|
||||
* font: Only pass relevant data to label renderer
|
||||
|
||||
[ Sebastian Krzyszkowiak ]
|
||||
* layout: terminal: Swap positions of preferences and actions button
|
||||
* layout: terminal: Show actions button on all views
|
||||
* layout: terminal: Replace actions button with period on symbols view
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
* setup: Connect ui to the state manager
|
||||
* debian: Add missing commas
|
||||
|
||||
[ David Boddie ]
|
||||
* Tidy build file and docs
|
||||
* Use pip to install recommonmark
|
||||
|
||||
-- Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm> Fri, 31 Jan 2020 09:59:12 +0000
|
||||
|
||||
squeekboard (1.8.0) amber-phone; urgency=medium
|
||||
|
||||
[ Dorota Czaplejewicz ]
|
||||
|
||||
10
debian/check_release.py
vendored
Executable file
10
debian/check_release.py
vendored
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Checks tag before release.
|
||||
Feed it the first changelog line, and then all available tags.
|
||||
"""
|
||||
|
||||
import re, sys
|
||||
tag = "v" + re.findall("\\((.*)\\)", input())[0]
|
||||
if tag not in map(str.strip, sys.stdin.readlines()):
|
||||
raise Exception("Changelog's current version doesn't have a tag. Push the tag!")
|
||||
@ -3,10 +3,42 @@ Hacking
|
||||
|
||||
This document describes the standards for modifying and maintaining the *squeekboard* project.
|
||||
|
||||
Principles
|
||||
----------
|
||||
|
||||
The project was built upon some guiding principles, which should be respected primarily by the maintainers, but also by contributors to avoid needlessly rejected changes.
|
||||
|
||||
The overarching principle of *squeekboard* is to empower users.
|
||||
|
||||
Software is primarily meant to solve problems of its users. Often in the quest to make software better, a hard distinction is made between the developer, who becomes the creator, and the user, who takes the role of the consumer, without direct influence on the software they use.
|
||||
This project aims to give users the power to make the software work for them by blurring the lines between users and developers.
|
||||
|
||||
Nonwithstanding its current state, *squeekboard* must be structured in a way that provides users a gradual way to gain more experience and power to adjust it. It must be easy, in order of importance:
|
||||
|
||||
- to use the software,
|
||||
- to modify its resources,
|
||||
- to change its behaviour,
|
||||
- to contribute upstream.
|
||||
|
||||
To give an idea of what it means in practice, those are some examples of what has been important for *squeekboard* so far:
|
||||
|
||||
- being quick and useable,
|
||||
- allowing local overrides of resources and config,
|
||||
- storing resources and config as editable, standard files,
|
||||
- having complete, up to date documentation of interfaces,
|
||||
- having an easy process of sending contributions,
|
||||
- adapting to to user's settings and constrains without overriding them,
|
||||
- avoiding compiling whenever possible,
|
||||
- making it easy to build,
|
||||
- having code that is [simple and obvious](https://www.python.org/dev/peps/pep-0020/),
|
||||
- having an easy process of testing and accepting contributions.
|
||||
|
||||
You may notice that they are ordered roughly from "user-focused" to "maintainer-focused". While good properties are desired, sometimes they conflict, and maintainers should give additional weight to those benefitting the user compared to those benefitting regular contributors.
|
||||
|
||||
Sending patches
|
||||
---------------
|
||||
|
||||
By submitting a change to this project, you agree to license it under the [GPL license version 3](./COPYING), or any later version. You also certify that your contribution fulfills the [Developer's Certificate of Origin 1.1](./dco.txt).
|
||||
By submitting a change to this project, you agree to license it under the [GPL license version 3](https://source.puri.sm/Librem5/squeekboard/blob/master/COPYING), or any later version. You also certify that your contribution fulfills the [Developer's Certificate of Origin 1.1](https://source.puri.sm/Librem5/squeekboard/blob/master/dco.txt).
|
||||
|
||||
Development environment
|
||||
-----------------------
|
||||
@ -24,8 +56,7 @@ sudo apt-get -y install build-essential
|
||||
sudo apt-get -y build-dep .
|
||||
```
|
||||
|
||||
For an explicit list of dependencies check the `Build-Depends` entry in the
|
||||
[`debian/control`](./debian/control) file.
|
||||
For an explicit list of dependencies check the `Build-Depends` entry in the [`debian/control`](https://source.puri.sm/Librem5/squeekboard/blob/master/debian/control) file.
|
||||
|
||||
Testing
|
||||
-------
|
||||
10
doc/index.md
10
doc/index.md
@ -5,17 +5,23 @@ Contents
|
||||
--------
|
||||
|
||||
* [Tutorial](tutorial.md)
|
||||
* [Contributing](hacking.md)
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Squeekboard is the on-screen keyboard for the Librem 5 phone. For more information, look at the [README](https://source.puri.sm/Librem5/squeekboard/blob/master/README.md).
|
||||
Squeekboard is the on-screen keyboard for the Librem 5 phone. For information about building, look at the [README](https://source.puri.sm/Librem5/squeekboard/blob/master/README.md).
|
||||
|
||||
Layouts
|
||||
-------
|
||||
|
||||
Squeekboard allows user-provided keyboard layouts. They can be created without recompiling the keyboard code. The [tutorial](/tutorial.md) explains the process in detail.
|
||||
Squeekboard allows user-provided keyboard layouts. They can be created without recompiling the keyboard code. The [tutorial](tutorial.md) explains the process in detail.
|
||||
|
||||
Layouts are created using a text-based format, based on YAML.
|
||||
|
||||
TODO: Provide a description of the format.
|
||||
|
||||
Contributions
|
||||
-------------
|
||||
|
||||
Anyone is free to modify *squeekboard*. See the [contributing document](hacking.md).
|
||||
|
||||
@ -31,7 +31,7 @@ So at least I will try to start writing a short how-to here and edit this post a
|
||||
**Running squeekboard**
|
||||
|
||||
* Follow these instructions to run squeekboard: [https://source.puri.sm/Librem5/squeekboard/blob/master/README.md#running ](https://source.puri.sm/Librem5/squeekboard/blob/master/README.md#running)
|
||||
* Additionally take a look at https://source.puri.sm/Librem5/squeekboard/blob/master/HACKING.md#testing
|
||||
* Additionally take a look at the contribution document for [testing info](HACKING.md#testing)
|
||||
* You can either test it locally on your Linux system or use the [QEMU Librem 5 image ](https://developer.puri.sm/Librem5/Development_Environment/Boards/emulators.html)
|
||||
* To test squeekboard locally, you need phoc. Either compile that from the sources as well or use the CI repository ci.puri.sm for Debian based systems:
|
||||
`deb [arch=amd64] http://ci.puri.sm/ scratch librem5`
|
||||
|
||||
@ -41,23 +41,15 @@
|
||||
#include "src/layout.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
|
||||
{
|
||||
EekRenderer *renderer;
|
||||
EekboardContextService *eekboard_context; // unowned reference
|
||||
EekRenderer *renderer; // owned, nullable
|
||||
LayoutHolder *eekboard_context; // 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
|
||||
} EekGtkKeyboardPrivate;
|
||||
@ -88,31 +80,59 @@ eek_gtk_keyboard_real_draw (GtkWidget *self,
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation (self, &allocation);
|
||||
|
||||
if (!priv->keyboard) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!priv->renderer) {
|
||||
PangoContext *pcontext = gtk_widget_get_pango_context (self);
|
||||
|
||||
priv->renderer = eek_renderer_new (priv->keyboard, pcontext);
|
||||
priv->renderer = eek_renderer_new (
|
||||
priv->keyboard,
|
||||
pcontext);
|
||||
|
||||
eek_renderer_set_allocation_size (priv->renderer,
|
||||
priv->keyboard->layout,
|
||||
allocation.width,
|
||||
allocation.height);
|
||||
eek_renderer_set_scale_factor (priv->renderer,
|
||||
gtk_widget_get_scale_factor (self));
|
||||
}
|
||||
|
||||
eek_renderer_render_keyboard (priv->renderer, cr);
|
||||
eek_renderer_render_keyboard (priv->renderer, priv->submission, cr, priv->keyboard);
|
||||
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
|
||||
eek_gtk_keyboard_real_size_allocate (GtkWidget *self,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
EekGtkKeyboardPrivate *priv =
|
||||
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)
|
||||
eek_renderer_set_allocation_size (priv->renderer,
|
||||
priv->keyboard->layout,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
|
||||
@ -124,7 +144,9 @@ static void depress(EekGtkKeyboard *self,
|
||||
gdouble x, gdouble y, guint32 time)
|
||||
{
|
||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||
|
||||
if (!priv->keyboard) {
|
||||
return;
|
||||
}
|
||||
squeek_layout_depress(priv->keyboard->layout,
|
||||
priv->submission,
|
||||
x, y, eek_renderer_get_transformation(priv->renderer), time, self);
|
||||
@ -134,7 +156,10 @@ static void drag(EekGtkKeyboard *self,
|
||||
gdouble x, gdouble y, guint32 time)
|
||||
{
|
||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||
squeek_layout_drag(priv->keyboard->layout,
|
||||
if (!priv->keyboard) {
|
||||
return;
|
||||
}
|
||||
squeek_layout_drag(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout,
|
||||
priv->submission,
|
||||
x, y, eek_renderer_get_transformation(priv->renderer), time,
|
||||
priv->eekboard_context, self);
|
||||
@ -143,8 +168,10 @@ static void drag(EekGtkKeyboard *self,
|
||||
static void release(EekGtkKeyboard *self, guint32 time)
|
||||
{
|
||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||
|
||||
squeek_layout_release(priv->keyboard->layout,
|
||||
if (!priv->keyboard) {
|
||||
return;
|
||||
}
|
||||
squeek_layout_release(eek_layout_holder_get_keyboard(priv->eekboard_context)->layout,
|
||||
priv->submission,
|
||||
eek_renderer_get_transformation(priv->renderer), time,
|
||||
priv->eekboard_context, self);
|
||||
@ -264,7 +291,7 @@ eek_gtk_keyboard_dispose (GObject *object)
|
||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||
|
||||
if (priv->renderer) {
|
||||
g_object_unref (priv->renderer);
|
||||
eek_renderer_free(priv->renderer);
|
||||
priv->renderer = NULL;
|
||||
priv->renderer = NULL;
|
||||
}
|
||||
@ -311,26 +338,46 @@ eek_gtk_keyboard_init (EekGtkKeyboard *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.
|
||||
* Returns: a #GtkWidget
|
||||
*/
|
||||
GtkWidget *
|
||||
eek_gtk_keyboard_new (LevelKeyboard *keyboard, EekboardContextService *eekservice,
|
||||
struct submission *submission)
|
||||
eek_gtk_keyboard_new (LayoutHolder *eekservice,
|
||||
struct submission *submission,
|
||||
struct squeek_layout_state *layout)
|
||||
{
|
||||
EekGtkKeyboard *ret = EEK_GTK_KEYBOARD(g_object_new (EEK_TYPE_GTK_KEYBOARD, NULL));
|
||||
EekGtkKeyboardPrivate *priv = (EekGtkKeyboardPrivate*)eek_gtk_keyboard_get_instance_private (ret);
|
||||
priv->keyboard = keyboard;
|
||||
priv->eekboard_context = eekservice;
|
||||
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);
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
struct submission;
|
||||
typedef struct _LevelKeyboard LevelKeyboard; // including causes weird bugs
|
||||
struct squeek_layout_state;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#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;
|
||||
GtkWidget *eek_gtk_keyboard_new (LevelKeyboard *keyboard, EekboardContextService *eekservice, struct submission *submission);
|
||||
GtkWidget *eek_gtk_keyboard_new (LayoutHolder *eekservice, struct submission *submission, struct squeek_layout_state *layout);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* EEK_GTK_KEYBOARD_H */
|
||||
|
||||
@ -38,10 +38,8 @@ void level_keyboard_free(LevelKeyboard *self) {
|
||||
}
|
||||
|
||||
LevelKeyboard*
|
||||
level_keyboard_new (const gchar *keyboard_type,
|
||||
enum squeek_arrangement_kind t)
|
||||
level_keyboard_new (struct squeek_layout *layout)
|
||||
{
|
||||
struct squeek_layout *layout = squeek_load_layout(keyboard_type, t);
|
||||
LevelKeyboard *keyboard = g_new0(LevelKeyboard, 1);
|
||||
|
||||
if (!keyboard) {
|
||||
|
||||
@ -47,8 +47,7 @@ gchar * eek_keyboard_get_keymap
|
||||
(LevelKeyboard *keyboard);
|
||||
|
||||
LevelKeyboard*
|
||||
level_keyboard_new (const gchar *keyboard_type,
|
||||
enum squeek_arrangement_kind t);
|
||||
level_keyboard_new (struct squeek_layout *layout);
|
||||
void level_keyboard_free(LevelKeyboard *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -28,27 +28,6 @@
|
||||
#include "eek-renderer.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 */
|
||||
static void render_button_label (cairo_t *cr, GtkStyleContext *ctx,
|
||||
@ -138,9 +117,7 @@ eek_render_button (EekRenderer *self,
|
||||
gboolean pressed,
|
||||
gboolean locked)
|
||||
{
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||
|
||||
GtkStyleContext *ctx = priv->button_context;
|
||||
GtkStyleContext *ctx = self->button_context;
|
||||
/* Set the name of the button on the widget path, using the name obtained
|
||||
from the button's symbol. */
|
||||
g_autoptr (GtkWidgetPath) path = NULL;
|
||||
@ -160,7 +137,7 @@ eek_render_button (EekRenderer *self,
|
||||
}
|
||||
gtk_style_context_add_class(ctx, outline_name);
|
||||
|
||||
render_button_in_context(priv->scale_factor, cr, ctx, button);
|
||||
render_button_in_context(self->scale_factor, cr, ctx, button);
|
||||
|
||||
// Save and restore functions don't work if gtk_render_* was used in between
|
||||
gtk_style_context_set_state(ctx, GTK_STATE_FLAG_NORMAL);
|
||||
@ -214,118 +191,46 @@ render_button_label (cairo_t *cr,
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
// FIXME: Pass just the active modifiers instead of entire submission
|
||||
void
|
||||
eek_renderer_render_keyboard (EekRenderer *self,
|
||||
cairo_t *cr)
|
||||
struct submission *submission,
|
||||
cairo_t *cr,
|
||||
LevelKeyboard *keyboard)
|
||||
{
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (priv->keyboard);
|
||||
g_return_if_fail (priv->allocation_width > 0.0);
|
||||
g_return_if_fail (priv->allocation_height > 0.0);
|
||||
g_return_if_fail (self->allocation_width > 0.0);
|
||||
g_return_if_fail (self->allocation_height > 0.0);
|
||||
|
||||
/* Paint the background covering the entire widget area */
|
||||
gtk_render_background (priv->view_context,
|
||||
gtk_render_background (self->view_context,
|
||||
cr,
|
||||
0, 0,
|
||||
priv->allocation_width, priv->allocation_height);
|
||||
self->allocation_width, self->allocation_height);
|
||||
|
||||
cairo_save(cr);
|
||||
cairo_translate (cr, priv->widget_to_layout.origin_x, priv->widget_to_layout.origin_y);
|
||||
cairo_scale (cr, priv->widget_to_layout.scale, priv->widget_to_layout.scale);
|
||||
cairo_translate (cr, self->widget_to_layout.origin_x, self->widget_to_layout.origin_y);
|
||||
cairo_scale (cr, self->widget_to_layout.scale, self->widget_to_layout.scale);
|
||||
|
||||
squeek_draw_layout_base_view(priv->keyboard->layout, self, cr);
|
||||
squeek_layout_draw_all_changed(priv->keyboard->layout, self, cr);
|
||||
squeek_draw_layout_base_view(keyboard->layout, self, cr);
|
||||
squeek_layout_draw_all_changed(keyboard->layout, self, cr, submission);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
eek_renderer_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
void
|
||||
eek_renderer_free (EekRenderer *self)
|
||||
{
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (
|
||||
EEK_RENDERER(object));
|
||||
|
||||
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;
|
||||
if (self->pcontext) {
|
||||
g_object_unref (self->pcontext);
|
||||
self->pcontext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
g_object_unref(self->css_provider);
|
||||
g_object_unref(self->view_context);
|
||||
g_object_unref(self->button_context);
|
||||
// this is where renderer-specific surfaces would be released
|
||||
|
||||
G_OBJECT_CLASS (eek_renderer_parent_class)->dispose (object);
|
||||
free(self);
|
||||
}
|
||||
|
||||
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) {
|
||||
GTypeInfo info = {0};
|
||||
info.class_size = sizeof(GtkWidgetClass);
|
||||
@ -353,81 +258,75 @@ static GType button_type() {
|
||||
}
|
||||
|
||||
static void
|
||||
eek_renderer_init (EekRenderer *self)
|
||||
renderer_init (EekRenderer *self)
|
||||
{
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (self);
|
||||
|
||||
priv->keyboard = NULL;
|
||||
priv->pcontext = NULL;
|
||||
priv->allocation_width = 0.0;
|
||||
priv->allocation_height = 0.0;
|
||||
priv->scale_factor = 1;
|
||||
self->pcontext = NULL;
|
||||
self->allocation_width = 0.0;
|
||||
self->allocation_height = 0.0;
|
||||
self->scale_factor = 1;
|
||||
|
||||
GtkIconTheme *theme = gtk_icon_theme_get_default ();
|
||||
|
||||
gtk_icon_theme_add_resource_path (theme, "/sm/puri/squeekboard/icons");
|
||||
|
||||
priv->css_provider = squeek_load_style();
|
||||
self->css_provider = squeek_load_style();
|
||||
}
|
||||
|
||||
EekRenderer *
|
||||
eek_renderer_new (LevelKeyboard *keyboard,
|
||||
PangoContext *pcontext)
|
||||
{
|
||||
EekRenderer *renderer = g_object_new (EEK_TYPE_RENDERER,
|
||||
"pango-context", pcontext,
|
||||
NULL);
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||
priv->keyboard = keyboard;
|
||||
EekRenderer *renderer = calloc(1, sizeof(EekRenderer));
|
||||
renderer_init(renderer);
|
||||
renderer->pcontext = pcontext;
|
||||
g_object_ref (renderer->pcontext);
|
||||
|
||||
/* Create a style context for the layout */
|
||||
GtkWidgetPath *path = gtk_widget_path_new();
|
||||
gtk_widget_path_append_type(path, view_type());
|
||||
|
||||
priv->view_context = gtk_style_context_new();
|
||||
gtk_style_context_set_path(priv->view_context, path);
|
||||
renderer->view_context = gtk_style_context_new();
|
||||
gtk_style_context_set_path(renderer->view_context, path);
|
||||
gtk_widget_path_unref(path);
|
||||
if (squeek_layout_get_kind(priv->keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||
gtk_style_context_add_class(priv->view_context, "wide");
|
||||
if (squeek_layout_get_kind(keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||
gtk_style_context_add_class(renderer->view_context, "wide");
|
||||
}
|
||||
gtk_style_context_add_provider (priv->view_context,
|
||||
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||
gtk_style_context_add_provider (renderer->view_context,
|
||||
GTK_STYLE_PROVIDER(renderer->css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
/* Create a style context for the buttons */
|
||||
path = gtk_widget_path_new();
|
||||
gtk_widget_path_append_type(path, view_type());
|
||||
if (squeek_layout_get_kind(priv->keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||
if (squeek_layout_get_kind(keyboard->layout) == ARRANGEMENT_KIND_WIDE) {
|
||||
gtk_widget_path_iter_add_class(path, -1, "wide");
|
||||
}
|
||||
gtk_widget_path_append_type(path, button_type());
|
||||
priv->button_context = gtk_style_context_new ();
|
||||
gtk_style_context_set_path(priv->button_context, path);
|
||||
renderer->button_context = gtk_style_context_new ();
|
||||
gtk_style_context_set_path(renderer->button_context, path);
|
||||
gtk_widget_path_unref(path);
|
||||
gtk_style_context_set_parent(priv->button_context, priv->view_context);
|
||||
gtk_style_context_set_state (priv->button_context, GTK_STATE_FLAG_NORMAL);
|
||||
gtk_style_context_add_provider (priv->button_context,
|
||||
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||
gtk_style_context_set_parent(renderer->button_context, renderer->view_context);
|
||||
gtk_style_context_set_state (renderer->button_context, GTK_STATE_FLAG_NORMAL);
|
||||
gtk_style_context_add_provider (renderer->button_context,
|
||||
GTK_STYLE_PROVIDER(renderer->css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
void
|
||||
eek_renderer_set_allocation_size (EekRenderer *renderer,
|
||||
struct squeek_layout *layout,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||
g_return_if_fail (width > 0.0 && height > 0.0);
|
||||
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||
renderer->allocation_width = width;
|
||||
renderer->allocation_height = height;
|
||||
|
||||
priv->allocation_width = width;
|
||||
priv->allocation_height = height;
|
||||
|
||||
priv->widget_to_layout = squeek_layout_calculate_transformation(
|
||||
priv->keyboard->layout,
|
||||
priv->allocation_width, priv->allocation_height);
|
||||
renderer->widget_to_layout = squeek_layout_calculate_transformation(
|
||||
layout,
|
||||
renderer->allocation_width, renderer->allocation_height);
|
||||
|
||||
// This is where size-dependent surfaces would be released
|
||||
}
|
||||
@ -435,10 +334,7 @@ eek_renderer_set_allocation_size (EekRenderer *renderer,
|
||||
void
|
||||
eek_renderer_set_scale_factor (EekRenderer *renderer, gint scale)
|
||||
{
|
||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||
priv->scale_factor = scale;
|
||||
renderer->scale_factor = scale;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
@ -467,9 +363,5 @@ eek_renderer_get_icon_surface (const gchar *icon_name,
|
||||
|
||||
struct transformation
|
||||
eek_renderer_get_transformation (EekRenderer *renderer) {
|
||||
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;
|
||||
return renderer->widget_to_layout;
|
||||
}
|
||||
|
||||
@ -25,31 +25,36 @@
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
#include "eek-types.h"
|
||||
#include "src/submission.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
struct squeek_layout;
|
||||
|
||||
#define EEK_TYPE_RENDERER (eek_renderer_get_type())
|
||||
G_DECLARE_DERIVABLE_TYPE (EekRenderer, eek_renderer, EEK, RENDERER, GObject)
|
||||
|
||||
struct _EekRendererClass
|
||||
/// Renders LevelKayboards
|
||||
/// It cannot adjust styles at runtime.
|
||||
typedef struct EekRenderer
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
PangoContext *pcontext; // owned
|
||||
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
|
||||
|
||||
cairo_surface_t *(* get_icon_surface) (EekRenderer *self,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
gint scale);
|
||||
// Mutable state
|
||||
/// Background extents
|
||||
gdouble allocation_width;
|
||||
gdouble allocation_height;
|
||||
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;
|
||||
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
||||
PangoContext *pcontext);
|
||||
void eek_renderer_set_allocation_size
|
||||
(EekRenderer *renderer,
|
||||
(EekRenderer *renderer, struct squeek_layout *layout,
|
||||
gdouble width,
|
||||
gdouble height);
|
||||
void eek_renderer_set_scale_factor (EekRenderer *renderer,
|
||||
@ -59,8 +64,10 @@ cairo_surface_t *eek_renderer_get_icon_surface(const gchar *icon_name,
|
||||
gint size,
|
||||
gint scale);
|
||||
|
||||
void eek_renderer_render_keyboard (EekRenderer *renderer,
|
||||
cairo_t *cr);
|
||||
void eek_renderer_render_keyboard (EekRenderer *renderer, struct submission *submission,
|
||||
cairo_t *cr, LevelKeyboard *keyboard);
|
||||
void
|
||||
eek_renderer_free (EekRenderer *self);
|
||||
|
||||
struct transformation
|
||||
eek_renderer_get_transformation (EekRenderer *renderer);
|
||||
|
||||
@ -37,7 +37,7 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _EekBounds EekBounds;
|
||||
|
||||
typedef struct _EekboardContextService EekboardContextService;
|
||||
typedef struct _LayoutHolder LayoutHolder;
|
||||
typedef struct _ServerContextService ServerContextService;
|
||||
typedef struct _LevelKeyboard LevelKeyboard;
|
||||
|
||||
|
||||
@ -35,34 +35,17 @@ enum {
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
enum {
|
||||
DESTROYED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
#define LAYOUT_HOLDER_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, 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 {
|
||||
struct _LayoutHolderPrivate {
|
||||
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
|
||||
struct submission *submission; // unowned
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (LayoutHolder, layout_holder, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
eekboard_context_service_set_property (GObject *object,
|
||||
@ -79,12 +62,12 @@ eekboard_context_service_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_service_get_property (GObject *object,
|
||||
layout_holder_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||
LayoutHolder *context = LAYOUT_HOLDER(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_KEYBOARD:
|
||||
@ -96,60 +79,52 @@ eekboard_context_service_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
|
||||
settings_get_layout(GSettings *settings, char **type, char **layout)
|
||||
{
|
||||
if (!settings) {
|
||||
return;
|
||||
}
|
||||
GVariant *inputs = g_settings_get_value(settings, "sources");
|
||||
if (g_variant_n_children(inputs) == 0) {
|
||||
g_warning("No system layout present");
|
||||
*type = NULL;
|
||||
*layout = NULL;
|
||||
} else {
|
||||
// current layout is always first
|
||||
g_variant_get_child(inputs, 0, "(ss)", type, layout);
|
||||
}
|
||||
g_variant_unref(inputs);
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_update_layout(EekboardContextService *context, enum squeek_arrangement_kind t)
|
||||
{
|
||||
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);
|
||||
}
|
||||
eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *state) {
|
||||
*context->layout = *state;
|
||||
gchar *layout_name = state->overlay_name;
|
||||
|
||||
if (!keyboard_layout) {
|
||||
keyboard_layout = g_strdup("us");
|
||||
}
|
||||
if (layout_name == NULL) {
|
||||
layout_name = state->layout_name;
|
||||
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
switch (priv->purpose) {
|
||||
switch (state->purpose) {
|
||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER:
|
||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE:
|
||||
keyboard_layout = g_strdup("number");
|
||||
layout_name = "number";
|
||||
break;
|
||||
case ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL:
|
||||
keyboard_layout = g_strdup("terminal");
|
||||
layout_name = "terminal";
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if (layout_name == NULL) {
|
||||
layout_name = "us";
|
||||
}
|
||||
}
|
||||
|
||||
// generic part follows
|
||||
LevelKeyboard *keyboard = level_keyboard_new(keyboard_layout, t);
|
||||
struct squeek_layout *layout = squeek_load_layout(layout_name, state->arrangement);
|
||||
LevelKeyboard *keyboard = level_keyboard_new(layout);
|
||||
// set as current
|
||||
LevelKeyboard *previous_keyboard = context->priv->keyboard;
|
||||
context->priv->keyboard = keyboard;
|
||||
@ -159,6 +134,7 @@ eekboard_context_service_update_layout(EekboardContextService *context, enum squ
|
||||
submission_set_keyboard(context->priv->submission, keyboard);
|
||||
}
|
||||
|
||||
// Update UI
|
||||
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)
|
||||
@ -167,67 +143,22 @@ eekboard_context_service_update_layout(EekboardContextService *context, enum squ
|
||||
}
|
||||
}
|
||||
|
||||
static void update_layout_and_type(EekboardContextService *context) {
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
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
|
||||
layout_holder_init (LayoutHolder *self) {
|
||||
self->priv = LAYOUT_HOLDER_GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
static void
|
||||
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)
|
||||
layout_holder_class_init (LayoutHolderClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
gobject_class->constructed = eekboard_context_service_constructed;
|
||||
gobject_class->set_property = eekboard_context_service_set_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);
|
||||
gobject_class->get_property = layout_holder_get_property;
|
||||
|
||||
/**
|
||||
* EekboardContextService:keyboard:
|
||||
*
|
||||
* An #EekKeyboard currently active in this context.
|
||||
* An #LevelKeyboard currently active in this context.
|
||||
*/
|
||||
pspec = g_param_spec_pointer("keyboard",
|
||||
"Keyboard",
|
||||
@ -238,92 +169,115 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
||||
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.
|
||||
* Returns: (transfer none): an #EekKeyboard
|
||||
* Returns: (transfer none): a LevelKeyboard
|
||||
*/
|
||||
LevelKeyboard *
|
||||
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||
eek_layout_holder_get_keyboard (LayoutHolder *context)
|
||||
{
|
||||
return context->priv->keyboard;
|
||||
}
|
||||
|
||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
||||
void eekboard_context_service_set_hint_purpose(LayoutHolder *context,
|
||||
uint32_t hint, uint32_t purpose)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->hint != hint || priv->purpose != purpose) {
|
||||
priv->hint = hint;
|
||||
priv->purpose = purpose;
|
||||
update_layout_and_type(context);
|
||||
if (context->layout->hint != hint || context->layout->purpose != purpose) {
|
||||
context->layout->hint = hint;
|
||||
context->layout->purpose = purpose;
|
||||
eek_layout_holder_use_layout(context, context->layout);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_set_overlay(EekboardContextService *context, const char* name) {
|
||||
context->priv->overlay = g_strdup(name);
|
||||
update_layout_and_type(context);
|
||||
eekboard_context_service_set_overlay(LayoutHolder *context, const char* name) {
|
||||
if (g_strcmp0(context->layout->overlay_name, name)) {
|
||||
g_free(context->layout->overlay_name);
|
||||
context->layout->overlay_name = g_strdup(name);
|
||||
eek_layout_holder_use_layout(context, context->layout);
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
eekboard_context_service_get_overlay(EekboardContextService *context) {
|
||||
return context->priv->overlay;
|
||||
eekboard_context_service_get_overlay(LayoutHolder *context) {
|
||||
return context->layout->overlay_name;
|
||||
}
|
||||
|
||||
EekboardContextService *eekboard_context_service_new(void)
|
||||
LayoutHolder *eek_layout_holder_new(struct squeek_layout_state *state)
|
||||
{
|
||||
return g_object_new (EEKBOARD_TYPE_CONTEXT_SERVICE, NULL);
|
||||
LayoutHolder *context = g_object_new (EEKBOARD_TYPE_LAYOUT_HOLDER, NULL);
|
||||
context->layout = state;
|
||||
eek_layout_holder_use_layout(context, context->layout);
|
||||
return context;
|
||||
}
|
||||
|
||||
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) {
|
||||
void eek_layout_holder_set_submission(LayoutHolder *context, struct submission *submission) {
|
||||
context->priv->submission = submission;
|
||||
if (context->priv->submission) {
|
||||
submission_set_keyboard(context->priv->submission, context->priv->keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) {
|
||||
context->priv->ui = ui;
|
||||
static void settings_update_layout(struct gsettings_tracker *self) {
|
||||
// The layout in the param must be the same layout as held by context.
|
||||
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,74 +30,60 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define EEKBOARD_CONTEXT_SERVICE_PATH "/org/fedorahosted/Eekboard/Context_%d"
|
||||
#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_TYPE_LAYOUT_HOLDER (layout_holder_get_type())
|
||||
#define LAYOUT_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_LAYOUT_HOLDER, LayoutHolder))
|
||||
#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_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))
|
||||
|
||||
|
||||
typedef struct _EekboardContextServiceClass EekboardContextServiceClass;
|
||||
typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
|
||||
typedef struct _LayoutHolderClass LayoutHolderClass;
|
||||
typedef struct _LayoutHolderPrivate LayoutHolderPrivate;
|
||||
|
||||
/**
|
||||
* EekboardContextService:
|
||||
*
|
||||
* Handles layout state, gsettings, and virtual-keyboard.
|
||||
* Handles layout state, and virtual-keyboard.
|
||||
*
|
||||
* TODO: Restrict to managing keyboard layouts, and maybe button repeats,
|
||||
* and the virtual keyboard protocol.
|
||||
*
|
||||
* The #EekboardContextService structure contains only private data
|
||||
* and should only be accessed using the provided API.
|
||||
*/
|
||||
struct _EekboardContextService {
|
||||
struct _LayoutHolder {
|
||||
GObject parent;
|
||||
|
||||
EekboardContextServicePrivate *priv;
|
||||
LayoutHolderPrivate *priv;
|
||||
struct squeek_layout_state *layout; // Unowned
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
struct _LayoutHolderClass {
|
||||
/*< private >*/
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
struct squeek_view *(*create_keyboard) (EekboardContextService *self,
|
||||
const gchar *keyboard_type);
|
||||
|
||||
/* signals */
|
||||
void (*destroyed) (EekboardContextService *self);
|
||||
|
||||
/*< private >*/
|
||||
/* padding */
|
||||
gpointer pdummy[24];
|
||||
};
|
||||
|
||||
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);
|
||||
GType layout_holder_get_type(void) G_GNUC_CONST;
|
||||
|
||||
void eekboard_context_service_set_keymap(EekboardContextService *context,
|
||||
/// Handles gsettings os-level keyboard layout switches.
|
||||
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);
|
||||
|
||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
||||
void eekboard_context_service_set_hint_purpose(LayoutHolder *context,
|
||||
uint32_t hint,
|
||||
uint32_t purpose);
|
||||
void
|
||||
eekboard_context_service_update_layout(EekboardContextService *context, enum squeek_arrangement_kind t);
|
||||
eek_layout_holder_use_layout(LayoutHolder *context, struct squeek_layout_state *layout);
|
||||
G_END_DECLS
|
||||
#endif /* EEKBOARD_CONTEXT_SERVICE_H */
|
||||
|
||||
17
squeekboard.doap
Normal file
17
squeekboard.doap
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns="http://usefulinc.com/ns/doap#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:admin="http://webns.net/mvcb/">
|
||||
<name>squeekboard</name>
|
||||
<shortdesc>A Wayland virtual keyboard</shortdesc>
|
||||
<description>A virtual keyboard supporting Wayland, built primarily for the Librem 5 phone.</description>
|
||||
<homepage rdf:resource="https://source.puri.sm/Librem5/squeekboard" />
|
||||
<bug-database rdf:resource="https://source.puri.sm/Librem5/squeekboard/issues" />
|
||||
<os>Linux</os>
|
||||
<license rdf:resource="http://usefulinc.com/doap/licenses/gpl" />
|
||||
<maintainer>
|
||||
<foaf:Person>
|
||||
<foaf:name>Dorota Czaplejewicz</foaf:name>
|
||||
<foaf:mbox rdf:resource="mailto:dorota.czaplejewicz@puri.sm" />
|
||||
</foaf:Person>
|
||||
</maintainer>
|
||||
|
||||
</Project>
|
||||
@ -10,8 +10,11 @@ pub struct KeySym(pub String);
|
||||
type View = String;
|
||||
|
||||
/// Use to send modified keypresses
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Modifier {
|
||||
/// Control and Alt are the only modifiers
|
||||
/// which doesn't interfere with levels,
|
||||
/// so it's simple to implement as levels are deprecated in squeekboard.
|
||||
Control,
|
||||
Alt,
|
||||
}
|
||||
@ -27,14 +30,33 @@ pub enum Action {
|
||||
/// When unlocked by pressing it or emitting a key
|
||||
unlock: View,
|
||||
},
|
||||
/// Set this modifier TODO: release?
|
||||
SetModifier(Modifier),
|
||||
/// Hold this modifier for as long as the button is pressed
|
||||
ApplyModifier(Modifier),
|
||||
/// Submit some text
|
||||
Submit {
|
||||
/// Text to submit with input-method
|
||||
/// Text to submit with input-method.
|
||||
/// If None, then keys are to be submitted instead.
|
||||
text: Option<CString>,
|
||||
/// The key events this symbol submits when submitting text is not possible
|
||||
keys: Vec<KeySym>,
|
||||
},
|
||||
/// Erase a position behind the cursor
|
||||
Erase,
|
||||
ShowPreferences,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
pub fn is_locked(&self, view_name: &str) -> bool {
|
||||
match self {
|
||||
Action::LockView { lock, unlock: _ } => lock == view_name,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
pub fn is_active(&self, view_name: &str) -> bool {
|
||||
match self {
|
||||
Action::SetView(view) => view == view_name,
|
||||
Action::LockView { lock, unlock: _ } => lock == view_name,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
107
src/data.rs
107
src/data.rs
@ -15,6 +15,7 @@ use std::vec::Vec;
|
||||
|
||||
use xkbcommon::xkb;
|
||||
|
||||
use ::action;
|
||||
use ::keyboard::{
|
||||
KeyState, PressType,
|
||||
generate_keymap, generate_keycodes, FormattingError
|
||||
@ -239,14 +240,20 @@ type ButtonIds = String;
|
||||
#[derive(Debug, Default, Deserialize, PartialEq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct ButtonMeta {
|
||||
/// Special action to perform on activation. Conflicts with keysym, text.
|
||||
// TODO: structure (action, keysym, text, modifier) as an enum
|
||||
// to detect conflicts and missing values at compile time
|
||||
/// Special action to perform on activation.
|
||||
/// Conflicts with keysym, text, modifier.
|
||||
action: Option<Action>,
|
||||
/// The name of the XKB keysym to emit on activation.
|
||||
/// Conflicts with action, text
|
||||
/// Conflicts with action, text, modifier.
|
||||
keysym: Option<String>,
|
||||
/// The text to submit on activation. Will be derived from ID if not present
|
||||
/// Conflicts with action, keysym
|
||||
/// Conflicts with action, keysym, modifier.
|
||||
text: Option<String>,
|
||||
/// The modifier to apply while the key is locked
|
||||
/// Conflicts with action, keysym, text
|
||||
modifier: Option<Modifier>,
|
||||
/// If not present, will be derived from text or the button ID
|
||||
label: Option<String>,
|
||||
/// Conflicts with label
|
||||
@ -264,6 +271,23 @@ enum Action {
|
||||
SetView(String),
|
||||
#[serde(rename="show_prefs")]
|
||||
ShowPrefs,
|
||||
/// Remove last character
|
||||
#[serde(rename="erase")]
|
||||
Erase,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
enum Modifier {
|
||||
Control,
|
||||
Shift,
|
||||
Lock,
|
||||
#[serde(alias="Mod1")]
|
||||
Alt,
|
||||
Mod2,
|
||||
Mod3,
|
||||
Mod4,
|
||||
Mod5,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
@ -386,13 +410,16 @@ impl Layout {
|
||||
)
|
||||
}).collect()
|
||||
},
|
||||
action::Action::Erase => vec![
|
||||
*keymap.get("BackSpace")
|
||||
.expect(&format!("BackSpace missing from keymap")),
|
||||
],
|
||||
_ => Vec::new(),
|
||||
};
|
||||
(
|
||||
name.into(),
|
||||
KeyState {
|
||||
pressed: PressType::Released,
|
||||
locked: false,
|
||||
keycodes,
|
||||
action,
|
||||
}
|
||||
@ -417,8 +444,8 @@ impl Layout {
|
||||
)}
|
||||
);
|
||||
|
||||
let views = HashMap::from_iter(
|
||||
self.views.iter().map(|(name, view)| {
|
||||
let views: Vec<_> = self.views.iter()
|
||||
.map(|(name, view)| {
|
||||
let rows = view.iter().map(|row| {
|
||||
let buttons = row.split_ascii_whitespace()
|
||||
.map(|name| {
|
||||
@ -432,8 +459,7 @@ impl Layout {
|
||||
&mut warning_handler,
|
||||
))
|
||||
});
|
||||
::layout::Row {
|
||||
angle: 0,
|
||||
layout::Row {
|
||||
buttons: add_offsets(
|
||||
buttons,
|
||||
|button| button.size.width,
|
||||
@ -446,9 +472,26 @@ impl Layout {
|
||||
name.clone(),
|
||||
layout::View::new(rows)
|
||||
)
|
||||
})
|
||||
}).collect();
|
||||
|
||||
// Center views on the same point.
|
||||
let views = {
|
||||
let total_size = layout::View::calculate_super_size(
|
||||
views.iter().map(|(_name, view)| view).collect()
|
||||
);
|
||||
|
||||
HashMap::from_iter(views.into_iter().map(|(name, view)| (
|
||||
name,
|
||||
(
|
||||
layout::c::Point {
|
||||
x: (total_size.width - view.get_width()) / 2.0,
|
||||
y: (total_size.height - view.get_height()) / 2.0,
|
||||
},
|
||||
view,
|
||||
),
|
||||
)))
|
||||
};
|
||||
|
||||
(
|
||||
Ok(::layout::LayoutData {
|
||||
views: views,
|
||||
@ -487,22 +530,27 @@ fn create_action<H: logging::Handler>(
|
||||
Action(Action),
|
||||
Text(String),
|
||||
Keysym(String),
|
||||
Modifier(Modifier),
|
||||
};
|
||||
|
||||
let submission = match (
|
||||
&symbol_meta.action,
|
||||
&symbol_meta.keysym,
|
||||
&symbol_meta.text
|
||||
&symbol_meta.text,
|
||||
&symbol_meta.modifier,
|
||||
) {
|
||||
(Some(action), None, None) => SubmitData::Action(action.clone()),
|
||||
(None, Some(keysym), None) => SubmitData::Keysym(keysym.clone()),
|
||||
(None, None, Some(text)) => SubmitData::Text(text.clone()),
|
||||
(None, None, None) => SubmitData::Text(name.into()),
|
||||
(Some(action), None, None, None) => SubmitData::Action(action.clone()),
|
||||
(None, Some(keysym), None, None) => SubmitData::Keysym(keysym.clone()),
|
||||
(None, None, Some(text), None) => SubmitData::Text(text.clone()),
|
||||
(None, None, None, Some(modifier)) => {
|
||||
SubmitData::Modifier(modifier.clone())
|
||||
},
|
||||
(None, None, None, None) => SubmitData::Text(name.into()),
|
||||
_ => {
|
||||
warning_handler.handle(
|
||||
logging::Level::Warning,
|
||||
&format!(
|
||||
"Button {} has more than one of (action, keysym, text)",
|
||||
"Button {} has more than one of (action, keysym, text, modifier)",
|
||||
name,
|
||||
),
|
||||
);
|
||||
@ -558,6 +606,7 @@ fn create_action<H: logging::Handler>(
|
||||
SubmitData::Action(
|
||||
Action::ShowPrefs
|
||||
) => ::action::Action::ShowPreferences,
|
||||
SubmitData::Action(Action::Erase) => action::Action::Erase,
|
||||
SubmitData::Keysym(keysym) => ::action::Action::Submit {
|
||||
text: None,
|
||||
keys: vec!(::action::KeySym(
|
||||
@ -589,7 +638,27 @@ fn create_action<H: logging::Handler>(
|
||||
false => format!("U{:04X}", codepoint as u32),
|
||||
})
|
||||
}).collect(),
|
||||
},
|
||||
SubmitData::Modifier(modifier) => match modifier {
|
||||
Modifier::Control => action::Action::ApplyModifier(
|
||||
action::Modifier::Control,
|
||||
),
|
||||
Modifier::Alt => action::Action::ApplyModifier(
|
||||
action::Modifier::Alt,
|
||||
),
|
||||
unsupported_modifier => {
|
||||
warning_handler.handle(
|
||||
logging::Level::Bug,
|
||||
&format!(
|
||||
"Modifier {:?} unsupported", unsupported_modifier,
|
||||
),
|
||||
);
|
||||
action::Action::Submit {
|
||||
text: None,
|
||||
keys: Vec::new(),
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -687,6 +756,7 @@ mod tests {
|
||||
keysym: None,
|
||||
action: None,
|
||||
text: None,
|
||||
modifier: None,
|
||||
label: Some("test".into()),
|
||||
outline: None,
|
||||
}
|
||||
@ -743,7 +813,7 @@ mod tests {
|
||||
.build(ProblemPanic).0
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
out.views["base"]
|
||||
out.views["base"].1
|
||||
.get_rows()[0].1
|
||||
.buttons[0].1
|
||||
.label,
|
||||
@ -758,7 +828,7 @@ mod tests {
|
||||
.build(ProblemPanic).0
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
out.views["base"]
|
||||
out.views["base"].1
|
||||
.get_rows()[0].1
|
||||
.buttons[0].1
|
||||
.label,
|
||||
@ -774,7 +844,7 @@ mod tests {
|
||||
.build(ProblemPanic).0
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
out.views["base"]
|
||||
out.views["base"].1
|
||||
.get_rows()[0].1
|
||||
.buttons[0].1
|
||||
.state.borrow()
|
||||
@ -828,6 +898,7 @@ mod tests {
|
||||
keysym: None,
|
||||
text: None,
|
||||
action: None,
|
||||
modifier: None,
|
||||
label: Some("test".into()),
|
||||
outline: None,
|
||||
}
|
||||
|
||||
@ -3,9 +3,11 @@
|
||||
use cairo;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use ::action::Action;
|
||||
use ::keyboard;
|
||||
use ::layout::{ Button, Layout };
|
||||
use ::layout::c::{ EekGtkKeyboard, Point };
|
||||
use ::submission::Submission;
|
||||
|
||||
use glib::translate::FromGlibPtrNone;
|
||||
use gtk::WidgetExt;
|
||||
@ -37,30 +39,37 @@ mod c {
|
||||
);
|
||||
}
|
||||
|
||||
/// Draws all buttons that are not in the base state
|
||||
#[no_mangle]
|
||||
pub extern "C"
|
||||
fn squeek_layout_draw_all_changed(
|
||||
layout: *mut Layout,
|
||||
renderer: EekRenderer,
|
||||
cr: *mut cairo_sys::cairo_t,
|
||||
submission: *const Submission,
|
||||
) {
|
||||
let layout = unsafe { &mut *layout };
|
||||
let submission = unsafe { &*submission };
|
||||
let cr = unsafe { cairo::Context::from_raw_none(cr) };
|
||||
let active_modifiers = submission.get_active_modifiers();
|
||||
|
||||
let view = layout.get_current_view();
|
||||
for (row_offset, row) in &view.get_rows() {
|
||||
for (x_offset, button) in &row.buttons {
|
||||
layout.foreach_visible_button(|offset, button| {
|
||||
let state = RefCell::borrow(&button.state).clone();
|
||||
if state.pressed == keyboard::PressType::Pressed || state.locked {
|
||||
let active_mod = match &state.action {
|
||||
Action::ApplyModifier(m) => active_modifiers.contains(m),
|
||||
_ => false,
|
||||
};
|
||||
let locked = state.action.is_active(&layout.current_view)
|
||||
| active_mod;
|
||||
if state.pressed == keyboard::PressType::Pressed || locked {
|
||||
render_button_at_position(
|
||||
renderer, &cr,
|
||||
row_offset + Point { x: *x_offset, y: 0.0 },
|
||||
offset,
|
||||
button.as_ref(),
|
||||
state.pressed, state.locked,
|
||||
state.pressed, locked,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@ -72,17 +81,15 @@ mod c {
|
||||
) {
|
||||
let layout = unsafe { &mut *layout };
|
||||
let cr = unsafe { cairo::Context::from_raw_none(cr) };
|
||||
let view = layout.get_current_view();
|
||||
for (row_offset, row) in &view.get_rows() {
|
||||
for (x_offset, button) in &row.buttons {
|
||||
|
||||
layout.foreach_visible_button(|offset, button| {
|
||||
render_button_at_position(
|
||||
renderer, &cr,
|
||||
row_offset + Point { x: *x_offset, y: 0.0 },
|
||||
offset,
|
||||
button.as_ref(),
|
||||
keyboard::PressType::Released, false,
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 zwp_virtual_keyboard_manager_v1 *vkmanager,
|
||||
struct wl_seat *seat,
|
||||
EekboardContextService *state) {
|
||||
LayoutHolder *state) {
|
||||
struct zwp_input_method_v2 *im = NULL;
|
||||
if (immanager) {
|
||||
im = zwp_input_method_manager_v2_get_input_method(immanager, seat);
|
||||
@ -49,6 +49,23 @@ void imservice_connect_listeners(struct zwp_input_method_v2 *im, struct imservic
|
||||
zwp_input_method_v2_add_listener(im, &input_method_listener, imservice);
|
||||
}
|
||||
|
||||
void
|
||||
eek_input_method_commit_string(struct zwp_input_method_v2 *zwp_input_method_v2, const char *text)
|
||||
{
|
||||
zwp_input_method_v2_commit_string(zwp_input_method_v2, text);
|
||||
}
|
||||
|
||||
void
|
||||
eek_input_method_delete_surrounding_text(struct zwp_input_method_v2 *zwp_input_method_v2, uint32_t before_length, uint32_t after_length) {
|
||||
zwp_input_method_v2_delete_surrounding_text(zwp_input_method_v2, before_length, after_length);
|
||||
};
|
||||
|
||||
void
|
||||
eek_input_method_commit(struct zwp_input_method_v2 *zwp_input_method_v2, uint32_t serial)
|
||||
{
|
||||
zwp_input_method_v2_commit(zwp_input_method_v2, serial);
|
||||
}
|
||||
|
||||
/// Declared explicitly because _destroy is inline,
|
||||
/// making it unavailable in Rust
|
||||
void imservice_destroy_im(struct zwp_input_method_v2 *im) {
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
/*! Manages zwp_input_method_v2 protocol.
|
||||
*
|
||||
* Library module.
|
||||
*/
|
||||
|
||||
use std::boxed::Box;
|
||||
use std::ffi::CString;
|
||||
use std::fmt;
|
||||
@ -32,6 +37,9 @@ pub mod c {
|
||||
fn imservice_destroy_im(im: *mut c::InputMethod);
|
||||
#[allow(improper_ctypes)] // IMService will never be dereferenced in C
|
||||
pub fn imservice_connect_listeners(im: *mut InputMethod, imservice: *const IMService);
|
||||
pub fn eek_input_method_commit_string(im: *mut InputMethod, text: *const c_char);
|
||||
pub fn eek_input_method_delete_surrounding_text(im: *mut InputMethod, before: u32, after: u32);
|
||||
pub fn eek_input_method_commit(im: *mut InputMethod, serial: u32);
|
||||
fn eekboard_context_service_set_hint_purpose(state: *const StateManager, hint: u32, purpose: u32);
|
||||
fn server_context_service_show_keyboard(imservice: *const UIManager);
|
||||
fn server_context_service_hide_keyboard(imservice: *const UIManager);
|
||||
@ -328,7 +336,7 @@ impl Default for IMProtocolState {
|
||||
|
||||
pub struct IMService {
|
||||
/// Owned reference (still created and destroyed in C)
|
||||
pub im: *const c::InputMethod,
|
||||
pub im: *mut c::InputMethod,
|
||||
/// Unowned reference. Be careful, it's shared with C at large
|
||||
state_manager: *const c::StateManager,
|
||||
/// Unowned reference. Be careful, it's shared with C at large
|
||||
@ -340,6 +348,11 @@ pub struct IMService {
|
||||
serial: Wrapping<u32>,
|
||||
}
|
||||
|
||||
pub enum SubmitError {
|
||||
/// The input method had not been activated
|
||||
NotActive,
|
||||
}
|
||||
|
||||
impl IMService {
|
||||
pub fn new(
|
||||
im: *mut c::InputMethod,
|
||||
@ -364,4 +377,51 @@ impl IMService {
|
||||
}
|
||||
imservice
|
||||
}
|
||||
|
||||
pub fn commit_string(&self, text: &CString) -> Result<(), SubmitError> {
|
||||
match self.current.active {
|
||||
true => {
|
||||
unsafe {
|
||||
c::eek_input_method_commit_string(self.im, text.as_ptr())
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
false => Err(SubmitError::NotActive),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete_surrounding_text(
|
||||
&self,
|
||||
before: u32, after: u32,
|
||||
) -> Result<(), SubmitError> {
|
||||
match self.current.active {
|
||||
true => {
|
||||
unsafe {
|
||||
c::eek_input_method_delete_surrounding_text(
|
||||
self.im,
|
||||
before, after,
|
||||
)
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
false => Err(SubmitError::NotActive),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn commit(&mut self) -> Result<(), SubmitError> {
|
||||
match self.current.active {
|
||||
true => {
|
||||
unsafe {
|
||||
c::eek_input_method_commit(self.im, self.serial.0)
|
||||
}
|
||||
self.serial += Wrapping(1u32);
|
||||
Ok(())
|
||||
},
|
||||
false => Err(SubmitError::NotActive),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_active(&self) -> bool {
|
||||
self.current.active
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
/*! State of the emulated keyboard and keys.
|
||||
* Regards the keyboard as if it was composed of switches. */
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::rc::Rc;
|
||||
use std::string::FromUtf8Error;
|
||||
|
||||
use ::action::Action;
|
||||
use ::logging;
|
||||
|
||||
// Traits
|
||||
use std::io::Write;
|
||||
use std::iter::{ FromIterator, IntoIterator };
|
||||
|
||||
@ -20,28 +23,39 @@ pub enum PressType {
|
||||
|
||||
pub type KeyCode = u32;
|
||||
|
||||
bitflags!{
|
||||
/// Map to `virtual_keyboard.modifiers` modifiers values
|
||||
/// From https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Keyboard_State
|
||||
pub struct Modifiers: u8 {
|
||||
const SHIFT = 0x1;
|
||||
const LOCK = 0x2;
|
||||
const CONTROL = 0x4;
|
||||
/// Alt
|
||||
const MOD1 = 0x8;
|
||||
const MOD2 = 0x10;
|
||||
const MOD3 = 0x20;
|
||||
/// Meta
|
||||
const MOD4 = 0x40;
|
||||
/// AltGr
|
||||
const MOD5 = 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
/// When the submitted actions of keys need to be tracked,
|
||||
/// they need a stable, comparable ID
|
||||
#[derive(PartialEq)]
|
||||
pub struct KeyStateId(*const KeyState);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct KeyState {
|
||||
pub pressed: PressType,
|
||||
pub locked: bool,
|
||||
/// A cache of raw keycodes derived from Action::Sumbit given a keymap
|
||||
/// A cache of raw keycodes derived from Action::Submit given a keymap
|
||||
pub keycodes: Vec<KeyCode>,
|
||||
/// Static description of what the key does when pressed or released
|
||||
pub action: Action,
|
||||
}
|
||||
|
||||
impl KeyState {
|
||||
#[must_use]
|
||||
pub fn into_activated(self) -> KeyState {
|
||||
match self.action {
|
||||
Action::LockView { lock: _, unlock: _ } => KeyState {
|
||||
locked: self.locked ^ true,
|
||||
..self
|
||||
},
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn into_released(self) -> KeyState {
|
||||
KeyState {
|
||||
@ -49,6 +63,20 @@ impl KeyState {
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn into_pressed(self) -> KeyState {
|
||||
KeyState {
|
||||
pressed: PressType::Pressed,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
/// KeyStates instances are the unique identifiers of pressed keys,
|
||||
/// and the actions submitted with them.
|
||||
pub fn get_id(keystate: &Rc<RefCell<KeyState>>) -> KeyStateId {
|
||||
KeyStateId(keystate.as_ptr() as *const KeyState)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sorts an iterator by converting it to a Vector and back
|
||||
@ -66,9 +94,10 @@ fn sorted<'a, I: Iterator<Item=&'a str>>(
|
||||
pub fn generate_keycodes<'a, C: IntoIterator<Item=&'a str>>(
|
||||
key_names: C
|
||||
) -> HashMap<String, u32> {
|
||||
let special_keysyms = ["BackSpace", "Return"].iter().map(|&s| s);
|
||||
HashMap::from_iter(
|
||||
// sort to remove a source of indeterminism in keycode assignment
|
||||
sorted(key_names.into_iter())
|
||||
sorted(key_names.into_iter().chain(special_keysyms))
|
||||
.map(|name| String::from(name))
|
||||
.zip(9..)
|
||||
)
|
||||
@ -95,7 +124,10 @@ impl From<io::Error> for FormattingError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a de-facto single level keymap. TODO: actually drop second level
|
||||
/// Generates a de-facto single level keymap.
|
||||
// TODO: don't rely on keys and their order,
|
||||
// but rather on what keysyms and keycodes are in use.
|
||||
// Iterating actions makes it hard to deduplicate keysyms.
|
||||
pub fn generate_keymap(
|
||||
keystates: &HashMap::<String, KeyState>
|
||||
) -> Result<String, FormattingError> {
|
||||
@ -110,7 +142,8 @@ pub fn generate_keymap(
|
||||
)?;
|
||||
|
||||
for (name, state) in keystates.iter() {
|
||||
if let Action::Submit { text: _, keys } = &state.action {
|
||||
match &state.action {
|
||||
Action::Submit { text: _, keys } => {
|
||||
if let 0 = keys.len() {
|
||||
log_print!(
|
||||
logging::Level::Warning,
|
||||
@ -126,6 +159,23 @@ pub fn generate_keymap(
|
||||
keycode,
|
||||
)?;
|
||||
}
|
||||
},
|
||||
Action::Erase => {
|
||||
let mut keycodes = state.keycodes.iter();
|
||||
write!(
|
||||
buf,
|
||||
"
|
||||
<BackSpace> = {};",
|
||||
keycodes.next().expect("Erase key has no keycode"),
|
||||
)?;
|
||||
if let Some(_) = keycodes.next() {
|
||||
log_print!(
|
||||
logging::Level::Bug,
|
||||
"Erase key has multiple keycodes",
|
||||
);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +187,9 @@ pub fn generate_keymap(
|
||||
xkb_symbols \"squeekboard\" {{
|
||||
|
||||
name[Group1] = \"Letters\";
|
||||
name[Group2] = \"Numbers/Symbols\";"
|
||||
name[Group2] = \"Numbers/Symbols\";
|
||||
|
||||
key <BackSpace> {{ [ BackSpace ] }};"
|
||||
)?;
|
||||
|
||||
for (name, state) in keystates.iter() {
|
||||
@ -195,7 +247,6 @@ mod tests {
|
||||
keys: vec!(KeySym("a".into()), KeySym("c".into())),
|
||||
},
|
||||
keycodes: vec!(9, 10),
|
||||
locked: false,
|
||||
pressed: PressType::Released,
|
||||
},
|
||||
}).unwrap();
|
||||
|
||||
16
src/layout.h
16
src/layout.h
@ -7,13 +7,23 @@
|
||||
#include "eek/eek-gtk-keyboard.h"
|
||||
#include "eek/eek-renderer.h"
|
||||
#include "eek/eek-types.h"
|
||||
#include "src/submission.h"
|
||||
#include "virtual-keyboard-unstable-v1-client-protocol.h"
|
||||
#include "text-input-unstable-v3-client-protocol.h"
|
||||
|
||||
enum squeek_arrangement_kind {
|
||||
ARRANGEMENT_KIND_BASE = 0,
|
||||
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;
|
||||
|
||||
EekBounds squeek_button_get_bounds(const struct squeek_button*);
|
||||
@ -37,7 +47,7 @@ void squeek_layout_release(struct squeek_layout *layout,
|
||||
struct submission *submission,
|
||||
struct transformation widget_to_layout,
|
||||
uint32_t timestamp,
|
||||
EekboardContextService *manager,
|
||||
LayoutHolder *manager,
|
||||
EekGtkKeyboard *ui_keyboard);
|
||||
void squeek_layout_release_all_only(struct squeek_layout *layout,
|
||||
struct submission *submission,
|
||||
@ -51,8 +61,8 @@ void squeek_layout_drag(struct squeek_layout *layout,
|
||||
struct submission *submission,
|
||||
double x_widget, double y_widget,
|
||||
struct transformation widget_to_layout,
|
||||
uint32_t timestamp, EekboardContextService *manager,
|
||||
uint32_t timestamp, LayoutHolder *manager,
|
||||
EekGtkKeyboard *ui_keyboard);
|
||||
void squeek_layout_draw_all_changed(struct squeek_layout *layout, EekRenderer* renderer, cairo_t *cr);
|
||||
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);
|
||||
#endif
|
||||
|
||||
190
src/layout.rs
190
src/layout.rs
@ -26,10 +26,10 @@ use std::vec::Vec;
|
||||
|
||||
use ::action::Action;
|
||||
use ::drawing;
|
||||
use ::keyboard::{ KeyState, PressType };
|
||||
use ::keyboard::KeyState;
|
||||
use ::logging;
|
||||
use ::manager;
|
||||
use ::submission::{ Submission, Timestamp };
|
||||
use ::submission::{ Submission, SubmitData, Timestamp };
|
||||
use ::util::find_max_double;
|
||||
|
||||
// Traits
|
||||
@ -249,7 +249,7 @@ pub mod c {
|
||||
unsafe { Box::from_raw(layout) };
|
||||
}
|
||||
|
||||
/// Entry points for more complex procedures and algoithms which span multiple modules
|
||||
/// Entry points for more complex procedures and algorithms which span multiple modules
|
||||
pub mod procedures {
|
||||
use super::*;
|
||||
|
||||
@ -329,11 +329,8 @@ pub mod c {
|
||||
Point { x: x_widget, y: y_widget }
|
||||
);
|
||||
|
||||
let state = {
|
||||
let view = layout.get_current_view();
|
||||
view.find_button_by_position(point)
|
||||
.map(|place| place.button.state.clone())
|
||||
};
|
||||
let state = layout.find_button_by_position(point)
|
||||
.map(|place| place.button.state.clone());
|
||||
|
||||
if let Some(state) = state {
|
||||
seat::handle_press_key(
|
||||
@ -374,8 +371,7 @@ pub mod c {
|
||||
|
||||
let pressed = layout.pressed_keys.clone();
|
||||
let button_info = {
|
||||
let view = layout.get_current_view();
|
||||
let place = view.find_button_by_position(point);
|
||||
let place = layout.find_button_by_position(point);
|
||||
place.map(|place| {(
|
||||
place.button.state.clone(),
|
||||
place.button.clone(),
|
||||
@ -486,8 +482,6 @@ pub struct Button {
|
||||
pub struct Row {
|
||||
/// Buttons together with their offset from the left
|
||||
pub buttons: Vec<(f64, Box<Button>)>,
|
||||
/// Angle is not really used anywhere...
|
||||
pub angle: i32,
|
||||
}
|
||||
|
||||
impl Row {
|
||||
@ -554,14 +548,14 @@ impl View {
|
||||
})
|
||||
}
|
||||
|
||||
fn get_width(&self) -> f64 {
|
||||
pub fn get_width(&self) -> f64 {
|
||||
// No need to call `get_rows()`,
|
||||
// as the biggest row is the most far reaching in both directions
|
||||
// because they are all centered.
|
||||
find_max_double(self.rows.iter(), |(_offset, row)| row.get_width())
|
||||
}
|
||||
|
||||
fn get_height(&self) -> f64 {
|
||||
pub fn get_height(&self) -> f64 {
|
||||
self.rows.iter().next_back()
|
||||
.map(|(y_offset, row)| row.get_height() + y_offset)
|
||||
.unwrap_or(0.0)
|
||||
@ -578,6 +572,21 @@ impl View {
|
||||
row,
|
||||
)}).collect()
|
||||
}
|
||||
|
||||
/// Returns a size which contains all the views
|
||||
/// if they are all centered on the same point.
|
||||
pub fn calculate_super_size(views: Vec<&View>) -> Size {
|
||||
Size {
|
||||
height: find_max_double(
|
||||
views.iter(),
|
||||
|view| view.get_height(),
|
||||
),
|
||||
width: find_max_double(
|
||||
views.iter(),
|
||||
|view| view.get_width(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The physical characteristic of layout for the purpose of styling
|
||||
@ -605,7 +614,8 @@ pub struct Layout {
|
||||
// Views own the actual buttons which have state
|
||||
// Maybe they should own UI only,
|
||||
// and keys should be owned by a dedicated non-UI-State?
|
||||
pub views: HashMap<String, View>,
|
||||
/// Point is the offset within the layout
|
||||
pub views: HashMap<String, (c::Point, View)>,
|
||||
|
||||
// Non-UI stuff
|
||||
/// xkb keymap applicable to the contained keys. Unchangeable
|
||||
@ -619,12 +629,12 @@ pub struct Layout {
|
||||
// When the list tracks actual location,
|
||||
// it becomes possible to place popovers and other UI accurately.
|
||||
pub pressed_keys: HashSet<::util::Pointer<RefCell<KeyState>>>,
|
||||
pub locked_keys: HashSet<::util::Pointer<RefCell<KeyState>>>,
|
||||
}
|
||||
|
||||
/// A builder structure for picking up layout data from storage
|
||||
pub struct LayoutData {
|
||||
pub views: HashMap<String, View>,
|
||||
/// Point is the offset within layout
|
||||
pub views: HashMap<String, (c::Point, View)>,
|
||||
pub keymap_str: CString,
|
||||
pub margins: Margins,
|
||||
}
|
||||
@ -650,13 +660,17 @@ impl Layout {
|
||||
views: data.views,
|
||||
keymap_str: data.keymap_str,
|
||||
pressed_keys: HashSet::new(),
|
||||
locked_keys: HashSet::new(),
|
||||
margins: data.margins,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_current_view_position(&self) -> &(c::Point, View) {
|
||||
&self.views
|
||||
.get(&self.current_view).expect("Selected nonexistent view")
|
||||
}
|
||||
|
||||
pub fn get_current_view(&self) -> &View {
|
||||
self.views.get(&self.current_view).expect("Selected nonexistent view")
|
||||
&self.views.get(&self.current_view).expect("Selected nonexistent view").1
|
||||
}
|
||||
|
||||
fn set_view(&mut self, view: String) -> Result<(), NoSuchView> {
|
||||
@ -670,16 +684,9 @@ impl Layout {
|
||||
|
||||
/// Calculates size without margins
|
||||
fn calculate_inner_size(&self) -> Size {
|
||||
Size {
|
||||
height: find_max_double(
|
||||
self.views.iter(),
|
||||
|(_name, view)| view.get_height(),
|
||||
),
|
||||
width: find_max_double(
|
||||
self.views.iter(),
|
||||
|(_name, view)| view.get_width(),
|
||||
),
|
||||
}
|
||||
View::calculate_super_size(
|
||||
self.views.iter().map(|(_, (_offset, v))| v).collect()
|
||||
)
|
||||
}
|
||||
|
||||
/// Size including margins
|
||||
@ -714,6 +721,42 @@ impl Layout {
|
||||
scale: 1.0,
|
||||
})
|
||||
}
|
||||
|
||||
fn find_button_by_position(&self, point: c::Point) -> Option<ButtonPlace> {
|
||||
let (offset, layout) = self.get_current_view_position();
|
||||
layout.find_button_by_position(point - offset)
|
||||
}
|
||||
|
||||
pub fn foreach_visible_button<F>(&self, mut f: F)
|
||||
where F: FnMut(c::Point, &Box<Button>)
|
||||
{
|
||||
let (view_offset, view) = self.get_current_view_position();
|
||||
for (row_offset, row) in &view.get_rows() {
|
||||
for (x_offset, button) in &row.buttons {
|
||||
let offset = view_offset
|
||||
+ row_offset.clone()
|
||||
+ c::Point { x: *x_offset, y: 0.0 };
|
||||
f(offset, button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_locked_keys(&self) -> Vec<Rc<RefCell<KeyState>>> {
|
||||
let mut out = Vec::new();
|
||||
let view = self.get_current_view();
|
||||
for (_, row) in &view.get_rows() {
|
||||
for (_, button) in &row.buttons {
|
||||
let locked = {
|
||||
let state = RefCell::borrow(&button.state).clone();
|
||||
state.action.is_locked(&self.current_view)
|
||||
};
|
||||
if locked {
|
||||
out.push(button.state.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
mod procedures {
|
||||
@ -765,7 +808,6 @@ mod procedures {
|
||||
|
||||
let row = Row {
|
||||
buttons: vec!((0.1, button)),
|
||||
angle: 0,
|
||||
};
|
||||
|
||||
let view = View {
|
||||
@ -841,9 +883,9 @@ mod seat {
|
||||
#[must_use]
|
||||
fn unstick_locks(layout: &mut Layout) -> ViewChange {
|
||||
let mut new_view = None;
|
||||
for key in layout.locked_keys.clone() {
|
||||
for key in layout.get_locked_keys().clone() {
|
||||
let key: &Rc<RefCell<KeyState>> = key.borrow();
|
||||
let mut key = RefCell::borrow_mut(key);
|
||||
let key = RefCell::borrow(key);
|
||||
match &key.action {
|
||||
Action::LockView { lock: _, unlock: view } => {
|
||||
new_view = Some(view.clone());
|
||||
@ -854,7 +896,6 @@ mod seat {
|
||||
a,
|
||||
),
|
||||
};
|
||||
key.locked = false;
|
||||
}
|
||||
|
||||
ViewChange {
|
||||
@ -875,13 +916,38 @@ mod seat {
|
||||
"Key {:?} was already pressed", rckey,
|
||||
);
|
||||
}
|
||||
let mut key = rckey.borrow_mut();
|
||||
submission.virtual_keyboard.switch(
|
||||
let key: KeyState = {
|
||||
RefCell::borrow(rckey).clone()
|
||||
};
|
||||
let action = key.action.clone();
|
||||
match action {
|
||||
Action::Submit {
|
||||
text: Some(text),
|
||||
keys: _,
|
||||
} => submission.handle_press(
|
||||
KeyState::get_id(rckey),
|
||||
SubmitData::Text(&text),
|
||||
&key.keycodes,
|
||||
PressType::Pressed,
|
||||
time,
|
||||
);
|
||||
key.pressed = PressType::Pressed;
|
||||
),
|
||||
Action::Submit {
|
||||
text: None,
|
||||
keys: _,
|
||||
} => submission.handle_press(
|
||||
KeyState::get_id(rckey),
|
||||
SubmitData::Keycodes,
|
||||
&key.keycodes,
|
||||
time,
|
||||
),
|
||||
Action::Erase => submission.handle_press(
|
||||
KeyState::get_id(rckey),
|
||||
SubmitData::Erase,
|
||||
&key.keycodes,
|
||||
time,
|
||||
),
|
||||
_ => {},
|
||||
};
|
||||
RefCell::replace(rckey, key.into_pressed());
|
||||
}
|
||||
|
||||
pub fn handle_release_key(
|
||||
@ -899,38 +965,43 @@ mod seat {
|
||||
|
||||
// update
|
||||
let key = key.into_released();
|
||||
let key = match action {
|
||||
Action::LockView { lock: _, unlock: _ } => key.into_activated(),
|
||||
_ => key,
|
||||
};
|
||||
|
||||
// process changes
|
||||
match action {
|
||||
Action::Submit { text: _, keys: _ } => {
|
||||
Action::Submit { text: _, keys: _ }
|
||||
| Action::Erase
|
||||
=> {
|
||||
unstick_locks(layout).apply();
|
||||
submission.virtual_keyboard.switch(
|
||||
&key.keycodes,
|
||||
PressType::Released,
|
||||
time,
|
||||
);
|
||||
submission.handle_release(KeyState::get_id(rckey), time);
|
||||
},
|
||||
Action::SetView(view) => {
|
||||
try_set_view(layout, view)
|
||||
},
|
||||
Action::LockView { lock, unlock } => {
|
||||
// The button that triggered this will be in the right state
|
||||
// due to commit at the end.
|
||||
let gets_locked = !key.action.is_locked(&layout.current_view);
|
||||
unstick_locks(layout)
|
||||
// It doesn't matter what the resulting view should be,
|
||||
// it's getting changed anyway.
|
||||
.choose_view(
|
||||
match key.locked {
|
||||
match gets_locked {
|
||||
true => lock.clone(),
|
||||
false => unlock.clone(),
|
||||
}
|
||||
)
|
||||
.apply()
|
||||
},
|
||||
Action::ApplyModifier(modifier) => {
|
||||
// FIXME: key id is unneeded with stateless locks
|
||||
let key_id = KeyState::get_id(rckey);
|
||||
let gets_locked = !submission.is_modifier_active(modifier.clone());
|
||||
match gets_locked {
|
||||
true => submission.handle_add_modifier(
|
||||
key_id,
|
||||
modifier, time,
|
||||
),
|
||||
false => submission.handle_drop_modifier(key_id, time),
|
||||
}
|
||||
}
|
||||
// only show when UI is present
|
||||
Action::ShowPreferences => if let Some(ui) = &ui {
|
||||
// only show when layout manager is available
|
||||
@ -957,20 +1028,11 @@ mod seat {
|
||||
}
|
||||
}
|
||||
},
|
||||
Action::SetModifier(_) => log_print!(
|
||||
logging::Level::Bug,
|
||||
"Modifiers unsupported",
|
||||
),
|
||||
};
|
||||
|
||||
let pointer = ::util::Pointer(rckey.clone());
|
||||
// Apply state changes
|
||||
layout.pressed_keys.remove(&pointer);
|
||||
if key.locked {
|
||||
layout.locked_keys.insert(pointer);
|
||||
} else {
|
||||
layout.locked_keys.remove(&pointer);
|
||||
}
|
||||
// Commit activated button state changes
|
||||
RefCell::replace(rckey, key);
|
||||
}
|
||||
@ -981,11 +1043,11 @@ mod test {
|
||||
use super::*;
|
||||
|
||||
use std::ffi::CString;
|
||||
use ::keyboard::PressType;
|
||||
|
||||
pub fn make_state() -> Rc<RefCell<::keyboard::KeyState>> {
|
||||
Rc::new(RefCell::new(::keyboard::KeyState {
|
||||
pressed: PressType::Released,
|
||||
locked: false,
|
||||
keycodes: Vec::new(),
|
||||
action: Action::SetView("default".into()),
|
||||
}))
|
||||
@ -1012,7 +1074,6 @@ mod test {
|
||||
(
|
||||
0.0,
|
||||
Row {
|
||||
angle: 0,
|
||||
buttons: vec![(
|
||||
0.0,
|
||||
Box::new(Button {
|
||||
@ -1025,7 +1086,6 @@ mod test {
|
||||
(
|
||||
10.0,
|
||||
Row {
|
||||
angle: 0,
|
||||
buttons: vec![(
|
||||
0.0,
|
||||
Box::new(Button {
|
||||
@ -1049,7 +1109,6 @@ mod test {
|
||||
(
|
||||
0.0,
|
||||
Row {
|
||||
angle: 0,
|
||||
buttons: vec![(
|
||||
0.0,
|
||||
Box::new(Button {
|
||||
@ -1064,7 +1123,6 @@ mod test {
|
||||
current_view: String::new(),
|
||||
keymap_str: CString::new("").unwrap(),
|
||||
kind: ArrangementKind::Base,
|
||||
locked_keys: HashSet::new(),
|
||||
pressed_keys: HashSet::new(),
|
||||
// Lots of bottom margin
|
||||
margins: Margins {
|
||||
@ -1074,7 +1132,7 @@ mod test {
|
||||
bottom: 1.0,
|
||||
},
|
||||
views: hashmap! {
|
||||
String::new() => view,
|
||||
String::new() => (c::Point { x: 0.0, y: 0.0 }, view),
|
||||
},
|
||||
};
|
||||
assert_eq!(
|
||||
|
||||
@ -35,5 +35,6 @@ mod style;
|
||||
mod submission;
|
||||
pub mod tests;
|
||||
pub mod util;
|
||||
mod ui_manager;
|
||||
mod vkeyboard;
|
||||
mod xdg;
|
||||
|
||||
@ -15,6 +15,7 @@ sources = [
|
||||
'dbus.c',
|
||||
'imservice.c',
|
||||
'server-context-service.c',
|
||||
'ui_manager.c',
|
||||
'wayland.c',
|
||||
'../eek/eek.c',
|
||||
'../eek/eek-element.c',
|
||||
|
||||
@ -4,10 +4,14 @@
|
||||
#include "wayland-client-protocol.h"
|
||||
|
||||
struct squeek_outputs;
|
||||
struct squeek_output_handle {
|
||||
struct wl_output *output;
|
||||
struct squeek_outputs *outputs;
|
||||
};
|
||||
|
||||
struct squeek_outputs *squeek_outputs_new();
|
||||
void squeek_outputs_free(struct squeek_outputs*);
|
||||
void squeek_outputs_register(struct squeek_outputs*, struct wl_output *output);
|
||||
struct wl_output *squeek_outputs_get_current(struct squeek_outputs*);
|
||||
struct squeek_output_handle squeek_outputs_get_current(struct squeek_outputs*);
|
||||
int32_t squeek_outputs_get_perceptual_width(struct squeek_outputs*, struct wl_output *output);
|
||||
#endif
|
||||
|
||||
235
src/outputs.rs
235
src/outputs.rs
@ -1,5 +1,10 @@
|
||||
/* Copyright (C) 2019-2020 Purism SPC
|
||||
* SPDX-License-Identifier: GPL-3.0+
|
||||
*/
|
||||
|
||||
/*! Managing Wayland outputs */
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::vec::Vec;
|
||||
use ::logging;
|
||||
|
||||
@ -17,7 +22,7 @@ pub mod c {
|
||||
// Defined in C
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Copy, Hash)]
|
||||
pub struct WlOutput(*const c_void);
|
||||
|
||||
#[repr(C)]
|
||||
@ -63,7 +68,7 @@ pub mod c {
|
||||
}
|
||||
|
||||
/// Map to `wl_output.transform` values
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum Transform {
|
||||
Normal = 0,
|
||||
Rotated90 = 1,
|
||||
@ -103,7 +108,29 @@ pub mod c {
|
||||
) -> i32;
|
||||
}
|
||||
|
||||
type COutputs = ::util::c::Wrapped<Outputs>;
|
||||
pub 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
|
||||
|
||||
@ -111,7 +138,7 @@ pub mod c {
|
||||
outputs: COutputs,
|
||||
wl_output: WlOutput,
|
||||
_x: i32, _y: i32,
|
||||
_phys_width: i32, _phys_height: i32,
|
||||
phys_width: i32, phys_height: i32,
|
||||
_subpixel: i32,
|
||||
_make: *const c_char, _model: *const c_char,
|
||||
transform: i32,
|
||||
@ -127,8 +154,23 @@ pub mod c {
|
||||
let output_state: Option<&mut OutputState>
|
||||
= find_output_mut(&mut collection, wl_output)
|
||||
.map(|o| &mut o.pending);
|
||||
|
||||
match output_state {
|
||||
Some(state) => { state.transform = Some(transform) },
|
||||
Some(state) => {
|
||||
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!(
|
||||
logging::Level::Warning,
|
||||
"Got geometry on unknown output",
|
||||
@ -169,11 +211,12 @@ pub mod c {
|
||||
}
|
||||
|
||||
extern fn outputs_handle_done(
|
||||
outputs: COutputs,
|
||||
outputs_raw: COutputs,
|
||||
wl_output: WlOutput,
|
||||
) {
|
||||
let outputs = outputs.clone_ref();
|
||||
let mut collection = outputs.borrow_mut();
|
||||
let outputs = outputs_raw.clone_ref();
|
||||
{
|
||||
let mut collection = RefCell::borrow_mut(&outputs);
|
||||
let output = find_output_mut(&mut collection, wl_output);
|
||||
match output {
|
||||
Some(output) => { output.current = output.pending.clone(); }
|
||||
@ -183,6 +226,13 @@ pub mod c {
|
||||
),
|
||||
};
|
||||
}
|
||||
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(
|
||||
outputs: COutputs,
|
||||
@ -206,7 +256,10 @@ pub mod c {
|
||||
#[no_mangle]
|
||||
pub extern "C"
|
||||
fn squeek_outputs_new() -> COutputs {
|
||||
COutputs::new(Outputs { outputs: Vec::new() })
|
||||
COutputs::new(Outputs {
|
||||
outputs: Vec::new(),
|
||||
update_cb: None,
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@ -240,46 +293,15 @@ pub mod c {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C"
|
||||
fn squeek_outputs_get_current(raw_collection: COutputs) -> WlOutput {
|
||||
fn squeek_outputs_get_current(raw_collection: COutputs) -> OutputHandle {
|
||||
let collection = raw_collection.clone_ref();
|
||||
let collection = collection.borrow();
|
||||
collection.outputs[0].output.clone()
|
||||
OutputHandle {
|
||||
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
|
||||
|
||||
fn find_output(
|
||||
@ -305,27 +327,112 @@ pub mod c {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
/// Generic size
|
||||
#[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 {
|
||||
width: i32,
|
||||
height: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct OutputState {
|
||||
current_mode: Option<Mode>,
|
||||
phys_size: Option<SizeMM>,
|
||||
transform: Option<c::Transform>,
|
||||
scale: i32,
|
||||
pub scale: i32,
|
||||
}
|
||||
|
||||
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 {
|
||||
OutputState {
|
||||
current_mode: None,
|
||||
phys_size: None,
|
||||
transform: None,
|
||||
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 {
|
||||
@ -334,6 +441,38 @@ pub struct Output {
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ mod variants {
|
||||
|
||||
use glib::ToVariant;
|
||||
use glib::translate::FromGlibPtrFull;
|
||||
use glib::translate::FromGlibPtrNone;
|
||||
use glib::translate::ToGlibPtr;
|
||||
|
||||
/// Unpacks tuple & array variants
|
||||
@ -91,7 +92,7 @@ mod variants {
|
||||
unsafe {
|
||||
let ret = glib_sys::g_variant_builder_end(builder);
|
||||
glib_sys::g_variant_builder_unref(builder);
|
||||
glib::Variant::from_glib_full(ret)
|
||||
glib::Variant::from_glib_none(ret)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,8 +132,28 @@ 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) {
|
||||
let settings = gio::Settings::new("org.gnome.desktop.input-sources");
|
||||
let settings = get_settings("org.gnome.desktop.input-sources");
|
||||
if let Some(settings) = settings {
|
||||
let inputs = settings.get_value("sources").unwrap();
|
||||
let current = (kind.clone(), name.clone());
|
||||
let inputs = variants::get_tuples(inputs).into_iter()
|
||||
@ -141,9 +162,10 @@ fn set_layout(kind: String, name: String) {
|
||||
.chain(inputs).collect();
|
||||
settings.set_value(
|
||||
"sources",
|
||||
&variants::ArrayPairString(inputs).to_variant()
|
||||
&variants::ArrayPairString(inputs).to_variant(),
|
||||
);
|
||||
settings.apply();
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to what the user wants to see
|
||||
@ -283,9 +305,13 @@ pub fn show(
|
||||
let overlay_layouts = resources::get_overlays().into_iter()
|
||||
.map(|name| LayoutId::Local(name.to_string()));
|
||||
|
||||
let settings = gio::Settings::new("org.gnome.desktop.input-sources");
|
||||
let settings = get_settings("org.gnome.desktop.input-sources");
|
||||
let inputs = settings
|
||||
.map(|settings| {
|
||||
let inputs = settings.get_value("sources").unwrap();
|
||||
let inputs = variants::get_tuples(inputs);
|
||||
variants::get_tuples(inputs)
|
||||
})
|
||||
.unwrap_or_else(|| Vec::new());
|
||||
|
||||
let system_layouts: Vec<LayoutId> = inputs.into_iter()
|
||||
.map(|(kind, name)| LayoutId::System { kind, name })
|
||||
|
||||
@ -16,14 +16,16 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
|
||||
("us_wide", include_str!("../data/keyboards/us_wide.yaml")),
|
||||
("de", include_str!("../data/keyboards/de.yaml")),
|
||||
("de_wide", include_str!("../data/keyboards/de_wide.yaml")),
|
||||
("el", include_str!("../data/keyboards/el.yaml")),
|
||||
("es", include_str!("../data/keyboards/es.yaml")),
|
||||
("fi", include_str!("../data/keyboards/fi.yaml")),
|
||||
("gr", include_str!("../data/keyboards/gr.yaml")),
|
||||
("it", include_str!("../data/keyboards/it.yaml")),
|
||||
("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")),
|
||||
("jp+kana_wide", include_str!("../data/keyboards/jp+kana_wide.yaml")),
|
||||
("no", include_str!("../data/keyboards/no.yaml")),
|
||||
("number", include_str!("../data/keyboards/number.yaml")),
|
||||
("pl", include_str!("../data/keyboards/pl.yaml")),
|
||||
("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")),
|
||||
("se", include_str!("../data/keyboards/se.yaml")),
|
||||
// layout+overlay
|
||||
("terminal", include_str!("../data/keyboards/terminal.yaml")),
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SIZE_CONSTRAINT_LANDSCAPE,
|
||||
PROP_SIZE_CONSTRAINT_PORTRAIT,
|
||||
PROP_VISIBLE,
|
||||
PROP_LAST
|
||||
};
|
||||
@ -41,19 +39,17 @@ typedef struct _ServerContextServiceClass ServerContextServiceClass;
|
||||
struct _ServerContextService {
|
||||
GObject parent;
|
||||
|
||||
EekboardContextService *state; // unowned
|
||||
LayoutHolder *state; // unowned
|
||||
/// Needed for instantiating the widget
|
||||
struct submission *submission; // unowned
|
||||
struct squeek_layout_state *layout;
|
||||
struct ui_manager *manager; // unowned
|
||||
|
||||
gboolean visible;
|
||||
PhoshLayerSurface *window;
|
||||
GtkWidget *widget; // nullable
|
||||
guint hiding;
|
||||
guint last_requested_height;
|
||||
enum squeek_arrangement_kind last_type;
|
||||
|
||||
gdouble size_constraint_landscape[2];
|
||||
gdouble size_constraint_portrait[2];
|
||||
};
|
||||
|
||||
struct _ServerContextServiceClass {
|
||||
@ -75,27 +71,6 @@ on_destroy (GtkWidget *widget, gpointer user_data)
|
||||
//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
|
||||
on_notify_map (GObject *object,
|
||||
ServerContextService *context)
|
||||
@ -112,26 +87,6 @@ on_notify_unmap (GObject *object,
|
||||
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
|
||||
on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
|
||||
{
|
||||
@ -141,14 +96,8 @@ on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
|
||||
"configured-width", &width,
|
||||
"configured-height", &height,
|
||||
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 = calculate_height(width);
|
||||
guint desired_height = squeek_uiman_get_perceptual_height(context->manager);
|
||||
guint configured_height = (guint)height;
|
||||
// if height was already requested once but a different one was given
|
||||
// (for the same set of surrounding properties),
|
||||
@ -171,14 +120,14 @@ make_window (ServerContextService *context)
|
||||
if (context->window)
|
||||
g_error("Window already present");
|
||||
|
||||
struct wl_output *output = squeek_outputs_get_current(squeek_wayland->outputs);
|
||||
int32_t width = squeek_outputs_get_perceptual_width(squeek_wayland->outputs, output);
|
||||
uint32_t height = calculate_height(width);
|
||||
struct squeek_output_handle output = squeek_outputs_get_current(squeek_wayland->outputs);
|
||||
squeek_uiman_set_output(context->manager, output);
|
||||
uint32_t height = squeek_uiman_get_perceptual_height(context->manager);
|
||||
|
||||
context->window = g_object_new (
|
||||
PHOSH_TYPE_LAYER_SURFACE,
|
||||
"layer-shell", squeek_wayland->layer_shell,
|
||||
"wl-output", output,
|
||||
"wl-output", output.output,
|
||||
"height", height,
|
||||
"anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM
|
||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
||||
@ -190,6 +139,7 @@ make_window (ServerContextService *context)
|
||||
NULL
|
||||
);
|
||||
|
||||
squeek_uiman_set_surface(context->manager, context->window);
|
||||
g_object_connect (context->window,
|
||||
"signal::destroy", G_CALLBACK(on_destroy), context,
|
||||
"signal::map", G_CALLBACK(on_notify_map), context,
|
||||
@ -224,14 +174,11 @@ make_widget (ServerContextService *context)
|
||||
gtk_widget_destroy(context->widget);
|
||||
context->widget = NULL;
|
||||
}
|
||||
|
||||
LevelKeyboard *keyboard = eekboard_context_service_get_keyboard (context->state);
|
||||
|
||||
context->widget = eek_gtk_keyboard_new (keyboard, context->state, context->submission);
|
||||
context->widget = eek_gtk_keyboard_new (context->state, context->submission, context->layout);
|
||||
|
||||
gtk_widget_set_has_tooltip (context->widget, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER(context->window), context->widget);
|
||||
gtk_widget_show (context->widget);
|
||||
gtk_widget_show_all(context->widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -296,21 +243,8 @@ server_context_service_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
|
||||
GVariant *variant;
|
||||
|
||||
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:
|
||||
context->visible = g_value_get_boolean (value);
|
||||
break;
|
||||
@ -359,26 +293,6 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
||||
gobject_class->get_property = server_context_service_get_property;
|
||||
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.
|
||||
*/
|
||||
@ -398,19 +312,12 @@ server_context_service_init (ServerContextService *state) {
|
||||
}
|
||||
|
||||
ServerContextService *
|
||||
server_context_service_new (EekboardContextService *state, struct submission *submission)
|
||||
server_context_service_new (LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman)
|
||||
{
|
||||
ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL);
|
||||
ui->submission = submission;
|
||||
ui->state = state;
|
||||
g_signal_connect (state,
|
||||
"notify::keyboard",
|
||||
G_CALLBACK(on_notify_keyboard),
|
||||
ui);
|
||||
ui->layout = layout;
|
||||
ui->manager = uiman;
|
||||
return ui;
|
||||
}
|
||||
|
||||
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *service)
|
||||
{
|
||||
return service->last_type;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include "src/layout.h"
|
||||
#include "src/submission.h"
|
||||
#include "ui_manager.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -36,7 +37,7 @@ typedef struct _ServerContextService ServerContextService;
|
||||
GType server_context_service_get_type
|
||||
(void) G_GNUC_CONST;
|
||||
|
||||
ServerContextService *server_context_service_new(EekboardContextService *state, struct submission *submission);
|
||||
ServerContextService *server_context_service_new(LayoutHolder *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman);
|
||||
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
|
||||
void server_context_service_show_keyboard (ServerContextService *context);
|
||||
void server_context_service_hide_keyboard (ServerContextService *context);
|
||||
|
||||
@ -28,9 +28,11 @@
|
||||
#include "eek/eek.h"
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
#include "dbus.h"
|
||||
#include "layout.h"
|
||||
#include "outputs.h"
|
||||
#include "submission.h"
|
||||
#include "server-context-service.h"
|
||||
#include "ui_manager.h"
|
||||
#include "wayland.h"
|
||||
|
||||
#include <gdk/gdkwayland.h>
|
||||
@ -38,11 +40,14 @@
|
||||
|
||||
/// Global application state
|
||||
struct squeekboard {
|
||||
struct squeek_wayland wayland;
|
||||
DBusHandler *dbus_handler;
|
||||
EekboardContextService *settings_context;
|
||||
ServerContextService *ui_context;
|
||||
struct submission *submission;
|
||||
struct squeek_wayland wayland; // Just hooks.
|
||||
DBusHandler *dbus_handler; // Controls visibility of the OSK.
|
||||
LayoutHolder *layout_holder; // Currently used layout & keyboard.
|
||||
ServerContextService *ui_context; // mess, includes the entire UI
|
||||
struct submission *submission; // Wayland text input handling.
|
||||
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.
|
||||
};
|
||||
|
||||
|
||||
@ -199,8 +204,10 @@ main (int argc, char **argv)
|
||||
g_warning("Wayland input method interface not available");
|
||||
}
|
||||
|
||||
instance.settings_context = eekboard_context_service_new();
|
||||
instance.ui_manager = squeek_uiman_new(instance.wayland.outputs);
|
||||
|
||||
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
|
||||
|
||||
// TODO: make dbus errors non-always-fatal
|
||||
@ -222,9 +229,9 @@ main (int argc, char **argv)
|
||||
error = NULL;
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||
if (connection == NULL) {
|
||||
g_printerr ("Can't connect to the bus: %s\n", error->message);
|
||||
g_printerr ("Can't connect to the bus: %s. "
|
||||
"Visibility switching unavailable.", error->message);
|
||||
g_error_free (error);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case G_BUS_TYPE_NONE:
|
||||
@ -246,8 +253,10 @@ main (int argc, char **argv)
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
DBusHandler *service = dbus_handler_new(connection, DBUS_SERVICE_PATH);
|
||||
guint owner_id = 0;
|
||||
DBusHandler *service = NULL;
|
||||
if (connection) {
|
||||
service = dbus_handler_new(connection, DBUS_SERVICE_PATH);
|
||||
|
||||
if (service == NULL) {
|
||||
g_printerr ("Can't create dbus server\n");
|
||||
@ -255,7 +264,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
instance.dbus_handler = service;
|
||||
|
||||
guint owner_id = g_bus_own_name_on_connection (connection,
|
||||
owner_id = g_bus_own_name_on_connection (connection,
|
||||
DBUS_SERVICE_INTERFACE,
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_name_acquired,
|
||||
@ -266,17 +275,20 @@ main (int argc, char **argv)
|
||||
g_printerr ("Can't own the name\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
instance.submission = get_submission(instance.wayland.input_method_manager,
|
||||
instance.wayland.virtual_keyboard_manager,
|
||||
instance.wayland.seat,
|
||||
instance.settings_context);
|
||||
instance.layout_holder);
|
||||
|
||||
eekboard_context_service_set_submission(instance.settings_context, instance.submission);
|
||||
eek_layout_holder_set_submission(instance.layout_holder, instance.submission);
|
||||
|
||||
ServerContextService *ui_context = server_context_service_new(
|
||||
instance.settings_context,
|
||||
instance.submission);
|
||||
instance.layout_holder,
|
||||
instance.submission,
|
||||
&instance.layout_choice,
|
||||
instance.ui_manager);
|
||||
if (!ui_context) {
|
||||
g_error("Could not initialize GUI");
|
||||
exit(1);
|
||||
@ -288,7 +300,6 @@ main (int argc, char **argv)
|
||||
if (instance.dbus_handler) {
|
||||
dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context);
|
||||
}
|
||||
eekboard_context_service_set_ui(instance.settings_context, instance.ui_context);
|
||||
|
||||
session_register();
|
||||
|
||||
@ -296,9 +307,15 @@ main (int argc, char **argv)
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
if (connection) {
|
||||
if (service) {
|
||||
if (owner_id != 0) {
|
||||
g_bus_unown_name (owner_id);
|
||||
}
|
||||
g_object_unref (service);
|
||||
}
|
||||
g_object_unref (connection);
|
||||
}
|
||||
g_main_loop_unref (loop);
|
||||
|
||||
squeek_wayland_deinit (&instance.wayland);
|
||||
|
||||
@ -10,10 +10,10 @@ struct submission;
|
||||
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
|
||||
struct zwp_virtual_keyboard_manager_v1 *vkmanager,
|
||||
struct wl_seat *seat,
|
||||
EekboardContextService *state);
|
||||
LayoutHolder *state);
|
||||
|
||||
// Defined in Rust
|
||||
struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state);
|
||||
struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, LayoutHolder *state);
|
||||
void submission_set_ui(struct submission *self, ServerContextService *ui_context);
|
||||
void submission_set_keyboard(struct submission *self, LevelKeyboard *keyboard);
|
||||
#endif
|
||||
|
||||
@ -17,9 +17,18 @@
|
||||
* and those events SHOULD NOT cause any lost events.
|
||||
* */
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::ffi::CString;
|
||||
use ::action::Modifier;
|
||||
use ::imservice;
|
||||
use ::imservice::IMService;
|
||||
use ::keyboard::{ KeyCode, KeyStateId, Modifiers, PressType };
|
||||
use ::util::vec_remove;
|
||||
use ::vkeyboard::VirtualKeyboard;
|
||||
|
||||
// traits
|
||||
use std::iter::FromIterator;
|
||||
|
||||
/// Gathers stuff defined in C or called by C
|
||||
pub mod c {
|
||||
use super::*;
|
||||
@ -56,7 +65,9 @@ pub mod c {
|
||||
Box::<Submission>::into_raw(Box::new(
|
||||
Submission {
|
||||
imservice,
|
||||
modifiers_active: Vec::new(),
|
||||
virtual_keyboard: VirtualKeyboard(vk),
|
||||
pressed: Vec::new(),
|
||||
}
|
||||
))
|
||||
}
|
||||
@ -92,9 +103,144 @@ pub mod c {
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Timestamp(pub u32);
|
||||
|
||||
pub struct Submission {
|
||||
// used by C callbacks internally, TODO: make use with virtual keyboard
|
||||
#[allow(dead_code)]
|
||||
imservice: Option<Box<IMService>>,
|
||||
pub virtual_keyboard: VirtualKeyboard,
|
||||
enum SubmittedAction {
|
||||
/// A collection of keycodes that were pressed
|
||||
VirtualKeyboard(Vec<KeyCode>),
|
||||
IMService,
|
||||
}
|
||||
|
||||
pub struct Submission {
|
||||
imservice: Option<Box<IMService>>,
|
||||
virtual_keyboard: VirtualKeyboard,
|
||||
modifiers_active: Vec<(KeyStateId, Modifier)>,
|
||||
pressed: Vec<(KeyStateId, SubmittedAction)>,
|
||||
}
|
||||
|
||||
pub enum SubmitData<'a> {
|
||||
Text(&'a CString),
|
||||
Erase,
|
||||
Keycodes,
|
||||
}
|
||||
|
||||
impl Submission {
|
||||
/// Sends a submit text event if possible;
|
||||
/// otherwise sends key press and makes a note of it
|
||||
pub fn handle_press(
|
||||
&mut self,
|
||||
key_id: KeyStateId,
|
||||
data: SubmitData,
|
||||
keycodes: &Vec<KeyCode>,
|
||||
time: Timestamp,
|
||||
) {
|
||||
let mods_are_on = !self.modifiers_active.is_empty();
|
||||
|
||||
let was_committed_as_text = match (&mut self.imservice, mods_are_on) {
|
||||
(Some(imservice), false) => {
|
||||
enum Outcome {
|
||||
Submitted(Result<(), imservice::SubmitError>),
|
||||
NotSubmitted,
|
||||
};
|
||||
|
||||
let submit_outcome = match data {
|
||||
SubmitData::Text(text) => {
|
||||
Outcome::Submitted(imservice.commit_string(text))
|
||||
},
|
||||
SubmitData::Erase => {
|
||||
/* Delete_surrounding_text takes byte offsets,
|
||||
* so cannot work without get_surrounding_text.
|
||||
* This is a bug in the protocol.
|
||||
*/
|
||||
// imservice.delete_surrounding_text(1, 0),
|
||||
Outcome::NotSubmitted
|
||||
},
|
||||
SubmitData::Keycodes => Outcome::NotSubmitted,
|
||||
};
|
||||
|
||||
match submit_outcome {
|
||||
Outcome::Submitted(result) => {
|
||||
match result.and_then(|()| imservice.commit()) {
|
||||
Ok(()) => true,
|
||||
Err(imservice::SubmitError::NotActive) => false,
|
||||
}
|
||||
},
|
||||
Outcome::NotSubmitted => false,
|
||||
}
|
||||
},
|
||||
(_, _) => false,
|
||||
};
|
||||
|
||||
let submit_action = match was_committed_as_text {
|
||||
true => SubmittedAction::IMService,
|
||||
false => {
|
||||
self.virtual_keyboard.switch(
|
||||
keycodes,
|
||||
PressType::Pressed,
|
||||
time,
|
||||
);
|
||||
SubmittedAction::VirtualKeyboard(keycodes.clone())
|
||||
},
|
||||
};
|
||||
|
||||
self.pressed.push((key_id, submit_action));
|
||||
}
|
||||
|
||||
pub fn handle_release(&mut self, key_id: KeyStateId, time: Timestamp) {
|
||||
let index = self.pressed.iter().position(|(id, _)| *id == key_id);
|
||||
if let Some(index) = index {
|
||||
let (_id, action) = self.pressed.remove(index);
|
||||
match action {
|
||||
// string already sent, nothing to do
|
||||
SubmittedAction::IMService => {},
|
||||
// no matter if the imservice got activated,
|
||||
// keys must be released
|
||||
SubmittedAction::VirtualKeyboard(keycodes) => {
|
||||
self.virtual_keyboard.switch(
|
||||
&keycodes,
|
||||
PressType::Released,
|
||||
time,
|
||||
)
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn handle_add_modifier(
|
||||
&mut self,
|
||||
key_id: KeyStateId,
|
||||
modifier: Modifier, _time: Timestamp,
|
||||
) {
|
||||
self.modifiers_active.push((key_id, modifier));
|
||||
self.update_modifiers();
|
||||
}
|
||||
|
||||
pub fn handle_drop_modifier(
|
||||
&mut self,
|
||||
key_id: KeyStateId,
|
||||
_time: Timestamp,
|
||||
) {
|
||||
vec_remove(&mut self.modifiers_active, |(id, _)| *id == key_id);
|
||||
self.update_modifiers();
|
||||
}
|
||||
|
||||
fn update_modifiers(&mut self) {
|
||||
let raw_modifiers = self.modifiers_active.iter()
|
||||
.map(|(_id, m)| match m {
|
||||
Modifier::Control => Modifiers::CONTROL,
|
||||
Modifier::Alt => Modifiers::MOD1,
|
||||
})
|
||||
.fold(Modifiers::empty(), |m, n| m | n);
|
||||
self.virtual_keyboard.set_modifiers_state(raw_modifiers);
|
||||
}
|
||||
|
||||
pub fn is_modifier_active(&self, modifier: Modifier) -> bool {
|
||||
self.modifiers_active.iter()
|
||||
.position(|(_id, m)| *m == modifier)
|
||||
.is_some()
|
||||
}
|
||||
|
||||
pub fn get_active_modifiers(&self) -> HashSet<Modifier> {
|
||||
HashSet::from_iter(
|
||||
self.modifiers_active.iter().map(|(_id, m)| m.clone())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ fn check_layout(layout: Layout) {
|
||||
let state = xkb::State::new(&keymap);
|
||||
|
||||
// "Press" each button with keysyms
|
||||
for view in layout.views.values() {
|
||||
for (_pos, view) in layout.views.values() {
|
||||
for (_y, row) in &view.get_rows() {
|
||||
for (_x, button) in &row.buttons {
|
||||
let keystate = button.state.borrow();
|
||||
|
||||
8
src/ui_manager.c
Normal file
8
src/ui_manager.c
Normal file
@ -0,0 +1,8 @@
|
||||
#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);
|
||||
}
|
||||
15
src/ui_manager.h
Normal file
15
src/ui_manager.h
Normal file
@ -0,0 +1,15 @@
|
||||
#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
|
||||
241
src/ui_manager.rs
Normal file
241
src/ui_manager.rs
Normal file
@ -0,0 +1,241 @@
|
||||
/* 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)
|
||||
}))
|
||||
}
|
||||
15
src/util.rs
15
src/util.rs
@ -94,11 +94,13 @@ pub mod c {
|
||||
}
|
||||
/// Extracts the reference to the data.
|
||||
/// It may cause problems if attempted in more than one place
|
||||
// FIXME: check for null
|
||||
pub unsafe fn unwrap(self) -> Rc<RefCell<T>> {
|
||||
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>> {
|
||||
// A bit dangerous: the Rc may be in use elsewhere
|
||||
let used_rc = unsafe { Rc::from_raw(self.0) };
|
||||
@ -106,6 +108,10 @@ pub mod c {
|
||||
Rc::into_raw(used_rc); // prevent dropping the original reference
|
||||
rc
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.0.is_null()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for Wrapped<T> {
|
||||
@ -130,6 +136,7 @@ pub mod c {
|
||||
impl<T> COpaquePtr for Wrapped<T> {}
|
||||
}
|
||||
|
||||
/// Clones the underlying data structure, like ToOwned.
|
||||
pub trait CloneOwned {
|
||||
type Owned;
|
||||
fn clone_owned(&self) -> Self::Owned;
|
||||
@ -195,6 +202,12 @@ pub trait WarningHandler {
|
||||
fn handle(&mut self, warning: &str);
|
||||
}
|
||||
|
||||
/// Removes the first matcing item
|
||||
pub fn vec_remove<T, F: FnMut(&T) -> bool>(v: &mut Vec<T>, pred: F) -> Option<T> {
|
||||
let idx = v.iter().position(pred);
|
||||
idx.map(|idx| v.remove(idx))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*! Managing the events belonging to virtual-keyboard interface. */
|
||||
|
||||
use ::keyboard::{ KeyCode, PressType };
|
||||
use ::keyboard::{ KeyCode, Modifiers, PressType };
|
||||
use ::layout::c::LevelKeyboard;
|
||||
use ::submission::Timestamp;
|
||||
|
||||
@ -26,6 +26,11 @@ pub mod c {
|
||||
virtual_keyboard: ZwpVirtualKeyboardV1,
|
||||
keyboard: LevelKeyboard,
|
||||
);
|
||||
|
||||
pub fn eek_virtual_keyboard_set_modifiers(
|
||||
virtual_keyboard: ZwpVirtualKeyboardV1,
|
||||
modifiers: u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +38,7 @@ pub mod c {
|
||||
pub struct VirtualKeyboard(pub c::ZwpVirtualKeyboardV1);
|
||||
|
||||
impl VirtualKeyboard {
|
||||
// TODO: split out keyboard state management
|
||||
// TODO: error out if keymap not set
|
||||
pub fn switch(
|
||||
&self,
|
||||
keycodes: &Vec<KeyCode>,
|
||||
@ -68,12 +73,16 @@ impl VirtualKeyboard {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_modifiers_state(&self, modifiers: Modifiers) {
|
||||
let modifiers = modifiers.bits() as u32;
|
||||
unsafe {
|
||||
c::eek_virtual_keyboard_set_modifiers(self.0, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_keymap(&self, keyboard: LevelKeyboard) {
|
||||
unsafe {
|
||||
c::eek_virtual_keyboard_update_keymap(
|
||||
self.0,
|
||||
keyboard,
|
||||
);
|
||||
c::eek_virtual_keyboard_update_keymap(self.0, keyboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,12 @@ void eek_virtual_keyboard_update_keymap(struct zwp_virtual_keyboard_v1 *zwp_virt
|
||||
keyboard->keymap_fd, keyboard->keymap_len);
|
||||
}
|
||||
|
||||
void
|
||||
eek_virtual_keyboard_set_modifiers(struct zwp_virtual_keyboard_v1 *zwp_virtual_keyboard_v1, uint32_t mods_depressed) {
|
||||
zwp_virtual_keyboard_v1_modifiers(zwp_virtual_keyboard_v1,
|
||||
mods_depressed, 0, 0, 0);
|
||||
}
|
||||
|
||||
int squeek_output_add_listener(struct wl_output *wl_output,
|
||||
const struct wl_output_listener *listener, void *data) {
|
||||
return wl_output_add_listener(wl_output, listener, data);
|
||||
|
||||
@ -50,13 +50,14 @@ endforeach
|
||||
foreach layout : [
|
||||
'us', 'us_wide',
|
||||
'de', 'de_wide',
|
||||
'el',
|
||||
'es',
|
||||
'fi',
|
||||
'gr',
|
||||
'it',
|
||||
'jp+kana','jp+kana_wide',
|
||||
'no',
|
||||
'number',
|
||||
'pl', 'pl_wide',
|
||||
'se',
|
||||
'terminal',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user