Commit Graph

663 Commits

Author SHA1 Message Date
Alexander Mikhaylenko
197fe80857 testsuite: Fix swapped params in notify test
The expected and counted params are swapped in literally every call, so
swapping the params to match them.
2020-04-24 23:54:07 +05:00
Matthias Clasen
12d5fdd457 menubutton: Drop relief
We are only using this as a boolean, so change it
to a boolean property named has-frame.
2020-04-17 10:57:36 -04:00
Matthias Clasen
df1816a29c button: Drop relief
We are only using this as a boolean, so change it
to a boolean property named has-frame.
2020-04-17 10:57:36 -04:00
Matthias Clasen
285aa226e5 scrolledwindow: Drop shadow-type
We were only using this as a boolean, so change it
to a boolean property named has-frame.
2020-04-17 10:57:36 -04:00
Emmanuele Bassi
f28aa1ba02 Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.

The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.

The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 19:54:02 +01:00
Matthias Clasen
5095e87bb7 testsuite: Add some checks for focus states
This is some opportunistic checking in a test that
is really about focus chains, but better than nothing.
2020-04-16 12:31:17 -04:00
Matthias Clasen
b09b2dd2cd testsuite: Make actions test order-independent
We only want to check that the actions are what we
expect, not that they are registered in a particular
order.
2020-04-11 10:07:31 -04:00
Matthias Clasen
822c2aba36 scalebutton: Don't derive from GtkButton
Make GtkScaleButton a widget that has a toggle button
as a child, just like all the other button widgets now.
The immediate benefit of this arrangement is to avoid
the "double focus" problem when we pop up the popup.

Update accessible, demos and tests to match.
2020-04-09 20:43:45 -04:00
Matthias Clasen
038190c5a8 Disable focus-chain test that depends on the environment
The color editor shows a color picker button only if it
finds a suitable implementation, which it does not in ci.
So disable the focus-chain test for page 3.
2020-04-09 17:50:29 -04:00
Matthias Clasen
99eed078bd Remove focusable-container tests
Like the previous commit, these tests were relying
on setting :can-focus to make an unsuspecting container
focusable, which does not work anymore.
2020-04-09 17:50:29 -04:00
Matthias Clasen
6720552afd Remove the focus test
This test was expecting to make existing widgets like
GtkBox focusable by setting :can-focus. That just doesn't
work anymore.

The focus chain testing that is done here is already
better covered by test-focus-chain, so lets just remove this.
2020-04-09 17:50:29 -04:00
Matthias Clasen
6f01508aa8 Fix up focus chain result
The notebook grab_focus change in the previous commit made
backwards tabbing work as expected, and thereby changed the
output of one of the focus-chain tests.
2020-04-09 17:50:29 -04:00
Matthias Clasen
9416856420 testsuite: Stop setting :has-focus
This is not necessary, whenever we want to set the initial
focus in a ui file, we can set GtkWindow:focus-widget.
2020-04-09 17:50:29 -04:00
Matthias Clasen
bbd4fb8798 testsuite: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
ff8217db40 Add more focus chain tests
Test page 2 and 3 of widget-factory as well, and try other directions.
2020-04-09 17:50:28 -04:00
Matthias Clasen
a3861bf9a0 Fix running focus-chain tests in ci
The widget-factory ui files require geettings
(for the color chooser), so set GSETTINGS_SCHEMA_DIR.
2020-04-09 17:50:28 -04:00
Matthias Clasen
c297d45b8a gtk: Stop using modifier intents
Reviewing the existing settings, the only backend with
some differences in the modifier intent settings is OS X,
and we would rather have that implemented by interpreting
the existing modifiers in the appropriate way.

                X11      Wayland  Win32    OS X

primary         ctrl     ctrl     ctrl     mod2
mnemonic        alt      alt      alt      alt
context menu    -        -        -        ctrl
extend sel      shift    shift    shift    shift
modify sel      ctrl     ctrl     ctrl     mod2
no text         alt|ctrl alt|ctrl alt|ctrl mod2|ctrl
shift group     varies   -        -        alt

GTK now uses the following modifiers:

primary         ctrl
mnemonic        alt
extend sel      shift
modify sel      ctrl
no text         alt|ctrl

The context menu and shift group intents were not used
in GTK at all.

Update tests to no longer expect <Primary> to roundtrip
through the accelerator parsing and formatting code.
2020-04-06 16:32:03 -04:00
Matthias Clasen
0a96a483c6 gdk: Redo key events
Add all of the keyboard translation results in the key event,
so we can translate the keyboard state at the time the event
is created, and avoid doing state translation at match time.

We actually need to carry two sets of translation results,
since we ignore CapsLock when matching accelerators, in
gdk_event_matches().

At the same time, drop the scancode field - it is only ever
set on win32, and is basically unused in GTK.

Update all callers.
2020-04-06 15:13:54 -04:00
Matthias Clasen
b02db72e17 Rename GDK_MOD1_MASK to GDK_ALT_MASK
We've hardcoded Mod1 = Alt for a long time, there is
no need to keep the confusing naming around anymore.
2020-04-06 01:40:49 -04:00
Matthias Clasen
6eaadba008 testsuite: Stop using keymap apis 2020-04-06 01:40:49 -04:00
Matthias Clasen
e8330c5eec Add gdk_event_matches
Move the elaborate key event matching code from
GtkShortcutTrigger to GdkEvent, which greatly reduces
the amount of keymap api use outside of GDK.
2020-04-05 23:37:13 -04:00
Matthias Clasen
8991275fbd colorbutton: Fix focus
The colorbutton contains a button which contains a colorswatch.
We want the focus to go straight to the button, nowhere else,
so mark the swatch as !can-focus.

Adapt tests to match.
2020-04-04 00:28:45 -04:00
Matthias Clasen
6b292af6ac testsuite: Add tests for parsing shortcut actions 2020-04-03 22:42:00 -04:00
Matthias Clasen
d662512c44 testsuite: Add a big focus chain testcase 2020-04-03 11:35:34 -04:00
Matthias Clasen
324af2f701 testsuite: Try harder to record a full focus chain
It is hard to avoid widgets with the same name in a
large ui file - try harder to record a full focus chain
before decide that we've wrapped, by including the widget
address in the comparison. Note that we don't include
the addresses in the generated output, since that would
make expected output vary from run to run.
2020-04-03 11:35:26 -04:00
Matthias Clasen
b92b7f45b5 testsuite: Add a test for transforms in builder files 2020-03-31 16:49:51 -04:00
Matthias Clasen
2bacc0d4ef testsuite: Add a test for parsing layout properties
and drop the child properties test that doesn't
do anything anymore.
2020-03-31 16:49:51 -04:00
Matthias Clasen
96f822434f testsuite: Add a builder test for shortcut controllers 2020-03-30 20:08:25 -04:00
Matthias Clasen
8acd9ffc76 testsuite: Fix notify test no not fail on the 30th
We are setting the month property to 10 different values,
checking that the change succeeds. But the calendar defaults
to the current date, so on every 30th of the month, we
try to set a date of Febuary 30, which fails.

Lets fix this before the 31st, by setting the calendar
to a good date.
2020-03-29 09:04:19 -04:00
Emmanuele Bassi
b1327167e2 Improve GtkShortcutTrigger parsing tests
Split off all possible cases into sub-tests, and add more thorough
checks on the invalid strings unit.
2020-03-27 14:56:05 +00:00
Emmanuele Bassi
6719d3044d Add parsing for GtkAlternativeTrigger
Alternative triggers are separate by a pipe character.
2020-03-27 14:35:00 +00:00
Emmanuele Bassi
c75fdda8dd tests: Add more cases for the trigger parser 2020-03-27 13:57:19 +00:00
Emmanuele Bassi
6e8c78714d Turn GtkShortcutAction into a GObject
Just like we did for GtkShortcutTrigger.

This allows language bindings to properly deal with all the actions.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
457b6657bb Turn GtkShortcutTrigger into an object
The lightweight inheritance mechanism used for GtkShortcutTrigger is not
going to be usable by bindings, because boxed types cannot have derived
types.

We could use GTypeInstance and derive everything from that, like
GParamSpec, but in the end shortcuts are not really a performance
critical paths, unlike CSS values or render nodes.
2020-03-25 23:14:45 -04:00
Matthias Clasen
d66121c61e Drop the keyhash test
GtkKeyHash is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
586e7749d5 shortcuttrigger: Do elaborate matching for key events
Copy the logic from GtkKeyHash for matching key events
to shortcuts.

Adapt shortcuts test to work with the better matching,
by creating more complete key events.
2020-03-25 23:14:45 -04:00
Matthias Clasen
904835d4b1 shortcuttrigger: Introduce partial matches
Allow GtkShortcutTrigger to return partial matches.
Currently, no triggers produce such results, and
GtkShortcutController treats partial matches like
exact ones.
2020-03-25 23:14:45 -04:00
Matthias Clasen
cb821d5df3 Add tests for shortcut actions 2020-03-25 23:14:45 -04:00
Matthias Clasen
ff056af249 Add a test for shortcut triggers 2020-03-25 23:14:45 -04:00
Matthias Clasen
778d884f70 Use an action for the context menu keybinding
The ::popup-menu signal is going away.
2020-03-25 23:14:44 -04:00
Benjamin Otte
cac39526a9 testsuite: Remove GtkAccelGroup usage 2020-03-25 23:14:28 -04:00
Benjamin Otte
90a34312d4 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2020-03-25 23:14:28 -04:00
Benjamin Otte
580863b112 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2020-03-25 23:14:28 -04:00
Benjamin Otte
cd0332aad5 shortcut: Add GtkShortcutAction
Similar to GtkShortcutTrigger, GtkShortCutAction provides all the
different ways to activate a shortcut.

So far, these different ways are supported:

 - do nothing
 - Call a user-provided callback
 - Call gtk_widget_activate()
 - Call gtk_widget_mnemonic_activate()
 - Emit an action signal
 - Activate an action from the widget's action muxer
2020-03-25 23:14:27 -04:00
Matthias Clasen
6d452f1eb8 shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-25 22:36:03 -04:00
Matthias Clasen
5870d9d72a testsuite: Set NO_AT_BRIDGE for gtk tests
The a11y stack insists on spewing hard to control warnings
that make our tests fail. So, no accessibility for gtk tests :(
2020-03-25 17:03:58 -04:00
Marc-Antoine Perennou
eb8e0910c3 testsuite/gtk/flattenlistmodel.c: fix build
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-03-22 10:53:59 +01:00
Christian Hergert
ccac404f28 widget: fix class private data usage to be _init() safe
Before this commit, adding GtkWidgetAction to class private data would
require copying the actions to each subclass as they were built or
modified. This was convenient in that it is a sort of "copy on write"
semantic.

However, due to the way that GTypeInstance works with base _init()
functions, the "g_class" pointer in GTypeInstance is updated as each
_init() function is called. That means you cannot access the subclasses
class private data, but only the parent class private data.

If instead we use a singly linked list of GtkWidgetAction, each subclass
has their own "head" yet all subclasses share the tail of the
GtkWidgetAction chain.

This creates one bit of complexity though. You need a stable way to know
which "bit" is the "enabled" bit of the action so we can track enabled
GAction state. That is easily solved by calculating the distance to the
end of the chain for a given action so that base classes sort ahead of
subclasses. Since the parent class always knows its parent's actions, the
position is stable.

A new dynamic bitarray helper also helps us avoid allocations in all the
current cases (up to 64 actions per widget) and dynamically switches to
malloc if that is to ever be exceeded.
2020-03-20 11:17:56 -07:00
Matthias Clasen
c7caa53917 testsuite: disable performance tests
For some reason, these tests are flaky in ci,
they always work locally for me. So, until
we use the data these tests produce for something,
lets just turn them off.
2020-03-20 13:47:58 -04:00
Matthias Clasen
cbb0ca4902 testsuite: Tell meson we use TAP
This makes meson actually parse the individual test
results. Most of the time, it does not make a difference,
but one case where it does is when all the individual
tests of a binary are skipped, meson will mark the
test as skipped.
2020-03-20 11:55:26 -04:00