summaryrefslogtreecommitdiff
path: root/gtk/gtkimcontextwayland.c
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate gtk_widget_translate_coordinatesMatthias Clasen2023-03-251-9/+10
| | | | | | | Update all (non-deprecated) callers to use gtk_widget_compute_point instead. Fixes: #5697
* Merge branch 'wip/gtk4-fix-delete-surrounding' into 'main'Matthias Clasen2022-12-201-2/+12
|\ | | | | | | | | gtkimcontextwayland: Convert byte based offset to char based offset in delete_surrounding_text See merge request GNOME/gtk!5254
| * gtkimcontextwayland: Convert byte based offset to char based offset in ↵Alynx Zhou2022-12-201-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | delete_surrounding_text ClutterInputFocus/GtkIMContext uses char based offset for delete_surrounding, however, text_input_v3 uses byte based offset for it. Currently only GTK with mutter can work correctly via text_input_v3 because they both forget to convert between char based offset and byte based offset. This commit fixes it in GTK by converting byte based offset to char based offset with the UTF-8 encoded surrounding text. Fixes <https://gitlab.gnome.org/GNOME/gtk/-/issues/4566>.
* | imcontextwayland: Set up OSK activation gesture on non text widgetsCarlos Garnacho2022-11-281-16/+6
| | | | | | | | | | | | | | | | | | | | With GtkText and GtkTextView (and in extension, all their subclasses) handling OSK activation activation, this gesture is only useful for all text input widgets that are not subclasses of these 2 widgets, e.g. the VTEs and crosswords of the world. These still do need a hand in handling OSK activation, so only set up the gesture for such cases.
* | imcontextwayland: Implement activate_osk() vmethodCarlos Garnacho2022-11-281-0/+15
|/ | | | | | This method does explicitly what the builtin GtkClickGesture in the IM context is doing implicitly. The gesture will be dropped after porting is done.
* Merge branch 'wip/carlosg/shuffle-reset-take2' into 'main'Matthias Clasen2022-09-281-3/+20
|\ | | | | | | | | | | | | gtkimcontextwayland: Shuffle full resets after IM changes Closes #5200 See merge request GNOME/gtk!5050
| * gtkimcontextwayland: Shuffle full resets after IM changesCarlos Garnacho2022-09-241-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Doing reset() on the text widgets after commit and delete_surrounding is still too eager for some IMs (e.g. those that expect being able to commit text while keeping a preedit buffer shown). However, reset() is more of a "synchronize state" action on Wayland, and it is still desirable to do that after changes that do come from the IM (e.g. requesting the new surrounding text and cursor/anchor positions). Notably here, the text_input protocol may still come up with a preedit string after this state synchronization happens. Shuffle the code so that the text widgets do not reset() the IM context after text is deleted or committed, but the Wayland IM does apply its practical effects after these actions happen. This keeps the Wayland IM fully up-to-date wrt text widget state, while not altering the ::commit and ::delete-surrounding-text behavior for other IM context implementations. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5200 Fixes: 5b78fe2721 (gtktextview: Also reset IM context after IM...) Fixes: 7c0a395ff9 (gtktext: Also reset IM context after IM...) Fixes: 52ac71b972 (gtktextview: Shuffle the places doing IM reset) Fixes: 9e29739e66 (gtktext: Shuffle the places doing IM reset)
* | Drop gtkintl.hMatthias Clasen2022-09-241-1/+0
|/ | | | | Include gtkprivate.h for I_() and glib-i18n.h for gettext macros.
* Use gtk_event_controller_set_static_nameMatthias Clasen2022-08-271-1/+1
| | | | This avoids strdups.
* gtkimcontextwayland: Refactor handling of client updatesCarlos Garnacho2022-08-181-24/+34
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, the wayland IM context sends zwp_text_input_v3.commit from a number of places, and some of them with partial data. In order to make client state updates "atomic" and complete, make the communication happen over an unified notify_im_change() function that happens on a narrower set of circumstances: - The GtkIMContext is reset - The GtkIMContext is just focused - The gesture to invoke the OSK is triggered - The IM context is reacting to changes coming from the compositor Notably, setting the cursor location or the surrounding text do not try to commit state on their own, and now will be flushed with the corresponding IM update or reset. But also, these requests won't be prevented from happening individually on serial mismatch, instead it will be the whole state commit which is held off. With these changes in place, all client-side updates are notified atomically to the compositor under a single .commit request. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5106 Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5105
* imcontextwayland: Ignore preedit updates from NULL to NULLCarlos Garnacho2022-04-261-0/+3
| | | | | | | If we get consecutive preedit string updates that announce a NULL string, we still do end up issuing ::preedit-changed with those. Ignore changes from NULL to NULL, it is the other combinations which must issue this signal.
* imwayland: Do not defer commit() after set_surrounding_text()Carlos Garnacho2022-04-061-5/+8
| | | | | | | | | | | | | | | | For reasons that only apply to the old serial handling, asking for the surrounding after IM changes resulted in lazy handling of commit() afterwards. With the recent interpretation of serials, this problem became more apparent, since it is in fact very likely that the last interaction step after an IM change is notifying of the changed surrounding text after the IM change was applied. Make handling of surrounding text similar to caret position changes, always commit() after the state change, but skip through non-changes. This makes the compositor state fully up-to-date after an IM change.
* imwayland: Connect OSK activating gesture to parent widget on editablesCarlos Garnacho2022-04-061-3/+20
| | | | | | | | | | | | The gesture as connected currently on the child GtkText is easily overridden by the parent editables (and gently done so in the attempt to consume all clicks). Connect this gesture to the parent editable widget in these cases, so the gesture can cohabit with the click-consuming one. It's not part of the same group, but it won't be abruptly cancelled. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4795
* Merge branch 'wip/carlosg/im-wayland-serials' into 'main'Carlos Garnacho2022-03-161-11/+17
|\ | | | | | | | | | | | | gtk/imwayland: Use serial to control outbound messages Closes #3641 See merge request GNOME/gtk!4398
| * gtk/imwayland: Use serial to control outbound messagesCarlos Garnacho2022-03-161-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | Following the text-input protocol changes at https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/115, use the serial number to have the client push changes to the zwp_text_input_v3 object only after compositor/client states match. This specifically is more lenient to compositors pushing multiple .done events ahead of the client replying to them. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3641
* | gtkimcontextwayland: Add native surface offset to input coordinatesCarlos Garnacho2022-03-161-3/+6
|/ | | | | | | | We were missing the surface offset (e.g. shadows) at the time of expressing the text caret location in surface coordinates. Add this offset so the coordinates are as expected by the compositor. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4668
* gtkimcontextwayland: Save context even when text_input isn't around yetGuido Günther2022-01-191-1/+2
| | | | | | | | | | | | | | | Remember the current context on focus-in even though the text-input isn't set up yet. This helps in the case where the text-input is not yet created but a widget already got focused. Without that the enable() invocation in text_input_enter() woulnd't be invoked leaving the input method disabled. This fixes gtk4-demo --run=search_entry which would initially not show the on-screen keyboard when e.g using phoc/sway as compositor.
* gtkimcontextwayland: Set a higher IO extension priorityCarlos Garnacho2021-12-041-1/+1
| | | | | | | | We want this to take precedence in the wayland platform to other modules that might be loaded via the IO extension point. None of those is going to bode well in this platform. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4443
* Revert "imwayland: Tweak preedit text"Matthias Clasen2021-08-241-38/+4
| | | | | | | | This reverts commit d84a028455cadbf146e4cd234f57dc1df2e69cd6. IBus uses the same character now. Fixes: #4123
* imwayland: Name event controllersMatthias Clasen2021-04-021-0/+1
| | | | This helps with debugging.
* imwayland: Pass anchor with surroundingMatthias Clasen2021-03-041-6/+8
| | | | | | This was missing in the initial implementation since GtkIMContext did not have it in its api, but it was added now, so we can send the information.
* imwayland: Be careful about cursor positionsMatthias Clasen2021-02-181-4/+6
| | | | | | We don't want to hand out cursor positions based on the original preedit text and then tweak the text to be different.
* imwayland: Tweak preedit textunintrusive-compose-preeditMatthias Clasen2021-02-181-1/+33
| | | | | | | Tweak the preedit text we get from IBus (via the compositor) to match what GtkIMContextSimple produces for Compose sequences now. This provides a unified experience.
* imwayland: Return limited preedit attributesMatthias Clasen2021-02-171-4/+14
| | | | | | It should not matter, but it is the right thing to do to limit the preedit attributes to the length of the preedit text.
* imcontext: Enable font fallback for preeditMatthias Clasen2021-02-171-0/+3
| | | | | | Not doing so only invites hexboxes. Fixes: #3678
* dragsource: Use double coordinates for checking drag thresholdAlexander Mikhaylenko2021-01-291-4/+5
| | | | | | | | | | | | | | | | | | If multiple nested widgets have drag sources on them, both using bubble phase, we need to reliably pick the inner one. Both of them will try to start dragging, and we need to make sure there are no situations where the outer widget starts drag earlier and cancels the inner one. Currently, this can easily happen via integer rounding: start and current coordinates passed into gtk_drag_check_threshold() are initially doubles (other than in GtkNotebook and GtkIconView), and are casted to ints. Then those rounded values are used to calculate deltas to compare to the drag threshold, losing quite a lot of precision along the way, and often resulting in the outer widget getting larger deltas. To avoid it, just don't round it. Introduce a variant of the function that operates on doubles: gtk_drag_check_threshold_double() and use it instead of the original everywhere.
* gtk/imcontextwayland: Unset focus when unsetting widgetCarlos Garnacho2020-11-051-0/+1
| | | | | | | | | | | In destruction paths of a focused entry, the IM context might first end up detached from its widget, then destroyed. This currently prevents the IM context from detaching itself from the GtkIMContextWaylandGlobal. Make it do so when unsetting the client widget, so the IM context gets properly unfocused before destruction. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3176
* Replace "gdouble" with "double"Benjamin Otte2020-07-251-6/+6
|
* Replace "gchar" with "char"Benjamin Otte2020-07-251-7/+7
|
* Replace "gint" with "int"Benjamin Otte2020-07-251-13/+13
|
* gtk: focus out the GtkIMContextWayland upon finalization.Jehan2020-06-291-0/+4
| | | | | | | | In particular, it will NULL-ified the current global context if this is the finalized one, avoiding dangling invalid pointers. Would have been a cherry-pick from branch gtk-3-24 of commit b592ded80ad4825d115317ba6750a086da0434c0, but files moved.
* Change coordinate translation apis to take doublesMatthias Clasen2020-05-171-1/+4
| | | | | | Change gtk_widget_translate_coordinates and gtk_native_get_surface_transform to operate on doubles. Update all callers.
* imwayland: Clamp the surrounding string end correctlyCarlos Garnacho2020-04-031-1/+1
| | | | | | | | | | | | | | In the paths where len > MAX_LEN and cursor/anchor are separated by at least MAX_LEN from text edges, we were clamping the right end of the surrounding string at MAX_LEN. Oops. This end anchor may go as far as the string length, although just up to len - MAX_LEN in real terms (due to the condition above that caches cursor/anchor positions being near enough the text end). Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2565 (cherry-picked from commit d7fb15c822eabe22ffda19892153d69b0f4fc2f3)
* imcontextwayland: Honour len argument in gtk_im_context_wayland_set_surroundingRobert Mader2020-03-161-1/+1
| | | | | Clients may pass not `NULL`-terminated strings as the function takes a `len` argument. Use that argument.
* imcontextwayland: Fix copy/paste errorBenjamin Otte2020-03-051-1/+1
|
* gtk: Stop using GdkEventKeyMatthias Clasen2020-02-211-1/+1
| | | | | We should just use GdkEvent, instead of taking a GdkEventKey, and then cast it everywhere.
* imwayland: Fix get_preedit_string cursor positionxdavidwu2020-01-171-1/+2
| | | | | | GtkIMContext get_preedit_string should return cursor position counted in characters, but cursor_begin here is counted in bytes. This add the missing conversion.
* imwayland: Suppport terminal purposeDorota Czaplejewicz2019-12-121-0/+2
|
* Rename GtkGestureMultiPress to GtkGestureClickMatthias Clasen2019-05-291-11/+11
| | | | | The name just made it hard for people to find the right gesture to use.
* Stop using gtk_widget_get_toplevelMatthias Clasen2019-05-281-1/+1
| | | | All uses of it can be replaced by gtk_widget_get_root.
* imwayland: Toggle OSK more sparinglyCarlos Garnacho2019-02-091-0/+23
| | | | | | | | | Specifically it is avoided to be toggled if: - Just received focus (in order to preserve OSK state across focus changes) - Moving cursor around. Still allow some jitter as perfect accuracy is not possible. Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1277
* imcontextwayland: Get rid of global variableBenjamin Otte2019-01-221-27/+86
| | | | | Attach it to the GdkDisplay. Also fixes -Wshadow complaining about "global" being shadowed.
* imcontext: Fix priorities of modulesBenjamin Otte2019-01-221-1/+1
| | | | | | | | | All built-in backend modules get a priority of 0 because they are the default ones. GtkIMContextSimple gets a priority of G_MININT because it's the fallback one. This mirrors the media modules code.
* imcontextwayland: (Hopefully) fix if expressionTimm Bäder2019-01-041-1/+1
|
* imwayland: Respect maximum length of 4000 Bytes on strings being sent.Carlos Garnacho2018-12-181-3/+63
| | | | Hitting the limit will raise protocol errors.
* imwayland: Plug leaksCarlos Garnacho2018-12-181-0/+4
| | | | | The various strings (pending/current preedit, surrounding, and commit buffer) are being leaked in the case of GtkIMContext destruction.
* imwayland.c: fix formattingDorota Czaplejewicz2018-12-181-3/+3
|
* imwayland: rearrange functions to remove prototypesDorota Czaplejewicz2018-12-181-95/+89
|
* imwayland: Handle enter and leave eventsDorota Czaplejewicz2018-12-181-28/+57
| | | | Before this patch, imwayland would assume that text-input enter and leave events follow the general (wl_keyboard) focus, and was unable to handle the situation where they would not be provided at the same time.
* imwayland: Collect return value from ::delete-surrounding signalCarlos Garnacho2018-12-181-4/+4
| | | | | There's not much we can do about the signal not being handled, but we should fetch the return value anyway.