Commit Graph

66 Commits

Author SHA1 Message Date
Daniel Stone 9ced4a4f3a weston-keyboard: Create input_panel_surface earlier
If we only create the input_panel_surface after we've already created
the window and tried to get some content for it, then we're never going
to enter the input_panel_surface committed handler, so we'll never get
the chance to properly map the surface.

Follow the other surface types by creating the input-panel surface
before we try to attach anything to it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: bdf2019e ("desktop-shell: Map input panel surfaces before views")
2023-11-21 13:30:51 +00:00
Aske Bækdal Møller 33ec3898d0 clients: keyboard: fix delete before cursor
When editing a text field in chromium deleting the surrounding text with
backspace fails with `The selection range for surrounding text is invalid`

It seems like `(start - keyboard->surrounding_text) - keyboard->surrounding_cursor` evaluates to -1.

As far as i can tell `start - keyboard->surrounding_text` evaluates to
the index in the surrounding_text char arrays that should be deleted.

Signed-off-by: Aske Bækdal Møller <aske@geanix.com>
2023-11-13 17:03:47 +02:00
Marius Vlad b3544c26ad clients/window: Add functions to set/retrieve app_id
Adds appid for all clients using the toolkit, flower, fullscreen, image,
resizor, scaler, smoke, stacking, subsurfaces, terminal,
touch-calibrator, transformed, etc.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Alyssa Ross 7c12182576 clients: don't use deprecated fontconfig aliases
The "sans" and "mono" aliases for "sans-serif" and "monospace" are
deprecated[1].  Let's standardize on the non-deprecated versions, which were
already in use in some places.

[1]: be453bd159/fonts.conf.in (L33-67)

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2021-11-18 10:57:16 +02:00
Takuro Ashie 5ff978a52b weston-keyboard: Enable to set as overlay panel
input-method-v1 protocol provides two surface type for the input
panel, `toplevel` and `overlay`. But there is no example for the later
one. This change enables to set weston-keyboard as overlay panel by the
environment variable `WESTON_KEYBOARD_SURFACE_TYPE=overlay` to
demonstrate this feature. In Addition, add weston.ini option
`overlay-keyboard` to set it.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
2021-10-14 21:17:07 +09:00
Pekka Paalanen 497d03edbf clients/keyboard: free input_panel_surface
Fixes ASan leak:

Direct leak of 80 byte(s) in 1 object(s) allocated from:
    #0 0x7fe7791f4518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
    #1 0x7fe779100892 in zalloc ../../git/wayland/src/wayland-private.h:232
    #2 0x7fe779100892 in proxy_create ../../git/wayland/src/wayland-client.c:422
    #3 0x7fe779100ede in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
    #4 0x7fe779100ede in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
    #5 0x7fe779101226 in wl_proxy_marshal_constructor ../../git/wayland/src/wayland-client.c:834
    #6 0x56428c9bc578 in zwp_input_panel_v1_get_input_panel_surface protocol/input-method-unstable-v1-client-protocol.h:678
    #7 0x56428c9c0bbb in set_toplevel ../../git/weston/clients/keyboard.c:965
    #8 0x56428c9c0c8d in display_output_handler ../../git/weston/clients/keyboard.c:980
    #9 0x56428c9ddead in display_handle_mode ../../git/weston/clients/window.c:5700
    #10 0x7fe7786668ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
    #11 0x7fe7786662be in ffi_call (/lib/x86_64-linux-gnu/libffi.so.6+0x62be)
    #12 0x7fe779103fac in wl_closure_invoke ../../git/wayland/src/connection.c:1018
    #13 0x7fe779100a48 in dispatch_event ../../git/wayland/src/wayland-client.c:1452
    #14 0x7fe779101e43 in dispatch_queue ../../git/wayland/src/wayland-client.c:1598
    #15 0x7fe779101e43 in wl_display_dispatch_queue_pending ../../git/wayland/src/wayland-client.c:1840
    #16 0x56428c9e031c in handle_display_data ../../git/weston/clients/window.c:6211
    #17 0x56428c9e2147 in display_run ../../git/weston/clients/window.c:6553
    #18 0x56428c9c1559 in main ../../git/weston/clients/keyboard.c:1053
    #19 0x7fe77885e09a in __libc_start_main ../csu/libc-start.c:308
    #20 0x56428c9bc029 in _start (/home/pq/build/weston-meson/clients/weston-keyboard+0x19029)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Pekka Paalanen d9b949d8b9 keyboard: free stuff on exit
This fixes a bunch of leaks when trying to run a Weston test with
desktop-shell, which spawns weston-keyboard.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-05-31 12:35:01 +03:00
Antonio Borneo 3957863667 log: remove "%m" from format strings by using strerror(errno)
The printf() format specifier "%m" is a glibc extension to print
the string returned by strerror(errno). While supported by other
libraries (e.g. uClibc and musl), it is not widely portable.

In Weston code the format string is often passed to a logging
function that calls other syscalls before the conversion of "%m"
takes place. If one of such syscall modifies the value in errno,
the conversion of "%m" will incorrectly report the error string
corresponding to the new value of errno.

Remove all the occurrences of the specifier "%m" in Weston code
by using directly the string returned by strerror(errno).
While there, fix some minor indentation issue.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-05-02 22:10:30 +02:00
Marius Vlad 0161802aa0 Fix compiler warning: unused variable when building with DEBUG
clients/keyboard.c: In function 'dbg':
clients/keyboard.c:276:6: warning: variable 'l' set but not used [-Wunused-but-set-variable]
  int l;

Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
2018-12-15 18:37:57 +02:00
Jussi Kukkonen 649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Armin Krezović ea0316a54c keyboard: Only set toplevel when there is a valid output
Currently, the keyboard client is created and the input
panel surface is set as toplevel on the first output it
finds. This does not work in a scenario when there are
no outputs, resulting in weston-keyboard to crash at
startup due to operating on an invalid output pointer.

This makes input panel toplevel setting depend on a
valid output, and if there was no output present at
startup, it will be set toplevel as soon as an output
gets plugged in.

v2:

- Remove dependency on output pointer at startup
- Only setup output_configure_handler after the
  keyboard has been created
- Let the output_configure_handler handle toplevel
  setting in all cases

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: fixed a line break]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-06-27 14:23:05 +03:00
Bryce Harrington e99e4bf2b9 clients & tests: Unify multiple definitions of x*alloc and related functions
Direct fail_on_null calls now produce output like:

    [weston-info] clients/weston-info.c:714: out of memory

xmalloc, et al produce output on failure like:

    [weston-info] out of memory (-1)

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-03-17 14:13:13 +02:00
Jonas Ådahl b57f472c84 Use input method protocol from wayland-protocols
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Jan Arne Petersen <janarne@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-11-19 13:17:59 +02:00
Jonas Ådahl 3bcba347a2 Use text input protocol from wayland-protocols
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Jan Arne Petersen <janarne@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-11-19 13:07:10 +02:00
Bryce Harrington 1f6b0d1d2c clients: Update boilerplate from MIT X11 license to MIT Expat licenses 2015-06-15 13:04:18 -07:00
Michael Vetter 2a18a52844 remove trailing whitespaces
Remove trailing whitespaces because they are not needed and jumping to
the end of al ine should do just that and not jump to the whitespace.
2015-05-15 13:12:32 -07:00
Olivier Blin 814f0ee5a6 keyboard: do not crash when input panel is not available
[Pekka Paalanen: whitespace fix]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-17 13:52:09 +03:00
Bryce W. Harrington 762b231e0b clients: Initialize label in keyboard handling code
Quells warning:
  clients/keyboard.c: In function ‘keyboard_handle_key.isra.5’:
  clients/keyboard.c:556:11: warning: ‘label’ may be used uninitialized in
  this function [-Wuninitialized]

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2014-05-09 12:33:20 -07:00
Manuel Bachmann 301f06b894 keyboard: add the missing symbols layout, fix arabic layout
The "symbols" modifier key of weston-keyboard is no longer
inactive, but will provide an additionnal layout with
numerals and special characters.

Fix the Arabic keyboard, which was rendering out of the
bounds, and now use the Arabic IBM PC keyboard as a
reference for its standard and new symbols layouts.

https://bugs.freedesktop.org/show_bug.cgi?id=71757

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
2014-04-16 22:42:27 -07:00
Andrew Wedgbury 9cd661e746 Make sure config.h is included before any system headers
There was an issue recently in screen-share.c where config.h was not
being included, resulting in the wrong definition for off_t being used on
32 bit systems. I checked and I don't think this problem is happening
elsewhere, but to help avoid this sort of problem in the future, I went
through and made sure that config.h is included first whenever system
headers are included.

The config.h header should be included before any system headers, failing
to do this can result in the wrong type sizes being defined on certain
systems, e.g. off_t from sys/types.h

Signed-off-by: Andrew Wedgbury <andrew.wedgbury@realvnc.com>
2014-04-07 10:22:28 -07:00
Kristian Høgsberg d6d3b377f8 keyboard: Make debug output less verbose
The keyboard is too chatty, make it use a dbg() function for logging
which defaults to disabled.

Also drop a noisy fprintf() in input_panel_configure().
2014-01-09 23:58:14 -08:00
Kristian Høgsberg 700d6ad071 keyboard: Don't strcat() into a strdup()ed string
We need to reallocate the memory to hold the entire concatenated string,
but strcat() doesn't do that.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=71750
2014-01-09 23:45:18 -08:00
Kristian Høgsberg a548b4b85c keyboard: Fix insert_text() string utility
strncat() into a newly allocated buffer isn't well-defined.  I don't know
how this didn't crash all the time, getting blocks from malloc() with
a NUL in the first byte must be fairly common.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=71750
2014-01-09 23:39:20 -08:00
Kristian Høgsberg ef9c8eb2db keyboard: Handle touch up event
This fixes arrow keys which trigger on button up.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73169
2014-01-07 12:57:59 -08:00
Brian J Lovin a8e627f4f2 keyboard: Add rudimentary touch support to keyboard.
At this time there is no way to have a key be activated when
touch_up is called, so all this patch does is activate they
key on touch_down.

Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
2013-09-03 22:49:16 -07:00
Kristian Høgsberg 20ffdffc03 keyboard: Don't use next_utf8_char() to go back where we came from
We go one utf8 char back and then one forward.  Just remember the original
position instead, which also avoids a warning about potentially
dereferencing a NULL return value from next_utf8_char().
2013-08-15 11:37:14 -07:00
Peter Hutterer f3d62276d2 malloc + memset -> zalloc
And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-08 13:46:13 -07:00
Brian Lovin bc91926e0c clients: use xmalloc in more places
For the clients continue to use xmalloc() to simplify OOM-handling.

Signed-off-by: Brian Lovin <brian.j.lovin@intel.com>
2013-08-07 16:27:33 -07:00
Jan Arne Petersen d8aa3327b3 keyboard: Fix offsets when deleting text
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-06 20:26:20 -04:00
Jan Arne Petersen cc75ec11ca text: Rename input_method to wl_input_method
Also rename input_method_context to wl_input_method_context,
input_panel to wl_input_panel and input_panel_surface to
wl_input_panel_surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:18:46 -04:00
Jan Arne Petersen 62ece76b1e text: Rename text_input to wl_text_input
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:06:27 -04:00
Jan Arne Petersen 8f2f764c0c keyboard: Remove unneded calls
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:06:27 -04:00
Jan Arne Petersen 919bc149e1 text: delete text on commit_string
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 17:06:26 -04:00
Jan Arne Petersen 00191c7c4a text: Fix serial handling
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:41:48 -04:00
Jan Arne Petersen 7cd29e199a text: Add output argument to set_toplevel
Allow to specify an output for a toplevel  input panel surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:41:47 -04:00
Jan Arne Petersen 85ecaa5d75 text: Add "none" preedit-style
Use "default" preedit style as default. "None" is used when the
composing text should look like non-composing text.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:23:46 -04:00
Jan Arne Petersen 78d00e45cc text: Rename text_model to text_input
Also rename text_model_factory to text_input_manager.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:23:35 -04:00
Jan Arne Petersen b8b76a603f keyboard: Reset state on activate
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:21:52 -04:00
Jan Arne Petersen 9d41913eff text: Add example for language/text direction
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:21:34 -04:00
Jan Arne Petersen ece6b5af51 text: Add language and text-direction to protocol
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-05-02 16:21:18 -04:00
Kristian Høgsberg 4172f668e7 Pass argc pointer to parse_options()
This lets us keep argc up to date as the backend picks out arguments
from the argv array.
2013-02-20 15:27:49 -05:00
Jan Arne Petersen 1cc9e08d2f text: Split out cursor_position
Add an extra cursor_position, which also allows to change the anchor
(for slections). Change the index type to int to allow setting it before
the beginning of a commited string.

The cursor should not be moved as a direct repsonse to this event but
atomically on the next commit_string event.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:08:01 -05:00
Jan Arne Petersen 0eabcaafae text: Add commit request
Allows for atomic state changes. Updated surrounding text, content type
and micro focus is taken into account all at once at commit.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:07:03 -05:00
Jan Arne Petersen ffbb20f730 text: Move input_panel interface to input-method
Move the input_panel interface from desktop-shell to input-method (since
it is not really tied to desktop-shell).

Add an input_panel_surface interface like wl_shell_surface to make it
easier to extend it. Also add a parameter to the set_toplevel request to
be able to specify where to show an input panel surface on the screen.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:05:04 -05:00
Jan Arne Petersen 2dc3b3fc9f keyboard: add support for invoke_action
Set the pre-edit cursor on the clicked index on invoke_action.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:01:12 -05:00
Jan Arne Petersen e475f29330 keyboard: Add support for a numeric layout
Add support for a numeric key layout, which is used for some numeric
content purpose types.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 17:00:20 -05:00
Jan Arne Petersen 49a3fb3d1d keyboard: Add support for pre-edit styling
Adds a button to the keyboard to support different styles of pre-edit
styling.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 16:55:58 -05:00
Jan Arne Petersen c7d2a9839b text: add serial argument to text protocol
The serial argument will allow to ignore outdated events from before a
reset request.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 16:55:37 -05:00
Jan Arne Petersen 4653531e7a text: add pre-edit styling support to protocol
Also add a separate preedit-cursor event and add a commit argument to
preedit-string to allow to support commit on reset. Fix editor and
keyboard example to adapt to the protocol changes.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2013-02-15 16:55:27 -05:00
Jan Arne Petersen cd99706b61 text: Send more information with keysym events
Send state and modifier from the demo keyboard with the keysym event and
take them into account in the editor example.

Add some helper functions to write and read a modifiers_map array.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
2012-11-27 13:06:21 -05:00