forked from AuroraMiddleware/gtk
Bring back im context focus-in/out
The key controller still needs to track focus, in order to emit these signals when required.
This commit is contained in:
parent
cadeca74e2
commit
0c96b2d8f7
@ -52,8 +52,7 @@ struct _GtkEventControllerKey
|
||||
|
||||
GdkEvent *current_event;
|
||||
|
||||
guint is_focus : 1;
|
||||
guint contains_focus : 1;
|
||||
gboolean is_focus;
|
||||
};
|
||||
|
||||
struct _GtkEventControllerKeyClass
|
||||
@ -145,6 +144,44 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
|
||||
return handled;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_key_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkEventControllerKey *key = GTK_EVENT_CONTROLLER_KEY (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
gboolean start_crossing, end_crossing;
|
||||
gboolean is_focus;
|
||||
|
||||
if (crossing->type != GTK_CROSSING_FOCUS)
|
||||
return;
|
||||
|
||||
start_crossing = crossing->direction == GTK_CROSSING_OUT &&
|
||||
widget == crossing->old_target;
|
||||
end_crossing = crossing->direction == GTK_CROSSING_IN &&
|
||||
widget == crossing->new_target;
|
||||
|
||||
if (!start_crossing && !end_crossing)
|
||||
return;
|
||||
|
||||
is_focus = end_crossing;
|
||||
|
||||
if (key->is_focus != is_focus)
|
||||
{
|
||||
key->is_focus = is_focus;
|
||||
|
||||
if (key->im_context)
|
||||
{
|
||||
if (is_focus)
|
||||
gtk_im_context_focus_in (key->im_context);
|
||||
else
|
||||
gtk_im_context_focus_out (key->im_context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
|
||||
{
|
||||
@ -153,6 +190,7 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass)
|
||||
|
||||
object_class->finalize = gtk_event_controller_key_finalize;
|
||||
controller_class->handle_event = gtk_event_controller_key_handle_event;
|
||||
controller_class->handle_crossing = gtk_event_controller_key_handle_crossing;
|
||||
|
||||
/**
|
||||
* GtkEventControllerKey::key-pressed:
|
||||
|
Loading…
Reference in New Issue
Block a user