Respond to the input purpose, showing a numeric keypad if requested
This commit is contained in:
		@ -79,6 +79,8 @@ struct _EekboardContextServicePrivate {
 | 
			
		||||
    gboolean repeat_triggered;
 | 
			
		||||
 | 
			
		||||
    GSettings *settings;
 | 
			
		||||
    uint32_t hint;
 | 
			
		||||
    uint32_t purpose;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
 | 
			
		||||
@ -353,11 +355,15 @@ settings_update_layout(EekboardContextService *context)
 | 
			
		||||
        keyboard_layout = g_strdup("undefined");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
 | 
			
		||||
 | 
			
		||||
    if (priv->purpose == ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE)
 | 
			
		||||
        keyboard_layout = g_strdup("numbers");
 | 
			
		||||
 | 
			
		||||
    // generic part follows
 | 
			
		||||
    static guint keyboard_id = 0;
 | 
			
		||||
    EekKeyboard *keyboard = g_hash_table_lookup(context->priv->keyboard_hash,
 | 
			
		||||
                                                GUINT_TO_POINTER(keyboard_id));
 | 
			
		||||
    g_debug("type=%s, layout=%s, keyboard=%p", keyboard_type, keyboard_layout, keyboard);
 | 
			
		||||
    // create a keyboard
 | 
			
		||||
    if (!keyboard) {
 | 
			
		||||
        EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
 | 
			
		||||
@ -641,3 +647,15 @@ void eekboard_context_service_set_keymap(EekboardContextService *context,
 | 
			
		||||
        WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
 | 
			
		||||
        keyboard->keymap_fd, keyboard->keymap_len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
 | 
			
		||||
                                               uint32_t hint, uint32_t purpose)
 | 
			
		||||
{
 | 
			
		||||
    EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
 | 
			
		||||
 | 
			
		||||
    if (priv->hint != hint || priv->purpose != purpose) {
 | 
			
		||||
        priv->hint = hint;
 | 
			
		||||
        priv->purpose = purpose;
 | 
			
		||||
        settings_update_layout(context);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@
 | 
			
		||||
#include <eek/eek.h>
 | 
			
		||||
 | 
			
		||||
#include "virtual-keyboard-unstable-v1-client-protocol.h"
 | 
			
		||||
#include "text-input-unstable-v3-client-protocol.h"
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
@ -104,5 +105,9 @@ gboolean      eekboard_context_service_get_fullscreen
 | 
			
		||||
void eekboard_context_service_set_keymap(EekboardContextService *context,
 | 
			
		||||
                                         const EekKeyboard *keyboard);
 | 
			
		||||
 | 
			
		||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
 | 
			
		||||
                                               uint32_t hint,
 | 
			
		||||
                                               uint32_t purpose);
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
#endif  /* EEKBOARD_CONTEXT_SERVICE_H */
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,7 @@ wl_protos = [
 | 
			
		||||
  'wlr-layer-shell-unstable-v1.xml',
 | 
			
		||||
  'virtual-keyboard-unstable-v1.xml',
 | 
			
		||||
  'input-method-unstable-v2.xml',
 | 
			
		||||
  'text-input-unstable-v3.xml'
 | 
			
		||||
]
 | 
			
		||||
wl_proto_sources = []
 | 
			
		||||
foreach proto: wl_protos
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,15 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void imservice_handle_text_change_cause(void *data, struct zwp_input_method_v2 *input_method, uint32_t cause) {}
 | 
			
		||||
void imservice_handle_content_type(void *data, struct zwp_input_method_v2 *input_method, uint32_t hint, uint32_t purpose) {}
 | 
			
		||||
 | 
			
		||||
void imservice_handle_content_type(void *data, struct zwp_input_method_v2 *input_method, uint32_t hint, uint32_t purpose)
 | 
			
		||||
{
 | 
			
		||||
    struct imservice *ims = (struct imservice*)data;
 | 
			
		||||
    EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(ims->ui_manager);
 | 
			
		||||
 | 
			
		||||
    eekboard_context_service_set_hint_purpose(context, hint, purpose);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void imservice_handle_unavailable(void *data, struct zwp_input_method_v2 *input_method) {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,8 +33,11 @@ struct imservice* get_imservice(EekboardContextService *context,
 | 
			
		||||
                                struct wl_seat *seat) {
 | 
			
		||||
    struct zwp_input_method_v2 *im = zwp_input_method_manager_v2_get_input_method(manager, seat);
 | 
			
		||||
    struct imservice *imservice = imservice_new(im, context);
 | 
			
		||||
    zwp_input_method_v2_add_listener(im,
 | 
			
		||||
        &input_method_listener, imservice);
 | 
			
		||||
 | 
			
		||||
    /* Add a listener, passing the imservice instance to make it available to
 | 
			
		||||
       callbacks. */
 | 
			
		||||
    zwp_input_method_v2_add_listener(im, &input_method_listener, imservice);
 | 
			
		||||
 | 
			
		||||
    return imservice;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,11 @@
 | 
			
		||||
#include "input-method-unstable-v2-client-protocol.h"
 | 
			
		||||
#include "eek/eek-types.h"
 | 
			
		||||
 | 
			
		||||
struct imservice;
 | 
			
		||||
struct imservice
 | 
			
		||||
{
 | 
			
		||||
    struct zwp_input_method_v2 *im;
 | 
			
		||||
    EekboardContextService *ui_manager;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct imservice* get_imservice(EekboardContextService *context,
 | 
			
		||||
                                struct zwp_input_method_manager_v2 *manager,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user