suggestion picker: a persistent layer to complement virtual keyboards like wvkbd
-rw-r--r--keyboard.c99
-rw-r--r--main.c16
-rw-r--r--proto/virtual-keyboard-unstable-v1.xml113
3 files changed, 2 insertions, 226 deletions
diff --git a/keyboard.c b/keyboard.c
index 3c77a4b..5a6471d 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -1,4 +1,3 @@
-#include "proto/virtual-keyboard-unstable-v1-client-protocol.h"
#include <linux/input-event-codes.h>
#include <stdio.h>
#include <sys/mman.h>
@@ -169,20 +168,6 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
bool unlatch_shift = false;
if (kb->last_press) {
- unlatch_shift = (kb->mods & Shift) == Shift;
-
- if (unlatch_shift) {
- kb->mods ^= Shift;
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
- }
-
- if (kb->last_press->type == Copy) {
- zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
- WL_KEYBOARD_KEY_STATE_RELEASED);
- } else {
- zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
- WL_KEYBOARD_KEY_STATE_RELEASED);
- }
if (kb->compose >= 2) {
kb->compose = 0;
@@ -245,20 +230,9 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
switch (k->type) {
case Code:
- if (k->code_mod) {
- if (k->reset_mod) {
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, k->code_mod, 0, 0, 0);
- } else {
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods ^ k->code_mod, 0,
- 0, 0);
- }
- } else {
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
- }
+
kb->last_swipe = kb->last_press = k;
kbd_draw_key(kb, k, Press);
- zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
- WL_KEYBOARD_KEY_STATE_PRESSED);
if (kb->print || kb->print_intersect)
kbd_print_key_stdout(kb, k);
if (kb->compose) {
@@ -267,72 +241,6 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
kb->compose++;
}
break;
- case Mod:
- kb->mods ^= k->code;
- if (k->code == Shift) {
- kbd_draw_layout(kb);
- }
- if (kb->mods & k->code) {
- kbd_draw_key(kb, k, Press);
- } else {
- kbd_draw_key(kb, k, Unpress);
- }
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
- break;
- case Layout:
- // switch to the layout determined by the key
- kbd_switch_layout(kb, k->layout);
- break;
- case Compose:
- // switch to the associated layout determined by the *next* keypress
- if (kb->compose == 0) {
- kb->compose = 1;
- } else {
- kb->compose = 0;
- }
- if ((bool)kb->compose) {
- kbd_draw_key(kb, k, Press);
- } else {
- kbd_draw_key(kb, k, Unpress);
- }
- break;
- case NextLayer:
- // switch to the next layout in the layer sequence
- kb->layer_index++;
- enum layout_id layer;
- if (kb->landscape) {
- layer = kb->landscape_layers[kb->layer_index];
- } else {
- layer = kb->layers[kb->layer_index];
- }
- if (layer == NumLayouts) {
- kb->layer_index = 0;
- if (kb->landscape) {
- layer = kb->landscape_layers[kb->layer_index];
- } else {
- layer = kb->layers[kb->layer_index];
- }
- }
- kbd_switch_layout(kb, &kb->layouts[layer]);
- break;
- case BackLayer:
- // switch to the previously active layout
- if (kb->prevlayout)
- kbd_switch_layout(kb, kb->prevlayout);
- break;
- case Copy:
- // copy code as unicode chr by setting a temporary keymap
- kb->last_swipe = kb->last_press = k;
- kbd_draw_key(kb, k, Press);
- if (kb->debug)
- fprintf(stderr, "pressing copy key\n");
- create_and_upload_keymap(kb, kb->layout->keymap_name, k->code, k->code_mod);
- zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
- zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
- WL_KEYBOARD_KEY_STATE_PRESSED);
- if (kb->print || kb->print_intersect)
- kbd_print_key_stdout(kb, k);
- break;
default:
break;
}
@@ -475,11 +383,6 @@ create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
if (ptr == (void *)-1) {
die("could not map keymap data\n");
}
- if (kb->vkbd == NULL) {
- die("kb.vkbd = NULL\n");
- }
strcpy(ptr, keymap_str);
- zwp_virtual_keyboard_v1_keymap(kb->vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
- keymap_fd, keymap_size);
free((void *)keymap_str);
}
diff --git a/main.c b/main.c
index 5eab410..6023693 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,3 @@
-#include "proto/virtual-keyboard-unstable-v1-client-protocol.h"
#include "proto/wlr-layer-shell-unstable-v1-client-protocol.h"
#include <linux/input-event-codes.h>
#include <stdio.h>
@@ -27,7 +26,6 @@ static struct wl_touch *touch;
static struct wl_output *wl_output;
static struct zwlr_layer_shell_v1 *layer_shell;
static struct zwlr_layer_surface_v1 *layer_surface;
-static struct zwp_virtual_keyboard_manager_v1 *vkbd_mgr;
/* drawing */
static struct drw draw_ctx;
@@ -312,10 +310,7 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name,
} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
layer_shell =
wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 1);
- } else if (strcmp(interface,
- zwp_virtual_keyboard_manager_v1_interface.name) == 0) {
- vkbd_mgr = wl_registry_bind(registry, name,
- &zwp_virtual_keyboard_manager_v1_interface, 1);
+
}
}
@@ -495,15 +490,6 @@ main(int argc, char **argv) {
if (layer_shell == NULL) {
die("layer_shell not available\n");
}
- if (vkbd_mgr == NULL) {
- die("virtual_keyboard_manager not available\n");
- }
-
- keyboard.vkbd =
- zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(vkbd_mgr, seat);
- if (keyboard.vkbd == NULL) {
- die("failed to init virtual keyboard_manager\n");
- }
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list);
diff --git a/proto/virtual-keyboard-unstable-v1.xml b/proto/virtual-keyboard-unstable-v1.xml
deleted file mode 100644
index 5095c91..0000000
--- a/proto/virtual-keyboard-unstable-v1.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="virtual_keyboard_unstable_v1">
- <copyright>
- Copyright © 2008-2011 Kristian Høgsberg
- Copyright © 2010-2013 Intel Corporation
- Copyright © 2012-2013 Collabora, Ltd.
- Copyright © 2018 Purism SPC
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice (including the next
- paragraph) shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
- </copyright>
-
- <interface name="zwp_virtual_keyboard_v1" version="1">
- <description summary="virtual keyboard">
- The virtual keyboard provides an application with requests which emulate
- the behaviour of a physical keyboard.
-
- This interface can be used by clients on its own to provide raw input
- events, or it can accompany the input method protocol.
- </description>
-
- <request name="keymap">
- <description summary="keyboard mapping">
- Provide a file descriptor to the compositor which can be
- memory-mapped to provide a keyboard mapping description.
-
- Format carries a value from the keymap_format enumeration.
- </description>
- <arg name="format" type="uint" summary="keymap format"/>
- <arg name="fd" type="fd" summary="keymap file descriptor"/>
- <arg name="size" type="uint" summary="keymap size, in bytes"/>
- </request>
-
- <enum name="error">
- <entry name="no_keymap" value="0" summary="No keymap was set"/>
- </enum>
-
- <request name="key">
- <description summary="key event">
- A key was pressed or released.
- The time argument is a timestamp with millisecond granularity, with an
- undefined base. All requests regarding a single object must share the
- same clock.
-
- Keymap must be set before issuing this request.
-
- State carries a value from the key_state enumeration.
- </description>
- <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
- <arg name="key" type="uint" summary="key that produced the event"/>
- <arg name="state" type="uint" summary="physical state of the key"/>
- </request>
-
- <request name="modifiers">
- <description summary="modifier and group state">
- Notifies the compositor that the modifier and/or group state has
- changed, and it should update state.
-
- The client should use wl_keyboard.modifiers event to synchronize its
- internal state with seat state.
-
- Keymap must be set before issuing this request.
- </description>
- <arg name="mods_depressed" type="uint" summary="depressed modifiers"/>
- <arg name="mods_latched" type="uint" summary="latched modifiers"/>
- <arg name="mods_locked" type="uint" summary="locked modifiers"/>
- <arg name="group" type="uint" summary="keyboard layout"/>
- </request>
-
- <request name="destroy" type="destructor" since="1">
- <description summary="destroy the virtual keyboard keyboard object"/>
- </request>
- </interface>
-
- <interface name="zwp_virtual_keyboard_manager_v1" version="1">
- <description summary="virtual keyboard manager">
- A virtual keyboard manager allows an application to provide keyboard
- input events as if they came from a physical keyboard.
- </description>
-
- <enum name="error">
- <entry name="unauthorized" value="0" summary="client not authorized to use the interface"/>
- </enum>
-
- <request name="create_virtual_keyboard">
- <description summary="Create a new virtual keyboard">
- Creates a new virtual keyboard associated to a seat.
-
- If the compositor enables a keyboard to perform arbitrary actions, it
- should present an error when an untrusted client requests a new
- keyboard.
- </description>
- <arg name="seat" type="object" interface="wl_seat"/>
- <arg name="id" type="new_id" interface="zwp_virtual_keyboard_v1"/>
- </request>
- </interface>
-</protocol>