key-emitter: Remove unused
This commit is contained in:
		@ -31,7 +31,6 @@
 | 
				
			|||||||
#include <glib/gprintf.h>
 | 
					#include <glib/gprintf.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "eekboard/eekboard-context-service.h"
 | 
					#include "eekboard/eekboard-context-service.h"
 | 
				
			||||||
#include "eekboard/key-emitter.h"
 | 
					 | 
				
			||||||
#include "keymap.h"
 | 
					#include "keymap.h"
 | 
				
			||||||
#include "eek-keyboard.h"
 | 
					#include "eek-keyboard.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <gio/gio.h>
 | 
					#include <gio/gio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "eekboard/key-emitter.h"
 | 
					 | 
				
			||||||
#include "wayland.h"
 | 
					#include "wayland.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "eek/eek-xml-layout.h"
 | 
					#include "eek/eek-xml-layout.h"
 | 
				
			||||||
@ -71,7 +70,7 @@ struct _EekboardContextServicePrivate {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    char *overlay;
 | 
					    char *overlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GSettings *settings;
 | 
					    GSettings *settings; // Owned reference
 | 
				
			||||||
    uint32_t hint;
 | 
					    uint32_t hint;
 | 
				
			||||||
    uint32_t purpose;
 | 
					    uint32_t purpose;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -46,6 +46,8 @@ typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * EekboardContextService:
 | 
					 * EekboardContextService:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
					 * Handles layout state, gsettings, and virtual-keyboard.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 * TODO: Restrict to managing keyboard layouts, and maybe button repeats,
 | 
					 * TODO: Restrict to managing keyboard layouts, and maybe button repeats,
 | 
				
			||||||
 * and the virtual keyboard protocol.
 | 
					 * and the virtual keyboard protocol.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
				
			|||||||
@ -1,136 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
 * Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
 | 
					 | 
				
			||||||
 * Copyright (C) 2011 Red Hat, Inc.
 | 
					 | 
				
			||||||
 * Copyright (C) 2019 Purism, SPC
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This program is free software: you can redistribute it and/or modify
 | 
					 | 
				
			||||||
 * it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
					 | 
				
			||||||
 * (at your option) any later version.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
 * GNU General Public License for more details.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * You should have received a copy of the GNU General Public License
 | 
					 | 
				
			||||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* This file is responsible for managing keycode data and emitting keycodes. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "eekboard/key-emitter.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <gdk/gdk.h>
 | 
					 | 
				
			||||||
#include <X11/XKBlib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "eekboard/eekboard-context-service.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO: decide whether it's this struct that carries the keyboard around in key-emitter or if the whole manager should be dragged around
 | 
					 | 
				
			||||||
// if this is the carrier, then it should be made part of the manager
 | 
					 | 
				
			||||||
// hint: check which fields need to be persisted between keypresses; which between keyboards
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
    struct zwp_virtual_keyboard_v1 *virtual_keyboard; // unowned copy
 | 
					 | 
				
			||||||
    struct xkb_keymap *keymap; // unowned copy
 | 
					 | 
				
			||||||
    XkbDescRec *xkb;
 | 
					 | 
				
			||||||
    guint modifier_keycodes[8];
 | 
					 | 
				
			||||||
    guint modifier_indices[MOD_IDX_LAST];
 | 
					 | 
				
			||||||
    guint group;
 | 
					 | 
				
			||||||
} SeatEmitter;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int send_virtual_keyboard_key(
 | 
					 | 
				
			||||||
    struct zwp_virtual_keyboard_v1 *keyboard,
 | 
					 | 
				
			||||||
    unsigned int keycode,
 | 
					 | 
				
			||||||
    unsigned is_press,
 | 
					 | 
				
			||||||
    uint32_t timestamp
 | 
					 | 
				
			||||||
) {
 | 
					 | 
				
			||||||
    zwp_virtual_keyboard_v1_key(keyboard, timestamp, keycode, (unsigned)is_press);
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Finds the first key code for each modifier and saves it in modifier_keycodes */
 | 
					 | 
				
			||||||
static void
 | 
					 | 
				
			||||||
update_modifier_info (SeatEmitter *client)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_SHIFT] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_SHIFT);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_CAPS] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_CAPS);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_CTRL] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_CTRL);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_ALT] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_ALT);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_NUM] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_NUM);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_MOD3] = xkb_keymap_mod_get_index(client->keymap, "Mod3");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_LOGO] = xkb_keymap_mod_get_index(client->keymap, XKB_MOD_NAME_LOGO);
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_ALTGR] = xkb_keymap_mod_get_index(client->keymap, "Mod5");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_NUMLK] = xkb_keymap_mod_get_index(client->keymap, "NumLock");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_ALSO_ALT] = xkb_keymap_mod_get_index(client->keymap, "Alt");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_LVL3] = xkb_keymap_mod_get_index(client->keymap, "LevelThree");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_LALT] = xkb_keymap_mod_get_index(client->keymap, "LAlt");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_RALT] = xkb_keymap_mod_get_index(client->keymap, "RAlt");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_RCONTROL] = xkb_keymap_mod_get_index(client->keymap, "RControl");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_LCONTROL] = xkb_keymap_mod_get_index(client->keymap, "LControl");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_SCROLLLK] = xkb_keymap_mod_get_index(client->keymap, "ScrollLock");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_LVL5] = xkb_keymap_mod_get_index(client->keymap, "LevelFive");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_ALSO_ALTGR] = xkb_keymap_mod_get_index(client->keymap, "AltGr");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_META] = xkb_keymap_mod_get_index(client->keymap, "Meta");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_SUPER] = xkb_keymap_mod_get_index(client->keymap, "Super");
 | 
					 | 
				
			||||||
    client->modifier_indices[MOD_IDX_HYPER] = xkb_keymap_mod_get_index(client->keymap, "Hyper");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
    for (xkb_mod_index_t i = 0;
 | 
					 | 
				
			||||||
         i < xkb_keymap_num_mods(client->keymap);
 | 
					 | 
				
			||||||
         i++) {
 | 
					 | 
				
			||||||
        g_log("squeek", G_LOG_LEVEL_DEBUG, "%s", xkb_keymap_mod_get_name(client->keymap, i));
 | 
					 | 
				
			||||||
    }*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void
 | 
					 | 
				
			||||||
send_fake_key (SeatEmitter *emitter,
 | 
					 | 
				
			||||||
               LevelKeyboard *keyboard,
 | 
					 | 
				
			||||||
               guint    keycode,
 | 
					 | 
				
			||||||
               gboolean pressed,
 | 
					 | 
				
			||||||
               uint32_t timestamp)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    zwp_virtual_keyboard_v1_modifiers(emitter->virtual_keyboard, 0, 0, 0, 0);
 | 
					 | 
				
			||||||
    send_virtual_keyboard_key (emitter->virtual_keyboard, keycode - 8, (unsigned)pressed, timestamp);
 | 
					 | 
				
			||||||
    zwp_virtual_keyboard_v1_modifiers(emitter->virtual_keyboard, 0, 0, 0, 0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
emit_key_activated (EekboardContextService *manager,
 | 
					 | 
				
			||||||
                    LevelKeyboard     *keyboard,
 | 
					 | 
				
			||||||
                    guint            keycode,
 | 
					 | 
				
			||||||
                    gboolean pressed,
 | 
					 | 
				
			||||||
                    uint32_t timestamp)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    /* FIXME: figure out how to deal with Client after key presses go through
 | 
					 | 
				
			||||||
    if (g_strcmp0 (eek_symbol_get_name (symbol), "cycle-keyboard") == 0) {
 | 
					 | 
				
			||||||
        client->keyboards_head = g_slist_next (client->keyboards_head);
 | 
					 | 
				
			||||||
        if (client->keyboards_head == NULL)
 | 
					 | 
				
			||||||
            client->keyboards_head = client->keyboards;
 | 
					 | 
				
			||||||
        eekboard_context_set_keyboard (client->context,
 | 
					 | 
				
			||||||
                                       GPOINTER_TO_UINT(client->keyboards_head->data),
 | 
					 | 
				
			||||||
                                       NULL);
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (g_strcmp0 (eek_symbol_get_name (symbol), "preferences") == 0) {
 | 
					 | 
				
			||||||
        gchar *argv[2];
 | 
					 | 
				
			||||||
        GError *error;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        argv[0] = g_build_filename (LIBEXECDIR, "eekboard-setup", NULL);
 | 
					 | 
				
			||||||
        argv[1] = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        error = NULL;
 | 
					 | 
				
			||||||
        if (!g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, &error)) {
 | 
					 | 
				
			||||||
            g_warning ("can't spawn %s: %s", argv[0], error->message);
 | 
					 | 
				
			||||||
            g_error_free (error);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        g_free (argv[0]);
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
    SeatEmitter emitter = {0};
 | 
					 | 
				
			||||||
    emitter.virtual_keyboard = manager->virtual_keyboard;
 | 
					 | 
				
			||||||
    update_modifier_info (&emitter);
 | 
					 | 
				
			||||||
    send_fake_key (&emitter, keyboard, keycode, pressed, timestamp);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,45 +0,0 @@
 | 
				
			|||||||
#ifndef KEYEMITTER_H
 | 
					 | 
				
			||||||
#define KEYEMITTER_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <inttypes.h>
 | 
					 | 
				
			||||||
#include <glib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "eek/eek.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "virtual-keyboard-unstable-v1-client-protocol.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Indices obtained by xkb_keymap_mod_get_name
 | 
					 | 
				
			||||||
enum mod_indices {
 | 
					 | 
				
			||||||
    MOD_IDX_SHIFT,
 | 
					 | 
				
			||||||
    MOD_IDX_CAPS,
 | 
					 | 
				
			||||||
    MOD_IDX_CTRL,
 | 
					 | 
				
			||||||
    MOD_IDX_ALT,
 | 
					 | 
				
			||||||
    MOD_IDX_NUM,
 | 
					 | 
				
			||||||
    MOD_IDX_MOD3,
 | 
					 | 
				
			||||||
    MOD_IDX_LOGO,
 | 
					 | 
				
			||||||
    MOD_IDX_ALTGR,
 | 
					 | 
				
			||||||
    MOD_IDX_NUMLK, // Caution, not sure which is the right one
 | 
					 | 
				
			||||||
    MOD_IDX_ALSO_ALT, // Not sure why, alt emits the first alt on my setup
 | 
					 | 
				
			||||||
    MOD_IDX_LVL3,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Not sure if the next 4 are used at all
 | 
					 | 
				
			||||||
    MOD_IDX_LALT,
 | 
					 | 
				
			||||||
    MOD_IDX_RALT,
 | 
					 | 
				
			||||||
    MOD_IDX_RCONTROL,
 | 
					 | 
				
			||||||
    MOD_IDX_LCONTROL,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    MOD_IDX_SCROLLLK,
 | 
					 | 
				
			||||||
    MOD_IDX_LVL5,
 | 
					 | 
				
			||||||
    MOD_IDX_ALSO_ALTGR, // Not used on my layout
 | 
					 | 
				
			||||||
    MOD_IDX_META,
 | 
					 | 
				
			||||||
    MOD_IDX_SUPER,
 | 
					 | 
				
			||||||
    MOD_IDX_HYPER,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    MOD_IDX_LAST,
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
emit_key_activated (EekboardContextService *manager, LevelKeyboard *keyboard,
 | 
					 | 
				
			||||||
                    guint            keycode,
 | 
					 | 
				
			||||||
                    gboolean pressed, uint32_t timestamp);
 | 
					 | 
				
			||||||
#endif // KEYEMITTER_H
 | 
					 | 
				
			||||||
@ -26,7 +26,6 @@ sources = [
 | 
				
			|||||||
  '../eek/eek-xml-layout.c',
 | 
					  '../eek/eek-xml-layout.c',
 | 
				
			||||||
  '../eek/layersurface.c',
 | 
					  '../eek/layersurface.c',
 | 
				
			||||||
  dbus_src,
 | 
					  dbus_src,
 | 
				
			||||||
  '../eekboard/key-emitter.c',
 | 
					 | 
				
			||||||
  '../eekboard/eekboard-context-service.c',
 | 
					  '../eekboard/eekboard-context-service.c',
 | 
				
			||||||
  #  '../eekboard/eekboard-xklutil.c',
 | 
					  #  '../eekboard/eekboard-xklutil.c',
 | 
				
			||||||
  squeekboard_resources,
 | 
					  squeekboard_resources,
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user