Compare commits

..

358 Commits

Author SHA1 Message Date
Matthias Clasen
70eec3ee01 listitemwidget: Update some accessible state
Pass the selected state on to a11y.

Fixes: #6663
2024-04-26 11:50:30 -04:00
Matthias Clasen
05d5860dc0 listview: Fix some oversights
The list factory widget was notifying the wrong properties.
2024-04-26 11:19:59 -04:00
Matthias Clasen
2e08db91ca Merge branch 'offload-snapshot-no-child' into 'main'
Don't crash if snapshotting a GtkGraphicsOffload without child

See merge request GNOME/gtk!7183
2024-04-25 20:46:31 +00:00
Sebastian Dröge
2c9b47ff3c Don't crash if snapshotting a GtkGraphicsOffload without child 2024-04-25 22:46:35 +03:00
Matthias Clasen
62ad1a61dc Merge branch 'matthiasc/for-main' into 'main'
offload: Make logging more compact

See merge request GNOME/gtk!7181
2024-04-25 03:01:44 +00:00
Matthias Clasen
3fc9de7539 offload: Make logging more compact
Use a format of

[XXX] SYMBOL DETAILS

where SYMBOL indicates the offloading status:
 🗙 - no offload
 ▲ - offload above, with background
 △ - offload above, no background
 ▼ - offload below, with background
 ▽ - offload below, no background
2024-04-24 22:01:56 -04:00
Matthias Clasen
1c9a55d185 Merge branch 'vulkan-msvc' into 'main'
gskvulkandescriptors.c: Don't return value from void-rettype function

See merge request GNOME/gtk!7175
2024-04-25 01:37:49 +00:00
Matthias Clasen
492940205e Merge branch 'amolenaar/macos-fix-nsapp-shortcuts' into 'main'
macos: fix in-app native shortcuts (regression)

See merge request GNOME/gtk!7178
2024-04-25 01:35:59 +00:00
Arjan Molenaar
985e4906c8 macos: Add some docs for the different NSEvent getters 2024-04-24 23:49:37 +02:00
Benjamin Otte
e9dcf8167c Merge branch 'gbsneto/vulkan-dmabuf-general' into 'main'
vulkan/image: Use GENERAL for initial layout of DMA-BUF textures

See merge request GNOME/gtk!7179
2024-04-24 20:55:51 +00:00
Georges Basile Stavracas Neto
3aa6c27c26 vulkan/image: Use GENERAL for initial layout of DMA-BUF textures
The VK_IMAGE_LAYOUT_UNDEFINED layout means that the data hold by the
texture can be discarded, and we don't want to discard it. Because the
Vulkan spec is unclear (see [1] for a discussion), err on the side of
caution and use VK_IMAGE_LAYOUT_GENERAL.

Fixes import failures with WebKit.

[1] https://github.com/ValveSoftware/gamescope/issues/356
2024-04-24 17:21:51 -03:00
Emmanuele Bassi
7075e6be89 Merge branch 'gst-backend-msvc' into 'main'
GStreamer media backend: Fix building on Visual Studio

See merge request GNOME/gtk!7174
2024-04-24 10:04:11 +00:00
Chun-wei Fan
016354b6dd gskvulkandescriptors.c: Don't return value from void-rettype function
Fixes builds on Visual Studio with Vulkan enabled, as later GLib releases
consider this as an error on Visual Studio builds.
2024-04-24 16:19:43 +08:00
Chun-wei Fan
1dfc6d65df GStreamer media backend: Fix building and running on Windows
Visual Studio (and possibly other non-GCC compilers) do not like
uses of #-preprocessor directives in macro usage (warning C5101: use of
preprocessor directive in function-like macro argument list is undefined
behavior is also shown), so fix the build by defining another macro
accordingly.
2024-04-24 16:15:32 +08:00
Matthias Clasen
b7d0295481 Merge branch 'macos-default-settings' into 'main'
macos: Respect the default-settings debug key

See merge request GNOME/gtk!7173
2024-04-23 16:38:00 +00:00
Matthias Clasen
a2854af325 macos: Respect the default-settings debug key
This makes our behavior more consistent across platforms.
The suggestion came up in discussion in #6545.
2024-04-23 07:52:25 -04:00
Changwoo Ryu
320496b039 Update Korean translation
(cherry picked from commit e1dafd7a5d)
2024-04-23 11:33:48 +00:00
Arjan Molenaar
f004f14b89 macos: fix in-app native shortcuts (again)
Popping an event of the queue in the IMContext handler
prevents it from being forwarded to the NSApp, in case the
(key) event was not handled by IMContext.

So I reverted to a mix of the original (4.13) and new (4.14.1) behavior
for fetching events: NSEvent lookup for IMContext uses loose matching,
so it can work with rewritten events. When sending events to NSApp, only
we're checking for an exact match.

Now in-app keyboard shortcuts (e.g. Ctrl-F2) work from within text
fields again.
2024-04-23 08:57:09 +02:00
Matthias Clasen
8f15f6959c Merge branch 'vulkan-profiler-mark' into 'main'
gsk: Add a profiler mark for pipeline creation

See merge request GNOME/gtk!7172
2024-04-23 01:19:20 +00:00
Matthias Clasen
f26efd9adf gsk: Add a profiler mark for pipeline creation
This is the Vulkan equivalent of shader compilation, it could be
expensive, so lets add a mark around it.
2024-04-22 20:47:25 -04:00
Matthias Clasen
3f342d75b2 Merge branch 'wip/alice/root-test' into 'main'
testsuite: Add css/style/root test

See merge request GNOME/gtk!7171
2024-04-22 20:26:46 +00:00
Alice Mikhaylenko
3ab189404e testsuite: Add css/style/root test
Should have been a part of 76421847a5
but I forgot to commit it.
2024-04-22 21:34:50 +04:00
Matthias Clasen
48fc8d6606 Merge branch 'wip/alice/root' into 'main'
cssselector: Support :root

See merge request GNOME/gtk!7170
2024-04-22 16:26:18 +00:00
Matthias Clasen
2e0f411de9 Merge branch 'amolenaar/macos-fix-delayed-rendering' into 'main'
macos: Avoid repeatedly sending events back to macOS

See merge request GNOME/gtk!7158
2024-04-22 16:25:57 +00:00
Matthias Clasen
f08e36e225 Merge branch 'wip/alice/bugfix' into 'main'
csstokenizer: Fix an out of bounds when reading an ident followed by EOF

See merge request GNOME/gtk!7169
2024-04-22 16:25:17 +00:00
Matthias Clasen
9f358ac655 Merge branch 'matthiasc/for-main' into 'main'
roaring: Fix some ubsan warnings

See merge request GNOME/gtk!7165
2024-04-22 15:52:04 +00:00
Matthias Clasen
33d1349e53 Merge branch 'wip/alice/wayland-crash' into 'main'
wayland: Consistently handle enum type

Closes #6649

See merge request GNOME/gtk!7168
2024-04-22 15:25:31 +00:00
Alice Mikhaylenko
76421847a5 cssselector: Support :root
This will be useful for defining global variables.
2024-04-22 18:55:35 +04:00
Alice Mikhaylenko
840cd6e44c csstokenizer: Fix an out of bounds when reading an ident followed by EOF 2024-04-22 17:59:29 +04:00
Arjan Molenaar
f81038e99a macos: Avoid repeatedly sending events back to macOS
in the old approach it was possible that one NSEvent was
sent to the underlying NSApp multiple times. This resulted in
those events being forwarded to our (glib) event queue again.

The visual result was that no screen updates were done. Under the hood
the application was very busy with passing events around.

By popping the events off of our event queue, we make sure they're sent
only once.
2024-04-22 15:51:12 +02:00
Alice Mikhaylenko
007e7c68dc wayland: Consistently handle enum type
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6649
2024-04-22 17:18:11 +04:00
Emmanuele Bassi
e5e147ad53 Merge branch 'wip/alice/flatpak-fix' into 'main'
Fix flatpak build

See merge request GNOME/gtk!7166
2024-04-22 13:04:33 +00:00
Alice Mikhaylenko
58e00040e0 Fix flatpak build
Regressed in 70cd0e28ab
2024-04-22 16:18:58 +04:00
Matthias Clasen
5d1b8399fb testsuite: Fix another ubsan warning
The expression here was a bit too dense for ubsan to figure out
what branches aren't hit.
2024-04-21 22:24:02 -04:00
Matthias Clasen
deec2b6c6c lsan: Don't suppress glib and gio leaks
These are useful to see and not all that common.
2024-04-21 22:02:44 -04:00
Matthias Clasen
246eb8ea25 gtk: Fix more ubsan warnings
Most of these are calling a get_instance_private() function before
checking that the object isn't NULL.
2024-04-21 22:01:06 -04:00
Matthias Clasen
815df9a76a wayland: Fix an ubsan warning
dev_t requires 8-byte alignment, so we need to use memcpy.
2024-04-21 21:32:41 -04:00
Matthias Clasen
f896dddadc inspector: Fix an ubsan warning
These values are too big for int, so cast them to double.
2024-04-21 21:21:11 -04:00
Matthias Clasen
d733e94a8b roaring: Fix some ubsan warnings
Avoid warnings about memcpy (NULL, NULL, 0).
2024-04-21 21:20:16 -04:00
Matthias Clasen
59db0ca328 Merge branch 'matthiasc/for-main' into 'main'
wayland: Use wl_compositor version 6

See merge request GNOME/gtk!7164
2024-04-22 01:00:22 +00:00
Matthias Clasen
3bd97590a1 wayland: Tweak a debug message
We aren't drawing to subsurfaces.
2024-04-21 20:37:45 -04:00
Matthias Clasen
722a0fa36d wayland: Check subsurface backgrounds better
Do the same checks for background coordinates that we do for the
subsurface coordinates themselves: they must be integral in both
application and device pixels.
2024-04-21 20:33:29 -04:00
Matthias Clasen
b21708c5e4 offload: Consolidate logging a bit
Spew a bit less per-frame. Unfortunately, we still spew for
every frame, and fixing that would require more extensive
refactoring to centralize all logging in gskoffload.c
2024-04-21 20:18:38 -04:00
Matthias Clasen
b5fb584316 wayland: Use gdk_debug_message consistently
For debug messages, we should always use gdk_debug_message.
2024-04-21 19:41:49 -04:00
Matthias Clasen
fd1e1b9b7c Cosmetics 2024-04-21 19:35:52 -04:00
Matthias Clasen
c0caae0ff0 wayland: Use wl_compositor version 6
This gives us events for preferred_buffer_scale (which we ignore)
and preferred_buffer_transform (which we also currently ignore).
2024-04-21 19:27:58 -04:00
Matthias Clasen
5c972e4786 Post-release version bump 2024-04-21 12:27:05 -04:00
Matthias Clasen
1a3c5cf420 4.15.0 2024-04-21 12:21:40 -04:00
Matthias Clasen
eb7affd911 testsuite: Fix the offload tests 2024-04-21 12:21:40 -04:00
Matthias Clasen
a05dbff2c9 testsuite: Tweak the offload tests
We set GDK_DEBUG=force-offload now, so we can look at the actual
offload status.
2024-04-21 12:21:40 -04:00
Matthias Clasen
4b0d17b332 wayland: Fix an offload cornercase
Treat textures with background as opaque for the purposes of
offloading.
2024-04-21 12:21:40 -04:00
Matthias Clasen
2d8f677e63 Merge branch 'matthiasc/for-main' into 'main'
build: Fix docs build

See merge request GNOME/gtk!7162
2024-04-21 15:25:37 +00:00
Matthias Clasen
b5c9b6aa25 docs: Some updates to the render tool manpage
List all supported output formats and fix a few typos.
2024-04-21 11:03:31 -04:00
Matthias Clasen
86924c2f9a docs: Add some metadata to man pages
It would be nice to include the version here, but that is trickier.
2024-04-21 11:03:14 -04:00
Matthias Clasen
af0f5e3f30 build: Fix docs build
There was an overlooked used of a dropped option here.
2024-04-21 10:15:06 -04:00
Matthias Clasen
9e6c72210d Merge branch 'fix-dconf-reference' into 'main'
docs: Improve a reference

Closes #6635

See merge request GNOME/gtk!7161
2024-04-21 14:03:37 +00:00
Matthias Clasen
ce0b2d6953 NEWS: Updates 2024-04-21 09:40:55 -04:00
Matthias Clasen
d1bb3f66ac ci: Use pangos documentation option
The gtk_doc option has been deprecated in pango.
Use the replacement to avoid a deprecation warning.
2024-04-21 09:40:55 -04:00
Matthias Clasen
70cd0e28ab Drop deprecated build options
These cause harm in connection with subprojects if the subprojects
yield to a deprecated option. So just rip the bandaid off and
drop the deprecated build options.
2024-04-21 09:40:55 -04:00
Matthias Clasen
2e00bcc580 docs: Improve a reference
DConf is not what we use, it is actually GSettings.

Fixes: #6635
2024-04-20 20:12:54 -04:00
Matthias Clasen
db68c1f2c6 NEWS: Updates 2024-04-20 19:14:54 -04:00
Matthias Clasen
e3fa60a070 Merge branch 'matthiasc/for-main' into 'main'
ci: Stop using deprecated options

See merge request GNOME/gtk!7160
2024-04-20 22:35:20 +00:00
Matthias Clasen
c9c29d8bde gsk: Only prefer Vulkan on Wayland
Make Vulkan the default on Vulkan-friendly platforms.
For now, that list only includes Wayland.
2024-04-20 18:10:21 -04:00
Matthias Clasen
cd59d62947 Merge branch 'offload-new-transfer-none' into 'main'
Drop return value annotation of gtk_graphics_offload_new()

See merge request GNOME/gtk!7159
2024-04-20 21:26:03 +00:00
Sebastian Dröge
4f4fe4ef44 Drop return value annotation of gtk_graphics_offload_new()
A floating reference is returned, not a full reference. By having no
annotation, like for all other widget constructors, the correct default
is used again.
2024-04-20 22:45:15 +03:00
Matthias Clasen
06f83847c6 ci: Stop using deprecated options
A small step towards being able to drop these eventually.
2024-04-20 13:44:08 -04:00
Matthias Clasen
941b5c2aeb NEWS: Updates 2024-04-20 12:45:32 -04:00
Matthias Clasen
d661b7f258 Merge branch 'docs-tweaks' into 'main'
docs: Tweaks

See merge request GNOME/gtk!7157
2024-04-20 14:15:30 +00:00
Matthias Clasen
f86d996d58 NEWS: Updates 2024-04-20 09:18:03 -04:00
Matthias Clasen
fe3031fb99 docs: Tweaks
Shuffle the gtk-font-rendering docs around a bit.
2024-04-20 09:10:57 -04:00
Matthias Clasen
4b001a24db Merge branch 'vulkan-by-default' into 'main'
gsk: Change the default renderer

Closes #6537

See merge request GNOME/gtk!7153
2024-04-20 13:09:02 +00:00
Matthias Clasen
4727fea631 Merge branch 'textview-text-shadow' into 'main'
Apply css text shadows in text views

See merge request GNOME/gtk!7154
2024-04-20 13:06:54 +00:00
Matthias Clasen
7ff4cba624 Apply css text shadows in text views
For now, this just applies the shadow from the widget's style,
there is no way to apply different shadows to text ranges (except
for the selection, which already has its own css style).
2024-04-20 08:48:39 -04:00
Matthias Clasen
0363cc83b9 Merge branch 'deprecate-cursor-theme-setters' into 'main'
gdk: Deprecate public cursor theme setters

See merge request GNOME/gtk!7155
2024-04-20 12:40:25 +00:00
Matthias Clasen
c1327e2c1b gdk: Deprecate public cursor theme setters
No need for this api, we've made the frontend setter private
for a reason.
2024-04-20 07:50:10 -04:00
Aurimas Černius
9971707544 Update Lithuanian translation
(cherry picked from commit 49046f5c34)
2024-04-20 10:39:37 +00:00
Matthias Clasen
02115912aa Cosmetics 2024-04-19 20:52:57 -04:00
Martin
e29571e6a6 Update Slovenian translation 2024-04-19 21:46:32 +00:00
Matthias Clasen
582ad79088 gsk: Change the default renderer
The intent of this change to get wider testing and verify that the
Vulkan drivers we get to use in the wild are good enough for our
needs. If significant problems show up, we will revert this change
for 4.16.

The new preference order is vulkan > ngl > gl > cairo.

The gl renderer is still there because we need it to support gles2.

If you need to override the default renderer choice, you can
still use the GSK_RENDERER environment variable.

Fixes: #6537
2024-04-19 13:50:40 -04:00
Matthias Clasen
3fac42fd3c Merge branch 'hint-font-metrics-redux' into 'main'
Add a new font rendering setting

See merge request GNOME/gtk!7113
2024-04-19 17:34:57 +00:00
Matthias Clasen
8f0b38b462 tests: Update for the new setting
One of our tests counts our settings. Not super-useful, but lets
keep it working.
2024-04-19 12:56:34 -04:00
Matthias Clasen
6c5a106d7e inspector: Show the font rendering setting
Replace the font options with the new font rendering setting.
The font options are still available for tweaking in the inspector
as properties of the GtkSettings object.
2024-04-19 12:56:34 -04:00
Matthias Clasen
5f7cab4632 Add a new font rendering setting
Add a high-level setting that gives us more freedom to tweak
font rendering knobs according to our needs. It has a 'manual'
value that lets users continue to influence font rendering using
the low-level font-related settings as before.

Once the schemas have this, we can support setting this session-wide.
See https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/merge_requests/79

The initial implementation of 'automatic' font rendering is fairly
simplistic: if the monitor dpi is less than 200, prefer sharpness,
so turn on metrics hinting and slight hinting. If the monitor dpi
is at least 200, we both off.
2024-04-19 12:56:34 -04:00
Matthias Clasen
558db5a3a7 settings: Allow enums as settings
We can easily handle this, and it makes such settings appear
more natural, e.g. in the inspector.
2024-04-19 12:56:34 -04:00
Matthias Clasen
bc94b4f235 widget: Simplify our font options handling
Streamline the code that sets up pango contexts.

No functional change.
2024-04-19 09:39:52 -04:00
Matthias Clasen
4c809281b2 widget: Stop hardcoding hint-font-metrics
We used to hardcode hint-font-metrics = TRUE for unscaled
rendering. Stop doing that. Users should be able to decide
for themselves.
2024-04-19 09:19:53 -04:00
Matthias Clasen
81faf7caa3 settings: Change the default of hint-font-metrics
Change the default value to TRUE. This is because we want to stop
hardcoding this value for unscaled situations, but we don't want
to change everybody's font rendering.
2024-04-19 09:19:27 -04:00
Andi Chandler
7477e8626d Update British English translation
(cherry picked from commit e26c5945a9)
2024-04-18 22:44:51 +00:00
Matthias Clasen
47f30d208c Merge branch 'matthiasc/for-main' into 'main'
Add a missing deprecation note

See merge request GNOME/gtk!7152
2024-04-18 17:23:28 +00:00
Matthias Clasen
74a1c0916a Add a missing deprecation note
GdkVulkanContext is deprecated and only exposed in the api because
we need it as return type of the (deprecated)
gdk_surface_create_vulkan_context() API.
2024-04-18 12:49:18 -04:00
Matthias Clasen
ee67edbe3a Merge branch 'matthiasc/for-main' into 'main'
inspector: Clean up refcounting in the recorder

Closes #6634

See merge request GNOME/gtk!7149
2024-04-18 00:33:17 +00:00
Matthias Clasen
ec9cdb74ef gsk: Actually punch transparent holes
In a57f7e3935 I accidentally replaced { 0, 0, 0, 0 } with
GDK_RGBA_BLACK instead of GDK_RGBA_TRANSPARENT. Oops.

Fixes: #6634
2024-04-17 20:09:13 -04:00
Matthias Clasen
ad0f9144ec inspector: Avoid writing settings back needlessly
We were a bit careless and were writing some values back to the
GtkSettings on init, possibly with rounding errors. Avoid that.
2024-04-17 19:02:57 -04:00
Matthias Clasen
3e8215a971 inspector: Cosmetics
Use GDK_RGBA macros instead of parsing colors from names for every
subsurface.
2024-04-17 16:53:52 -04:00
Matthias Clasen
8df7487e2a inspector: Clean up refcounting in the recorder
We were getting things mixed up here, and it was leading to crashes
when clicking around between frames.
2024-04-17 16:49:38 -04:00
Matthias Clasen
633692b53e NEWS: Updates 2024-04-17 15:34:26 -04:00
Matthias Clasen
e0a5c65003 Merge branch 'black-background' into 'main'
Add GtkGraphicsOffload:black-background

See merge request GNOME/gtk!7147
2024-04-17 17:38:18 +00:00
Matthias Clasen
e4753791c0 video: Use the black-background property
Instead of hardcoding a black background in the theme, use the
new property to tell the GtkGraphicsOffload widget to draw one.
2024-04-17 12:52:35 -04:00
Matthias Clasen
a57f7e3935 graphicsoffload: Add a black-background property
This property allows explicit control over whether to draw
a black background behind offloaded content or not, instead
of relying on the theme background.
2024-04-17 12:52:03 -04:00
Matthias Clasen
8de5a94eb7 Merge branch 'fixwmhints' into 'main'
x11: Remove last_wmspec_check_time

Closes #6558

See merge request GNOME/gtk!7145
2024-04-17 15:31:26 +00:00
Matthias Clasen
88872d1986 Merge branch 'rgba-tweaks' into 'main'
Use our defines for color

See merge request GNOME/gtk!7144
2024-04-17 00:17:06 +00:00
oreo639
ab33b56ec9 x11: Remove last_wmspec_check_time
In fetch_net_wm_check_window(), before updating the wmspec_check_window, a
check is performed to verify a 15s difference between last_wmspec_check_time
and the current monotonic time.

The comment suggests that this check is done to ensure that it doesn't check
for a new check window repeatedly over and over again. While that was the case
origionally, currently the last_wmspec_check_time only gets updated when
wmspec_check_window is set, which is already checked earlier, making the time
check useless.

This check causes issues on cold boots where gtk4 applications are not able
to obtain the wmspec_check_window until 15 seconds after boot, making gtk
unable to check for extended wm_hints during that time.

Fixes: #6558
2024-04-16 12:35:00 -07:00
Matthias Clasen
c37e88d561 Merge branch 'fix-typo' into 'main'
docs: Fix typo

See merge request GNOME/gtk!7146
2024-04-16 10:32:18 +00:00
Jan Willem
2638700435 Docs: Fix typo 2024-04-16 08:47:25 +00:00
Matthias Clasen
0a5a720fe1 Use gdkrgbaprivate.h in more places
This gets inline functions used where it matters.
2024-04-15 22:57:01 -04:00
Matthias Clasen
0e5f7601e4 Add some inline rgba functions
These are trivial enough to inline everywhere.
2024-04-15 22:57:01 -04:00
Matthias Clasen
e583e823b5 Use our defines for color
We have GDK_RGBA_WHITE, GDK_RGBA_BLACK and GDK_RGBA_TRANSPARENT,
lets use it instead of open-coding it.
2024-04-15 22:57:01 -04:00
Matthias Clasen
a96358046f Merge branch 'matthiasc/for-main' into 'main'
Drop another unwanted file

See merge request GNOME/gtk!7143
2024-04-16 02:21:26 +00:00
Matthias Clasen
40f26ea09b Drop another unwanted file 2024-04-15 21:40:52 -04:00
Matthias Clasen
71a7f0771b Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!7142
2024-04-16 01:32:29 +00:00
Matthias Clasen
00739718ab Drop unwanted files 2024-04-15 20:50:27 -04:00
Matthias Clasen
19881c8c06 NEWS: Updates 2024-04-15 20:50:27 -04:00
Matthias Clasen
8b0aae8536 Merge branch 'matthiasc/single-pixel-buffer' into 'main'
wayland: Use single-pixel buffer optimization for offload

See merge request GNOME/gtk!7136
2024-04-16 00:20:07 +00:00
Matthias Clasen
fbe000734a wayland: Refuse offloading when we can't
If we have a subsurface with background, but no single-pixel
buffer support, refuse to offload.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0c67b367ac subsurface: Tweak the attach implementation
Do the backend call before changing the stacking order in the
frontend. This is necessary so the backend can look at the current
stacking order to determine if it will change.
2024-04-15 19:53:46 -04:00
Matthias Clasen
f75b4aac1d wayland: Minimize work for subsurfaces
Only commit things that have changed. In the ideal scenario, only
the texture changes from frame to frame, and all the sizing related
setup and the background stay the same, causing the least amount
of work in the compositor.
2024-04-15 19:53:46 -04:00
Matthias Clasen
d563d158c0 subsurface: Add gdk_subsurface_get_sibling
This was just a missing getter. The backend implementation will
use this information to determine whether stacking changes.
2024-04-15 19:53:46 -04:00
Matthias Clasen
5c892fa4ea offload: Add more tests
Include background in offload tests.
2024-04-15 19:53:46 -04:00
Matthias Clasen
4aac64edf0 offload: Some renaming
Rename things to be more in line with the subsurface api.
2024-04-15 19:53:46 -04:00
Matthias Clasen
c97bbfdfb1 offload: Use subsurface bounds for diffing
When adding the whole subsurface to the diff, use the subsurface
bounds, which takes both the texture and the background into
account.
2024-04-15 19:53:46 -04:00
Matthias Clasen
a44598772d wayland: Use subsurface bounds for holes
When punching a hole into the opaque region, use the subsurface
bounds, which takes both the texture and the background into
account.
2024-04-15 19:53:46 -04:00
Matthias Clasen
933a0e5a98 subsurface: Some api revision and documentation
Rename things so they make more sense. The dest/source naming got
a bit unclear when we added background into the mix. Now we're going
for:

source_rect - the texture region to display
texture_rect - dimensions of the subsurface showing the texture
background_rect - dimensions of the background subsurface
bounds - union of texture_rect and background_rect

Also use this opportunity to add some api docs.
2024-04-15 19:53:46 -04:00
Matthias Clasen
e33e9c506d theme: Move the black background of the video
We need the black inside the subsurface node for the single-pixel
optimization to work, so put it there.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0108a5f56d offload: Use subsurface background optimization
Detect a black color node below the texture node and pass that
information to the subsurface, to take advange of the single-pixel
buffer optimization.

To make this work, we need to stop using the bounds of the subsurface
node for sizing the offload, and instead use either the clip or
the texture node for that.
2024-04-15 19:53:46 -04:00
Matthias Clasen
c995473407 Add more subsurface tests
Add some more tests for the basic functioning of the subsurface API.
2024-04-15 19:53:46 -04:00
Matthias Clasen
3f9bdaa4c8 Add background to subsurfaces
Make it possible for subsurfaces to have a black background on a
secondary subsurface below the actual subsurface. Using a single-pixel
buffer for that background increases the changes that the compositor
will use direct scanout for the actual subsurface.

This changes the private subsurface API. All callers have been
updated to pass an empty background rect.
2024-04-15 19:53:46 -04:00
Robert Mader
a70998aa50 wayland: Support the single-pixel-buffer protocol
This just gets the manager object. It is not used yet.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0fb1f44eec gdk: Add a debug flag to allow non-dmabuf offload
This is useful for debugging offloading without having to rely
on gstreamer giving us dmabufs. To use it, set

GDK_DEBUG=force-offload

in the environment.
2024-04-15 19:53:46 -04:00
Matthias Clasen
26cc96bb7f testsuite: Cosmetics
Correct a debug message.
2024-04-15 19:53:46 -04:00
Matthias Clasen
1c8b22cf05 subsurface: Cosmetics 2024-04-15 19:53:46 -04:00
Matthias Clasen
abbbd08931 Merge branch 'ebassi/docs-contributing' into 'main'
docs: Update contribution guide

See merge request GNOME/gtk!7141
2024-04-15 12:41:18 +00:00
Matthias Clasen
587cf28dd3 Merge branch 'rendernode-tool-pdf' into 'main'
rendernode-tool: add support for rendering to PDF

See merge request GNOME/gtk!7140
2024-04-15 10:58:36 +00:00
Emmanuele Bassi
53231a137c docs: Update contribution guide
- Fix link to the security policy
- Drop the confusing note about SSH access (with the old URL)
- Use modern idiomatic Meson subcommands for configuring and building
- Use `git switch` instead of `git checkout`
- Specify that you should always use merge requests, not patches
- Link to the handbook instead of the wiki
2024-04-15 11:56:13 +01:00
Christian Hergert
104a264d8b rendernode-tool: add support for rendering to PDF 2024-04-14 22:29:52 -07:00
Anders Jonsson
75fd582b97 Update Swedish translation
(cherry picked from commit f920f51300)
2024-04-14 11:22:05 +00:00
Matthias Clasen
89977412e9 Merge branch 'matthiasc/for-main' into 'main'
gsk: Fix a minor type mismatch

Closes #6628

See merge request GNOME/gtk!7138
2024-04-14 02:51:45 +00:00
Matthias Clasen
ce030b1b36 gsk: Fix a minor type mismatch
Use the same types in the declaration of gsk_standard_contour_init.

Fixes: #6628
2024-04-13 22:28:48 -04:00
Matthias Clasen
6c5dc8cd1f Merge branch 'matthiasc/for-main' into 'main'
wayland: Cosmetics

See merge request GNOME/gtk!7137
2024-04-13 21:56:27 +00:00
Matthias Clasen
fb4b38e5ea inspector: Fix a bunch of memory leaks
g_list_store_append is *not* transfer full. Oops.
2024-04-13 17:22:42 -04:00
Matthias Clasen
fc405f8882 wayland: Cosmetics
Don't clear the same pointer twice.
2024-04-13 17:22:42 -04:00
Benjamin Otte
afe61e28e0 Merge branch 'wip/p3732/no-additional-grid-tile' into 'main'
grid-view: make footer tile file empty space

Closes #6076

See merge request GNOME/gtk!6370
2024-04-13 15:35:43 +00:00
Peter Eisenmann
4f3f3c9ae2 grid-view: make footer tile file empty space 2024-04-13 15:35:42 +00:00
Matthias Clasen
e699685003 Merge branch 'mr7057-preparation' into 'main'
gdk/wayland: Make the surface handle empty commits

See merge request GNOME/gtk!7133
2024-04-12 15:54:33 +00:00
Robert Mader
9583195e96 gdk/wayland: Make the surface handle empty commits
In order to avoid some code duplication and ensure the Cairo and
Vulkan implementations behave like the GL one.
2024-04-12 17:04:54 +02:00
Matthias Clasen
a526f0770e Merge branch 'warning-fix' into 'main'
gdk/gsk: Fix a couple of maybe-uninitialized warnings

See merge request GNOME/gtk!7132
2024-04-12 11:55:04 +00:00
Philip Withnall
707e492f0d gsk: Fix a maybe-uninitialized warning
The compiler (gcc 13.2) thinks that `t` could be used uninitialised.
That’s obviously not the case, because there’s always going to be at
least one loop iteration due to the initial values of `t1` and `t2`.

Change the loop to a `do…while` to make that a bit clearer to the
compiler without making any functional changes to the code.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 12:08:03 +01:00
Philip Withnall
680dba6524 gdk: Fix a maybe-uninitialized warning
If there somehow end up being no `supported_versions`, `ctx` would end
up being dereferenced before being initialised. While I think that’s
unlikely, the compiler doesn’t know that, so let’s just initialise the
variable unconditionally.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-12 12:03:29 +01:00
Matthias Clasen
d1bb1d091c Merge branch 'gdk-build-dep-fix' into 'main'
build: Add a missing dependency

Closes #6618

See merge request GNOME/gtk!7127
2024-04-11 20:57:34 +00:00
Matthias Clasen
6510b876d1 build: Add a missing dependency
Add the generated gdk headers to the sources for all the backends,
to guarantee that they are generated before the library is used.

Fixes: #6618
2024-04-11 15:47:38 -04:00
Matthias Clasen
e376941e49 Merge branch 'scrollbar_accessible_range' into 'main'
a11y: Implement GtkAccessibleRange for scrollbars

Closes gnome-control-center#2994

See merge request GNOME/gtk!7129
2024-04-11 18:20:49 +00:00
Matthias Clasen
4889199b14 Merge branch 'glarea-dispose-fix' into 'main'
dmabuf texture: Survive multiple disposes

Closes #6623

See merge request GNOME/gtk!7131
2024-04-11 18:20:12 +00:00
Luca Bacci
2e15225446 Merge branch 'remove-work-arounds' into 'main'
GdkWin32: Remove some work arounds that are not needed anymore

Closes #6614

See merge request GNOME/gtk!7114
2024-04-11 17:03:08 +00:00
Matthias Clasen
9dad71513c glarea: Clean up dispose
We were getting our gl and dmabuf texture mixed up and ending
up freeing the Texture structs while they were still used as
callback data for dmabuf texture destroys. Avoid that by keeping
separate pointers for the gl and dmabuf textures.

Fixes: #6623
2024-04-11 12:48:01 -04:00
Matthias Clasen
ed072b4b5d dmabuf texture: Survive multiple disposes
dispose can be called more than once, so be safe for that.
2024-04-11 12:45:24 -04:00
Boyuan Yang
7ffc4e0a21 Update Chinese (China) translation 2024-04-11 15:46:08 +00:00
Emmanuele Bassi
b9403f4f5b Apply review suggestions 2024-04-11 14:04:12 +00:00
Lukáš Tyrychtr
9f1aa3141b a11y: Implement GtkAccessibleRange for scrollbars
Fixes gnome-control-center#2994
2024-04-11 14:25:42 +02:00
Matthias Clasen
06e905f87d Merge branch 'gtk-wlmod' into 'main'
Meson: Use wayland module

See merge request GNOME/gtk!7126
2024-04-11 01:29:29 +00:00
Xavier Claessens
2ba8dcebff Apply 1 suggestion(s) to 1 file(s) 2024-04-10 15:52:42 +00:00
Xavier Claessens
95a8def7c2 Meson: Use wayland module 2024-04-10 11:43:04 -04:00
Matthias Clasen
777799070d Merge branch 'simplify_widget_accessible_get_bounds' into 'main'
a11y: Simplify GtkWidget's GtkAccessible.get_bounds implementation

See merge request GNOME/gtk!7128
2024-04-10 15:40:44 +00:00
Lukáš Tyrychtr
0f83a9550b Proper rounding 2024-04-10 15:46:39 +02:00
Lukáš Tyrychtr
17f2443350 a11y: Simplify GtkWidget's GtkAccessible.get_bounds implementation
We can use the result from gtk_widget_get_bounds for the coordinates as well.
2024-04-10 15:32:16 +02:00
Matthias Clasen
6bfc995097 Merge branch 'matthiasc/for-main' into 'main'
docs: Update some links

See merge request GNOME/gtk!7125
2024-04-10 01:04:14 +00:00
Matthias Clasen
8068111c6e Merge branch 'fix-xi2-input-source-type-debug-msg' into 'main'
xi2: Fix incorrect input source type in Input debug message

Closes #6619

See merge request GNOME/gtk!7120
2024-04-10 00:45:14 +00:00
Matthias Clasen
6e1c47b021 Merge branch 'improve_gtkeditabledelegate_docs' into 'main'
GtkEditable: Document the usage restrictions of gtk_editable_delegate_get_accessible_platform_state

See merge request GNOME/gtk!5691
2024-04-10 00:36:44 +00:00
Matthias Clasen
aed4ced032 Merge branch 'broadway-port-2972-3130' into 'main'
[gtk4] gdk/broadway: Port !2972 and !3130 from gtk3

See merge request GNOME/gtk!4467
2024-04-10 00:12:28 +00:00
Matthias Clasen
96160ea5dc docs: Update some links
Use docs.gtk.org for all the documentation that is hosted there.
2024-04-09 20:00:00 -04:00
Matthias Clasen
c76c07ddfe Merge branch 'matthiasc/for-main' into 'main'
testsuite: Cosmetics

See merge request GNOME/gtk!7124
2024-04-09 23:41:01 +00:00
Matthias Clasen
7b82dc7ac5 inspector: Show monitor resolution 2024-04-09 19:14:01 -04:00
Matthias Clasen
a63e9d38fb gdk: Add private convenience api
Add a function to get the monitor resolution.

We may use this information in the future to make font rendering
decisions.
2024-04-09 19:13:34 -04:00
Matthias Clasen
cc8db1805d gsk: Be safer against bad font options
Some combinations of hint-style and hint-metrics lead to bad glyph
placement in the glyph cache, so avoid them.
2024-04-09 19:12:49 -04:00
Matthias Clasen
948532f3c9 Deprecate gtk_widget_set/get_font_options
cairo font options are too low-level, and setting them directly
prevents us from doing smarter things for font rendering.
2024-04-09 19:12:41 -04:00
Matthias Clasen
8f39f8d827 testsuite: Add another test
This test checks that pango attributes can be specified in serialized
form.
2024-04-09 19:06:31 -04:00
Matthias Clasen
5e28c05121 testsuite: Cosmetics
Make the builder parser test less verbose.
2024-04-09 19:06:12 -04:00
Matthias Clasen
32d15a5858 Merge branch 'builder-gtkshortcutaction-warning' into 'main'
builder: Show warning for invalid action on GtkShortcut

See merge request GNOME/gtk!7121
2024-04-09 20:36:59 +00:00
Benjamin Otte
460eaac1f4 Merge branch 'wip/otte/for-main' into 'main'
vulkan: Handle generating mipmaps for 1x1 images

Closes #6553

See merge request GNOME/gtk!7073
2024-04-09 16:25:20 +00:00
Benjamin Otte
02d7817632 demo: Use get_fps() in fishbowl demo
Hopefully that leads to somewhat more reliable fps measurements
2024-04-09 17:39:36 +02:00
Benjamin Otte
3080e2974d gpu: ceil() offscreen size before generating offscreen
The goal is to generate an offscreen at 1x scale.
When not ceil()ing the numbers the offscreen code would do it *and*
adjust the scale accordingly, so we'd end up with something like a
1.01x scale.

And that would cause the code to reenter this codepath with the goal to
generate an offscreen at 1x scale.
And indeed, this would lead to infinite recursion.

Tests included.

Fixes #6553
2024-04-09 17:39:32 +02:00
Juliano de Souza Camargo
be9d98ed38 Update Brazilian Portuguese translation 2024-04-09 13:31:35 +00:00
Leônidas Araújo
944274bc58 Update Brazilian Portuguese translation
(cherry picked from commit 235388fdcd)
2024-04-09 13:26:40 +00:00
Sabri Ünal
b555e909c4 Update Turkish translation 2024-04-09 09:55:55 +00:00
Matthijs Velsink
c0b813940e builder: Show warning for invalid action on GtkShortcut
The parsing for a `GTK_TYPE_SHORTCUT_ACTION` on a GtkShortcut in a
builder file can fail, resulting in a `NULL` GtkShortcutAction. This
currently does not result in any warnings, potentially making typos in
builder files tricky to debug.

Since `gtk_shortcut_action_parse_builder()` already sets an error if it
fails, we can just use that and simply return false.
2024-04-09 02:41:57 +02:00
Benjamin Otte
9fe9ea34fd vulkan: Handle generating mipmaps for 1x1 images
Testcase included.
2024-04-08 21:06:54 +02:00
Hansem Ro
d90dc7f75e xi2: Fix incorrect input source type in Input debug message
This drops cursor and eraser source names to account for their removal
from GdkInputSource so that GDK_DEBUG=input debug message correctly
prints source type in X11 environment.

Fixes: c1d90273 ("gdk: Drop GDK_SOURCE_ERASER")
Fixes: 3285f52d ("gdk: Drop GDK_SOURCE_CURSOR")
Closes: #6619
2024-04-08 10:15:00 -07:00
Matthias Clasen
f36f1b9829 Merge branch 'dmabuf-glarea' into 'main'
One approach to dmabufs in glarea

See merge request GNOME/gtk!7116
2024-04-07 17:24:33 +00:00
Matthias Clasen
2b09f5ea1e dmabuf: Reshuffle docs slightly
Move related parts together, for easier understanding.
2024-04-07 13:03:13 -04:00
Matthias Clasen
f51c82a2aa gtk-demo: Use offload for shadertoy
This is an easy way to verify that GtkGLArea delivers dmabufs
now, and it might have some practical uses to offload gl area.
2024-04-07 13:03:13 -04:00
Matthias Clasen
11d3be278d glarea: Return dmabuf textures
Export the GL texture as a dmabuf if we can, and provide the
texture in that form.
2024-04-07 13:03:13 -04:00
Benjamin Otte
cc98282caa Merge branch 'shortcutmanager-fix-phase-changes' into 'main'
shortcutmanager: Handle propagation phase changes of added controllers

Closes #6246

See merge request GNOME/gtk!7115
2024-04-07 15:45:51 +00:00
Matthias Clasen
85f2e1ccd8 Add gdk_dmabuf_texture_builder_set_dmabuf
Private utility api.
2024-04-07 11:12:13 -04:00
Matthias Clasen
91b98bc9e2 Add a private header
Just cosmetic reshuffling.
2024-04-07 11:12:13 -04:00
Matthias Clasen
704ee6a9d0 offload: Determine output transforms
When we look for the texture to attach to the subsurface, keep
track of transforms we see along the way, and look at their scale
component to determine if the texture needs to be flipped.
We currently don't allow rotations here.

This fixes glarea rendering being upside-down when offloaded.
2024-04-07 11:12:06 -04:00
Matthias Clasen
72e9f30937 subsurface: Add transforms
Allow to specify a D₂ transform when attaching a texture to a
subsurface, to handle flipped and rotated content. The Wayland
implementation handles these transforms by setting a buffer
transform on the subsurface.

All callers have been updated to pass GDK_TEXTURE_TRANSFORM_NORMAL.
2024-04-07 11:02:40 -04:00
Matthijs Velsink
aadaf4adf2 shortcutmanager: Track propagation phase of added controllers
GtkShortcutManager allows adding controllers to it. For the default
implementation, they get added to one of two models, based on the
propagation phase (either GTK_PHASE_CAPTURE or GTK_PHASE_BUBBLE).

However, when a controller is removed, its presence in the manager gets
checked against the current propagation phase of the controller, which
may have changed from when it was added. This can lead to crashes if the
controller was not disposed properly since it still has a reference in
one of the two models of the GtkShortcutManager.

To fix this, add a callback for `notify::propagation-phase`, which
removes the controller from all possible models and readds it again with
its current phase. This callback is only disconnected permanently when
the controller is manually removed with
`gtk_shortcut_manager_default_remove_controller()`.

Closes #6246
2024-04-07 16:29:08 +02:00
Yaron Shahrabani
d83ad6b505 Update Hebrew translation
(cherry picked from commit b19247e4ef)
2024-04-06 13:19:11 +00:00
Piotr Drąg
b647d1a58c Update Polish translation 2024-04-06 12:32:39 +02:00
Luca Bacci
3c94e91e5e GdkWin32: Do not clear surface contents when restoring from minimize
The code does not work anyway since we dropped WS_EX_LAYERED windows.
2024-04-06 10:58:40 +02:00
Luca Bacci
8a1bee1d79 GdkWin32: Don't explicitly set the transient owner as active
...when a transient child is hidden.

The system does that automatically
2024-04-06 10:58:25 +02:00
Luca Bacci
9297439de4 GdkWin32: Remove some work arounds that are not needed anymore
2cc650ce was added to work around some of the regressions
introduced by 79557271, but that commit was finally reverted
in 43476c09.

We can now revert 2cc650ce as well.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6614
2024-04-06 10:44:02 +02:00
Danial Behzadi
68cff3b108 Update Persian translation
(cherry picked from commit 58d48cd3e5)
2024-04-05 12:40:53 +00:00
Matthias Clasen
84846aace7 Merge branch 'matthiasc/for-main' into 'main'
wayland: Work around mutter deficiences

See merge request GNOME/gtk!7112
2024-04-05 09:47:34 +00:00
Athmane MOKRAOUI
7bd93730d1 Update Kabyle translation 2024-04-05 09:16:50 +00:00
Matthias Clasen
c5d05fdc88 wayland: Work around mutter deficiences
Add the environment variable NO_POINTER_VIEWPORT to force the use
of buffer scale for pointer surfaces. This is a temporary workaround
for https://gitlab.gnome.org/GNOME/mutter/-/issues/2633.
2024-04-05 11:13:24 +02:00
Asier Sarasua Garmendia
f6ff2cd1cb Update Basque translation
(cherry picked from commit e54ecf5e32)
2024-04-05 08:43:42 +00:00
Matthias Clasen
9b0060e84d Merge branch 'matthiasc/for-main' into 'main'
Bump the cairo dep

See merge request GNOME/gtk!7110
2024-04-05 08:00:56 +00:00
Matthias Clasen
8d5633cb88 Drop code handling old cairo
We require cairo 1.18 now, so know that we will get subpixel
positioning for text, and have a little less uncertainty in
our font rendering.
2024-04-05 09:00:22 +02:00
Matthias Clasen
f74b1d48b6 Merge branch 'update-gtkswitch-state-docs' into 'main'
docs: Clarify state and active properties in GtkSwitch

Closes #6600

See merge request GNOME/gtk!7109
2024-04-05 06:57:16 +00:00
Matthias Clasen
27ebf756fe Bump the cairo dep
Require cairo 1.18, now that we have this stable release.
2024-04-05 08:01:39 +02:00
Dylan McCall
631da2e723 docs: Clarify state and active properties in GtkSwitch
Remove duplicate descriptions of the switch's appearance, describe more
particularly how the default signal handler for `GtkSwitch::state-set`
behaves, and add a suggestion that the `state` property should
only be set when communicating a delayed state change.

Fixes #6600
2024-04-04 20:29:07 -07:00
Matthias Clasen
b5531d3d6f Merge branch 'michaelweghorn/a11y_atspi_getcharacterextents_getoffsetatpoint_fixes' into 'main'
a11y atspi: Misc fixes for AT-SPI Text methods GetCharacterExtents, GetRangeExtents and GetOffsetAtPoint

See merge request GNOME/gtk!7104
2024-04-04 22:28:50 +00:00
Martin
5e6bc41fdd Update Slovenian translation 2024-04-04 22:15:05 +00:00
Matthias Clasen
d0581af2af Merge branch 'matthiasc/for-main' into 'main'
printing: Add context to some strings

See merge request GNOME/gtk!7107
2024-04-04 16:15:30 +00:00
Artur S0
cec746804d Update Russian translation 2024-04-04 15:36:42 +00:00
Matthias Clasen
ade1aaa8be printing: Add context to some strings
The job priority strings need context to disambiguate them from
similar short strings elsewhere.
2024-04-04 16:56:50 +02:00
Matthias Clasen
345d23898d Merge branch 'matthiasc/for-main' into 'main'
Add context to some translatable strings

Closes #6609

See merge request GNOME/gtk!7105
2024-04-04 14:38:06 +00:00
Matthias Clasen
415717276a Merge branch 'fix-spinbutton-updates' into 'main'
Revert "spinbutton: Tangential refactoring, small fix"

Closes #6599

See merge request GNOME/gtk!7103
2024-04-04 13:27:56 +00:00
Matthias Clasen
cebe640bce Add context to some translatable strings
This was requested by Alexandre Franke.

Fixes: #6609
2024-04-04 15:25:07 +02:00
Emmanuele Bassi
73084b761f Apply code style fixes from review 2024-04-04 13:05:24 +00:00
Athmane MOKRAOUI
eb13ecfbe7 Update Kabyle translation 2024-04-04 12:13:23 +00:00
Matthias Clasen
85c4507609 spinbutton: Fix a corner case
Fix a bug where a zero increment would make the value unsettable,
when the more natural operation is to allow any value to be set.
2024-04-04 14:11:10 +02:00
Matthias Clasen
fcb6c8e447 Revert "spinbutton: Tangential refactoring, small fix"
This reverts commit 3d898af736.

The commit caused a regression where, depending on the update policy,
we would not apply value changes at all.

Fixes: #6599
2024-04-04 14:00:25 +02:00
Michael Weghorn
0b27f39c2b a11y atspi: Don't require GtkWidget for GetOffsetAtPoint
Use the existing `gtk_at_spi_translate_coordinates_to_accessible`
to translate the coordinates passed as parameters to AT-SPI
Text's GetOffsetAtPoint method instead of having a
custom GtkWidget-specific translation.

This makes this work for non-GtkWidget GtkAccessibles
as well, and also adds support for parent-relative
coordinates (ATSPI_COORD_TYPE_PARENT).
2024-04-04 13:53:49 +02:00
Michael Weghorn
2101f880af a11 atspi: Fix type for GetOffsetAtPoint result
With the fix from the previous commit in place,
trying to use the GetOffsetAtPoint AT-SPI Text method
from Accerciser's IPython console with the gtk4-demo
Hypertext example would still give this error:

    In [46]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[46]: (58, 20, 5, 19)
    In [47]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    ---------------------------------------------------------------------------
    Error                                     Traceback (most recent call last)
    Cell In[47], line 1
    ----> 1 acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)

    File /usr/lib/python3/dist-packages/pyatspi/text.py:346, in Text.getOffsetAtPoint(self, x, y, coordType)
        331 def getOffsetAtPoint(self, x, y, coordType):
        332         """
        333         Get the offset of the character at a given onscreen coordinate.
        334         The coordinate system used to interpret x and y is determined
       (...)
        344         -1 if the point is outside the bounds of any glyph.
        345         """
    --> 346         return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)

    Error: atspi_error: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. (1)

and the gtk4-demo output would show the actual problem:

    (gtk4-demo:563491): GLib-GIO-WARNING **: 13:18:27.652: Type of return value is incorrect: expected '(i)', got '(u)'

Fix this by returning an int as expected.

With this in place, the result is now as expected:

    In [48]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[48]: (58, 20, 5, 19)
    In [49]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    Out[49]: 5
2024-04-04 13:52:28 +02:00
Michael Weghorn
2cc241732d a11y atspi: Fix input variant type for Text's GetOffsetAtPoint
Trying to use the AT-SPI Text GetOffsetAtPoint method
didn't work.

For example, trying to use it from Accerciser's IPython
console with the gtk4-demo Hypertext example, would
give this error:

    In [45]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    ---------------------------------------------------------------------------
    Error                                     Traceback (most recent call last)
    Cell In[45], line 1
    ----> 1 acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)

    File /usr/lib/python3/dist-packages/pyatspi/text.py:346, in Text.getOffsetAtPoint(self, x, y, coordType)
        331 def getOffsetAtPoint(self, x, y, coordType):
        332         """
        333         Get the offset of the character at a given onscreen coordinate.
        334         The coordinate system used to interpret x and y is determined
       (...)
        344         -1 if the point is outside the bounds of any glyph.
        345         """
    --> 346         return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)

    Error: atspi_error: Unsupported coordinate space (1)

and the gtk4-demo output would show the actual problem:

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.862: the GVariant format string '(i&s)' has a type of '(is)' but the given value has a type of '(iiu)'

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.863: g_variant_get: assertion 'valid_format_string (format_string, TRUE, value)' failed

Specify the proper type, which gets us one step further at least.
2024-04-04 13:50:13 +02:00
Michael Weghorn
c01782b0a9 a11y atspi: Reuse helper to translate text coords
Instead of reimplementing translating coordinates
relative to a GtkAccessible in a way that requires
that the GtkAccessible is a GtkWidget, reuse the
existing helper function
`gtk_at_spi_translate_coordinates_from_accessible`
in the implementations of AT-SPI Text methods
GetCharacterExtents and GetRangeExtents.

This makes the implementation work for non-GtkWidget
GtkAccessibles, adds support for parent-relative
coordinates (ATSPI_COORD_TYPE_PARENT)
and also fixes an issue with incorrect extents
being reported in a quick test with the "Hypertext"
sample from gtk4-demo.

Sample for querying extents in Accerciser's IPython
console for the Hypertext sample previously gave this
result:

    In [39]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[39]: (58, 20, -53, -1)

Now, a positive width and height are returned as expected and
the result matches the one when using the GTK 3 version
in gtk3-demo:

    In [1]: acc.queryText().getCharacterExtents(5, pyatspi.XY_WINDOW)
    Out[1]: (58, 20, 5, 19)
2024-04-04 13:50:13 +02:00
Michael Weghorn
a62831562f a11y atspi: Move helpers for coord translation to gtkatspiutils
Move the (so far) local helper functions used for the
AT-SPI Component method implementations,
`translate_coordinates_from_accessible` and
`translate_coordinates_to_accessible` to
`gtkatspiutilsprivate` and add a "gtk_at_spi_"
prefix to the function names.

This will allow to reuse them elsewhere in
upcoming commits.
2024-04-04 13:50:06 +02:00
Matthias Clasen
40dd81e1a4 Merge branch 'drop-redundant-a11y-code' into 'main'
a11y: Drop the per-widget text implementations

See merge request GNOME/gtk!6924
2024-04-04 10:03:15 +00:00
Matthias Clasen
a9f3a52c18 Drop some per-widget a11y text implementations
We still keep the editable implementation, since not all our
editable widgets implement GtkAccessibleText yet, but the label,
inscription and textview implementations are unused.
2024-04-04 10:14:46 +02:00
Matthias Clasen
0978912922 Merge branch 'macos-color-picker' into 'main'
macos: color picker

Closes #5137

See merge request GNOME/gtk!7099
2024-04-04 06:56:08 +00:00
Matthias Clasen
3c9923d395 Merge branch 'a11y-text-work' into 'main'
a11y: Implement GetOffsetAtPoint

See merge request GNOME/gtk!7004
2024-04-04 05:31:17 +00:00
Matthias Clasen
0296f49eb0 Merge branch 'dynamic-cursor' into 'main'
gdk: Add dynamic cursors

See merge request GNOME/gtk!7067
2024-04-04 05:30:54 +00:00
Matthias Clasen
4b7a550366 Merge branch 'bump-pango-dep' into 'main'
Bump the pango dep

Closes #6554

See merge request GNOME/gtk!7100
2024-04-04 05:29:56 +00:00
Matthias Clasen
37e18b784e gtk-demo: Add a callback cursor
Make one of the GTK logo cursors in the cursors demo use a callback
cursor that follows the cursor theme size, to show that that is
possible.
2024-04-04 01:07:28 +02:00
Matthias Clasen
1275a2cb8d wayland: Use a viewport for pointer surfaces
This should give us more flexibility for buffer size vs surface
size.

Unfortunately, mutter doesn't play along currently, so this is
only useful for kwin, weston or sway.
2024-04-04 01:07:28 +02:00
Matthias Clasen
67a6f343a0 wayland: Keep pointer_output_scale as double
We can round up to the next integer when we need to.
2024-04-04 01:07:28 +02:00
Matthias Clasen
a98e6bff85 Add a test app
This app has a dynamic cursor that is the GTK logo, loaded from
an SVG to make it come out at the nominal size of the cursor
theme, while taking fractional scaling into account.
2024-04-04 01:07:28 +02:00
Matthias Clasen
d0f5644771 macos: Handle callback cursors
This implementation matches the X11 one closely.
2024-04-04 01:07:28 +02:00
Matthias Clasen
b1a3ac8330 win32: Handle callback cursors
This implementation matches the X11 one closely.
2024-04-04 01:07:28 +02:00
Matthias Clasen
80811069ac x11: Handle callback cursors
For these cursors, get the texture for the cursor image by
calling the callback. We always use scale 1.
2024-04-04 01:07:28 +02:00
Matthias Clasen
6e3dc1e669 wayland: Handle callback cursors
For these cursors, get the texture for the cursor image by
calling the callback. We don't do any caching of the cursor
images for now.
2024-04-04 01:07:28 +02:00
Matthias Clasen
d1aa0a74e4 gdk: Add callback cursors
Add a variant of GdkCursor that obtains the texture for the cursor
via a callback. The callback gives us the flexibility to handle
fractional scales and update the cursor for cursor theme size
changes as well as scale changes.
2024-04-04 01:07:28 +02:00
Matthias Clasen
7a6fb09179 inscription: Add tests for gtk_accessible_text_get_offset
Test that we get the expected values on an inscription.
2024-04-04 01:05:38 +02:00
Matthias Clasen
5732c5e3d0 label: Add tests for gtk_accessible_text_get_offset
Test that we get the expected values on a label.
2024-04-04 01:05:38 +02:00
Matthias Clasen
79fb3d9b0c textview: Implement gtk_accessible_text_get_offset
This is relatively straightforward, reusing existing infrastructure.
2024-04-04 01:05:31 +02:00
Matthias Clasen
17455054f1 text: Implement gtk_accessible_text_get_offset
Reusing existing infrastructure as much as possible.
2024-04-04 01:04:47 +02:00
Matthias Clasen
763f51cb98 inscription: Implement gtk_accessible_text_get_offset
This is copying the corresponding code from GtkLabel.
2024-04-04 01:04:13 +02:00
Matthias Clasen
9fb78603ec label: Implement gtk_accessible_text_get_offset
We can reuse existing infrastructure for this.
2024-04-04 01:03:33 +02:00
Matthias Clasen
f802be88e9 a11y: Use gtk_accessible_text_get_offset
Implement GetOffsetAtPoint using gtk_accessible_text_get_offset.
2024-04-04 01:02:42 +02:00
Matthias Clasen
b9d2049991 a11y: Add gtk_accessible_text_get_offset
This is not implemented yet.
2024-04-04 01:02:41 +02:00
Matthias Clasen
cfe3558610 a11y: Add GetOffsetAtPoint
We don't handle it yet.
2024-04-04 01:00:25 +02:00
Matthias Clasen
35d15de3b6 label: Fix provider info lifecycle
This is a follow-up fix to a48df87a85, which was insufficient.
2024-04-04 01:00:25 +02:00
Matthias Clasen
23a336df0e Bump the pango dep
Require pango 1.52, and drop the fallback code.

Fixes: #6554
2024-04-04 00:56:24 +02:00
Matthias Clasen
bacdc735a4 Merge branch 'a11y-text-work2' into 'main'
a11y: Add gtk_accessible_text_get_extents

See merge request GNOME/gtk!7006
2024-04-03 22:55:30 +00:00
Matthias Clasen
19a168446e textview: Implement gtk_accessible_text_get_extents
There is some question if this needs to be clipped to widget extents
- if the textview is in a scrolled window, we can easily return
extents here that go beyond the window or event the screen.
2024-04-04 00:29:24 +02:00
Matthias Clasen
47ec7bc66d text: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
b4178870dd inscription: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
03ef792802 label: Implement gtk_accessible_text_get_extents
Using existing infrastructure.
2024-04-04 00:29:24 +02:00
Matthias Clasen
7955efef6c atspi: Use gtk_accessible_text_get_extents
Implement the GetCharacterExtents and GetRangeExtents methods of
the atspi Text interface using the new GtkAccessibleText api.
2024-04-04 00:29:24 +02:00
Matthias Clasen
3134003376 a11y: Add gtk_accessible_text_get_extents
This will be used to implement GetRangeExtents in atspi.
2024-04-04 00:29:24 +02:00
Matthias Clasen
a508860d1f Merge branch 'matthiasc/for-main' into 'main'
Start 4.15 development

See merge request GNOME/gtk!7098
2024-04-03 22:04:11 +00:00
Arjan Molenaar
c835ca41e0 macos: Pick color with NSColorSampler
NSColorSampler is the easiest way to pick a color.
It does require macOS 10.15+ to work.
2024-04-03 21:10:20 +02:00
Arjan Molenaar
2d5eafd014 macos: Add skeleton for color picker 2024-04-03 21:01:24 +02:00
Matthias Clasen
9b34878208 Merge branch 'cursor-demo-cosmetics' into 'main'
gtk-demo: Cosmetic changes

See merge request GNOME/gtk!7068
2024-04-03 14:08:38 +00:00
Matthias Clasen
4b1b956d27 Start 4.15 development 2024-04-03 15:53:49 +02:00
Matthias Clasen
0dd58c4d1b gtk-demo: Cosmetic changes
Remove the periods from the tooltips in the cursor demo.
Tooltips are better without periods.
2024-04-03 14:39:51 +02:00
Matthias Clasen
4b2b6d6212 Merge branch 'matthiasc/for-main' into 'main'
Post-release version bump

See merge request GNOME/gtk!7097
2024-04-03 12:23:07 +00:00
Matthias Clasen
2cdb53d524 Post-release version bump 2024-04-03 14:19:31 +02:00
Matthias Clasen
4f7721e742 Merge branch 'matthiasc/for-main' into 'main'
4.14.2

See merge request GNOME/gtk!7096
2024-04-03 12:18:20 +00:00
Matthias Clasen
29c29b0e64 4.14.2 2024-04-03 12:20:34 +02:00
Matthias Clasen
3d7fc0a598 Merge branch 'cff-font-hinting' into 'main'
gsk: Use hinted extents

Closes #6577 and #6568

See merge request GNOME/gtk!7086
2024-04-03 10:12:47 +00:00
Matthias Clasen
9e3e0052dc Merge branch 'fix_accessible_text_changed_notifications' into 'main'
a11y: Provide correct end offset for GtkText text insertions

Closes libadwaita#824

See merge request GNOME/gtk!7075
2024-04-03 09:37:52 +00:00
Yaron Shahrabani
5ecfcaec0d Update Hebrew translation 2024-04-03 09:13:56 +00:00
Matthias Clasen
cc24401dfb Drop unused private API
We are not using gsk_get_unhinted_glyph_string_extents anymore.
2024-04-03 10:53:55 +02:00
Matthias Clasen
f445d8b518 gsk: Use hinted extents
This works better for cff fonts, where hinting is not as local as
what the autohinter does for ttf fonts, and it does not seem to
have negative effects.

Fixes: #6577
Fixes: #6568
2024-04-03 10:52:13 +02:00
Carlos Garnacho
af4c9ea61e Merge branch 'provide-touch-serial-later' into 'main'
gdk/wayland: Proivde latest touch serial even after a touch ended

See merge request GNOME/gtk!5782
2024-04-03 08:43:03 +00:00
Matthias Clasen
4a75c288b2 Merge branch 'cff-font-hinting2' into 'main'
gsk: Keep metrics hinting on when rendering

See merge request GNOME/gtk!7093
2024-04-02 08:48:07 +00:00
Andre Klapper
89fca57e68 Docs / README: Fix issue tracker URL
Link to public Issues overview page instead of a 404 New Issue page
when you are not already logged into GNOME GitLab.
2024-04-02 10:10:11 +02:00
Matthias Clasen
d50b780551 gsk: Keep metrics hinting on when rendering
It turns out that we mispositioned glyphs with some cff fonts
when metrics hinting is off, and hinting is on. Since we don't
fully understand the interactions of these settings at this point,
lets preserve metrics hinting as it was on the font we got.

This at least gives folks a workaround for when they experience
clipped rendering with cff fonts: Turn on hint-metrics.

We forced hint metrics off here because it made Pango do some
creative wfh for hex boxes at small sizes, but I've dropped that
on the Pango side.
2024-04-02 09:10:46 +02:00
Matthias Clasen
f4a8787219 Merge branch 'empty-settings-portal' into 'main'
wayland: Fix detection of empty settings portal response

See merge request GNOME/gtk!7090
2024-04-02 06:44:08 +00:00
Chris Williams
979d0f4b1d wayland: Fix detection of empty settings portal response
The ReadAll method returns a one-element tuple, so
g_variant_n_children() is always 1.
2024-04-01 10:33:00 -04:00
Matthias Clasen
5af7c7d0f2 Merge branch 'matthiasc/for-main' into 'main'
ci: Avoid silly date-dependent failures

See merge request GNOME/gtk!7088
2024-03-31 13:59:11 +00:00
Matthias Clasen
90aff59826 Merge branch 'no-fc-build' into 'main'
Fix build without fontconfig

Closes #6591

See merge request GNOME/gtk!7087
2024-03-31 13:58:21 +00:00
Matthias Clasen
f0f3ea1b3e Fix build without fontconfig
We were missing some ifdefs for Windows builds.

Fixes: #6591
2024-03-31 13:08:01 +02:00
Matthias Clasen
f4b7f5de2f ci: Avoid silly date-dependent failures
GtkCalendar defaults to the current date, and things get murky
if the current day is number 30 or 31 in a month. Avoid these
problems.
2024-03-31 09:57:50 +02:00
Danial Behzadi
ca5af396b0 Update Persian translation 2024-03-30 20:31:19 +00:00
Ekaterine Papava
9f56be3551 Update Georgian translation 2024-03-30 18:26:28 +00:00
Martin
389f41ead7 Update Slovenian translation 2024-03-30 17:03:18 +00:00
Yuri Chornoivan
62108f8c30 Update Ukrainian translation 2024-03-30 09:27:21 +00:00
Matthias Clasen
d3206f9b67 Merge branch 'inspector-font-settings' into 'main'
inspector: Add font settings

See merge request GNOME/gtk!7085
2024-03-30 09:14:59 +00:00
Emmanuele Bassi
9b81f4cc31 Merge branch 'ebassi/doc-fixes' into 'main'
docs: Fix the reference link

See merge request GNOME/gtk!7084
2024-03-29 14:56:41 +00:00
Matthias Clasen
a864084a4e inspector: Add font settings
Add dedicated UI for font-related settings.

This makes debugging font rendering easier.
2024-03-29 15:55:36 +01:00
Matthias Clasen
ba44464d2a inspector: Cosmetics
Line up the scale+entry rows better.
2024-03-29 15:55:36 +01:00
Emmanuele Bassi
9509876f10 docs: Fix the reference link 2024-03-29 13:31:36 +00:00
Matthias Clasen
f79549f5fc Merge branch 'typo-fix' into 'main'
docs: Corrected typo on gtkDirectoryList description

See merge request GNOME/gtk!7083
2024-03-29 06:47:37 +00:00
maxrdz
bfb451ff4d docs: Corrected typo on gtkDirectoryList description 2024-03-28 22:56:18 -07:00
Benjamin Otte
edfbfb2ba7 Merge branch 'wip/otte/msys-build' into 'main'
Fix msys CI build

Closes #6580

See merge request GNOME/gtk!7082
2024-03-28 20:50:24 +00:00
Benjamin Otte
6aa37a116d build: Install vulkan-headers on msys CI
Apparently those are 2 packages.

Fixes #6580
2024-03-28 21:09:44 +01:00
Benjamin Otte
a34c018592 build: Use "meson setup" instead of just "meson"
Gets rid of a warning.
2024-03-28 21:09:44 +01:00
Benjamin Otte
710d8b948b build: Remove stray file
How did that one get here?
2024-03-28 21:09:44 +01:00
Benjamin Otte
3df85581d5 Merge branch 'wip/otte/6582' into 'main'
wayland: On hide, remove frame callbacks from subsurfaces

Closes #6582

See merge request GNOME/gtk!7081
2024-03-28 19:59:29 +00:00
Benjamin Otte
91e3bc4496 wayland: On hide, remove frame callbacks from subsurfaces
Fixes subsurfaces receiving frame callbacks while the surface is hidden
or already destroyed.

Fixes #6582
2024-03-28 20:29:06 +01:00
Sabri Ünal
1f5df481a5 Update Turkish translation 2024-03-28 14:35:29 +00:00
Matthias Clasen
768522ce7f Merge branch 'matthiasc/for-main' into 'main'
icontheme: Trust the compiler

See merge request GNOME/gtk!7076
2024-03-28 00:02:50 +00:00
Benjamin Otte
5f4e5db91b Merge branch 'gtklistitemwidget-focus' into 'main'
gtk: Fix GtkListItemWidget focus chain

Closes #6340

See merge request GNOME/gtk!6777
2024-03-27 21:35:56 +00:00
Matthias Clasen
c5f73cb406 Tweak the eglconfig description once more
Just always print the depth and stencil buffer depth,
for maximum clarity.
2024-03-27 16:30:27 +01:00
Lukáš Tyrychtr
86c4a9b3bd a11y: Provide correct end offset for GtkText text insertions
Fixes libadwaita#824
2024-03-27 16:24:32 +01:00
Matthias Clasen
fb915dc8da NEWS: Updates 2024-03-27 14:18:16 +01:00
Matthias Clasen
7a2569be14 icontheme: Trust the compiler
Just trust the compiler to replace strlen (literal) by the length.
2024-03-27 14:18:16 +01:00
Athmane MOKRAOUI
b1eed1c153 Add Kabyle translation 2024-03-26 11:34:22 +00:00
Martin
fac6f6c712 Update Slovenian translation 2024-03-24 23:19:54 +00:00
Martin
3f1fc798f0 Update Slovenian translation 2024-03-24 23:17:49 +00:00
Luca Bacci
e6a86f61dc Merge branch 'fix-issue-3749' into 'main'
GdkWin32: Always set WS_MINIMIZEBOX on GdkToplevel

Closes #3749

See merge request GNOME/gtk!7072
2024-03-22 17:57:06 +00:00
Matthias Clasen
2799632c02 Merge branch 'scalefix' into 'main'
GtkScale: improving symmetry and value positioning

Closes #5171

See merge request GNOME/gtk!6935
2024-03-22 16:18:48 +00:00
Luca Bacci
8ffa681e02 GdkWin32: Always set WS_MINIMIZEBOX on GdkToplevel
Regardless if server-side decorated or not. This way the shell knows
that the window can be minimized.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3749
2024-03-22 16:47:59 +01:00
Matthias Clasen
154035e76f Merge branch 'entry-progress' into 'main'
theme: Make sure progress in entries is visible

Closes #6201

See merge request GNOME/gtk!7071
2024-03-22 15:00:48 +00:00
Matthias Clasen
1d4c664bfa theme: Make sure progress in entries is visible
Give the trough a min height, so it doesn't shrink to nothing.

Fixes: #6201
2024-03-22 09:34:11 -04:00
Matthias Clasen
85a650afce Merge branch 'dnd-cursor-malaise' into 'main'
wayland: Guarantee dnd-move as a cursor name

See merge request GNOME/gtk!7070
2024-03-22 02:15:32 +00:00
Matthias Clasen
f6c4d3731c dnd: Go back to using dnd-move as move cursor
The move cursor in Adwaita is stuck with the 4-headed arrow image
which isn't suitable for a dnd cursor.

See https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/issues/286
2024-03-21 21:36:38 -04:00
Matthias Clasen
5e9070145e wayland: Guarantee dnd-move as a cursor name
We need to go back to using this, since move is widely abused
and thus can't change its image to one thats appropriate for dnd.
2024-03-21 21:35:45 -04:00
Matthias Clasen
81ced841dd Merge branch 'matthiasc/for-main' into 'main'
inspector: Show presentation time protocol

See merge request GNOME/gtk!7069
2024-03-21 12:35:33 +00:00
Matthias Clasen
9837a9dcfd inspector: Show presentation time protocol
We have a list of all the used Wayland protocols and their versions
in the inspector. Lets keep it up-to-date.
2024-03-21 07:29:58 -04:00
Matthias Clasen
1704ec3c7d Merge branch 'wip/chergert/presentation-time' into 'main'
gdk/wayland: implement client side of presentation-time

See merge request GNOME/gtk!6987
2024-03-21 11:28:19 +00:00
Matthias Clasen
c70a326055 Merge branch 'matthiasc/for-main' into 'main'
Sync cursor images with Adwaita

See merge request GNOME/gtk!7065
2024-03-21 02:37:35 +00:00
Christian Hergert
53616a73e9 gdk/wayland: use wp_presentation for more accurate frame timings
This attempts to improve the accuracy for the "presentation_time" of an
individual GdkFrameTimings. That information is currently filled in as soon
as we get a frame callback. However, if presentation-time wayland protocol
is available, that will be used to supliment a more accurate time which
may improve future presentation-time predictions within GdkFrameClockIdle.

The protocol states that all related and sub surfaces will receive the
same information so it is safe that this could be registered for more
than just the toplevel. The information becomes idempotent.
2024-03-20 14:45:58 -07:00
Jordan Petridis
2d3a3d6a78 Merge branch 'alatiera/ci-vulkan' into 'main'
flatpak-build.sh: Do not disable vulkan

See merge request GNOME/gtk!7066
2024-03-20 20:15:54 +00:00
Jordan Petridis
6ca9e5987b flatpak-build.sh: Do not disable vulkan
In a94d7abf0d we removed
the explicit disable from the manifest.

Now we should also have the CI build the vulkan render as well.
2024-03-20 21:18:13 +02:00
Matthias Clasen
2c1590001f Sync cursor images with Adwaita
Several cursor metaphors were changes in Adwaita. Update our docs
and the Cursors demo to match.
2024-03-20 13:19:12 -04:00
Matthias Clasen
82aee038e9 Merge branch 'alatiera/ci-vulkan' into 'main'
flatpak demos: Enable vulkan backend

See merge request GNOME/gtk!7064
2024-03-20 14:46:04 +00:00
Jordan Petridis
a94d7abf0d flatpak demos: Enable vulkan backend
glslc is now in the Sdk itself

https://gitlab.gnome.org/GNOME/gnome-build-meta/-/merge_requests/2640
2024-03-20 15:47:42 +02:00
Matthias Clasen
3b87903889 Merge branch 'wayland-min-version' into 'main'
wayland: Check some required globals

See merge request GNOME/gtk!7062
2024-03-20 02:57:06 +00:00
Matthias Clasen
191f826075 wayland: Only set buffer scale if we can
We check this in some other places, so be consistent.
2024-03-19 22:22:53 -04:00
Matthias Clasen
5d52c43074 wayland: Check all required globals for subsurfaces
Before trying to use subsurfaces, make sure we have both
a subcompositor and a viewporter.
2024-03-19 22:22:53 -04:00
Matthias Clasen
f6a67aeb20 wayland: Check some required globals
This may be largely cosmetics, since these are core protocols that
are unlikely to ever be missing. But lets check anyway.
2024-03-19 17:28:25 -04:00
Jordi Mas
370e2f0940 Update Catalan translation 2024-03-19 21:37:20 +01:00
Alexandre Franke
2ec9fc26d3 Update French translation 2024-03-19 13:06:37 +00:00
Matthias Clasen
c2d898d462 Merge branch 'fix-macos-typo' into 'main'
quartz: Fix a crash

See merge request GNOME/gtk!7059
2024-03-19 03:11:58 +00:00
Matthias Clasen
7c04231255 Merge branch 'macos-remove-shadows' into 'main'
macos: Drop shadow related code from macos backend

See merge request GNOME/gtk!7048
2024-03-19 02:38:38 +00:00
Arjan Molenaar
08216dcee9 macos: Drop shadow related code from macos backend 2024-03-19 02:38:37 +00:00
Matthias Clasen
9817df12ff quartz: Fix a crash
This was an oversight in 816f8807a3.
2024-03-18 21:51:24 -04:00
Matthias Clasen
5b0e8eb574 Merge branch 'fix-macos-typo' into 'main'
macos: Fix a typo in the appmenu handling code

See merge request GNOME/gtk!7055
2024-03-19 01:49:08 +00:00
Matthias Clasen
cecde85faa Merge branch 'drag-cursor-tweak' into 'main'
dnd: Use the default cursor during motion

Closes #6337 and #6511

See merge request GNOME/gtk!7058
2024-03-19 01:46:35 +00:00
Matthias Clasen
aa95b4f341 dnd: Use the default cursor during motion
When no action is selected, use the default cursor, and only
switch to one of the action-indicating cursors when we are over
a drop target.

Fixes: #6337
Fixes: #6511
2024-03-18 21:17:55 -04:00
Matthias Clasen
816f8807a3 macos: Fix a typo in the appmenu handling code
We were using APP_DATA in one place, and APP_MENU in the other.
Just stop using object data for this.
2024-03-18 18:49:55 -04:00
Martin
26d3c407b3 Update Slovenian translation 2024-03-18 17:36:52 +00:00
Matthias Clasen
a973e8ea8d Merge branch 'gl-offload-fixes' into 'main'
gl: Handle offloads in offscreen context better

Closes #6551

See merge request GNOME/gtk!7053
2024-03-18 15:22:22 +00:00
Matthias Clasen
b007597c58 Merge branch 'macos-application-demo' into 'main'
Revert "macos: fix weird menubar rendering."

Closes #6524

See merge request GNOME/gtk!7052
2024-03-18 14:40:45 +00:00
Matthias Clasen
1e83a44c93 gl: Handle offloads in offscreen context better
Back out of offloading below if we are in an offscreen context,
since the hole will get lost in the offscreen.

Fixes: #6551
2024-03-18 08:41:31 -04:00
Matthias Clasen
259ad83de9 macos: Fix up app menu support
We were forgetting to add the newly loaded app menu to the
combined menubar. Pointed out by Dominik Reichardt in #6524.

Fixes: #6524
2024-03-18 07:50:30 -04:00
Matthias Clasen
b4f5432d5a gtk4-demo: Clean up the application demo
This partially reverts ca1c570c21.
2024-03-17 22:29:22 -04:00
Matthias Clasen
4fe4523c49 Revert "macos: fix weird menubar rendering."
This reverts commit 75868dfee4.
2024-03-17 22:29:22 -04:00
Gergo Koteles
34028ea31e GtkScale: move value in line with the through.
The value is between the through and the markups, and appears scattered.

Move it in line with the through.

Fixes: #5171
2024-02-23 02:04:24 +01:00
Gergo Koteles
4244314a40 GtkScale: add symmetry border to the scales without markups
The scales with marks require css adjustments for center positioning.

Add border to the other side to make it symmetrical.

Fixes: #5171
2024-02-23 01:58:47 +01:00
Kévin Commaille
e6046e9493 gtk: Fix GtkListItemWidget focus chain
It would not check if the focus child can handle the focus,
so it wouldn't be possible to navigate through each focusable descendant

Fixes #6340
2024-01-17 15:14:12 +01:00
Lukáš Tyrychtr
02cdb36421 Document what to do if the preconditions can not be met 2023-05-22 12:22:18 +02:00
Lukáš Tyrychtr
b3d4d70bc1 GtkEditable: Document the usage restrictions of gtk_editable_delegate_get_accessible_platform_state
The API is not always useful, because it depends on the position of the
delegated to widget in the widget tree, so document that.
2023-05-22 12:22:18 +02:00
Jonas Dreßler
e5ffbb19c0 gdk/wayland: Proivde latest touch serial even after a touch ended
When grabbing the seat for an xdg popup using xdg_popup_grab() in response
to a touch-end event, we request the grab a little late and the touch is no
longer being tracked by gdkseat. This means that
_gdk_wayland_seat_get_last_implicit_grab_serial() right now can not provide
us with the serial for that touchpoint, because that serial was stored on
the GdkWaylandTouchData that is already gone.

To still provide the compositor a valid serial in that case, store the
serial of the latest touchpoint more persistently in GdkWaylandSeat itself,
so that we can still access it when the touchpoint has already ended.
2023-04-03 15:12:55 +02:00
Maxim Zakharov
715c0bfc0a gdk/broadway: Port !2972 and !3130 from gtk3
!2972 fixes touchscreen events processing
 !3130 adds support for Android/Chrome on-screen keyboard
2022-02-11 09:29:57 +11:00
390 changed files with 17148 additions and 15806 deletions

View File

@@ -445,9 +445,8 @@ reference:
--force-fallback-for=gdk-pixbuf,pango
-Dintrospection=enabled
-Ddocumentation=true
-Dgtk_doc=true
-Dgdk-pixbuf:gtk_doc=true
-Dpango:gtk_doc=true
-Dpango:documentation=true
-Dbuild-demos=false
-Dbuild-examples=false
-Dbuild-tests=false

Binary file not shown.

View File

@@ -19,13 +19,12 @@ flatpak build ${builddir} meson \
--buildtype=debugoptimized \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dvulkan=disabled \
-Dbuild-tests=false \
-Dbuild-testsuite=false \
-Dbuild-examples=false \
-Dintrospection=disabled \
-Dbuild-demos=true \
-Ddemo-profile=devel \
-Dprofile=devel \
_flatpak_build
flatpak build --env=CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA ${builddir} ninja -C _flatpak_build install

View File

@@ -34,7 +34,8 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-shared-mime-info \
mingw-w64-$MSYS2_ARCH-python-gobject \
mingw-w64-$MSYS2_ARCH-shaderc \
mingw-w64-$MSYS2_ARCH-vulkan
mingw-w64-$MSYS2_ARCH-vulkan \
mingw-w64-$MSYS2_ARCH-vulkan-headers
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
@@ -44,7 +45,7 @@ export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
meson \
meson setup \
-Dx11-backend=false \
-Dwayland-backend=false \
-Dwin32-backend=true \

View File

@@ -35,7 +35,7 @@ The issue tracker is meant to be used for actionable issues only.
You should not open a new issue for security related questions.
When in doubt, follow [security](https://security.gnome.org/).
When in doubt, follow the process for [GNOME security issues](https://security.gnome.org/).
### Bug reports
@@ -144,33 +144,28 @@ $ git clone https://gitlab.gnome.org/yourusername/gtk.git
$ cd gtk
```
**Note**: if you plan to push changes to back to the main repository and
have a GNOME account, you can skip the fork, and use the following instead:
```sh
$ git clone git@gitlab.gnome.org:GNOME/gtk.git
$ cd gtk
```
To compile the Git version of GTK on your system, you will need to
configure your build using Meson:
```sh
$ meson _builddir .
$ cd _builddir
$ ninja
$ meson setup _builddir .
$ meson compile -C _builddir
```
Typically, you should work on your own branch:
```sh
$ git checkout -b your-branch
$ git switch -C your-branch
```
Once you've finished working on the bug fix or feature, push the branch
to the Git repository and open a new merge request, to let the GTK
maintainers review your contribution.
**Important**: Do **not** attach a diff or a patch file to a GitLab issue.
Patches cannot be reviewed, and do not not go through the CI pipeline. If
you wish to submit your changes to GTK, always use a merge request.
### Code reviews
Each contribution is reviewed by the core developers of the GTK project.
@@ -262,4 +257,4 @@ people committing to GTK to follow a few rules:
If you have been contributing to GTK for a while and you don't have commit
access to the repository, you may ask to obtain it following the [GNOME account
process](https://wiki.gnome.org/AccountsTeam/NewAccounts).
process](https://handbook.gnome.org/infrastructure/developer-access.html).

159
NEWS
View File

@@ -1,6 +1,163 @@
Overview of Changes in 4.14.2, xx-xx-xxxx
Overview of Changes in 4.15.1, xx-xx-xxxx
=========================================
Overview of Changes in 4.15.0, 21-04-2024
=========================================
This release changes the default GSK renderer to be Vulkan, on
Wayland. Other platforms still use ngl.
The intent of this change is to get wider testing and verify that
Vulkan drivers are good enough for us to rely on. If significant
problems show up, we will revert this change for 4.16.
You can still override the renderer choice using the GSK_RENDERER
environment variable.
---
This release also changes font rendering settings by introducing
a new high-level gtk-font-rendering settings which gives GTK more
freedom to decide on font rendering.
You can still use the low-level font-related settings by changing
the new property to 'manual'.
---
* GtkColumnView:
- Fix infinite loops in dispose
- Fix problems with weak ref cycles in GtkExpression
* GtkListView:
* GtkShortcutManager:
- Track the propagation phase of added controllers
* GtkGLArea:
- Produce dmabuf textures, so graphics offload is possible
* GtkTextView:
- Support text shadows
* GtkGraphicsOffload:
- Add a black-background property
* Settings:
- Add a new gtk-font-rendering setting
* Accessibility:
- Add support for GetRangeExtents to GtkAccessibleText
- Add support for GetOffsetAtPoint to GtkAccessibleText
- Implement GtkAccessibleRange for scrollbars
* GDK:
- Add a callback-based cursor API
* GSK:
- Use the Vulkan renderer by default
- Avoid an infinite recursion with offscreens in some cases
- Optimize graphics offload to make it more likely that compositors
can use direct scanout
* X11:
- Fix some confusing debug messages
- Drop a no-longer-relevant optimization that was interfering with
getting the current window manager capabilities
* macOS:
- Implement the color picker for macOS 10.15+
* Debugging:
- Snow monitor resolution in the inspector
* Demos:
- Use graphics offload in the shadertoy demo
- Show more reliable fps numbers in the fishbowl demo
* Tools:
- Support generating pdf in gtk4-rendernode-tool
* Build:
- Require pango 1.52
- Require cairo 1.18
- Add a missing dependency that was causing build failures
- Drop deprecated build options:
gtk_doc -> documentation
update_screenshots -> screenshots
demo-profile -> profile
demos -> build-demos
* Deprecations:
- gdk_widget_set/get_font_options
- gdk_wayland/x11_display_set_cursor_theme
* Translation updates:
Basque
Brazilian Portuguese
British English
Chinese (China)
Hebrew
Kabyle
Persian
Polish
Russian
Slovenian
Swedish
Turkish
Overview of Changes in 4.14.2, 03-04-2024
=========================================
* GtkScale:
- Improve positioning of values in some cases
* Theme:
- Make progress in entries visible
* Accessibility:
- Fix text insertion handling
* GDK:
- dnd: Use the default cursor durion motion
- dnd: Use a better cursor for indicating the move action
* GSK:
- gl: Handle offloads in offscreen context better
- Fix text rendering problems with some fonts
* Wayland:
- Tighten up some protocol version checks
- Use the presentation time protocol
- Fix a crash with subsurfaces
- Improve settings portal handling
* macOS:
- Fix up the app menu support
* Windows:
- Fix problems with minimization
- Fix build without fontconfig
* Debugging:
- Add font settings in the inspector
* Demos:
- Clean up the application demo
- Update cursor images for the cursor demo
* Translation updates:
Catalan
Czech
French
Georgian
Hebrew
Persian
Slovenian
Turkish
Ukrainian
Overview of Changes in 4.14.1, 16-03-2024
=========================================

View File

@@ -125,7 +125,7 @@ version, for example `gtk-4-10`.
How to report bugs
------------------
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/new).
Bugs should be reported on the [issues page](https://gitlab.gnome.org/GNOME/gtk/issues/).
In the bug report please include:

View File

@@ -185,9 +185,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{
@@ -131,7 +130,6 @@
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}

View File

@@ -114,9 +114,8 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Ddemo-profile=devel"
"-Dprofile=devel"
],
"sources" : [
{
@@ -131,7 +130,6 @@
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -15,12 +15,54 @@ on_destroy (gpointer data)
window = NULL;
}
static GdkTexture *
cursor_callback (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y,
gpointer data)
{
GdkPixbuf *pixbuf;
GdkTexture *texture;
GError *error = NULL;
int scaled_size;
scaled_size = ceil (cursor_size * scale);
pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/cursors/images/gtk-logo.svg",
scaled_size, scaled_size,
TRUE,
&error);
if (!pixbuf)
{
g_print ("%s\n", error->message);
g_error_free (error);
return NULL;
}
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
*width = cursor_size;
*height = cursor_size;
*hotspot_x = 18 * cursor_size / 32.0;
*hotspot_y = 2 * cursor_size / 32.0;
return texture;
}
GtkWidget *
do_cursors (GtkWidget *do_widget)
{
if (!window)
{
GtkBuilder *builder;
GtkWidget *logo_callback;
GdkCursor *cursor;
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
@@ -29,6 +71,10 @@ do_cursors (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (on_destroy), NULL);
logo_callback = GTK_WIDGET (gtk_builder_get_object (builder, "logo_callback"));
cursor = gdk_cursor_new_from_callback (cursor_callback, NULL, NULL, NULL);
gtk_widget_set_cursor (logo_callback, cursor);
g_object_unref (cursor);
g_object_unref (builder);
}

File diff suppressed because it is too large Load Diff

View File

@@ -116,6 +116,7 @@
<file>w_resize_cursor.png</file>
<file>zoom_in_cursor.png</file>
<file>zoom_out_cursor.png</file>
<file>gtk-logo.svg</file>
</gresource>
<gresource prefix="/dnd">
<file>dnd.css</file>

138
demos/gtk-demo/gtk-logo.svg Normal file
View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
id="svg6843"
sodipodi:version="0.32"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
version="1.0"
sodipodi:docname="gtk-logo.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="/home/ebassi/Pictures/gtk-logo-256.png"
inkscape:export-xdpi="192"
inkscape:export-ydpi="192">
<defs
id="defs6845">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-50 : 600 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="700 : 600 : 1"
inkscape:persp3d-origin="300 : 400 : 1"
id="perspective13" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="69.874353"
inkscape:cy="64.313526"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:document-units="px"
inkscape:grid-bbox="true"
width="128px"
height="128px"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid7947" />
</sodipodi:namedview>
<metadata
id="metadata6848">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<dc:date />
<dc:creator>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:rights>
<dc:publisher>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:publisher>
<dc:identifier />
<dc:source />
<dc:relation />
<dc:language />
<dc:subject>
<rdf:Bag />
</dc:subject>
<dc:coverage />
<dc:description />
<dc:contributor>
<cc:Agent>
<dc:title />
</cc:Agent>
</dc:contributor>
<cc:license
rdf:resource="" />
</cc:Work>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
sodipodi:nodetypes="ccccc"
id="path6976"
d="M 20.88413,30.82696 L 53.816977,55.527708 L 107.33282,39.060543 L 70.587303,17.177763 L 20.88413,30.82696 z"
style="fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6978"
d="M 22.94243,82.287118 L 20.88413,30.82696 L 53.816977,55.527708 L 53.816977,111.10486 L 22.94243,82.287118 z"
style="fill:#e40000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
id="path6980"
d="M 53.816977,111.10486 L 103.21619,90.5207 L 107.33282,39.060543 L 53.816977,55.527708 L 53.816977,111.10486 z"
style="fill:#7fe719;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.12364459;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" />
<path
sodipodi:nodetypes="ccc"
id="path6982"
d="M 23.216626,81.319479 L 70.48573,67.361442 L 103.38422,90.444516"
style="opacity:1;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
id="path6984"
d="M 70.434539,17.875593 L 70.434539,66.984877"
style="opacity:1;fill:#babdb6;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -456,43 +456,33 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GdkFrameClock *frame_clock;
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
gint64 n_frames, expected_frames;
gint64 start_timestamp, end_timestamp;
GdkFrameTimings *end;
gint64 end_counter;
double fps, expected_fps;
gint64 interval;
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (fishbowl));
if (frame_clock == NULL)
return;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
fps = gdk_frame_clock_get_fps (frame_clock);
if (fps <= 0.0)
return;
start_timestamp = gdk_frame_timings_get_presentation_time (start);
end_timestamp = gdk_frame_timings_get_presentation_time (end);
if (start_timestamp == 0 || end_timestamp == 0)
{
start_timestamp = gdk_frame_timings_get_frame_time (start);
end_timestamp = gdk_frame_timings_get_frame_time (end);
}
n_frames = end_counter - start_counter;
priv->framerate = ((double) n_frames) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
priv->framerate = ((int)(priv->framerate * 100))/100.0;
priv->framerate = fps;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
if (!priv->benchmark)
return;
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end == NULL)
return;
interval = gdk_frame_timings_get_refresh_interval (end);
if (interval == 0)
{
@@ -500,16 +490,16 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
if (interval == 0)
return;
}
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
expected_fps = (double) G_USEC_PER_SEC / interval;
if (n_frames >= expected_frames)
if (fps > (expected_fps - 1))
{
if (priv->last_benchmark_change > 0)
priv->last_benchmark_change *= 2;
else
priv->last_benchmark_change = 1;
}
else if (n_frames + 1 < expected_frames)
else if (0.95 * fps < expected_fps)
{
if (priv->last_benchmark_change < 0)
priv->last_benchmark_change--;

View File

@@ -2,7 +2,7 @@
<interface>
<menu id="menubar">
<submenu>
<attribute name="label" translatable="yes">_Application</attribute>
<attribute name="label" translatable="yes">_File</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_New</attribute>
@@ -33,7 +33,7 @@
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">_File</attribute>
<attribute name="label" translatable="yes">_Preferences</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -120,7 +120,7 @@ create_shadertoy_window (GtkWidget *do_widget)
gtk_box_append (GTK_BOX (box), aspect);
shadertoy = new_shadertoy ("/shadertoy/alienplanet.glsl");
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), shadertoy);
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (aspect), gtk_graphics_offload_new (shadertoy));
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 250);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -74,6 +74,7 @@ in a selector, widget names must be prefixed with a &num; character.
| E:not(selector) | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#negation) | |
| E:dir(ltr), E:dir(rtl) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#the-dir-pseudo) | |
| E:drop(active) | [CSS Selector Level 4](https://drafts.csswg.org/selectors/#drag-pseudos) | |
| E:root | [CSS Selector Level 3](https://www.w3.org/TR/selectors-3/#root-pseudo) | |
| E F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#descendent-combinators) | |
| E > F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#child-combinators) | |
| E ~ F | [CSS Selector Level 3](https://www.w3.org/TR/css3-selectors/#general-sibling-combinators) | |

View File

@@ -8,6 +8,10 @@ gtk4-broadwayd
The Broadway display server
---------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-broadwayd** [OPTIONS...] <DISPLAY>

View File

@@ -8,6 +8,10 @@ gtk4-builder-tool
GtkBuilder File Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-builder-tool** <COMMAND> [OPTIONS...] <FILE>

View File

@@ -8,6 +8,9 @@ gtk4-demo-application
Demonstrate GtkApplication
--------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-demo
Demonstrate GTK widgets
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-encode-symbolic-svg
Symbolic icon conversion utility
--------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-icon-browser
List themed icons
-----------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-launch
Launch an application
---------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-node-editor
Editor render nodes
-----------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-path-tool
GskPath Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-path-tool** <COMMAND> [OPTIONS...] <PATH>

View File

@@ -8,6 +8,10 @@ gtk4-query-settings
Print name and value of GTK settings
------------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-rendernode-tool
GskRenderNode Utility
-----------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------
| **gtk4-rendernode-tool** <COMMAND> [OPTIONS...] <FILE>
@@ -45,13 +49,14 @@ without any titlebar.
Rendering
^^^^^^^^^
The ``render`` command saves a rendering of the rendernode as a png or tiff image.
The name of the file to write can be specified as a second FILE argument.
The ``render`` command saves a rendering of the rendernode as a png, tiff or svg
image or as pdf document. The name of the file to write can be specified as a second
FILE argument.
``--renderer=RENDERER``
Use the given renderer. Use ``--renderer=help`` to get a information
about poassible values for the ``RENDERER``.
about possible values for the ``RENDERER``.
Benchmark
^^^^^^^^^
@@ -93,4 +98,4 @@ exit code is 1. If the images are identical, it is 0.
``--quiet``
Don't write results to stdout.`
Don't write results to stdout.

View File

@@ -8,6 +8,10 @@ gtk4-update-icon-cache
Icon theme caching utility
--------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -8,6 +8,10 @@ gtk4-widget-factory
Showcase GTK widgets and styles
-------------------------------
:Version: GTK
:Manual section: 1
:Manual group: GTK commands
SYNOPSIS
--------

View File

@@ -80,7 +80,7 @@ if get_option('man-pages') and rst2man.found()
[ 'gtk4-path-tool', '1', ],
]
if get_option('demos')
if get_option('build-demos')
rst_files += [
[ 'gtk4-demo', '1', ],
[ 'gtk4-demo-application', '1', ],

View File

@@ -58,12 +58,12 @@ GTK is divided into three parts:
storage types for efficient use in GUI applications, and much more.
[gnu-lgpl]: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
[glib]: https://developer.gnome.org/glib/stable/
[gobject]: https://developer.gnome.org/gobject/stable/
[gio]: https://developer.gnome.org/gio/stable/
[glib]: https://docs.gtk.org/glib/
[gobject]: https://docs.gtk.org/gobject/
[gio]: https://docs.gtk.org/gio/
[cairo]: https://www.cairographics.org/manual/
[opengl]: https://www.opengl.org/about/
[vulkan]: https://www.vulkan.org/
[pango]: https://pango.gnome.org/
[gdkpixbuf]: https://developer.gnome.org/gdk-pixbuf/stable/
[pango]: https://docs.gtk.org/pango/
[gdkpixbuf]: https://docs.gtk.org/gdk-pixbuf/
[graphene]: https://ebassi.github.io/graphene/

View File

@@ -27,7 +27,7 @@ the question you have, this list is a good place to start.
Every major version of GTK comes with a [migration guide](#migrating). You may also
find useful information in the documentation for specific widgets and functions. If
you have a question not covered in the manual, feel free to ask, and please
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/new) against the
[file a bug report](https://gitlab.gnome.org/GNOME/gtk/issues/) against the
documentation.
* Should I maintain parallel versions of my UI in GTK x and GTK y?
@@ -54,7 +54,7 @@ the question you have, this list is a good place to start.
For strings returned from functions, they will be declared "const" if they should
not be freed. Non-const strings should be freed with `g_free()`. Arrays follow the
same rule. If you find an undocumented exception to the rules, please
[file a bug report.](https://gitlab.gnome.org/GNOME/gtk/issues/new).
[file a bug report.](https://gitlab.gnome.org/GNOME/gtk/issues/).
The transfer annotations for gobject-introspection that are part of the
documentation can provide useful hints for memory handling semantics as well.

View File

@@ -4,7 +4,7 @@ Slug: gtk-resources
## Opening a bug or feature request
If you encounter a bug, misfeature, or missing feature in GTK, please
file a bug report on our [GitLab project](https://gitlab.gnome.org/GNOME/gtk/issues/new).
file a bug report on our [GitLab project](https://gitlab.gnome.org/GNOME/gtk/issues/).
You should also file issues if the documentation is out of date with the
existing API, or unclear.

View File

@@ -217,6 +217,10 @@ A number of options affect behavior instead of logging:
`no-portals`
: Disable use of [portals](https://docs.flatpak.org/en/latest/portals.html)
`force-offload`
: Force graphics offload for all textures, even when slower. This allows
to debug offloading in the absence of dmabufs.
`gl-disable`
: Disable OpenGL support

View File

@@ -91,6 +91,31 @@ const GDK_META_MASK = 1 << 28;
var useDataUrls = window.location.search.includes("datauri");
/* check if we are on Android and using Chrome */
var isAndroidChrome = false;
{
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("android") > -1 && ua.indexOf("chrom") > -1) {
isAndroidChrome = true;
}
}
/* check for the passive option for Event listener */
let passiveSupported = false;
try {
const options = {
get passive() { // This function will be called when the browser
// attempts to access the passive property.
passiveSupported = true;
return false;
}
};
window.addEventListener("test", null, options);
window.removeEventListener("test", null, options);
} catch(err) {
passiveSupported = false;
}
/* This base64code is based on https://github.com/beatgammit/base64-js/blob/master/index.js which is MIT licensed */
var b64_lookup = [];
@@ -215,11 +240,32 @@ function logStackTrace(len) {
log(callstack[i]);
}
/* Helper functions for touch identifier to make it unique on Android */
var globalTouchIdentifier = Math.round(Date.now() / 1000);
function touchIdentifierStart(tId)
{
if (isAndroidChrome) {
if (tId == 0) {
return ++globalTouchIdentifier;
}
return globalTouchIdentifier + tId;
}
return tId;
}
function touchIdentifier(tId)
{
if (isAndroidChrome) {
return globalTouchIdentifier + tId;
}
return tId;
}
var grab = new Object();
grab.surface = null;
grab.ownerEvents = false;
grab.implicit = false;
var keyDownList = [];
var inputList = [];
var lastSerial = 0;
var lastX = 0;
var lastY = 0;
@@ -987,7 +1033,14 @@ function handleDisplayCommands(display_commands)
break;
case DISPLAY_OP_DELETE_SURFACE:
var id = cmd[1];
delete surfaces[id];
if (id == surfaceWithMouse) {
surfaceWithMouse = 0;
}
if (id == realSurfaceWithMouse) {
realSurfaceWithMouse = 0;
firstTouchDownId = null;
}
delete surfaces[id];
break;
case DISPLAY_OP_CHANGE_TEXTURE:
var image = cmd[1];
@@ -1371,8 +1424,14 @@ function getEffectiveEventTarget (id) {
function updateKeyboardStatus() {
if (fakeInput != null && showKeyboardChanged) {
showKeyboardChanged = false;
if (showKeyboard)
if (showKeyboard) {
if (isAndroidChrome) {
fakeInput.blur();
fakeInput.value = ' '.repeat(80); // TODO: Should be exchange with broadway server
// to bring real value here.
}
fakeInput.focus();
}
else
fakeInput.blur();
}
@@ -2924,6 +2983,19 @@ function pushKeyEvent(fev) {
keyDownList.push(fev);
}
function copyInputEvent(ev) {
var members = ['inputType', 'data'], i, obj = {};
for (i = 0; i < members.length; i++) {
if (typeof ev[members[i]] !== "undefined")
obj[members[i]] = ev[members[i]];
}
return obj;
}
function pushInputEvent(fev) {
inputList.push(fev);
}
function getKeyEvent(keyCode, pop) {
var i, fev = null;
for (i = keyDownList.length-1; i >= 0; i--) {
@@ -3022,6 +3094,29 @@ function handleKeyUp(e) {
keysym = fev.keysym;
else {
//log("Key event (keyCode = " + ev.keyCode + ") not found on keyDownList");
if (isAndroidChrome && (ev.keyCode == 229)) {
var i, fev = null, len = inputList.length, str;
for (i = 0; i < len; i++) {
fev = inputList[i];
switch(fev.inputType) {
case "deleteContentBackward":
sendInput(BROADWAY_EVENT_KEY_PRESS, [65288, lastState]);
sendInput(BROADWAY_EVENT_KEY_RELEASE, [65288, lastState]);
break;
case "insertText":
if (fev.data !== undefined) {
for (let sym of fev.data) {
sendInput(BROADWAY_EVENT_KEY_PRESS, [sym.codePointAt(0), lastState]);
sendInput(BROADWAY_EVENT_KEY_RELEASE, [sym.codePointAt(0), lastState]);
}
}
break;
default:
break;
}
}
inputList.splice(0, len);
}
keysym = 0;
}
@@ -3030,6 +3125,16 @@ function handleKeyUp(e) {
return cancelEvent(ev);
}
function handleInput (e) {
var fev = null, ev = (e ? e : window.event), keysym = null, suppress = false;
fev = copyInputEvent(ev);
pushInputEvent(fev);
// Stop keypress events just in case
return cancelEvent(ev);
}
function onKeyDown (ev) {
updateForEvent(ev);
return handleKeyDown(ev);
@@ -3045,6 +3150,11 @@ function onKeyUp (ev) {
return handleKeyUp(ev);
}
function onInput (ev) {
updateForEvent(ev);
return handleInput(ev);
}
function cancelEvent(ev)
{
ev = ev ? ev : window.event;
@@ -3076,13 +3186,14 @@ function onMouseWheel(ev)
}
function onTouchStart(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifierStart(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
@@ -3090,7 +3201,7 @@ function onTouchStart(ev) {
var isEmulated = 0;
if (firstTouchDownId == null) {
firstTouchDownId = touch.identifier;
firstTouchDownId = touchId;
isEmulated = 1;
if (realSurfaceWithMouse != origId || id != surfaceWithMouse) {
@@ -3105,52 +3216,54 @@ function onTouchStart(ev) {
}
}
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [0, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
function onTouchMove(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifier(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
if (firstTouchDownId == touchId) {
isEmulated = 1;
}
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [1, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
function onTouchEnd(ev) {
event.preventDefault();
ev.preventDefault();
updateKeyboardStatus();
updateForEvent(ev);
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var touchId = touchIdentifier(touch.identifier);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
if (firstTouchDownId == touchId) {
isEmulated = 1;
firstTouchDownId = null;
}
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput (BROADWAY_EVENT_TOUCH, [2, id, touchId, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
@@ -3167,11 +3280,11 @@ function setupDocument(document)
document.onkeyup = onKeyUp;
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', onMouseWheel, false);
document.addEventListener('mousewheel', onMouseWheel, false);
document.addEventListener('touchstart', onTouchStart, false);
document.addEventListener('touchmove', onTouchMove, false);
document.addEventListener('touchend', onTouchEnd, false);
document.addEventListener('DOMMouseScroll', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('mousewheel', onMouseWheel, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchstart', onTouchStart, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchmove', onTouchMove, passiveSupported ? { passive: false, capture: false } : false);
document.addEventListener('touchend', onTouchEnd, passiveSupported ? { passive: false, capture: false } : false);
} else if (document.attachEvent) {
element.attachEvent("onmousewheel", onMouseWheel);
}
@@ -3237,12 +3350,14 @@ function connect()
};
var iOS = /(iPad|iPhone|iPod)/g.test( navigator.userAgent );
if (iOS) {
if (iOS || isAndroidChrome) {
fakeInput = document.createElement("input");
fakeInput.type = "text";
fakeInput.style.position = "absolute";
fakeInput.style.left = "-1000px";
fakeInput.style.top = "-1000px";
document.body.appendChild(fakeInput);
if (isAndroidChrome)
fakeInput.addEventListener('input', onInput, passiveSupported ? { passive: false, capture: false } : false);
}
}

View File

@@ -52,8 +52,7 @@ broadwayjs_h = custom_target('broadwayjs.h',
)
libgdk_broadway = static_library('gdk-broadway',
clienthtml_h, broadwayjs_h,
gdk_broadway_sources, gdkconfig, gdkenum_h,
sources: [ clienthtml_h, broadwayjs_h, gdk_broadway_sources, gdk_gen_headers ],
include_directories: [confinc, gdkinc],
c_args: [
'-DGTK_COMPILATION',

View File

@@ -122,6 +122,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
{ "gl-no-fractional", GDK_DEBUG_GL_NO_FRACTIONAL, "Disable fractional scaling for OpenGL" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },

View File

@@ -156,6 +156,9 @@ gdk_cursor_finalize (GObject *object)
g_clear_object (&cursor->texture);
g_clear_object (&cursor->fallback);
if (cursor->destroy)
cursor->destroy (cursor->data);
G_OBJECT_CLASS (gdk_cursor_parent_class)->finalize (object);
}
@@ -253,6 +256,11 @@ gdk_cursor_hash (gconstpointer pointer)
hash ^= g_str_hash (cursor->name);
else if (cursor->texture)
hash ^= g_direct_hash (cursor->texture);
else if (cursor->callback)
{
hash ^= g_direct_hash (cursor->callback);
hash ^= g_direct_hash (cursor->data);
}
hash ^= (cursor->hotspot_x << 8) | cursor->hotspot_y;
@@ -281,6 +289,10 @@ gdk_cursor_equal (gconstpointer a,
ca->hotspot_y != cb->hotspot_y)
return FALSE;
if (ca->callback != cb->callback ||
ca->data != cb->data)
return FALSE;
return TRUE;
}
@@ -355,6 +367,45 @@ gdk_cursor_new_from_texture (GdkTexture *texture,
NULL);
}
/**
* gdk_cursor_new_from_callback:
* @callback: the `GdkCursorGetTextureCallback`
* @data: data to pass to @callback
* @destroy: destroy notify for @data
* @fallback: (nullable): the `GdkCursor` to fall back to when
* this one cannot be supported
*
* Creates a new callback-based cursor object.
*
* Cursors of this kind produce textures for the cursor
* image on demand, when the @callback is called.
*
* Returns: (nullable): a new `GdkCursor`
*
* Since: 4.16
*/
GdkCursor *
gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
gpointer data,
GDestroyNotify destroy,
GdkCursor *fallback)
{
GdkCursor *cursor;
g_return_val_if_fail (callback != NULL, NULL);
g_return_val_if_fail (fallback == NULL || GDK_IS_CURSOR (fallback), NULL);
cursor = g_object_new (GDK_TYPE_CURSOR,
"fallback", fallback,
NULL);
cursor->callback = callback;
cursor->data = data;
cursor->destroy = destroy;
return cursor;
}
/**
* gdk_cursor_get_fallback: (attributes org.gtk.Method.get_property=fallback)
* @cursor: a `GdkCursor`
@@ -459,3 +510,22 @@ gdk_cursor_get_hotspot_y (GdkCursor *cursor)
return cursor->hotspot_y;
}
GdkTexture *
gdk_cursor_get_texture_for_size (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y)
{
if (cursor->callback == NULL)
return NULL;
return cursor->callback (cursor,
cursor_size, scale,
width, height,
hotspot_x, hotspot_y,
cursor->data);
}

View File

@@ -51,6 +51,52 @@ GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor *fallback);
/**
* GdkCursorGetTestureCallback:
* @cursor: the `GdkCursor`
* @cursor_size: the nominal cursor size, in application pixels
* @scale: the device scale
* @width: (out): return location for the actual cursor width,
* in application pixels
* @height: (out): return location for the actual cursor height,
* in application pixels
* @hotspot_x: (out): return location for the hotspot X position,
* in application pixels
* @hotspot_y: (out): return location for the hotspot Y position,
* in application pixels
* @data: User data for the callback
*
* The type of callback used by a dynamic `GdkCursor` to generate
* a texture for the cursor image at the given @cursor_size
* and @scale.
*
* The actual cursor size in application pixels may be different
* from @cursor_size x @cursor_size, and will be returned in
* @width, @height. The returned texture should have a size that
* corresponds to the actual cursor size, in device pixels (i.e.
* application pixels, multiplied by @scale).
*
* This function may fail and return `NULL`, in which case
* the fallback cursor will be used.
*
* Returns: (nullable) (transfer full): the cursor image, or
* `NULL` if none could be produced.
*/
typedef GdkTexture * (* GdkCursorGetTextureCallback) (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y,
gpointer data);
GDK_AVAILABLE_IN_4_16
GdkCursor * gdk_cursor_new_from_callback (GdkCursorGetTextureCallback callback,
gpointer data,
GDestroyNotify destroy,
GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
GDK_AVAILABLE_IN_ALL

View File

@@ -44,6 +44,10 @@ struct _GdkCursor
GdkTexture *texture;
int hotspot_x;
int hotspot_y;
GdkCursorGetTextureCallback callback;
gpointer data;
GDestroyNotify destroy;
};
struct _GdkCursorClass
@@ -55,5 +59,13 @@ guint gdk_cursor_hash (gconstpointer
gboolean gdk_cursor_equal (gconstpointer a,
gconstpointer b);
GdkTexture * gdk_cursor_get_texture_for_size (GdkCursor *cursor,
int cursor_size,
double scale,
int *width,
int *height,
int *hotspot_x,
int *hotspot_y);
G_END_DECLS

View File

@@ -44,7 +44,7 @@ typedef enum {
GDK_DEBUG_NO_PORTALS = 1 << 15,
GDK_DEBUG_GL_DISABLE = 1 << 16,
GDK_DEBUG_GL_NO_FRACTIONAL= 1 << 17,
GDK_DEBUG_FORCE_OFFLOAD = 1 << 18,
GDK_DEBUG_GL_DISABLE_GL = 1 << 19,
GDK_DEBUG_GL_DISABLE_GLES = 1 << 20,
GDK_DEBUG_GL_PREFER_GL = 1 << 21,

View File

@@ -1559,13 +1559,14 @@ describe_egl_config (EGLDisplay egl_display,
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_DEPTH_SIZE, &depth))
depth = 0;
if (!eglGetConfigAttrib (egl_display, egl_config, EGL_STENCIL_SIZE, &stencil))
stencil = 0;
return g_strdup_printf ("R%dG%dB%dA%d%s%s%s", red, green, blue, alpha,
return g_strdup_printf ("R%dG%dB%dA%d%s, depth %d, stencil %d", red, green, blue, alpha,
type == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT ? "" : " float",
depth > 0 ? ", depth buffer" : "",
stencil > 0 ? ", stencil buffer" : "");
depth,
stencil);
}
gpointer

View File

@@ -25,6 +25,7 @@
#include "gdkdmabufformatsbuilderprivate.h"
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkdmabuftexturebuilderprivate.h"
#include "gdktextureprivate.h"
#include <gdk/gdkglcontext.h>
#include <gdk/gdkgltexturebuilder.h>
@@ -71,7 +72,10 @@ gdk_dmabuf_texture_dispose (GObject *object)
GdkDmabufTexture *self = GDK_DMABUF_TEXTURE (object);
if (self->destroy)
self->destroy (self->data);
{
self->destroy (self->data);
self->destroy = NULL;
}
g_clear_object (&self->downloader);
g_clear_object (&self->display);

View File

@@ -25,6 +25,7 @@
#include "gdkdisplay.h"
#include "gdkenumtypes.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkdmabuftexturebuilderprivate.h"
#include <cairo-gobject.h>
@@ -948,22 +949,20 @@ gdk_dmabuf_texture_builder_set_update_region (GdkDmabufTextureBuilder *self,
*
* Builds a new `GdkTexture` with the values set up in the builder.
*
* It is a programming error to call this function if any mandatory
* property has not been set.
* It is a programming error to call this function if any mandatory property has not been set.
*
* If the dmabuf is not supported by GTK, %NULL will be returned and @error will be set.
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats. If the
* format is not supported by GTK, %NULL will be returned and @error will be set.
*
* The `destroy` function gets called when the returned texture gets released.
*
* It is possible to call this function multiple times to create multiple textures,
* possibly with changing properties in between.
*
* It is the responsibility of the caller to keep the file descriptors for the planes
* open until the created texture is no longer used, and close them afterwards (possibly
* using the @destroy notify).
*
* Not all formats defined in the `drm_fourcc.h` header are supported. You can use
* [method@Gdk.Display.get_dmabuf_formats] to get a list of supported formats.
* It is possible to call this function multiple times to create multiple textures,
* possibly with changing properties in between.
*
* Returns: (transfer full) (nullable): a newly built `GdkTexture` or `NULL`
* if the format is not supported
@@ -1004,3 +1003,19 @@ gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *self)
{
return &self->dmabuf;
}
void
gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *self,
const GdkDmabuf *dmabuf)
{
gdk_dmabuf_texture_builder_set_fourcc (self, dmabuf->fourcc);
gdk_dmabuf_texture_builder_set_modifier (self, dmabuf->modifier);
gdk_dmabuf_texture_builder_set_n_planes (self, dmabuf->n_planes);
for (unsigned int i = 0; i < dmabuf->n_planes; i++)
{
gdk_dmabuf_texture_builder_set_fd (self, i, dmabuf->planes[i].fd);
gdk_dmabuf_texture_builder_set_stride (self, i, dmabuf->planes[i].stride);
gdk_dmabuf_texture_builder_set_offset (self, i, dmabuf->planes[i].offset);
}
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "gdkdmabuftexturebuilder.h"
#include "gdkdmabufprivate.h"
G_BEGIN_DECLS
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
void gdk_dmabuf_texture_builder_set_dmabuf (GdkDmabufTextureBuilder *builder,
const GdkDmabuf *dmabuf);
G_END_DECLS

View File

@@ -7,8 +7,6 @@
G_BEGIN_DECLS
const GdkDmabuf * gdk_dmabuf_texture_builder_get_dmabuf (GdkDmabufTextureBuilder *builder);
GdkTexture * gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
GDestroyNotify destroy,
gpointer data,

View File

@@ -50,18 +50,6 @@
#include "gdkenumtypes.h"
#include "gdkeventsprivate.h"
static struct {
GdkDragAction action;
const char *name;
GdkCursor *cursor;
} drag_cursors[] = {
{ GDK_ACTION_ASK, "dnd-ask", NULL },
{ GDK_ACTION_COPY, "copy", NULL },
{ GDK_ACTION_MOVE, "move", NULL },
{ GDK_ACTION_LINK, "alias", NULL },
{ 0, "no-drop", NULL },
};
enum {
PROP_0,
PROP_CONTENT,
@@ -786,6 +774,20 @@ gdk_drag_handle_source_event (GdkEvent *event)
return FALSE;
}
static struct {
GdkDragAction action;
const char *name;
GdkCursor *cursor;
} drag_cursors[] = {
{ 0, "default", NULL },
{ GDK_ACTION_ASK, "dnd-ask", NULL },
{ GDK_ACTION_COPY, "copy", NULL },
{ GDK_ACTION_MOVE, "dnd-move", NULL }, /* Not using move here, since move is stuck using
* a mismatched visual metaphor in Adwaita
*/
{ GDK_ACTION_LINK, "alias", NULL },
};
GdkCursor *
gdk_drag_get_cursor (GdkDrag *drag,
GdkDragAction action)

View File

@@ -744,3 +744,11 @@ gdk_monitor_set_description (GdkMonitor *monitor,
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
}
#define MM_PER_INCH 25.4
double
gdk_monitor_get_dpi (GdkMonitor *monitor)
{
return MAX ((monitor->geometry.width * monitor->scale) / (monitor->width_mm / MM_PER_INCH),
(monitor->geometry.height * monitor->scale) / (monitor->height_mm / MM_PER_INCH));
}

View File

@@ -76,6 +76,7 @@ void gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
void gdk_monitor_invalidate (GdkMonitor *monitor);
void gdk_monitor_set_description (GdkMonitor *monitor,
const char *description);
double gdk_monitor_get_dpi (GdkMonitor *monitor);
G_END_DECLS

View File

@@ -59,7 +59,7 @@ typedef enum {
* @get_current_image: return a `GdkPaintable` that does not change over
* time. This means the `GDK_PAINTABLE_STATIC_SIZE` and
* `GDK_PAINTABLE_STATIC_CONTENTS` flag are set.
* @get_flags: Get the flags for this instance. See [enum@Gdk.PaintableFlags]
* @get_flags: Get the flags for this instance. See [flags@Gdk.PaintableFlags]
* for details.
* @get_intrinsic_width: The preferred width for this object to be
* snapshot at or 0 if none. This is purely a hint. The object must still

View File

@@ -98,9 +98,9 @@ gdk_rgba_free (GdkRGBA *rgba)
* Returns: %TRUE if the @rgba is clear
*/
gboolean
gdk_rgba_is_clear (const GdkRGBA *rgba)
(gdk_rgba_is_clear) (const GdkRGBA *rgba)
{
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
return _gdk_rgba_is_clear (rgba);
}
/**
@@ -115,9 +115,9 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
* Returns: %TRUE if the @rgba is opaque
*/
gboolean
gdk_rgba_is_opaque (const GdkRGBA *rgba)
(gdk_rgba_is_opaque) (const GdkRGBA *rgba)
{
return rgba->alpha > ((float)0xff00 / (float)0xffff);
return _gdk_rgba_is_opaque (rgba);
}
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
@@ -368,21 +368,10 @@ gdk_rgba_hash (gconstpointer p)
* Returns: %TRUE if the two colors compare equal
*/
gboolean
gdk_rgba_equal (gconstpointer p1,
gconstpointer p2)
(gdk_rgba_equal) (gconstpointer p1,
gconstpointer p2)
{
const GdkRGBA *rgba1, *rgba2;
rgba1 = p1;
rgba2 = p2;
if (rgba1->red == rgba2->red &&
rgba1->green == rgba2->green &&
rgba1->blue == rgba2->blue &&
rgba1->alpha == rgba2->alpha)
return TRUE;
return FALSE;
return _gdk_rgba_equal (p1, p2);
}
/**

View File

@@ -43,5 +43,34 @@
gboolean gdk_rgba_parser_parse (GtkCssParser *parser,
GdkRGBA *rgba);
#define gdk_rgba_is_clear(rgba) _gdk_rgba_is_clear (rgba)
#define gdk_rgba_is_opaque(rgba) _gdk_rgba_is_opaque (rgba)
#define gdk_rgba_equal(p1, p2) _gdk_rgba_equal (p1, p2)
static inline gboolean
_gdk_rgba_is_clear (const GdkRGBA *rgba)
{
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
}
static inline gboolean
_gdk_rgba_is_opaque (const GdkRGBA *rgba)
{
return rgba->alpha > ((float)0xff00 / (float)0xffff);
}
static inline gboolean
_gdk_rgba_equal (gconstpointer p1,
gconstpointer p2)
{
const GdkRGBA *rgba1 = p1;
const GdkRGBA *rgba2 = p2;
return rgba1->red == rgba2->red &&
rgba1->green == rgba2->green &&
rgba1->blue == rgba2->blue &&
rgba1->alpha == rgba2->alpha;
}
G_END_DECLS

View File

@@ -48,6 +48,14 @@ gdk_subsurface_class_init (GdkSubsurfaceClass *class)
object_class->finalize = gdk_subsurface_finalize;
}
/*< private >
* gdk_subsurface_get_parent:
* @subsurface: a `GdkSubsurface`
*
* Returns the parent surface of @subsurface.
*
* Returns: the parent surface
*/
GdkSurface *
gdk_subsurface_get_parent (GdkSubsurface *subsurface)
{
@@ -108,15 +116,41 @@ insert_subsurface (GdkSubsurface *subsurface,
}
}
/*< private >
* gdk_subsurface_attach:
* @subsurface: the `GdkSubsurface`
* @texture: the texture to attach. This typically has to be a `GdkDmabufTexture`
* @source: the source rectangle (i.e. the subset of the texture) to display
* @dest: the dest rectangle, in application pixels, relative to the parent surface.
* It must be integral in application and device pixels, or attaching will fail
* @transform: the transform to apply to the texture contents before displaying
* @background: (nullable): the background rectangle, in application pixels relative
* to the parent surface. This tells GDK to put a black background of this
* size below the subsurface. It must be integral in application and device pixels,
* or attaching will fail
* @above: whether the subsurface should be above its sibling
* @sibling: (nullable): the sibling subsurface to stack relative to, or `NULL` to
* stack relative to the parent surface
*
* Attaches content to a subsurface.
*
* This function takes all the necessary arguments to determine the subsurface
* configuration, including its position, size, content, background and stacking.
*
* Returns: `TRUE` if the attaching succeeded
*/
gboolean
gdk_subsurface_attach (GdkSubsurface *subsurface,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
GdkTextureTransform transform,
const graphene_rect_t *background,
gboolean above,
GdkSubsurface *sibling)
{
GdkSurface *parent = subsurface->parent;
gboolean result;
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
@@ -130,6 +164,15 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
g_return_val_if_fail (sibling == NULL || GDK_IS_SUBSURFACE (sibling), FALSE);
g_return_val_if_fail (sibling == NULL || sibling->parent == subsurface->parent, FALSE);
result = GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface,
texture,
source,
dest,
transform,
background,
above,
sibling);
remove_subsurface (subsurface);
if (sibling)
@@ -155,9 +198,17 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
}
}
return GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface, texture, source, dest, above, sibling);
return result;
}
/*< private >
* gdk_subsurface_detach:
* @subsurface: a `GdkSubsurface`
*
* Hides the subsurface.
*
* To show it again, you need to call gdk_subsurface_attach().
*/
void
gdk_subsurface_detach (GdkSubsurface *subsurface)
{
@@ -168,6 +219,14 @@ gdk_subsurface_detach (GdkSubsurface *subsurface)
GDK_SUBSURFACE_GET_CLASS (subsurface)->detach (subsurface);
}
/*< private >
* gdk_subsurface_get_texture:
* @subsurface: a `GdkSubsurface`
*
* Gets the texture that is currently displayed by the subsurface.
*
* Returns: (nullable): the texture that is displayed
*/
GdkTexture *
gdk_subsurface_get_texture (GdkSubsurface *subsurface)
{
@@ -176,30 +235,138 @@ gdk_subsurface_get_texture (GdkSubsurface *subsurface)
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_texture (subsurface);
}
/*< private >
* gdk_subsurface_get_source_rect:
* @subsurface: a `GdkSubsurface`
* @rect: (out caller-allocates): return location for the rectangle
*
* Returns the source rect that was specified in the most recent
* gdk_subsurface_attach() call for @subsurface.
*/
void
gdk_subsurface_get_source (GdkSubsurface *subsurface,
graphene_rect_t *source)
gdk_subsurface_get_source_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect)
{
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
g_return_if_fail (source != NULL);
g_return_if_fail (rect != NULL);
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_source (subsurface, source);
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_source_rect (subsurface, rect);
}
/*< private >
* gdk_subsurface_get_texture_rect:
* @subsurface: a `GdkSubsurface`
* @rect: (out caller-allocates): return location for the rectangle
*
* Returns the texture rect that was specified in the most recent
* gdk_subsurface_attach() call for @subsurface.
*/
void
gdk_subsurface_get_dest (GdkSubsurface *subsurface,
graphene_rect_t *dest)
gdk_subsurface_get_texture_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect)
{
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
g_return_if_fail (dest != NULL);
g_return_if_fail (rect != NULL);
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_dest (subsurface, dest);
GDK_SUBSURFACE_GET_CLASS (subsurface)->get_texture_rect (subsurface, rect);
}
/*< private >
* gdk_subsurface_is_above_parent:
* @subsurface: a `GdkSubsurface`
*
* Returns whether the subsurface is above the parent surface
* or below. Note that a subsurface can be above its parent
* surface, and still be covered by sibling subsurfaces.
*
* Returns: `TRUE` if @subsurface is above its parent
*/
gboolean
gdk_subsurface_is_above_parent (GdkSubsurface *subsurface)
{
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), TRUE);
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
return subsurface->above_parent;
}
/*< private>
* gdk_subsurface_get_sibling:
* @subsurface: the `GdkSubsurface`
* @above: whether to get the subsurface above
*
* Returns the subsurface above (or below) @subsurface in
* the stacking order.
*
* Returns: the sibling, or `NULL` if there is none.
*/
GdkSubsurface *
gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
gboolean above)
{
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), NULL);
if (above)
return subsurface->sibling_above;
else
return subsurface->sibling_below;
}
/*< private >
* gdk_subsurface_get_transform:
* @subsurface: a `GdkSubsurface`
*
* Returns the transform that was specified in the most recent call to
* gdk_subsurface_attach() call for @subsurface.
*
* Returns: the transform
*/
GdkTextureTransform
gdk_subsurface_get_transform (GdkSubsurface *subsurface)
{
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_TEXTURE_TRANSFORM_NORMAL);
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface);
}
/*< private >
* gdk_subsurface_get_background_rect:
* @subsurface: a `GdkSubsurface`
* @rect: (out caller-allocates): return location for the rectangle
*
* Obtains the background rect that was specified in the most recent
* gdk_subsurface_attach() call for @subsurface.
*
* Returns: `TRUE` if @subsurface has a background
*/
gboolean
gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect)
{
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
g_return_val_if_fail (rect != NULL, FALSE);
return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_background_rect (subsurface, rect);
}
/*< private >
* gdk_subsurface_get_bounds:
* @subsurface: a `GdkSubsurface`
* @bounds: (out caller-allocates): return location for the bounds
*
* Returns the bounds of the subsurface.
*
* The bounds are the union of the texture and background rects.
*/
void
gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
graphene_rect_t *bounds)
{
graphene_rect_t background;
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
g_return_if_fail (bounds != NULL);
gdk_subsurface_get_texture_rect (subsurface, bounds);
if (gdk_subsurface_get_background_rect (subsurface, &background))
graphene_rect_union (bounds, &background, bounds);
}

View File

@@ -47,42 +47,68 @@ struct _GdkSubsurface
GdkSubsurface *sibling_below;
};
typedef enum {
GDK_TEXTURE_TRANSFORM_NORMAL,
GDK_TEXTURE_TRANSFORM_90,
GDK_TEXTURE_TRANSFORM_180,
GDK_TEXTURE_TRANSFORM_270,
GDK_TEXTURE_TRANSFORM_FLIPPED,
GDK_TEXTURE_TRANSFORM_FLIPPED_90,
GDK_TEXTURE_TRANSFORM_FLIPPED_180,
GDK_TEXTURE_TRANSFORM_FLIPPED_270,
} GdkTextureTransform;
struct _GdkSubsurfaceClass
{
GObjectClass parent_class;
gboolean (* attach) (GdkSubsurface *subsurface,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
gboolean above,
GdkSubsurface *sibling);
void (* detach) (GdkSubsurface *subsurface);
GdkTexture * (* get_texture) (GdkSubsurface *subsurface);
void (* get_source) (GdkSubsurface *subsurface,
graphene_rect_t *source);
void (* get_dest) (GdkSubsurface *subsurface,
graphene_rect_t *dest);
gboolean (* attach) (GdkSubsurface *subsurface,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
GdkTextureTransform transform,
const graphene_rect_t *bg,
gboolean above,
GdkSubsurface *sibling);
void (* detach) (GdkSubsurface *subsurface);
GdkTexture * (* get_texture) (GdkSubsurface *subsurface);
void (* get_source_rect) (GdkSubsurface *subsurface,
graphene_rect_t *rect);
void (* get_texture_rect) (GdkSubsurface *subsurface,
graphene_rect_t *rect);
GdkTextureTransform
(* get_transform) (GdkSubsurface *subsurface);
gboolean (* get_background_rect) (GdkSubsurface *subsurface,
graphene_rect_t *rect);
};
GType gdk_subsurface_get_type (void) G_GNUC_CONST;
GType gdk_subsurface_get_type (void) G_GNUC_CONST;
GdkSurface * gdk_subsurface_get_parent (GdkSubsurface *subsurface);
gboolean gdk_subsurface_attach (GdkSubsurface *subsurface,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
gboolean above,
GdkSubsurface *sibling);
void gdk_subsurface_detach (GdkSubsurface *subsurface);
GdkTexture * gdk_subsurface_get_texture (GdkSubsurface *subsurface);
void gdk_subsurface_get_source (GdkSubsurface *subsurface,
graphene_rect_t *source);
void gdk_subsurface_get_dest (GdkSubsurface *subsurface,
graphene_rect_t *dest);
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
GdkSurface * gdk_subsurface_get_parent (GdkSubsurface *subsurface);
gboolean gdk_subsurface_attach (GdkSubsurface *subsurface,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
GdkTextureTransform transform,
const graphene_rect_t *background,
gboolean above,
GdkSubsurface *sibling);
void gdk_subsurface_detach (GdkSubsurface *subsurface);
GdkTexture * gdk_subsurface_get_texture (GdkSubsurface *subsurface);
void gdk_subsurface_get_source_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect);
void gdk_subsurface_get_texture_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect);
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
gboolean above);
GdkTextureTransform
gdk_subsurface_get_transform (GdkSubsurface *subsurface);
gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect);
void gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
graphene_rect_t *bounds);
G_END_DECLS

View File

@@ -57,6 +57,9 @@ static const GdkDebugKey gsk_vulkan_feature_keys[] = {
*
* Support for `GdkVulkanContext` is platform-specific and context creation
* can fail, returning %NULL context.
*
* Deprecated: 4.14: GTK does not expose any Vulkan internals. This
* struct is a leftover that was accidentally exposed.
*/
typedef struct _GdkVulkanContextPrivate GdkVulkanContextPrivate;

View File

@@ -296,10 +296,6 @@ typedef NSString *CALayerContentsGravity;
GdkMonitor *monitor;
GdkRectangle geometry;
GdkRectangle workarea;
int shadow_top = 0;
int shadow_left = 0;
int shadow_right = 0;
int shadow_bottom = 0;
GdkRectangle window_gdk;
GdkPoint pointer_position;
GdkPoint new_origin;
@@ -307,13 +303,6 @@ typedef NSString *CALayerContentsGravity;
if (!inManualMove)
return NO;
/* Get our shadow so we can adjust the window position sans-shadow */
_gdk_macos_surface_get_shadow (gdk_surface,
&shadow_top,
&shadow_right,
&shadow_bottom,
&shadow_left);
windowFrame = [self frame];
currentLocation = [NSEvent mouseLocation];
@@ -339,21 +328,9 @@ typedef NSString *CALayerContentsGravity;
window_gdk.width = windowFrame.size.width;
window_gdk.height = windowFrame.size.height;
/* Subtract our shadowin from the window */
window_gdk.x += shadow_left;
window_gdk.y += shadow_top;
window_gdk.width = window_gdk.width - shadow_left - shadow_right;
window_gdk.height = window_gdk.height - shadow_top - shadow_bottom;
/* Now place things on the monitor */
_edge_snapping_motion (&self->snapping, &pointer_position, &window_gdk);
/* And add our shadow back to the frame */
window_gdk.x -= shadow_left;
window_gdk.y -= shadow_top;
window_gdk.width += shadow_left + shadow_right;
window_gdk.height += shadow_top + shadow_bottom;
/* Convert to quartz coordinates */
_gdk_macos_display_to_display_coords ([self gdkDisplay],
window_gdk.x,
@@ -737,17 +714,11 @@ typedef NSString *CALayerContentsGravity;
-(NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
GdkMacosSurface *surface = gdk_surface;
NSRect rect;
int shadow_top;
/* Allow the window to move up "shadow_top" more than normally allowed
* by the default impl. This makes it possible to move windows with
* client side shadow right up to the screen's menu bar. */
_gdk_macos_surface_get_shadow (surface, &shadow_top, NULL, NULL, NULL);
rect = [super constrainFrameRect:frameRect toScreen:screen];
if (frameRect.origin.y > rect.origin.y)
rect.origin.y = MIN (frameRect.origin.y, rect.origin.y + shadow_top);
rect.origin.y = MIN (frameRect.origin.y, rect.origin.y);
return rect;
}

View File

@@ -22,6 +22,7 @@
#include <string.h>
#include "gdkmacoscursor-private.h"
#include "gdkcursorprivate.h"
@interface NSCursor()
-(long long)_coreCursorType;
@@ -217,9 +218,25 @@ _gdk_macos_cursor_get_ns_cursor (GdkCursor *cursor)
if (name == NULL)
{
nscursor = create_cursor_from_texture (gdk_cursor_get_texture (cursor),
gdk_cursor_get_hotspot_x (cursor),
gdk_cursor_get_hotspot_y (cursor));
GdkTexture *texture;
int hotspot_x, hotspot_y;
texture = gdk_cursor_get_texture (cursor);
hotspot_x = gdk_cursor_get_hotspot_x (cursor);
hotspot_y = gdk_cursor_get_hotspot_y (cursor);
if (texture == NULL)
{
int size = 32; // FIXME
int width, height;
texture = gdk_cursor_get_texture_for_size (cursor, size, 1,
&width, &height,
&hotspot_x, &hotspot_y);
}
nscursor = create_cursor_from_texture (texture, hotspot_x, hotspot_y);
return nscursor;
}
}

View File

@@ -161,7 +161,8 @@ void _gdk_macos_display_send_event (GdkMacosDisp
void _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
int x,
int y);
NSEvent *_gdk_macos_display_get_nsevent (GdkEvent *event);
NSEvent *_gdk_macos_display_get_matching_nsevent (GdkEvent *event);
NSEvent *_gdk_macos_display_get_exact_nsevent (GdkEvent *event);
NSEvent *_gdk_macos_display_get_last_nsevent (void);
GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self,
NSInteger sequence_number);

View File

@@ -47,20 +47,20 @@ _gdk_macos_display_position_toplevel_with_parent (GdkMacosDisplay *self,
/* Try to center on top of the parent but also try to make the whole thing
* visible in case that lands us under the topbar/panel/etc.
*/
parent_rect.x = parent->root_x + parent->shadow_left;
parent_rect.y = parent->root_y + parent->shadow_top;
parent_rect.width = GDK_SURFACE (parent)->width - parent->shadow_left - parent->shadow_right;
parent_rect.height = GDK_SURFACE (parent)->height - parent->shadow_top - parent->shadow_bottom;
parent_rect.x = parent->root_x;
parent_rect.y = parent->root_y;
parent_rect.width = GDK_SURFACE (parent)->width;
parent_rect.height = GDK_SURFACE (parent)->height;
surface_rect.width = GDK_SURFACE (surface)->width - surface->shadow_left - surface->shadow_right;
surface_rect.height = GDK_SURFACE (surface)->height - surface->shadow_top - surface->shadow_bottom;
surface_rect.width = GDK_SURFACE (surface)->width;
surface_rect.height = GDK_SURFACE (surface)->height;
surface_rect.x = parent_rect.x + ((parent_rect.width - surface_rect.width) / 2);
surface_rect.y = parent_rect.y + ((parent_rect.height - surface_rect.height) / 2);
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (monitor), &surface_rect);
*x = surface_rect.x - surface->shadow_left;
*y = surface_rect.y - surface->shadow_top;
*x = surface_rect.x;
*y = surface_rect.y;
}
static inline gboolean
@@ -99,15 +99,15 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
gdk_macos_monitor_get_workarea (monitor, &workarea);
/* First place at top-left of current monitor */
surface_rect.width = GDK_SURFACE (surface)->width - surface->shadow_left - surface->shadow_right;
surface_rect.height = GDK_SURFACE (surface)->height - surface->shadow_top - surface->shadow_bottom;
surface_rect.width = GDK_SURFACE (surface)->width;
surface_rect.height = GDK_SURFACE (surface)->height;
surface_rect.x = workarea.x + ((workarea.width - surface_rect.width) / 2);
surface_rect.y = workarea.y + ((workarea.height - surface_rect.height) / 2);
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (surface->best_monitor), &surface_rect);
*x = surface_rect.x - surface->shadow_left;
*y = surface_rect.y - surface->shadow_top;
*x = surface_rect.x;
*y = surface_rect.y;
/* Try to see if there are any other surfaces at this origin and if so,
* adjust until we get something better.
@@ -119,11 +119,11 @@ _gdk_macos_display_position_toplevel (GdkMacosDisplay *self,
*y += WARP_OFFSET_Y;
/* If we reached the bottom right, just bail and try the workspace origin */
if (*x + surface->shadow_left + WARP_OFFSET_X > workarea.x + workarea.width ||
*y + surface->shadow_top + WARP_OFFSET_Y > workarea.y + workarea.height)
if (*x + WARP_OFFSET_X > workarea.x + workarea.width ||
*y + WARP_OFFSET_Y > workarea.y + workarea.height)
{
*x = workarea.x - surface->shadow_left;
*y = workarea.y - surface->shadow_top;
*x = workarea.x;
*y = workarea.y;
return;
}
}

View File

@@ -77,6 +77,9 @@ gdk_macos_display_get_setting (GdkDisplay *display,
const char *setting,
GValue *value)
{
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_DEFAULT_SETTINGS)
return FALSE;
return _gdk_macos_display_get_setting (GDK_MACOS_DISPLAY (display), setting, value);
}
@@ -991,17 +994,41 @@ _gdk_macos_display_warp_pointer (GdkMacosDisplay *self,
CGWarpMouseCursorPosition ((CGPoint) { x, y });
}
/* Find the matching `NSEvent` for an `GdkEvent`. This function
* return the `NSEvent`, also for rewritten `GdkEvent`'s.
*/
NSEvent *
_gdk_macos_display_get_nsevent (GdkEvent *event)
_gdk_macos_display_get_matching_nsevent (GdkEvent *event)
{
for (const GList *iter = event_map.head; iter; iter = iter->next)
for (GList *iter = event_map.head; iter; iter = iter->next)
{
const GdkToNSEventMap *map = iter->data;
GdkToNSEventMap *map = iter->data;
if (map->gdk_event->event_type == event->event_type &&
map->gdk_event->device == event->device &&
map->gdk_event->time == event->time)
return map->nsevent;
{
return map->nsevent;
}
}
return NULL;
}
/* Find the matching `NSEvent` for the original `GdkEvent`.
* If an event was rewritten, it returns `NULL`.
*/
NSEvent *
_gdk_macos_display_get_exact_nsevent (GdkEvent *event)
{
for (GList *iter = event_map.head; iter; iter = iter->next)
{
GdkToNSEventMap *map = iter->data;
if (map->gdk_event == event)
{
return map->nsevent;
}
}
return NULL;

View File

@@ -738,7 +738,7 @@ gdk_macos_event_source_dispatch (GSource *source,
if (!handled)
{
NSEvent *nsevent = _gdk_macos_display_get_nsevent (event);
NSEvent *nsevent = _gdk_macos_display_get_exact_nsevent (event);
if (nsevent != NULL)
[NSApp sendEvent: nsevent];
}

View File

@@ -68,19 +68,10 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
gdk_macos_monitor_get_workarea (monitor, &bounds);
gdk_popup_layout_get_shadow_width (layout,
&self->parent_instance.shadow_left,
&self->parent_instance.shadow_right,
&self->parent_instance.shadow_top,
&self->parent_instance.shadow_bottom);
gdk_surface_layout_popup_helper (GDK_SURFACE (self),
width,
height,
self->parent_instance.shadow_left,
self->parent_instance.shadow_right,
self->parent_instance.shadow_top,
self->parent_instance.shadow_bottom,
0, 0, 0, 0, /* shadow-left/right/top/bottom */
monitor,
&bounds,
self->layout,

View File

@@ -61,11 +61,6 @@ struct _GdkMacosSurface
int height;
} next_layout;
int shadow_top;
int shadow_right;
int shadow_bottom;
int shadow_left;
cairo_rectangle_int_t next_frame;
gint64 pending_frame_counter;
@@ -91,16 +86,6 @@ CGDirectDisplayID _gdk_macos_surface_get_screen_id (GdkMacosSurface
const char *_gdk_macos_surface_get_title (GdkMacosSurface *self);
void _gdk_macos_surface_set_title (GdkMacosSurface *self,
const char *title);
void _gdk_macos_surface_get_shadow (GdkMacosSurface *self,
int *top,
int *right,
int *bottom,
int *left);
void _gdk_macos_surface_set_shadow (GdkMacosSurface *self,
int top,
int right,
int bottom,
int left);
gboolean _gdk_macos_surface_is_opaque (GdkMacosSurface *self);
NSView *_gdk_macos_surface_get_view (GdkMacosSurface *self);
gboolean _gdk_macos_surface_get_modal_hint (GdkMacosSurface *self);

View File

@@ -236,32 +236,6 @@ gdk_macos_surface_get_scale (GdkSurface *surface)
return [self->window backingScaleFactor];
}
void
_gdk_macos_surface_set_shadow (GdkMacosSurface *surface,
int top,
int right,
int bottom,
int left)
{
GdkMacosSurface *self = (GdkMacosSurface *)surface;
g_assert (GDK_IS_MACOS_SURFACE (self));
if (self->shadow_top == top &&
self->shadow_right == right &&
self->shadow_bottom == bottom &&
self->shadow_left == left)
return;
self->shadow_top = top;
self->shadow_right = right;
self->shadow_bottom = bottom;
self->shadow_left = left;
if (top || right || bottom || left)
[self->window setHasShadow:NO];
}
static void
gdk_macos_surface_begin_frame (GdkMacosSurface *self)
{
@@ -579,29 +553,6 @@ gdk_macos_surface_init (GdkMacosSurface *self)
self->monitors = g_ptr_array_new_with_free_func (g_object_unref);
}
void
_gdk_macos_surface_get_shadow (GdkMacosSurface *self,
int *top,
int *right,
int *bottom,
int *left)
{
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
if (top)
*top = self->shadow_top;
if (left)
*left = self->shadow_left;
if (bottom)
*bottom = self->shadow_bottom;
if (right)
*right = self->shadow_right;
}
gboolean
_gdk_macos_surface_is_opaque (GdkMacosSurface *self)
{
@@ -1097,16 +1048,12 @@ _gdk_macos_surface_monitor_changed (GdkMacosSurface *self)
g_set_object (&child->best_monitor, best);
area.x = self->root_x + GDK_SURFACE (child)->x + child->shadow_left;
area.y = self->root_y + GDK_SURFACE (child)->y + child->shadow_top;
area.width = GDK_SURFACE (child)->width - child->shadow_left - child->shadow_right;
area.height = GDK_SURFACE (child)->height - child->shadow_top - child->shadow_bottom;
area.x = self->root_x + GDK_SURFACE (child)->x;
area.y = self->root_y + GDK_SURFACE (child)->y;
area.width = GDK_SURFACE (child)->width;
area.height = GDK_SURFACE (child)->height;
_gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (best), &area);
area.x -= child->shadow_left;
area.y -= child->shadow_top;
_gdk_macos_surface_move (child, area.x, area.y);
gdk_surface_invalidate_rect (GDK_SURFACE (child), NULL);
}

View File

@@ -152,13 +152,6 @@ _gdk_macos_toplevel_surface_compute_size (GdkSurface *surface)
mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
}
if (size.shadow.is_valid)
_gdk_macos_surface_set_shadow (macos_surface,
size.shadow.top,
size.shadow.right,
size.shadow.bottom,
size.shadow.left);
_gdk_macos_surface_set_geometry_hints (macos_surface, &geometry, mask);
if (surface->state & (GDK_TOPLEVEL_STATE_FULLSCREEN |

View File

@@ -61,7 +61,7 @@ gdk_macos_deps = [
libgdk_c_args += ['-xobjective-c']
libgdk_macos = static_library('gdk-macos',
gdk_macos_sources, gdkconfig, gdkenum_h,
sources: [ gdk_macos_sources, gdk_gen_headers ],
include_directories: [ confinc, gdkinc, ],
c_args: [ libgdk_c_args, common_cflags, ],
link_with: [],

View File

@@ -202,7 +202,13 @@ gdkwayland_inc = include_directories('wayland')
wlinc = include_directories('.')
win32rcinc = include_directories('win32/rc')
gdk_gen_headers = [gdkenum_h, gdkmarshal_h, gdkconfig, gdkversionmacros_h, gdk_visibility_h]
gdk_gen_headers = [
gdkenum_h,
gdkmarshal_h,
gdkconfig,
gdkversionmacros_h,
gdk_visibility_h,
]
gdk_deps = [
libm,
@@ -278,7 +284,7 @@ if gdk_backends.length() == 0
endif
libgdk = static_library('gdk',
sources: [gdk_sources, gdk_backends_gen_headers, gdkconfig],
sources: [gdk_sources, gdk_backends_gen_headers, gdk_gen_headers],
dependencies: gdk_deps + [libgtk_css_dep],
link_with: [libgtk_css],
include_directories: [confinc, gdkx11_inc, wlinc],
@@ -290,7 +296,7 @@ libgdk = static_library('gdk',
# list the dependencies and generated headers and such, for use in the
# "public" libgtk_dep used by internal executables.
libgdk_dep = declare_dependency(
sources: ['gdk.h', gdkconfig, gdkenum_h],
sources: ['gdk.h', gdk_gen_headers],
include_directories: [confinc, gdkx11_inc, wlinc],
dependencies: gdk_deps + [libgtk_css_dep],
)

View File

@@ -198,17 +198,8 @@ static void
gdk_wayland_cairo_context_empty_frame (GdkDrawContext *draw_context)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!impl->has_pending_subsurface_commits)
return;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
gdk_wayland_surface_handle_empty_frame (surface);
}
static void

View File

@@ -79,6 +79,7 @@ static const struct {
{ "move", "dnd-move" },
{ "no-drop", "dnd-none" },
{ "dnd-ask", "dnd-copy" }, /* not CSS, but we want to guarantee it anyway */
{ "dnd-move", "default" },
{ "not-allowed", "crossed_circle" },
{ "grab", "hand2" },
{ "grabbing", "hand2" },
@@ -154,15 +155,19 @@ static const struct wl_buffer_listener buffer_listener = {
struct wl_buffer *
_gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
GdkCursor *cursor,
guint desired_scale,
double desired_scale,
gboolean use_viewporter,
guint image_index,
int *hotspot_x,
int *hotspot_y,
int *width,
int *height,
int *scale)
double *scale)
{
GdkTexture *texture;
int desired_scale_factor;
desired_scale_factor = (int) ceil (desired_scale);
if (gdk_cursor_get_name (cursor))
{
@@ -173,7 +178,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
c = gdk_wayland_cursor_load_for_name (display,
_gdk_wayland_display_get_cursor_theme (display),
desired_scale,
desired_scale_factor,
gdk_cursor_get_name (cursor));
if (c && c->image_count > 0)
{
@@ -190,7 +195,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
image = c->images[image_index];
cursor_scale = desired_scale;
cursor_scale = desired_scale_factor;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
{
@@ -210,7 +215,7 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
return wl_cursor_image_get_buffer (image);
}
}
else
else if (gdk_cursor_get_texture (cursor))
{
cairo_surface_t *surface;
struct wl_buffer *buffer;
@@ -225,7 +230,7 @@ from_texture:
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
&GDK_FRACTIONAL_SCALE_INIT_INT (1));
gdk_texture_download (texture,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
@@ -249,11 +254,50 @@ from_texture:
return buffer;
}
else
{
if (!use_viewporter)
*scale = desired_scale_factor;
else
*scale = desired_scale;
texture = gdk_cursor_get_texture_for_size (cursor,
display->cursor_theme_size,
*scale,
width,
height,
hotspot_x,
hotspot_y);
if (texture)
{
cairo_surface_t *surface;
struct wl_buffer *buffer;
surface = gdk_wayland_display_create_shm_surface (display,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
&GDK_FRACTIONAL_SCALE_INIT_INT (1));
gdk_texture_download (texture,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
cairo_surface_mark_dirty (surface);
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
wl_buffer_add_listener (buffer, &buffer_listener, surface);
g_object_unref (texture);
return buffer;
}
}
if (gdk_cursor_get_fallback (cursor))
return _gdk_wayland_cursor_get_buffer (display,
gdk_cursor_get_fallback (cursor),
gdk_cursor_get_fallback (cursor),
desired_scale,
use_viewporter,
image_index,
hotspot_x, hotspot_y,
width, height,

View File

@@ -62,6 +62,7 @@ struct _GdkWaylandPointerData {
uint32_t grab_time;
struct wl_surface *pointer_surface;
struct wp_viewport *pointer_surface_viewport;
guint cursor_is_default: 1;
GdkCursor *cursor;
guint cursor_timeout_id;
@@ -69,7 +70,7 @@ struct _GdkWaylandPointerData {
guint cursor_image_delay;
guint touchpad_event_sequence;
guint current_output_scale;
double current_output_scale;
GSList *pointer_surface_outputs;
/* Accumulated event data for a pointer frame */
@@ -182,6 +183,8 @@ struct _GdkWaylandSeat
GdkWaylandPointerData pointer_info;
GdkWaylandPointerData touch_info;
uint32_t latest_touch_down_serial;
GdkModifierType key_modifiers;
GdkSurface *keyboard_focus;
GdkSurface *grab_surface;

View File

@@ -260,18 +260,25 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
GdkWaylandPointerData *pointer =
gdk_wayland_device_get_pointer (wayland_device);
struct wl_buffer *buffer;
int x, y, w, h, scale;
int x, y, w, h;
double scale;
guint next_image_index, next_image_delay;
gboolean retval = G_SOURCE_REMOVE;
GdkWaylandTabletData *tablet;
gboolean use_viewport;
tablet = gdk_wayland_seat_find_tablet (seat, device);
use_viewport = pointer->pointer_surface_viewport != NULL;
if (g_getenv ("NO_POINTER_VIEWPORT"))
use_viewport = FALSE;
if (pointer->cursor)
{
buffer = _gdk_wayland_cursor_get_buffer (GDK_WAYLAND_DISPLAY (seat->display),
pointer->cursor,
pointer->current_output_scale,
use_viewport,
pointer->cursor_image_index,
&x, &y, &w, &h, &scale);
}
@@ -310,7 +317,17 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
if (buffer)
{
wl_surface_attach (pointer->pointer_surface, buffer, 0, 0);
wl_surface_set_buffer_scale (pointer->pointer_surface, scale);
if (use_viewport)
{
wp_viewport_set_source (pointer->pointer_surface_viewport,
wl_fixed_from_int (0),
wl_fixed_from_int (0),
wl_fixed_from_double (w * scale),
wl_fixed_from_double (h * scale));
wp_viewport_set_destination (pointer->pointer_surface_viewport, w, h);
}
else if (wl_surface_get_version (pointer->pointer_surface) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
wl_surface_set_buffer_scale (pointer->pointer_surface, scale);
wl_surface_damage (pointer->pointer_surface, 0, 0, w, h);
wl_surface_commit (pointer->pointer_surface);
}

View File

@@ -58,6 +58,7 @@
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
#include <wayland/server-decoration-client-protocol.h>
#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include "presentation-time-client-protocol.h"
#include "wm-button-layout-translation.h"
@@ -95,7 +96,6 @@
#define GTK_SHELL1_VERSION 5
#define OUTPUT_VERSION_WITH_DONE 2
#define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
#define XDG_ACTIVATION_VERSION 1
#define OUTPUT_VERSION 3
#ifdef HAVE_TOPLEVEL_STATE_SUSPENDED
@@ -105,6 +105,9 @@
#endif
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
static void _gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size);
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
@@ -310,7 +313,9 @@ linux_dmabuf_main_device (void *data,
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
struct wl_array *device)
{
dev_t dev G_GNUC_UNUSED = *(dev_t *)device->data;
dev_t dev G_GNUC_UNUSED;
memcpy (&dev, device->data, sizeof (dev_t));
GDK_DEBUG (MISC, "got dmabuf main device: %u %u", major (dev), minor (dev));
}
@@ -327,7 +332,9 @@ linux_dmabuf_tranche_target_device (void *data,
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
struct wl_array *device)
{
dev_t dev G_GNUC_UNUSED = *(dev_t *)device->data;
dev_t dev G_GNUC_UNUSED;
memcpy (&dev, device->data, sizeof (dev_t));
GDK_DEBUG (MISC, "got dmabuf tranche target device: %u %u", major (dev), minor (dev));
}
@@ -437,7 +444,7 @@ gdk_registry_handle_global (void *data,
{
display_wayland->compositor =
wl_registry_bind (display_wayland->wl_registry, id,
&wl_compositor_interface, MIN (version, 5));
&wl_compositor_interface, MIN (version, 6));
}
else if (strcmp (interface, "wl_shm") == 0)
{
@@ -585,24 +592,34 @@ gdk_registry_handle_global (void *data,
{
display_wayland->xdg_activation =
wl_registry_bind (display_wayland->wl_registry, id,
&xdg_activation_v1_interface,
MIN (version, XDG_ACTIVATION_VERSION));
&xdg_activation_v1_interface, 1);
}
else if (strcmp (interface, "wp_fractional_scale_manager_v1") == 0)
{
display_wayland->fractional_scale =
wl_registry_bind (display_wayland->wl_registry, id,
&wp_fractional_scale_manager_v1_interface,
MIN (version, 1));
&wp_fractional_scale_manager_v1_interface, 1);
}
else if (strcmp (interface, "wp_viewporter") == 0)
{
display_wayland->viewporter =
wl_registry_bind (display_wayland->wl_registry, id,
&wp_viewporter_interface,
&wp_viewporter_interface, 1);
}
else if (strcmp (interface, "wp_presentation") == 0)
{
display_wayland->presentation =
wl_registry_bind (display_wayland->wl_registry, id,
&wp_presentation_interface,
MIN (version, 1));
}
else if (strcmp (interface, wp_single_pixel_buffer_manager_v1_interface.name) == 0)
{
display_wayland->single_pixel_buffer =
wl_registry_bind (display_wayland->wl_registry, id,
&wp_single_pixel_buffer_manager_v1_interface,
MIN (version, 1));
}
g_hash_table_insert (display_wayland->known_globals,
GUINT_TO_POINTER (id), g_strdup (interface));
@@ -700,7 +717,8 @@ _gdk_wayland_display_open (const char *display_name)
process_on_globals_closures (display_wayland);
/* Wait for initializing to complete. This means waiting for all
* asynchronous roundtrips that were triggered during initial roundtrip. */
* asynchronous roundtrips that were triggered during initial roundtrip.
*/
while (display_wayland->async_roundtrips != NULL)
{
if (wl_display_dispatch (display_wayland->wl_display) < 0)
@@ -710,6 +728,18 @@ _gdk_wayland_display_open (const char *display_name)
}
}
/* Check that we got all the required globals */
if (display_wayland->compositor == NULL ||
display_wayland->shm == NULL ||
display_wayland->data_device_manager == NULL)
{
g_warning ("The Wayland compositor does not provide one or more of the required interfaces, "
"not using Wayland display");
g_object_unref (display);
return NULL;
}
if (display_wayland->xdg_wm_base_id)
{
display_wayland->shell_variant = GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL;
@@ -799,6 +829,8 @@ gdk_wayland_display_dispose (GObject *object)
g_clear_pointer (&display_wayland->xdg_activation, xdg_activation_v1_destroy);
g_clear_pointer (&display_wayland->fractional_scale, wp_fractional_scale_manager_v1_destroy);
g_clear_pointer (&display_wayland->viewporter, wp_viewporter_destroy);
g_clear_pointer (&display_wayland->presentation, wp_presentation_destroy);
g_clear_pointer (&display_wayland->single_pixel_buffer, wp_single_pixel_buffer_manager_v1_destroy);
g_clear_pointer (&display_wayland->linux_dmabuf, zwp_linux_dmabuf_v1_destroy);
g_clear_pointer (&display_wayland->linux_dmabuf_feedback, zwp_linux_dmabuf_feedback_v1_destroy);
if (display_wayland->linux_dmabuf_formats)
@@ -1104,7 +1136,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
display_class->get_monitors = gdk_wayland_display_get_monitors;
display_class->get_monitor_at_surface = gdk_wayland_display_get_monitor_at_surface;
display_class->get_setting = gdk_wayland_display_get_setting;
display_class->set_cursor_theme = gdk_wayland_display_set_cursor_theme;
display_class->set_cursor_theme = _gdk_wayland_display_set_cursor_theme;
}
static void
@@ -1177,11 +1209,22 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland,
* @size: the size to use for cursors
*
* Sets the cursor theme for the given @display.
*
* Deprecated: 4.16: Use the cursor-related properties of
* [GtkSettings](../gtk4/class.Settings.html) to set the cursor theme
*/
void
gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size)
{
_gdk_wayland_display_set_cursor_theme (display, name, size);
}
static void
_gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY(display);
struct wl_cursor_theme *theme;
@@ -1250,7 +1293,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
else
name = "default";
gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
_gdk_wayland_display_set_cursor_theme (GDK_DISPLAY (display_wayland), name, size);
g_value_unset (&v);
gdk_profiler_end_mark (before, "Wayland cursor theme load", NULL);
@@ -1786,6 +1829,7 @@ static TranslationEntry translations[] = {
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.desktop.interface", "font-rgba-order", "gtk-xft-rgba", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.desktop.interface", "font-rendering", "gtk-font-rendering", G_TYPE_ENUM, { .i = 0 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
@@ -1877,6 +1921,7 @@ apply_portal_setting (TranslationEntry *entry,
entry->fallback.s = g_intern_string (g_variant_get_string (value, NULL));
break;
case G_TYPE_INT:
case G_TYPE_ENUM:
entry->fallback.i = g_variant_get_int32 (value);
break;
case G_TYPE_BOOLEAN:
@@ -1996,9 +2041,10 @@ init_settings (GdkDisplay *display)
g_variant_get (ret, "(a{sa{sv}})", &iter);
if (g_variant_n_children (ret) == 0)
if (g_variant_iter_n_children (iter) == 0)
{
g_debug ("Received no portal settings");
g_clear_pointer (&iter, g_variant_iter_free);
g_clear_pointer (&ret, g_variant_unref);
goto fallback;
@@ -2125,6 +2171,9 @@ set_value_from_entry (GdkDisplay *display,
case G_TYPE_BOOLEAN:
g_value_set_boolean (value, entry->fallback.b);
break;
case G_TYPE_ENUM:
g_value_set_enum (value, entry->fallback.i);
break;
case G_TYPE_NONE:
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
g_value_set_uint (value, (guint)entry->fallback.i);
@@ -2175,6 +2224,11 @@ set_value_from_entry (GdkDisplay *display,
? g_settings_get_boolean (settings, entry->key)
: entry->fallback.b);
break;
case G_TYPE_ENUM:
g_value_set_enum (value, settings && entry->valid
? g_settings_get_enum (settings, entry->key)
: entry->fallback.i);
break;
case G_TYPE_NONE:
if (g_str_equal (entry->setting, "gtk-fontconfig-timestamp"))
g_value_set_uint (value, (guint)entry->fallback.i);

View File

@@ -39,6 +39,8 @@
#include <gdk/wayland/xdg-activation-v1-client-protocol.h>
#include <gdk/wayland/fractional-scale-v1-client-protocol.h>
#include <gdk/wayland/viewporter-client-protocol.h>
#include <gdk/wayland/presentation-time-client-protocol.h>
#include <gdk/wayland/single-pixel-buffer-v1-client-protocol.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
@@ -125,6 +127,8 @@ struct _GdkWaylandDisplay
struct xdg_activation_v1 *xdg_activation;
struct wp_fractional_scale_manager_v1 *fractional_scale;
struct wp_viewporter *viewporter;
struct wp_presentation *presentation;
struct wp_single_pixel_buffer_manager_v1 *single_pixel_buffer;
GList *async_roundtrips;

View File

@@ -88,14 +88,7 @@ gdk_wayland_gl_context_empty_frame (GdkDrawContext *draw_context)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
if (gdk_wayland_surface_needs_commit (surface))
{
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
}
gdk_wayland_surface_handle_empty_frame (surface);
}
static void

View File

@@ -34,6 +34,7 @@
#include <gdk/wayland/gdkwayland.h>
#include <gdk/wayland/gdkdisplay-wayland.h>
#include <gdk/wayland/gdkseat-wayland.h>
#include <gdk/wayland/gdkwaylandpresentationtime-private.h>
#include <xkbcommon/xkbcommon.h>
@@ -115,13 +116,14 @@ void gdk_wayland_display_system_bell (GdkDisplay *display,
struct wl_buffer *_gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
GdkCursor *cursor,
guint desired_scale,
double desired_scale,
gboolean use_viewporter,
guint image_index,
int *hotspot_x,
int *hotspot_y,
int *w,
int *h,
int *scale);
double *scale);
guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
GdkCursor *cursor,
guint scale,
@@ -129,7 +131,7 @@ guint _gdk_wayland_cursor_get_next_image_index (GdkWaylandDisplay *display,
guint *next_image_delay);
void gdk_wayland_surface_sync (GdkSurface *surface);
gboolean gdk_wayland_surface_needs_commit (GdkSurface *surface);
void gdk_wayland_surface_handle_empty_frame (GdkSurface *surface);
void gdk_wayland_surface_commit (GdkSurface *surface);
void gdk_wayland_surface_notify_committed (GdkSurface *surface);
void gdk_wayland_surface_request_frame (GdkSurface *surface);

View File

@@ -781,8 +781,8 @@ pointer_handle_motion (void *data,
{
double x, y;
gdk_event_get_position (event, &x, &y);
g_message ("motion %f %f, seat %p state %d",
x, y, seat, gdk_event_get_modifier_state (event));
gdk_debug_message ("motion %f %f, seat %p state %d",
x, y, seat, gdk_event_get_modifier_state (event));
}
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
@@ -1640,6 +1640,7 @@ touch_handle_down (void *data,
touch->x = wl_fixed_to_double (x);
touch->y = wl_fixed_to_double (y);
touch->touch_down_serial = serial;
seat->latest_touch_down_serial = serial;
event = gdk_touch_event_new (GDK_TOUCH_BEGIN,
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
@@ -1663,7 +1664,7 @@ touch_handle_down (void *data,
{
double xx, yy;
gdk_event_get_position (event, &xx, &yy);
g_message ("touch begin %f %f", xx, yy);
gdk_debug_message ("touch begin %f %f", xx, yy);
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -1698,7 +1699,7 @@ touch_handle_up (void *data,
{
double x, y;
gdk_event_get_position (event, &x, &y);
g_message ("touch end %f %f", x, y);
gdk_debug_message ("touch end %f %f", x, y);
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -1746,7 +1747,7 @@ touch_handle_motion (void *data,
{
double xx, yy;
gdk_event_get_position (event, &xx, &yy);
g_message ("touch update %f %f", xx, yy);
gdk_debug_message ("touch update %f %f", xx, yy);
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -1840,9 +1841,9 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
{
double x, y;
gdk_event_get_position (event, &x, &y);
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event), x, y, seat,
gdk_event_get_modifier_state (event));
gdk_debug_message ("swipe event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event), x, y, seat,
gdk_event_get_modifier_state (event));
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -1935,10 +1936,10 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
{
double x, y;
gdk_event_get_position (event, &x, &y);
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event),
x, y, seat,
gdk_event_get_modifier_state (event));
gdk_debug_message ("pinch event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event),
x, y, seat,
gdk_event_get_modifier_state (event));
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2029,10 +2030,10 @@ emit_gesture_hold_event (GdkWaylandSeat *seat,
{
double x, y;
gdk_event_get_position (event, &x, &y);
g_message ("hold event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event),
x, y, seat,
gdk_event_get_modifier_state (event));
gdk_debug_message ("hold event %d, coords: %f %f, seat %p state %d",
gdk_event_get_event_type (event),
x, y, seat,
gdk_event_get_modifier_state (event));
}
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -3766,8 +3767,7 @@ pointer_surface_update_scale (GdkDevice *device)
GdkWaylandDevice *wayland_device = GDK_WAYLAND_DEVICE (device);
GdkWaylandPointerData *pointer =
gdk_wayland_device_get_pointer (wayland_device);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
guint32 scale;
double scale;
GSList *l;
if (wl_surface_get_version (pointer->pointer_surface) < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
@@ -3782,8 +3782,8 @@ pointer_surface_update_scale (GdkDevice *device)
scale = 1;
for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
{
guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, l->data);
scale = MAX (scale, output_scale);
GdkMonitor *monitor = gdk_wayland_display_get_monitor_for_output (seat->display, l->data);
scale = MAX (scale, gdk_monitor_get_scale (monitor));
}
if (pointer->current_output_scale == scale)
@@ -3878,6 +3878,7 @@ gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
g_clear_object (&pointer->cursor);
wl_surface_destroy (pointer->pointer_surface);
g_slist_free (pointer->pointer_surface_outputs);
g_clear_pointer (&pointer->pointer_surface_viewport, wp_viewport_destroy);
}
static void
@@ -4241,6 +4242,9 @@ init_pointer_data (GdkWaylandPointerData *pointer_data,
wl_surface_add_listener (pointer_data->pointer_surface,
&pointer_surface_listener,
logical_device);
if (display_wayland->viewporter)
pointer_data->pointer_surface_viewport = wp_viewporter_get_viewport (display_wayland->viewporter, pointer_data->pointer_surface);
}
void
@@ -4390,15 +4394,24 @@ _gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat *seat,
serial = tablet->pointer_info.press_serial;
}
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
if (g_hash_table_size (seat->touches) > 0)
{
if (touch->touch_down_serial > serial)
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
{
if (sequence)
*sequence = GDK_SLOT_TO_EVENT_SEQUENCE (touch->id);
serial = touch->touch_down_serial;
if (touch->touch_down_serial > serial)
{
if (sequence)
*sequence = GDK_SLOT_TO_EVENT_SEQUENCE (touch->id);
serial = touch->touch_down_serial;
}
}
}
else
{
if (seat->latest_touch_down_serial > serial)
serial = seat->latest_touch_down_serial;
}
return serial;
}

View File

@@ -2,6 +2,7 @@
#include "gdksubsurfaceprivate.h"
#include "wayland-client-protocol.h"
typedef struct _GdkWaylandSubsurface GdkWaylandSubsurface;
typedef struct _GdkWaylandSubsurfaceClass GdkWaylandSubsurfaceClass;
@@ -23,10 +24,17 @@ struct _GdkWaylandSubsurface
GdkTexture *texture;
cairo_rectangle_int_t dest;
graphene_rect_t source;
enum wl_output_transform transform;
struct wl_region *opaque_region;
struct wl_callback *frame_callback;
struct wl_surface *bg_surface;
struct wl_subsurface *bg_subsurface;
struct wp_viewport *bg_viewport;
cairo_rectangle_int_t bg_rect;
gboolean bg_attached;
};
struct _GdkWaylandSubsurfaceClass

View File

@@ -25,6 +25,8 @@
#include "gdkdmabuftextureprivate.h"
#include "gdksurface-wayland-private.h"
#include "gdksubsurfaceprivate.h"
#include "gdkdebugprivate.h"
#include "gsk/gskrectprivate.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
@@ -46,11 +48,55 @@ gdk_wayland_subsurface_finalize (GObject *object)
g_clear_pointer (&self->viewport, wp_viewport_destroy);
g_clear_pointer (&self->subsurface, wl_subsurface_destroy);
g_clear_pointer (&self->surface, wl_surface_destroy);
g_clear_pointer (&self->subsurface, wl_subsurface_destroy);
g_clear_pointer (&self->bg_viewport, wp_viewport_destroy);
g_clear_pointer (&self->bg_subsurface, wl_subsurface_destroy);
g_clear_pointer (&self->bg_surface, wl_surface_destroy);
G_OBJECT_CLASS (gdk_wayland_subsurface_parent_class)->finalize (object);
}
static void
shm_buffer_release (void *data,
struct wl_buffer *buffer)
{
cairo_surface_t *surface = data;
/* Note: the wl_buffer is destroyed as cairo user data */
cairo_surface_destroy (surface);
}
static const struct wl_buffer_listener shm_buffer_listener = {
shm_buffer_release,
};
static struct wl_buffer *
get_shm_wl_buffer (GdkWaylandSubsurface *self,
GdkTexture *texture)
{
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
int width, height;
cairo_surface_t *surface;
GdkTextureDownloader *downloader;
struct wl_buffer *buffer;
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
surface = gdk_wayland_display_create_shm_surface (display, width, height, &GDK_FRACTIONAL_SCALE_INIT_INT (1));
downloader = gdk_texture_downloader_new (texture);
gdk_texture_downloader_download_into (downloader,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
gdk_texture_downloader_free (downloader);
buffer = _gdk_wayland_shm_surface_get_wl_buffer (surface);
wl_buffer_add_listener (buffer, &shm_buffer_listener, surface);
return buffer;
}
static void
dmabuf_buffer_release (void *data,
struct wl_buffer *buffer)
@@ -97,8 +143,8 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = {
};
static struct wl_buffer *
get_wl_buffer (GdkWaylandSubsurface *self,
GdkTexture *texture)
get_dmabuf_wl_buffer (GdkWaylandSubsurface *self,
GdkTexture *texture)
{
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
const GdkDmabuf *dmabuf;
@@ -149,23 +195,138 @@ get_wl_buffer (GdkWaylandSubsurface *self,
return buffer;
}
static struct wl_buffer *
get_wl_buffer (GdkWaylandSubsurface *self,
GdkTexture *texture)
{
GdkDisplay *display = gdk_surface_get_display (GDK_SUBSURFACE (self)->parent);
struct wl_buffer *buffer = NULL;
if (GDK_IS_DMABUF_TEXTURE (texture))
buffer = get_dmabuf_wl_buffer (self, texture);
if (GDK_DISPLAY_DEBUG_CHECK (display, FORCE_OFFLOAD))
{
if (!buffer)
buffer = get_shm_wl_buffer (self, texture);
}
return buffer;
}
static void
sp_buffer_release (void *data,
struct wl_buffer *buffer)
{
wl_buffer_destroy (buffer);
}
static const struct wl_buffer_listener sp_buffer_listener = {
sp_buffer_release,
};
static struct wl_buffer *
get_sp_buffer (GdkWaylandSubsurface *self)
{
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SUBSURFACE (self)->parent));
struct wl_buffer *buffer = NULL;
if (display->single_pixel_buffer)
buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_buffer,
0, 0, 0, 0xffffffffU);
if (buffer)
wl_buffer_add_listener (buffer, &sp_buffer_listener, self);
return buffer;
}
static inline enum wl_output_transform
gdk_texture_transform_to_wl (GdkTextureTransform transform)
{
return (enum wl_output_transform) transform;
}
static inline GdkTextureTransform
wl_output_transform_to_gdk (enum wl_output_transform transform)
{
return (GdkTextureTransform) transform;
}
static void
ensure_bg_surface (GdkWaylandSubsurface *self)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (GDK_SUBSURFACE (self)->parent);
GdkDisplay *display = gdk_surface_get_display (GDK_SUBSURFACE (self)->parent);
GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display);
struct wl_region *region;
if (self->bg_surface)
return;
self->bg_surface = wl_compositor_create_surface (disp->compositor);
self->bg_subsurface = wl_subcompositor_get_subsurface (disp->subcompositor,
self->bg_surface,
impl->display_server.wl_surface);
self->bg_viewport = wp_viewporter_get_viewport (disp->viewporter, self->bg_surface);
/* We are opaque */
wl_surface_set_opaque_region (self->bg_surface, self->opaque_region);
/* No input, please */
region = wl_compositor_create_region (disp->compositor);
wl_surface_set_input_region (self->bg_surface, region);
wl_region_destroy (region);
}
static inline gboolean
scaled_rect_is_integral (const graphene_rect_t *rect,
float scale,
graphene_rect_t *device_rect)
{
cairo_rectangle_int_t device_int;
gsk_rect_scale (rect, scale, scale, device_rect);
device_int.x = device_rect->origin.x;
device_int.y = device_rect->origin.y;
device_int.width = device_rect->size.width;
device_int.height = device_rect->size.height;
return device_int.x == device_rect->origin.x &&
device_int.y == device_rect->origin.y &&
device_int.width == device_rect->size.width &&
device_int.height == device_rect->size.height;
}
static gboolean
gdk_wayland_subsurface_attach (GdkSubsurface *sub,
GdkTexture *texture,
const graphene_rect_t *source,
const graphene_rect_t *dest,
GdkTextureTransform transform,
const graphene_rect_t *background,
gboolean above,
GdkSubsurface *sibling)
{
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
GdkWaylandSurface *parent = GDK_WAYLAND_SURFACE (sub->parent);
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (sub->parent));
struct wl_buffer *buffer = NULL;
gboolean result = FALSE;
GdkWaylandSubsurface *sib = sibling ? GDK_WAYLAND_SUBSURFACE (sibling) : NULL;
gboolean will_be_above;
double scale;
graphene_rect_t device_rect;
cairo_rectangle_int_t device_dest;
gboolean has_background;
enum wl_output_transform tf;
gboolean dest_changed = FALSE;
gboolean source_changed = FALSE;
gboolean transform_changed = FALSE;
gboolean stacking_changed = FALSE;
gboolean needs_commit = FALSE;
gboolean background_changed = FALSE;
gboolean needs_bg_commit = FALSE;
if (sibling)
will_be_above = sibling->above_parent;
@@ -178,69 +339,133 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
return FALSE;
}
self->dest.x = dest->origin.x;
self->dest.y = dest->origin.y;
self->dest.width = dest->size.width;
self->dest.height = dest->size.height;
self->source.origin.x = source->origin.x;
self->source.origin.y = source->origin.y;
self->source.size.width = source->size.width;
self->source.size.height = source->size.height;
scale = gdk_fractional_scale_to_double (&parent->scale);
device_rect.origin.x = dest->origin.x * scale;
device_rect.origin.y = dest->origin.y * scale;
device_rect.size.width = dest->size.width * scale;
device_rect.size.height = dest->size.height * scale;
device_dest.x = device_rect.origin.x;
device_dest.y = device_rect.origin.y;
device_dest.width = device_rect.size.width;
device_dest.height = device_rect.size.height;
if (self->dest.x != dest->origin.x ||
self->dest.y != dest->origin.y ||
self->dest.width != dest->size.width ||
self->dest.height != dest->size.height)
{
self->dest.x = dest->origin.x;
self->dest.y = dest->origin.y;
self->dest.width = dest->size.width;
self->dest.height = dest->size.height;
dest_changed = TRUE;
}
if (!gsk_rect_equal (&self->source, source))
{
self->source.origin.x = source->origin.x;
self->source.origin.y = source->origin.y;
self->source.size.width = source->size.width;
self->source.size.height = source->size.height;
source_changed = TRUE;
}
tf = gdk_texture_transform_to_wl (transform);
if (self->transform != tf)
{
self->transform = tf;
transform_changed = TRUE;
}
if (sibling != gdk_subsurface_get_sibling (sub, above) ||
will_be_above != gdk_subsurface_is_above_parent (sub))
stacking_changed = TRUE;
if (self->texture == NULL)
{
dest_changed = TRUE;
source_changed = TRUE;
transform_changed = TRUE;
stacking_changed = TRUE;
}
scale = gdk_fractional_scale_to_double (&parent->scale);
if (background)
{
background_changed =
!self->bg_attached ||
self->bg_rect.x != background->origin.x ||
self->bg_rect.y != background->origin.y ||
self->bg_rect.width != background->size.width ||
self->bg_rect.height != background->size.height;
self->bg_rect.x = background->origin.x;
self->bg_rect.y = background->origin.y;
self->bg_rect.width = background->size.width;
self->bg_rect.height = background->size.height;
}
else
{
background_changed = self->bg_attached;
self->bg_rect.x = 0;
self->bg_rect.y = 0;
self->bg_rect.width = 0;
self->bg_rect.height = 0;
}
has_background = self->bg_rect.width > 0 && self->bg_rect.height > 0;
if (has_background)
ensure_bg_surface (self);
if (!scaled_rect_is_integral (dest, 1, &device_rect))
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Non-integer coordinates %g %g %g %g for %dx%d texture, hiding subsurface %p",
"[%p] 🗙 Non-integral coordinates %g %g %g %g",
self,
dest->origin.x, dest->origin.y,
dest->size.width, dest->size.height,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self);
dest->size.width, dest->size.height);
}
else if (device_dest.x != device_rect.origin.x ||
device_dest.y != device_rect.origin.y ||
device_dest.width != device_rect.size.width ||
device_dest.height != device_rect.size.height)
else if (!scaled_rect_is_integral (dest, scale, &device_rect))
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Non-integral device coordinates %g %g %g %g (fractional scale %.2f), hiding subsurface %p",
"[%p] 🗙 Non-integral device coordinates %g %g %g %g (scale %.2f)",
self,
device_rect.origin.x, device_rect.origin.y,
device_rect.size.width, device_rect.size.width,
scale,
self);
device_rect.size.width, device_rect.size.height,
scale);
}
else if (!GDK_IS_DMABUF_TEXTURE (texture))
else if (background && !scaled_rect_is_integral (background, 1, &device_rect))
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"%dx%d %s is not a GdkDmabufTexture, hiding subsurface %p",
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
"[%p] 🗙 Non-integral background coordinates %g %g %g %g",
self,
background->origin.x, background->origin.y,
background->size.width, background->size.height);
}
else if (background && !scaled_rect_is_integral (background, scale, &device_rect))
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"[%p] 🗙 Non-integral background device coordinates %g %g %g %g (scale %.2f)",
self,
device_rect.origin.x, device_rect.origin.y,
device_rect.size.width, device_rect.size.height,
scale);
}
else if (!GDK_IS_DMABUF_TEXTURE (texture) &&
!GDK_DISPLAY_DEBUG_CHECK (gdk_surface_get_display (sub->parent), FORCE_OFFLOAD))
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"[%p] 🗙 %s (%dx%d) is not a GdkDmabufTexture",
self,
G_OBJECT_TYPE_NAME (texture),
self);
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
}
else if (!will_be_above &&
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE)
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE &&
!has_background)
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Cannot offload non-opaque %dx%d texture below, hiding subsurface %p",
"[%p] 🗙 Non-opaque texture (%dx%d) below",
self,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
gdk_texture_get_height (texture));
}
else if (has_background && !display->single_pixel_buffer)
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"[%p] 🗙 Texture has background, but no single-pixel buffer support",
self);
}
else
@@ -269,10 +494,13 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
}
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Attached %dx%d texture to subsurface %p at %d %d %d %d",
"[%p] %s Attaching texture (%dx%d) at %d %d %d %d",
self,
will_be_above
? (has_background ? "" : "")
: (has_background ? "" : ""),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self,
self->dest.x, self->dest.y,
self->dest.width, self->dest.height);
result = TRUE;
@@ -280,35 +508,53 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
else
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Compositor failed to create wl_buffer for %dx%d texture, hiding subsurface %p",
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
"[%p] 🗙 Failed to create wl_buffer",
self);
}
}
else
{
if (dest_changed)
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"[%p] %s Moving texture (%dx%d) to %d %d %d %d",
self,
will_be_above
? (has_background ? "" : "")
: (has_background ? "" : ""),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self->dest.x, self->dest.y,
self->dest.width, self->dest.height);
buffer = NULL;
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Moved %dx%d texture in subsurface %p to %d %d %d %d",
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self,
self->dest.x, self->dest.y,
self->dest.width, self->dest.height);
result = TRUE;
}
}
if (result)
{
wl_subsurface_set_position (self->subsurface, self->dest.x, self->dest.y);
wp_viewport_set_destination (self->viewport, self->dest.width, self->dest.height);
wp_viewport_set_source (self->viewport,
wl_fixed_from_double (self->source.origin.x),
wl_fixed_from_double (self->source.origin.y),
wl_fixed_from_double (self->source.size.width),
wl_fixed_from_double (self->source.size.height));
if (transform_changed)
{
wl_surface_set_buffer_transform (self->surface, self->transform);
needs_commit = TRUE;
}
if (dest_changed)
{
wl_subsurface_set_position (self->subsurface, self->dest.x, self->dest.y);
wp_viewport_set_destination (self->viewport, self->dest.width, self->dest.height);
needs_commit = TRUE;
}
if (source_changed)
{
wp_viewport_set_source (self->viewport,
wl_fixed_from_double (self->source.origin.x),
wl_fixed_from_double (self->source.origin.y),
wl_fixed_from_double (self->source.size.width),
wl_fixed_from_double (self->source.size.height));
needs_commit = TRUE;
}
if (buffer)
{
@@ -317,39 +563,95 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
0, 0,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
needs_commit = TRUE;
}
if (has_background)
{
if (background_changed)
{
wl_subsurface_set_position (self->bg_subsurface, self->bg_rect.x, self->bg_rect.y);
wp_viewport_set_destination (self->bg_viewport, self->bg_rect.width, self->bg_rect.height);
needs_bg_commit = TRUE;
}
if (!self->bg_attached)
{
self->bg_attached = TRUE;
wp_viewport_set_source (self->bg_viewport,
wl_fixed_from_int (0),
wl_fixed_from_int (0),
wl_fixed_from_int (1),
wl_fixed_from_int (1));
wl_surface_attach (self->bg_surface, get_sp_buffer (self), 0, 0);
wl_surface_damage_buffer (self->bg_surface, 0, 0, 1, 1);
needs_bg_commit = TRUE;
}
}
else
{
if (self->bg_attached)
{
self->bg_attached = FALSE;
wl_surface_attach (self->bg_surface, NULL, 0, 0);
needs_bg_commit = TRUE;
}
}
result = TRUE;
}
else
{
g_set_object (&self->texture, NULL);
if (g_set_object (&self->texture, NULL))
{
wl_surface_attach (self->surface, NULL, 0, 0);
needs_commit = TRUE;
}
wl_surface_attach (self->surface, NULL, 0, 0);
if (self->bg_attached)
{
self->bg_attached = FALSE;
wl_surface_attach (self->bg_surface, NULL, 0, 0);
needs_bg_commit = TRUE;
}
}
if (sib)
if (stacking_changed)
{
if (above)
wl_subsurface_place_above (self->subsurface, sib->surface);
if (sib)
{
if (above)
wl_subsurface_place_above (self->subsurface, sib->surface);
else
wl_subsurface_place_below (self->subsurface, sib->surface);
}
else
wl_subsurface_place_below (self->subsurface, sib->surface);
}
else
{
if (above)
wl_subsurface_place_above (self->subsurface,
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
else
wl_subsurface_place_below (self->subsurface,
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
{
if (above)
wl_subsurface_place_above (self->subsurface,
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
else
wl_subsurface_place_below (self->subsurface,
GDK_WAYLAND_SURFACE (sub->parent)->display_server.wl_surface);
}
needs_commit = TRUE;
if (self->bg_attached)
{
wl_subsurface_place_below (self->bg_subsurface, self->surface);
needs_bg_commit = TRUE;
}
}
wl_surface_commit (self->surface);
if (needs_commit)
wl_surface_commit (self->surface);
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
if (needs_bg_commit)
wl_surface_commit (self->bg_surface);
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = needs_commit || needs_bg_commit;
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = stacking_changed || dest_changed || background_changed;
return result;
}
@@ -361,7 +663,7 @@ gdk_wayland_subsurface_detach (GdkSubsurface *sub)
if (sub->parent == NULL)
{
g_warning ("Can't draw to destroyed subsurface %p", self);
g_warning ("Can't detach from destroyed subsurface %p", self);
return;
}
@@ -370,6 +672,13 @@ gdk_wayland_subsurface_detach (GdkSubsurface *sub)
wl_surface_set_opaque_region (self->surface, self->opaque_region);
wl_surface_commit (self->surface);
if (self->bg_attached)
{
wl_surface_attach (self->bg_surface, NULL, 0, 0);
wl_surface_commit (self->bg_surface);
self->bg_attached = FALSE;
}
((GdkWaylandSurface *)sub->parent)->has_pending_subsurface_commits = TRUE;
GDK_WAYLAND_SURFACE (sub->parent)->opaque_region_dirty = TRUE;
}
@@ -383,27 +692,49 @@ gdk_wayland_subsurface_get_texture (GdkSubsurface *sub)
}
static void
gdk_wayland_subsurface_get_dest (GdkSubsurface *sub,
graphene_rect_t *dest)
gdk_wayland_subsurface_get_texture_rect (GdkSubsurface *sub,
graphene_rect_t *rect)
{
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
dest->origin.x = self->dest.x;
dest->origin.y = self->dest.y;
dest->size.width = self->dest.width;
dest->size.height = self->dest.height;
rect->origin.x = self->dest.x;
rect->origin.y = self->dest.y;
rect->size.width = self->dest.width;
rect->size.height = self->dest.height;
}
static void
gdk_wayland_subsurface_get_source (GdkSubsurface *sub,
graphene_rect_t *source)
gdk_wayland_subsurface_get_source_rect (GdkSubsurface *sub,
graphene_rect_t *rect)
{
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
source->origin.x = self->source.origin.x;
source->origin.y = self->source.origin.y;
source->size.width = self->source.size.width;
source->size.height = self->source.size.height;
rect->origin.x = self->source.origin.x;
rect->origin.y = self->source.origin.y;
rect->size.width = self->source.size.width;
rect->size.height = self->source.size.height;
}
static GdkTextureTransform
gdk_wayland_subsurface_get_transform (GdkSubsurface *sub)
{
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
return wl_output_transform_to_gdk (self->transform);
}
static gboolean
gdk_wayland_subsurface_get_background_rect (GdkSubsurface *sub,
graphene_rect_t *rect)
{
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);
rect->origin.x = self->bg_rect.x;
rect->origin.y = self->bg_rect.y;
rect->size.width = self->bg_rect.width;
rect->size.height = self->bg_rect.height;
return rect->size.width > 0 && rect->size.height > 0;
}
static void
@@ -417,8 +748,10 @@ gdk_wayland_subsurface_class_init (GdkWaylandSubsurfaceClass *class)
subsurface_class->attach = gdk_wayland_subsurface_attach;
subsurface_class->detach = gdk_wayland_subsurface_detach;
subsurface_class->get_texture = gdk_wayland_subsurface_get_texture;
subsurface_class->get_source = gdk_wayland_subsurface_get_source;
subsurface_class->get_dest = gdk_wayland_subsurface_get_dest;
subsurface_class->get_source_rect = gdk_wayland_subsurface_get_source_rect;
subsurface_class->get_texture_rect = gdk_wayland_subsurface_get_texture_rect;
subsurface_class->get_transform = gdk_wayland_subsurface_get_transform;
subsurface_class->get_background_rect = gdk_wayland_subsurface_get_background_rect;
};
static void
@@ -466,9 +799,9 @@ gdk_wayland_surface_create_subsurface (GdkSurface *surface)
GdkWaylandSubsurface *sub;
struct wl_region *region;
if (disp->viewporter == NULL)
if (disp->subcompositor == NULL || disp->viewporter == NULL)
{
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Can't use subsurfaces without viewporter");
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Can't use subsurfaces without subcompositor and viewporter");
return NULL;
}

View File

@@ -44,6 +44,8 @@ struct _GdkWaylandSurface
struct wl_event_queue *event_queue;
struct wl_callback *frame_callback;
GdkWaylandPresentationTime *presentation_time;
unsigned int initial_configure_received : 1;
unsigned int has_uncommitted_ack_configure : 1;
unsigned int has_pending_subsurface_commits : 1;

View File

@@ -52,6 +52,9 @@
#include "gdktoplevel-wayland-private.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include "presentation-time-client-protocol.h"
#include "gsk/gskrectprivate.h"
/**
@@ -270,6 +273,20 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
_gdk_surface_update_size (surface);
}
static void
gdk_wayland_surface_clear_frame_callback (GdkWaylandSurface *self)
{
GdkSurface *surface = GDK_SURFACE (self);
g_clear_pointer (&self->frame_callback, wl_callback_destroy);
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
{
GdkSubsurface *subsurface = gdk_surface_get_subsurface (surface, i);
gdk_wayland_subsurface_clear_frame_callback (subsurface);
}
}
void
gdk_wayland_surface_frame_callback (GdkSurface *surface,
uint32_t time)
@@ -283,13 +300,7 @@ gdk_wayland_surface_frame_callback (GdkSurface *surface,
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland frame event", NULL);
GDK_DISPLAY_DEBUG (GDK_DISPLAY (display_wayland), EVENTS, "frame %p", surface);
g_clear_pointer (&impl->frame_callback, wl_callback_destroy);
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
{
GdkSubsurface *subsurface = gdk_surface_get_subsurface (surface, i);
gdk_wayland_subsurface_clear_frame_callback (subsurface);
}
gdk_wayland_surface_clear_frame_callback (impl);
GDK_WAYLAND_SURFACE_GET_CLASS (impl)->handle_frame (impl);
@@ -403,6 +414,17 @@ gdk_wayland_surface_request_frame (GdkSurface *surface)
wl_proxy_set_queue ((struct wl_proxy *) self->frame_callback, NULL);
wl_callback_add_listener (self->frame_callback, &frame_listener, surface);
if (self->presentation_time == NULL)
{
GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
self->presentation_time = gdk_wayland_presentation_time_new (wayland_display);
}
gdk_wayland_presentation_time_track (self->presentation_time,
clock,
self->display_server.wl_surface,
gdk_frame_clock_get_frame_counter (clock));
for (gsize i = 0; i < gdk_surface_get_n_subsurfaces (surface); i++)
{
GdkSubsurface *subsurface = gdk_surface_get_subsurface (surface, i);
@@ -637,6 +659,7 @@ static void
gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
struct wl_region *wl_region = NULL;
if (!impl->display_server.wl_surface)
@@ -659,16 +682,21 @@ gdk_wayland_surface_sync_opaque_region (GdkSurface *surface)
continue;
if (sub->texture != NULL)
cairo_region_subtract_rectangle (region, &sub->dest);
{
graphene_rect_t bounds;
cairo_rectangle_int_t rect;
gdk_subsurface_get_bounds (subsurface, &bounds);
gsk_rect_to_cairo_grow (&bounds, &rect);
cairo_region_subtract_rectangle (region, &rect);
}
}
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
region);
wl_region = wl_region_from_cairo_region (display, region);
cairo_region_destroy (region);
}
else
wl_region = wl_region_from_cairo_region (GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)),
impl->opaque_region);
wl_region = wl_region_from_cairo_region (display, impl->opaque_region);
}
wl_surface_set_opaque_region (impl->display_server.wl_surface, wl_region);
@@ -755,7 +783,7 @@ gdk_wayland_surface_sync (GdkSurface *surface)
gdk_wayland_surface_sync_viewport (surface);
}
gboolean
static gboolean
gdk_wayland_surface_needs_commit (GdkSurface *surface)
{
GdkWaylandSurface *self = GDK_WAYLAND_SURFACE (surface);
@@ -767,6 +795,20 @@ gdk_wayland_surface_needs_commit (GdkSurface *surface)
self->viewport_dirty;
}
void
gdk_wayland_surface_handle_empty_frame (GdkSurface *surface)
{
if (!gdk_wayland_surface_needs_commit (surface))
return;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "Wayland surface commit", NULL);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
}
static void
gdk_wayland_surface_fractional_scale_preferred_scale_cb (void *data,
struct wp_fractional_scale_v1 *fractional_scale,
@@ -779,6 +821,11 @@ gdk_wayland_surface_fractional_scale_preferred_scale_cb (void *data,
gdk_wayland_surface_update_size (surface,
surface->width, surface->height,
&GDK_FRACTIONAL_SCALE_INIT (scale));
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
"preferred fractional scale, surface %p scale %f",
surface,
gdk_fractional_scale_to_double (&GDK_FRACTIONAL_SCALE_INIT (scale)));
}
static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
@@ -795,8 +842,8 @@ surface_enter (void *data,
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
GDK_DISPLAY_DEBUG(gdk_surface_get_display (surface), EVENTS,
"surface enter, surface %p output %p", surface, output);
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
"surface enter, surface %p output %p", surface, output);
impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
@@ -828,9 +875,38 @@ surface_leave (void *data,
gdk_surface_leave_monitor (surface, monitor);
}
static void
surface_preferred_buffer_scale (void *data,
struct wl_surface *wl_surface,
int32_t factor)
{
GdkSurface *surface = GDK_SURFACE (data);
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
"preferred buffer scale, surface %p scale %d",
surface, factor);
}
static void
surface_preferred_buffer_transform (void *data,
struct wl_surface *wl_surface,
uint32_t transform)
{
GdkSurface *surface = GDK_SURFACE (data);
const char *transform_name[] = {
"normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270"
};
GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
"preferred buffer transform, surface %p transform %s",
surface, transform_name[transform]);
}
static const struct wl_surface_listener surface_listener = {
surface_enter,
surface_leave
surface_leave,
surface_preferred_buffer_scale,
surface_preferred_buffer_transform,
};
static void
@@ -1048,7 +1124,8 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
unmap_popups_for_surface (surface);
g_clear_pointer (&impl->frame_callback, wl_callback_destroy);
g_clear_pointer (&impl->presentation_time, gdk_wayland_presentation_time_free);
gdk_wayland_surface_clear_frame_callback (impl);
if (impl->awaiting_frame_frozen)
{
impl->awaiting_frame_frozen = FALSE;

View File

@@ -34,6 +34,7 @@
#include "gdktoplevelprivate.h"
#include "gdkdevice-wayland-private.h"
#include <wayland/presentation-time-client-protocol.h>
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
@@ -122,6 +123,8 @@ struct _GdkWaylandToplevel
struct wl_output *initial_fullscreen_output;
struct wp_presentation_feedback *feedback;
struct {
GdkToplevelState unset_flags;
GdkToplevelState set_flags;

View File

@@ -77,16 +77,8 @@ static void
gdk_vulkan_context_wayland_empty_frame (GdkDrawContext *context)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!impl->has_pending_subsurface_commits)
return;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
gdk_wayland_surface_commit (surface);
gdk_wayland_surface_notify_committed (surface);
gdk_wayland_surface_handle_empty_frame (surface);
}
static void

View File

@@ -48,7 +48,7 @@ GDK_AVAILABLE_IN_ALL
struct wl_display *gdk_wayland_display_get_wl_display (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
struct wl_compositor *gdk_wayland_display_get_wl_compositor (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_16
void gdk_wayland_display_set_cursor_theme (GdkDisplay *display,
const char *name,
int size);
@@ -60,7 +60,7 @@ void gdk_wayland_display_set_startup_notification_id (GdkDisp
GDK_AVAILABLE_IN_ALL
gboolean gdk_wayland_display_query_registry (GdkDisplay *display,
const char *global);
const char *global);
GDK_AVAILABLE_IN_4_4
gpointer gdk_wayland_display_get_egl_display (GdkDisplay *display);

View File

@@ -0,0 +1,19 @@
#pragma once
#include <gdk/gdkframeclock.h>
#include <gdk/wayland/gdkdisplay-wayland.h>
#include <gdk/wayland/gdksurface-wayland.h>
#include <gdk/wayland/gdkwaylanddisplay.h>
G_BEGIN_DECLS
typedef struct _GdkWaylandPresentationTime GdkWaylandPresentationTime;
GdkWaylandPresentationTime *gdk_wayland_presentation_time_new (GdkWaylandDisplay *display);
void gdk_wayland_presentation_time_track (GdkWaylandPresentationTime *self,
GdkFrameClock *frame_clock,
struct wl_surface *surface,
gint64 frame_number);
void gdk_wayland_presentation_time_free (GdkWaylandPresentationTime *self);
G_END_DECLS

View File

@@ -0,0 +1,152 @@
#include "config.h"
#include <gdk/gdkframeclockprivate.h>
#include "gdkwaylandpresentationtime-private.h"
typedef struct _GdkWaylandPresentationFrame
{
GdkWaylandPresentationTime *self;
struct wp_presentation_feedback *feedback;
GdkFrameClock *frame_clock;
gint64 frame_number;
} GdkWaylandPresentationFrame;
static void
gdk_wayland_presentation_frame_free (GdkWaylandPresentationFrame *frame)
{
g_clear_pointer (&frame->feedback, wp_presentation_feedback_destroy);
g_clear_object (&frame->frame_clock);
frame->self = NULL;
g_free (frame);
}
struct _GdkWaylandPresentationTime
{
GdkWaylandDisplay *display;
GPtrArray *frames;
};
GdkWaylandPresentationTime *
gdk_wayland_presentation_time_new (GdkWaylandDisplay *display)
{
GdkWaylandPresentationTime *self;
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), NULL);
self = g_new0 (GdkWaylandPresentationTime, 1);
self->display = g_object_ref (display);
self->frames = g_ptr_array_new_with_free_func ((GDestroyNotify)gdk_wayland_presentation_frame_free);
return self;
}
void
gdk_wayland_presentation_time_free (GdkWaylandPresentationTime *self)
{
g_clear_pointer (&self->frames, g_ptr_array_unref);
g_clear_object (&self->display);
g_free (self);
}
static gint64
time_from_wayland (uint32_t tv_sec_hi,
uint32_t tv_sec_lo,
uint32_t tv_nsec)
{
guint64 t = tv_sec_hi;
t <<= 32;
t |= tv_sec_lo;
t *= G_USEC_PER_SEC;
t += tv_nsec / 1000L;
return (gint64)t;
}
static void
gdk_wayland_presentation_feedback_sync_output (void *data,
struct wp_presentation_feedback *feedback,
struct wl_output *output)
{
}
static void
gdk_wayland_presentation_feedback_presented (void *data,
struct wp_presentation_feedback *feedback,
uint32_t tv_sec_hi,
uint32_t tv_sec_lo,
uint32_t tv_nsec,
uint32_t refresh,
uint32_t seq_hi,
uint32_t seq_lo,
uint32_t flags)
{
GdkWaylandPresentationFrame *frame = data;
GdkWaylandPresentationTime *self;
GdkFrameTimings *timings;
guint pos;
g_assert (frame != NULL);
g_assert (frame->self != NULL);
self = frame->self;
if ((timings = gdk_frame_clock_get_timings (frame->frame_clock, frame->frame_number)))
{
timings->presentation_time = time_from_wayland (tv_sec_hi, tv_sec_lo, tv_nsec);
timings->complete = TRUE;
}
if (g_ptr_array_find (self->frames, frame, &pos))
g_ptr_array_remove_index_fast (self->frames, pos);
}
static void
gdk_wayland_presentation_feedback_discarded (void *data,
struct wp_presentation_feedback *feedback)
{
GdkWaylandPresentationFrame *frame = data;
guint pos;
g_assert (frame != NULL);
g_assert (frame->self != NULL);
if (g_ptr_array_find (frame->self->frames, frame, &pos))
g_ptr_array_remove_index_fast (frame->self->frames, pos);
}
static const struct wp_presentation_feedback_listener gdk_wayland_presentation_feedback_listener = {
gdk_wayland_presentation_feedback_sync_output,
gdk_wayland_presentation_feedback_presented,
gdk_wayland_presentation_feedback_discarded,
};
void
gdk_wayland_presentation_time_track (GdkWaylandPresentationTime *self,
GdkFrameClock *frame_clock,
struct wl_surface *surface,
gint64 frame_number)
{
struct wp_presentation_feedback *feedback;
GdkWaylandPresentationFrame *frame;
g_return_if_fail (self != NULL);
g_return_if_fail (surface != NULL);
if (self->display->presentation == NULL)
return;
if (!(feedback = wp_presentation_feedback (self->display->presentation, surface)))
return;
frame = g_new0 (GdkWaylandPresentationFrame, 1);
frame->self = self;
frame->frame_clock = g_object_ref (frame_clock);
frame->frame_number = frame_number;
frame->feedback = g_steal_pointer (&feedback);
g_ptr_array_add (self->frames, frame);
wp_presentation_feedback_add_listener (frame->feedback,
&gdk_wayland_presentation_feedback_listener,
frame);
}

View File

@@ -22,6 +22,7 @@ gdk_wayland_sources = files([
'gdktoplevel-wayland.c',
'gdkpopup-wayland.c',
'gdkvulkancontext-wayland.c',
'gdkwaylandpresentationtime.c',
'wm-button-layout-translation.c',
])
@@ -46,81 +47,40 @@ gdk_wayland_deps = [
wlegldep,
]
wayland_scanner = find_program('wayland-scanner')
# Format:
# - protocol name
# - protocol stability ('private', 'stable' or 'unstable')
# - protocol version (if stability is 'unstable')
wlmod = import('unstable-wayland')
proto_sources = [
['gtk-shell', 'private', ],
['primary-selection', 'unstable', 'v1', ],
['pointer-gestures', 'unstable', 'v1', ],
['viewporter', 'stable', ],
['xdg-shell', 'unstable', 'v6', ],
['xdg-shell', 'stable', ],
['xdg-foreign', 'unstable', 'v1', ],
['xdg-foreign', 'unstable', 'v2', ],
['tablet', 'unstable', 'v2', ],
['keyboard-shortcuts-inhibit', 'unstable', 'v1', ],
['server-decoration', 'private' ],
['xdg-output', 'unstable', 'v1', ],
['idle-inhibit', 'unstable', 'v1', ],
['xdg-activation', 'staging', 'v1', ],
['fractional-scale', 'staging', 'v1', ],
['linux-dmabuf', 'unstable', 'v1', ],
'protocol/gtk-shell.xml',
'protocol/server-decoration.xml',
wlmod.find_protocol('primary-selection', state: 'unstable', version: 1),
wlmod.find_protocol('pointer-gestures', state: 'unstable', version: 1),
wlmod.find_protocol('viewporter', state: 'stable'),
wlmod.find_protocol('xdg-shell', state: 'unstable', version: 6),
wlmod.find_protocol('xdg-shell', state: 'stable'),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-foreign', state: 'unstable', version: 2),
wlmod.find_protocol('tablet', state: 'unstable', version: 2),
wlmod.find_protocol('keyboard-shortcuts-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-output', state: 'unstable', version: 1),
wlmod.find_protocol('idle-inhibit', state: 'unstable', version: 1),
wlmod.find_protocol('xdg-activation', state: 'staging', version: 1),
wlmod.find_protocol('fractional-scale', state: 'staging', version: 1),
wlmod.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
wlmod.find_protocol('presentation-time', state: 'stable'),
wlmod.find_protocol('single-pixel-buffer', state: 'staging', version: 1),
]
gdk_wayland_gen_headers = []
foreach p: proto_sources
proto_name = p.get(0)
proto_stability = p.get(1)
if proto_stability == 'stable'
output_base = proto_name
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
elif proto_stability == 'staging'
proto_version = p.get(2)
output_base = '@0@-@1@'.format(proto_name, proto_version)
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
elif proto_stability == 'private'
output_base = proto_name
input = files('protocol/@0@.xml'.format(proto_name))
else
proto_version = p.get(2)
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
endif
gdk_wayland_gen_headers += custom_target('@0@ client header'.format(output_base),
input: input,
output: '@0@-client-protocol.h'.format(output_base),
command: [
wayland_scanner,
'client-header',
'@INPUT@', '@OUTPUT@',
],
)
gdk_wayland_sources += custom_target('@0@ source'.format(output_base),
input: input,
output: '@0@-protocol.c'.format(output_base),
command: [
wayland_scanner,
'private-code',
'@INPUT@', '@OUTPUT@',
],
)
# Returns a list [.c, .h]
gen = wlmod.scan_xml(p)
assert(gen.length() == 2)
gdk_wayland_sources += gen[0]
gdk_wayland_gen_headers += gen[1]
endforeach
libgdk_wayland = static_library('gdk-wayland',
sources: [
gdk_wayland_sources,
gdk_wayland_gen_headers,
gdkconfig,
gdkenum_h,
],
sources: [ gdk_wayland_sources, gdk_wayland_gen_headers, gdk_gen_headers ],
include_directories: [ confinc, gdkinc, ],
c_args: [
'-DGTK_COMPILATION',

View File

@@ -21,6 +21,7 @@
#include "gdkcursor.h"
#include "gdkwin32.h"
#include "gdktextureprivate.h"
#include "gdkcursorprivate.h"
#include "gdkdisplay-win32.h"
@@ -1481,6 +1482,7 @@ gdk_win32_display_get_win32hcursor (GdkWin32Display *display,
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
GdkWin32HCursor *win32hcursor;
const char *cursor_name;
GdkTexture *texture;
GdkCursor *fallback;
g_return_val_if_fail (cursor != NULL, NULL);
@@ -1494,14 +1496,32 @@ gdk_win32_display_get_win32hcursor (GdkWin32Display *display,
return win32hcursor;
cursor_name = gdk_cursor_get_name (cursor);
texture = gdk_cursor_get_texture (cursor);
if (cursor_name)
win32hcursor = gdk_win32hcursor_create_for_name (display, cursor_name);
else
else if (texture)
win32hcursor = gdk_win32hcursor_create_for_texture (display,
gdk_cursor_get_texture (cursor),
texture,
gdk_cursor_get_hotspot_x (cursor),
gdk_cursor_get_hotspot_y (cursor));
else
{
int size = display->cursor_theme_size;
int width, height, hotspot_x, hotspot_y;
texture = gdk_cursor_get_texture_for_size (cursor, size, 1,
&width, &height,
&hotspot_x, &hotspot_y);
if (texture)
{
win32hcursor = gdk_win32hcursor_create_for_texture (display,
texture,
hotspot_x,
hotspot_y);
g_object_unref (texture);
}
}
if (win32hcursor != NULL)
{

Some files were not shown because too many files have changed in this diff Show More