state: Connect the animation state machine to the rest
This ensures that the new state machine is fed events, as well as that its results are applied. The old ad-hoc system is removed. There is one regression where the last layout will be used when the panel is brought up manually.
This commit is contained in:
@ -30,7 +30,6 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_VISIBLE,
|
||||
PROP_ENABLED,
|
||||
PROP_LAST
|
||||
};
|
||||
@ -45,10 +44,8 @@ struct _ServerContextService {
|
||||
struct ui_manager *manager; // unowned
|
||||
struct vis_manager *vis_manager; // owned
|
||||
|
||||
gboolean visible;
|
||||
PhoshLayerSurface *window;
|
||||
GtkWidget *widget; // nullable
|
||||
guint hiding;
|
||||
guint last_requested_height;
|
||||
};
|
||||
|
||||
@ -67,23 +64,6 @@ on_destroy (ServerContextService *self, GtkWidget *widget)
|
||||
//eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
|
||||
}
|
||||
|
||||
static void
|
||||
on_notify_map (ServerContextService *self, GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
|
||||
|
||||
g_object_set (self, "visible", TRUE, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
on_notify_unmap (ServerContextService *self, GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
|
||||
|
||||
g_object_set (self, "visible", FALSE, NULL);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
calculate_height(int32_t width, GdkRectangle *geometry)
|
||||
{
|
||||
@ -187,8 +167,6 @@ make_window (ServerContextService *self)
|
||||
|
||||
g_object_connect (self->window,
|
||||
"swapped-signal::destroy", G_CALLBACK(on_destroy), self,
|
||||
"swapped-signal::map", G_CALLBACK(on_notify_map), self,
|
||||
"swapped-signal::unmap", G_CALLBACK(on_notify_unmap), self,
|
||||
"swapped-signal::configured", G_CALLBACK(on_surface_configure), self,
|
||||
NULL);
|
||||
|
||||
@ -225,7 +203,7 @@ make_widget (ServerContextService *self)
|
||||
gtk_widget_show_all(self->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
server_context_service_real_show_keyboard (ServerContextService *self)
|
||||
{
|
||||
if (!self->window) {
|
||||
@ -234,92 +212,13 @@ server_context_service_real_show_keyboard (ServerContextService *self)
|
||||
if (!self->widget) {
|
||||
make_widget (self);
|
||||
}
|
||||
self->visible = TRUE;
|
||||
gtk_widget_show (GTK_WIDGET(self->window));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
show_keyboard_source_func(ServerContextService *context)
|
||||
{
|
||||
server_context_service_real_show_keyboard(context);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
server_context_service_real_hide_keyboard (ServerContextService *self)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET(self->window));
|
||||
self->visible = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
hide_keyboard_source_func(ServerContextService *context)
|
||||
{
|
||||
server_context_service_real_hide_keyboard(context);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_hide (ServerContextService *self)
|
||||
{
|
||||
server_context_service_real_hide_keyboard(self);
|
||||
self->hiding = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
server_context_service_show_keyboard (ServerContextService *self)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
|
||||
|
||||
if (self->hiding) {
|
||||
g_source_remove (self->hiding);
|
||||
self->hiding = 0;
|
||||
}
|
||||
|
||||
if (!self->visible) {
|
||||
g_idle_add((GSourceFunc)show_keyboard_source_func, self);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_context_service_force_show_keyboard (ServerContextService *self)
|
||||
{
|
||||
if (!submission_hint_available(self->submission)) {
|
||||
eekboard_context_service_set_hint_purpose(
|
||||
self->state,
|
||||
ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE,
|
||||
ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL
|
||||
);
|
||||
}
|
||||
server_context_service_show_keyboard(self);
|
||||
}
|
||||
|
||||
void
|
||||
server_context_service_hide_keyboard (ServerContextService *self)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
|
||||
|
||||
if (self->visible) {
|
||||
g_idle_add((GSourceFunc)hide_keyboard_source_func, self);
|
||||
}
|
||||
}
|
||||
|
||||
/// Meant for use by the input-method handler:
|
||||
/// the visible keyboard is no longer needed.
|
||||
/// The implementation will delay it slightly,
|
||||
/// because the release may be due to switching from one text field to another.
|
||||
/// In this case, the user doesn't really need the keyboard surface
|
||||
/// to disappear completely.
|
||||
void
|
||||
server_context_service_release_visibility (ServerContextService *self)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
|
||||
|
||||
if (!self->hiding && self->visible) {
|
||||
self->hiding = g_timeout_add (200, (GSourceFunc) on_hide, self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -338,9 +237,6 @@ server_context_service_set_property (GObject *object,
|
||||
ServerContextService *self = SERVER_CONTEXT_SERVICE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_VISIBLE:
|
||||
self->visible = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_ENABLED:
|
||||
server_context_service_set_physical_keyboard_present (self, !g_value_get_boolean (value));
|
||||
break;
|
||||
@ -356,11 +252,7 @@ server_context_service_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ServerContextService *self = SERVER_CONTEXT_SERVICE(object);
|
||||
switch (prop_id) {
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, self->visible);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -388,18 +280,6 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
||||
gobject_class->get_property = server_context_service_get_property;
|
||||
gobject_class->dispose = server_context_service_dispose;
|
||||
|
||||
/**
|
||||
* Flag to indicate if keyboard is visible or not.
|
||||
*/
|
||||
pspec = g_param_spec_boolean ("visible",
|
||||
"Visible",
|
||||
"Visible",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_VISIBLE,
|
||||
pspec);
|
||||
|
||||
/**
|
||||
* ServerContextServie:keyboard:
|
||||
*
|
||||
@ -452,13 +332,3 @@ server_context_service_new (EekboardContextService *self, struct submission *sub
|
||||
init(ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
void
|
||||
server_context_service_update_visible (ServerContextService *self, gboolean visible) {
|
||||
if (visible) {
|
||||
server_context_service_show_keyboard(self);
|
||||
} else {
|
||||
server_context_service_hide_keyboard(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user