Commit Graph

328 Commits

Author SHA1 Message Date
Matthias Clasen
71649fce29 text: Convert docs 2021-03-11 16:37:36 +00:00
Matthias Clasen
ccae0e1732 text: Optimize away 0-change insertions and deletions
We can short-circuit insert and delete calls that are
not causing any change.
2021-03-04 15:18:30 -05:00
Matthias Clasen
447203ce52 text: Delete selection when preedit starts
This prevents confusing misrendering when the preedit text
pushes the selection text out of the rendered selection.

Fixes: #1123
2021-03-04 15:18:30 -05:00
Matthias Clasen
feccdad9d2 text: Send anchor with surrounding
We have the api to do it now.
2021-03-04 15:18:30 -05:00
Matthias Clasen
19b9967a72 text: Fix sticky preedit attrs
In some cases, we were inadvertedly merging the
preedit attributes into priv->attrs, instead of
keeping them separate. This was causing the underlines
to grow beyond the preedit and never go away. One
place where this was showing up is the fontchooser
preview.

Fixes: #3679
2021-02-17 23:25:31 -05:00
Alexander Mikhaylenko
f63e6394ac dragsource: Use double coordinates for checking drag threshold
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.
2021-01-29 12:01:34 +05:00
Jonas Ådahl
517bc0db84 gtk/texthandle: Use gtk_text_handle_present() instead of GtkNative 2020-12-07 20:37:29 +01:00
Jonas Ådahl
2cddec7798 gtk/popover: Use gtk_popover_present() instead of going via GtkNative
This makes it more explicit that managers of popovers make it "present".
2020-12-07 20:37:29 +01:00
Bilal Elmoussaoui
ec537d75e4 Text: add missing nullability annotations 2020-12-02 10:28:07 -05:00
Matthias Clasen
2ef72442ec docs: Fix the links for keybinding signals
GtkBindingSignal does not exist anymore, so link to
GtkSignalAction for an explanation of keybinding signals.
2020-11-17 07:34:52 -05:00
Timm Bäder
ff1fb4f10d text: Remove empty root() implementation 2020-10-22 17:46:34 +02:00
Timm Bäder
1bf79a4dae text: Fix a documentation mishap 2020-10-22 17:46:34 +02:00
Timm Bäder
85d4b86545 text: Fold focus_{in,out} into only caller 2020-10-22 17:46:34 +02:00
Timm Bäder
98e88b7b53 text: Avoid a crash
Calculate the "was previous focus in a child widget" condition before
chaining up into grab_focus, to a void that unreffing the prev_focus
widget.
2020-10-22 17:46:34 +02:00
Matthias Clasen
043ffd38bc text: React to text attribute changes in css
Recompute the layout when the css style change
affects text attributes. This matches what we do
in GtkLabel, and without this, changing the
font-features-setting css property in the Inspector
does not have immediate effect.
2020-10-21 13:46:58 -04:00
Matthias Clasen
cbb6828657 docs: Document more accessible roles
Document that GtkText is skipped in accessibility.
2020-10-20 23:19:30 -04:00
Benjamin Otte
8dad615f04 gtk: Remove unused header include
gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in
gadgets, and gadgets are gone now.
2020-10-20 04:50:12 +02:00
Matthias Clasen
ccbacb5cce Fix the build
I forgot a few casts in a02c50e72f.
2020-10-13 11:23:13 -04:00
Matthias Clasen
a02c50e72f text: Make editable signals work again
Since the big editable reorg, GtkText was not emitting
::insert-text and ::delete-text, as is expected of
editables. We want to use those signals for a11y
change notification, so make them work again.
2020-10-13 00:49:10 -04:00
Matthias Clasen
8182fab4d9 text: Ignore text widgets for a11y
We want to implement the Text interface on the
wrapper entries.
2020-10-12 21:45:48 -04:00
Matthias Clasen
2a5af4e1d6 text: Set the readonly accessible property
This mirrors what we already do for GtkTextView.
2020-10-12 15:10:40 -04:00
Matthias Clasen
1b1bf6c90a text: Add some missing setters and getters
Add getters and setters for the enable-emoji-completion,
propagate-text-width and truncate-multiline properties.
2020-10-03 13:11:20 -04:00
Matthias Clasen
4a2c817690 docs: Document various entry ::activate signals 2020-09-29 07:04:07 -04:00
Matthias Clasen
0011a1032d text: Claim the sequence when we start selecting
Without this, drag-select will only work sporadically
in entries in headerbars.

Fixes: #2994
2020-09-12 11:18:36 -04:00
Matthias Clasen
5a8267dfae text: Set the hotspot for the drag icon
This makes the drag icon align properly with the
dragged text at the beginning of the drag.
2020-09-07 11:18:45 -04:00
Matthias Clasen
adc9d91e0e text: Stop drag updates when a dnd starts
This prevents the selection from changing underneath
us, messing up move dnd operations.
2020-09-06 12:19:44 -04:00
Matthias Clasen
635492b016 text: Don't replace unselected text with Emoji
We must be careful to not select everything on focus-in
before we have the Emoji inserted. This was accidentally
broken in d5121af876.

Fixes: #3122
2020-09-05 08:40:02 -04:00
Matthias Clasen
d5121af876 text widgets: Don't lose focus after Emoji
Make sure to grab focus back when the Emoji chooser
disappears. This prevents focus going nowhere when
the Emoji chooser is canceled.

Fixes: #3112
2020-09-02 15:20:58 -04:00
Matthias Clasen
43ec96684a text: Properly handle focus moving to a descendent
To discriminate between is-focus and contains-focus,
we need to use notify::is-focus. This makes sure
we don't get annoying warnings when the blink_cb
gets triggered on an unfocused entry.

Fixes: #2979
2020-08-24 18:31:35 -04:00
Matthias Clasen
ca0f136deb text: Don't compute invisible char needlessly
There is no real reason to do expensive text layout
operations unless we need the invisible char because
the text's visibilty is FALSE.
2020-08-23 17:41:13 -04:00
Matthias Clasen
c0191c7225 text: Defer most recomputation until we're mapped
It doesn't make sense to update scroll positions or
im cursor locations while we're unmapped, and doing
so causes us to do expensive text measuring.
2020-08-23 17:41:13 -04:00
Matthias Clasen
ae7cefd97d Drop style class defines
We document the supported style classes by name,
not by macro name, and these macros don't really
add any value. Drop them for GTK 4.
2020-08-14 07:03:27 -04:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Emmanuele Bassi
c63087a563 Remove ATK
To build a better world sometimes means having to tear the old one down.
        -- Alexander Pierce, "Captain America: The Winter Soldier"

ATK served us well for nearly 20 years, but the world has changed, and
GTK has changed with it. Now ATK is mostly a hindrance towards improving
the accessibility stack:

 - it maps to a very specific implementation, AT-SPI, which is Linux and
   Unix specific
 - it requires implementing the same functionality in three different
   layers of the stack: AT-SPI, ATK, and GTK
 - only GTK uses it; every other Linux and Unix toolkit and application
   talks to AT-SPI directly, including assistive technologies

Sadly, we cannot incrementally port GTK to a new accessibility stack;
since ATK insulates us entirely from the underlying implementation, we
cannot replace it piecemeal. Instead, we're going to remove everything
and then incrementally build on a clean slate:

 - add an "accessible" interface, implemented by GTK objects directly,
   which describe the accessible role and state changes for every UI
   element
 - add an "assistive technology context" to proxy a native accessibility
   API, and assign it to every widget
 - implement the AT context depending on the platform

For more information, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2833
2020-07-26 20:31:14 +01:00
Matthias Clasen
4786a16696 actionmuxer: Port internal users
Port all internal users of the action muxer
from the GActionGroup interface to the new
action muxer apis.
2020-07-20 08:24:52 -04:00
Matthias Clasen
2e2336ffce text: Claim clicks when grabbing focus
If we don't, an ancestor (such a GtkListItemWidget)
may interpret the click as "I should grab focus!",
and still our focus away. This was causing hard-to-focus
entries in the property list in the inspector.
2020-07-18 12:47:47 -04:00
Matthias Clasen
0d10982379 text: Support reverse selection
Take ordering of cursor_position and selection_bound
into account when copying text to the clipboard, and
ensure that both orders work the same.

Fixes: #2898
2020-06-26 22:22:47 -04:00
Matthias Clasen
c20a966f06 text: Update action enabled state correctly
Take the editable property into account when updating
the emoji.insert action state, and update the action
when it changes.

Fixes: #2897
2020-06-26 22:13:12 -04:00
Matthias Clasen
cd9f5733b3 text: Be more selective when selecting on focus-in
We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the entry to
be selected, unexpected things happen, since the action
applies to the current selection.

Fixes: #2869
2020-06-26 15:49:39 -04:00
Matthias Clasen
8b4560cbfb Revert "text: Avoid creating a PangoAttrList we don't need"
This reverts commit 67c2665028.

The splicing we do here has the important side-effect
of shifting the preedit attributes to the right position.
Without it, we end up always underlining the first chars
in the entry, regardless where the preedit happens.
2020-06-26 15:27:17 -04:00
Matthias Clasen
2d914d52be text: Handle key events in the target phase
This makes sure that we do actual key input right
in the middle between all the capture and bubble
event controllers, and are not dependent on the
ordering of those controllers.

The bug that triggered this change was that the
shortcut for activation (Enter) was getting triggered
before the key input, causing Ctrl-Shift-u hex
to stop working, since it never received the enter
to commit the sequence.
2020-06-26 14:08:35 -04:00
Matthias Clasen
3558beaa61 text: Give names to event controllers
It helps with debugging.
2020-06-26 14:08:11 -04:00
Carlos Garnacho
0ce4f66976 gtktext: Don't accept (twice!) all press actions
The gesture should claim the sequence after triggering uncancellable
actions, like pasting, showing a menu or selecting words/lines. A
single first button press initiating a drag does not trigger
anything yet, so it should avoid claiming the sequence.
2020-06-26 17:48:10 +02:00
Emmanuele Bassi
3f78199cd5 Rename (unused) argument 2020-06-18 17:31:48 +01:00
Yuri Chornoivan
c0cf839729 Fix minor typos 2020-06-18 10:47:16 +03:00
Matthias Clasen
687da2ca6b text: Drop unused includes 2020-06-15 23:10:32 -04:00
Christoph Reiter
2d5cf2b4c4 Drop fallback-c89.c
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().
2020-05-31 17:09:23 +02:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
01df133401 text: Avoid clash of preedit and placeholder
Take preedit into account when determining the
visibility of placeholder text.
2020-05-22 10:48:33 -04:00
Timm Bäder
7235472a58 text: Assert that we have ranges before using them
We never hit this code path otherwise but let's make sure.
2020-05-19 08:32:33 +02:00