Commit Graph

690 Commits

Author SHA1 Message Date
Matthias Clasen
d771aa6fee testsuite: Destroy surfaces
If we don't destroy the surface, it leaks.

GDK backends keep an extra reference on the
surface for the external resources associated
with it, and only drop it in destroy().
2020-05-16 09:12:18 -04:00
Matthias Clasen
0232218100 displayclose: Quietly skip if no X available 2020-05-15 14:58:58 -04:00
Matthias Clasen
509db01319 tests: Centralize our test setup a bit
Put all of the constant environment into the
toplevel meson.build file, to reduce repetition
and copy-paste errors.
2020-05-15 14:11:53 -04:00
Matthias Clasen
8912a6eb75 gtk: Handle seatless displays
If you run weston with the headless backend, you get a Wayland
display with no seat, which is just fine by the protocol.

gdk_display_get_default_seat() returns NULL in this case. Various
widgets assume that we always have a seat with a keyboard and a
pointer, since that is what X guarantees. Make things survive
without that, so we can run the testsuite under a headless
Wayland compositor.
2020-05-15 14:11:53 -04:00
Matthias Clasen
378cca75ea Add a test for a flowbox crash 2020-05-13 21:47:11 -04:00
Matthias Clasen
2a24b8c653 Replace most remaining uses of container api
These are all on GtkBox or enumerating children.
2020-05-11 22:38:21 -04:00
Matthias Clasen
6f170a0cf7 testsuite: Fix listbox tests
When moving from gtk_container_forall to the widget dom
api, we are now iterating over all children of the listbox,
including headers, separators, etc. So, skip everything
that is not a listboxrow, to make the tests work again.
2020-05-11 22:21:39 -04:00
Matthias Clasen
c55aa7e590 testsuite: Redo listbox sort test
This test was relying on gtk_container_forall returning
the visual (ie sorted) order of children, while iterating
with the widget dom api gives the insertion order.

Instead of using gtk_container_forall, use
gtk_list_box_row_get_index to reconstruct the visual
order.
2020-05-11 22:21:39 -04:00
Matthias Clasen
88141103cd Don't use container api on GtkListBox 2020-05-11 22:21:39 -04:00
Matthias Clasen
c0657297d1 grid: Remove a test for grid container functionality
This test was specifically testing how gtk_container_add
behaves on grids. Well, it doesn't anymore.
2020-05-11 22:21:39 -04:00
Matthias Clasen
932aa58237 Avoid container api on grids
GtkContainer is going away.
2020-05-11 22:21:39 -04:00
Matthias Clasen
d7b1ecdf52 Cosmetics: Replace GtkContainer in an error message
GtkWidget is not that much better here, unfortunately.

Adapt the testsuite to match.
2020-05-11 15:42:51 -04:00
Timm Bäder
e5d6b493c0 testsuite: add widget refcount test case
Testing toplevels and popovers.
2020-05-11 12:20:59 -04:00
Matthias Clasen
025375ff5f Replace gtk_widget_destroy everywhere
Replace all remaining uses of gtk_widget_destroy
by gtk_container_remove or g_object_unref.
2020-05-11 12:20:59 -04:00
Matthias Clasen
cd0081d08a Use gtk_window_destroy
Replace calls to gtk_widget_destroy on windows
with gtk_window_destroy.
2020-05-11 12:20:57 -04:00
Matthias Clasen
466d2a84de testsuite: Clean up unexpected children
If you call gtk_widget_set_parent on an unsuspecting
parent widget, it is your reponsibility to clean up
before the parent gets finalized.
2020-05-11 12:19:39 -04:00
Matthias Clasen
b8c5bf8af8 testsuite: Enable the remaining template tests
These are no longer failing.
2020-05-11 10:30:03 -04:00
Matthias Clasen
1b8a025a5f Clean up a leak in a test
One of the treeview tests was calling gtk_widget_destroy
on a child instead of the toplevel, which leaks the toplevel
unnecessarily. Plus, we're moving towards allowing destroy
only on toplevels.
2020-05-11 08:15:55 -04:00
Matthias Clasen
caab6ac6e7 testsuite: Add more tests for automated components
Add template tests that show the complex dialogs before
destroying them. This reveals that we are leaking in
several of them. These leaks don't show up if the
dialogs are destroyed right away, as the existing
tests do.

Disable the two failing tests for now:
  /template/GtkFileChooserDialog/show
  /template/GtkPrintUnixDialog/show
2020-05-10 16:25:28 -04:00
Matthias Clasen
9d4b01fff8 testsuite: Use lowercase component in test paths
This is purely cosmetic.
2020-05-10 16:25:28 -04:00
Matthias Clasen
fc42a0696e Add a test for refcounts under reordering
It turns out that we have a ref leak at the very
core of our dom model :( gtk_widget_insert_before/after
leak a reference if the widget was already under
the same parent. This is something that GtkBox
frequently does. It shows up e.g. when packing
widgets at the end in a headerbar.
2020-05-09 19:38:19 -04:00
Matthias Clasen
5d26af06e4 combobox: Add a child property 2020-05-04 22:53:08 -04:00
Matthias Clasen
12ecbd1508 listboxrow: Derive from GtkWidget
We want to remove GtkBin and GtkContainer as they don't
provide much useful functionality anymore.

See #2681
2020-05-04 22:53:08 -04:00
Matthias Clasen
649ae635a7 Use gtk_revealer_set_child throughout
Replace all uses of gtk_container_add on revealers
with gtk_revealer_set_child.
2020-05-04 22:53:08 -04:00
Matthias Clasen
f59f355190 Use gtk_window_set_child throughout
Replace all uses of gtk_container_add on windows
by gtk_window_set_child.
2020-05-04 22:53:08 -04:00
Matthias Clasen
67759d4c3e Use gtk_scrolled_window_set_child throughout
Replace all uses of gtk_container_add on popovers
by gtk_scrolled_window_set_child.
2020-05-04 22:53:07 -04:00
Matthias Clasen
8e261056b9 Use gtk_popover_set_child throughout
Replace all uses of gtk_container_add on popovers
by gtk_popover_set_child.
2020-05-04 22:53:07 -04:00
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