From 894191d3a0ea737f2f9a633fe1354f88544c8016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 1 Dec 2021 13:00:13 +0100 Subject: [PATCH 1/4] entry: Use a scrolled window This ensures all entries are reachable even with the OSK unfolded --- tools/entry.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/entry.py b/tools/entry.py index 5064a4fa..0a15c0f3 100644 --- a/tools/entry.py +++ b/tools/entry.py @@ -46,6 +46,7 @@ class App(Gtk.Application): def do_activate(self): w = Gtk.ApplicationWindow(application=self) + w.set_default_size (300, 500) notebook = Gtk.Notebook() def add_purpose(entry, purpose): entry.set_input_purpose(purpose) @@ -54,7 +55,10 @@ class App(Gtk.Application): purpose_grid = new_grid(self.purposes, add_purpose) hint_grid = new_grid(self.hints, add_hint) - notebook.append_page(purpose_grid, Gtk.Label(label="Purposes")) + purpose_scroll = Gtk.ScrolledWindow() + purpose_scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + purpose_scroll.add(purpose_grid) + notebook.append_page(purpose_scroll, Gtk.Label(label="Purposes")) notebook.append_page(hint_grid, Gtk.Label(label="Hints")) w.add(notebook) w.show_all() From 937638c582e59b26172abbb3568a43d6bda25055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 1 Dec 2021 13:07:01 +0100 Subject: [PATCH 2/4] entry: Set a margin on the grids Less heavy on the eyes. --- tools/entry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/entry.py b/tools/entry.py index 0a15c0f3..e1ed27fd 100644 --- a/tools/entry.py +++ b/tools/entry.py @@ -14,6 +14,8 @@ except AttributeError: def new_grid(items, set_type): grid = Gtk.Grid(orientation='vertical', column_spacing=8, row_spacing=8) + grid.props.margin = 6 + i = 0 for text, value in items: l = Gtk.Label(label=text) From 912fe0b7b7aedac81bfab9f06c6559e5cd8a5c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 1 Dec 2021 14:09:24 +0100 Subject: [PATCH 3/4] entry: Add a random text entry field This allows to test the case where the purpose changes but nothing else. --- tools/entry.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/entry.py b/tools/entry.py index e1ed27fd..c2982a1a 100644 --- a/tools/entry.py +++ b/tools/entry.py @@ -1,10 +1,13 @@ #!/usr/bin/env python3 import gi +import random import sys gi.require_version('Gtk', '3.0') +gi.require_version('GLib', '2.0') from gi.repository import Gtk +from gi.repository import GLib try: terminal = [("Terminal", Gtk.InputPurpose.TERMINAL)] @@ -46,6 +49,25 @@ class App(Gtk.Application): ("OSK provided", Gtk.InputHints.INHIBIT_OSK) ] + def on_purpose_toggled(self, btn, entry): + purpose = Gtk.InputPurpose.PIN if btn.get_active() else Gtk.InputPurpose.PASSWORD + entry.set_input_purpose(purpose) + + def on_timeout(self, e): + r = random.randint(0, len(self.purposes) - 1) + (_, purpose) = self.purposes[r] + print(f"Setting {purpose}") + e.set_input_purpose(purpose) + return True + + def add_random (self, grid): + l = Gtk.Label(label="Random") + e = Gtk.Entry(hexpand=True) + e.set_input_purpose(Gtk.InputPurpose.FREE_FORM) + grid.attach(l, 0, len(self.purposes), 1, 1) + grid.attach(e, 1, len(self.purposes), 1, 1) + GLib.timeout_add_seconds (3, self.on_timeout, e) + def do_activate(self): w = Gtk.ApplicationWindow(application=self) w.set_default_size (300, 500) @@ -55,6 +77,7 @@ class App(Gtk.Application): def add_hint(entry, hint): entry.set_input_hints(hint) purpose_grid = new_grid(self.purposes, add_purpose) + self.add_random(purpose_grid) hint_grid = new_grid(self.hints, add_hint) purpose_scroll = Gtk.ScrolledWindow() From 06b17907bf024b92af0f4b20ed9203a2ba81203b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 1 Dec 2021 14:30:06 +0100 Subject: [PATCH 4/4] imservice: Invoke eekboard_context_service_set_hint_purpose unconditionally Since eekboard_context_service_set_hint_purpose() checks if the hint or purpose changed this doesn't cause unwanted layout reloads. Closes: #311 --- src/imservice.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/imservice.rs b/src/imservice.rs index 3a87de4b..ce6a036e 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -153,14 +153,14 @@ pub mod c { if active_changed { (imservice.active_callback)(imservice.current.active); - if imservice.current.active { - unsafe { - eekboard_context_service_set_hint_purpose( - imservice.state_manager, - imservice.current.content_hint.bits(), - imservice.current.content_purpose.clone() as u32, - ); - } + } + if imservice.current.active { + unsafe { + eekboard_context_service_set_hint_purpose( + imservice.state_manager, + imservice.current.content_hint.bits(), + imservice.current.content_purpose.clone() as u32, + ); } } }