managers: Move visible flag to UI manager
This commit is contained in:
@ -48,7 +48,6 @@
|
||||
enum {
|
||||
PROP_0, // Magic: without this, keyboard is not useable in g_object_notify
|
||||
PROP_KEYBOARD,
|
||||
PROP_VISIBLE,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -66,7 +65,6 @@ static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
struct _EekboardContextServicePrivate {
|
||||
gboolean enabled;
|
||||
gboolean visible;
|
||||
|
||||
LevelKeyboard *keyboard; // currently used keyboard
|
||||
GHashTable *keyboard_hash; // a table of available keyboards, per layout
|
||||
@ -135,18 +133,6 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_real_show_keyboard (EekboardContextService *self)
|
||||
{
|
||||
self->priv->visible = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_real_hide_keyboard (EekboardContextService *self)
|
||||
{
|
||||
self->priv->visible = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_service_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -161,9 +147,6 @@ eekboard_context_service_set_property (GObject *object,
|
||||
g_object_unref (context->priv->keyboard);
|
||||
context->priv->keyboard = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
context->priv->visible = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -182,9 +165,6 @@ eekboard_context_service_get_property (GObject *object,
|
||||
case PROP_KEYBOARD:
|
||||
g_value_set_object (value, context->priv->keyboard);
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, context->priv->visible);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -362,20 +342,6 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_KEYBOARD,
|
||||
pspec);
|
||||
|
||||
/**
|
||||
* EekboardContextService:visible:
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -437,26 +403,6 @@ eekboard_context_service_disable (EekboardContextService *context)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_show_keyboard (EekboardContextService *context)
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||
|
||||
if (!context->priv->visible) {
|
||||
server_context_service_real_show_keyboard (context);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
eekboard_context_service_hide_keyboard (EekboardContextService *context)
|
||||
{
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||
|
||||
if (context->priv->visible) {
|
||||
server_context_service_real_hide_keyboard (context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* eekboard_context_service_destroy:
|
||||
* @context: an #EekboardContextService
|
||||
|
||||
@ -88,14 +88,6 @@ GType eekboard_context_service_get_type
|
||||
(void) G_GNUC_CONST;
|
||||
void eekboard_context_service_enable (EekboardContextService *context);
|
||||
void eekboard_context_service_disable (EekboardContextService *context);
|
||||
void eekboard_context_service_show_keyboard
|
||||
(EekboardContextService *context);
|
||||
void
|
||||
eekboard_context_service_real_show_keyboard (EekboardContextService *self);
|
||||
void
|
||||
eekboard_context_service_real_hide_keyboard (EekboardContextService *self);
|
||||
void eekboard_context_service_hide_keyboard
|
||||
(EekboardContextService *context);
|
||||
void eekboard_context_service_destroy (EekboardContextService *context);
|
||||
LevelKeyboard *eekboard_context_service_get_keyboard(EekboardContextService *context);
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ typedef struct _EekboardServicePrivate
|
||||
guint registration_id;
|
||||
char *object_path;
|
||||
|
||||
EekboardContextService *context; // unowned reference
|
||||
ServerContextService *context; // unowned reference
|
||||
} EekboardServicePrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardService, eekboard_service, G_TYPE_OBJECT)
|
||||
@ -162,9 +162,9 @@ handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
|
||||
|
||||
if (priv->context) {
|
||||
if (arg_visible) {
|
||||
eekboard_context_service_show_keyboard (priv->context);
|
||||
server_context_service_show_keyboard (priv->context);
|
||||
} else {
|
||||
eekboard_context_service_hide_keyboard (priv->context);
|
||||
server_context_service_hide_keyboard (priv->context);
|
||||
}
|
||||
}
|
||||
sm_puri_osk0_complete_set_visible(object, invocation);
|
||||
@ -173,13 +173,13 @@ handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
|
||||
|
||||
static void on_visible(EekboardService *service,
|
||||
GParamSpec *pspec,
|
||||
EekboardContextService *context)
|
||||
ServerContextService *context)
|
||||
{
|
||||
gboolean visible;
|
||||
EekboardServicePrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_SERVICE (service));
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE (context));
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (context));
|
||||
|
||||
priv = eekboard_service_get_instance_private (service);
|
||||
g_object_get (context, "visible", &visible, NULL);
|
||||
@ -295,7 +295,7 @@ eekboard_service_new (GDBusConnection *connection,
|
||||
|
||||
void
|
||||
eekboard_service_set_context(EekboardService *service,
|
||||
EekboardContextService *context)
|
||||
ServerContextService *context)
|
||||
{
|
||||
EekboardServicePrivate *priv = eekboard_service_get_instance_private (service);
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#define __EEKBOARD_SERVICE_H_INSIDE__ 1
|
||||
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
#include "server-context-service.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -50,6 +50,6 @@ GType eekboard_service_get_type (void) G_GNUC_CONST;
|
||||
EekboardService * eekboard_service_new (GDBusConnection *connection,
|
||||
const gchar *object_path);
|
||||
void eekboard_service_set_context(EekboardService *service,
|
||||
EekboardContextService *context);
|
||||
ServerContextService *context);
|
||||
G_END_DECLS
|
||||
#endif /* EEKBOARD_SERVICE_H */
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
|
||||
|
||||
static const struct zwp_input_method_v2_listener input_method_listener = {
|
||||
.activate = imservice_handle_input_method_activate,
|
||||
.deactivate = imservice_handle_input_method_deactivate,
|
||||
@ -15,7 +12,7 @@ static const struct zwp_input_method_v2_listener input_method_listener = {
|
||||
.unavailable = imservice_handle_unavailable,
|
||||
};
|
||||
|
||||
struct imservice* get_imservice(EekboardContextService *context,
|
||||
struct imservice* get_imservice(ServerContextService *context,
|
||||
struct zwp_input_method_manager_v2 *manager,
|
||||
struct wl_seat *seat) {
|
||||
struct zwp_input_method_v2 *im = zwp_input_method_manager_v2_get_input_method(manager, seat);
|
||||
@ -28,14 +25,6 @@ struct imservice* get_imservice(EekboardContextService *context,
|
||||
return imservice;
|
||||
}
|
||||
|
||||
void imservice_make_visible(EekboardContextService *context) {
|
||||
eekboard_context_service_show_keyboard (context);
|
||||
}
|
||||
|
||||
void imservice_try_hide(EekboardContextService *context) {
|
||||
eekboard_context_service_hide_keyboard (context);
|
||||
}
|
||||
|
||||
/// Declared explicitly because _destroy is inline,
|
||||
/// making it unavailable in Rust
|
||||
void imservice_destroy_im(struct zwp_input_method_v2 *im) {
|
||||
|
||||
@ -3,16 +3,17 @@
|
||||
|
||||
#include "input-method-unstable-v2-client-protocol.h"
|
||||
#include "eek/eek-types.h"
|
||||
#include "src/server-context-service.h"
|
||||
|
||||
struct imservice;
|
||||
|
||||
struct imservice* get_imservice(EekboardContextService *context,
|
||||
struct imservice* get_imservice(ServerContextService *context,
|
||||
struct zwp_input_method_manager_v2 *manager,
|
||||
struct wl_seat *seat);
|
||||
|
||||
// Defined in Rust
|
||||
struct imservice* imservice_new(struct zwp_input_method_v2 *im,
|
||||
EekboardContextService *context);
|
||||
ServerContextService *context);
|
||||
void imservice_handle_input_method_activate(void *data, struct zwp_input_method_v2 *input_method);
|
||||
void imservice_handle_input_method_deactivate(void *data, struct zwp_input_method_v2 *input_method);
|
||||
void imservice_handle_surrounding_text(void *data, struct zwp_input_method_v2 *input_method,
|
||||
|
||||
@ -29,8 +29,8 @@ pub mod c {
|
||||
extern "C" {
|
||||
fn imservice_destroy_im(im: *mut c::InputMethod);
|
||||
fn eekboard_context_service_set_hint_purpose(imservice: *const UIManager, hint: u32, purpose: u32);
|
||||
fn eekboard_context_service_show_keyboard(imservice: *const UIManager);
|
||||
fn eekboard_context_service_hide_keyboard(imservice: *const UIManager);
|
||||
fn server_context_service_show_keyboard(imservice: *const UIManager);
|
||||
fn server_context_service_hide_keyboard(imservice: *const UIManager);
|
||||
}
|
||||
|
||||
// The following defined in Rust. TODO: wrap naked pointers to Rust data inside RefCells to prevent multiple writers
|
||||
@ -150,13 +150,13 @@ pub mod c {
|
||||
};
|
||||
if active_changed {
|
||||
if imservice.current.active {
|
||||
eekboard_context_service_show_keyboard(imservice.ui_manager);
|
||||
server_context_service_show_keyboard(imservice.ui_manager);
|
||||
eekboard_context_service_set_hint_purpose(
|
||||
imservice.ui_manager,
|
||||
imservice.current.content_hint.bits(),
|
||||
imservice.current.content_purpose.clone() as u32);
|
||||
} else {
|
||||
eekboard_context_service_hide_keyboard(imservice.ui_manager);
|
||||
server_context_service_hide_keyboard(imservice.ui_manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,7 +173,7 @@ pub mod c {
|
||||
// the keyboard is already decommissioned
|
||||
imservice.current.active = false;
|
||||
|
||||
eekboard_context_service_hide_keyboard(imservice.ui_manager);
|
||||
server_context_service_hide_keyboard(imservice.ui_manager);
|
||||
}
|
||||
|
||||
// FIXME: destroy and deallocate
|
||||
|
||||
@ -23,14 +23,15 @@
|
||||
#include "eek/eek.h"
|
||||
#include "eek/eek-gtk-keyboard.h"
|
||||
#include "eek/layersurface.h"
|
||||
#include "wayland.h"
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
#include "wayland.h"
|
||||
#include "server-context-service.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SIZE_CONSTRAINT_LANDSCAPE,
|
||||
PROP_SIZE_CONSTRAINT_PORTRAIT,
|
||||
PROP_VISIBLE,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -39,6 +40,7 @@ typedef struct _ServerContextServiceClass ServerContextServiceClass;
|
||||
struct _ServerContextService {
|
||||
EekboardContextService parent;
|
||||
|
||||
gboolean visible;
|
||||
PhoshLayerSurface *window;
|
||||
GtkWidget *widget;
|
||||
guint hiding;
|
||||
@ -95,8 +97,8 @@ on_notify_keyboard (GObject *object,
|
||||
g_object_get (context, "visible", &visible, NULL);
|
||||
|
||||
if (visible) {
|
||||
eekboard_context_service_hide_keyboard(EEKBOARD_CONTEXT_SERVICE(context));
|
||||
eekboard_context_service_show_keyboard(EEKBOARD_CONTEXT_SERVICE(context));
|
||||
server_context_service_hide_keyboard(context);
|
||||
server_context_service_show_keyboard(context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,11 +240,18 @@ make_widget (ServerContextService *context)
|
||||
gtk_widget_show (context->widget);
|
||||
}
|
||||
|
||||
void
|
||||
server_context_service_real_show_keyboard (EekboardContextService *_context)
|
||||
static gboolean
|
||||
on_hide (ServerContextService *context)
|
||||
{
|
||||
ServerContextService *context = SERVER_CONTEXT_SERVICE(_context);
|
||||
gtk_widget_hide (GTK_WIDGET(context->window));
|
||||
context->hiding = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
server_context_service_real_show_keyboard (ServerContextService *context)
|
||||
{
|
||||
if (context->hiding) {
|
||||
g_source_remove (context->hiding);
|
||||
context->hiding = 0;
|
||||
@ -253,28 +262,37 @@ server_context_service_real_show_keyboard (EekboardContextService *_context)
|
||||
if (!context->widget)
|
||||
make_widget (context);
|
||||
|
||||
eekboard_context_service_real_show_keyboard (_context);
|
||||
context->visible = TRUE;
|
||||
gtk_widget_show (GTK_WIDGET(context->window));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_hide (ServerContextService *context)
|
||||
static void
|
||||
server_context_service_real_hide_keyboard (ServerContextService *context)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET(context->window));
|
||||
context->hiding = 0;
|
||||
if (!context->hiding)
|
||||
context->hiding = g_timeout_add (200, (GSourceFunc) on_hide, context);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
context->visible = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
server_context_service_real_hide_keyboard (EekboardContextService *_context)
|
||||
server_context_service_show_keyboard (ServerContextService *context)
|
||||
{
|
||||
ServerContextService *context = SERVER_CONTEXT_SERVICE(_context);
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(context));
|
||||
|
||||
if (!context->hiding)
|
||||
context->hiding = g_timeout_add (200, (GSourceFunc) on_hide, context);
|
||||
if (!context->visible) {
|
||||
server_context_service_real_show_keyboard (context);
|
||||
}
|
||||
}
|
||||
|
||||
eekboard_context_service_real_hide_keyboard (_context);
|
||||
void
|
||||
server_context_service_hide_keyboard (ServerContextService *context)
|
||||
{
|
||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(context));
|
||||
|
||||
if (context->visible) {
|
||||
server_context_service_real_hide_keyboard (context);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -304,6 +322,9 @@ server_context_service_set_property (GObject *object,
|
||||
&context->size_constraint_portrait[0],
|
||||
&context->size_constraint_portrait[1]);
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
context->visible = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -311,6 +332,23 @@ server_context_service_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
server_context_service_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
|
||||
switch (prop_id) {
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, context->visible);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
server_context_service_dispose (GObject *object)
|
||||
{
|
||||
@ -332,6 +370,7 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
||||
context_class->destroyed = server_context_service_real_destroyed;
|
||||
|
||||
gobject_class->set_property = server_context_service_set_property;
|
||||
gobject_class->get_property = server_context_service_get_property;
|
||||
gobject_class->dispose = server_context_service_dispose;
|
||||
|
||||
pspec = g_param_spec_variant ("size-constraint-landscape",
|
||||
@ -353,6 +392,18 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SIZE_CONSTRAINT_PORTRAIT,
|
||||
pspec);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -364,10 +415,10 @@ server_context_service_init (ServerContextService *context)
|
||||
context);
|
||||
}
|
||||
|
||||
EekboardContextService *
|
||||
ServerContextService *
|
||||
server_context_service_new ()
|
||||
{
|
||||
return EEKBOARD_CONTEXT_SERVICE(g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL));
|
||||
return g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL);
|
||||
}
|
||||
|
||||
enum squeek_arrangement_kind server_context_service_get_layout_type(EekboardContextService *service)
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#ifndef SERVER_CONTEXT_SERVICE_H
|
||||
#define SERVER_CONTEXT_SERVICE_H 1
|
||||
|
||||
#include "eekboard/eekboard-service.h"
|
||||
#include "src/layout.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -33,10 +32,13 @@ G_BEGIN_DECLS
|
||||
/** Manages the liecycle of the window displaying layouts. */
|
||||
typedef struct _ServerContextService ServerContextService;
|
||||
|
||||
EekboardContextService *server_context_service_new ();
|
||||
GType server_context_service_get_type
|
||||
(void) G_GNUC_CONST;
|
||||
|
||||
ServerContextService *server_context_service_new();
|
||||
enum squeek_arrangement_kind server_context_service_get_layout_type(EekboardContextService*);
|
||||
void server_context_service_real_show_keyboard (EekboardContextService *context);
|
||||
void server_context_service_real_hide_keyboard (EekboardContextService *context);
|
||||
void server_context_service_show_keyboard (ServerContextService *context);
|
||||
void server_context_service_hide_keyboard (ServerContextService *context);
|
||||
G_END_DECLS
|
||||
#endif /* SERVER_CONTEXT_SERVICE_H */
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include "eekboard/eekboard-service.h"
|
||||
#include "eek/eek.h"
|
||||
#include "eekboard/eekboard-context-service.h"
|
||||
#include "imservice.h"
|
||||
#include "outputs.h"
|
||||
#include "server-context-service.h"
|
||||
@ -38,7 +39,7 @@
|
||||
/// Global application state
|
||||
struct squeekboard {
|
||||
struct squeek_wayland wayland;
|
||||
EekboardContextService *context;
|
||||
ServerContextService *context;
|
||||
struct imservice *imservice;
|
||||
};
|
||||
|
||||
@ -80,12 +81,12 @@ on_destroyed (EekboardService *service,
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static EekboardContextService *create_context() {
|
||||
EekboardContextService *context = server_context_service_new ();
|
||||
static ServerContextService *create_context() {
|
||||
ServerContextService *context = server_context_service_new ();
|
||||
g_object_set_data_full (G_OBJECT(context),
|
||||
"owner", g_strdup ("sender"),
|
||||
(GDestroyNotify)g_free);
|
||||
eekboard_context_service_enable (context);
|
||||
eekboard_context_service_enable (EEKBOARD_CONTEXT_SERVICE(context));
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user