85 Commits

Author SHA1 Message Date
Maarten van Gompel
125664afd5 use OVERLAY so keyboard is visible over fullscreen windows as well
Ref: https://github.com/jjsullivan5196/wvkbd/issues/73
2024-11-25 12:31:19 +01:00
Willow Barraco
9cc8931b46 Fix the initial output geometry guessing
wvkbd adapt its height, and layout depending on if the screen
is in landscape mode or not.

The only realiable way to know which outputs our surface is
rendered on is the wl_surface->enter(wl_output) event. But we receive
this event very late in the flow. After the first frame rendering, and
commit to the surface.

There already is some code to guess the best initial tentative, on the
most simple situations, to try to avoid an immediate re-creation of the
Wayland objects, buffer, and re-rendering of the layout.

But two issues was present:

First, we need a second roundtrip of the events, after the global
handle. This make the compositor to send the wl_outputs events earlier,
giving their geometry before our first show().

Then, the code that loop on them, if we don't already know the
current_output, was wrong. Because we changed the default state to
landscaped a while ago.

We also change how this code behave, we use the very first wl_output we
know about. Every behaviors are somehow wrong at this point, this one is
the simplest.

Now when starting wvkbd with only one screen, we don't need a second
loop anymore.

On situation where multiple screens are present, it will eventually need
a second one.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-11-05 10:14:12 +01:00
Willow Barraco
7d195c8217 Skip the first resize when landscaped while starting
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-11-02 21:27:31 +01:00
Maarten van Gompel
ba778478e6 added -R parameter to configure rounding 2024-04-15 20:38:02 +02:00
rdbo
e3081fb6e9 fixed malfunctioning theme at random 2024-04-12 22:07:35 +02:00
mojyack
8106d7606d Check if popup surf configured on callbacks
In some situations, wl_touch_* events come between layer_surface_configure and xdg_popup_surface_configure.
It causes the keyboard to be drawn before the popup surf is configured, leading to "error 3: xdg_surface has never been configured".
This commit fixes this.
2024-03-29 23:16:53 +01:00
Willow Barraco
bb237f5afa Re-open the keyboard on the same output it was
Even if the user is focusing another output while the geometry change.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-03-03 11:33:58 +01:00
Willow Barraco
b083169ee4 Minimise visual glitches when starting
Most of the time, the first frame have to be rendered without knowing
which output is the current one. It means the first window could have
incorrect dimensions. This cause other program surface to shrink,
then grow back.

Let's try a smoother approach:

If we don't know the current output, we could check if one of them is
landscaped. If this is the case, we start landscaped to minimise the
visual glitch.

Also, the compositor might choose to not send any output geometry
information before the first surface role is assigned (sway master
829c75b9). Meaning after our initial set_size request. So we have to start
landscaped, and eventually flip to horizontal.

Thanks to the patch "Skip the first resize when landscaped while
starting", we do not draw multiple time on the buffer when we switch to vertical
mode.

This should cover most of the cases, and produce a more discrete
start.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-03-01 22:54:34 +01:00
Zach DeCook
de3b9a77e4 event loop: exit if the wayland socket disappears
(prevents infinite loop when your compositor crashes)

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-01-30 18:42:17 +01:00
Maarten van Gompel
77c6cf4fe6 implemented a stub wl_surface_leave
This fixes "listener function for opcode 1 of wl_surface is NULL" error in wayfire 0.8.0

Ref: https://github.com/jjsullivan5196/wvkbd/issues/52
2023-11-10 20:27:40 +01:00
Maarten van Gompel
9f8e73b315 fixup: re-add flip_landscape() to wl_surface_enter (needed for landscape detection) 2023-11-04 14:33:30 +01:00
mojyack
0e17680041 do not refresh on wl_surface_enter
there is no need to do so, because this event is followed by layer_surface_configure.
sway-HEAD(020a572) complains "A configure is scheduled for an uninitialized xdg_surface",
but it works anyway.

fix #50
2023-11-04 14:32:04 +01:00
mojyack
2d01b8963b fix hyprland crashes when creating a surface multiple times 2023-11-03 20:47:29 +01:00
mojyack
c457d697aa optimize output iteration 2023-11-03 20:47:29 +01:00
mojyack
5471e2ea0e resize keyboard only when entered to different output
the keyboard layout is saved even when hide/show (if output is same).
this is old behavior.
2023-11-03 20:47:29 +01:00
mojyack
a126945401 handle screen resize and redraw in layer_surface_configure 2023-11-03 20:47:29 +01:00
mojyack
aa9e8ab7ab avoid using "wl_output" literal 2023-10-29 16:42:19 +01:00
Frank Oltmanns
d6439afcb9 Make font selection scheme specific
Add the members font and font_descriptor to struct clr_scheme, so that
it is possible to specify a font for each scheme.

During initialization create the font descriptors for each scheme.

Instead of initially setting the font descriptor when setting up the
buffer, set the font descriptor when drawing the text.

Signed-off-by: Frank Oltmanns <frank@oltmanns.dev>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-10-29 13:07:57 +01:00
Frank Oltmanns
6e52be343d Add support for multiple schemes
Allow to use more than two color schemes.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-10-13 21:20:18 +02:00
Maarten van Gompel
aaff22a105 set preferred scale default to 1
Ref: https://github.com/jjsullivan5196/wvkbd/issues/43
2023-09-22 18:42:27 +02:00
Einar Arnason
ab56a2748b Add missing include 2023-09-18 17:14:04 +02:00
Willow Barraco
02027621af
Cleanups
This cleanup a bit how we store and use the preferred_scale and
preferred_fractional_scale.

This rename some methods to make their behavior more explicit.
2023-09-18 12:13:43 +02:00
Willow Barraco
63c209ec7f
Regression fix: keyboard didn't re-show on SIGUSR2 anymore
When triggering show() on kill USR2, everything works as expected, but
the keyboard attributes are the same as before. So in
layer_surface_configure, we don't match the condition.

Checking hidden, and resetting it from inside this scope is enough to
solve the problem.
2023-09-18 12:13:34 +02:00
Willow Barraco
76b64f6a85
Fix builds 2023-09-08 23:26:42 +02:00
Willow Barraco
a152fd036f
Break on function definitions 2023-09-08 23:14:40 +02:00
Willow Barraco
fbbf563d70
Simplest clang-format 2023-09-08 22:57:14 +02:00
Willow Barraco
2747980a4e
clang-format 2023-09-08 22:42:49 +02:00
Willow Barraco
34d6ce5566 Cleanup output management
The goal is to minimize startup redraws.

It looks like the surface must enter the output for us to finaly know
which one it is. We need this to use the correct scale value. It make
the surface to be blurry at first, but I can not find a better way.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-09-08 21:17:36 +02:00
Willow Barraco
730e97038c Support fractional-scale-v1
This make text less blurry. It continues to works without.

before:
https://dav.missbanal.net/00bd0fd5-e22f-4a60-87f8-ce6f400d33c9.png

after:
https://dav.missbanal.net/a3f02f1e-d6ce-4378-a141-e2093ba87eed.png
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-09-08 21:17:31 +02:00
mojyack
50296daa46 fix missing initializations in previous commit
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-09-06 23:19:31 +02:00
mojyack
21045044ba fix seat_handle_capabilities
seat_handle_capabilities may be called more than once with different caps.
In the current implementation, wl_{pointer,touch}_add_listener can be
called multiple times for the same seat, causing the buttons to be pressed
more than once in a single tap.
This commit implements seat_handle_capabilities correctly and
avoids setting duplicate handlers, and also handles the removal of capabilities.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2023-09-06 23:19:31 +02:00
Willow Barraco
24e354ce9e
Add popup to display pressed keys 2023-09-06 15:29:07 +02:00
Willow Barraco
b1890848d5
Remove surface commits where it is unecessary and wrong 2023-09-06 14:25:40 +02:00
Willow Barraco
db44029d87
Add --alpha to configure all alpha color values 2023-08-31 11:41:20 +02:00
Maarten van Gompel
bfcd3527dd scroll wheel switches layers (as opposed to crashing as it did before) 2023-08-31 11:39:17 +02:00
Maarten van Gompel
2e476c6548 Made 'full' and 'simple' layouts less prone to mistyping and improved layout switching
- The full layout now squashes less keys in a row, to accomplish this
  the semicolon/colon, equal/plus and alt keys had to be sacrificed
  from the full layout (they're on the special/symbols layout still).
- The half-keys in the simple layout are removed, giving a bit more
  space.
- The default total keyboard height has been slightly enlarged (10px)
- The compose key moved down, it was too close to the 'a' (accidental
  presses). The tab key moved to the top-right.
- The spacing between the buttons is slightly larger (aesthetic only)
- The key for layer switching is now labelled more consistently with an icon, and indicates direction of switching with an arrow
- An extra "index" layout was added that can be activated by pressing
  Compose + the next/prev layout button. It has a key for each layout,
  even those not specified at start. This special layout does not appear
  in the normal layer cycling.
- The "Abc" key on secondary layers returns to the last alphabetical layout
- The compose layouts automatically hide when the user presses the space
  where there are no keys, no need to explicitly press the "Abc" key.
2023-08-31 11:39:17 +02:00
Maarten van Gompel
b6ec34fe3a fix scaling problem from "support multiple outputs" 2023-08-27 12:12:03 +02:00
mojyack
79797fc837 support multiple outputs 2023-08-26 12:48:45 +02:00
Patrick Steinhardt
9bbc8d4a99 main: Allow user to override layers in landscape mode
Add a new parameter `--landscape-layers` as well as an environment
variable `WVKBD_LANDSCAPE_LAYERS` that allows the user to override the
default set of layers in landscape mode. This complements the existing
`-l` parameter and `WVKBD_LAYERS` environment variable, which do the
equivalent for non-landscape mode.

Furthermore, add documentation for the new switch. Move the `-l`
parameter to the bottom so we don't have to realign all parameters and
so all layer-related parameters are grouped together.
2022-10-07 21:02:29 +02:00
Emmanuel LE TRONG
acf38cf46e Add a --list-layers option
To get a list of available layers for the -l option.

Signed-off-by: Emmanuel LE TRONG <emmanuel.le-trong@cnrs-orleans.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-08-16 17:29:50 +02:00
Maarten van Gompel
f446bf9147 fixup: code indentation fixes after last patch 2022-07-27 18:39:11 +02:00
Ghassan Alduraibi
e29b029308 add: args to customize keyboard colors (takes rrggbb or rrggbbaa values) add: function to set keyboard colors from rrggbb or rrggbbaa values fix: handle empty font arg
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-27 18:30:11 +02:00
Zach DeCook
0cd0d5e1a1 layout: Implement spacing better
to no longer need overscan

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-10 22:52:22 +02:00
ArenM
1843e60a74 only commit surface when it changed
Previously wvkbd would commit an (usually) unchanged surface at the
framerate of the compositor, this only commits the buffer when we render
something new.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 22:13:21 +02:00
ArenM
a2cacb7e25 use signalfd instead of signal
Switch to using signalfds because using the signal syscall was causing
problems without the frame callbacks (the change in the next commit), I
think this is because it would end up with multiple tasks polling the
same wayland file descriptor.

Previously this would exit after the second SIGPIPE signal. I checked
with earboxer on irc, and confirmed that handling all occurrences is the
correct behavior.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 22:12:54 +02:00
ArenM
dbe1e01fe9 call show instead of duplicating in startshidden check
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 22:12:48 +02:00
ArenM
c1b95f2700 reset layer index on rotation
If there are more layers in one orientation than the other this can
cause wvkbd to overshoot the end of the layer list when switching
layers. It also means that switching layers after rotating will jump to
the next layer in the list, which is somewhat unexpected.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 18:08:14 +02:00
ArenM
9d6696fb23 call kbd_resize when showing
Since layer_surface_configure was changed to only call kbd_resize when
an output dimension changed, kbd_resize doesn't get called if the
keyboard was hidden and is being shown again, meaning it doesn't tell
the compositor about the scale.

This causes it to only output the top-right quarter of the keybaord
stretched to the entire window size after a SIGUSR1 + SIGUSR2 cycle with
the display scale set to 2.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 18:08:06 +02:00
ArenM
f540cf36fa Use output dimensions to detect landscape mode
Most displays are in landscape mode by default, so checking to see if
it's rotated will produce the exact opposite of the expected results.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-07-05 18:08:02 +02:00
Zach DeCook
22ff01fb8b Keyboard: Avoid unnecessary resizes
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2022-06-25 15:19:33 +02:00