Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74af1336e8 | |||
| 88b0afa319 | |||
| 4d487ed872 | |||
| e9d6631159 |
@ -102,8 +102,12 @@ pub mod c {
|
||||
imservice.pending = IMProtocolState {
|
||||
content_hint: {
|
||||
ContentHint::from_bits(hint).unwrap_or_else(|| {
|
||||
eprintln!("Warning: received invalid hint flags");
|
||||
ContentHint::NONE
|
||||
let out = ContentHint::from_bits_truncate(hint);
|
||||
eprintln!(
|
||||
"Warning: received hint flags with unknown bits set: 0x{:x}",
|
||||
hint ^ out.bits(),
|
||||
);
|
||||
out
|
||||
})
|
||||
},
|
||||
content_purpose: {
|
||||
@ -142,19 +146,34 @@ pub mod c {
|
||||
let imservice = check_imservice(imservice, im).unwrap();
|
||||
let active_changed = imservice.current.active ^ imservice.pending.active;
|
||||
|
||||
fn is_visible(state: &IMProtocolState) -> bool {
|
||||
state.active
|
||||
&& !state.content_hint.contains(
|
||||
ContentHint::ON_SCREEN_INPUT_PROVIDED
|
||||
)
|
||||
}
|
||||
|
||||
let visible_changed = is_visible(&imservice.current)
|
||||
^ is_visible(&imservice.pending);
|
||||
|
||||
imservice.serial += Wrapping(1u32);
|
||||
imservice.current = imservice.pending.clone();
|
||||
imservice.pending = IMProtocolState {
|
||||
active: imservice.current.active,
|
||||
..IMProtocolState::default()
|
||||
};
|
||||
if active_changed {
|
||||
if imservice.current.active {
|
||||
eekboard_context_service_show_keyboard(imservice.ui_manager);
|
||||
|
||||
if active_changed && imservice.current.active {
|
||||
eekboard_context_service_set_hint_purpose(
|
||||
imservice.ui_manager,
|
||||
imservice.current.content_hint.bits(),
|
||||
imservice.current.content_purpose.clone() as u32);
|
||||
imservice.current.content_purpose.clone() as u32,
|
||||
);
|
||||
}
|
||||
|
||||
if visible_changed {
|
||||
if is_visible(&imservice.current) {
|
||||
eekboard_context_service_show_keyboard(imservice.ui_manager);
|
||||
} else {
|
||||
eekboard_context_service_hide_keyboard(imservice.ui_manager);
|
||||
}
|
||||
@ -219,6 +238,7 @@ bitflags!{
|
||||
const SENSITIVE_DATA = 0x80;
|
||||
const LATIN = 0x100;
|
||||
const MULTILINE = 0x200;
|
||||
const ON_SCREEN_INPUT_PROVIDED = 0x400;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,19 @@ except AttributeError:
|
||||
print("Terminal purpose not available on this GTK version", file=sys.stderr)
|
||||
terminal = []
|
||||
|
||||
def new_grid(items, set_type):
|
||||
grid = Gtk.Grid(orientation='vertical', column_spacing=8, row_spacing=8)
|
||||
i = 0
|
||||
for text, value in items:
|
||||
l = Gtk.Label(label=text)
|
||||
e = Gtk.Entry(hexpand=True)
|
||||
set_type(e, value)
|
||||
grid.attach(l, 0, i, 1, 1)
|
||||
grid.attach(e, 1, i, 1, 1)
|
||||
i += 1
|
||||
return grid
|
||||
|
||||
|
||||
class App(Gtk.Application):
|
||||
|
||||
purposes = [
|
||||
@ -27,20 +40,23 @@ class App(Gtk.Application):
|
||||
("PIN", Gtk.InputPurpose.PIN),
|
||||
] + terminal
|
||||
|
||||
hints = [
|
||||
("OSK provided", Gtk.InputHints.INHIBIT_OSK)
|
||||
]
|
||||
|
||||
def do_activate(self):
|
||||
w = Gtk.ApplicationWindow(application=self)
|
||||
grid = Gtk.Grid(orientation='vertical', column_spacing=8, row_spacing=8)
|
||||
i = 0
|
||||
for text, purpose in self.purposes:
|
||||
notebook = Gtk.Notebook()
|
||||
def add_purpose(entry, purpose):
|
||||
entry.set_input_purpose(purpose)
|
||||
def add_hint(entry, hint):
|
||||
entry.set_input_hints(hint)
|
||||
purpose_grid = new_grid(self.purposes, add_purpose)
|
||||
hint_grid = new_grid(self.hints, add_hint)
|
||||
|
||||
l = Gtk.Label(label=text)
|
||||
e = Gtk.Entry(hexpand=True)
|
||||
e.set_input_purpose(purpose)
|
||||
grid.attach(l, 0, i, 1, 1)
|
||||
grid.attach(e, 1, i, 1, 1)
|
||||
i += 1
|
||||
|
||||
w.add(grid)
|
||||
notebook.append_page(purpose_grid, Gtk.Label(label="Purposes"))
|
||||
notebook.append_page(hint_grid, Gtk.Label(label="Hints"))
|
||||
w.add(notebook)
|
||||
w.show_all()
|
||||
|
||||
app = App()
|
||||
|
||||
Reference in New Issue
Block a user