mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-15 05:19:54 +02:00
Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
eefd08f431 | |||
76b64f6a85 | |||
a152fd036f | |||
1a36f6d5f2 | |||
fbbf563d70 | |||
2747980a4e | |||
34d6ce5566 | |||
7af5410235 | |||
730e97038c | |||
50296daa46 | |||
21045044ba | |||
9e03e120c3 | |||
24e354ce9e | |||
b1890848d5 | |||
8bdc761d9b | |||
fa659b4584 | |||
3752d0e392 | |||
4444c6e664 | |||
8f7142b171 | |||
975bd2ec32 | |||
47a45d557b | |||
c45446a794 | |||
73130886cc | |||
67ef1d40f3 | |||
50c40863b8 | |||
d75d42aaa1 | |||
84020a9151 | |||
3504f83ca6 | |||
fda7007955 | |||
9687d839f9 | |||
dc7ee664f0 | |||
db44029d87 | |||
4ed89188d6 | |||
a573be707c | |||
dcca9e48c7 | |||
ca9b028795 | |||
29e32edf5c | |||
17863cdabc | |||
8c6baa800b | |||
81e5c01a22 | |||
bfcd3527dd | |||
0ca0409400 | |||
f402af96fa | |||
74695835ad | |||
46f4515477 | |||
6101db15b9 | |||
848e836713 | |||
8bffc1adc3 | |||
68ea69944d | |||
9134b0e8f6 | |||
f52345aaef | |||
048e25d660 | |||
2e476c6548 | |||
b6ec34fe3a | |||
79797fc837 | |||
83edf203a7 | |||
98e6c43d54 | |||
2d84f0e241 | |||
a2b5b78051 | |||
b32509163d | |||
8bdd7418a8 | |||
1f3e6f681f | |||
bcd0880dd5 | |||
031ec135d0 | |||
1577b2f742 | |||
9bbc8d4a99 | |||
dfae590264 | |||
7fe983af16 |
108
.clang-format
108
.clang-format
@ -1,107 +1,5 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
AlwaysBreakAfterDefinitionReturnType: All
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
BreakBeforeBraces: Linux
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 2
|
||||
UseTab: ForIndentation
|
||||
...
|
||||
|
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*.c]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ include/config.h
|
||||
*.log
|
||||
wvkbd
|
||||
config.h
|
||||
wvkbd-mobintl
|
||||
|
2
Makefile
2
Makefile
@ -24,7 +24,7 @@ OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: ${BIN}
|
||||
|
||||
config.h: config.def.h
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
|
||||
proto/%-client-protocol.c: proto/%.xml
|
||||
|
31
README.md
31
README.md
@ -17,7 +17,7 @@ new features.
|
||||
- Custom color schemes
|
||||
- Proper font drawing
|
||||
- Intuitive layouts
|
||||
- International layouts (cyrillic, arabic)
|
||||
- International layouts (cyrillic, arabic, persian, greek, georgian)
|
||||
- Support for 'Copy' keys which are not on the keymap
|
||||
- Emoji support
|
||||
- Compose key for character variants (e.g. diacritics)
|
||||
@ -55,10 +55,12 @@ the resulting binary will be `wvkbd-yourlayout`
|
||||
|
||||
Run `wvkbd-mobintl` (or the binary for your custom layout set).
|
||||
|
||||
You can switch between the layouts/layers of the keyboard by pressing the Abc/Sym key in the bottom-left. If you only
|
||||
want a subset of the available layers, you can define which wants you want and in what order you want to cycle through
|
||||
them using the `-l` parameter. This takes takes a ordered comma separated list of
|
||||
layout names that are defined in your layout set.
|
||||
You can switch between the layouts/layers of the keyboard by pressing the
|
||||
⌨ key (little keyboard) the bottom-left (press shift to iterate back instead of
|
||||
forward). If you only want a subset of the available layers, you can define
|
||||
which you want and in what order you want to cycle through them using the
|
||||
`-l` parameter (or `--landscape-layers` for landscape mode). This takes takes a ordered comma separated list of layout names
|
||||
that are defined in your layout set.
|
||||
|
||||
The keyboard can be hidden by sending it a `SIGUSR1` signal, shown again by sending it `SIGUSR2` or toggled by sending it `SIGRTMIN`.
|
||||
This saves some start up time and may be appropriate in some low-resource environments.
|
||||
@ -73,6 +75,25 @@ Another output mode, `-O` will let the keyboard output keys which are swiped ove
|
||||
|
||||
`$ wvkbd-mobintl -O | swipeGuess.sh words.txt | completelyTypeWord.sh`
|
||||
|
||||
### Compose button
|
||||
|
||||
The default mobile international layout features a Compose button (`Cmp`)
|
||||
which, when combined with another key, opens up a layout that offers variants
|
||||
for that key. This is similar to functionality that other keyboards implemented
|
||||
using a *long press* (wvkbd has no such notion, holding a key will repeat
|
||||
it like on a physical keyboard).
|
||||
|
||||
For example, press Cmp + a to access variants with diacritics like á,à,â,ä, etc..
|
||||
|
||||
Most layouts also feature the following that are less obvious:
|
||||
|
||||
* Press Cmp + ``.`` to access more punctuation
|
||||
* Press Cmp + ``-`` or ``,`` to access 'mathematical' symbols (+,-,=,etc)
|
||||
* Press Cmp + ``'`` or ``0`` or ``9`` to access more brackets and quotes
|
||||
* Press Cmp + ``q`` to access emojis
|
||||
|
||||
Last, but not least, pressing Cmp + space or Cmp + ⌨ or Cmp + Abc opens up an index that allows you to immediately jump to any
|
||||
layout by name, even layouts not explicitly added to your layers on startup.
|
||||
|
||||
## Contribute
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef config_def_h_INCLUDED
|
||||
#define config_def_h_INCLUDED
|
||||
|
||||
static const char *default_font = "Monospace 14";
|
||||
static const int transparency = 225;
|
||||
static const char *default_font = "Sans 14";
|
||||
static const int transparency = 255;
|
||||
|
||||
struct clr_scheme scheme = {
|
||||
/* colors */
|
||||
@ -24,15 +24,14 @@ struct clr_scheme scheme1 = {
|
||||
/* layers is an ordered list of layouts, used to cycle through */
|
||||
static enum layout_id layers[] = {
|
||||
Full, // First layout is the default layout on startup
|
||||
Special, Emoji, Simple, SimpleGrid, Nav, Dialer,
|
||||
Cyrillic, Arabic, Persian, Greek, Georgian,
|
||||
Special,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
/* layers is an ordered list of layouts, used to cycle through */
|
||||
static enum layout_id landscape_layers[] = {
|
||||
Landscape, // First layout is the default layout on startup
|
||||
Special, Emoji, Nav, Greek,
|
||||
LandscapeSpecial,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
VERSION = 0.10
|
||||
VERSION = 0.14
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 359 KiB |
Binary file not shown.
Before Width: | Height: | Size: 215 KiB After Width: | Height: | Size: 429 KiB |
58
drw.c
58
drw.c
@ -6,7 +6,8 @@
|
||||
#include "shm_open.h"
|
||||
|
||||
void
|
||||
drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s) {
|
||||
drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
|
||||
{
|
||||
if (ds->buf) {
|
||||
munmap(ds->pool_data, ds->size);
|
||||
wl_buffer_destroy(ds->buf);
|
||||
@ -21,38 +22,53 @@ drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s) {
|
||||
}
|
||||
|
||||
void
|
||||
drwsurf_flip(struct drwsurf *ds) {
|
||||
drwsurf_flip(struct drwsurf *ds)
|
||||
{
|
||||
wl_surface_attach(ds->surf, ds->buf, 0, 0);
|
||||
wl_surface_commit(ds->surf);
|
||||
}
|
||||
|
||||
void
|
||||
drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, const char *label) {
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label)
|
||||
{
|
||||
|
||||
cairo_save(d->cairo);
|
||||
|
||||
cairo_set_source_rgba(
|
||||
d->cairo, color.bgra[2] / (double)255, color.bgra[1] / (double)255,
|
||||
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
||||
cairo_move_to(d->cairo, x + (double)w / 2.0, y + (double)h / 2.0);
|
||||
cairo_move_to(d->cairo, x + w / 2, y + h / 2);
|
||||
|
||||
pango_layout_set_text(d->layout, label, -1);
|
||||
pango_layout_set_width(d->layout, (w - (b * 2)) * PANGO_SCALE);
|
||||
pango_layout_set_height(d->layout, (h - (b * 2)) * PANGO_SCALE);
|
||||
|
||||
int width, height;
|
||||
pango_layout_get_size(d->layout, &width, &height);
|
||||
pango_layout_get_pixel_size(d->layout, &width, &height);
|
||||
|
||||
cairo_rel_move_to(d->cairo, -width / 2, -height / 2);
|
||||
|
||||
cairo_rel_move_to(d->cairo, -((double)width / PANGO_SCALE) / 2,
|
||||
-((double)height / PANGO_SCALE) / 2);
|
||||
pango_cairo_show_layout(d->cairo, d->layout);
|
||||
cairo_restore(d->cairo);
|
||||
}
|
||||
|
||||
wl_surface_damage(d->surf, x, y, w, h);
|
||||
void
|
||||
drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||
{
|
||||
cairo_save(d->cairo);
|
||||
|
||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_rectangle(d->cairo, x, y, w, h);
|
||||
cairo_fill(d->cairo);
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
}
|
||||
|
||||
void
|
||||
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool over) {
|
||||
uint32_t w, uint32_t h, bool over)
|
||||
{
|
||||
cairo_save(d->cairo);
|
||||
|
||||
if (over) {
|
||||
@ -68,24 +84,25 @@ drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
cairo_fill(d->cairo);
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
|
||||
wl_surface_damage(d->surf, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h) {
|
||||
uint32_t w, uint32_t h)
|
||||
{
|
||||
drw_do_rectangle(d, color, x, y, w, h, false);
|
||||
}
|
||||
|
||||
void
|
||||
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h) {
|
||||
uint32_t w, uint32_t h)
|
||||
{
|
||||
drw_do_rectangle(d, color, x, y, w, h, true);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
setup_buffer(struct drwsurf *drwsurf) {
|
||||
setup_buffer(struct drwsurf *drwsurf)
|
||||
{
|
||||
int stride = drwsurf->width * 4;
|
||||
drwsurf->size = stride * drwsurf->height;
|
||||
|
||||
@ -103,23 +120,24 @@ setup_buffer(struct drwsurf *drwsurf) {
|
||||
|
||||
struct wl_shm_pool *pool =
|
||||
wl_shm_create_pool(drwsurf->ctx->shm, fd, drwsurf->size);
|
||||
drwsurf->buf = wl_shm_pool_create_buffer(
|
||||
pool, 0, drwsurf->width, drwsurf->height, stride, WL_SHM_FORMAT_ARGB8888);
|
||||
drwsurf->buf =
|
||||
wl_shm_pool_create_buffer(pool, 0, drwsurf->width, drwsurf->height,
|
||||
stride, WL_SHM_FORMAT_ARGB8888);
|
||||
wl_shm_pool_destroy(pool);
|
||||
close(fd);
|
||||
|
||||
cairo_surface_t *s = cairo_image_surface_create_for_data(
|
||||
drwsurf->pool_data, CAIRO_FORMAT_ARGB32, drwsurf->width, drwsurf->height,
|
||||
stride);
|
||||
drwsurf->pool_data, CAIRO_FORMAT_ARGB32, drwsurf->width,
|
||||
drwsurf->height, stride);
|
||||
|
||||
drwsurf->cairo = cairo_create(s);
|
||||
cairo_scale(drwsurf->cairo, drwsurf->scale, drwsurf->scale);
|
||||
cairo_set_antialias(drwsurf->cairo, CAIRO_ANTIALIAS_NONE);
|
||||
drwsurf->layout = pango_cairo_create_layout(drwsurf->cairo);
|
||||
pango_layout_set_font_description(drwsurf->layout,
|
||||
drwsurf->ctx->font_description);
|
||||
pango_layout_set_auto_dir(drwsurf->layout, false);
|
||||
cairo_save(drwsurf->cairo);
|
||||
|
||||
wl_surface_set_buffer_scale(drwsurf->surf, drwsurf->scale);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
9
drw.h
9
drw.h
@ -9,7 +9,8 @@ struct drw {
|
||||
PangoFontDescription *font_description;
|
||||
};
|
||||
struct drwsurf {
|
||||
uint32_t width, height, scale, size;
|
||||
uint32_t width, height, size;
|
||||
double scale;
|
||||
|
||||
struct drw *ctx;
|
||||
struct wl_surface *surf;
|
||||
@ -22,7 +23,7 @@ struct drwsurf {
|
||||
};
|
||||
struct kbd;
|
||||
|
||||
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s);
|
||||
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s);
|
||||
void drwsurf_flip(struct drwsurf *ds);
|
||||
|
||||
typedef union {
|
||||
@ -30,6 +31,8 @@ typedef union {
|
||||
uint32_t color;
|
||||
} Color;
|
||||
|
||||
void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool fill);
|
||||
void drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
@ -38,7 +41,7 @@ void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
|
||||
void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, const char *label);
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label);
|
||||
|
||||
uint32_t setup_buffer(struct drwsurf *drwsurf);
|
||||
|
||||
|
401
keyboard.c
401
keyboard.c
@ -1,5 +1,6 @@
|
||||
#include "proto/virtual-keyboard-unstable-v1-client-protocol.h"
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include "keyboard.h"
|
||||
@ -19,11 +20,20 @@
|
||||
#include KEYMAP
|
||||
|
||||
void
|
||||
kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
||||
kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index)
|
||||
{
|
||||
kb->prevlayout = kb->layout;
|
||||
if ((kb->layer_index != kb->last_abc_index) && (kb->layout->abc)) {
|
||||
kb->last_abc_layout = kb->layout;
|
||||
kb->last_abc_index = kb->layer_index;
|
||||
}
|
||||
kb->layer_index = layer_index;
|
||||
kb->layout = l;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Switching to layout %s)\n", kb->layout->name);
|
||||
fprintf(stderr, "Switching to layout %s, layer_index %ld\n",
|
||||
kb->layout->name, layer_index);
|
||||
if (!l->keymap_name)
|
||||
fprintf(stderr, "Layout has no keymap!"); // sanity check
|
||||
if ((!kb->prevlayout) ||
|
||||
(strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
|
||||
fprintf(stderr, "Switching to keymap %s\n", kb->layout->keymap_name);
|
||||
@ -32,8 +42,70 @@ kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
||||
kbd_draw_layout(kb);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_next_layer(struct kbd *kb, struct key *k, bool invert)
|
||||
{
|
||||
size_t layer_index = kb->layer_index;
|
||||
if ((kb->mods & Ctrl) || (kb->mods & Alt) || (kb->mods & AltGr) ||
|
||||
((bool)kb->compose)) {
|
||||
// with modifiers ctrl/alt/altgr: switch to the first layer
|
||||
layer_index = 0;
|
||||
kb->mods = 0;
|
||||
} else if ((kb->mods & Shift) || (kb->mods & CapsLock) || (invert)) {
|
||||
// with modifiers shift/capslock or invert set: switch to the previous
|
||||
// layout in the layer sequence
|
||||
if (layer_index > 0) {
|
||||
layer_index--;
|
||||
} else {
|
||||
size_t layercount = 0;
|
||||
for (size_t i = 0; layercount == 0; i++) {
|
||||
if (kb->landscape) {
|
||||
if (kb->landscape_layers[i] == NumLayouts)
|
||||
layercount = i;
|
||||
} else {
|
||||
if (kb->layers[i] == NumLayouts)
|
||||
layercount = i;
|
||||
}
|
||||
}
|
||||
layer_index = layercount - 1;
|
||||
}
|
||||
if (!invert)
|
||||
kb->mods ^= Shift;
|
||||
} else {
|
||||
// normal behaviour: switch to the next layout in the layer sequence
|
||||
layer_index++;
|
||||
}
|
||||
size_t layercount = 0;
|
||||
for (size_t i = 0; layercount == 0; i++) {
|
||||
if (kb->landscape) {
|
||||
if (kb->landscape_layers[i] == NumLayouts)
|
||||
layercount = i;
|
||||
} else {
|
||||
if (kb->layers[i] == NumLayouts)
|
||||
layercount = i;
|
||||
}
|
||||
}
|
||||
if (layer_index >= layercount) {
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "wrapping layer_index back to start\n");
|
||||
layer_index = 0;
|
||||
}
|
||||
enum layout_id layer;
|
||||
if (kb->landscape) {
|
||||
layer = kb->landscape_layers[layer_index];
|
||||
} else {
|
||||
layer = kb->layers[layer_index];
|
||||
}
|
||||
if (((bool)kb->compose) && (k)) {
|
||||
kb->compose = 0;
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
kbd_switch_layout(kb, &kb->layouts[layer], layer_index);
|
||||
}
|
||||
|
||||
uint8_t
|
||||
kbd_get_rows(struct layout *l) {
|
||||
kbd_get_rows(struct layout *l)
|
||||
{
|
||||
uint8_t rows = 0;
|
||||
struct key *k = l->keys;
|
||||
while (k->type != Last) {
|
||||
@ -45,25 +117,16 @@ kbd_get_rows(struct layout *l) {
|
||||
return rows + 1;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
enum layout_id *
|
||||
kbd_init_layers(char *layer_names_list)
|
||||
{
|
||||
enum layout_id *layers;
|
||||
uint8_t numlayers = 0;
|
||||
bool found;
|
||||
char *s;
|
||||
int i;
|
||||
bool found;
|
||||
|
||||
fprintf(stderr, "Initializing keyboard\n");
|
||||
|
||||
kb->layouts = layouts;
|
||||
|
||||
for (i = 0; i < NumLayouts - 1; i++)
|
||||
;
|
||||
fprintf(stderr, "Found %d layouts\n", i);
|
||||
|
||||
kb->layer_index = 0;
|
||||
|
||||
if (layer_names_list) {
|
||||
uint8_t numlayers = 0;
|
||||
kb->layers = malloc(MAX_LAYERS * sizeof(enum layout_id));
|
||||
layers = malloc(MAX_LAYERS * sizeof(enum layout_id));
|
||||
s = strtok(layer_names_list, ",");
|
||||
while (s != NULL) {
|
||||
if (numlayers + 1 == MAX_LAYERS) {
|
||||
@ -72,9 +135,9 @@ kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
}
|
||||
found = false;
|
||||
for (i = 0; i < NumLayouts - 1; i++) {
|
||||
if (kb->layouts[i].name && strcmp(kb->layouts[i].name, s) == 0) {
|
||||
if (layouts[i].name && strcmp(layouts[i].name, s) == 0) {
|
||||
fprintf(stderr, "layer #%d = %s\n", numlayers + 1, s);
|
||||
kb->layers[numlayers++] = i;
|
||||
layers[numlayers++] = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@ -85,13 +148,37 @@ kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
}
|
||||
s = strtok(NULL, ",");
|
||||
}
|
||||
kb->layers[numlayers] = NumLayouts; // mark the end of the sequence
|
||||
layers[numlayers] = NumLayouts; // mark the end of the sequence
|
||||
if (numlayers == 0) {
|
||||
fprintf(stderr, "No layers defined\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
return layers;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list,
|
||||
char *landscape_layer_names_list)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "Initializing keyboard\n");
|
||||
|
||||
kb->layouts = layouts;
|
||||
|
||||
for (i = 0; i < NumLayouts - 1; i++)
|
||||
;
|
||||
fprintf(stderr, "Found %d layouts\n", i);
|
||||
|
||||
kb->layer_index = 0;
|
||||
kb->last_abc_index = 0;
|
||||
|
||||
if (layer_names_list)
|
||||
kb->layers = kbd_init_layers(layer_names_list);
|
||||
if (landscape_layer_names_list)
|
||||
kb->landscape_layers = kbd_init_layers(landscape_layer_names_list);
|
||||
|
||||
i = 0;
|
||||
enum layout_id lid = kb->layers[0];
|
||||
while (lid != NumLayouts) {
|
||||
@ -107,14 +194,15 @@ kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
}
|
||||
|
||||
kb->layout = &kb->layouts[layer];
|
||||
kb->prevlayout = kb->layout;
|
||||
kb->last_abc_layout = &kb->layouts[layer];
|
||||
|
||||
/* upload keymap */
|
||||
create_and_upload_keymap(kb, kb->layout->keymap_name, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
|
||||
kbd_init_layout(struct layout *l, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t x = 0, y = 0;
|
||||
uint8_t rows = kbd_get_rows(l);
|
||||
|
||||
@ -146,7 +234,8 @@ kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
|
||||
}
|
||||
|
||||
double
|
||||
kbd_get_row_length(struct key *k) {
|
||||
kbd_get_row_length(struct key *k)
|
||||
{
|
||||
double l = 0.0;
|
||||
while ((k->type != Last) && (k->type != EndRow)) {
|
||||
l += k->width;
|
||||
@ -156,14 +245,16 @@ kbd_get_row_length(struct key *k) {
|
||||
}
|
||||
|
||||
struct key *
|
||||
kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
|
||||
kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y)
|
||||
{
|
||||
struct layout *l = kb->layout;
|
||||
struct key *k = l->keys;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "get key: +%d+%d\n", x, y);
|
||||
while (k->type != Last) {
|
||||
if ((k->type != EndRow) && (k->type != Pad) && (k->type != Pad) &&
|
||||
(x >= k->x) && (y >= k->y) && (x < k->x + k->w) && (y < k->y + k->h)) {
|
||||
(x >= k->x) && (y >= k->y) && (x < k->x + k->w) &&
|
||||
(y < k->y + k->h)) {
|
||||
return k;
|
||||
}
|
||||
k++;
|
||||
@ -171,8 +262,20 @@ kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t
|
||||
kbd_get_layer_index(struct kbd *kb, struct layout *l)
|
||||
{
|
||||
for (size_t i = 0; i < NumLayouts - 1; i++) {
|
||||
if (l == &kb->layouts[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_unpress_key(struct kbd *kb, uint32_t time) {
|
||||
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||
{
|
||||
bool unlatch_shift = false;
|
||||
|
||||
if (kb->last_press) {
|
||||
@ -187,13 +290,20 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
|
||||
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,
|
||||
if ((kb->last_press->code == KEY_SPACE) && (unlatch_shift)) {
|
||||
// shift + space is tab
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, KEY_TAB,
|
||||
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;
|
||||
kbd_switch_layout(kb, kb->prevlayout);
|
||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||
} else if (unlatch_shift) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
@ -205,7 +315,8 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
|
||||
}
|
||||
|
||||
void
|
||||
kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
kbd_release_key(struct kbd *kb, uint32_t time)
|
||||
{
|
||||
kbd_unpress_key(kb, time);
|
||||
if (kb->print_intersect && kb->last_swipe) {
|
||||
printf("\n");
|
||||
@ -216,10 +327,14 @@ kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
|
||||
kbd_clear_last_popup(kb);
|
||||
drwsurf_flip(kb->popup_surf);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y)
|
||||
{
|
||||
// Output intersecting keys
|
||||
// (for external 'swiping'-based accelerators).
|
||||
if (kb->print_intersect) {
|
||||
@ -230,8 +345,8 @@ kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
}
|
||||
struct key *intersect_key;
|
||||
intersect_key = kbd_get_key(kb, x, y);
|
||||
if (intersect_key &&
|
||||
(!kb->last_swipe || intersect_key->label != kb->last_swipe->label)) {
|
||||
if (intersect_key && (!kb->last_swipe ||
|
||||
intersect_key->label != kb->last_swipe->label)) {
|
||||
kbd_print_key_stdout(kb, intersect_key);
|
||||
kb->last_swipe = intersect_key;
|
||||
kbd_draw_key(kb, kb->last_swipe, Swipe);
|
||||
@ -241,35 +356,58 @@ kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
|
||||
kbd_clear_last_popup(kb);
|
||||
drwsurf_flip(kb->popup_surf);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
||||
(k->type != NextLayer) && (k->layout)) {
|
||||
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
|
||||
{
|
||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod)) {
|
||||
if ((k->type == NextLayer) || (k->type == BackLayer) ||
|
||||
((k->type == Code) && (k->code == KEY_SPACE))) {
|
||||
kb->compose = 0;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "showing layout index\n");
|
||||
kbd_switch_layout(kb, &kb->layouts[Index], 0);
|
||||
return;
|
||||
} else if (k->layout) {
|
||||
kb->compose++;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "showing compose %d\n", kb->compose);
|
||||
kbd_switch_layout(kb, k->layout);
|
||||
kbd_switch_layout(kb, k->layout,
|
||||
kbd_get_layer_index(kb, k->layout));
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
if ((k->code == KEY_SPACE) && (kb->mods & Shift)) {
|
||||
// shift space is tab
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, 0, 0, 0, 0);
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, KEY_TAB,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
} else {
|
||||
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) {
|
||||
@ -282,17 +420,26 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
kb->mods ^= k->code;
|
||||
if (k->code == Shift) {
|
||||
kbd_draw_layout(kb);
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
kbd_switch_layout(kb, k->layout, kbd_get_layer_index(kb, k->layout));
|
||||
// reset previous layout to default/first so we don't get any weird
|
||||
// cycles
|
||||
kb->last_abc_index = 0;
|
||||
if (kb->landscape) {
|
||||
kb->last_abc_layout = &kb->layouts[kb->landscape_layers[0]];
|
||||
} else {
|
||||
kb->last_abc_layout = &kb->layouts[kb->layers[0]];
|
||||
}
|
||||
break;
|
||||
case Compose:
|
||||
// switch to the associated layout determined by the *next* keypress
|
||||
@ -307,55 +454,24 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
break;
|
||||
case NextLayer:
|
||||
if ((kb->mods & Ctrl) || (kb->mods & Alt) || (kb->mods & AltGr) || ((bool)kb->compose)) {
|
||||
// with modifiers: switch to the first layer
|
||||
kb->layer_index = 0;
|
||||
kb->mods = 0;
|
||||
} else if ((kb->mods & Shift) || (kb->mods & CapsLock)) {
|
||||
// with modifiers: switch to the previous layout in the layer sequence
|
||||
if (kb->layer_index > 0) {
|
||||
kb->layer_index--;
|
||||
} else {
|
||||
size_t layercount = 0;
|
||||
for (size_t i = 0; layercount == 0; i++) {
|
||||
if (kb->landscape) {
|
||||
if (kb->landscape_layers[i] == NumLayouts) layercount = i;
|
||||
} else {
|
||||
if (kb->layers[i] == NumLayouts) layercount = i;
|
||||
}
|
||||
}
|
||||
kb->layer_index = layercount - 1;
|
||||
}
|
||||
kb->mods = 0;
|
||||
} else {
|
||||
// normal behaviour: 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];
|
||||
}
|
||||
}
|
||||
if ((bool)kb->compose) {
|
||||
kb->compose = 0;
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
kbd_switch_layout(kb, &kb->layouts[layer]);
|
||||
case NextLayer: //(also handles previous layer when shift modifier is on, or
|
||||
//"first layer" with other modifiers)
|
||||
kbd_next_layer(kb, k, false);
|
||||
break;
|
||||
case BackLayer:
|
||||
// switch to the previously active layout
|
||||
if (kb->prevlayout)
|
||||
kbd_switch_layout(kb, kb->prevlayout);
|
||||
case BackLayer: // triggered when "Abc" keys are pressed
|
||||
// switch to the last active alphabetical layout
|
||||
if (kb->last_abc_layout) {
|
||||
kb->compose = 0;
|
||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||
// reset previous layout to default/first so we don't get any weird
|
||||
// cycles
|
||||
kb->last_abc_index = 0;
|
||||
if (kb->landscape) {
|
||||
kb->last_abc_layout = &kb->layouts[kb->landscape_layers[0]];
|
||||
} else {
|
||||
kb->last_abc_layout = &kb->layouts[kb->layers[0]];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Copy:
|
||||
// copy code as unicode chr by setting a temporary keymap
|
||||
@ -363,7 +479,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
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);
|
||||
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);
|
||||
@ -375,10 +492,12 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
drwsurf_flip(kb->popup_surf);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_print_key_stdout(struct kbd *kb, struct key *k) {
|
||||
kbd_print_key_stdout(struct kbd *kb, struct key *k)
|
||||
{
|
||||
/* printed keys may slightly differ from the actual output
|
||||
* we generally print what is on the key LABEL and only support the normal
|
||||
* and shift layers. Other modifiers produce no output (Ctrl,Alt)
|
||||
@ -417,33 +536,74 @@ kbd_print_key_stdout(struct kbd *kb, struct key *k) {
|
||||
}
|
||||
|
||||
void
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) {
|
||||
struct drwsurf *d = kb->surf;
|
||||
kbd_clear_last_popup(struct kbd *kb)
|
||||
{
|
||||
if (kb->last_popup_w && kb->last_popup_h) {
|
||||
drw_do_clear(kb->popup_surf, kb->last_popup_x, kb->last_popup_y,
|
||||
kb->last_popup_w, kb->last_popup_h);
|
||||
wl_surface_damage(kb->popup_surf->surf, kb->last_popup_x,
|
||||
kb->last_popup_y, kb->last_popup_w, kb->last_popup_h);
|
||||
|
||||
kb->last_popup_w = kb->last_popup_h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
{
|
||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||
label);
|
||||
struct clr_scheme *scheme = (k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
||||
struct clr_scheme *scheme =
|
||||
(k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
||||
|
||||
switch (type) {
|
||||
case None:
|
||||
case Unpress:
|
||||
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->fg);
|
||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->fg);
|
||||
break;
|
||||
case Press:
|
||||
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->high);
|
||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->high);
|
||||
break;
|
||||
case Swipe:
|
||||
draw_over_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->swipe);
|
||||
draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->swipe);
|
||||
break;
|
||||
}
|
||||
drw_draw_text(d, scheme->text, k->x, k->y, k->w, k->h, label);
|
||||
|
||||
drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h,
|
||||
KBD_KEY_BORDER, label);
|
||||
wl_surface_damage(kb->surf->surf, k->x, k->y, k->w, k->h);
|
||||
|
||||
if (type == Press || type == Unpress) {
|
||||
kbd_clear_last_popup(kb);
|
||||
|
||||
kb->last_popup_x = k->x;
|
||||
kb->last_popup_y = kb->h + k->y - k->h;
|
||||
kb->last_popup_w = k->w;
|
||||
kb->last_popup_h = k->h;
|
||||
|
||||
drw_fill_rectangle(kb->popup_surf, kb->scheme.bg, k->x,
|
||||
kb->last_popup_y, k->w, k->h);
|
||||
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
|
||||
KBD_KEY_BORDER, scheme->high);
|
||||
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
|
||||
k->w, k->h, KBD_KEY_BORDER, label);
|
||||
wl_surface_damage(kb->popup_surf->surf, k->x, kb->last_popup_y, k->w,
|
||||
k->h);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kbd_draw_layout(struct kbd *kb) {
|
||||
kbd_draw_layout(struct kbd *kb)
|
||||
{
|
||||
struct drwsurf *d = kb->surf;
|
||||
struct key *next_key = kb->layout->keys;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw layout");
|
||||
fprintf(stderr, "Draw layout\n");
|
||||
|
||||
drw_fill_rectangle(d, kb->scheme.bg, 0, 0, kb->w, kb->h);
|
||||
|
||||
@ -456,21 +616,30 @@ kbd_draw_layout(struct kbd *kb) {
|
||||
(next_key->type == Compose && kb->compose)) {
|
||||
kbd_draw_key(kb, next_key, Press);
|
||||
} else {
|
||||
kbd_draw_key(kb, next_key, Unpress);
|
||||
kbd_draw_key(kb, next_key, None);
|
||||
}
|
||||
next_key++;
|
||||
}
|
||||
wl_surface_damage(d->surf, 0, 0, kb->w, kb->h);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
|
||||
struct drwsurf *d = kb->surf;
|
||||
|
||||
fprintf(stderr, "Resize %dx%d %d, %d layouts\n", kb->w, kb->h, kb->s,
|
||||
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount)
|
||||
{
|
||||
fprintf(stderr, "Resize %dx%d %f, %d layouts\n", kb->w, kb->h, kb->scale,
|
||||
layoutcount);
|
||||
|
||||
drwsurf_resize(d, kb->w, kb->h, kb->s);
|
||||
drwsurf_resize(kb->surf, kb->w, kb->h, kb->scale);
|
||||
drwsurf_resize(kb->popup_surf, kb->w, kb->h * 2, kb->scale);
|
||||
for (int i = 0; i < layoutcount; i++) {
|
||||
if (kb->debug) {
|
||||
if (layouts[i].name)
|
||||
fprintf(stderr, "Initialising layout %s, keymap %s\n",
|
||||
layouts[i].name, layouts[i].keymap_name);
|
||||
else
|
||||
fprintf(stderr, "Initialising unnamed layout %d, keymap %s\n",
|
||||
i, layouts[i].keymap_name);
|
||||
}
|
||||
kbd_init_layout(&layouts[i], kb->w, kb->h);
|
||||
}
|
||||
kbd_draw_layout(kb);
|
||||
@ -478,20 +647,23 @@ kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
|
||||
|
||||
void
|
||||
draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color) {
|
||||
uint32_t height, uint32_t border, Color color)
|
||||
{
|
||||
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
}
|
||||
void
|
||||
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color) {
|
||||
uint32_t height, uint32_t border, Color color)
|
||||
{
|
||||
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
}
|
||||
|
||||
void
|
||||
create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
||||
uint32_t comp_shift_unichr) {
|
||||
uint32_t comp_shift_unichr)
|
||||
{
|
||||
int keymap_index = -1;
|
||||
for (int i = 0; i < NUMKEYMAPS; i++) {
|
||||
if (!strcmp(keymap_names[i], name)) {
|
||||
@ -503,15 +675,16 @@ create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
||||
exit(9);
|
||||
}
|
||||
const char *keymap_template = keymaps[keymap_index];
|
||||
const size_t keymap_size = strlen(keymap_template) + 64;
|
||||
size_t keymap_size = strlen(keymap_template) + 64;
|
||||
char *keymap_str = malloc(keymap_size);
|
||||
sprintf(keymap_str, keymap_template, comp_unichr, comp_shift_unichr);
|
||||
keymap_size = strlen(keymap_str);
|
||||
int keymap_fd = os_create_anonymous_file(keymap_size);
|
||||
if (keymap_fd < 0) {
|
||||
die("could not create keymap fd\n");
|
||||
}
|
||||
void *ptr =
|
||||
mmap(NULL, keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, keymap_fd, 0);
|
||||
void *ptr = mmap(NULL, keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
keymap_fd, 0);
|
||||
if (ptr == (void *)-1) {
|
||||
die("could not map keymap data\n");
|
||||
}
|
||||
|
22
keyboard.h
22
keyboard.h
@ -42,7 +42,8 @@ enum key_modifier_type {
|
||||
};
|
||||
|
||||
enum key_draw_type {
|
||||
Unpress = 0,
|
||||
None = 0,
|
||||
Unpress,
|
||||
Press,
|
||||
Swipe,
|
||||
};
|
||||
@ -81,6 +82,7 @@ struct layout {
|
||||
struct key *keys;
|
||||
const char *keymap_name;
|
||||
const char *name;
|
||||
bool abc; //is this an alphabetical/abjad layout or not? (i.e. something that is a primary input layout)
|
||||
uint32_t keyheight; // absolute height (pixels)
|
||||
};
|
||||
|
||||
@ -93,21 +95,27 @@ struct kbd {
|
||||
|
||||
bool print;
|
||||
bool print_intersect;
|
||||
uint32_t w, h, s;
|
||||
uint32_t w, h;
|
||||
double scale, pending_scale;
|
||||
bool landscape;
|
||||
uint8_t mods;
|
||||
uint8_t compose;
|
||||
struct key *last_press;
|
||||
struct key *last_swipe;
|
||||
struct layout *prevlayout;
|
||||
struct layout *prevlayout; //the previous layout, needed to keep track of keymap changes
|
||||
size_t layer_index;
|
||||
struct layout *last_abc_layout; //the last alphabetical layout to fall back to (may be further away than prevlayout)
|
||||
size_t last_abc_index; //the layer index of the last alphabetical layout
|
||||
|
||||
struct layout *layouts;
|
||||
enum layout_id *layers;
|
||||
enum layout_id *landscape_layers;
|
||||
|
||||
struct drwsurf *surf;
|
||||
struct drwsurf *popup_surf;
|
||||
struct zwp_virtual_keyboard_v1 *vkbd;
|
||||
|
||||
uint32_t last_popup_x, last_popup_y, last_popup_w, last_popup_h;
|
||||
};
|
||||
|
||||
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
@ -115,20 +123,24 @@ void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color);
|
||||
|
||||
void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list);
|
||||
void kbd_init(struct kbd *kb, struct layout *layouts,
|
||||
char *layer_names_list, char *landscape_layer_names_list);
|
||||
void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height);
|
||||
struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y);
|
||||
size_t kbd_get_layer_index(struct kbd *kb, struct layout *l);
|
||||
void kbd_unpress_key(struct kbd *kb, uint32_t time);
|
||||
void kbd_release_key(struct kbd *kb, uint32_t time);
|
||||
void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y);
|
||||
void kbd_press_key(struct kbd *kb, struct key *k, uint32_t time);
|
||||
void kbd_print_key_stdout(struct kbd *kb, struct key *k);
|
||||
void kbd_clear_last_popup(struct kbd *kb);
|
||||
void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type);
|
||||
void kbd_draw_layout(struct kbd *kb);
|
||||
void kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount);
|
||||
uint8_t kbd_get_rows(struct layout *l);
|
||||
double kbd_get_row_length(struct key *k);
|
||||
void kbd_switch_layout(struct kbd *kb, struct layout *l);
|
||||
void kbd_next_layer(struct kbd *kb, struct key *k, bool invert);
|
||||
void kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index);
|
||||
|
||||
void create_and_upload_keymap(struct kbd *kb, const char *name,
|
||||
uint32_t comp_unichr, uint32_t comp_shift_unichr);
|
||||
|
1466
keymap.mobintl.h
1466
keymap.mobintl.h
File diff suppressed because it is too large
Load Diff
1029
layout.mobintl.h
1029
layout.mobintl.h
File diff suppressed because it is too large
Load Diff
553
main.c
553
main.c
@ -1,5 +1,8 @@
|
||||
#include "proto/virtual-keyboard-unstable-v1-client-protocol.h"
|
||||
#include "proto/wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
#include "proto/xdg-shell-client-protocol.h"
|
||||
#include "proto/fractional-scale-v1-client-protocol.h"
|
||||
#include "proto/viewporter-client-protocol.h"
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -8,6 +11,7 @@
|
||||
#include <sys/signalfd.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wchar.h>
|
||||
|
||||
@ -26,14 +30,34 @@ static struct wl_compositor *compositor;
|
||||
static struct wl_seat *seat;
|
||||
static struct wl_pointer *pointer;
|
||||
static struct wl_touch *touch;
|
||||
static struct wl_output *wl_output;
|
||||
static struct wl_region *empty_region;
|
||||
static struct zwlr_layer_shell_v1 *layer_shell;
|
||||
static struct zwlr_layer_surface_v1 *layer_surface;
|
||||
static struct xdg_wm_base *wm_base;
|
||||
static struct xdg_surface *popup_xdg_surface;
|
||||
static struct xdg_popup *popup_xdg_popup;
|
||||
static struct xdg_positioner *popup_xdg_positioner;
|
||||
static struct zwp_virtual_keyboard_manager_v1 *vkbd_mgr;
|
||||
static struct wp_fractional_scale_v1 *wfs_draw_surf;
|
||||
static struct wp_fractional_scale_manager_v1 *wfs_mgr;
|
||||
static struct wp_viewport *draw_surf_viewport, *popup_draw_surf_viewport;
|
||||
static struct wp_viewporter *viewporter;
|
||||
|
||||
struct Output {
|
||||
uint32_t name;
|
||||
uint32_t w, h;
|
||||
double scale;
|
||||
struct wl_output *data;
|
||||
};
|
||||
static struct Output *current_output;
|
||||
|
||||
#define WL_OUTPUTS_LIMIT 8
|
||||
static struct Output wl_outputs[WL_OUTPUTS_LIMIT];
|
||||
static int wl_outputs_size;
|
||||
|
||||
/* drawing */
|
||||
static struct drw draw_ctx;
|
||||
static struct drwsurf draw_surf;
|
||||
static struct drwsurf draw_surf, popup_draw_surf;
|
||||
|
||||
/* layer surface parameters */
|
||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
|
||||
@ -61,6 +85,8 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
|
||||
static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button,
|
||||
uint32_t state);
|
||||
static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, uint32_t axis, wl_fixed_t value);
|
||||
|
||||
static void wl_touch_down(void *data, struct wl_touch *wl_touch,
|
||||
uint32_t serial, uint32_t time,
|
||||
@ -83,6 +109,9 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
||||
static void seat_handle_name(void *data, struct wl_seat *wl_seat,
|
||||
const char *name);
|
||||
|
||||
static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output);
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface,
|
||||
uint32_t version);
|
||||
@ -94,6 +123,7 @@ static void layer_surface_configure(void *data,
|
||||
uint32_t serial, uint32_t w, uint32_t h);
|
||||
static void layer_surface_closed(void *data,
|
||||
struct zwlr_layer_surface_v1 *surface);
|
||||
static void resize();
|
||||
|
||||
/* event handlers */
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
@ -101,6 +131,7 @@ static const struct wl_pointer_listener pointer_listener = {
|
||||
.leave = wl_pointer_leave,
|
||||
.motion = wl_pointer_motion,
|
||||
.button = wl_pointer_button,
|
||||
.axis = wl_pointer_axis,
|
||||
};
|
||||
|
||||
static const struct wl_touch_listener touch_listener = {
|
||||
@ -118,6 +149,10 @@ static const struct wl_seat_listener seat_listener = {
|
||||
.name = seat_handle_name,
|
||||
};
|
||||
|
||||
static const struct wl_surface_listener surface_listener = {
|
||||
.enter = wl_surface_enter,
|
||||
};
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
.global = handle_global,
|
||||
.global_remove = handle_global_remove,
|
||||
@ -131,7 +166,8 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
|
||||
/* configuration, allows nested code to access above variables */
|
||||
|
||||
char *
|
||||
estrdup(const char *s) {
|
||||
estrdup(const char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!(p = strdup(s))) {
|
||||
@ -145,7 +181,8 @@ estrdup(const char *s) {
|
||||
void
|
||||
wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, struct wl_surface *surface, int32_t id,
|
||||
wl_fixed_t x, wl_fixed_t y) {
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct key *next_key;
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
@ -157,18 +194,24 @@ wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
next_key = kbd_get_key(&keyboard, touch_x, touch_y);
|
||||
if (next_key) {
|
||||
kbd_press_key(&keyboard, next_key, time);
|
||||
} else if (keyboard.compose) {
|
||||
keyboard.compose = 0;
|
||||
kbd_switch_layout(&keyboard, keyboard.prevlayout,
|
||||
keyboard.last_abc_index);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, int32_t id) {
|
||||
uint32_t time, int32_t id)
|
||||
{
|
||||
kbd_release_key(&keyboard, time);
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y) {
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
touch_x = wl_fixed_to_int(x);
|
||||
@ -178,33 +221,45 @@ wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_frame(void *data, struct wl_touch *wl_touch) {}
|
||||
wl_touch_frame(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_cancel(void *data, struct wl_touch *wl_touch) {}
|
||||
wl_touch_cancel(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_shape(void *data, struct wl_touch *wl_touch, int32_t id,
|
||||
wl_fixed_t major, wl_fixed_t minor) {}
|
||||
wl_fixed_t major, wl_fixed_t minor)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_orientation(void *data, struct wl_touch *wl_touch, int32_t id,
|
||||
wl_fixed_t orientation) {}
|
||||
wl_fixed_t orientation)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
struct wl_surface *surface, wl_fixed_t surface_x,
|
||||
wl_fixed_t surface_y) {}
|
||||
wl_fixed_t surface_y)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
struct wl_surface *surface) {
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
cur_x = cur_y = -1;
|
||||
}
|
||||
|
||||
void
|
||||
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||
{
|
||||
cur_x = wl_fixed_to_int(surface_x);
|
||||
cur_y = wl_fixed_to_int(surface_y);
|
||||
|
||||
@ -215,7 +270,8 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
|
||||
void
|
||||
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state) {
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
struct key *next_key;
|
||||
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||
|
||||
@ -229,30 +285,76 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
next_key = kbd_get_key(&keyboard, cur_x, cur_y);
|
||||
if (next_key) {
|
||||
kbd_press_key(&keyboard, next_key, time);
|
||||
} else if (keyboard.compose) {
|
||||
keyboard.compose = 0;
|
||||
kbd_switch_layout(&keyboard, keyboard.prevlayout,
|
||||
keyboard.last_abc_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
uint32_t axis, wl_fixed_t value)
|
||||
{
|
||||
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
||||
drwsurf_flip(keyboard.surf);
|
||||
}
|
||||
|
||||
void
|
||||
seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
||||
enum wl_seat_capability caps) {
|
||||
enum wl_seat_capability caps)
|
||||
{
|
||||
if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
|
||||
if (pointer == NULL) {
|
||||
pointer = wl_seat_get_pointer(wl_seat);
|
||||
wl_pointer_add_listener(pointer, &pointer_listener, NULL);
|
||||
}
|
||||
} else {
|
||||
if (pointer != NULL) {
|
||||
wl_pointer_destroy(pointer);
|
||||
pointer = NULL;
|
||||
}
|
||||
}
|
||||
if ((caps & WL_SEAT_CAPABILITY_TOUCH)) {
|
||||
if (touch == NULL) {
|
||||
touch = wl_seat_get_touch(wl_seat);
|
||||
wl_touch_add_listener(touch, &touch_listener, NULL);
|
||||
}
|
||||
} else {
|
||||
if (touch != NULL) {
|
||||
wl_touch_destroy(touch);
|
||||
touch = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {}
|
||||
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output)
|
||||
{
|
||||
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
|
||||
if (wl_outputs[i].data == wl_output) {
|
||||
current_output = &wl_outputs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
resize();
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
int physical_width, int physical_height, int subpixel,
|
||||
const char *make, const char *model, int transform) {
|
||||
const char *make, const char *model, int transform)
|
||||
{
|
||||
struct Output *output = data;
|
||||
|
||||
// Swap width and height on rotated displays
|
||||
if (transform % 2 != 0) {
|
||||
int tmp = physical_width;
|
||||
@ -260,9 +362,157 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
physical_height = tmp;
|
||||
}
|
||||
|
||||
bool landscape = physical_width > physical_height;
|
||||
if (landscape == keyboard.landscape) return;
|
||||
keyboard.landscape = landscape;
|
||||
output->w = physical_width;
|
||||
output->h = physical_height;
|
||||
|
||||
if (current_output == output) {
|
||||
resize();
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_done(void *data, struct wl_output *wl_output)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale)
|
||||
{
|
||||
struct Output *output = data;
|
||||
output->scale = scale;
|
||||
|
||||
if (current_output == output) {
|
||||
resize();
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
|
||||
int width, int height, int refresh)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_output_listener output_listener = {
|
||||
.geometry = display_handle_geometry,
|
||||
.mode = display_handle_mode,
|
||||
.done = display_handle_done,
|
||||
.scale = display_handle_scale};
|
||||
|
||||
static void
|
||||
xdg_wm_base_ping(void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
|
||||
{
|
||||
xdg_wm_base_pong(xdg_wm_base, serial);
|
||||
}
|
||||
|
||||
static const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
||||
.ping = xdg_wm_base_ping,
|
||||
};
|
||||
|
||||
void
|
||||
handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version)
|
||||
{
|
||||
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||
compositor =
|
||||
wl_registry_bind(registry, name, &wl_compositor_interface, 3);
|
||||
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
draw_ctx.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
if (wl_outputs_size < WL_OUTPUTS_LIMIT) {
|
||||
struct Output *output = &wl_outputs[wl_outputs_size];
|
||||
output->data =
|
||||
wl_registry_bind(registry, name, &wl_output_interface, 2);
|
||||
output->name = name;
|
||||
output->scale = 1;
|
||||
wl_output_add_listener(output->data, &output_listener, output);
|
||||
wl_outputs_size += 1;
|
||||
}
|
||||
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
|
||||
wl_seat_add_listener(seat, &seat_listener, NULL);
|
||||
} 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, xdg_wm_base_interface.name) == 0) {
|
||||
wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
|
||||
xdg_wm_base_add_listener(wm_base, &xdg_wm_base_listener, NULL);
|
||||
} else if (strcmp(interface,
|
||||
wp_fractional_scale_manager_v1_interface.name) == 0) {
|
||||
wfs_mgr = wl_registry_bind(
|
||||
registry, name, &wp_fractional_scale_manager_v1_interface, 1);
|
||||
} else if (strcmp(interface, wp_viewporter_interface.name) == 0) {
|
||||
viewporter =
|
||||
wl_registry_bind(registry, name, &wp_viewporter_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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
|
||||
{
|
||||
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
|
||||
if (wl_outputs[i].name == name) {
|
||||
wl_output_destroy(wl_outputs[i].data);
|
||||
for (; i < WL_OUTPUTS_LIMIT - 1; i += 1) {
|
||||
wl_outputs[i] = wl_outputs[i + 1];
|
||||
}
|
||||
wl_outputs_size -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
drwsurf_flip(&popup_draw_surf);
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdg_popup_surface_listener = {
|
||||
.configure = xdg_popup_surface_configure,
|
||||
};
|
||||
|
||||
static void
|
||||
xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, int32_t x,
|
||||
int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
|
||||
drwsurf_flip(&draw_surf);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_done(void *data, struct xdg_popup *xdg_popup)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct xdg_popup_listener xdg_popup_listener = {
|
||||
.configure = xdg_popup_configure,
|
||||
.popup_done = xdg_popup_done,
|
||||
};
|
||||
|
||||
static void
|
||||
wp_fractional_scale_prefered_scale(
|
||||
void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||
uint32_t scale)
|
||||
{
|
||||
keyboard.pending_scale = (double)scale / 120;
|
||||
}
|
||||
|
||||
static const struct wp_fractional_scale_v1_listener
|
||||
wp_fractional_scale_listener = {
|
||||
.preferred_scale = wp_fractional_scale_prefered_scale,
|
||||
};
|
||||
|
||||
void
|
||||
resize()
|
||||
{
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
|
||||
enum layout_id layer;
|
||||
if (keyboard.landscape) {
|
||||
@ -274,8 +524,14 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
}
|
||||
|
||||
keyboard.layout = &keyboard.layouts[layer];
|
||||
keyboard.prevlayout = keyboard.layout;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.prevlayout = keyboard.layout;
|
||||
keyboard.last_abc_layout = keyboard.layout;
|
||||
keyboard.last_abc_index = 0;
|
||||
|
||||
if (!wfs_mgr || !viewporter) {
|
||||
keyboard.pending_scale = current_output->scale;
|
||||
}
|
||||
|
||||
if (layer_surface) {
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
@ -284,76 +540,85 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_done(void *data, struct wl_output *wl_output) {}
|
||||
|
||||
static void
|
||||
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale) {
|
||||
keyboard.s = scale;
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
|
||||
int width, int height, int refresh) {}
|
||||
|
||||
static const struct wl_output_listener output_listener = {
|
||||
.geometry = display_handle_geometry,
|
||||
.mode = display_handle_mode,
|
||||
.done = display_handle_done,
|
||||
.scale = display_handle_scale};
|
||||
|
||||
void
|
||||
handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version) {
|
||||
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||
compositor = wl_registry_bind(registry, name, &wl_compositor_interface, 3);
|
||||
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
draw_ctx.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
if (!wl_output) {
|
||||
wl_output = wl_registry_bind(registry, name, &wl_output_interface, 2);
|
||||
keyboard.s = 1;
|
||||
wl_output_add_listener(wl_output, &output_listener, NULL);
|
||||
}
|
||||
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
|
||||
wl_seat_add_listener(seat, &seat_listener, NULL);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {}
|
||||
|
||||
void
|
||||
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
uint32_t serial, uint32_t w, uint32_t h) {
|
||||
if (keyboard.w != w || keyboard.h != h) {
|
||||
uint32_t serial, uint32_t w, uint32_t h)
|
||||
{
|
||||
if (keyboard.w != w || keyboard.h != h ||
|
||||
keyboard.scale != keyboard.pending_scale) {
|
||||
keyboard.w = w;
|
||||
keyboard.h = h;
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
keyboard.scale = keyboard.pending_scale;
|
||||
|
||||
if (wfs_mgr && viewporter) {
|
||||
if (!wfs_draw_surf) {
|
||||
wfs_draw_surf =
|
||||
wp_fractional_scale_manager_v1_get_fractional_scale(
|
||||
wfs_mgr, draw_surf.surf);
|
||||
wp_fractional_scale_v1_add_listener(
|
||||
wfs_draw_surf, &wp_fractional_scale_listener, NULL);
|
||||
}
|
||||
if (!draw_surf_viewport) {
|
||||
draw_surf_viewport =
|
||||
wp_viewporter_get_viewport(viewporter, draw_surf.surf);
|
||||
}
|
||||
wp_viewport_set_destination(draw_surf_viewport, keyboard.w,
|
||||
keyboard.h);
|
||||
} else {
|
||||
wl_surface_set_buffer_scale(draw_surf.surf, keyboard.scale);
|
||||
}
|
||||
|
||||
if (popup_xdg_popup) {
|
||||
xdg_popup_destroy(popup_xdg_popup);
|
||||
}
|
||||
if (popup_xdg_surface) {
|
||||
xdg_surface_destroy(popup_xdg_surface);
|
||||
}
|
||||
if (popup_draw_surf.surf) {
|
||||
wl_surface_destroy(popup_draw_surf.surf);
|
||||
}
|
||||
|
||||
popup_draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
|
||||
xdg_positioner_set_size(popup_xdg_positioner, w, h * 2);
|
||||
xdg_positioner_set_anchor_rect(popup_xdg_positioner, 0, -h, w, h * 2);
|
||||
|
||||
wl_surface_set_input_region(popup_draw_surf.surf, empty_region);
|
||||
popup_xdg_surface =
|
||||
xdg_wm_base_get_xdg_surface(wm_base, popup_draw_surf.surf);
|
||||
xdg_surface_add_listener(popup_xdg_surface, &xdg_popup_surface_listener,
|
||||
NULL);
|
||||
popup_xdg_popup = xdg_surface_get_popup(popup_xdg_surface, NULL,
|
||||
popup_xdg_positioner);
|
||||
xdg_popup_add_listener(popup_xdg_popup, &xdg_popup_listener, NULL);
|
||||
zwlr_layer_surface_v1_get_popup(layer_surface, popup_xdg_popup);
|
||||
|
||||
if (wfs_mgr && viewporter) {
|
||||
popup_draw_surf_viewport =
|
||||
wp_viewporter_get_viewport(viewporter, popup_draw_surf.surf);
|
||||
wp_viewport_set_destination(popup_draw_surf_viewport, keyboard.w,
|
||||
keyboard.h * 2);
|
||||
} else {
|
||||
wl_surface_set_buffer_scale(popup_draw_surf.surf, keyboard.scale);
|
||||
}
|
||||
|
||||
wl_surface_commit(popup_draw_surf.surf);
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||
|
||||
drwsurf_flip(&draw_surf);
|
||||
}
|
||||
|
||||
void
|
||||
layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface) {
|
||||
layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface)
|
||||
{
|
||||
zwlr_layer_surface_v1_destroy(surface);
|
||||
wl_surface_destroy(draw_surf.surf);
|
||||
run_display = false;
|
||||
}
|
||||
|
||||
void
|
||||
usage(char *argv0) {
|
||||
usage(char *argv0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l "
|
||||
"layers]\n",
|
||||
@ -361,26 +626,38 @@ usage(char *argv0) {
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -D - Enable debug\n");
|
||||
fprintf(stderr, " -o - Print pressed keys to standard output\n");
|
||||
fprintf(stderr, " -O - Print intersected keys to standard output\n");
|
||||
fprintf(stderr, " -l - Comma separated list of layers\n");
|
||||
fprintf(stderr,
|
||||
" -O - Print intersected keys to standard output\n");
|
||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
||||
fprintf(stderr, " --fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
||||
fprintf(
|
||||
stderr,
|
||||
" --alpha [int] - Set alpha value for all colors [0-255]\n");
|
||||
fprintf(stderr, " --bg [rrggbb|aa] - Set color of background\n");
|
||||
fprintf(stderr, " --fg [rrggbb|aa] - Set color of keys\n");
|
||||
fprintf(stderr, " --fg-sp [rrggbb|aa] - Set color of special keys\n");
|
||||
fprintf(stderr, " --press [rrggbb|aa] - Set color of pressed keys\n");
|
||||
fprintf(stderr, " --press-sp [rrggbb|aa] - Set color of pressed special keys\n");
|
||||
fprintf(stderr,
|
||||
" --press-sp [rrggbb|aa] - Set color of pressed special keys\n");
|
||||
fprintf(stderr, " --swipe [rrggbb|aa] - Set color of swiped keys\n");
|
||||
fprintf(stderr, " --swipe-sp [rrggbb|aa] - Set color of swiped special keys\n");
|
||||
fprintf(stderr,
|
||||
" --swipe-sp [rrggbb|aa] - Set color of swiped special keys\n");
|
||||
fprintf(stderr, " --text [rrggbb|aa] - Set color of text on keys\n");
|
||||
fprintf(stderr, " --text-sp [rrggbb|aa] - Set color of text on special keys\n");
|
||||
fprintf(stderr, " --list-layers - Print the list of available layers\n");
|
||||
fprintf(stderr,
|
||||
" --text-sp [rrggbb|aa] - Set color of text on special keys\n");
|
||||
fprintf(stderr,
|
||||
" --list-layers - Print the list of available layers\n");
|
||||
fprintf(stderr,
|
||||
" -l - Comma separated list of layers\n");
|
||||
fprintf(stderr, " --landscape-layers - Comma separated list of "
|
||||
"landscape layers\n");
|
||||
}
|
||||
|
||||
void
|
||||
list_layers() {
|
||||
list_layers()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NumLayouts - 1; i++) {
|
||||
if (layouts[i].name) {
|
||||
@ -390,7 +667,8 @@ list_layers() {
|
||||
}
|
||||
|
||||
void
|
||||
hide() {
|
||||
hide()
|
||||
{
|
||||
if (!layer_surface) {
|
||||
return;
|
||||
}
|
||||
@ -402,7 +680,8 @@ hide() {
|
||||
}
|
||||
|
||||
void
|
||||
show() {
|
||||
show()
|
||||
{
|
||||
if (layer_surface) {
|
||||
return;
|
||||
}
|
||||
@ -410,8 +689,9 @@ show() {
|
||||
wl_display_sync(display);
|
||||
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
wl_surface_add_listener(draw_surf.surf, &surface_listener, NULL);
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
||||
layer_shell, draw_surf.surf, NULL, layer, namespace);
|
||||
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||
@ -421,26 +701,27 @@ show() {
|
||||
NULL);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
drwsurf_flip(&draw_surf);
|
||||
|
||||
hidden = false;
|
||||
}
|
||||
|
||||
void
|
||||
toggle_visibility() {
|
||||
if (hidden) show();
|
||||
else hide();
|
||||
toggle_visibility()
|
||||
{
|
||||
if (hidden)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
void
|
||||
pipewarn() {
|
||||
pipewarn()
|
||||
{
|
||||
fprintf(stderr, "wvkbd: cannot pipe data out.\n");
|
||||
}
|
||||
|
||||
void
|
||||
set_kbd_colors(uint8_t * bgra, char * hex) {
|
||||
set_kbd_colors(uint8_t *bgra, char *hex)
|
||||
{
|
||||
// bg, fg, text, high, swipe
|
||||
int length = strlen(hex);
|
||||
if (length == 6 || length == 8) {
|
||||
@ -459,9 +740,10 @@ set_kbd_colors(uint8_t * bgra, char * hex) {
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* parse command line arguments */
|
||||
char *layer_names_list = NULL;
|
||||
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
|
||||
const char *fc_font_pattern = NULL;
|
||||
height = normal_height = KBD_PIXEL_HEIGHT;
|
||||
landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
@ -469,6 +751,8 @@ main(int argc, char **argv) {
|
||||
char *tmp;
|
||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||
layer_names_list = estrdup(tmp);
|
||||
if ((tmp = getenv("WVKBD_LANDSCAPE_LAYERS")))
|
||||
landscape_layer_names_list = estrdup(tmp);
|
||||
if ((tmp = getenv("WVKBD_HEIGHT")))
|
||||
normal_height = atoi(tmp);
|
||||
if ((tmp = getenv("WVKBD_LANDSCAPE_HEIGHT")))
|
||||
@ -480,6 +764,10 @@ main(int argc, char **argv) {
|
||||
keyboard.scheme = scheme;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.scheme1 = scheme1;
|
||||
keyboard.pending_scale = 1;
|
||||
|
||||
uint8_t alpha = 0;
|
||||
bool alpha_defined = false;
|
||||
|
||||
int i;
|
||||
for (i = 1; argv[i]; i++) {
|
||||
@ -497,55 +785,79 @@ main(int argc, char **argv) {
|
||||
if (layer_names_list)
|
||||
free(layer_names_list);
|
||||
layer_names_list = estrdup(argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-landscape-layers")) ||
|
||||
(!strcmp(argv[i], "--landscape-layers"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (landscape_layer_names_list)
|
||||
free(landscape_layer_names_list);
|
||||
landscape_layer_names_list = estrdup(argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-bg")) || (!strcmp(argv[i], "--bg"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.bg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-alpha")) ||
|
||||
(!strcmp(argv[i], "--alpha"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
alpha = atoi(argv[++i]);
|
||||
alpha_defined = true;
|
||||
} else if ((!strcmp(argv[i], "-fg")) || (!strcmp(argv[i], "--fg"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-fg-sp")) || (!strcmp(argv[i], "--fg-sp"))) {
|
||||
} else if ((!strcmp(argv[i], "-fg-sp")) ||
|
||||
(!strcmp(argv[i], "--fg-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press")) || (!strcmp(argv[i], "--press"))) {
|
||||
} else if ((!strcmp(argv[i], "-press")) ||
|
||||
(!strcmp(argv[i], "--press"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press-sp")) || (!strcmp(argv[i], "--press-sp"))) {
|
||||
} else if ((!strcmp(argv[i], "-press-sp")) ||
|
||||
(!strcmp(argv[i], "--press-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe")) || (!strcmp(argv[i], "--swipe"))) {
|
||||
} else if ((!strcmp(argv[i], "-swipe")) ||
|
||||
(!strcmp(argv[i], "--swipe"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe-sp")) || (!strcmp(argv[i], "--swipe-sp"))) {
|
||||
} else if ((!strcmp(argv[i], "-swipe-sp")) ||
|
||||
(!strcmp(argv[i], "--swipe-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text")) || (!strcmp(argv[i], "--text"))) {
|
||||
} else if ((!strcmp(argv[i], "-text")) ||
|
||||
(!strcmp(argv[i], "--text"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.text.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text-sp")) || (!strcmp(argv[i], "--text-sp"))) {
|
||||
} else if ((!strcmp(argv[i], "-text-sp")) ||
|
||||
(!strcmp(argv[i], "--text-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
@ -589,6 +901,15 @@ main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha_defined) {
|
||||
keyboard.scheme.bg.bgra[3] = alpha;
|
||||
keyboard.scheme.fg.bgra[3] = alpha;
|
||||
keyboard.scheme.high.bgra[3] = alpha;
|
||||
keyboard.scheme1.bg.bgra[3] = alpha;
|
||||
keyboard.scheme1.fg.bgra[3] = alpha;
|
||||
keyboard.scheme1.high.bgra[3] = alpha;
|
||||
}
|
||||
|
||||
if (!fc_font_pattern) {
|
||||
fc_font_pattern = default_font;
|
||||
}
|
||||
@ -599,7 +920,9 @@ main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
draw_surf.ctx = &draw_ctx;
|
||||
popup_draw_surf.ctx = &draw_ctx;
|
||||
keyboard.surf = &draw_surf;
|
||||
keyboard.popup_surf = &popup_draw_surf;
|
||||
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener, NULL);
|
||||
@ -614,22 +937,30 @@ main(int argc, char **argv) {
|
||||
if (layer_shell == NULL) {
|
||||
die("layer_shell not available\n");
|
||||
}
|
||||
if (wm_base == NULL) {
|
||||
die("wm_base not available\n");
|
||||
}
|
||||
if (vkbd_mgr == NULL) {
|
||||
die("virtual_keyboard_manager not available\n");
|
||||
}
|
||||
|
||||
empty_region = wl_compositor_create_region(compositor);
|
||||
popup_xdg_positioner = xdg_wm_base_create_positioner(wm_base);
|
||||
|
||||
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);
|
||||
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list,
|
||||
landscape_layer_names_list);
|
||||
|
||||
draw_ctx.font_description =
|
||||
pango_font_description_from_string(fc_font_pattern);
|
||||
|
||||
if (!hidden) show();
|
||||
if (!hidden)
|
||||
show();
|
||||
|
||||
struct pollfd fds[2];
|
||||
int WAYLAND_FD = 0;
|
||||
@ -669,10 +1000,14 @@ main(int argc, char **argv) {
|
||||
|
||||
if (read(fds[SIGNAL_FD].fd, &si, sizeof(si)) != sizeof(si))
|
||||
fprintf(stderr, "Signal read error: %d", errno);
|
||||
else if (si.ssi_signo == SIGUSR1) hide();
|
||||
else if (si.ssi_signo == SIGUSR2) show();
|
||||
else if (si.ssi_signo == SIGRTMIN) toggle_visibility();
|
||||
else if (si.ssi_signo == SIGPIPE) pipewarn();
|
||||
else if (si.ssi_signo == SIGUSR1)
|
||||
hide();
|
||||
else if (si.ssi_signo == SIGUSR2)
|
||||
show();
|
||||
else if (si.ssi_signo == SIGRTMIN)
|
||||
toggle_visibility();
|
||||
else if (si.ssi_signo == SIGPIPE)
|
||||
pipewarn();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,8 @@
|
||||
#include "os-compatibility.h"
|
||||
|
||||
int
|
||||
os_fd_set_cloexec(int fd) {
|
||||
os_fd_set_cloexec(int fd)
|
||||
{
|
||||
long flags;
|
||||
|
||||
if (fd == -1)
|
||||
@ -52,7 +53,8 @@ os_fd_set_cloexec(int fd) {
|
||||
}
|
||||
|
||||
static int
|
||||
set_cloexec_or_close(int fd) {
|
||||
set_cloexec_or_close(int fd)
|
||||
{
|
||||
if (os_fd_set_cloexec(fd) != 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
@ -61,7 +63,8 @@ set_cloexec_or_close(int fd) {
|
||||
}
|
||||
|
||||
int
|
||||
os_socketpair_cloexec(int domain, int type, int protocol, int *sv) {
|
||||
os_socketpair_cloexec(int domain, int type, int protocol, int *sv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef SOCK_CLOEXEC
|
||||
@ -86,7 +89,8 @@ os_socketpair_cloexec(int domain, int type, int protocol, int *sv) {
|
||||
}
|
||||
|
||||
int
|
||||
os_epoll_create_cloexec(void) {
|
||||
os_epoll_create_cloexec(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef EPOLL_CLOEXEC
|
||||
@ -102,7 +106,8 @@ os_epoll_create_cloexec(void) {
|
||||
}
|
||||
|
||||
static int
|
||||
create_tmpfile_cloexec(char *tmpname) {
|
||||
create_tmpfile_cloexec(char *tmpname)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_MKOSTEMP
|
||||
@ -142,7 +147,8 @@ create_tmpfile_cloexec(char *tmpname) {
|
||||
* SIGBUS on accessing mmap()'ed file contents instead.
|
||||
*/
|
||||
int
|
||||
os_create_anonymous_file(off_t size) {
|
||||
os_create_anonymous_file(off_t size)
|
||||
{
|
||||
static const char template[] = "/weston-shared-XXXXXX";
|
||||
const char *path;
|
||||
char *name;
|
||||
@ -193,7 +199,8 @@ os_create_anonymous_file(off_t size) {
|
||||
|
||||
#ifndef MISSING_STRCHRNUL
|
||||
char *
|
||||
strchrnul(const char *s, int c) {
|
||||
strchrnul(const char *s, int c)
|
||||
{
|
||||
while (*s && *s != c)
|
||||
s++;
|
||||
return (char *)s;
|
||||
|
102
proto/fractional-scale-v1.xml
Normal file
102
proto/fractional-scale-v1.xml
Normal file
@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="fractional_scale_v1">
|
||||
<copyright>
|
||||
Copyright © 2022 Kenny Levinsen
|
||||
|
||||
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>
|
||||
|
||||
<description summary="Protocol for requesting fractional surface scales">
|
||||
This protocol allows a compositor to suggest for surfaces to render at
|
||||
fractional scales.
|
||||
|
||||
A client can submit scaled content by utilizing wp_viewport. This is done by
|
||||
creating a wp_viewport object for the surface and setting the destination
|
||||
rectangle to the surface size before the scale factor is applied.
|
||||
|
||||
The buffer size is calculated by multiplying the surface size by the
|
||||
intended scale.
|
||||
|
||||
The wl_surface buffer scale should remain set to 1.
|
||||
|
||||
If a surface has a surface-local size of 100 px by 50 px and wishes to
|
||||
submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
|
||||
be used and the wp_viewport destination rectangle should be 100 px by 50 px.
|
||||
|
||||
For toplevel surfaces, the size is rounded halfway away from zero. The
|
||||
rounding algorithm for subsurface position and size is not defined.
|
||||
</description>
|
||||
|
||||
<interface name="wp_fractional_scale_manager_v1" version="1">
|
||||
<description summary="fractional surface scale information">
|
||||
A global interface for requesting surfaces to use fractional scales.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="unbind the fractional surface scale interface">
|
||||
Informs the server that the client will not be using this protocol
|
||||
object anymore. This does not affect any other objects,
|
||||
wp_fractional_scale_v1 objects included.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="fractional_scale_exists" value="0"
|
||||
summary="the surface already has a fractional_scale object associated"/>
|
||||
</enum>
|
||||
|
||||
<request name="get_fractional_scale">
|
||||
<description summary="extend surface interface for scale information">
|
||||
Create an add-on object for the the wl_surface to let the compositor
|
||||
request fractional scales. If the given wl_surface already has a
|
||||
wp_fractional_scale_v1 object associated, the fractional_scale_exists
|
||||
protocol error is raised.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="wp_fractional_scale_v1"
|
||||
summary="the new surface scale info interface id"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="the surface"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="wp_fractional_scale_v1" version="1">
|
||||
<description summary="fractional scale interface to a wl_surface">
|
||||
An additional interface to a wl_surface object which allows the compositor
|
||||
to inform the client of the preferred scale.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="remove surface scale information for surface">
|
||||
Destroy the fractional scale object. When this object is destroyed,
|
||||
preferred_scale events will no longer be sent.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="preferred_scale">
|
||||
<description summary="notify of new preferred scale">
|
||||
Notification of a new preferred scale for this surface that the
|
||||
compositor suggests that the client should use.
|
||||
|
||||
The sent scale is the numerator of a fraction with a denominator of 120.
|
||||
</description>
|
||||
<arg name="scale" type="uint" summary="the new preferred scale"/>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
180
proto/viewporter.xml
Normal file
180
proto/viewporter.xml
Normal file
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="viewporter">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2013-2016 Collabora, Ltd.
|
||||
|
||||
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="wp_viewporter" version="1">
|
||||
<description summary="surface cropping and scaling">
|
||||
The global interface exposing surface cropping and scaling
|
||||
capabilities is used to instantiate an interface extension for a
|
||||
wl_surface object. This extended interface will then allow
|
||||
cropping and scaling the surface contents, effectively
|
||||
disconnecting the direct relationship between the buffer and the
|
||||
surface size.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="unbind from the cropping and scaling interface">
|
||||
Informs the server that the client will not be using this
|
||||
protocol object anymore. This does not affect any other objects,
|
||||
wp_viewport objects included.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="viewport_exists" value="0"
|
||||
summary="the surface already has a viewport object associated"/>
|
||||
</enum>
|
||||
|
||||
<request name="get_viewport">
|
||||
<description summary="extend surface interface for crop and scale">
|
||||
Instantiate an interface extension for the given wl_surface to
|
||||
crop and scale its content. If the given wl_surface already has
|
||||
a wp_viewport object associated, the viewport_exists
|
||||
protocol error is raised.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="wp_viewport"
|
||||
summary="the new viewport interface id"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"
|
||||
summary="the surface"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="wp_viewport" version="1">
|
||||
<description summary="crop and scale interface to a wl_surface">
|
||||
An additional interface to a wl_surface object, which allows the
|
||||
client to specify the cropping and scaling of the surface
|
||||
contents.
|
||||
|
||||
This interface works with two concepts: the source rectangle (src_x,
|
||||
src_y, src_width, src_height), and the destination size (dst_width,
|
||||
dst_height). The contents of the source rectangle are scaled to the
|
||||
destination size, and content outside the source rectangle is ignored.
|
||||
This state is double-buffered, and is applied on the next
|
||||
wl_surface.commit.
|
||||
|
||||
The two parts of crop and scale state are independent: the source
|
||||
rectangle, and the destination size. Initially both are unset, that
|
||||
is, no scaling is applied. The whole of the current wl_buffer is
|
||||
used as the source, and the surface size is as defined in
|
||||
wl_surface.attach.
|
||||
|
||||
If the destination size is set, it causes the surface size to become
|
||||
dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
this size. This overrides whatever the attached wl_buffer size is,
|
||||
unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
has no content and therefore no size. Otherwise, the size is always
|
||||
at least 1x1 in surface local coordinates.
|
||||
|
||||
If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
taken as the source. If the source rectangle is set and the destination
|
||||
size is not set, then src_width and src_height must be integers, and the
|
||||
surface size becomes the source rectangle size. This results in cropping
|
||||
without scaling. If src_width or src_height are not integers and
|
||||
destination size is not set, the bad_size protocol error is raised when
|
||||
the surface state is applied.
|
||||
|
||||
The coordinate transformations from buffer pixel coordinates up to
|
||||
the surface-local coordinates happen in the following order:
|
||||
1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
3. crop and scale (wp_viewport.set*)
|
||||
This means, that the source rectangle coordinates of crop and scale
|
||||
are given in the coordinates after the buffer transform and scale,
|
||||
i.e. in the coordinates that would be the surface-local coordinates
|
||||
if the crop and scale was not applied.
|
||||
|
||||
If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
Otherwise, if the source rectangle is partially or completely outside of
|
||||
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
out_of_buffer error.
|
||||
|
||||
If the wl_surface associated with the wp_viewport is destroyed,
|
||||
all wp_viewport requests except 'destroy' raise the protocol error
|
||||
no_surface.
|
||||
|
||||
If the wp_viewport object is destroyed, the crop and scale
|
||||
state is removed from the wl_surface. The change will be applied
|
||||
on the next wl_surface.commit.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="remove scaling and cropping from the surface">
|
||||
The associated wl_surface's crop and scale state is removed.
|
||||
The change is applied on the next wl_surface.commit.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="bad_value" value="0"
|
||||
summary="negative or zero values in width or height"/>
|
||||
<entry name="bad_size" value="1"
|
||||
summary="destination size is not integer"/>
|
||||
<entry name="out_of_buffer" value="2"
|
||||
summary="source rectangle extends outside of the content area"/>
|
||||
<entry name="no_surface" value="3"
|
||||
summary="the wl_surface was destroyed"/>
|
||||
</enum>
|
||||
|
||||
<request name="set_source">
|
||||
<description summary="set the source rectangle for cropping">
|
||||
Set the source rectangle of the associated wl_surface. See
|
||||
wp_viewport for the description, and relation to the wl_buffer
|
||||
size.
|
||||
|
||||
If all of x, y, width and height are -1.0, the source rectangle is
|
||||
unset instead. Any other set of values where width or height are zero
|
||||
or negative, or x or y are negative, raise the bad_value protocol
|
||||
error.
|
||||
|
||||
The crop and scale state is double-buffered state, and will be
|
||||
applied on the next wl_surface.commit.
|
||||
</description>
|
||||
<arg name="x" type="fixed" summary="source rectangle x"/>
|
||||
<arg name="y" type="fixed" summary="source rectangle y"/>
|
||||
<arg name="width" type="fixed" summary="source rectangle width"/>
|
||||
<arg name="height" type="fixed" summary="source rectangle height"/>
|
||||
</request>
|
||||
|
||||
<request name="set_destination">
|
||||
<description summary="set the surface size for scaling">
|
||||
Set the destination size of the associated wl_surface. See
|
||||
wp_viewport for the description, and relation to the wl_buffer
|
||||
size.
|
||||
|
||||
If width is -1 and height is -1, the destination size is unset
|
||||
instead. Any other pair of values for width and height that
|
||||
contains zero or negative values raises the bad_value protocol
|
||||
error.
|
||||
|
||||
The crop and scale state is double-buffered state, and will be
|
||||
applied on the next wl_surface.commit.
|
||||
</description>
|
||||
<arg name="width" type="int" summary="surface width"/>
|
||||
<arg name="height" type="int" summary="surface height"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
@ -25,7 +25,7 @@
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwlr_layer_shell_v1" version="3">
|
||||
<interface name="zwlr_layer_shell_v1" version="4">
|
||||
<description summary="create surfaces that are layers of the desktop">
|
||||
Clients can use this interface to assign the surface_layer role to
|
||||
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||
@ -100,7 +100,7 @@
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_layer_surface_v1" version="3">
|
||||
<interface name="zwlr_layer_surface_v1" version="4">
|
||||
<description summary="layer metadata interface">
|
||||
An interface that may be implemented by a wl_surface, for surfaces that
|
||||
are designed to be rendered as a layer of a stacked desktop-like
|
||||
@ -203,21 +203,85 @@
|
||||
<arg name="left" type="int"/>
|
||||
</request>
|
||||
|
||||
<enum name="keyboard_interactivity">
|
||||
<description summary="types of keyboard interaction possible for a layer shell surface">
|
||||
Types of keyboard interaction possible for layer shell surfaces. The
|
||||
rationale for this is twofold: (1) some applications are not interested
|
||||
in keyboard events and not allowing them to be focused can improve the
|
||||
desktop experience; (2) some applications will want to take exclusive
|
||||
keyboard focus.
|
||||
</description>
|
||||
|
||||
<entry name="none" value="0">
|
||||
<description summary="no keyboard focus is possible">
|
||||
This value indicates that this surface is not interested in keyboard
|
||||
events and the compositor should never assign it the keyboard focus.
|
||||
|
||||
This is the default value, set for newly created layer shell surfaces.
|
||||
|
||||
This is useful for e.g. desktop widgets that display information or
|
||||
only have interaction with non-keyboard input devices.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="exclusive" value="1">
|
||||
<description summary="request exclusive keyboard focus">
|
||||
Request exclusive keyboard focus if this surface is above the shell surface layer.
|
||||
|
||||
For the top and overlay layers, the seat will always give
|
||||
exclusive keyboard focus to the top-most layer which has keyboard
|
||||
interactivity set to exclusive. If this layer contains multiple
|
||||
surfaces with keyboard interactivity set to exclusive, the compositor
|
||||
determines the one receiving keyboard events in an implementation-
|
||||
defined manner. In this case, no guarantee is made when this surface
|
||||
will receive keyboard focus (if ever).
|
||||
|
||||
For the bottom and background layers, the compositor is allowed to use
|
||||
normal focus semantics.
|
||||
|
||||
This setting is mainly intended for applications that need to ensure
|
||||
they receive all keyboard events, such as a lock screen or a password
|
||||
prompt.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="on_demand" value="2" since="4">
|
||||
<description summary="request regular keyboard focus semantics">
|
||||
This requests the compositor to allow this surface to be focused and
|
||||
unfocused by the user in an implementation-defined manner. The user
|
||||
should be able to unfocus this surface even regardless of the layer
|
||||
it is on.
|
||||
|
||||
Typically, the compositor will want to use its normal mechanism to
|
||||
manage keyboard focus between layer shell surfaces with this setting
|
||||
and regular toplevels on the desktop layer (e.g. click to focus).
|
||||
Nevertheless, it is possible for a compositor to require a special
|
||||
interaction to focus or unfocus layer shell surfaces (e.g. requiring
|
||||
a click even if focus follows the mouse normally, or providing a
|
||||
keybinding to switch focus between layers).
|
||||
|
||||
This setting is mainly intended for desktop shell components (e.g.
|
||||
panels) that allow keyboard interaction. Using this option can allow
|
||||
implementing a desktop shell that can be fully usable without the
|
||||
mouse.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<request name="set_keyboard_interactivity">
|
||||
<description summary="requests keyboard events">
|
||||
Set to 1 to request that the seat send keyboard events to this layer
|
||||
surface. For layers below the shell surface layer, the seat will use
|
||||
normal focus semantics. For layers above the shell surface layers, the
|
||||
seat will always give exclusive keyboard focus to the top-most layer
|
||||
which has keyboard interactivity set to true.
|
||||
Set how keyboard events are delivered to this surface. By default,
|
||||
layer shell surfaces do not receive keyboard events; this request can
|
||||
be used to change this.
|
||||
|
||||
This setting is inherited by child surfaces set by the get_popup
|
||||
request.
|
||||
|
||||
Layer surfaces receive pointer, touch, and tablet events normally. If
|
||||
you do not want to receive them, set the input region on your surface
|
||||
to an empty region.
|
||||
|
||||
Events is double-buffered, see wl_surface.commit.
|
||||
Keyboard interactivity is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="keyboard_interactivity" type="uint"/>
|
||||
<arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
|
||||
</request>
|
||||
|
||||
<request name="get_popup">
|
||||
@ -302,6 +366,7 @@
|
||||
<entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
|
||||
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
||||
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
||||
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
||||
</enum>
|
||||
|
||||
<enum name="anchor" bitfield="true">
|
||||
|
@ -29,7 +29,7 @@
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="xdg_wm_base" version="2">
|
||||
<interface name="xdg_wm_base" version="6">
|
||||
<description summary="create desktop-style surfaces">
|
||||
The xdg_wm_base interface is exposed as a global object enabling clients
|
||||
to turn their wl_surfaces into windows in a desktop environment. It
|
||||
@ -50,6 +50,8 @@
|
||||
summary="the client provided an invalid surface state"/>
|
||||
<entry name="invalid_positioner" value="5"
|
||||
summary="the client provided an invalid positioner"/>
|
||||
<entry name="unresponsive" value="6"
|
||||
summary="the client didn’t respond to a ping event in time"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
@ -58,7 +60,7 @@
|
||||
|
||||
Destroying a bound xdg_wm_base object while there are surfaces
|
||||
still alive created by this xdg_wm_base object instance is illegal
|
||||
and will result in a protocol error.
|
||||
and will result in a defunct_surfaces error.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
@ -75,7 +77,9 @@
|
||||
<description summary="create a shell surface from a surface">
|
||||
This creates an xdg_surface for the given surface. While xdg_surface
|
||||
itself is not a role, the corresponding surface may only be assigned
|
||||
a role extending xdg_surface, such as xdg_toplevel or xdg_popup.
|
||||
a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is
|
||||
illegal to create an xdg_surface for a wl_surface which already has an
|
||||
assigned role and this will result in a role error.
|
||||
|
||||
This creates an xdg_surface for the given surface. An xdg_surface is
|
||||
used as basis to define a role to a given surface, such as xdg_toplevel
|
||||
@ -92,7 +96,8 @@
|
||||
<request name="pong">
|
||||
<description summary="respond to a ping event">
|
||||
A client must respond to a ping event with a pong request or
|
||||
the client may be deemed unresponsive. See xdg_wm_base.ping.
|
||||
the client may be deemed unresponsive. See xdg_wm_base.ping
|
||||
and xdg_wm_base.error.unresponsive.
|
||||
</description>
|
||||
<arg name="serial" type="uint" summary="serial of the ping event"/>
|
||||
</request>
|
||||
@ -101,12 +106,14 @@
|
||||
<description summary="check if the client is alive">
|
||||
The ping event asks the client if it's still alive. Pass the
|
||||
serial specified in the event back to the compositor by sending
|
||||
a "pong" request back with the specified serial. See xdg_wm_base.ping.
|
||||
a "pong" request back with the specified serial. See xdg_wm_base.pong.
|
||||
|
||||
Compositors can use this to determine if the client is still
|
||||
alive. It's unspecified what will happen if the client doesn't
|
||||
respond to the ping request, or in what timeframe. Clients should
|
||||
try to respond in a reasonable amount of time.
|
||||
try to respond in a reasonable amount of time. The “unresponsive”
|
||||
error is provided for compositors that wish to disconnect unresponsive
|
||||
clients.
|
||||
|
||||
A compositor is free to ping in any way it wants, but a client must
|
||||
always respond to any xdg_wm_base object it created.
|
||||
@ -115,7 +122,7 @@
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_positioner" version="2">
|
||||
<interface name="xdg_positioner" version="6">
|
||||
<description summary="child surface positioner">
|
||||
The xdg_positioner provides a collection of rules for the placement of a
|
||||
child surface relative to a parent surface. Rules can be defined to ensure
|
||||
@ -135,7 +142,7 @@
|
||||
For an xdg_positioner object to be considered complete, it must have a
|
||||
non-zero size set by set_size, and a non-zero anchor rectangle set by
|
||||
set_anchor_rect. Passing an incomplete xdg_positioner object when
|
||||
positioning a surface raises an error.
|
||||
positioning a surface raises an invalid_positioner error.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
@ -223,7 +230,8 @@
|
||||
specified (e.g. 'bottom_right' or 'top_left'), then the child surface
|
||||
will be placed towards the specified gravity; otherwise, the child
|
||||
surface will be centered over the anchor point on any axis that had no
|
||||
gravity specified.
|
||||
gravity specified. If the gravity is not in the ‘gravity’ enum, an
|
||||
invalid_input error is raised.
|
||||
</description>
|
||||
<arg name="gravity" type="uint" enum="gravity"
|
||||
summary="gravity direction"/>
|
||||
@ -357,9 +365,49 @@
|
||||
<arg name="x" type="int" summary="surface position x offset"/>
|
||||
<arg name="y" type="int" summary="surface position y offset"/>
|
||||
</request>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="set_reactive" since="3">
|
||||
<description summary="continuously reconstrain the surface">
|
||||
When set reactive, the surface is reconstrained if the conditions used
|
||||
for constraining changed, e.g. the parent window moved.
|
||||
|
||||
If the conditions changed and the popup was reconstrained, an
|
||||
xdg_popup.configure event is sent with updated geometry, followed by an
|
||||
xdg_surface.configure event.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="set_parent_size" since="3">
|
||||
<description summary="">
|
||||
Set the parent window geometry the compositor should use when
|
||||
positioning the popup. The compositor may use this information to
|
||||
determine the future state the popup should be constrained using. If
|
||||
this doesn't match the dimension of the parent the popup is eventually
|
||||
positioned against, the behavior is undefined.
|
||||
|
||||
The arguments are given in the surface-local coordinate space.
|
||||
</description>
|
||||
<arg name="parent_width" type="int"
|
||||
summary="future window geometry width of parent"/>
|
||||
<arg name="parent_height" type="int"
|
||||
summary="future window geometry height of parent"/>
|
||||
</request>
|
||||
|
||||
<request name="set_parent_configure" since="3">
|
||||
<description summary="set parent configure this is a response to">
|
||||
Set the serial of an xdg_surface.configure event this positioner will be
|
||||
used in response to. The compositor may use this information together
|
||||
with set_parent_size to determine what future state the popup should be
|
||||
constrained using.
|
||||
</description>
|
||||
<arg name="serial" type="uint"
|
||||
summary="serial of parent configure event"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_surface" version="2">
|
||||
<interface name="xdg_surface" version="6">
|
||||
<description summary="desktop user interface surface base interface">
|
||||
An interface that may be implemented by a wl_surface, for
|
||||
implementations that provide a desktop-style user interface.
|
||||
@ -386,6 +434,13 @@
|
||||
manipulate a buffer prior to the first xdg_surface.configure call must
|
||||
also be treated as errors.
|
||||
|
||||
After creating a role-specific object and setting it up, the client must
|
||||
perform an initial commit without any buffer attached. The compositor
|
||||
will reply with initial wl_surface state such as
|
||||
wl_surface.preferred_buffer_scale followed by an xdg_surface.configure
|
||||
event. The client must acknowledge it and is then allowed to attach a
|
||||
buffer to map the surface.
|
||||
|
||||
Mapping an xdg_surface-based role surface is defined as making it
|
||||
possible for the surface to be shown by the compositor. Note that
|
||||
a mapped surface is not guaranteed to be visible once it is mapped.
|
||||
@ -399,19 +454,30 @@
|
||||
|
||||
A newly-unmapped surface is considered to have met condition (1) out
|
||||
of the 3 required conditions for mapping a surface if its role surface
|
||||
has not been destroyed.
|
||||
has not been destroyed, i.e. the client must perform the initial commit
|
||||
again before attaching a buffer.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="not_constructed" value="1"/>
|
||||
<entry name="already_constructed" value="2"/>
|
||||
<entry name="unconfigured_buffer" value="3"/>
|
||||
<entry name="not_constructed" value="1"
|
||||
summary="Surface was not fully constructed"/>
|
||||
<entry name="already_constructed" value="2"
|
||||
summary="Surface was already constructed"/>
|
||||
<entry name="unconfigured_buffer" value="3"
|
||||
summary="Attaching a buffer to an unconfigured surface"/>
|
||||
<entry name="invalid_serial" value="4"
|
||||
summary="Invalid serial number when acking a configure event"/>
|
||||
<entry name="invalid_size" value="5"
|
||||
summary="Width or height was zero or negative"/>
|
||||
<entry name="defunct_role_object" value="6"
|
||||
summary="Surface was destroyed before its role object"/>
|
||||
</enum>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the xdg_surface">
|
||||
Destroy the xdg_surface object. An xdg_surface must only be destroyed
|
||||
after its role object has been destroyed.
|
||||
after its role object has been destroyed, otherwise
|
||||
a defunct_role_object error is raised.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
@ -466,13 +532,22 @@
|
||||
commit. This unset is meant for extremely simple clients.
|
||||
|
||||
The arguments are given in the surface-local coordinate space of
|
||||
the wl_surface associated with this xdg_surface.
|
||||
the wl_surface associated with this xdg_surface, and may extend outside
|
||||
of the wl_surface itself to mark parts of the subsurface tree as part of
|
||||
the window geometry.
|
||||
|
||||
The width and height must be greater than zero. Setting an invalid size
|
||||
will raise an error. When applied, the effective window geometry will be
|
||||
the set window geometry clamped to the bounding rectangle of the
|
||||
combined geometry of the surface of the xdg_surface and the associated
|
||||
When applied, the effective window geometry will be the set window
|
||||
geometry clamped to the bounding rectangle of the combined
|
||||
geometry of the surface of the xdg_surface and the associated
|
||||
subsurfaces.
|
||||
|
||||
The effective geometry will not be recalculated unless a new call to
|
||||
set_window_geometry is done and the new pending surface state is
|
||||
subsequently applied.
|
||||
|
||||
The width and height of the effective window geometry must be
|
||||
greater than zero. Setting an invalid size will raise an
|
||||
invalid_size error.
|
||||
</description>
|
||||
<arg name="x" type="int"/>
|
||||
<arg name="y" type="int"/>
|
||||
@ -493,6 +568,8 @@
|
||||
|
||||
If the client receives multiple configure events before it
|
||||
can respond to one, it only has to ack the last configure event.
|
||||
Acking a configure event that was never sent raises an invalid_serial
|
||||
error.
|
||||
|
||||
A client is not required to commit immediately after sending
|
||||
an ack_configure request - it may even ack_configure several times
|
||||
@ -501,6 +578,17 @@
|
||||
A client may send multiple ack_configure requests before committing, but
|
||||
only the last request sent before a commit indicates which configure
|
||||
event the client really is responding to.
|
||||
|
||||
Sending an ack_configure request consumes the serial number sent with
|
||||
the request, as well as serial numbers sent by all configure events
|
||||
sent on this xdg_surface prior to the configure event referenced by
|
||||
the committed serial.
|
||||
|
||||
It is an error to issue multiple ack_configure requests referencing a
|
||||
serial from the same configure event, or to issue an ack_configure
|
||||
request referencing a serial from a configure event issued before the
|
||||
event identified by the last ack_configure request for the same
|
||||
xdg_surface. Doing so will raise an invalid_serial error.
|
||||
</description>
|
||||
<arg name="serial" type="uint" summary="the serial from the configure event"/>
|
||||
</request>
|
||||
@ -526,9 +614,10 @@
|
||||
</description>
|
||||
<arg name="serial" type="uint" summary="serial of the configure event"/>
|
||||
</event>
|
||||
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_toplevel" version="2">
|
||||
<interface name="xdg_toplevel" version="6">
|
||||
<description summary="toplevel surface">
|
||||
This interface defines an xdg_surface role which allows a surface to,
|
||||
among other things, set window-like properties such as maximize,
|
||||
@ -540,7 +629,11 @@
|
||||
by the compositor until it is explicitly mapped again.
|
||||
All active operations (e.g., move, resize) are canceled and all
|
||||
attributes (e.g. title, state, stacking, ...) are discarded for
|
||||
an xdg_toplevel surface when it is unmapped.
|
||||
an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to
|
||||
the state it had right after xdg_surface.get_toplevel. The client
|
||||
can re-map the toplevel by perfoming a commit without any buffer
|
||||
attached, waiting for a configure event and handling it as usual (see
|
||||
xdg_surface description).
|
||||
|
||||
Attaching a null buffer to a toplevel unmaps the surface.
|
||||
</description>
|
||||
@ -552,24 +645,37 @@
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_resize_edge" value="0" summary="provided value is
|
||||
not a valid variant of the resize_edge enum"/>
|
||||
<entry name="invalid_parent" value="1"
|
||||
summary="invalid parent toplevel"/>
|
||||
<entry name="invalid_size" value="2"
|
||||
summary="client provided an invalid min or max size"/>
|
||||
</enum>
|
||||
|
||||
<request name="set_parent">
|
||||
<description summary="set the parent of this surface">
|
||||
Set the "parent" of this surface. This surface should be stacked
|
||||
above the parent surface and all other ancestor surfaces.
|
||||
|
||||
Parent windows should be set on dialogs, toolboxes, or other
|
||||
Parent surfaces should be set on dialogs, toolboxes, or other
|
||||
"auxiliary" surfaces, so that the parent is raised when the dialog
|
||||
is raised.
|
||||
|
||||
Setting a null parent for a child window removes any parent-child
|
||||
relationship for the child. Setting a null parent for a window which
|
||||
currently has no parent is a no-op.
|
||||
Setting a null parent for a child surface unsets its parent. Setting
|
||||
a null parent for a surface which currently has no parent is a no-op.
|
||||
|
||||
If the parent is unmapped then its children are managed as
|
||||
though the parent of the now-unmapped parent has become the
|
||||
parent of this surface. If no parent exists for the now-unmapped
|
||||
parent then the children are managed as though they have no
|
||||
parent surface.
|
||||
Only mapped surfaces can have child surfaces. Setting a parent which
|
||||
is not mapped is equivalent to setting a null parent. If a surface
|
||||
becomes unmapped, its children's parent is set to the parent of
|
||||
the now-unmapped surface. If the now-unmapped surface has no parent,
|
||||
its children's parent is unset. If the now-unmapped surface becomes
|
||||
mapped again, its parent-child relationship is not restored.
|
||||
|
||||
The parent toplevel must not be one of the child toplevel's
|
||||
descendants, and the parent must be different from the child toplevel,
|
||||
otherwise the invalid_parent protocol error is raised.
|
||||
</description>
|
||||
<arg name="parent" type="object" interface="xdg_toplevel" allow-null="true"/>
|
||||
</request>
|
||||
@ -604,11 +710,14 @@
|
||||
For example, "org.freedesktop.FooViewer" where the .desktop file is
|
||||
"org.freedesktop.FooViewer.desktop".
|
||||
|
||||
Like other properties, a set_app_id request can be sent after the
|
||||
xdg_toplevel has been mapped to update the property.
|
||||
|
||||
See the desktop-entry specification [0] for more details on
|
||||
application identifiers and how they relate to well-known D-Bus
|
||||
names and .desktop files.
|
||||
|
||||
[0] http://standards.freedesktop.org/desktop-entry-spec/
|
||||
[0] https://standards.freedesktop.org/desktop-entry-spec/
|
||||
</description>
|
||||
<arg name="app_id" type="string"/>
|
||||
</request>
|
||||
@ -622,7 +731,8 @@
|
||||
This request asks the compositor to pop up such a window menu at
|
||||
the given position, relative to the local surface coordinates of
|
||||
the parent surface. There are no guarantees as to what menu items
|
||||
the window menu contains.
|
||||
the window menu contains, or even if a window menu will be drawn
|
||||
at all.
|
||||
|
||||
This request must be used in response to some sort of user action
|
||||
like a button press, key press, or touch down event.
|
||||
@ -698,16 +808,17 @@
|
||||
guarantee that the device focus will return when the resize is
|
||||
completed.
|
||||
|
||||
The edges parameter specifies how the surface should be resized,
|
||||
and is one of the values of the resize_edge enum. The compositor
|
||||
may use this information to update the surface position for
|
||||
example when dragging the top left corner. The compositor may also
|
||||
use this information to adapt its behavior, e.g. choose an
|
||||
appropriate cursor image.
|
||||
The edges parameter specifies how the surface should be resized, and
|
||||
is one of the values of the resize_edge enum. Values not matching
|
||||
a variant of the enum will cause the invalid_resize_edge protocol error.
|
||||
The compositor may use this information to update the surface position
|
||||
for example when dragging the top left corner. The compositor may also
|
||||
use this information to adapt its behavior, e.g. choose an appropriate
|
||||
cursor image.
|
||||
</description>
|
||||
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
|
||||
<arg name="serial" type="uint" summary="the serial of the user event"/>
|
||||
<arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
|
||||
<arg name="edges" type="uint" enum="resize_edge" summary="which edge or corner is being dragged"/>
|
||||
</request>
|
||||
|
||||
<enum name="state">
|
||||
@ -723,7 +834,8 @@
|
||||
<entry name="maximized" value="1" summary="the surface is maximized">
|
||||
<description summary="the surface is maximized">
|
||||
The surface is maximized. The window geometry specified in the configure
|
||||
event must be obeyed by the client.
|
||||
event must be obeyed by the client, or the xdg_wm_base.invalid_surface_state
|
||||
error is raised.
|
||||
|
||||
The client should draw without shadow or other
|
||||
decoration outside of the window geometry.
|
||||
@ -754,29 +866,36 @@
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="tiled_left" value="5" since="2">
|
||||
<description summary="the surface is tiled">
|
||||
<description summary="the surface’s left edge is tiled">
|
||||
The window is currently in a tiled layout and the left edge is
|
||||
considered to be adjacent to another part of the tiling grid.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="tiled_right" value="6" since="2">
|
||||
<description summary="the surface is tiled">
|
||||
<description summary="the surface’s right edge is tiled">
|
||||
The window is currently in a tiled layout and the right edge is
|
||||
considered to be adjacent to another part of the tiling grid.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="tiled_top" value="7" since="2">
|
||||
<description summary="the surface is tiled">
|
||||
<description summary="the surface’s top edge is tiled">
|
||||
The window is currently in a tiled layout and the top edge is
|
||||
considered to be adjacent to another part of the tiling grid.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="tiled_bottom" value="8" since="2">
|
||||
<description summary="the surface is tiled">
|
||||
<description summary="the surface’s bottom edge is tiled">
|
||||
The window is currently in a tiled layout and the bottom edge is
|
||||
considered to be adjacent to another part of the tiling grid.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="suspended" value="9" since="6">
|
||||
<description summary="surface repaint is suspended">
|
||||
The surface is currently not ordinarily being repainted; for
|
||||
example because its content is occluded by another window, or its
|
||||
outputs are switched off due to screen locking.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<request name="set_max_size">
|
||||
@ -810,11 +929,11 @@
|
||||
request.
|
||||
|
||||
Requesting a maximum size to be smaller than the minimum size of
|
||||
a surface is illegal and will result in a protocol error.
|
||||
a surface is illegal and will result in an invalid_size error.
|
||||
|
||||
The width and height must be greater than or equal to zero. Using
|
||||
strictly negative values for width and height will result in a
|
||||
protocol error.
|
||||
strictly negative values for width or height will result in a
|
||||
invalid_size error.
|
||||
</description>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
@ -851,11 +970,11 @@
|
||||
request.
|
||||
|
||||
Requesting a minimum size to be larger than the maximum size of
|
||||
a surface is illegal and will result in a protocol error.
|
||||
a surface is illegal and will result in an invalid_size error.
|
||||
|
||||
The width and height must be greater than or equal to zero. Using
|
||||
strictly negative values for width and height will result in a
|
||||
protocol error.
|
||||
invalid_size error.
|
||||
</description>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
@ -1014,9 +1133,68 @@
|
||||
a dialog to ask the user to save their data, etc.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 4 additions -->
|
||||
|
||||
<event name="configure_bounds" since="4">
|
||||
<description summary="recommended window geometry bounds">
|
||||
The configure_bounds event may be sent prior to a xdg_toplevel.configure
|
||||
event to communicate the bounds a window geometry size is recommended
|
||||
to constrain to.
|
||||
|
||||
The passed width and height are in surface coordinate space. If width
|
||||
and height are 0, it means bounds is unknown and equivalent to as if no
|
||||
configure_bounds event was ever sent for this surface.
|
||||
|
||||
The bounds can for example correspond to the size of a monitor excluding
|
||||
any panels or other shell components, so that a surface isn't created in
|
||||
a way that it cannot fit.
|
||||
|
||||
The bounds may change at any point, and in such a case, a new
|
||||
xdg_toplevel.configure_bounds will be sent, followed by
|
||||
xdg_toplevel.configure and xdg_surface.configure.
|
||||
</description>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 5 additions -->
|
||||
|
||||
<enum name="wm_capabilities" since="5">
|
||||
<entry name="window_menu" value="1" summary="show_window_menu is available"/>
|
||||
<entry name="maximize" value="2" summary="set_maximized and unset_maximized are available"/>
|
||||
<entry name="fullscreen" value="3" summary="set_fullscreen and unset_fullscreen are available"/>
|
||||
<entry name="minimize" value="4" summary="set_minimized is available"/>
|
||||
</enum>
|
||||
|
||||
<event name="wm_capabilities" since="5">
|
||||
<description summary="compositor capabilities">
|
||||
This event advertises the capabilities supported by the compositor. If
|
||||
a capability isn't supported, clients should hide or disable the UI
|
||||
elements that expose this functionality. For instance, if the
|
||||
compositor doesn't advertise support for minimized toplevels, a button
|
||||
triggering the set_minimized request should not be displayed.
|
||||
|
||||
The compositor will ignore requests it doesn't support. For instance,
|
||||
a compositor which doesn't advertise support for minimized will ignore
|
||||
set_minimized requests.
|
||||
|
||||
Compositors must send this event once before the first
|
||||
xdg_surface.configure event. When the capabilities change, compositors
|
||||
must send this event again and then send an xdg_surface.configure
|
||||
event.
|
||||
|
||||
The configured state should not be applied immediately. See
|
||||
xdg_surface.configure for details.
|
||||
|
||||
The capabilities are sent as an array of 32-bit unsigned integers in
|
||||
native endianness.
|
||||
</description>
|
||||
<arg name="capabilities" type="array" summary="array of 32-bit capabilities"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="xdg_popup" version="2">
|
||||
<interface name="xdg_popup" version="6">
|
||||
<description summary="short-lived, popup surfaces for menus">
|
||||
A popup surface is a short-lived, temporary surface. It can be used to
|
||||
implement for example menus, popovers, tooltips and other similar user
|
||||
@ -1040,12 +1218,6 @@
|
||||
The parent of an xdg_popup must be mapped (see the xdg_surface
|
||||
description) before the xdg_popup itself.
|
||||
|
||||
The x and y arguments passed when creating the popup object specify
|
||||
where the top left of the popup should be placed, relative to the
|
||||
local surface coordinates of the parent surface. See
|
||||
xdg_surface.get_popup. An xdg_popup must intersect with or be at least
|
||||
partially adjacent to its parent surface.
|
||||
|
||||
The client must call wl_surface.commit on the corresponding wl_surface
|
||||
for the xdg_popup state to take effect.
|
||||
</description>
|
||||
@ -1060,8 +1232,8 @@
|
||||
This destroys the popup. Explicitly destroying the xdg_popup
|
||||
object will also dismiss the popup, and unmap the surface.
|
||||
|
||||
If this xdg_popup is not the "topmost" popup, a protocol error
|
||||
will be sent.
|
||||
If this xdg_popup is not the "topmost" popup, the
|
||||
xdg_wm_base.not_the_topmost_popup protocol error will be sent.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
@ -1093,10 +1265,6 @@
|
||||
nested grabbing popup as well. When a compositor dismisses popups, it
|
||||
will follow the same dismissing order as required from the client.
|
||||
|
||||
The parent of a grabbing popup must either be another xdg_popup with an
|
||||
active explicit grab, or an xdg_popup or xdg_toplevel, if there are no
|
||||
explicit grabs already taken.
|
||||
|
||||
If the topmost grabbing popup is destroyed, the grab will be returned to
|
||||
the parent of the popup, if that parent previously had an explicit grab.
|
||||
|
||||
@ -1123,6 +1291,11 @@
|
||||
The x and y arguments represent the position the popup was placed at
|
||||
given the xdg_positioner rule, relative to the upper left corner of the
|
||||
window geometry of the parent surface.
|
||||
|
||||
For version 2 or older, the configure event for an xdg_popup is only
|
||||
ever sent once for the initial configuration. Starting with version 3,
|
||||
it may be sent again if the popup is setup with an xdg_positioner with
|
||||
set_reactive requested, or in response to xdg_popup.reposition requests.
|
||||
</description>
|
||||
<arg name="x" type="int"
|
||||
summary="x position relative to parent surface window geometry"/>
|
||||
@ -1140,5 +1313,58 @@
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="reposition" since="3">
|
||||
<description summary="recalculate the popup's location">
|
||||
Reposition an already-mapped popup. The popup will be placed given the
|
||||
details in the passed xdg_positioner object, and a
|
||||
xdg_popup.repositioned followed by xdg_popup.configure and
|
||||
xdg_surface.configure will be emitted in response. Any parameters set
|
||||
by the previous positioner will be discarded.
|
||||
|
||||
The passed token will be sent in the corresponding
|
||||
xdg_popup.repositioned event. The new popup position will not take
|
||||
effect until the corresponding configure event is acknowledged by the
|
||||
client. See xdg_popup.repositioned for details. The token itself is
|
||||
opaque, and has no other special meaning.
|
||||
|
||||
If multiple reposition requests are sent, the compositor may skip all
|
||||
but the last one.
|
||||
|
||||
If the popup is repositioned in response to a configure event for its
|
||||
parent, the client should send an xdg_positioner.set_parent_configure
|
||||
and possibly an xdg_positioner.set_parent_size request to allow the
|
||||
compositor to properly constrain the popup.
|
||||
|
||||
If the popup is repositioned together with a parent that is being
|
||||
resized, but not in response to a configure event, the client should
|
||||
send an xdg_positioner.set_parent_size request.
|
||||
</description>
|
||||
<arg name="positioner" type="object" interface="xdg_positioner"/>
|
||||
<arg name="token" type="uint" summary="reposition request token"/>
|
||||
</request>
|
||||
|
||||
<event name="repositioned" since="3">
|
||||
<description summary="signal the completion of a repositioned request">
|
||||
The repositioned event is sent as part of a popup configuration
|
||||
sequence, together with xdg_popup.configure and lastly
|
||||
xdg_surface.configure to notify the completion of a reposition request.
|
||||
|
||||
The repositioned event is to notify about the completion of a
|
||||
xdg_popup.reposition request. The token argument is the token passed
|
||||
in the xdg_popup.reposition request.
|
||||
|
||||
Immediately after this event is emitted, xdg_popup.configure and
|
||||
xdg_surface.configure will be sent with the updated size and position,
|
||||
as well as a new configure serial.
|
||||
|
||||
The client should optionally update the content of the popup, but must
|
||||
acknowledge the new popup configuration for the new position to take
|
||||
effect. See xdg_surface.ack_configure for details.
|
||||
</description>
|
||||
<arg name="token" type="uint" summary="reposition request token"/>
|
||||
</event>
|
||||
|
||||
</interface>
|
||||
</protocol>
|
||||
|
@ -6,7 +6,8 @@
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
randname(char *buf) {
|
||||
randname(char *buf)
|
||||
{
|
||||
struct timespec ts;
|
||||
long r;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
@ -18,7 +19,8 @@ randname(char *buf) {
|
||||
}
|
||||
|
||||
static int
|
||||
create_shm_file(void) {
|
||||
create_shm_file(void)
|
||||
{
|
||||
int retries = 100;
|
||||
int fd;
|
||||
do {
|
||||
@ -35,7 +37,8 @@ create_shm_file(void) {
|
||||
}
|
||||
|
||||
int
|
||||
allocate_shm_file(size_t size) {
|
||||
allocate_shm_file(size_t size)
|
||||
{
|
||||
int fd = create_shm_file();
|
||||
int ret;
|
||||
if (fd < 0)
|
||||
|
Reference in New Issue
Block a user