Skip to content

Commit a8969f2

Browse files
gtk: Add IMContextImpl::activate_osk
1 parent d8363a3 commit a8969f2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

gtk4/src/subclass/im_context.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ pub trait IMContextImpl: IMContextImplExt + ObjectImpl {
6161
fn set_use_preedit(&self, use_preedit: bool) {
6262
self.parent_set_use_preedit(use_preedit)
6363
}
64+
#[cfg(any(feature = "v4_10", feature = "dox"))]
65+
fn activate_osk(&self) {
66+
self.parent_activate_osk()
67+
}
6468
}
6569

6670
#[allow(clippy::upper_case_acronyms)]
@@ -81,6 +85,8 @@ pub trait IMContextImplExt: ObjectSubclass {
8185
fn parent_set_cursor_location(&self, area: &gdk::Rectangle);
8286
fn parent_set_surrounding(&self, text: &str, cursor_index: i32);
8387
fn parent_set_use_preedit(&self, use_preedit: bool);
88+
#[cfg(any(feature = "v4_10", feature = "dox"))]
89+
fn parent_activate_osk(&self);
8490
}
8591

8692
impl<T: IMContextImpl> IMContextImplExt for T {
@@ -304,6 +310,17 @@ impl<T: IMContextImpl> IMContextImplExt for T {
304310
}
305311
}
306312
}
313+
314+
#[cfg(any(feature = "v4_10", feature = "dox"))]
315+
fn parent_activate_osk(&self) {
316+
unsafe {
317+
let data = T::type_data();
318+
let parent_class = data.as_ref().parent_class() as *mut ffi::GtkIMContextClass;
319+
if let Some(f) = (*parent_class).activate_osk {
320+
f(self.obj().unsafe_cast_ref::<IMContext>().to_glib_none().0)
321+
}
322+
}
323+
}
307324
}
308325

309326
unsafe impl<T: IMContextImpl> IsSubclassable<T> for IMContext {
@@ -332,6 +349,10 @@ unsafe impl<T: IMContextImpl> IsSubclassable<T> for IMContext {
332349
klass.set_cursor_location = Some(im_context_set_cursor_location::<T>);
333350
klass.set_surrounding = Some(im_context_set_surrounding::<T>);
334351
klass.set_use_preedit = Some(im_context_set_use_preedit::<T>);
352+
#[cfg(any(feature = "v4_10", feature = "dox"))]
353+
{
354+
klass.activate_osk = Some(im_context_activate_osk::<T>);
355+
};
335356
}
336357
}
337358

@@ -504,3 +525,11 @@ unsafe extern "C" fn im_context_set_use_preedit<T: IMContextImpl>(
504525

505526
imp.set_use_preedit(from_glib(use_preedit))
506527
}
528+
529+
#[cfg(any(feature = "v4_10", feature = "dox"))]
530+
unsafe extern "C" fn im_context_activate_osk<T: IMContextImpl>(ptr: *mut ffi::GtkIMContext) {
531+
let instance = &*(ptr as *mut T::Instance);
532+
let imp = instance.imp();
533+
534+
imp.activate_osk()
535+
}

0 commit comments

Comments
 (0)