Compare commits

..

548 Commits

Author SHA1 Message Date
Matthias Clasen
49e93f6ee4 textview: Don't validate during snapshot
Do it during size_allocate, and go back there
if needed.
2023-02-21 15:04:30 -05:00
Matthias Clasen
4ec2234537 widget: Warn for invalidation during paint 2023-02-21 15:04:30 -05:00
Matthias Clasen
5a3755b233 frameclock: Add a debug helper
Begin able to query the current phase
is useful for debugging purposes.
2023-02-21 15:04:30 -05:00
Daniel
cad5771a66 Updated Spanish translation 2023-02-21 12:07:49 +01:00
Emmanuele Bassi
378f1421f0 Merge branch 'main' into 'main'
button: Remove nullable annotation for new_from_icon_name()

Closes #5606

See merge request GNOME/gtk!5544
2023-02-20 21:30:05 +00:00
Philipp Hörist
a209a73c69 button: Remove nullable annotation for new_from_icon_name()
This makes it more consistent with set_icon_name() which
does also not accept NULL.

Fixes #5606
2023-02-20 20:33:42 +01:00
Matthias Clasen
624458df9d Merge branch 'builder-tool-child-properties' into 'main'
gtk4-builder-tool: Prefer child properties

Closes #5609

See merge request GNOME/gtk!5543
2023-02-20 13:12:27 +00:00
Matthias Clasen
fbfbaa484d Merge branch 'matthiasc/for-main' into 'main'
filechooser: Fix paned limits

See merge request GNOME/gtk!5542
2023-02-20 13:04:33 +00:00
Matthias Clasen
3de10847b9 gtk4-builder-tool: Prefer child properties
Rewrite <child> elements to use child properties
where that is easily possible.

Fixes: #5609
2023-02-19 21:48:56 -05:00
Kukuh Syafaat
8be601da4f Update Indonesian translation 2023-02-20 01:20:48 +00:00
Matthias Clasen
07b9a6fb75 filechooser: Fix paned limits
The intention of the ui file was to not let
the paned shrink both children down to nothing,
but using <child> for the children effectively
overrides the setting of the shrink properties.
Fix that by using child properties instead of
<child>.
2023-02-19 19:12:30 -05:00
Matthias Clasen
5105d607de Merge branch 'builder-tool-template-parent' into 'main'
builder-tool: Try harder to find template parents

Closes #5232

See merge request GNOME/gtk!5541
2023-02-20 00:05:06 +00:00
Matthias Clasen
a9f03be588 builder-tool: Try harder to find template parents
This will make it work (in some cases) to add extra
libraries via LD_PRELOAD.

Based on work by Julian Sparber,
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5084

Fixes: #5232
2023-02-19 18:17:34 -05:00
Asier Sarasua Garmendia
d67bdb96ad Update Basque translation 2023-02-19 20:44:24 +00:00
Yuri Chornoivan
c8f4535ed2 Update Ukrainian translation 2023-02-19 20:23:35 +00:00
Aurimas Černius
21cbf98942 Update Lithuanian translation 2023-02-19 19:06:03 +00:00
Emmanuele Bassi
300540f6b8 Merge branch 'texturescalenode-type-annotations' into 'main'
Fix self-`(type)` annotations for `TextureScaleNode` methods

See merge request GNOME/gtk!5539
2023-02-19 17:18:01 +00:00
Sebastian Dröge
323ba14dde Fix self-(type) annotations for TextureScaleNode methods 2023-02-19 19:00:34 +02:00
Matthias Clasen
aaee1ee5bd Merge branch 'fix_custom_accessible_hierarchy' into 'main'
Allow setting accessible parent and next sibling

See merge request GNOME/gtk!5517
2023-02-19 16:15:49 +00:00
Matthias Clasen
70a711882c Fix the build 2023-02-19 15:26:27 +00:00
Matthias Clasen
5717b95cad Miscellaneous formatting and documentation fixes 2023-02-19 15:09:25 +00:00
Matthias Clasen
1b0f324be5 Merge branch 'missing-since-markers' into 'main'
Add two missing `Since` markers

See merge request GNOME/gtk!5537
2023-02-19 14:56:51 +00:00
Sebastian Dröge
ca93512106 Add two missing Since markers 2023-02-19 11:18:15 +02:00
Ekaterine Papava
fbd4f06ee2 Update Georgian translation 2023-02-19 05:48:04 +00:00
Benjamin Otte
d553f6941d Merge branch 'wip/otte/for-main' into 'main'
listview: Measure children only, not self

See merge request GNOME/gtk!5535
2023-02-19 05:33:59 +00:00
Matthias Clasen
2173b7ccaa Merge branch 'matthiasc/for-main' into 'main'
Drop some unnecessary includes

See merge request GNOME/gtk!5536
2023-02-19 05:01:53 +00:00
Matthias Clasen
ca6642deed Drop some unnecessary includes 2023-02-18 23:42:04 -05:00
Benjamin Otte
be6a4722c0 listview: Measure children only, not self
The previous code would include CSS padding/margin/border in the
measurement and that is wrong.

Until commit a96c75ff02 this was not actually visible, but afterwards
listitems were allocated 16px too wide.

Test included
2023-02-19 05:41:29 +01:00
Matthias Clasen
3b3b63062d Revert "Merge branch 'inscription-single-line' into 'main'"
This reverts commit 7ec90abf24, reversing
changes made to ec49a912aa.

We did not have agreement on this after all.
2023-02-18 19:04:00 -05:00
Matthias Clasen
7ec90abf24 Merge branch 'inscription-single-line' into 'main'
inscription: Add single-line-mode property

Closes #5444

See merge request GNOME/gtk!5504
2023-02-18 23:34:17 +00:00
Matthias Clasen
ec49a912aa Merge branch 'wip/carlosg/dnd-x11-keys' into 'main'
gdk/x11: Also grab keyboard during XDnD grabs

Closes #5604

See merge request GNOME/gtk!5533
2023-02-18 22:20:30 +00:00
Carlos Garnacho
ae94417f80 gdk/x11: Also grab keyboard during XDnD grabs
The drag source must handle events and messaging, this also
includes keyboard handling for accessibility and cancellation.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5604
2023-02-18 23:02:22 +01:00
Matthias Clasen
24a6803958 Merge branch 'matthiasc/for-main' into 'main'
gtksearchentry: Apply header capitalization to the "Clear entry" tooltip

See merge request GNOME/gtk!5532
2023-02-18 21:10:16 +00:00
Automeris naranja
4073371416 gtksearchentry: Apply header capitalization to the "Clear entry" tooltip
HIG advises to use header capitalization in tooltip texts.

https://developer.gnome.org/hig/patterns/feedback/tooltips.html
2023-02-18 15:53:54 -05:00
Matthias Clasen
e5a391c0b9 Merge branch 'matthiasc/for-main' into 'main'
securememory: use function checks

Closes #5070

See merge request GNOME/gtk!5531
2023-02-18 17:21:15 +00:00
Matthias Clasen
6cb612ac15 gtk-demo: Fix build without sincos
We are getting into trouble here if
sincos isn't detected but still present
in headers. Avoid that.

Also fix the other copy of gtkgears.c.
2023-02-18 10:41:02 -05:00
Matthias Clasen
9f64202a60 meson: Consolidate function checks
Put all the function checks in one place.
Remove functions we don't actually use,
and add ones that we have #ifdefs for in
in the code. Also add enough includes to
make these checks actually work.

Fixes: #5070
2023-02-18 09:37:36 -05:00
Matthias Clasen
19c362f638 securememory: use function checks
Checking for getpagesize in meson.build is
useless if we don't check the resulting define
in the code. So do that.
2023-02-18 09:34:50 -05:00
Matthias Clasen
e51fa8b65b Merge branch 'matthiasc/for-main' into 'main'
printing: Avoid getrandom

See merge request GNOME/gtk!5530
2023-02-17 22:39:04 +00:00
Matthias Clasen
06d3bbafaf printing: Avoid getrandom
GLib has perfectly serviceable random number
apis, and this breaks the macOs build.
2023-02-17 17:20:44 -05:00
Matthias Clasen
da8a1f4683 Merge branch 'scalebutton-active-since-marker' into 'main'
Add missing `Since` marker to `GtkScaleButton:active`

See merge request GNOME/gtk!5529
2023-02-17 19:54:03 +00:00
Sebastian Dröge
ad7d9bc409 Add missing Since marker to GtkScaleButton:active 2023-02-17 19:41:55 +02:00
Emmanuele Bassi
94cde8d702 Merge branch 'ebassi/ci-update-v41' into 'main'
ci: Update image

See merge request GNOME/gtk!5528
2023-02-17 12:55:50 +00:00
Emmanuele Bassi
ec7b1f7208 ci: Add no-cache option to run-docker.sh script
Use `run-docker.sh build --no-cache` to discard the cached layers if you
need to rebuild the image without modifying the Dockerfile.
2023-02-17 12:24:09 +00:00
Emmanuele Bassi
864fbf89cd ci: Update image
Refresh the Fedora base (still at 37), and add the Python packaging
module for gi-docgen.
2023-02-17 12:24:09 +00:00
Emmanuele Bassi
b8e928d703 Merge branch 'matthiasc/for-main' into 'main'
mask: Fix glsl

See merge request GNOME/gtk!5527
2023-02-17 12:23:36 +00:00
Matthias Clasen
0b4d41698b mask: Fix glsl 2023-02-17 06:26:42 -05:00
Matthias Clasen
a9eca60b84 Merge branch 'wip/fix-mask-modes-regression' into 'main'
wayland/glcontext: Don't call wl_surface.offset on old objects

See merge request GNOME/gtk!5526
2023-02-17 11:25:06 +00:00
Jonas Ådahl
53c3f497f1 wayland: Clean up some dead code 2023-02-17 12:03:58 +01:00
Jonas Ådahl
3183a21347 wayland/glcontext: Don't call wl_surface.offset on old objects
The availability of wl_surface.offset depends on the compositor, so we
can't call it unconditionally. Add a version check to so we only call
offset if we know we won't raise a protocol error.

Fixes: 0eb791eaaa ("Make mask nodes more versatile")
2023-02-17 12:03:27 +01:00
Matthias Clasen
07f090f947 Merge branch 'test-invisible-text' into 'main'
Add a test for invisible text navigation

See merge request GNOME/gtk!5525
2023-02-17 03:01:42 +00:00
Matthias Clasen
ad111087cc Add a test for invisible text navigation
This shows that (at least some) things
work as expected.

See: #1811
2023-02-16 14:27:44 -05:00
Jürgen Benvenuti
5092581be8 Update German translation 2023-02-16 17:18:16 +00:00
Matthias Clasen
b261f7f533 Merge branch 'nielsdg/set-action-enabled-doc-ref' into 'main'
widget: mention action_set_enabled in install_action

See merge request GNOME/gtk!5524
2023-02-16 11:24:15 +00:00
Niels De Graef
779f9e5071 widget: mention action_set_enabled in install_action
When looking at `gtk_widget_class_install_action()`, it isn't
immediately obvious how actions can be enabled or disabled. Add a
reference to the `gtk_widget_action_set_enabled()` method so people have
a quick link to that.
2023-02-16 08:47:06 +01:00
Matthias Clasen
b07d9d1912 Merge branch 'alatiera/flatpak-ci' into 'main'
ci: Build and publish aarch64 flatpaks

Closes #5594

See merge request GNOME/gtk!5523
2023-02-15 19:54:32 +00:00
Jordan Petridis
7b4692bcb0 ci: Add a simple auto-retry policy 2023-02-15 21:38:24 +02:00
Jordan Petridis
f0a2b6f165 ci: Build and publish aarch64 flatpaks
Close GNOME/gtk#5594
2023-02-15 21:19:56 +02:00
Jordan Petridis
2dc6efd9ce ci: Switch from only/except to rules: keyword
It's more flexible and allows us to combine the flatpak jobs
2023-02-15 21:10:40 +02:00
Emmanuele Bassi
1f4adb60bb Merge branch 'fix-annotations' into 'main'
Fix a couple incorrect annotations for optional parameters

See merge request GNOME/gtk!5503
2023-02-15 16:27:11 +00:00
Lukáš Tyrychtr
f507dd4962 Allow updating the next accessible sibling for a GtkAccessible 2023-02-15 12:29:16 +01:00
Matthias Clasen
1bdb368e8b Merge branch 'more-mask-modes' into 'main'
rendernodeparser: Fix mask mode handling

See merge request GNOME/gtk!5522
2023-02-15 03:54:01 +00:00
Matthias Clasen
aec4bfcf3b gsk: Add a node parser test for mask modes 2023-02-14 21:47:54 -05:00
Matthias Clasen
7e18c2849b gsk: Add a render test for mask modes 2023-02-14 21:47:54 -05:00
Matthias Clasen
351abadee7 Make make not fallback match GL
We were not handling the inverted-luminance
case the same way, and it caused a test to
fail. Yay for tests.
2023-02-14 21:47:54 -05:00
Matthias Clasen
951db28f71 rendernodeparser: Fix mask mode handling
I had forgotten inverted-luminance, and also
to print an error.
2023-02-14 21:01:12 -05:00
Benjamin Otte
40e7a265a7 rendernodeparser: Print an error when failing to parse an enum 2023-02-14 21:01:12 -05:00
Matthias Clasen
9a539cec57 Merge branch 'mask-modes' into 'main'
Make mask nodes more versatile

See merge request GNOME/gtk!5521
2023-02-15 00:57:17 +00:00
Matthias Clasen
724cf6bd70 Merge branch 'wip/cdavis/menubutton-active' into 'main'
menubutton: Add `active` property and getter/setter

See merge request GNOME/gtk!5506
2023-02-15 00:44:17 +00:00
Matthias Clasen
5e4b43dcce Merge branch 'wip/otte/downloader' into 'main'
Add GdkTextureDownloader

See merge request GNOME/gtk!5515
2023-02-15 00:41:26 +00:00
Matthias Clasen
fa43282695 Merge branch 'wip/otte/disable-style-check' into 'main'
CI: Don't run style-check-diff by default

See merge request GNOME/gtk!5520
2023-02-15 00:36:53 +00:00
Benjamin Otte
662c251cd0 demo: Spice up the mask demo
Also use all the mask modes, weeeee!
2023-02-14 19:07:01 -05:00
Matthias Clasen
0d97d03fc1 Document mask node parser format 2023-02-14 19:07:01 -05:00
Matthias Clasen
cb0aaf0b2c Add more mask node tests 2023-02-14 19:07:01 -05:00
Matthias Clasen
0eb791eaaa Make mask nodes more versatile
Add a GskMaskMode enumeration and implement it
in the GL and cairo renderers.
2023-02-14 19:07:01 -05:00
Benjamin Otte
073c836f96 CI: Don't run style-check-diff by default
We don't use it most of the time and it's also confusing to new contributors who think it's important to fix it.

Keep it for manual runs, so that interested people can just click a button to see the results. It also makes it easy to turn back on later.
2023-02-14 23:53:02 +00:00
Matthias Clasen
0a0a03d913 Merge branch 'fix_4258' into 'main'
Don't tell the screen reader that a button is related to an image which has no useful label

Closes #4258

See merge request GNOME/gtk!4665
2023-02-14 23:50:18 +00:00
Lukáš Tyrychtr
d43724f5fc Don't tell the screen reader that a button is related to an image which has no useful label 2023-02-14 23:50:18 +00:00
Matthias Clasen
abf3cdb187 Merge branch 'cpdb' into 'main'
Update dependencies for CPDB print backend

Closes #5589

See merge request GNOME/gtk!5518
2023-02-14 23:48:43 +00:00
Benjamin Otte
cca5de3c7f memorytexture: Export less private API
It's not needed anymore with GdkTextureDownloader now.
2023-02-15 00:39:18 +01:00
Benjamin Otte
774696011d glrenderer: Use GdkTexureDownloader 2023-02-15 00:39:18 +01:00
Benjamin Otte
c9f54ca371 texture: Export gdk_texture_get_format()
The API docs outline why quite well.

This should make it possible to do saving of textures to image files
without any private API with the same featureset that GTK uses.

Also remove the gsktextureprivate.h include where
gdk_texture_get_format() was the only reason for it.
2023-02-15 00:39:18 +01:00
Benjamin Otte
ce0123ea58 docs: Link from gdk_texture_download() to GdkTextureDownloader 2023-02-15 00:39:18 +01:00
Benjamin Otte
b30af72125 tiff: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte
eb45b8083a png: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte
f05d801e28 jpeg: Use GdkTexureDownloader when saving 2023-02-15 00:39:18 +01:00
Benjamin Otte
4afec951c7 pixbuf: Use GdkTextureDownloader when downloading pixbufs 2023-02-15 00:39:18 +01:00
Benjamin Otte
51ed1442a2 gdk: Add GdkTextureDownloader
It's the new object that allows more control about accessing texture
data.
2023-02-15 00:39:18 +01:00
Benjamin Otte
01ff6c1c22 memorytexture: Use right size for GBytes
The GBytes were created with the wrong size.

Nobody seems to have looked at it.
2023-02-14 23:42:17 +01:00
Fran Dieguez
73f3ea9511 Update Galician translation 2023-02-14 20:04:07 +00:00
Emmanuele Bassi
f1311dc053 Merge branch 'gsk-render-node-type-abi-breakage' into 'main'
gsk: Move new 4.10 `GskRenderNodeType`s to the end instead of inserting them in the middle

See merge request GNOME/gtk!5519
2023-02-14 19:28:36 +00:00
Sebastian Dröge
a252aadadf gsk: Move new 4.10 GskRenderNodeTypes to the end instead of inserting them in the middle 2023-02-14 21:04:41 +02:00
tinytrebuchet
300670dad4 Update dependencies for CPDB print backend
Require cpdb-frontend 2.x for building CPDB print backend.
2023-02-14 23:39:13 +05:30
Matthias Clasen
44c95d3c96 Merge branch 'kjellahl/clang' into 'main'
gskglrenderjob: Fix compilation with clang

See merge request GNOME/gtk!5516
2023-02-14 14:18:29 +00:00
Lukáš Tyrychtr
d566771262 Preserve the correct a11y tree in GtkStack
Now, when we can, ensure that the GtkStackPage is the parent of its widget.
2023-02-14 14:44:20 +01:00
Lukáš Tyrychtr
5f72b51105 Allow setting accessible parent and sibling explicitly
This allows to maintain the correct a11y hierarchy even when it contains
objects which are only GtkAccessibles.
2023-02-14 14:43:57 +01:00
Hugo Carvalho
e0afd22c84 Update Portuguese translation 2023-02-14 11:39:50 +00:00
Kjell Ahlstedt
869ab1cd1b gskglrenderjob: Fix compilation with clang 2023-02-14 10:29:25 +01:00
Matthias Clasen
730593fab5 Merge branch 'texttag_textview_documentation' into 'main'
Update TextTag and TextView indent Documentation

See merge request GNOME/gtk!5507
2023-02-14 00:08:39 +00:00
Matthias Clasen
d0798c9526 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Fix hotspot handling in dnd

See merge request GNOME/gtk!5513
2023-02-14 00:03:55 +00:00
Matthias Clasen
e6dfb8732a gtk-demo: Fix hotspot handling in dnd
We were not remembering the pointer coordinates.
2023-02-13 18:39:45 -05:00
Aurimas Černius
453ef8c7e1 Update Lithuanian translation 2023-02-13 21:07:37 +00:00
Sabri Ünal
819595d1a9 Update Turkish translation 2023-02-13 18:08:05 +00:00
Andre Klapper
306276b689 Fix invalid markup in Belarusian UI translation 2023-02-13 18:32:03 +01:00
Emmanuele Bassi
bb15a7ef46 Merge branch 'faq-updates' into 'main'
faq: Some updates

See merge request GNOME/gtk!5512
2023-02-13 14:50:35 +00:00
Matthias Clasen
cd0fe13dae faq: Add a question about parallel UIs 2023-02-13 08:54:36 -05:00
Matthias Clasen
3dcea74e85 faq: Don't number questions
The numbering makes it unnecessarily hard to add
and remove questions, and does not really seem
necessary. Just use bullets.
2023-02-13 08:52:04 -05:00
Matthias Clasen
537c2f6c7a faq: Some updates
Miscellaneous tweaks and changes, after reading
the whole thing.
2023-02-13 08:52:03 -05:00
Matthias Clasen
72379f64e9 Merge branch 'fix-font-chooser-filter' into 'main'
Fix an assertion in GtkFontChooserWidget when setting a filter.

See merge request GNOME/gtk!5511
2023-02-13 12:41:48 +00:00
Akira TAGOH
4532c3020b Fix an assertion in GtkFontChooserWidget when setting a filter. 2023-02-13 12:49:02 +09:00
Kukuh Syafaat
b60bd8a73d Update Indonesian translation 2023-02-13 02:47:33 +00:00
Matthias Clasen
37f12e4bf9 Post-release version bump 2023-02-12 21:04:15 -05:00
Matthias Clasen
8967b2da01 4.9.4 2023-02-12 20:36:13 -05:00
Matthias Clasen
dfb019509d docs: Document new build options 2023-02-12 20:36:13 -05:00
Matthias Clasen
a770b429ec Merge branch 'fix-gst-gl-use' into 'main'
gstreamer: Fix gl context use

Closes #5586

See merge request GNOME/gtk!5508
2023-02-13 00:41:51 +00:00
Matthias Clasen
7430bd7780 gstreamer: Fix gl context use
We were not activating the context in which
we want to wait for the fence. This caused
a stream of critical warnings.

Fixes: #5586
2023-02-12 19:29:04 -05:00
Jacob Mealey
272a40a01a Update TextTag and TextView indent Documentation
Change the documentation for both to be in line with Pango documentation
specifically regarding hanging indentation.
2023-02-12 23:12:51 +00:00
Matthias Clasen
f121f607ae Merge branch 'search_entry_placeholder' into 'main'
gtksearchentry: Add getter/setter for placeholder text

See merge request GNOME/gtk!4312
2023-02-12 22:06:36 +00:00
Christopher Davis
ff45145eac menubutton: Add active property and getter/setter
GtkMenuButton currently does not provide a way to tell
if it's open programmatically. The existing methods,
`popup()` and `popdown()`, do not expose any state
to callers. If someone wanted to know whether or not
a menubutton was open, they needed the popover. Given
that GtkMenuButton can manage the popovers itself,
that's not always an option for app developers.

This commit adds the `active` property and associated
methods, where `gtk_menu_button_set_active ()` replaces
both `gtk_menu_popup ()` and `gtk_menu_popdown ()`.
This addition also mirrors changes in other places,
Such as `GtkWidget:visible` vs `show()`/`hide()`.
2023-02-12 16:47:59 -05:00
Matthias Clasen
83c5f5ff0f Apply 4 suggestion(s) to 2 file(s) 2023-02-13 06:47:06 +09:00
Alexandros Theodotou
87d21dc5c9 gtksearchentry: Add getter/setter for placeholder text 2023-02-13 06:46:31 +09:00
Matthias Clasen
cef7e6b741 Merge branch 'mark-deprecations' into 'main'
docs: Mark various deprecations

See merge request GNOME/gtk!5502
2023-02-12 21:44:00 +00:00
Yuri Chornoivan
84b5e94ffd Update Ukrainian translation 2023-02-12 17:56:09 +00:00
Matthias Clasen
679d510059 Merge branch 'template-child-dispose-order' into 'main'
gtk: Set widget template children to NULL before destroy unref

See merge request GNOME/gtk!4611
2023-02-12 16:36:52 +00:00
Marco Melorio
d2755e0385 inscription: Add single-line-mode property
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5444.
2023-02-12 17:35:56 +01:00
Matthias Clasen
0c2b437643 Merge branch 'main' into 'main'
Add note about widgets implementing the interface adding the `horizontal`/`vertical` CSS classes

See merge request GNOME/gtk!5391
2023-02-12 16:28:12 +00:00
madmurphy
0764cf0c9c Add note about widgets implementing the interface adding the horizontal/vertical CSS classes 2023-02-12 16:28:12 +00:00
Marco Melorio
2504215459 docs: Mark everything in GtkVolumeButton as deprecated 2023-02-12 17:20:11 +01:00
Marco Melorio
d45db3a961 docs: Mark everything in GtkStatusBar as deprecated 2023-02-12 17:20:11 +01:00
Matthias Clasen
557a1ed879 Merge branch 'no-more-lpr' into 'main'
printing: Drop the lpr backend

See merge request GNOME/gtk!5500
2023-02-12 15:29:27 +00:00
Matthias Clasen
c28b6a3ee6 Merge branch 'texture-atlas-crash' into 'main'
gl: Avoid a crash in the texture library

Closes #5175

See merge request GNOME/gtk!5501
2023-02-12 15:28:06 +00:00
Marco Melorio
b34c139028 docs: Mark everything in GtkLockButton as deprecated 2023-02-12 16:12:17 +01:00
Matthias Clasen
dd22e2aea9 printing: Drop the lpr backend
We want to consolidate and get to fewer print
backends (ideally only one), and the future is cpdb.
2023-02-12 10:10:06 -05:00
Marco Melorio
6e6f2f652c docs: Mark everything in GtkCellAreaContext as deprecated 2023-02-12 16:09:39 +01:00
Marco Melorio
3aac70f245 docs: Mark everything in GtkAssistant as deprecated 2023-02-12 16:09:25 +01:00
Matthias Clasen
7f3ea15d80 Update POTFILES.in 2023-02-12 10:09:22 -05:00
Matthias Clasen
d3dfdd214f gl: Avoid a crash in the texture library
entry->texture can be NULL, so check before
using it.

Fixes: #5175
2023-02-12 10:01:11 -05:00
Matthias Clasen
b6c3cf4eee gl: Maintain state when truncating
When we truncate the command queue because it
is too big, we were messing up our state accounting
and running into criticals as a consequence.

This can be reproduced by opening a well-populated
fishbowl demo in the inspectors recorder.

Fixes: #5188
2023-02-12 09:56:32 -05:00
Matthias Clasen
157ef1d395 Deprecate GtkVolumeButton
Too specialized.
2023-02-12 09:48:49 -05:00
Matthias Clasen
d0263f563a NEWS: Updates 2023-02-12 09:21:38 -05:00
Matthias Clasen
83b48bb25f Merge branch 'mask-nodes-rebased' into 'main'
gsk: Introduce mask nodes

See merge request GNOME/gtk!5497
2023-02-12 14:11:47 +00:00
Matthias Clasen
81e9eca256 Merge branch 'nacho/scalebutton-active' into 'main'
gtkscalebutton: add active property

See merge request GNOME/gtk!5492
2023-02-12 14:01:27 +00:00
Ignacio Casal Quinteiro
44c2d585b8 gtkscalebutton: add active property 2023-02-12 14:01:26 +00:00
Matthias Clasen
348803af7d Add a mask node demo 2023-02-12 08:35:25 -05:00
Matthias Clasen
c8bfea7aa1 Add a test for mask nodes 2023-02-12 08:35:25 -05:00
Matthias Clasen
8f47e885f0 Add gtk_snapshot_push_mask 2023-02-12 08:35:25 -05:00
Matthias Clasen
a9f50f1f7a gl: Support mask nodes
Add a shader for masking.
2023-02-12 08:35:25 -05:00
Matthias Clasen
0d58e5365d gsk: Introduce mask nodes
Add GskMaskNode, and support it in the render node
parser, in the inspector and in GtkSnapshot.

The rendering is just fallback for now.

Based on old work by Timm Bäder.
2023-02-12 08:35:25 -05:00
Ekaterine Papava
d00d4c4475 Update Georgian translation 2023-02-12 12:30:05 +00:00
Piotr Drąg
a6e7c38236 Update POTFILES.in 2023-02-12 13:20:48 +01:00
Matthias Clasen
eee7e59265 Merge branch 'fix_editable_label' into 'main'
Remove timeout when disposing GtkEditableLabel

Closes #5584

See merge request GNOME/gtk!5499
2023-02-12 02:55:45 +00:00
Matthias Clasen
c2cb1ffe9e Merge branch 'wip/wl-dispatch-helper' into 'main'
wayland: Add event queue dispatch helper

See merge request GNOME/gtk!5498
2023-02-12 01:01:29 +00:00
Alexandros Theodotou
d918a77d34 Remove timeout when disposing GtkEditableLabel
Fixes: #5584
2023-02-12 09:45:07 +09:00
Matthias Clasen
2285ef3824 Merge branch 'scaled-textures' into 'main'
Scaled textures

See merge request GNOME/gtk!5488
2023-02-11 22:16:43 +00:00
Jonas Ådahl
b2a2bf819d wayland/launch-context: Use dispatch helper
Otherwise we risk a busy loop if e.g. the pipe broke.
2023-02-11 23:14:53 +01:00
Jonas Ådahl
dd9433b50e wayland: Add event queue dispatch helper
Dispatch failing should always fatal; use a helper to centralize the
error handling everywhere.
2023-02-11 23:13:39 +01:00
Matthias Clasen
67c53e46f9 Add gtk_snapshot_append_scaled_texture
This is the snapshot api corresponding to
gsk_texture_scale_node_new.
2023-02-11 15:09:38 -05:00
Matthias Clasen
238e7ec351 Add a test for scaled textures 2023-02-11 15:09:38 -05:00
Matthias Clasen
d916659781 gl: Handle GskTextureScaleNodes 2023-02-11 15:09:38 -05:00
Matthias Clasen
82c02574f1 gl: Make texture slicing more flexible
Allow to specify the filtering to use for the slices,
and allow forcing the number of slices. This will be
used in the next commit.
2023-02-11 15:09:38 -05:00
Matthias Clasen
26e6d2106b gl: Pass filters down from visit_texture_node
For now, we always pass GL_LINEAR.
2023-02-11 15:09:38 -05:00
Matthias Clasen
625ffa2d96 gtk-demo: Add filtering to the zoom demo 2023-02-11 15:09:38 -05:00
Matthias Clasen
dd3eedd510 gtk-demo: Rewrite the zoom demo slightly
Use a texture directly instead of a paintable.
This will be used in the following commit to
introduce filters.
2023-02-11 15:09:38 -05:00
Matthias Clasen
dc3a72cf38 nodeparser: Support texture-scale nodes 2023-02-11 15:09:38 -05:00
Matthias Clasen
b937c19dd4 gsk: Introduce GskTextureScaleNode 2023-02-11 15:09:38 -05:00
Matthias Clasen
04c3af537c Merge branch 'wip/handle-more-wl-dispatch-failures' into 'main'
wayland: Handle dispatch failing in a couple of more places

See merge request GNOME/gtk!5495
2023-02-11 19:56:45 +00:00
Matthias Clasen
cc43f5dcde gsk: Generate mipmaps when requested
If the min_filter requires it, call
glGenerateMipmap for our textures.
2023-02-11 09:29:03 -05:00
Matthias Clasen
c74d7afce5 gsk: Don't limit filters too much
GL does not allow mipmapping for mag filters,
but it doesn't have a problem with it for min
filters.
2023-02-11 09:29:03 -05:00
Matthias Clasen
52e18eb7fb Merge branch 'matthiasc/for-main' into 'main'
gdkevents.c: Fix up folding

See merge request GNOME/gtk!5496
2023-02-11 14:18:42 +00:00
Matthias Clasen
c0b5b4b8c1 gskrendernodeimpl.c: Use folding
Instead of homegrown markup.
2023-02-11 09:00:07 -05:00
Matthias Clasen
d497e721c9 gdkevents.c: Fix up folding
The modeline was lost at some point,
and superfluous spacing inserted.
2023-02-11 08:59:51 -05:00
Jonas Ådahl
a7fb9a6865 wayland: Handle dispatch failing in a couple of more places
Without doing this, we'll end up with risking GTK processes sitting
eating 100% CPU instead of just exit(1):ing.
2023-02-11 11:42:21 +01:00
Marek Kašík
2365d9be18 Merge branch 'cpdb' into 'main'
New CPDB print backend for GTK Print Dialog

See merge request GNOME/gtk!4930
2023-02-10 23:10:20 +00:00
tinytrebuchet
41b60bbd6c New CPDB print backend for GTK Print Dialog
The Common Print Dialog Backends (CPDB) concept has GUI-toolkit-independent
backends for each print technology (CUPS, Print to File, cloud printing
services, ...) and each print dialog (GTK, Qt, Chromium, ...) is supposed
to use this backend, so that changes in print technologies can be centrally
and quickly covered by changing the backends and everything new gets available
in all print dialogs.

This commit provides a GTK print dialog backend to add support for the CPDB
concept. It communicates with all installed CPDB backends and so gives support
for all these print technologies to the GTK print dialog.

To make use of CPDB the GTK print dialog is supposed to be installed with this
backend and the 'Print To File' backend, and not any others to prevent printer
duplication.
2023-02-11 01:13:48 +05:30
Emin Tufan Çetin
f0d3d011ea Update Turkish translation 2023-02-10 05:57:42 +00:00
Cameron White
0cb3555a65 Fix a couple incorrect annotations for optional parameters
The 'optional' annotation should be used in these cases rather than 'nullable'.
NULL can provided to ignore these output parameters, but the function is
not setting the output parameter to NULL.
2023-02-09 22:46:43 -05:00
Matthias Clasen
48e141a42c Merge branch 'avoid-criticals-tracker' into 'main'
searchengine: Avoid criticals when tracker init failed

See merge request GNOME/gtk!5489
2023-02-09 19:43:31 +00:00
Gaël Bonithon
6215b38e64 searchengine: Emit a simple warning when tracker init failed
Failure is allowed by nature of GInitable, and this avoids unnecessary
crashing of programs running with G_DEBUG=fatal-criticals.
2023-02-09 19:46:30 +01:00
Gaël Bonithon
41490f9624 searchengine: Add missing sanity check 2023-02-09 19:25:04 +01:00
Vasil Pupkin
45e6e9a7d1 Update Belarusian translation 2023-02-08 21:48:28 +00:00
Matthias Clasen
9991d6834d Merge branch 'stop-testing-pixbuf-formats' into 'main'
Drop pixbuf format tests

See merge request GNOME/gtk!5486
2023-02-07 18:48:39 +00:00
Matthias Clasen
ddf8c4dd1a Drop pixbuf format tests
We have our own loaders for the formats we
always want to support, so we don't need to
check for what gdk-pixbuf supports.
2023-02-07 07:54:22 -05:00
Matthias Clasen
970072ef65 Merge branch 'file-dialog-fixes' into 'main'
filedialog: Robustness fixes

See merge request GNOME/gtk!5485
2023-02-07 12:42:09 +00:00
Matthias Clasen
f8321029fc filedialog: Robustness fixes
This code was not working well.
2023-02-06 23:16:17 +01:00
Matthias Clasen
f83cab01ec filechooserportal: Fix an oversight 2023-02-06 20:28:35 +01:00
Sabri Ünal
8a74770ec1 Update Turkish translation 2023-02-06 09:19:35 +00:00
Matthias Clasen
39c503c108 Merge branch 'matthiasc/for-main' into 'main'
CONTRIBUTING: Updates

See merge request GNOME/gtk!5483
2023-02-06 06:53:14 +00:00
Matthias Clasen
fc32b8242b CONTRIBUTING: Updates
Mention matrix instead of irc, and ask
for display/graphics as essential info
in issues.
2023-02-06 07:35:11 +01:00
Piotr Drąg
7c2b4eb0e7 Update Polish translation 2023-02-05 15:22:00 +01:00
Matthias Clasen
d8b0aea6b7 Merge branch 'rename-openuri-portal' into 'main'
Use a Gtk prefix for dbus-generated code

Closes #5572

See merge request GNOME/gtk!5482
2023-02-05 08:27:09 +00:00
Matthias Clasen
190d8ef8ff Use a Gtk prefix for dbus-generated code
Copying this file from GIO without renaming it
was not the greatest idea in retrospect.

Fixes: #5572
2023-02-05 09:09:22 +01:00
Cheng-Chia Tseng
15e9194b59 Update Chinese (Taiwan) translation 2023-02-04 16:28:15 +00:00
Matthias Clasen
0257da6cc0 Post-release version bump 2023-02-04 17:01:51 +01:00
Matthias Clasen
907f878c9f make-release: Explicily enable introspection 2023-02-04 16:31:55 +01:00
Matthias Clasen
b2071cdeb5 4.9.3 2023-02-04 16:16:54 +01:00
Matthias Clasen
1a292bf8ab Merge branch 'wip/carlosg/scroll-fix' into 'main'
gdk/x11: Reset all scroll valuators on enter

Closes #4160

See merge request GNOME/gtk!5479
2023-02-04 13:14:02 +00:00
Matthias Clasen
7e07d63a6c Merge branch 'ebassi/stack-at-context' into 'main'
a11y: Clear the GtkATContext in a single step

See merge request GNOME/gtk!5477
2023-02-04 12:37:20 +00:00
Carlos Garnacho
824e983372 gdk/x11: Reset all scroll valuators on enter
We no longer need to make much distinction between multiple logical
devices, plus it breaks esp. with the Xwayland input device distribution.
Just iterate across all devices and reset their scroll valuators.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4160
2023-02-04 13:13:19 +01:00
Matthias Clasen
9e5417c6c7 Merge branch 'wip/carlosg/wayland-device-refactor' into 'main'
Refactor some wayland code

See merge request GNOME/gtk!5473
2023-02-04 07:48:33 +00:00
Matthias Clasen
e94dae8536 Merge branch 'rgba-free-checked' into 'main'
gtktextview: Avoid calling gdk_rgba_free for NULL values

See merge request GNOME/gtk!5474
2023-02-04 07:48:24 +00:00
Matthias Clasen
0dd163254d Merge branch 'ebassi/accessible-editable' into 'main'
a11y: Simplify GtkAccessible implementation for editables

See merge request GNOME/gtk!5475
2023-02-04 07:47:36 +00:00
Emmanuele Bassi
341ecab41a a11y: Clear the GtkATContext in a single step
There's no need to unrealize the GtkATContext inside dispose() and then
drop its reference inside finalize().
2023-02-03 17:11:22 +01:00
Marco Trevisan (Treviño)
9eac7ed8b9 gtktextview: Avoid calling gdk_rgba_free for NULL values
Related to glib#2908
2023-02-03 16:41:56 +01:00
Carlos Garnacho
4005eb8fe8 gdk/wayland: Rename gdkkeys-wayland.c file
Since it contains the GdkKeymap implementation, give it a more
obvious name.
2023-02-03 16:15:34 +01:00
Carlos Garnacho
1d4ceac2c5 gdk/wayland: "Split" GdkWaylandDevice implementation out
This is a bit spaghetti right now, since seats and devices were
heavily entangled there are a number of crossed private API calls that
should ideally not be there.

Let this be a first step, so more bits may move from the seat
implementation to devices.
2023-02-03 16:15:34 +01:00
Carlos Garnacho
a5246a6856 gdk/wayland: Split GdkDevicePad wayland implementation
This now lives in its own C file.
2023-02-03 16:08:07 +01:00
Lukáš Tyrychtr
11d235d165 a11y: Simplify GtkAccessible implementation for editables
This commit implements the idea brought up in #5032, and provides a
simple function for GtkEditable implementations using a delegate object.
The accessible state is proxied from the outher GtkEditable to the
delegate.
2023-02-03 16:08:06 +01:00
Carlos Garnacho
af00beb772 gdk/wayland: Move struct declarations to header
These will be used from outside the main file, after we are
done splitting it.
2023-02-03 16:00:01 +01:00
Carlos Garnacho
e5cd9354d5 gdk/wayland: Move GdkWaylandDevice data to private struct
Before splitting this object, avoid leaking details in its struct.
2023-02-03 15:58:11 +01:00
Carlos Garnacho
6426ab7466 gdk/wayland: Rename gdkdevice-wayland.c to gdkseat-wayland.c
This file, event though a clump of input-y objects, has more of
seats than anything else. Rename it so that we can start splitting
these objects out of it.
2023-02-03 15:58:11 +01:00
Matthias Clasen
b710df6f45 Merge branch 'file-chooser-context-menu' into 'main'
filechooser: Fix context menus

Closes #5554

See merge request GNOME/gtk!5472
2023-02-03 13:39:21 +00:00
Matthias Clasen
50998b0ee9 Merge branch 'drag-icon-robustness' into 'main'
dragicon: Handle files without info

See merge request GNOME/gtk!5460
2023-02-03 13:19:26 +00:00
Matthias Clasen
92c2c68c7b filechooser: Fix context menus
We only want to show the file list context menu
when we are over the file list.

Fixes: #5554
2023-02-03 14:17:34 +01:00
Matthias Clasen
c2f5b64b5d Merge branch 'ebassi/public-accessible' into 'main'
Make GtkAccessible public

Closes #4240

See merge request GNOME/gtk!5470
2023-02-03 11:31:06 +00:00
Matthias Clasen
460bf6d8b9 inspector: Show if accessibles aren't realized
This prevents confusion and makes it clear
what is going on.
2023-02-03 11:49:17 +01:00
Emmanuele Bassi
a0dff87c86 a11y: Documentation and code style fixes 2023-02-03 11:49:17 +01:00
Emmanuele Bassi
3015b9f120 a11y: Fix get_bounds() implementation
Don't allocate graphene_rect_t, and fix the size retrieval.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
01549e3c91 Take the widget transform into account when computing the bounds for a11y 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
bc48bfc2b6 a11y: Use a DOM-like API for iterating accessible objects
The `get_child_at_index()` API model comes from AT-SPI, and it's not an
efficient design, especially when coupled with large widgets.

Replace `get_child_at_index()` with `get_first_accessible_child()` and
`get_next_accessible_sibling()`.

That allows efficiently retrieving all the children, simplifies the
implementation of GtkAccessible in GtkWidget and closely resembeles the
GtkWidget API.

Getting the last child and previous sibling for iterating backwards is
not a part of the interface at the moment, but they can be added at a
later date.

Note that this change required tracking the next stack page in
GtkStackPage.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
6100258ba2 a11y: Rename GtkAccessible.get_parent
Avoid a collision when the type implementing the GtkAccessible interface
already has a `get_parent()` method—like GtkWidget.
2023-02-03 11:49:17 +01:00
Emmanuele Bassi
e083bd7920 Apply trivial review suggestions 2023-02-03 11:49:17 +01:00
Emmanuele Bassi
e915546b44 Add versioned symbol annotations 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
b6cfe35940 Style fixes
Documentation and coding style updates.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
4cd9fd9b15 stack: Use a pointer array for children
Reduce our dependency on linked lists; pointer arrays are better at
cache locality.

Additionally, we can avoid quadratic behaviors when finding a child at a
given index.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
6f8cab0e9d Style fix 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
6eb9161906 Improve documentation 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
d13695f586 a11y: Implement new GtkAccessible vfuncs in GtkStack
Implement the virtual a11y children for GtkStack.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
749919c551 Update API docs 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
58980e0b4a Make GtkAccessible public
Out of tree classes need to be able to implement the GtkAccessible
interface, in order to implement custom accessible objects.

Fixes: #4240
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
5813a5cace a11y: Add bounds rectangle to GtkAccessible
Make the bounds calculation part of the accessible interface.

Bounds are used by ATs like Orca to implement features like Flat Review:

https://help.gnome.org/users/orca/stable/howto_flat_review.html.en

Or to determine the area of a non-presentational widget.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
f88b777fe5 widget: Implement new GtkAccessible vfuncs 2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
a80af681b8 a11y: Skip non-presentable objects
Don't get confused with non-presentable objects when iterating the list
of children.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
94695bb276 a11y: Use GtkAccessible for tree traversal
Remove the widget tree dependence from GtkAtSpiContext.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
be36113826 a11y: Implement the new GtkAccessible vfuncs
Implement the gtk_accessible functions and begin removing the old widget
based tree calls.
2023-02-03 11:49:17 +01:00
Lukáš Tyrychtr
5dfbaa53fc a11y: Add DOM-like API to GtkAccessible
Add get_parent and get_child_at_index to GtkAccessible so we can
decouple the a11y tree from the widget tree.
2023-02-03 11:49:17 +01:00
Matthias Clasen
a13ddcb67b Merge branch 'filechooser-sidebar' into 'main'
placessidebar: Make all rows ellipsize

Closes #4710

See merge request GNOME/gtk!5471
2023-02-03 09:41:21 +00:00
Carlos Garnacho
d228bae365 Merge branch 'drag-button-issue' into 'main'
Fix button mask calculation for Wayland

Closes #5561

See merge request GNOME/gtk!5468
2023-02-03 09:28:01 +00:00
Matthias Clasen
463f12a3bb placessidebar: Make all rows ellipsize
Otherwise, we end up with a single long row
pushing the content of all the other rows
off to the left, which is much worse than
ellipsizing.

Fixes: #4710
2023-02-03 10:00:03 +01:00
Matthias Clasen
3f87b130ba NEWS: Updates 2023-02-03 09:26:50 +01:00
Benjamin Otte
c17049c6d1 Merge branch 'wip/otte/gl-is-current' into 'main'
gdk: Add private GLContext::is_current() check

Closes #5392

See merge request GNOME/gtk!5463
2023-02-02 21:56:32 +00:00
Arjan Molenaar
f000baf0d6 wayland: Fix button mask for button 2 and 3
Wayland and GTK order mouse button 2 and 3 differently.

Fixes #5561.
2023-02-02 21:48:58 +01:00
Arjan Molenaar
aef4c50155 Allow all mouse buttons to be used for the drawingarea demo
So we can test if the drag gesture works with all mouse buttons.
2023-02-02 21:29:45 +01:00
Matthias Clasen
2a1e4b8621 Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!5467
2023-02-02 17:36:44 +00:00
Matthias Clasen
cabd18fba0 textbtree: Fix a compiler warning 2023-02-02 17:15:28 +01:00
Matthias Clasen
1da4782262 gsk: Fix a compiler warning 2023-02-02 17:15:28 +01:00
Matthias Clasen
8911ed5d9b Merge branch 'monitor-description' into 'main'
Add GdkMonitor::description

See merge request GNOME/gtk!5466
2023-02-02 14:12:23 +00:00
Matthias Clasen
294b659dc1 Merge branch 'wip/carlosg/deprecations' into 'main'
Some deprecations and cleanups

See merge request GNOME/gtk!5465
2023-02-02 14:11:58 +00:00
Carlos Garnacho
7ad74ad6c3 gdk/wayland: Deprecate GdkDisplay windowing-specific for startup IDs
This is currently just used as a convenience storage of the startup ID
between the GtkApplication and the GtkWindow (after it's ready to notify
on it).

This could be untangled in the GTK layers so there is no involvement
from GDK in keeping the startup ID around, in the mean time just deprecate
these gdk_wayland* API calls.
2023-02-02 12:50:59 +01:00
Carlos Garnacho
bb777507ce gtkmodelbutton: Avoid gtk_gesture_set_sequence_state()
It is not necessary for this widget to know about the specific
sequence that is interacting.
2023-02-02 12:50:59 +01:00
Carlos Garnacho
1e1d79d4f7 gtktextview: Avoid gtk_gesture_set_sequence_state()
Use gtk_gesture_set_state() as this widget does not need specific
knowledge on the sequence being used for interaction.
2023-02-02 12:50:59 +01:00
Carlos Garnacho
a254a4529f gtkscrolledwindow: Clean up input handling a bit
These pieces were added in commit 8d2f81cca4, but are no longer
necessary since there's no capture_button_press special behavior
toggle.

This can be simplified again.
2023-02-02 12:50:59 +01:00
Matthias Clasen
e7bd691532 inspector: Show monitor descriptions 2023-02-02 12:32:28 +01:00
Matthias Clasen
4e62350232 wayland: Set up monitor descriptions
We get this information in the xdg_output protocol.
2023-02-02 12:32:28 +01:00
Matthias Clasen
2c883a70e2 Add GdkMonitor::description
This is the right string to when showing
monitors in the UI.
2023-02-02 12:32:28 +01:00
Matthias Clasen
3dfeb2fd37 monitor: Document connector names better 2023-02-02 12:32:28 +01:00
Carlos Garnacho
3ba3e8286f gtkwindowhandle: Refactor click handling a bit
Do not get a GdkEvent first and foremost, and only do that in the
parts where the GdkEvent is absolutely necessary (i.e. popping up
the WM menu for the window).
2023-02-02 11:21:22 +01:00
Carlos Garnacho
fbf4817ef5 gtkgesture: Deprecate gtk_gesture_set_sequence_state()
We can abstract widgets about the specific ongoing sequences that
are triggering a GtkGesture. This used to be more necessary in
GTK3 world where complex widgets might have required handling
different events in different areas, but in GTK4 world that would
be done with multiple widgets.

This is no longer necessary to carry forward.
2023-02-02 11:21:22 +01:00
Carlos Garnacho
db43e0669f gtkscrolledwindow: Avoid gtk_gesture_set_sequence_state()
This widget does not require special knowledge about the ongoing
event sequences, just make it use gtk_gesture_set_state() generically.
2023-02-02 11:21:22 +01:00
Carlos Garnacho
386c77b13d gtkwindowhandle: Avoid gtk_gesture_set_sequence_state()
It does not require special knowledge about the ongoing event
sequences, and it can instead trust the event controller. Make
it use gtk_gesture_set_state() generically.
2023-02-02 11:21:21 +01:00
Matthias Clasen
e6998dffe8 Merge branch 'small-gltexture-cleanup' into 'main'
gltexture: Small refactoring

See merge request GNOME/gtk!5464
2023-02-02 09:16:09 +00:00
Matthias Clasen
12057c8a30 gltexture: Small refactoring
We do this in two places, so factor out
the dropping of GL resources into a helper.
2023-02-02 10:01:36 +01:00
Matthias Clasen
b7c422cb98 ci: Stop running the asan build every time
It fails because of address sanitizer crashes,
and takes a long time. It is not that useful
in this shape.
2023-02-02 09:07:10 +01:00
Matthias Clasen
1c76f6586b Update po/POTFILES.in
Deprecations affect this file.
2023-02-02 09:05:31 +01:00
Matthias Clasen
d43968f7b6 Fix a deprecation warning 2023-02-02 09:03:26 +01:00
Matthias Clasen
26650787e1 main: Compiler warnin gfixes 2023-02-02 08:44:53 +01:00
Matthias Clasen
b4ef072188 icontheme: Compiler warning fixes 2023-02-02 08:44:28 +01:00
Matthias Clasen
3858c5282c Deprecate GtkAssistant
It is a dialog-like toplevel, and libadwaita has
replacement parts (like AdwCarousel).
2023-02-02 08:39:25 +01:00
Matthias Clasen
1ff8dad8ec Deprecate GtkLockButton
This is a very specialized widget, and should really just
live with the applications where it is used.
2023-02-02 08:39:25 +01:00
Matthias Clasen
d8cb11ec4a Deprecate GtkStatusbar
The design patterns using statusbar are no longer popular,
and it is pretty easy to make a statusbar yourself with boxes
and labels, if you need one. The only thing special about
GtkStatusbar was its window resize handle, but that has
been gone for a long time.
2023-02-02 08:39:24 +01:00
Matthias Clasen
8796950651 Deprecate more startup-notification API 2023-02-02 08:30:32 +01:00
Benjamin Otte
c6cef6db52 gdk: Add private GLContext::is_current() check
... and use this check in gdk_gl_context_make_current() and
gdk_gl_context_get_current() to make sure the context really is still
current.

The context no longer being current can happen when external GL
implementations make their own contexts current in the same threads GDK
contexts are used in.
And that can happen for example by WebKit.

Theoretically, this should also allow external EGL code to run in X11
applications when GDK chooses to use GLX, but I didn't try it.

Fixes #5392
2023-02-02 04:23:51 +01:00
Benjamin Otte
fdea27c04d win32: Remove unused variable 2023-02-02 04:23:51 +01:00
Fran Dieguez
a52f9d6def Update Galician translation 2023-02-01 19:12:29 +00:00
Benjamin Otte
ee272646c9 Merge branch 'fix-gltexture-confusion' into 'main'
gltexture: Use the right context

See merge request GNOME/gtk!5461
2023-02-01 18:47:28 +00:00
Matthias Clasen
6655177a0b Cosmetics 2023-02-01 18:38:22 +01:00
Daniel Mustieles
cb78f0d10a Update Spanish translation 2023-02-01 15:28:00 +00:00
Matthias Clasen
1cb621633c gltexture: Use the right context
When checking characteristics of the context
for downloading, we were using self->context,
even though we are using a possibly different
context for downloading.

Pass the right context along and use it.
2023-02-01 11:32:07 +01:00
Kukuh Syafaat
ce25efeee7 Update Indonesian translation 2023-02-01 03:14:46 +00:00
Matthias Clasen
375b554924 Merge branch 'fix-gst-sync' into 'main'
gst: Fix synchronization

See merge request GNOME/gtk!5459
2023-01-31 12:28:27 +00:00
Matthias Clasen
69eed999bb gst: Rename a field for clarity
gst_gdk_context is clearer than gst_app_context. Maybe
2023-01-30 15:01:31 -05:00
Matthias Clasen
cab5f2bd8d Merge branch 'file-chooser-dnd-crash' into 'main'
filechooserwidget: Fix file chooser crash when dropping empty file list

See merge request GNOME/gtk!5456
2023-01-30 19:28:24 +00:00
Fina Wilke
35e3c22832 filechooserwidget: Fix file chooser crash when dropping empty file list 2023-01-30 19:28:24 +00:00
Matthias Clasen
92612c2265 filetransfer: Be more careful around files
File may not have paths, and we should handle
that without incident. While we are at it, add
some logging so GDK_DEBUG=dnd gives us enough
output to see what is going on.
2023-01-30 14:03:13 -05:00
Matthias Clasen
4e1b46a7ec dragicon: Handle files without info
g_file_query_info can (and does) fail,
occasionally. Handle it.
2023-01-30 14:03:13 -05:00
Matthias Clasen
55f7f7d0ee gst: Fix synchronization
It does not make sense to sync and wait in the
same context, that is just a no-op. The intention
of this code clearly was to sync in the gst
context, and wait in the gdk one.

That also matches what the gtk sink implementation
in gstreamer does.
2023-01-30 12:04:49 -05:00
Matthias Clasen
442cd4a369 Merge branch 'password-entry-unrealize' into 'main'
passwordentry: Fix an asymmetry

Closes #5285

See merge request GNOME/gtk!5457
2023-01-30 12:29:33 +00:00
Matthias Clasen
53af41e2fa passwordentry: Fix an asymmetry
When connecting a signal in realize,
we should disconnect in unrealize.

Fixes: #5285
2023-01-29 22:39:28 -05:00
Matthias Clasen
c43e1f3d0a gsk: Quiet a compiler warning 2023-01-28 21:13:10 -05:00
Jürgen Benvenuti
32e855ad61 Update German translation 2023-01-28 19:59:19 +00:00
Benjamin Otte
034a8a5501 Merge branch 'tooltip-size-simplification' into 'main'
tooltip: Don't play games with max-width-chars

Closes #4470 and #5521

See merge request GNOME/gtk!5455
2023-01-28 18:26:00 +00:00
Matthias Clasen
1e9dbf2df0 tooltip: Prevent too-wide tooltip windows
Set the label to expand, so it actually fills
the width that we allocated for it, instead
of shrinking back to the minimum width for
its height.

Fixes: #5521
2023-01-28 13:07:26 -05:00
Matthias Clasen
dce21f06dd tooltip: Don't play games with max-width-chars
Setting max-width-chars to the number of characters
in the string works ok only as long as the average
char width we get from Pango matches reality. Sadly
that seems not always the case, and this code was
causing short Chinese tooltips to always be broken
into two lines.

Fixes: #4470
2023-01-28 13:06:30 -05:00
Piotr Drąg
56c1c4152f Update POTFILES.in 2023-01-28 14:05:01 +01:00
Matthias Clasen
a9d2fa296e Merge branch 'position-as-double' into 'main'
Boyscouting: fix position type in `gtk_drag_source_drag_begin()`

See merge request GNOME/gtk!5437
2023-01-28 03:24:19 +00:00
Carlos Garnacho
5bccb106c2 Merge branch 'work/zzag/activation-token-dbus' into 'main'
wayland: Fix handling of activation-token in org.freedesktop.Application requests

See merge request GNOME/gtk!5151
2023-01-28 00:44:25 +00:00
Yuri Chornoivan
45086487f1 Update Ukrainian translation 2023-01-27 19:23:39 +00:00
Vlad Zahorodnii
65f03121a4 wayland: Fix handling of activation-token in org.freedesktop.Application requests
At the moment, GTK applications search for "desktop-startup-id" in the
platform data on Wayland , but desktop environments such as plasma set
"activation-token" property instead as indicated in the spec:

    activation-token: This should be a string of the same value as would
    be stored in the XDG_ACTIVATION_TOKEN environment variable, as specified
    by the XDG Activation protocol for Wayland.

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus
2023-01-27 19:20:53 +00:00
Carlos Garnacho
09769193d7 Merge branch 'wip/carlosg/broadway-fix' into 'main'
gdk/broadway: Add deprecation guards around gdk_display_put_event()

See merge request GNOME/gtk!5450
2023-01-27 19:20:28 +00:00
Carlos Garnacho
7f8acf960b gdk/broadway: Add deprecation guards around gdk_display_put_event()
This went missing.
2023-01-27 19:59:36 +01:00
Matthias Clasen
ee0e026237 Merge branch 'fix_5551' into 'main'
object_tree.c: One gtk_list_item_get_child call is redundant

Closes #5551

See merge request GNOME/gtk!5449
2023-01-27 16:22:17 +00:00
Matthias Clasen
6bfd581a72 Merge branch 'wip/sophie-h/scrolled-window-propagate-event' into 'main'
scrolledWindow: Propagate event for no scrolling

See merge request GNOME/gtk!5447
2023-01-27 14:54:33 +00:00
Lukáš Tyrychtr
7b6f254e64 object_tree.c: One gtk_list_item_get_child call is redundant
Fixes #5551
2023-01-27 15:43:33 +01:00
Hugo Carvalho
47955cfe62 Update Portuguese translation 2023-01-27 14:26:32 +00:00
Sophie Herold
e62ca17f88 scrolledWindow: Propagate event for no scrolling 2023-01-26 20:12:10 +01:00
Matthias Clasen
c24ba58acb Merge branch 'broadway-modal-hint' into 'main'
[GTK4] gdk/broadway: Implements modal hint for Broadway surface

See merge request GNOME/gtk!4428
2023-01-26 02:44:54 +00:00
Matthias Clasen
30987168fb Merge branch 'fix_5543' into 'main'
GtkCssProvider: fix element type in docs

Closes #5543

See merge request GNOME/gtk!5441
2023-01-25 13:08:07 +00:00
Lukáš Tyrychtr
93a875bf20 Actually, the annotation is not needed in this case 2023-01-25 11:46:53 +01:00
Yosef Or Boczko
aac3bf581a Update Hebrew translation 2023-01-25 08:15:09 +00:00
Matthias Clasen
869f07521c Merge branch 'macos-fix-popups' into 'main'
macos: Fix popup event handling

Closes #5528

See merge request GNOME/gtk!5436
2023-01-24 16:37:23 +00:00
Matthias Clasen
7e392a1186 Merge branch 'wip/abono/gtk-switch-state-off' into 'main'
gtkswitch: Allow to set state FALSE while keeping active TRUE

See merge request GNOME/gtk!5442
2023-01-24 16:08:57 +00:00
Alessandro Bono
53d87e42a5 gtkswitch: Decouple set_state with set_active.
Allow the user to set a state that doesn't reflect the active property.
2023-01-24 14:55:16 +01:00
Arjan Molenaar
6757a1b409 macos: Propagate events for child surfaces
Before, popup windows did not respond to mouse clicks.
This change fixes that.

Fixes #5528.
2023-01-24 09:07:33 +01:00
Maxim Zakharov
115738dd2f remove unused variable 2023-01-24 11:41:27 +11:00
Matthias Clasen
5caa66ffb7 Merge branch 'macos-native-dnd' into 'main'
macos: DnD Drag support

Closes #3423

See merge request GNOME/gtk!5416
2023-01-23 22:01:30 +00:00
Emmanuele Bassi
7df73c4fd2 Use wording from a suggestion 2023-01-23 11:50:28 +00:00
Lukáš Tyrychtr
1ea5a08c8f GtkCssProvider: fix element type in docs
The method takes an array of char, which actually is UTF-8, so make the docs say so.
Fixes #5543
2023-01-23 12:12:00 +01:00
Matthias Clasen
9c669cbe90 Merge branch 'matthiasc/for-main' into 'main'
iconhelper: Handle GtkSymbolicPaintable

See merge request GNOME/gtk!5440
2023-01-22 18:36:11 +00:00
Matthias Clasen
1a5184bc85 iconhelper: Handle GtkSymbolicPaintable
If we are given a GtkSymbolicPaintable,
treat it as symbolic.
2023-01-22 13:18:18 -05:00
Jordi Mas
8f2ad8f154 Update Catalan translation 2023-01-21 16:58:51 +01:00
Arjan Molenaar
d6ef39b9a2 macos: remove dead code 2023-01-21 15:22:13 +01:00
Arjan Molenaar
52f6acd398 macos: Send dragging events directly to the display
Instead of adding events to the application event queue, dispatch
them directly to the right display. We know this when the event is
to be dispatched.

This is the same as used for the `sendEvent` method in `GdkMacosWindow`.

To achieve this I factored out the generic NSEvent to GdkEvent translation.
We can send an event directly, when we receive it in the GdkMacosWindow
directly from the OS.
2023-01-21 14:54:12 +01:00
Ekaterine Papava
2f894bb4ef Update Georgian translation 2023-01-20 16:04:31 +00:00
Matthias Clasen
2509fe0d17 Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!5434
2023-01-17 21:37:39 +00:00
Matthias Clasen
83a5611ce8 settings: Modernize the code
Drop some things that are no longer relevant,
and make this code look like modern GObject code.
2023-01-17 15:19:50 -05:00
Arjan Molenaar
136c1ccd2c macos: Update event source doc
Update the documentation with the interaction pattern we
need to support DnD.
2023-01-17 16:37:21 +01:00
Arjan Molenaar
16e23b3f9e macos: align functions in gdkmacosdrag-private.h 2023-01-17 16:12:57 +01:00
Matthias Clasen
af088d5e11 settings: Drop object_list
This code came from a time when we were installing
additional settings at runtime. We no longer do that,
so this code is unnecessary.
2023-01-17 08:30:37 -05:00
Matthias Clasen
a6e1c5c96a modules: Cosmetics
Use g_strv_length, instead of open-coding it.
2023-01-17 07:47:28 -05:00
Matthias Clasen
3c8c54ed15 stylecascade: Avoid some allocations 2023-01-17 07:39:51 -05:00
Arjan Molenaar
628aeda7ee macos: Provide the right drag action
We should use the drag action/operation provided by the
drag handlers, not rely on our internal bookkeeping.
2023-01-16 23:21:35 +01:00
Arjan Molenaar
2669dc269b macos: Default kCFRunLoopAllActivities
It's actually a mask, but we'll keep it in to
avoid compiler warnings.
2023-01-16 20:28:38 +01:00
Matthias Clasen
c4d3d72c57 Merge branch 'fix-hidpi-pictures' into 'main'
picture: Fix hi-dpi image handling

See merge request GNOME/gtk!5430
2023-01-16 14:32:01 +00:00
Matthias Clasen
cd79159420 picture: Fix hi-dpi image handling
The idea behind this code was to let scalable
images (i.e. mainly SVGs) provide twice as much
detail when the scale is 2. But we were also
using a scaler for pngs, causing them to be too
small on a hidpi screen. Fix that.

Note that there are cases where you want scaling
for pngs (when you display them scaled down, so
the image has 'hidden' detail). But we are not
attempting to handle that situation automatically.
2023-01-16 08:48:37 -05:00
Arjan Molenaar
1bc63eeadb macos: Queue events during drag
By passing the events during a (midal-ish) drag operation to the main loop,
we're able to keep up with what's happening. This allows the internal
drag state (GtkDragSource) to be updated and be done when the drag is
done.
2023-01-16 14:47:49 +01:00
Emin Tufan Çetin
071c6c60c0 Update Turkish translation 2023-01-15 22:47:27 +00:00
Matthias Clasen
fc24f401b7 Merge branch 'matthiasc/for-main' into 'main'
Use GtkUriLauncher where appropriate

See merge request GNOME/gtk!5432
2023-01-15 18:48:22 +00:00
Matthias Clasen
6c96e51b07 Use GtkUriLauncher where appropriate
GtkLabel, GtkLinkButton and GtkAboutDialog
all have a uri, not a file, so it makes more
sense to use a GtkUriLauncher.
2023-01-15 13:26:53 -05:00
Matthias Clasen
e703163bc4 Merge branch 'uri-launcher-demo' into 'main'
urilauncher: Fix finish function mismatch

See merge request GNOME/gtk!5431
2023-01-15 17:47:18 +00:00
Matthias Clasen
ad549cbded gtk-demo: Add a uri launcher demo 2023-01-15 11:58:43 -05:00
Matthias Clasen
673beef210 urilauncher: Fix finish function mismatch
We need to call the finish function that
matches the async function.
2023-01-15 11:58:09 -05:00
Matthias Clasen
55baa1f2e1 Merge branch 'docs-escape-xml-tag' into 'main'
Escape GtkBuilder XML tag in comment with backtick

Closes #5312

See merge request GNOME/gtk!5429
2023-01-15 15:12:28 +00:00
Arjan Molenaar
1d8a23e97b macos: Provide fallback pasteboard for gtype Dnd
The Drag data should pass through the macos pasteboard system.
We need to provide some pasteboard type. Let's make it a "URL",
which is a pretty generic type anyway.
2023-01-15 10:03:47 +01:00
Arjan Molenaar
422b4b6561 macos: No need to drag handle events
This is handled by the DraggingSource object.
2023-01-15 10:03:47 +01:00
Arjan Molenaar
27ee8b23fd macos: No need to grab a seat
The macOS DnD logic will take over anyway.
2023-01-15 10:03:47 +01:00
Arjan Molenaar
b9847795a7 macos: Support dragging from GdkMacosWindow
The handling is done similar to drag targets.
Note that dragging is a modal action on macos: no events
are sent to the main window. This could cause trouble when
we finish the drag, and not finish the gesture in GTK.
2023-01-15 10:01:56 +01:00
sunce
b13f05537b Escape GtkBuilder XML tag in comment with backtick
Escape XML tags in gi-docgen oriented comment e.g. from <child> to
`<child>`, so that they don't become HTML tag on the final webpage.
This fix includes everything from commit ff46ea64 and #5312.

Fixes #5312
2023-01-15 16:55:18 +08:00
Arjan Molenaar
757d1916ae Fix dx, dy position in gtk_drag_source_drag_begin
Coordinates are double. This change avoid an unneeded cast.
2023-01-15 09:52:43 +01:00
Matthias Clasen
0834dac6ee Merge branch 'matthiasc/for-main' into 'main'
widgetfactory: Load textures in threads

See merge request GNOME/gtk!5428
2023-01-15 04:12:47 +00:00
Matthias Clasen
3c31f72219 texture: Update docs
Document that we support TIFF as well.
2023-01-14 22:48:57 -05:00
Matthias Clasen
a0f63160d6 widgetfactory: Load textures in threads
It is useful to show how this is done, even
though the images here are not terribly large.
2023-01-14 22:38:20 -05:00
Matthias Clasen
c99d85954a Merge branch 'nielsdg/gtkwidgetactionactivatefunc-nullable-variant' into 'main'
Add missing nullable to GtkWidgetActionActivateFunc

See merge request GNOME/gtk!5424
2023-01-15 00:46:11 +00:00
Matthias Clasen
33f31d06f9 Merge branch 'uri-launcher' into 'main'
filelauncher: Plug a memory leak

See merge request GNOME/gtk!5425
2023-01-14 22:59:01 +00:00
Matthias Clasen
bf4b40f17e docs: Update deprecations for gtk_show_uri
We have a better replacement now.
2023-01-14 17:39:28 -05:00
Matthias Clasen
7aba9e3295 urilauncher: Add cross-references to the docs 2023-01-14 17:39:28 -05:00
Matthias Clasen
3080cb7acd Add GtkUriLauncher 2023-01-14 17:39:28 -05:00
Matthias Clasen
4b404f0dea Add g_openuri_portal_open_uri_async
This avoids a roundtrip through GFile and
thus works with random uri schemes.
2023-01-14 14:32:51 -05:00
Matthias Clasen
0c1c0524c7 openuri: Some reshuffling
This is in preparation of adding a method
that takes a uri instead of a GFile.
2023-01-14 14:32:51 -05:00
Matthias Clasen
b58ef290dc filelauncher: Plug a memory leak
Oops
2023-01-14 14:32:51 -05:00
Niels De Graef
1387fba7f8 Add missing nullable to GtkWidgetActionActivateFunc
The `GVariant` that is passed on to the `GtkWidgetActionActivateFunc`
can be `NULL` in case the parameter type is also `NULL`, so mark it
nullable.
2023-01-14 15:30:15 +01:00
Matthias Clasen
34b9ec5be2 Merge branch 'matthiasc/for-main' into 'main'
Fix a compiler warning

See merge request GNOME/gtk!5423
2023-01-14 05:30:10 +00:00
Matthias Clasen
cefdfbd894 icontheme: Streamline the suffix handling code 2023-01-14 00:14:43 -05:00
Matthias Clasen
3676ddbdff icontheme: Avoid some allocations
When loading icon themes, we can reuse memory
instead of allocating and freeing in a loop.
2023-01-14 00:14:43 -05:00
Matthias Clasen
7c1a0e0c15 icontheme: Keep a single string set
Instead of keeping a GtkStringSet per IconTheme,
just make one for the whole GtkIconTheme.

This avoids loops of the themes in some places, and
due to the overlap in icon names between the themes,
it reduces the amount of memory we use for the icon
names with Adwaita+hicolor from 5+4 chunks to 6 chunks.
2023-01-14 00:14:43 -05:00
Matthias Clasen
19bb043a85 testsuite: Fix various compiler warnings
These are mostly dead stores that clang
isn't happy with.
2023-01-14 00:14:43 -05:00
Matthias Clasen
fecc80b59c Fix a compiler warning
Clang things that timings can be NULL here,
and I think it might be right.
2023-01-14 00:14:41 -05:00
Matthias Clasen
1648dc36f8 Merge branch 'wip/corey/fix-docs' into 'main'
docs: Fix dependency names

See merge request GNOME/gtk!5422
2023-01-14 04:23:34 +00:00
Matthias Clasen
a27a2cbf40 Merge branch 'matthiasc/for-main' into 'main'
Silence a compiler warning

See merge request GNOME/gtk!5421
2023-01-14 00:18:50 +00:00
Corey Berla
e418656a04 docs: Fix dependency names
When gi-docgen added the "related" key, it also began checking
that the dependencies were actually dependencies otherwise they aren't
listed as dependencies.  The capitalization needs to match the
namespace.
2023-01-13 14:24:33 -08:00
Matthias Clasen
d4ec1afe44 Merge branch 'fix-spinner-stop' into 'main'
gtkcssanimatedstyle: Fix return of new_advance()

Closes #4426

See merge request GNOME/gtk!5420
2023-01-13 20:14:25 +00:00
Arjan Molenaar
420be8fb0f macos: run glib idle functions when in nested run loop
It looks like DnD starts a nested run loop. We still have to run our
GLib handlers, so animations work.
2023-01-13 20:03:55 +01:00
Christian Hergert
9c3629653f macos: abstract pasteboard for use in clipboard and drag
This will allow us to share a single NSPasteboardItem and data provider
implementation for both GdkClipboard and GdkDrag.
2023-01-13 20:03:55 +01:00
Christian Hergert
eb5cf831b1 macos: refactor pasteboard components into separate module
This will make it easier to reuse from drag integration so that we don't
require clipboards for everything.

We will need to subclass the pasteboard provider twice, however, both
for clipboard and dragging.
2023-01-13 20:03:55 +01:00
Matteo Percivaldi
374d97008b gtkcssanimatedstyle: Fix return of new_advance()
This was causing animation and transition to stop randomly and reset
their state to initial state.

This issue has existed since commit
7b68bdb831.

Closes #4426
2023-01-13 18:08:56 +01:00
Matthias Clasen
fecc923c2c Silence compiler warnings
Clang complains that these are dead stores.
They are, indeed.
2023-01-13 12:07:40 -05:00
Matthias Clasen
703ed608c0 Fix a compiler warning
Clang things that load_error might be NULL here.
It may be right.
2023-01-13 12:07:40 -05:00
Matthias Clasen
99f07c7c0a Fix a compiler warning
Clang things that timings can be NULL here,
and I think it might be right.
2023-01-13 12:07:40 -05:00
Matthias Clasen
51b4d70b8f gridview: Add a few assertions
Just to help static analysis out.

self->n_columns can't ever be 0, since
we clamp it between min_columns and
max_columns, with min_columns always
being at least one.
2023-01-13 12:07:40 -05:00
Matthias Clasen
746d12fc43 Silence a compiler warning
Clang was complaining that we never use the
value stored in mime_type. Just don't store it,
we are only interested in the side-effect
(interning the string).
2023-01-13 12:07:40 -05:00
Matthias Clasen
96ce9e10b8 Merge branch 'faster-ci' into 'main'
Add a build-testsuite option

See merge request GNOME/gtk!5419
2023-01-13 12:57:15 +00:00
Matthias Clasen
3090795351 ci: Try to speed up builds a bit
Don't build demos and tests, and only build
the testsuite where we want to run it.
2023-01-13 07:26:41 -05:00
Matthias Clasen
815b54f3df Update the build documentation 2023-01-13 07:15:15 -05:00
Matthias Clasen
9ad27e4371 Add a build-testsuite option
This will let us run the testsuite in ci without
having to build all the manual tests.
2023-01-13 07:14:33 -05:00
Matthias Clasen
a6e1804474 Merge branch 'macos-werror' into 'main'
CI: turn on -Werror for MacOS build

See merge request GNOME/gtk!5418
2023-01-13 03:08:36 +00:00
Benjamin Otte
7ae549e253 CI: turn on -Werror for MacOS build
The build is error-free and we want to keep it that way.

We'd also like to make Timm do real work instead of having to fix clang
warnings all the time and this build is a clang build.
2023-01-12 20:12:37 -05:00
Matthias Clasen
434d8ef0ea Merge branch 'wip/chergert/fix-macos-warnings' into 'main'
Fixes a few compilation warnings on macOS

See merge request GNOME/gtk!5415
2023-01-13 00:10:48 +00:00
Matthias Clasen
31a6d73635 Merge branch 'ebassi/pin-gi' into 'main'
Add gobject-introspection as a subproject

See merge request GNOME/gtk!5414
2023-01-12 23:35:23 +00:00
Christian Hergert
958ecf2855 gdk/macos: fix warning about _coreCursorType 2023-01-12 13:22:47 -08:00
Christian Hergert
fb12ad807a gsk/gl: fix warning when join_sources() is unused 2023-01-12 13:22:25 -08:00
Christian Hergert
965c52d369 gdk: fix warning when !HAVE_EGL 2023-01-12 13:22:02 -08:00
Emmanuele Bassi
474872563f Add gobject-introspection as a subproject
We pin GLib, so we must also pin g-i to the same version, otherwise
we'll get weird mismatches during development.
2023-01-12 17:56:37 +00:00
Matthias Clasen
b92e52bf0e Merge branch 'matthiasc/for-main' into 'main'
css: Avoid some allocations

See merge request GNOME/gtk!5413
2023-01-12 15:20:49 +00:00
Matthias Clasen
d226dc3812 iconcache: Be a bit less wasteful 2023-01-12 00:36:18 -05:00
Matthias Clasen
46e0fde606 css: Avoid more allocations for tokens
Make short string tokens static.
2023-01-12 00:12:09 -05:00
Matthias Clasen
1e7f525e0e css: Avoid some allocations
Avoid duplicating the function name just
for an error message.
2023-01-12 00:12:09 -05:00
Matthias Clasen
d43e0fb9a7 css: Avoid allocation for tokens
All valid dimensions are short, so store
the dimension inside the token.
2023-01-12 00:11:46 -05:00
Matthias Clasen
6fb6f47fc8 css: Avoid some allocations
Reuse the name_buffer for reading strings.
2023-01-12 00:11:11 -05:00
Matthias Clasen
0f7d8e04d8 css: Some inlining 2023-01-12 00:11:10 -05:00
Matthias Clasen
c9fca559dc Cosmetics 2023-01-12 00:11:10 -05:00
Matthias Clasen
b9d1b5d6a3 icontheme: Bit a bit less wasteful 2023-01-12 00:11:10 -05:00
Emin Tufan Çetin
5f75ba46a5 Update Turkish translation 2023-01-11 07:01:44 +00:00
Emin Tufan Çetin
2507301983 Update Turkish translation 2023-01-11 05:41:40 +00:00
Matthias Clasen
41aeff331d texthistory: Avoid g_autofree
msvc does not like it, unfortunately.
2023-01-10 22:20:57 -05:00
Matthias Clasen
3aab48ec16 Merge branch 'wip/chergert/fix-5506' into 'main'
istring: fix istring_prepend() on malloc transition

Closes #5506

See merge request GNOME/gtk!5411
2023-01-11 02:39:32 +00:00
Christian Hergert
ad0348b85e texthistory: add debugging helpers to print undo stack
This is helpful to have when tracking down issues like #5506.
2023-01-10 13:36:16 -08:00
Christian Hergert
6a134551b9 istring: fix istring_prepend() on malloc transition
When transitioning from internal to malloc, the strings were placed in
the wrong order to g_strconcat(). This fixes an issue with undo where
if you hit the boundary in just the right way, your undo stack will do
unexpected things.

Fixes #5506
2023-01-10 13:32:38 -08:00
Matthias Clasen
0e1ae6ad11 Merge branch 'matthiasc/for-main' into 'main'
Add some more text undo tests

See merge request GNOME/gtk!5410
2023-01-10 19:05:13 +00:00
Aleksandr Melman
5baf4b4b2e Update Russian translation 2023-01-10 12:57:03 +00:00
Matthias Clasen
63560061e8 Add some more text undo tests
Unsuccessfully trying to reproduce #5506.
2023-01-10 07:34:55 -05:00
Matthias Clasen
be721f5797 Merge branch 'matthiasc/for-main' into 'main'
Deprecate gdk_display_put_event

See merge request GNOME/gtk!5409
2023-01-09 21:15:08 +00:00
Matthias Clasen
0073bb79a7 Deprecate gdk_display_put_event
The documentation already tells you not to
use this function.

Ifdef the remaining users in the X11 backend.
2023-01-09 15:46:25 -05:00
Matthias Clasen
f59b506674 Merge branch 'macos-stable-dnd' into 'main'
macos: Drag and drop should not freeze applications

See merge request GNOME/gtk!5291
2023-01-09 11:52:50 +00:00
Matthias Clasen
88b4404296 Merge branch 'wip/corey/popover-accel' into 'main'
gtkmodelbutton: Ensure that accel label is always aligned to end

Closes #5504

See merge request GNOME/gtk!5407
2023-01-09 10:58:14 +00:00
Corey Berla
e20bc7723a gtkmodelbutton: Ensure that accel label is always aligned to end
When the model button just has a text label and accel text,
the button fills and the accel label is implicitly aigned to end.
When there's also a icon, even though it's not shown (because
icons are only shown if there's no text), the button doesn't fill
and the accel ends up not aligned (assuming one of the other buttons
is longer). Ensure that the accel label is aligned to the end.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5504
2023-01-08 22:32:22 -08:00
Emmanuele Bassi
7edf8841fb Merge branch 'a11y_check_null_path' into 'main'
a11y: Avoid crashing if GtkAtSpiContext::path is NULL

See merge request GNOME/gtk!5405
2023-01-09 00:14:21 +00:00
Emmanuele Bassi
6b5b7eab04 Merge branch 'doc-improvements' into 'main'
Two docs improvements

See merge request GNOME/gtk!5406
2023-01-08 22:16:49 +00:00
Marco Melorio
c775262e9d docs: Improve gtk_window_present description
Move most of the documentation from gtk_window_present_with_time and
also reword it a bit to make it more understandable.
2023-01-08 22:41:19 +01:00
Marco Melorio
553fde9761 docs: Don't mention deprecated API in gtk_widget_set_visible
That statement is true, but since that API is deprecated, it doesn't
need to be there anymore to avoid confusing people.
2023-01-08 21:49:28 +01:00
Barnabás Pőcze
f2593dec4b a11y: Use fallback logic when GApplication has no DBus object path
Use the fallback logic to generate the base path for the GtkAtSpiRoot
if the GApplication has no DBus object path to guarantee that
the base path will not stay NULL.
2023-01-08 19:58:54 +01:00
Barnabás Pőcze
ab5a6ed0f1 a11y: Check if path is NULL when removing from cache
`gtk_at_spi_cache_add_context()` checks if the GtkAtSpiContext's path
is NULL before inserting the context object into the hash table.
Do the same in `gtk_at_spi_cache_remove_context()` to avoid a NULL
pointer dereference in `g_str_hash()` during the hash table lookup
if a context with NULL path is removed. That can happen when the
GtkAtSpiRoot::base_path is NULL, which, in turn, can happen if
`g_application_get_dbus_object_path()` returns NULL.

  ==394047==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fd1966f8b84 bp 0x7fff11e3ded0 sp 0x7fff11e3de58 T0)
  ==394047==The signal is caused by a READ memory access.
  ==394047==Hint: address points to the zero page.
      #0 0x7fd1966f8b84 in g_str_hash (/usr/lib/libglib-2.0.so.0+0x37b84)
      #1 0x7fd1966f9c09 in g_hash_table_contains (/usr/lib/libglib-2.0.so.0+0x38c09)
      #2 0x7fd196062c10 in gtk_at_spi_cache_remove_context ../gtk/a11y/gtkatspicache.c:447
      #3 0x7fd19606e0a9 in gtk_at_spi_root_unregister ../gtk/a11y/gtkatspiroot.c:653
      #4 0x7fd196067f58 in gtk_at_spi_context_unrealize ../gtk/a11y/gtkatspicontext.c:1559
      #5 0x7fd195ced97f in gtk_at_context_unrealize ../gtk/gtkatcontext.c:668
      #6 0x7fd195f5576e in gtk_widget_unroot_at_context ../gtk/gtkwidget.c:2399
      #7 0x7fd195f55bd2 in gtk_widget_unroot ../gtk/gtkwidget.c:2499
      ...
2023-01-08 19:56:49 +01:00
Matthias Clasen
dd3cdc52f5 Fix code style 2023-01-08 14:41:11 +00:00
Matthias Clasen
5a3156a8b7 gdk: Update docs
Update the docs for gdk_display_get_monitor_at_surface.
2023-01-07 21:35:29 -05:00
Matthias Clasen
a4c2f19155 Merge branch 'gdk-display-get-monitor-is-nullable' into 'main'
gdkdisplay: Document get_monitor_at_surface can return NULL

Closes #5075

See merge request GNOME/gtk!4917
2023-01-07 20:39:04 +00:00
Matthias Clasen
be8fb1e9b8 Merge branch 'more-filesystemmodel-cleanups' into 'main'
filesystemmodel: Crop tree model cruft

See merge request GNOME/gtk!5402
2023-01-07 18:42:14 +00:00
Matthias Clasen
52c97dbf67 Merge branch 'win-file-ext' into 'main'
filechoosernativewin32: Set default extension

See merge request GNOME/gtk!5266
2023-01-07 18:14:37 +00:00
robxnano
57ebf26f15 filechoosernativewin32: Set default extension 2023-01-07 18:14:36 +00:00
Matthias Clasen
32247bc50e filesystemmodel: Drop tree model cruft
We no longer need the placeholder item for the
editable, so drop it.
2023-01-07 12:22:25 -05:00
Matthias Clasen
ad940bc892 filesystemmodel: Rename private header 2023-01-07 12:01:15 -05:00
Matthias Clasen
7d34e7e0f7 Merge branch 'filesystemmodel-cleanups' into 'main'
filesystemmodel: Cleanup unused defines

See merge request GNOME/gtk!5401
2023-01-07 14:36:20 +00:00
Georges Basile Stavracas Neto
b2f43076bd gtkfilesystemmodel: Use g_clear_* helpers
Saves some code.
2023-01-07 09:17:37 -05:00
Georges Basile Stavracas Neto
202e889577 filesystemmodel: Use G_DECLARE_FINAL_TYPE()
Clean up boilerplate. It's a private object anyway.
2023-01-07 09:17:37 -05:00
Georges Basile Stavracas Neto
a8690c84ab filesystemmodel: Cosmetics
Adjust code style, and shuffle some functions around. Remove
unhelpful doc comments.
2023-01-07 09:17:15 -05:00
Matthias Clasen
35244f4b59 filesystemmodel: Use g_set_object 2023-01-07 09:12:44 -05:00
Georges Basile Stavracas Neto
503c3ec04d filesystemmodel: Make function private to gtkfilesystemmodel.c
The _gtk_file_system_model_update_file() function is not used outside
GtkFileSystemModel, so no need to expose it in the header.

Shuffle it around in code, and remove it from the header.
2023-01-07 08:44:40 -05:00
Georges Basile Stavracas Neto
4a5a466975 filesystemmodel: Cleanup unused defines
They were made unused with the removal of GtkTreeModel interface
implementation.
2023-01-07 08:44:34 -05:00
Matthias Clasen
e694511da3 Merge branch 'werror-fixes' into 'main'
gtk-launch: Remove compile-time warning

See merge request GNOME/gtk!5400
2023-01-07 13:22:20 +00:00
Matthias Clasen
0a94827b9c Merge branch 'wip/corey/calendar' into 'main'
calendar: Fix marked days

See merge request GNOME/gtk!5399
2023-01-07 13:11:01 +00:00
Corey Berla
735cf301a4 calendar: Set marked days immediately
The marked days are set only as part of gtk_calendar_select_day().
This is insufficient, especially because the day-selected signal
is emitted after the marked days are set in gtk_calendar_select_day().
2023-01-06 20:37:54 -08:00
Corey Berla
e8a29f90d1 calendar: Only apply the marked_day to the current month
The marked day gets applied to the current month, and either the previous
or subsequent month if they are visible within the current month.
This doesn't make any sense and likely was an accidental regression
in a6f9052cf1.  Clarify the docs.
2023-01-06 20:21:35 -08:00
Corey Berla
182cc74834 calendar: Add css style for marked days
As part of a6f9052cf1, marked days lost
their style, essentially making that function worthless.  Previously,
they were simply bolded, but that doesn't give them proper justice.
2023-01-06 20:21:35 -08:00
Matthias Clasen
7801dd8944 Merge branch 'wip/phako/fix-activate-action-annotation' into 'main'
widget: Mark format as nullable in activate_action

See merge request GNOME/gtk!4653
2023-01-07 01:06:00 +00:00
Matthias Clasen
38e090f5c1 Merge branch 'main' into 'main'
Fix a typo

See merge request GNOME/gtk!5170
2023-01-07 00:59:32 +00:00
Benjamin Otte
998c382037 build: Turn off tautological-constant-out-of-range-compare warning
This issues a warning when an enum value is compared to a value that is
out of range for the enum.

We do this a lot, either when using -1 for undefined values or when
comparing array sizes to enum values like so:

  enum {
    ONE,
    TWO,
    THREE
  } some_enum_value;
  const char *names= { "one", "two", "three" };

  g_assert (some_enum_value < G_N_ELEMENTS (names));
2023-01-06 19:46:58 -05:00
Benjamin Otte
ac81e71f78 gtk-launch: Fix unused variable warning on macOS 2023-01-06 19:46:58 -05:00
Benjamin Otte
de271c9a30 ci: Disable -Werror on all subprojects
Would be nice if meson had a nicer way of doing this, but...
2023-01-06 19:46:58 -05:00
Benjamin Otte
bf3cf8bb29 glcontext: Avoid gcc warning on non-egl build 2023-01-06 19:46:58 -05:00
Benjamin Otte
63fa5b7f52 gtk-launch: Remove compile-time warning
This warning causes a -Werror build to fail.
2023-01-06 19:46:58 -05:00
Matthias Clasen
96add330f5 Merge branch 'wayland-surface-split3' into 'main'
Split gdksurface-wayland.c

See merge request GNOME/gtk!5217
2023-01-06 22:35:34 +00:00
Matthias Clasen
44aa6a891a Drop gdkpopup-wayland-private.h
It is empty now.
2023-01-06 17:02:03 -05:00
Matthias Clasen
7a30a21405 waylandsurface: Introduce a few vfuncs 2023-01-06 17:00:45 -05:00
Matthias Clasen
2b3eadcfa4 waylandpopup: Drop unused exports 2023-01-06 16:50:20 -05:00
Matthias Clasen
352443d5a5 waylandtoplevel: Drop unused exports 2023-01-06 16:50:20 -05:00
Matthias Clasen
3574fde770 More cleanups 2023-01-06 16:50:20 -05:00
Matthias Clasen
793689789c Misc cleanups
Detangle compute_size, among other things.
2023-01-06 16:50:19 -05:00
Matthias Clasen
120396fa40 wip: Split off GdkWaylandPopup
Like the GdkWaylandToplevel split-off, this needs some
more cleanup.
2023-01-06 16:50:19 -05:00
Matthias Clasen
d61ec38974 wip: Split off GdkWaylandToplevel
This still needs some more cleanup.
2023-01-06 16:50:19 -05:00
Matthias Clasen
2a463baed0 wayland: Rearrange the surface code 2023-01-06 16:50:19 -05:00
Matthias Clasen
348acde6bd wayland: Split public headers
Split gdkwaylandsurface.h into itself,
gdkwaylandtoplevel.h and gdkwaylandpopup.h.
This is in preparation for splitting the
types for real.
2023-01-06 13:47:34 -05:00
Matthias Clasen
5ba793842b wayland: Split display_server sub-structs
Move these to GdkWaylandToplevel and GdkWaylandPopup
as appropriate.
2023-01-06 13:47:34 -05:00
Matthias Clasen
149b608bfc wayland: Move next_layout into popup and toplevel
This is where it belongs.
2023-01-06 13:47:34 -05:00
Matthias Clasen
3348ea81f2 wayland: Move pending toplevel state to GdkWaylandToplevel
Another toplevel-only thing.
2023-01-06 13:47:34 -05:00
Matthias Clasen
63e69131bd wayland: Move input_grab_seat to GdkWaylandPopup
This is popup-only functionality.
2023-01-06 13:47:34 -05:00
Matthias Clasen
d42a34b0b3 wayland: Move reposition_token to GdkWaylandPopup
This is only used for popups, so move it there.
2023-01-06 13:47:34 -05:00
Matthias Clasen
5ee10fc669 wayland: Move shortcuts_inhibitors to GdkWaylandToplevel
Another toplevel-only feature.
2023-01-06 13:47:22 -05:00
Matthias Clasen
b0a4917ce4 wayland: Move imported_transient_for to GdkWaylandToplevel
Another toplevel-only thing.
2023-01-06 13:47:22 -05:00
Matthias Clasen
47e22d6301 wayland: Move geometry hints to GdkWaylandToplevel
Another toplevel-only thing.
2023-01-06 13:47:12 -05:00
Matthias Clasen
b970b60503 wayland: Move title to GdkWaylandToplevel
This is a toplevel property.
2023-01-06 13:47:06 -05:00
Matthias Clasen
7406f8165d wayland: Move drag surfaces to their own file 2023-01-06 13:46:58 -05:00
Matthias Clasen
9435e689c3 wayland: Drop create_dnd_surface
It is only used in one place.
2023-01-06 13:46:58 -05:00
Matthias Clasen
66c947b86b Merge branch 'swap-3-4' into 'main'
docs: Place example-{3,4} in numerical order

See merge request GNOME/gtk!5319
2023-01-06 18:06:55 +00:00
Matthias Clasen
ad1af87834 Merge branch 'gtk4-fix-xdg-activation-set-surface' into 'main'
gdk/wayland: set requesting surface to xdg-activation

See merge request GNOME/gtk!5293
2023-01-06 14:03:01 +00:00
Matthias Clasen
68700f8722 Merge branch 'drop-file-dialog-shortcuts' into 'main'
filedialog: Drop shortcut folders

See merge request GNOME/gtk!5396
2023-01-06 13:35:14 +00:00
Matthias Clasen
f76270167c Merge branch 'wip/otte/for-5496' into 'main'
filedialog: Never set the chooser's file

Closes #5496

See merge request GNOME/gtk!5393
2023-01-06 13:34:55 +00:00
Matthias Clasen
2a442c4fbb Merge branch 'macos-command-symbol' into 'main'
macos: Use Command key symbol in Keyboard shortcuts window

See merge request GNOME/gtk!5296
2023-01-06 13:17:36 +00:00
Matthias Clasen
9356dfc404 filedialog: Drop shortcut folders
The filechooser portal does not support this,
and we are defaulting to using the portal now.
Lets not offer a non-functional API.
2023-01-06 07:40:57 -05:00
Matthias Clasen
7eb8439047 Merge branch 'matthiasc/for-main' into 'main'
testfiledialog: Be more lenient

See merge request GNOME/gtk!5395
2023-01-06 12:34:10 +00:00
Matthias Clasen
0ccf9ad8fc testfiledialog: Be more lenient
Accept both open_multiple and open-multiple.
2023-01-06 07:12:36 -05:00
Arjan Molenaar
c52978dfa4 macos: Command should not come from gettext
Instead, just provide the right character.

See also
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkaccelgroup.c#L916.
2023-01-06 12:08:55 +01:00
Matthias Clasen
52dfa54301 Merge branch 'test-file-dialog' into 'main'
Test file dialog

See merge request GNOME/gtk!5394
2023-01-06 04:28:28 +00:00
Matthias Clasen
b6f9e00a9e Add a test for GtkFileDialog 2023-01-05 23:13:58 -05:00
Matthias Clasen
8780aa02d7 filedialog: Cosmetics 2023-01-05 23:06:31 -05:00
Benjamin Otte
8d5a39d765 Merge branch 'wip/corey/dnd-use-cursor' into 'main'
Fix accidental DnD

See merge request GNOME/gtk!5275
2023-01-05 22:39:26 +00:00
Benjamin Otte
446e6a8d62 filedialog: Never set the chooser's file
Instead, get by with setting the name and hope the filechooser figures
things out by itself.

Fixes #5496
2023-01-05 21:30:15 +01:00
Matthias Clasen
9b1bee99b8 Merge branch 'openuri-activation-token' into 'main'
Pass an activation token to OpenURI

See merge request GNOME/gtk!5389
2023-01-05 14:06:14 +00:00
Matthias Clasen
77cf0f1719 Merge branch 'filechooser-multi-folder' into 'main'
filechooser: Don't assert for possible cases

Closes #5494

See merge request GNOME/gtk!5392
2023-01-05 14:01:35 +00:00
Matthias Clasen
fc1f1366b4 filechooser: Don't assert for possible cases
switch_to_selected_folder can be called when the
selection contains more than one item. Handle it
like it used to be handled: switch to the first
folder we find.

Fixes: #5494
2023-01-05 08:41:33 -05:00
Matthias Clasen
6efd1a9dad Pass an activation token to OpenURI
The OpenURI portal can take an activation_token
nowadays. So it give one.
2023-01-04 16:39:24 -05:00
Matthias Clasen
8349ae2bc4 x11: Make a call NULL-safe
Make it safe to call gdk_x11_app_launch_context_get_startup_notify_id
with a NULL info.
2023-01-04 16:37:31 -05:00
Matthias Clasen
7c5c843b5b Merge branch 'matthiasc/for-main' into 'main'
Drop gtkmain.c from POTFILES

See merge request GNOME/gtk!5390
2023-01-04 17:22:54 +00:00
Matthias Clasen
bc11bc4f8d Drop gtkmain.c from POTFILES
No longer any translations here.
2023-01-04 12:03:01 -05:00
Matthias Clasen
be24e4a1f7 Merge branch 'deprecate-toggled' into 'main'
Deprecate gtk_toggle_button_toggled

See merge request GNOME/gtk!5388
2023-01-04 12:57:32 +00:00
Matthias Clasen
918ff1d0f4 Deprecate gtk_toggle_button_toggled
The function is documented as useless.
2023-01-04 07:32:51 -05:00
Anders Jonsson
20723613bc Update Swedish translation 2023-01-04 12:32:38 +00:00
Matthias Clasen
604aafe15d Merge branch 'wip/carlosg/startup-vs-focus' into 'main'
Consider startup vs focus requests for the Wayland platform

See merge request GNOME/gtk!5386
2023-01-03 15:14:35 +00:00
Carlos Garnacho
4041ca0f69 gdkdisplay: Deprecate gdk_display_notify_startup_complete()
We have various layers where we store the startup ID for a request,
since this API does not have a GdkToplevel that we can refer about
for the Wayland platform, this is the most obvious candidate to
start untangling these various layers.

Deprecate this call, it is already unused in the gtk/ side.
2023-01-03 14:58:33 +01:00
Carlos Garnacho
3526d8b299 gtkapplication: Do not call gdk_display_notify_startup_complete()
This should do nothing worthwhile anymore, the X11/Wayland GtkApplication
implementations do already pass the startup ID from the platform_data
via windowing specific APIs, and the application handling the request
via show()/present() should trigger the activation request.
2023-01-03 14:58:33 +01:00
Carlos Garnacho
e8adfa2a88 gtkwindow: Shuffle gdk_toplevel_set_startup_id() calls
While this used to be tangential to windows showing or requesting
focus, the xdg-activation Wayland protocol does merge both concepts
together.

But also, for a correct interaction with the compositor, the
toolkit should ideally merge the activation request resulting from
both into the same one, so that the gdk_toplevel_focus() request
replies to the startup token that started the application and
correct focus-stealing prevention/etc happens, instead making up
one just in time for the focus request.

This kind of requires doing things in the right order, a show()
request on the GtkWindow should activate any pending activation
token on the toplevel, a present() request should additionally
create a new token if there was none pending. And
xdg_activation_v1_activate() should happen once on both.

Shuffle the gdk_toplevel_set_startup_id() calls so that this
happens in the right order for Wayland, while making X11 happy
too.
2023-01-03 14:58:33 +01:00
Carlos Garnacho
7fab1b85ad gdk/x11: Emit "remove" s-n message from gdk_toplevel_set_startup_id
In the way towards deprecating gdk_display_notify_startup_complete(),
make gdk_toplevel_set_startup_id() on X11 perform this piece of messaging
itself. It should be harmless that the message is emitted twice, if
callers do still use that API.
2023-01-03 14:58:25 +01:00
Carlos Garnacho
5aeabdb3d4 gdk/wayland: Perform xdg_activation on gdk_toplevel_set_startup_id
This call has everything to perform activation as specified by the
xdg_activation protocol, notably a surface to activate as opposed to
gdk_display_notify_startup_complete().

Make activation happen here, so that the surface gets activated when
its gets a startup ID assigned.
2023-01-03 14:57:49 +01:00
Carlos Garnacho
6f01f846dc gtkwindow: Minor refactor
Move the handling of the startup ID to a separate function, since
this will be called from several places.
2023-01-03 14:57:44 +01:00
Matthias Clasen
3c4f6144a0 Merge branch 'fix-introspection' into 'main'
meson.build: build introspection according to option only

See merge request GNOME/gtk!5382
2023-01-03 11:56:49 +00:00
Alexander Kanavin
ae71d338d7 meson.build: build introspection according to option only
The way the check is written, if the build is native, then the
introspection option has no effect.

Particularly yocto project does want to disable introspection in
native builds and enable it in cross builds (both via the option),
and without this patch the former is not possible.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2023-01-03 08:26:07 +01:00
Matthias Clasen
8b469a2727 Merge branch 'nullable-gdk' into 'main'
gdk_display_open: Mark arg as nullable

See merge request GNOME/gtk!5380
2023-01-03 00:25:55 +00:00
Matthias Clasen
53813f24f0 Merge branch 'matthiasc/for-main' into 'main'
ci: Enable introspection for the docs build

See merge request GNOME/gtk!5383
2023-01-02 21:53:58 +00:00
Matthias Clasen
1fde83f12b Merge branch 'direction-from-language' into 'main'
Determine direction from language

See merge request GNOME/gtk!5385
2023-01-02 21:50:54 +00:00
Matthias Clasen
1f7783224b Determine direction from language
We can determine the direction to return here
without relying on translations, by using pango
and HarfBuzz apis to go
language -> script -> direction.
2023-01-02 16:30:27 -05:00
Matthias Clasen
0d04ceda76 Merge branch 'ccook/doc-changes-2' into 'main'
Various documentation suggests across a few domains.

See merge request GNOME/gtk!5384
2023-01-02 20:40:54 +00:00
Cam Cook
9396ccf9ff Various documentation suggests across a few domains.
| domain | current | suggestion |
|--------|---------|------------|
| [GtkSeparator](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkseparator.c#L39)    | "`![An example GtkSeparator](separators.png)`" | "`![An example GtkSeparator](separator.png)`" [1] |
| [GtkTextBuffer](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L4885)  | "if there is an redoable action" | "if there is a redoable action" |
| [GtkTextBuffer/get_enable_undo](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L5005) | (Renders `No description available.`) | "Returns: %TRUE if undoing and redoing changes to the buffer is allowed." [3] |
| [GtkTextBuffer/get_max_undo_levels](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L5102) | (Renders `No description available.`)| "Returns: The max number of undo levels allowed (0 indicates unlimited)." |
| [GtkTextBuffer](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L3874) | "with gtk_text_buffer_add_selection_clipboard()." | "with [method@Gtk.TextBuffer.add_selection_clipboard]" |
| [GtkTextBuffer](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L3494) | "it will automatically toggled" | "it will automatically toggle" |

* [1] See : [separator.png](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/images/separator.png), [gtk4.toml.in](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/gtk4.toml.in#L218), [visual_index.md](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/reference/gtk/visual_index.md?plain=1#L16)
* [2] Taken from `enable-undo` [property description](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbuffer.c#L516)

* [GtkTextMark/gtk_text_mark_set_visible](https://docs.gtk.org/gtk4/method.TextMark.set_visible.html) is defined in [GtkTextMark's header](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextmark.h#L93), but implemented in [GtkTextBTree](https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtktextbtree.c#L3036).
  * Other than being kind of confusing, this causes `gtk_text_mark_set_visible()`'s doc to not render where it expects it to.
2023-01-02 13:47:55 -05:00
Matthias Clasen
5a68639788 ci: Enable introspection for the docs build
It is required, so lets not rely on defaults.
2023-01-02 11:27:22 -05:00
Matthias Clasen
85df554ec1 Fix compiler warnings 2023-01-02 11:18:54 -05:00
Matthias Clasen
8776ebfe90 Merge branch 'dependency-review' into 'main'
Dependency review

See merge request GNOME/gtk!5381
2023-01-02 16:14:24 +00:00
Matthias Clasen
83eee03b0f build: Use the current gdk-pixbuf as subproject
This commit has fixes for subproject use that we need,
and is not in a release yet.
2023-01-02 10:57:52 -05:00
Matthias Clasen
d7bba4ebac build: Use libcloudproviders 0.3.1 as subproject 2023-01-02 10:57:52 -05:00
Matthias Clasen
40e2b5b153 build Use current libepoxy as subproject
We need recent fixes for graphene subproject use,
so use the current HEAD of master until there is
a release with these fixes.
2023-01-02 10:57:52 -05:00
Matthias Clasen
f7a7313758 build: Use the current graphene as subproject
We need recent fixes for graphene subproject use,
so use the current HEAD of master until there is
a release with these fixes.
2023-01-02 10:57:52 -05:00
Matthias Clasen
2d9ce0357f build: Use wayland 1.21.0 as subproject 2023-01-02 10:57:52 -05:00
Matthias Clasen
0ea05896df build: Use wayland-protocols 1.25 as subproject 2023-01-02 10:57:52 -05:00
Matthias Clasen
8c638df147 build: Use pango 1.50.12 as subproject 2023-01-02 10:57:52 -05:00
Matthias Clasen
6605ded4c9 build: Use fribidi 1.0.12 as subproject 2023-01-02 10:57:52 -05:00
Matthias Clasen
ba1a9530c8 build: Use cairo 1.17.6 as subproject
We don't want to use cairo 1.16, since it is
too old, so use 1.17.6 for now until there
is a stable 1.18 release.
2023-01-02 10:57:52 -05:00
Matthias Clasen
a9fcea369e build: Use glib 2.74.4 as subproject
This is the latest stable release.
2023-01-02 10:57:44 -05:00
Matthias Clasen
ca2787fbba build: Pass gobject_types=true to graphene
This is required for graphene-gobject to be built.
2023-01-02 09:15:59 -05:00
Matthias Clasen
6d2c897dfc build: Bump introspection dep to 1.72
This should be kept in sync with glib.
2023-01-02 09:15:56 -05:00
Matthias Clasen
01f81b2d77 build: Bump graphene req to 1.10
So we don't require an unstable version.
2023-01-02 09:15:56 -05:00
Sabri Ünal
8a3c5c63e8 Update Turkish translation 2023-01-02 13:58:10 +00:00
Maximiliano Sandoval R
b688f47776 gdk_display_open: Mark arg as nullable 2023-01-02 11:49:06 +01:00
Matthias Clasen
e126110ae0 Merge branch 'wide-inspector' into 'main'
inspector: Avoid super-wide window

See merge request GNOME/gtk!5379
2022-12-31 20:07:45 +00:00
Matthias Clasen
f98406b080 Merge branch 'annotate-dialog-deprecation' into 'main'
docs: Annotate GtkDialog deprecation

See merge request GNOME/gtk!5376
2022-12-31 20:07:20 +00:00
Matthias Clasen
40a2910262 inspector: Avoid super-wide window
Ellipsize values that can get long, to avoid
forcing an excessively wide window.
2022-12-31 12:30:40 -05:00
Marco Melorio
ec84077486 docs: Annotate GtkDialog deprecations 2022-12-30 15:37:11 +01:00
Benjamin Otte
188f9269b7 Merge branch 'wip/corey/list-item-visible' into 'main'
listitemwidget: Setup factory only once the widget is visible

See merge request GNOME/gtk!5374
2022-12-29 22:21:43 +00:00
Corey Berla
7ad693f865 gtkcolumnviewcolumn: Only create cells when the column is visible
It's a big performance drag to create many cells (and their associated
widgets) for columns that may never be shown. Only create cells
is the column is visible, and subsequently create/remove cells
when in column_set_visible.
2022-12-29 11:11:40 -08:00
Yosef Or Boczko
913e3680f3 Update Hebrew translation 2022-12-27 21:46:52 +00:00
Matthias Clasen
f3ad6015c6 Merge branch 'wip/corey/notify-drop-value' into 'main'
gtkdroptarget: Notify value property on local drag

See merge request GNOME/gtk!5372
2022-12-27 16:45:16 +00:00
Corey Berla
4e694c1824 gtkdroptarget: Notify value property on local drag
The value property is only getting notified when it's unset
or when it's set from gdk_drop_real_value_async().  Make sure
to always notify :value when its changed
2022-12-27 08:11:53 -08:00
Matthias Clasen
0214cb5b1b Post-release version bump 2022-12-26 07:22:39 -05:00
Arjan Molenaar
089d0caa5e macos: Fix freeze on drag
A Drag surface does not have a parent surface. Therefore, if we initialize
it with one, it's inheriting the frame clock from the parent, but the
drag surface is not linked to the parent. Once the drag surface is destroyed,
it's disposing the frame clock, which results in a "frozen" application.
2022-12-13 15:19:04 +01:00
Arjan Molenaar
d0c4413033 macos: Explicitly ungrab seat when drag is done or finalized
This is an extra safeguard that avoids grabbing resources longer than
nessecary. It also ensures the resource is removed from the drag,
so it is not freed again.
2022-12-13 15:19:04 +01:00
Arjan Molenaar
410fa9871f Remove old dragImage code
New code (macOS 10+ should support the NSDraggingSource protocol:
https://developer.apple.com/documentation/appkit/nsdraggingsource.
2022-12-13 15:19:04 +01:00
andy5995
9fd4b215ee docs: Place example-{3,4} in numerical order 2022-12-10 17:39:09 -06:00
Arjan Molenaar
19aaa8fee5 macos: Use Command key symbol for meta
Show the Apple Command symbol ⌘ as keyboard shortcut for the Meta key on macos,
similar to GtkAccelGroup.
2022-12-05 21:00:42 +01:00
Joan Bruguera
43c1a433aa gdk/wayland: set requesting surface to xdg-activation
The argument to xdg_activation_token_v1_set_surface is documented to be the
surface requesting the activation, not the surface to be activated, which is
given later when calling xdg_activation_v1_activate.
(c.f. 36cee4bdbc)

Use the same logic as in gdk_wayland_app_launch_context_get_startup_notify_id,
i.e. if we have a surface with focus, set that, otherwise set NULL.

This fixes requesting urgent/focus on wlroots (compositors like Sway, etc.),
which was blocked as the surface requesting the activation didn't have focus.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-12-04 23:33:34 +00:00
Corey Berla
ff8d88b097 dragsource: Add a timeout before starting a drag
No one wants a drag that happens in less than 100ms (if so, it's
probably accidental).
2022-11-29 20:06:21 -08:00
Hodong
30525835f3 Fix a typo 2022-10-25 19:40:30 +00:00
Ondřej Míchal
818ca63d35 gdkdisplay: Document get_monitor_at_surface can return NULL
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5075
2022-08-01 12:54:13 +02:00
Maxim Zakharov
2290c2bb23 gdk/broadway: Implements modal hint for Broadway surface
Ensures modal window is raised above parent; does return focus to
parent window when transient child window is closed.

That solves problems with overlapped modal window and focus loss in
complex multi window UI.
2022-05-17 15:18:30 +10:00
Jason Francis
3fc7c97979 gtk: Set widget template children to NULL before destroy unref 2022-05-14 10:13:39 -04:00
Jens Georg
b9551a8952 Remove obsolete "or %NULL" documentation 2022-04-20 15:15:51 +02:00
Jens Georg
e600fcbcc5 widget: Mark format as nullable in activate_action
The doc and the code allow it to be NULL
2022-04-19 10:17:39 +02:00
387 changed files with 39304 additions and 34417 deletions

View File

@@ -22,29 +22,35 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false -Dwayland:werror=false"
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Ddemos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v40"
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v41"
.only-default:
only:
- branches
except:
- tags
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
default:
retry:
max: 2
when:
- 'runner_system_failure'
- 'stuck_or_timeout_failure'
- 'scheduler_failure'
- 'api_failure'
interruptible: true
style-check-diff:
extends: .only-default
image: $FEDORA_IMAGE
stage: check
allow_failure: true
when: manual
script:
- .gitlab-ci/run-style-check-diff.sh
.build-fedora-default:
extends: .only-default
image: $FEDORA_IMAGE
artifacts:
when: always
@@ -113,7 +119,12 @@ release-build:
- pip3 install --user meson~=0.64
- meson subprojects download
- meson subprojects update --reset
- meson setup ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} _build
- meson setup
${COMMON_MESON_FLAGS}
${EXTRA_MESON_FLAGS}
${BACKEND_FLAGS}
${FEATURE_FLAGS}
_build
- meson compile -C _build
- .gitlab-ci/run-tests.sh _build x11
@@ -155,7 +166,6 @@ fedora-mingw64:
- ninja -C _build
.mingw-defaults:
extends: .only-default
stage: build
tags:
- win32-ps
@@ -187,9 +197,8 @@ msys2-mingw64:
macos:
# Sadly, this fails regularly, and its failure is never enlightening
allow_failure: true
extends: .only-default
only:
- branches@GNOME/gtk
rules:
- if: $CI_PROJECT_NAMESPACE == "GNOME"
stage: build
tags:
- macos
@@ -201,7 +210,7 @@ macos:
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
- export MESON_FORCE_BACKTRACE=1
script:
- meson setup
- meson setup ${COMMON_MESON_FLAGS}
-Dx11-backend=false
-Dbroadway-backend=true
-Dmacos-backend=true
@@ -210,6 +219,10 @@ macos:
-Dcpp_std=c++11
-Dpixman:tests=disabled
-Dlibjpeg-turbo:simd=disabled
-Ddemos=false
-Dbuild-tests=false
-Dbuild-examples=false
-Dbuild-testsuite=false
_build
- meson compile -C _build
artifacts:
@@ -218,10 +231,9 @@ macos:
- "${CI_PROJECT_DIR}/_build/meson-logs"
vs2017-x64:
extends: .only-default
# TODO: Uncomment this when ready to merge.
#only:
# - branches@GNOME/gtk
# rules:
# - if: $CI_PROJECT_NAMESPACE == "GNOME"
stage: build
tags:
- win32-ps
@@ -234,7 +246,7 @@ vs2017-x64:
- "${CI_PROJECT_DIR}/_build/meson-logs"
.flatpak-defaults:
image: $FLATPAK_IMAGE
image: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
stage: flatpak
allow_failure: true
tags:
@@ -244,65 +256,67 @@ vs2017-x64:
- "${APPID}-dev.flatpak"
- 'repo.tar'
expire_in: 1 day
rules:
# Only build Flatpak bundles automatically on main
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH != "main"
when: "manual"
script:
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
# Manual jobs, for branches and MRs
.flatpak-manual:
extends: .flatpak-defaults
when: manual
# Only build Flatpak bundles automatically on main
.flatpak-main:
extends: .flatpak-defaults
only:
- main
flatpak-manual:demo:
extends: .flatpak-manual
flatpak:demo:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.Demo4
flatpak-main:demo:
extends: .flatpak-main
flatpak:demo:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.Demo4
flatpak-manual:widget-factory:
extends: .flatpak-manual
flatpak:widget-factory:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.WidgetFactory4
flatpak-main:widget-factory:
extends: .flatpak-main
flatpak:widget-factory:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.WidgetFactory4
flatpak-manual:icon-browser:
extends: .flatpak-manual
flatpak:icon-browser:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.IconBrowser4
flatpak-main:icon-browser:
extends: .flatpak-main
flatpak:icon-browser:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.IconBrowser4
flatpak-manual:node-editor:
extends: .flatpak-manual
flatpak:node-editor:
extends: '.flatpak-defaults'
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
flatpak-main:node-editor:
extends: .flatpak-main
flatpak:node-editor:aarch64:
extends: '.flatpak-defaults'
needs: []
tags:
- flatpak-aarch64
variables:
APPID: org.gtk.gtk4.NodeEditor
@@ -311,23 +325,35 @@ flatpak-main:node-editor:
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
nightly demo:
extends: '.publish_nightly'
dependencies: ['flatpak-main:demo']
needs: ['flatpak-main:demo']
needs: ['flatpak:demo']
nightly demo aarch64:
extends: '.publish_nightly'
needs: ['flatpak:demo:aarch64']
nightly factory:
extends: '.publish_nightly'
dependencies: ['flatpak-main:widget-factory']
needs: ['flatpak-main:widget-factory']
needs: ['flatpak:widget-factory']
nightly factory aarch64:
extends: '.publish_nightly'
needs: ['flatpak:widget-factory:aarch64']
nightly icon-browser:
extends: '.publish_nightly'
dependencies: ['flatpak-main:icon-browser']
needs: ['flatpak-main:icon-browser']
needs: ['flatpak:icon-browser']
nightly icon-browser aarch64:
extends: '.publish_nightly'
needs: ['flatpak:icon-browser:aarch64']
nightly node-editor:
extends: '.publish_nightly'
dependencies: ['flatpak-main:node-editor']
needs: ['flatpak-main:node-editor']
needs: ['flatpak:node-editor']
nightly node-editor aarch64:
extends: '.publish_nightly'
needs: ['flatpak:node-editor:aarch64']
static-scan:
image: $FEDORA_IMAGE
@@ -338,7 +364,10 @@ static-scan:
script:
- export PATH="$HOME/.local/bin:$PATH"
- pip3 install --user meson~=0.64
- meson setup ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build
- meson setup
${COMMON_MESON_FLAGS}
${EXTRA_MESON_FLAGS}
_scan_build
- ninja -C _scan_build scan-build
artifacts:
paths:
@@ -352,6 +381,7 @@ asan-build:
tags: [ asan ]
stage: analysis
needs: []
when: manual
variables:
script:
- export PATH="$HOME/.local/bin:$PATH"
@@ -368,12 +398,22 @@ reference:
image: $FEDORA_IMAGE
stage: docs
needs: []
variables:
EXTRA_MESON_FLAGS: "--buildtype=release --force-fallback-for=gdk-pixbuf,pango"
script:
- export PATH="$HOME/.local/bin:$PATH"
- pip3 install --user meson~=0.64
- meson setup ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true -Dgdk-pixbuf:gtk_doc=true -Dpango:gtk_doc=true _build
- meson setup
${COMMON_MESON_FLAGS}
--buildtype=release
--force-fallback-for=gdk-pixbuf,pango
-Dintrospection=enabled
-Dgtk_doc=true
-Dgdk-pixbuf:gtk_doc=true
-Dpango:gtk_doc=true
-Ddemos=false
-Dbuild-examples=false
-Dbuild-tests=false
-Dbuild-testsuite=false
_build
- meson compile -C _build
- mkdir -p _reference/
- mv _build/docs/reference/gdk/gdk4/ _reference/gdk4/
@@ -396,9 +436,9 @@ reference:
publish-docs:
image: fedora:latest
stage: publish
interruptible: false
needs: ['reference']
script:
- "curl -X POST -F token=${PAGES_TRIGGER_TOKEN} -F ref=docs-gtk-org https://gitlab.gnome.org/api/v4/projects/665/trigger/pipeline"
only:
refs:
- main
rules:
- if: $CI_COMMIT_REF_NAME == "main"

View File

@@ -82,6 +82,7 @@ RUN dnf -y install \
python3-gobject \
python3-jinja2 \
python3-markdown \
python3-packaging \
python3-pip \
python3-pygments \
python3-typogrify \

View File

@@ -23,6 +23,7 @@ push=0
list=0
print_help=0
no_login=0
no_cache=0
while (($# > 0)); do
case "${1%%=*}" in
@@ -34,6 +35,7 @@ while (($# > 0)); do
--base|-b) read_arg base "$@" || shift;;
--version|-v) read_arg base_version "$@" || shift;;
--no-login) no_login=1;;
--no-cache) no_cache=1;;
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
esac
shift
@@ -103,11 +105,21 @@ TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
if [ $build == 1 ]; then
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
${CMD} build \
${format} \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
if [ $no_cache == 0 ]; then
${CMD} build \
${format} \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
else
${CMD} build \
${format} \
--no-cache \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
fi
exit $?
fi

View File

@@ -21,7 +21,7 @@ many things that we value:
Please, do not use the issue tracker for support questions. If you have
questions on how to use GTK effectively, you can use:
- the `#gtk` IRC channel on irc.gnome.org
- the `gtk` [room on matrix](https://matrix.to/#/#gtk:gnome.org)
- the [gtk tag on the GNOME Discourse instance](https://discourse.gnome.org/tag/gtk)
You can also look at the GTK tag on [Stack
@@ -44,6 +44,7 @@ If you're reporting a bug make sure to list:
0. which version of GTK are you using?
0. which operating system are you using?
0. what display and graphics driver are you using?
0. the necessary steps to reproduce the issue
0. the expected outcome
0. a description of the behavior; screenshots are also welcome

110
NEWS
View File

@@ -1,3 +1,113 @@
Overview of Changes in 4.9.5, xx-xx-xxxx
========================================
Overview of Changes in 4.9.4, 12-02-2023
========================================
* Printing:
- Add a CPDB backend
- Drop the lpr backend
* GtkFileDialog:
- Robustness fixes
* GtkScaleButton:
- Add an 'active' property
* GtkSearchEntry:
- Add placeholder text
* Fix conflicting type names between gtk and gio
* Gsk:
- Settable filtering for scaled textures
- Add mask nodes
- Some robustness and crash fixes
* Wayland:
- Handle dispatch failing in more places
* Deprecations:
- GtkVolumeButton
* Translation updates:
Belarusian
Chinese (Taiwan)
Georgian
Turkish
Ukrainian
Overview of Changes in 4.9.3, 04-02-2023
========================================
* Add GtkUriLauncher, as replacement for gtk_show_uri
* Add GdkMonitor::description
* Fix problems with tooltip sizing
* Deprecations:
- GtkStatusbar
- GtkAssistant
- GtkLockButton
- gtk_gesture_set_sequence_state
* GtkColumnView:
- Only create widgets for visible columns
* GtkFileDialog:
- Drop shortcut folders API
* GtkCalendar:
- Make marked days work again
* GtkSwitch:
- Make state and active independently settable
* GtkFileChooser:
- Fix a crash with DND
- Fix excessively wide sidebar
- Make context menus work again
* Accessibility:
- Make GtkAccessible public, so it can be implemented outside GTK
- Support accessible implementation for editables
* CSS:
- Fix randomly stopping CSS animations
* GL:
- Fix synchronization with GStreamer
- Fix problems with 3rd party GL in the same thread
* Wayland:
- Fix startup notification with xdg_activation
* Broadway:
- Implement modal windows
* macOS:
- Make DND work
* Build:
- Require graphene 1.10
- Require gobject-introspection 1.72
* Translation updates
Catalan
Galician
German
Hebrew
Indonesian
Portuguese
Russian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.9.2, 26-12-2022
========================================

View File

@@ -2,6 +2,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef GtkApplication DemoApplication;
typedef GtkApplicationClass DemoApplicationClass;

View File

@@ -7,6 +7,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *progress_bar = NULL;
static gboolean

View File

@@ -37,6 +37,8 @@ remove_timeout (gpointer data)
g_source_remove (id);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static gboolean
pop_status (gpointer data)
{
@@ -57,6 +59,8 @@ status_message (GtkStatusbar *status,
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
help_activate (GSimpleAction *action,
GVariant *parameter,

View File

@@ -215,6 +215,12 @@
<file>demo3widget.h</file>
<file>demo3widget.ui</file>
</gresource>
<gresource prefix="/mask">
<file>demo4widget.c</file>
<file>demo4widget.h</file>
<file>hsla.h</file>
<file>hsla.c</file>
</gresource>
<gresource prefix="/paintable_svg">
<file>svgpaintable.h</file>
<file>svgpaintable.c</file>
@@ -311,6 +317,7 @@
<file>list_store.c</file>
<file>main.c</file>
<file>markup.c</file>
<file>mask.c</file>
<file>menu.c</file>
<file>overlay.c</file>
<file>overlay_decorative.c</file>

View File

@@ -3,7 +3,8 @@
enum
{
PROP_PAINTABLE = 1,
PROP_TEXTURE = 1,
PROP_FILTER,
PROP_SCALE
};
@@ -11,8 +12,9 @@ struct _Demo3Widget
{
GtkWidget parent_instance;
GdkPaintable *paintable;
GdkTexture *texture;
float scale;
GskScalingFilter filter;
GtkWidget *menu;
};
@@ -28,6 +30,7 @@ static void
demo3_widget_init (Demo3Widget *self)
{
self->scale = 1.f;
self->filter = GSK_SCALING_FILTER_LINEAR;
gtk_widget_init_template (GTK_WIDGET (self));
}
@@ -36,7 +39,7 @@ demo3_widget_dispose (GObject *object)
{
Demo3Widget *self = DEMO3_WIDGET (object);
g_clear_object (&self->paintable);
g_clear_object (&self->texture);
gtk_widget_dispose_template (GTK_WIDGET (self), DEMO3_TYPE_WIDGET);
@@ -50,12 +53,13 @@ demo3_widget_snapshot (GtkWidget *widget,
Demo3Widget *self = DEMO3_WIDGET (widget);
int x, y, width, height;
double w, h;
GskRenderNode *node;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
w = self->scale * gdk_paintable_get_intrinsic_width (self->paintable);
h = self->scale * gdk_paintable_get_intrinsic_height (self->paintable);
w = self->scale * gdk_texture_get_width (self->texture);
h = self->scale * gdk_texture_get_height (self->texture);
x = MAX (0, (width - ceil (w)) / 2);
y = MAX (0, (height - ceil (h)) / 2);
@@ -63,7 +67,11 @@ demo3_widget_snapshot (GtkWidget *widget,
gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
gdk_paintable_snapshot (self->paintable, snapshot, w, h);
node = gsk_texture_scale_node_new (self->texture,
&GRAPHENE_RECT_INIT (0, 0, w, h),
self->filter);
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
gtk_snapshot_restore (snapshot);
gtk_snapshot_pop (snapshot);
}
@@ -81,9 +89,9 @@ demo3_widget_measure (GtkWidget *widget,
int size;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
size = gdk_paintable_get_intrinsic_width (self->paintable);
size = gdk_texture_get_width (self->texture);
else
size = gdk_paintable_get_intrinsic_height (self->paintable);
size = gdk_texture_get_height (self->texture);
*minimum = *natural = self->scale * size;
}
@@ -113,9 +121,9 @@ demo3_widget_set_property (GObject *object,
switch (prop_id)
{
case PROP_PAINTABLE:
g_clear_object (&self->paintable);
self->paintable = g_value_dup_object (value);
case PROP_TEXTURE:
g_clear_object (&self->texture);
self->texture = g_value_dup_object (value);
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
@@ -124,6 +132,11 @@ demo3_widget_set_property (GObject *object,
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
case PROP_FILTER:
self->filter = g_value_get_enum (value);
gtk_widget_queue_resize (GTK_WIDGET (object));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -140,14 +153,18 @@ demo3_widget_get_property (GObject *object,
switch (prop_id)
{
case PROP_PAINTABLE:
g_value_set_object (value, self->paintable);
case PROP_TEXTURE:
g_value_set_object (value, self->texture);
break;
case PROP_SCALE:
g_value_set_float (value, self->scale);
break;
case PROP_FILTER:
g_value_set_enum (value, self->filter);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -205,16 +222,21 @@ demo3_widget_class_init (Demo3WidgetClass *class)
widget_class->measure = demo3_widget_measure;
widget_class->size_allocate = demo3_widget_size_allocate;
g_object_class_install_property (object_class, PROP_PAINTABLE,
g_param_spec_object ("paintable", "Paintable", "Paintable",
GDK_TYPE_PAINTABLE,
g_object_class_install_property (object_class, PROP_TEXTURE,
g_param_spec_object ("texture", NULL, NULL,
GDK_TYPE_TEXTURE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SCALE,
g_param_spec_float ("scale", "Scale", "Scale",
g_param_spec_float ("scale", NULL, NULL,
0.0, 10.0, 1.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILTER,
g_param_spec_enum ("filter", NULL, NULL,
GSK_TYPE_SCALING_FILTER, GSK_SCALING_FILTER_LINEAR,
G_PARAM_READWRITE));
/* These are the actions that we are using in the menu */
gtk_widget_class_install_action (widget_class, "zoom.in", NULL, zoom_cb);
gtk_widget_class_install_action (widget_class, "zoom.out", NULL, zoom_cb);
@@ -229,16 +251,13 @@ GtkWidget *
demo3_widget_new (const char *resource)
{
Demo3Widget *self;
GdkPixbuf *pixbuf;
GdkPaintable *paintable;
GdkTexture *texture;
pixbuf = gdk_pixbuf_new_from_resource (resource, NULL);
paintable = GDK_PAINTABLE (gdk_texture_new_for_pixbuf (pixbuf));
texture = gdk_texture_new_from_resource (resource);
self = g_object_new (DEMO3_TYPE_WIDGET, "paintable", paintable, NULL);
self = g_object_new (DEMO3_TYPE_WIDGET, "texture", texture, NULL);
g_object_unref (pixbuf);
g_object_unref (paintable);
g_object_unref (texture);
return GTK_WIDGET (self);
}

View File

@@ -0,0 +1,226 @@
#include <math.h>
#include "demo4widget.h"
#include "hsla.h"
enum
{
PROP_0,
PROP_PROGRESS,
};
struct _Demo4Widget
{
GtkWidget parent_instance;
PangoLayout *layout;
GskColorStop stops[8];
gsize n_stops;
double progress;
guint tick;
};
struct _Demo4WidgetClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (Demo4Widget, demo4_widget, GTK_TYPE_WIDGET)
static void
rotate_color (GdkRGBA *rgba)
{
GdkHSLA hsla;
_gdk_hsla_init_from_rgba (&hsla, rgba);
hsla.hue -= 1;
_gdk_rgba_init_from_hsla (rgba, &hsla);
}
static gboolean
rotate_colors (GtkWidget *widget,
GdkFrameClock *clock,
gpointer user_data)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
for (unsigned int i = 0; i < self->n_stops; i++)
rotate_color (&self->stops[i].color);
gtk_widget_queue_draw (widget);
return G_SOURCE_CONTINUE;
}
static void
demo4_widget_init (Demo4Widget *self)
{
PangoFontDescription *desc;
self->progress = 0.5;
self->n_stops = 8;
self->stops[0].offset = 0;
self->stops[0].color = (GdkRGBA) { 1, 0, 0, 1 };
for (unsigned int i = 1; i < self->n_stops; i++)
{
GdkHSLA hsla;
self->stops[i].offset = i / (double)(self->n_stops - 1);
_gdk_hsla_init_from_rgba (&hsla, &self->stops[i - 1].color);
hsla.hue += 360.0 / (double)(self->n_stops - 1);
_gdk_rgba_init_from_hsla (&self->stops[i].color, &hsla);
}
self->layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "123");
desc = pango_font_description_from_string ("Cantarell Bold 210");
pango_layout_set_font_description (self->layout, desc);
pango_font_description_free (desc);
self->tick = gtk_widget_add_tick_callback (GTK_WIDGET (self), rotate_colors, NULL, NULL);
}
static void
demo4_widget_dispose (GObject *object)
{
Demo4Widget *self = DEMO4_WIDGET (object);
g_clear_object (&self->layout);
gtk_widget_remove_tick_callback (GTK_WIDGET (self), self->tick);
G_OBJECT_CLASS (demo4_widget_parent_class)->dispose (object);
}
static void
demo4_widget_snapshot_content (GtkWidget *widget,
GtkSnapshot *snapshot,
GskMaskMode mode)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
int width, height, layout_width, layout_height;
double scale;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
gtk_snapshot_push_mask (snapshot, mode);
pango_layout_get_pixel_size (self->layout, &layout_width, &layout_height);
scale = MIN ((double) width / layout_width, (double) height / layout_height);
gtk_snapshot_translate (snapshot,
&GRAPHENE_POINT_INIT ((width - scale * layout_width) / 2,
(height - scale * layout_height) / 2));
gtk_snapshot_scale (snapshot, scale, scale);
gtk_snapshot_append_layout (snapshot, self->layout, &(GdkRGBA) { 0, 0, 0, 1 });
gtk_snapshot_pop (snapshot);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, height),
self->stops,
self->n_stops);
gtk_snapshot_pop (snapshot);
}
static void
demo4_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
Demo4Widget *self = DEMO4_WIDGET (widget);
int width, height;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_INVERTED_LUMINANCE);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, 0),
(GskColorStop[2]) {
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
}, 2);
gtk_snapshot_pop (snapshot);
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_INVERTED_ALPHA);
gtk_snapshot_pop (snapshot);
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_LUMINANCE);
gtk_snapshot_append_linear_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (0, 0),
&GRAPHENE_POINT_INIT (width, 0),
(GskColorStop[2]) {
{ MAX (0.0, self->progress - 5.0 / width), { 1, 1, 1, 1 } },
{ MIN (1.0, self->progress + 5.0 / width), { 0, 0, 0, 1 } }
}, 2);
gtk_snapshot_pop (snapshot);
demo4_widget_snapshot_content (widget, snapshot, GSK_MASK_MODE_ALPHA);
gtk_snapshot_pop (snapshot);
}
static void
demo4_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
Demo4Widget *self = DEMO4_WIDGET (object);
switch (prop_id)
{
case PROP_PROGRESS:
self->progress = g_value_get_double (value);
gtk_widget_queue_draw (GTK_WIDGET (object));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo4_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
Demo4Widget *self = DEMO4_WIDGET (object);
switch (prop_id)
{
case PROP_PROGRESS:
g_value_set_double (value, self->progress);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
demo4_widget_class_init (Demo4WidgetClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = demo4_widget_dispose;
object_class->get_property = demo4_widget_get_property;
object_class->set_property = demo4_widget_set_property;
widget_class->snapshot = demo4_widget_snapshot;
g_object_class_install_property (object_class, PROP_PROGRESS,
g_param_spec_double ("progress", NULL, NULL,
0.0, 1.0, 0.5,
G_PARAM_READWRITE));
}
GtkWidget *
demo4_widget_new (void)
{
return g_object_new (DEMO4_TYPE_WIDGET, NULL);
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include <gtk/gtk.h>
#define DEMO4_TYPE_WIDGET (demo4_widget_get_type ())
G_DECLARE_FINAL_TYPE (Demo4Widget, demo4_widget, DEMO4, WIDGET, GtkWidget)
GtkWidget * demo4_widget_new (void);

View File

@@ -356,6 +356,10 @@ canvas_item_start_editing (CanvasItem *item)
}
typedef struct {
double x, y;
} Hotspot;
static GdkContentProvider *
prepare (GtkDragSource *source,
double x,
@@ -363,6 +367,7 @@ prepare (GtkDragSource *source,
{
GtkWidget *canvas;
GtkWidget *item;
Hotspot *hotspot;
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
@@ -373,6 +378,10 @@ prepare (GtkDragSource *source,
g_object_set_data (G_OBJECT (canvas), "dragged-item", item);
hotspot = g_new (Hotspot, 1);
gtk_widget_translate_coordinates (canvas, item, x, y, &hotspot->x, &hotspot->y);
g_object_set_data_full (G_OBJECT (canvas), "hotspot", hotspot, g_free);
return gdk_content_provider_new_typed (GTK_TYPE_WIDGET, item);
}
@@ -383,12 +392,14 @@ drag_begin (GtkDragSource *source,
GtkWidget *canvas;
CanvasItem *item;
GdkPaintable *paintable;
Hotspot *hotspot;
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = CANVAS_ITEM (g_object_get_data (G_OBJECT (canvas), "dragged-item"));
hotspot = (Hotspot *) g_object_get_data (G_OBJECT (canvas), "hotspot");
paintable = canvas_item_get_drag_icon (item);
gtk_drag_source_set_icon (source, paintable, item->r, item->r);
gtk_drag_source_set_icon (source, paintable, hotspot->x, hotspot->y);
g_object_unref (paintable);
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);

View File

@@ -362,7 +362,7 @@ do_drawingarea (GtkWidget *do_widget)
G_CALLBACK (scribble_resize), NULL);
drag = gtk_gesture_drag_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), 0);
gtk_widget_add_controller (da, GTK_EVENT_CONTROLLER (drag));
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), da);

View File

@@ -48,14 +48,16 @@
#define VERTICES_PER_TOOTH 34
#define GEAR_VERTEX_STRIDE 6
#ifndef HAVE_SINCOS
static void
sincos (double x, double *_sin, double *_cos)
static inline void
_sincos (double x, double *_sin, double *_cos)
{
#ifdef HAVE_SINCOS
sincos (x, _sin, _cos);
#else
*_sin = sin (x);
*_cos = cos (x);
}
#endif
}
/**
* Struct describing the vertices in triangle strip
@@ -307,11 +309,11 @@ create_gear (GLfloat inner_radius,
struct point p[7];
/* Calculate needed sin/cos for various angles */
sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
_sincos(i * 2.0 * G_PI / teeth + da * 0, &s[0], &c[0]);
_sincos(i * 2.0 * M_PI / teeth + da * 1, &s[1], &c[1]);
_sincos(i * 2.0 * M_PI / teeth + da * 2, &s[2], &c[2]);
_sincos(i * 2.0 * M_PI / teeth + da * 3, &s[3], &c[3]);
_sincos(i * 2.0 * M_PI / teeth + da * 4, &s[4], &c[4]);
GEAR_POINT(p[0], r2, 1);
GEAR_POINT(p[1], r2, 2);
@@ -520,7 +522,7 @@ void perspective(GLfloat *m, GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloa
identity(tmp);
deltaZ = zFar - zNear;
sincos(radians, &sine, &cosine);
_sincos(radians, &sine, &cosine);
if ((deltaZ == 0) || (sine == 0) || (aspect == 0))
return;

146
demos/gtk-demo/hsla.c Normal file
View File

@@ -0,0 +1,146 @@
#include <gdk/gdk.h>
#include "hsla.h"
void
_gdk_hsla_init_from_rgba (GdkHSLA *hsla,
const GdkRGBA *rgba)
{
float min;
float max;
float red;
float green;
float blue;
float delta;
g_return_if_fail (hsla != NULL);
g_return_if_fail (rgba != NULL);
red = rgba->red;
green = rgba->green;
blue = rgba->blue;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
hsla->lightness = (max + min) / 2;
hsla->saturation = 0;
hsla->hue = 0;
hsla->alpha = rgba->alpha;
if (max != min)
{
if (hsla->lightness <= 0.5)
hsla->saturation = (max - min) / (max + min);
else
hsla->saturation = (max - min) / (2 - max - min);
delta = max -min;
if (red == max)
hsla->hue = (green - blue) / delta;
else if (green == max)
hsla->hue = 2 + (blue - red) / delta;
else if (blue == max)
hsla->hue = 4 + (red - green) / delta;
hsla->hue *= 60;
if (hsla->hue < 0.0)
hsla->hue += 360;
}
}
void
_gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla)
{
float hue;
float lightness;
float saturation;
float m1, m2;
lightness = hsla->lightness;
saturation = hsla->saturation;
if (lightness <= 0.5)
m2 = lightness * (1 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2 * lightness - m2;
rgba->alpha = hsla->alpha;
if (saturation == 0)
{
rgba->red = lightness;
rgba->green = lightness;
rgba->blue = lightness;
}
else
{
hue = hsla->hue + 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->red = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->red = m2;
else if (hue < 240)
rgba->red = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->red = m1;
hue = hsla->hue;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->green = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->green = m2;
else if (hue < 240)
rgba->green = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->green = m1;
hue = hsla->hue - 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->blue = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
rgba->blue = m2;
else if (hue < 240)
rgba->blue = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->blue = m1;
}
}

15
demos/gtk-demo/hsla.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
typedef struct _GdkHSLA GdkHSLA;
struct _GdkHSLA {
float hue;
float saturation;
float lightness;
float alpha;
};
void _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
const GdkRGBA *rgba);
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla);

53
demos/gtk-demo/mask.c Normal file
View File

@@ -0,0 +1,53 @@
/* Masking
*
* Demonstrates mask nodes.
*
* This demo uses a text node as mask for
* an animated linear gradient.
*/
#include <gtk/gtk.h>
#include "demo4widget.h"
GtkWidget *
do_mask (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *box;
GtkWidget *demo;
GtkWidget *scale;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Mask Nodes");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), box);
demo = demo4_widget_new ();
gtk_widget_set_hexpand (demo, TRUE);
gtk_widget_set_vexpand (demo, TRUE);
gtk_box_append (GTK_BOX (box), demo);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 1, 0.1);
gtk_range_set_value (GTK_RANGE (scale), 0.5);
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value", demo, "progress", 0);
gtk_box_append (GTK_BOX (box), scale);
}
if (!gtk_widget_get_visible (window))
gtk_widget_set_visible (window, TRUE);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -22,9 +22,11 @@ do_menu (GtkWidget *do_widget)
if (!window)
{
GtkWidget *box;
GtkWidget *box2;
GtkWidget *sw;
GtkWidget *widget;
GtkWidget *scale;
GtkWidget *dropdown;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Menu");
@@ -43,10 +45,19 @@ do_menu (GtkWidget *do_widget)
widget = demo3_widget_new ("/transparent/portland-rose.jpg");
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), widget);
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_append (GTK_BOX (box), box2);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.01, 10.0, 0.1);
gtk_range_set_value (GTK_RANGE (scale), 1.0);
gtk_box_append (GTK_BOX (box), scale);
gtk_widget_set_hexpand (scale, TRUE);
gtk_box_append (GTK_BOX (box2), scale);
dropdown = gtk_drop_down_new (G_LIST_MODEL (gtk_string_list_new ((const char *[]){ "Linear", "Nearest", "Trilinear", NULL })), NULL);
gtk_box_append (GTK_BOX (box2), dropdown);
g_object_bind_property (dropdown, "selected", widget, "filter", G_BINDING_DEFAULT);
g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
widget, "scale",
G_BINDING_BIDIRECTIONAL);

View File

@@ -46,6 +46,7 @@ demos = files([
'links.c',
'listbox.c',
'listbox_controls.c',
'mask.c',
'menu.c',
'flowbox.c',
'list_store.c',
@@ -114,6 +115,7 @@ extra_demo_sources = files([
'gtkshadertoy.c',
'gtkshaderstack.c',
'gskshaderpaintable.c',
'hsla.c',
'puzzlepiece.c',
'bluroverlay.c',
'demoimage.c',
@@ -126,6 +128,7 @@ extra_demo_sources = files([
'four_point_transform.c',
'demo2widget.c',
'demo3widget.c',
'demo4widget.c',
'pixbufpaintable.c',
'script-names.c',
'unicode-names.c',

View File

@@ -1,11 +1,11 @@
/* Pickers
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog
/* Pickers and Launchers
* #Keywords: GtkColorDialog, GtkFontDialog, GtkFileDialog, GtkFileLauncher, GtkUriLauncher
*
* These widgets are mainly intended for use in preference dialogs.
* The dialogs are mainly intended for use in preference dialogs.
* They allow to select colors, fonts and applications.
*
* This demo shows both the default appearance for these dialogs,
* as well as some of the customizations that are possible.
* The launchers let you open files or URIs in applications that
* can handle them.
*/
#include <gtk/gtk.h>
@@ -73,9 +73,9 @@ open_file (GtkButton *picker,
}
static void
launch_done (GObject *source,
GAsyncResult *result,
gpointer data)
open_app_done (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkFileLauncher *launcher = GTK_FILE_LAUNCHER (source);
GError *error = NULL;
@@ -97,7 +97,35 @@ open_app (GtkButton *picker)
file = G_FILE (g_object_get_data (G_OBJECT (picker), "file"));
launcher = gtk_file_launcher_new (file);
gtk_file_launcher_launch (launcher, parent, NULL, launch_done, NULL);
gtk_file_launcher_launch (launcher, parent, NULL, open_app_done, NULL);
g_object_unref (launcher);
}
static void
open_uri_done (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkUriLauncher *launcher = GTK_URI_LAUNCHER (source);
GError *error = NULL;
if (!gtk_uri_launcher_launch_finish (launcher, result, &error))
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
launch_uri (GtkButton *picker)
{
GtkWindow *parent = GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (picker)));
GtkUriLauncher *launcher;
launcher = gtk_uri_launcher_new ("http://www.gtk.org");
gtk_uri_launcher_launch (launcher, parent, NULL, open_uri_done, NULL);
g_object_unref (launcher);
}
@@ -113,7 +141,7 @@ do_pickers (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Pickers");
gtk_window_set_title (GTK_WINDOW (window), "Pickers and Launchers");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
table = gtk_grid_new ();
@@ -121,8 +149,8 @@ do_pickers (GtkWidget *do_widget)
gtk_widget_set_margin_end (table, 20);
gtk_widget_set_margin_top (table, 20);
gtk_widget_set_margin_bottom (table, 20);
gtk_grid_set_row_spacing (GTK_GRID (table), 3);
gtk_grid_set_column_spacing (GTK_GRID (table), 10);
gtk_grid_set_row_spacing (GTK_GRID (table), 6);
gtk_grid_set_column_spacing (GTK_GRID (table), 6);
gtk_window_set_child (GTK_WINDOW (window), table);
label = gtk_label_new ("Color:");
@@ -149,7 +177,7 @@ do_pickers (GtkWidget *do_widget)
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
button = gtk_button_new_from_icon_name ("document-open-symbolic");
label = gtk_label_new ("None");
gtk_label_set_xalign (GTK_LABEL (label), 0.);
@@ -158,19 +186,23 @@ do_pickers (GtkWidget *do_widget)
g_signal_connect (button, "clicked", G_CALLBACK (open_file), label);
gtk_box_append (GTK_BOX (picker), label);
gtk_box_append (GTK_BOX (picker), button);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
label = gtk_label_new ("Application:");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 4, 1, 1);
app_picker = gtk_button_new_from_icon_name ("emblem-system-symbolic");
gtk_widget_set_halign (app_picker, GTK_ALIGN_END);
gtk_widget_set_sensitive (app_picker, FALSE);
g_signal_connect (app_picker, "clicked", G_CALLBACK (open_app), NULL);
gtk_grid_attach (GTK_GRID (table), app_picker, 1, 4, 1, 1);
gtk_box_append (GTK_BOX (picker), app_picker);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
label = gtk_label_new ("URI:");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
picker = gtk_button_new_with_label ("www.gtk.org");
g_signal_connect (picker, "clicked", G_CALLBACK (launch_uri), NULL);
gtk_grid_attach (GTK_GRID (table), picker, 1, 3, 1, 1);
}
if (!gtk_widget_get_visible (window))

View File

@@ -178,6 +178,16 @@ Creates a node like `gsk_inset_shadow_node_new()` with the given properties.
Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
### mask
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| source | `<node>` | color { } | always |
| mode | `<blend-mode>` | alpha | non-default |
| mask | `<node>` | color { } | always |
Creates a node like `gsk_mask_node_new()` with the given properties.
### opacity
| property | syntax | default | printed |
@@ -297,6 +307,21 @@ The default texture is a 10x10 checkerboard with the top left and bottom right
representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQYlWP8z3DmPwMaYGQwYUQXY0IXwAUGUCGGoxkYGBiweXAoeAYAz44F3e3U1xUAAAAASUVORK5CYII=")
`.
### texture-scale
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| texture | `<url>` | *see below* | always |
| filter | `filter` | *see below* | non-default |
Creates a node like `gsk_texture_scale_node_new()` with the given properties.
The default texture is a 10x10 checkerboard, just like for texture.
The possible filter values are `linear`, `nearest` and `trilinear`, with
`linear` being the default.
### transform
| property | syntax | default | printed |

View File

@@ -6,6 +6,8 @@
#include "demo_conf.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *main_window;
static GFile *filename = NULL;
static GtkPageSetup *page_setup = NULL;

View File

@@ -2056,6 +2056,67 @@ hide_widget (GtkWidget *widget)
gtk_widget_set_visible (widget, FALSE);
}
static void
load_texture_thread (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
{
const char *resource_path = (const char *) task_data;
GBytes *bytes;
GdkTexture *texture;
GError *error = NULL;
bytes = g_resources_lookup_data (resource_path, 0, &error);
if (!bytes)
{
g_task_return_error (task, error);
return;
}
texture = gdk_texture_new_from_bytes (bytes, &error);
g_bytes_unref (bytes);
if (!texture)
{
g_task_return_error (task, error);
return;
}
g_task_return_pointer (task, texture, g_object_unref);
}
static void
load_texture_done (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkWidget *picture = GTK_WIDGET (source);
GdkTexture *texture;
GError *error = NULL;
texture = g_task_propagate_pointer (G_TASK (result), &error);
if (!texture)
{
g_warning ("%s", error->message);
g_error_free (error);
return;
}
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (texture));
g_object_unref (texture);
}
static void
load_texture_in_thread (GtkWidget *picture,
const char *resource_path)
{
GTask *task = g_task_new (picture, NULL, load_texture_done, NULL);
g_task_set_task_data (task, (gpointer)resource_path, NULL);
g_task_run_in_thread (task, load_texture_thread);
g_object_unref (task);
}
static void
activate (GApplication *app)
{
@@ -2155,6 +2216,13 @@ activate (GApplication *app)
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
load_texture_in_thread ((GtkWidget *)gtk_builder_get_object (builder, "notebook_sunset"),
"/org/gtk/WidgetFactory4/sunset.jpg");
load_texture_in_thread ((GtkWidget *)gtk_builder_get_object (builder, "notebook_nyc"),
"/org/gtk/WidgetFactory4/nyc.jpg");
load_texture_in_thread ((GtkWidget *)gtk_builder_get_object (builder, "notebook_beach"),
"/org/gtk/WidgetFactory4/beach.jpg");
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
@@ -2184,11 +2252,13 @@ activate (GApplication *app)
for (i = 0; i < G_N_ELEMENTS (accels); i++)
gtk_application_set_accels_for_action (GTK_APPLICATION (app), accels[i].action_and_target, accels[i].accelerators);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
widget = (GtkWidget *)gtk_builder_get_object (builder, "statusbar");
gtk_statusbar_push (GTK_STATUSBAR (widget), 0, "All systems are operating normally.");
action = G_ACTION (g_property_action_new ("statusbar", widget, "visible"));
g_action_map_add_action (G_ACTION_MAP (window), action);
g_object_unref (G_OBJECT (action));
G_GNUC_END_IGNORE_DEPRECATIONS
widget = (GtkWidget *)gtk_builder_get_object (builder, "toolbar");
action = G_ACTION (g_property_action_new ("toolbar", widget, "visible"));
@@ -2362,6 +2432,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
widget = (GtkWidget *)gtk_builder_get_object (builder, "record_button");
g_object_set_data (G_OBJECT (window), "record_button", widget);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
widget = (GtkWidget *)gtk_builder_get_object (builder, "lockbox");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "lockbutton");
g_object_set_data (G_OBJECT (window), "lockbutton", widget2);
@@ -2379,6 +2450,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
G_BINDING_SYNC_CREATE);
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget2), permission);
g_object_unref (permission);
G_GNUC_END_IGNORE_DEPRECATIONS
widget = (GtkWidget *)gtk_builder_get_object (builder, "iconview1");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "increase_button");

View File

@@ -1263,8 +1263,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/sunset.jpg</property>
<object class="GtkPicture" id="notebook_sunset">
<property name="content-fit">cover</property>
<child>
<object class="GtkDragSource">
@@ -1290,8 +1289,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/nyc.jpg</property>
<object class="GtkPicture" id="notebook_nyc">
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>
@@ -1316,8 +1314,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkPicture">
<property name="file">resource:///org/gtk/WidgetFactory4/beach.jpg</property>
<object class="GtkPicture" id="notebook_beach">
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>

View File

@@ -18,12 +18,12 @@ search_index = true
docs_url = "https://docs.gtk.org/gobject/"
[dependencies."Gio-2.0"]
name = "GIO"
name = "Gio"
description = "GObject Interfaces and Objects, Networking, IPC, and I/O"
docs_url = "https://docs.gtk.org/gio/"
[dependencies."cairo-1.0"]
name = "Cairo"
name = "cairo"
description = "A 2D graphics library with support for multiple output devices"
docs_url = "https://www.cairographics.org/manual/"

View File

@@ -19,7 +19,7 @@ dependencies = ["Graphene-1.0", "Gdk-4.0"]
docs_url = "https://ebassi.github.io/graphene/docs/"
[dependencies."Gdk-4.0"]
name = "GDK"
name = "Gdk"
description = "The GTK windowing system abstraction"
docs_url = "https://docs.gtk.org/gdk4/"

View File

@@ -236,23 +236,17 @@ By default, GTK will try to build with support for the Vulkan graphics
API in addition to cairo and OpenGL. This option can be used to explicitly
control whether Vulkan should be used.
### `xinerama`
By default, GTK will try to link against the Xinerama libraries
if they are found. This option can be used to explicitly control
whether Xinerama should be used.
### `media`
### `media-gstreamer` and `media-ffmpeg`
By default, GTK will try to build the gstreamer backend for
media playback support. This option can be used to explicitly
media playback support. These options can be used to explicitly
control which media backends should be built.
### `print`
### `print-cups` and `print-cpdb`
By default, GTK will try to build various print backends
if their dependencies are found. This option can be used
to explicitly control which print backends should be built.
By default, GTK will try to build the cups and file print backends
if their dependencies are found. These options can be used to
explicitly control which print backends should be built.
### `cloudproviders`
@@ -274,18 +268,13 @@ support in the file chooser.
This option controls whether GTK should use colord for color
calibration support in the cups print backend.
### `gtk_doc` and `man-pages`
### `gtk_doc`, `man-pages` and `update_screenshots`
The *gtk-doc* package is used to generate the reference documentation
included with GTK. By default support for *gtk-doc* is disabled
The *gi-docgen* package is used to generate the reference documentation
included with GTK. By default support for *gi-docgen* is disabled
because it requires various extra dependencies to be installed.
If you have *gtk-doc* and *pandoc* installed and are modifying GTK,
you may want to enable *gtk-doc* support by passing in `-Dgtk_doc=true`.
Additionally, some tools provided by GTK have their own
manual pages generated using a similar set of dependencies;
if you have *xsltproc* then you can generate manual pages by
passing `-Dman-pages=true` when configuring the build.
Introspection needs to be enabled, since the documentation is generated
from introspection data.
### `introspection`
@@ -294,9 +283,14 @@ is mainly useful for shortening turnaround times on developer
systems. Installed builds of GTK should always have introspection
support.
### `build-tests`, `demos`
### `build-testsuite`
By default, GTK will build quite a few tests and demos.
If you want to run the testsuite to ensure that your GTK build
works, you should enable it with this option.
### `build-tests`, `build-examples`, `demos`
By default, GTK will build quite a few tests, examples and demos.
While these are useful on a developer system, they are not
needed when GTK is built e.g. for a flatpak runtime. These
options allow to disable building tests and demos.

View File

@@ -377,7 +377,7 @@ demonstrates input event handling with event controllers.
### Drawing in response to input
Create a new file with the following content named `example-4.c`.
Create a new file with the following content named `example-3.c`.
```c
#include <gtk/gtk.h>
@@ -572,7 +572,7 @@ main (int argc,
You can compile the program above with GCC using:
```
gcc $( pkg-config --cflags gtk4 ) -o example-4 example-4.c $( pkg-config --libs gtk4 )
gcc $( pkg-config --cflags gtk4 ) -o example-3 example-3.c $( pkg-config --libs gtk4 )
```
## Building user interfaces
@@ -587,7 +587,7 @@ XML format that can be parsed by the [class@Gtk.Builder] class.
### Packing buttons with GtkBuilder
Create a new file with the following content named `example-3.c`.
Create a new file with the following content named `example-4.c`.
```c
#include <gtk/gtk.h>
@@ -697,7 +697,7 @@ Create a new file with the following content named `builder.ui`.
You can compile the program above with GCC using:
```
gcc $( pkg-config --cflags gtk4 ) -o example-3 example-3.c $( pkg-config --libs gtk4 )
gcc $( pkg-config --cflags gtk4 ) -o example-4 example-4.c $( pkg-config --libs gtk4 )
```
Note that `GtkBuilder` can also be used to construct objects that are

View File

@@ -33,6 +33,11 @@ Validation
The ``validate`` command validates the given UI definition file and reports
errors to ``stderr``.
Note that there are limitations to the validation that can be done for templates,
since they are closely tied to the class_init function they are used in.
If your UI file uses types from third-party libraries, it may help to add those
libraries to the `LD_PRELOAD` environment variable.
``--deprecations``
Warn about uses of deprecated types in the UI definition file.

View File

@@ -14,12 +14,12 @@ search_index = true
dependencies = ["Gdk-4.0", "Gsk-4.0"]
[dependencies."Gdk-4.0"]
name = "GDK"
name = "Gdk"
description = "The GTK windowing system abstraction"
docs_url = "https://docs.gtk.org/gdk4/"
[dependencies."Gsk-4.0"]
name = "GSK"
name = "Gsk"
description = "The GTK rendering abstraction"
docs_url = "https://docs.gtk.org/gsk4/"

View File

@@ -105,3 +105,17 @@ retire it. If you need such a widget, it is relatively trivial to create one
using a [class@Gtk.Revealer] with labels and buttons.
Other libraries, such as libadwaita, may provide replacements as well.
## gtk_show_uri is being replaced
Instead of gtk_show_uri(), you should use GtkUriLauncher or GtkFileLauncher.
## GtkStatusbar is going away
This is an oldfashioned widget that does not do all that much anymore, since
it no longer has a resize handle for the window.
## GtkLockButton and GtkVolumeButton are going away
These are very specialized widgets that should better live with the application
where they are used.

View File

@@ -7,37 +7,50 @@ the question you have, this list is a good place to start.
## General Questions
1. How do I get started with GTK?
* How do I get started with GTK?
The GTK [website](https://www.gtk.org) offers some
[tutorials](https://www.gtk.org/documentation.php) and other documentation
(most of it about GTK 2.x and 3.x, but still somewhat applicable). This
reference manual also contains a introductory
This reference manual also contains a introductory
[Getting Started](#gtk-getting-started) part.
More documentation ranging from whitepapers to online books can be found at
the [GNOME developer's site](https://developer.gnome.org). After studying these
materials you should be well prepared to come back to this reference manual for details.
2. Where can I get help with GTK, submit a bug report, or make a feature request?
* Where can I get help with GTK, submit a bug report, or make a feature request?
See the [documentation](#gtk-resources) on this topic.
3. How do I port from one GTK version to another?
* How do I port from one GTK version to another?
See the [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
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
documentation.
4. How does memory management work in GTK? Should I free data returned from functions?
* Should I maintain parallel versions of my UI in GTK x and GTK y?
At the end of the day, that is up to you.
Our experience is that it is a lot of work, and usually not a good idea.
If you are not ready to make the jump to the next major version of GTK,
it is perfectly fine to stick with the stable release. We maintain them
for that reason.
* How does memory management work in GTK? Should I free data returned from functions?
See the documentation for `GObject` and `GInitiallyUnowned`. For `GObject` note
specifically `g_object_ref()` and `g_object_unref()`. `GInitiallyUnowned` is a
subclass of `GObject` so the same points apply, except that it has a "floating"
state (explained in its documentation).
In a widget tree, each container owns a reference to its children. The root
object (typically a `GtkWindow`) is owned by GTK. GTK will drop its reference
when you call [method@Gtk.Window.destroy].
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
@@ -46,7 +59,7 @@ the question you have, this list is a good place to start.
The transfer annotations for gobject-introspection that are part of the
documentation can provide useful hints for memory handling semantics as well.
5. Why does my program leak memory, if I destroy a widget immediately
* Why does my program leak memory, if I destroy a widget immediately
after creating it?
If `GtkFoo` isn't a toplevel window, then
@@ -69,7 +82,7 @@ the question you have, this list is a good place to start.
the initial floating reference and you don't have to worry about reference
counting at all ... just remove the widget from the container to get rid of it.
6. How do I use GTK with threads?
* How do I use GTK with threads?
GTK requires that all GTK API calls are made from the same thread in which
the `GtkApplication` was created, or `gtk_init()` was called (the _main thread_).
@@ -79,7 +92,7 @@ the question you have, this list is a good place to start.
the results back to the main thread using `g_idle_add()` or `GAsyncQueue`. GIO
offers useful tools for such an approach such as `GTask`.
7. How do I internationalize a GTK program?
* How do I internationalize a GTK program?
Most people use [GNU gettext](https://www.gnu.org/software/gettext/),
already required in order to install GLib. On a UNIX or Linux system with
@@ -134,7 +147,7 @@ the question you have, this list is a good place to start.
#define _(x) dgettext (GETTEXT_PACKAGE, x)
8. How do I use non-ASCII characters in GTK programs ?
* How do I use non-ASCII characters in GTK programs ?
GTK uses [Unicode](http://www.unicode.org) (more exactly UTF-8) for all text.
UTF-8 encodes each Unicode codepoint as a sequence of one to six bytes and
@@ -217,7 +230,7 @@ the question you have, this list is a good place to start.
to call bind_textdomain_codeset() to ensure that translated strings
are returned in UTF-8 encoding.
9. How do I use GTK with C++?
* How do I use GTK with C++?
There are two ways to approach this. The GTK header files use the subset
of C that's also valid C++, so you can simply use the normal GTK API
@@ -242,19 +255,23 @@ the question you have, this list is a good place to start.
There are very few functions that require this cast, however.
10. How do I use GTK with other non-C languages?
* How do I use GTK with other non-C languages?
See the list of [language bindings](https://www.gtk.org/language-bindings.php)
on the GTK [website](https://www.gtk.org).
11. How do I load an image or animation from a file?
* How do I load an image or animation from a file?
To load an image file straight into a display widget, use
[ctor@Gtk.Image.new_from_file]. To load an image for another purpose, use
[ctor@Gdk.Texture.new_from_file]. To load a video from a file, use
[ctor@Gtk.MediaFile.new_for_file].
[ctor@Gtk.Picture.new_for_file] or [ctor@GTk.Picture.new_for_filename].
To load an image for another purpose, use [ctor@Gdk.Texture.new_from_file].
To load a video from a file, use [ctor@Gtk.MediaFile.new_for_file].
12. How do I draw text?
* How do I draw text?
If you just want to put text into your user interface somewhere, it is
usually easiest to just use one of ready-made widgets for this purpose,
such as [class@Gtk.Label].
To draw a piece of text onto a cairo surface, use a Pango layout and
[func@PangoCairo.show_layout].
@@ -272,7 +289,7 @@ the question you have, this list is a good place to start.
To draw a piece of text in a widget [vfunc@Gtk.Widget.snapshot] implementation,
use [method@Gtk.Snapshot.append_layout].
13. How do I measure the size of a piece of text?
* How do I measure the size of a piece of text?
To obtain the size of a piece of text, use a Pango layout and
[method@Pango.Layout.get_pixel_size], using code like the following:
@@ -287,7 +304,7 @@ the question you have, this list is a good place to start.
See also the [Layout Objects](https://developer.gnome.org/pango/stable/pango-Layout-Objects.html)
section of the [Pango documentation](https://developer.gnome.org/pango/stable/).
14. Why are types not registered if I use their `GTK_TYPE_BLAH` macro?
* Why are types not registered if I use their `GTK_TYPE_BLAH` macro?
The %GTK_TYPE_BLAH macros are defined as calls to gtk_blah_get_type(), and
the `_get_type()` functions are declared as %G_GNUC_CONST which allows the
@@ -298,14 +315,14 @@ the question you have, this list is a good place to start.
g_type_ensure (GTK_TYPE_BLAH);
15. How do I create a transparent toplevel window?
* How do I create a transparent toplevel window?
Any toplevel window can be transparent. It is just a matter of setting a
transparent background in the CSS style for it.
## Which widget should I use...
16. ...for lists and trees?
* ...for lists and trees?
This question has different answers, depending on the size of the dataset
and the required formatting flexibility.
@@ -321,7 +338,7 @@ the question you have, this list is a good place to start.
and widgetry inside the list, then you probably want to use a [class@Gtk.ListBox],
which uses regular widgets for display.
17. ...for multi-line text display or editing?
* ...for multi-line text display or editing?
See the [text widget overview](#TextWidget) -- you should use the
[class@Gtk.TextView] widget.
@@ -330,7 +347,7 @@ the question you have, this list is a good place to start.
of course. It can be made selectable with [method@Gtk.Label.set_selectable]. For a
single-line text entry, see [class@Gtk.Entry].
18. ...to display an image or animation?
* ...to display an image or animation?
GTK has two widgets that are dedicated to displaying images. [class@Gtk.Image], for
small, fixed-size icons and [class@Gtk.Picture] for content images.
@@ -346,17 +363,14 @@ the question you have, this list is a good place to start.
mediafile = gtk_media_file_new_for_filename ("example.webm");
picture = gtk_picture_new_for_paintable (GDK_PAINTABLE (mediafile));
19. ...for presenting a set of mutually-exclusive choices, where Windows
* ...for presenting a set of mutually-exclusive choices, where Windows
would use a combo box?
With GTK, a [class@Gtk.ComboBox] is the recommended widget to use for this use case.
If you need an editable text entry, use the [property@Gtk.ComboBox:has-entry] property.
A newer alternative is [class@Gtk.DropDown].
With GTK, a [class@Gtk.DropDown] is the recommended widget to use for this use case.
## Questions about GtkWidget
20. How do I change the color of a widget?
* How do I change the color of a widget?
The background color of a widget is determined by the CSS style that applies
to it. To change that, you can set style classes on the widget, and provide
@@ -364,7 +378,7 @@ the question you have, this list is a good place to start.
[method@Gtk.CssProvider.load_from_file] and its variants.
See [method@Gtk.StyleContext.add_provider].
21. How do I change the font of a widget?
* How do I change the font of a widget?
If you want to make the text of a label larger, you can use
gtk_label_set_markup():
@@ -388,14 +402,14 @@ the question you have, this list is a good place to start.
of this approach is that users can then override the font you have chosen.
See the `GtkStyleContext` documentation for more discussion.
22. How do I disable/ghost/desensitize a widget?
* How do I disable/ghost/desensitize a widget?
In GTK a disabled widget is termed _insensitive_.
See [method@Gtk.Widget.set_sensitive].
## GtkTextView questions
23. How do I get the contents of the entire text widget as a string?
* How do I get the contents of the entire text widget as a string?
See [method@Gtk.TextBuffer.get_bounds] and [method@Gtk.TextBuffer.get_text]
or [method@Gtk.TextIter.get_text].
@@ -410,14 +424,14 @@ the question you have, this list is a good place to start.
/* use text */
g_free (text);
24. How do I make a text widget display its complete contents in a specific font?
* How do I make a text widget display its complete contents in a specific font?
If you use [method@Gtk.TextBuffer.insert_with_tags] with appropriate tags to
select the font, the inserted text will have the desired appearance, but
text typed in by the user before or after the tagged block will appear in
the default style.
25. How do I make a text view scroll to the end of the buffer automatically ?
* How do I make a text view scroll to the end of the buffer automatically ?
A good way to keep a text buffer scrolled to the end is to place a
[mark](#GtkTextMark) at the end of the buffer, and give it right gravity.
@@ -432,21 +446,21 @@ the question you have, this list is a good place to start.
## GtkTreeView questions
26. How do I associate some data with a row in the tree?
* How do I associate some data with a row in the tree?
Remember that the [iface@Gtk.TreeModel] columns don't necessarily have to be
displayed. So you can put non-user-visible data in your model just
like any other data, and retrieve it with [method@Gtk.TreeModel.get].
See the [tree widget overview](#TreeWidget).
27. How do I put an image and some text in the same column?
* How do I put an image and some text in the same column?
You can pack more than one [class@Gtk.CellRenderer] into a single [class@Gtk.TreeViewColumn]
using [method@Gtk.TreeViewColumn.pack_start] or [method@Gtk.TreeViewColumn.pack_end].
So pack both a [class@Gtk.CellRendererPixbuf] and a [class@Gtk.CellRendererText] into the
column.
28. I can set data easily on my [class@Gtk.TreeStore] or [class@Gtk.ListStore] models using
* I can set data easily on my [class@Gtk.TreeStore] or [class@Gtk.ListStore] models using
[method@Gtk.ListStore.set] and [method@Gtk.TreeStore.set], but can't read it back?
Both the [class@Gtk.TreeStore] and the [class@Gtk.ListStore] implement the [iface@Gtk.TreeModel]
@@ -454,7 +468,7 @@ the question you have, this list is a good place to start.
implements. The easiest way to read a set of data back is to use
[method@Gtk.TreeModel.get].
29. How do I change the way that numbers are formatted by `GtkTreeView`?
* How do I change the way that numbers are formatted by `GtkTreeView`?
Use [method@Gtk.TreeView.insert_column_with_data_func] or
[method@Gtk.TreeViewColumn.set_cell_data_func] and do the conversion
@@ -528,19 +542,21 @@ the question you have, this list is a good place to start.
(gpointer)DOUBLE_COLUMN, NULL);
}
30. How do I hide the expander arrows in my tree view?
* How do I hide the expander arrows in my tree view?
Set the expander-column property of the tree view to a hidden column.
See [method@Gtk.TreeView.set_expander_column] and [method@Gtk.TreeViewColumn.set_visible].
## Using cairo with GTK
31. How do I use cairo to draw in GTK applications?
* How do I use cairo to draw in GTK applications?
Use [method@Gtk.Snapshot.append_cairo] in your [vfunc@Gtk.Widget.snapshot] vfunc
to obtain a cairo context and draw with that.
[class@Gtk.DrawingArea] is a ready-made widget for drawing with cairo.
32. Can I improve the performance of my application by using another backend
If you implement a custom widget, use [method@Gtk.Snapshot.append_cairo]
in your [vfunc@Gtk.Widget.snapshot] vfunc to obtain a cairo context and draw with that.
* Can I improve the performance of my application by using another backend
of cairo (such as GL)?
No. Most drawing in GTK is not done via cairo anymore (but instead
@@ -551,7 +567,7 @@ the question you have, this list is a good place to start.
If you are interested in using GL for your own drawing, see [class@Gtk.GLArea].
33. Can I use cairo to draw on a `GdkPixbuf`?
* Can I use cairo to draw on a `GdkPixbuf`?
No. The cairo image surface does not support the pixel format used by `GdkPixbuf`.

View File

@@ -37,7 +37,7 @@ main (int argc,
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);

View File

@@ -213,6 +213,7 @@ typedef enum {
BROADWAY_REQUEST_RELEASE_TEXTURE,
BROADWAY_REQUEST_SET_NODES,
BROADWAY_REQUEST_ROUNDTRIP,
BROADWAY_REQUEST_SET_MODAL_HINT,
} BroadwayRequestType;
typedef struct {
@@ -293,6 +294,12 @@ typedef struct {
guint32 show_keyboard;
} BroadwayRequestSetShowKeyboard;
typedef struct {
BroadwayRequestBase base;
guint32 id;
gboolean modal_hint;
} BroadwayRequestSetModalHint;
typedef union {
BroadwayRequestBase base;
BroadwayRequestNewSurface new_surface;
@@ -312,6 +319,7 @@ typedef union {
BroadwayRequestUploadTexture upload_texture;
BroadwayRequestReleaseTexture release_texture;
BroadwayRequestSetNodes set_nodes;
BroadwayRequestSetModalHint set_modal_hint;
} BroadwayRequest;
typedef enum {

View File

@@ -124,6 +124,7 @@ struct BroadwaySurface {
gboolean visible;
gint32 transient_for;
guint32 texture;
gboolean modal_hint;
BroadwayNode *nodes;
GHashTable *node_lookup;
};
@@ -421,6 +422,14 @@ update_event_state (BroadwayServer *server,
{
surface->x = message->configure_notify.x;
surface->y = message->configure_notify.y;
if (server->focused_surface_id != message->configure_notify.id &&
server->pointer_grab_surface_id == -1 && surface->modal_hint)
{
broadway_server_surface_raise (server, message->configure_notify.id);
broadway_server_focus_surface (server, message->configure_notify.id);
broadway_server_flush (server);
}
}
break;
case BROADWAY_EVENT_ROUNDTRIP_NOTIFY:
@@ -1568,6 +1577,7 @@ broadway_server_destroy_surface (BroadwayServer *server,
int id)
{
BroadwaySurface *surface;
gint32 transient_for = -1;
if (server->mouse_in_surface_id == id)
{
@@ -1585,11 +1595,24 @@ broadway_server_destroy_surface (BroadwayServer *server,
surface = broadway_server_lookup_surface (server, id);
if (surface != NULL)
{
if (server->focused_surface_id == id)
transient_for = surface->transient_for;
server->surfaces = g_list_remove (server->surfaces, surface);
g_hash_table_remove (server->surface_id_hash,
GINT_TO_POINTER (id));
broadway_surface_free (server, surface);
}
if (transient_for != -1)
{
surface = broadway_server_lookup_surface (server, transient_for);
if (surface != NULL)
{
broadway_server_focus_surface (server, transient_for);
broadway_server_flush (server);
}
}
}
gboolean
@@ -1710,6 +1733,19 @@ broadway_server_surface_set_transient_for (BroadwayServer *server,
}
}
void
broadway_server_surface_set_modal_hint (BroadwayServer *server,
int id, gboolean modal_hint)
{
BroadwaySurface *surface;
surface = broadway_server_lookup_surface (server, id);
if (surface == NULL)
return;
surface->modal_hint = modal_hint;
}
gboolean
broadway_server_has_client (BroadwayServer *server)
{

View File

@@ -130,6 +130,9 @@ gboolean broadway_server_surface_move_resize (BroadwayServer *
int height);
void broadway_server_focus_surface (BroadwayServer *server,
int new_focused_surface);
void broadway_server_surface_set_modal_hint (BroadwayServer *server,
int id,
gboolean modal_hint);
#endif /* __BROADWAY_SERVER__ */

View File

@@ -380,6 +380,11 @@ client_handle_request (BroadwayClient *client,
case BROADWAY_REQUEST_SET_SHOW_KEYBOARD:
broadway_server_set_show_keyboard (server, request->set_show_keyboard.show_keyboard);
break;
case BROADWAY_REQUEST_SET_MODAL_HINT:
broadway_server_surface_set_modal_hint (server,
request->set_modal_hint.id,
request->set_modal_hint.modal_hint);
break;
default:
g_warning ("Unknown request of type %d", request->base.type);
}

View File

@@ -561,6 +561,18 @@ _gdk_broadway_server_surface_set_transient_for (GdkBroadwayServer *server,
BROADWAY_REQUEST_SET_TRANSIENT_FOR);
}
void
_gdk_broadway_server_surface_set_modal_hint (GdkBroadwayServer *server,
int id, gboolean modal_hint)
{
BroadwayRequestSetModalHint msg;
msg.id = id;
msg.modal_hint = modal_hint;
gdk_broadway_server_send_message (server, msg,
BROADWAY_REQUEST_SET_MODAL_HINT);
}
static int
open_shared_memory (void)
{

View File

@@ -78,5 +78,8 @@ gboolean _gdk_broadway_server_surface_move_resize (GdkBroadwaySe
int y,
int width,
int height);
void _gdk_broadway_server_surface_set_modal_hint (GdkBroadwayServer *server,
int id,
gboolean modal_hint);
#endif /* __GDK_BROADWAY_SERVER__ */

View File

@@ -82,6 +82,27 @@ gdk_event_source_check (GSource *source)
return retval;
}
static void
handle_focus_change (GdkEvent *event)
{
GdkEvent *focus_event;
gboolean focus_in = (gdk_event_get_event_type (event) == GDK_ENTER_NOTIFY);
if (gdk_crossing_event_get_detail (event) == GDK_NOTIFY_INFERIOR)
return;
if (!gdk_crossing_event_get_focus (event) )
return;
focus_event = gdk_focus_event_new (gdk_event_get_surface (event),
gdk_event_get_device (event),
focus_in);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gdk_display_put_event (gdk_event_get_display (event), focus_event);
G_GNUC_END_IGNORE_DEPRECATIONS
gdk_event_unref (focus_event);
}
void
_gdk_broadway_events_got_input (GdkDisplay *display,
BroadwayInputMsg *message)
@@ -110,6 +131,8 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, message->base.serial);
handle_focus_change (event);
}
break;
case BROADWAY_EVENT_LEAVE:
@@ -126,6 +149,8 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
message->crossing.mode,
GDK_NOTIFY_ANCESTOR);
handle_focus_change (event);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, message->base.serial);
}

View File

@@ -709,6 +709,21 @@ gdk_broadway_surface_set_transient_for (GdkSurface *surface,
_gdk_broadway_server_surface_set_transient_for (display->server, impl->id, impl->transient_for);
}
static void
gdk_broadway_surface_set_modal_hint (GdkSurface *surface,
gboolean modal)
{
GdkBroadwayDisplay *display;
GdkBroadwaySurface *impl;
impl = GDK_BROADWAY_SURFACE (surface);
impl->modal_hint = modal;
display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
_gdk_broadway_server_surface_set_modal_hint (display->server, impl->id, impl->modal_hint);
}
static void
gdk_broadway_surface_get_geometry (GdkSurface *surface,
int *x,
@@ -1433,6 +1448,8 @@ gdk_broadway_toplevel_set_property (GObject *object,
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
gdk_broadway_surface_set_modal_hint (surface, g_value_get_boolean (value));
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
@@ -1479,6 +1496,10 @@ gdk_broadway_toplevel_get_property (GObject *object,
g_value_set_object (value, surface->transient_for);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
g_value_set_boolean (value, surface->modal_hint);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_ICON_LIST:
g_value_set_pointer (value, NULL);
break;

View File

@@ -54,6 +54,7 @@ struct _GdkBroadwaySurface
gboolean dirty;
gboolean last_synced;
gboolean modal_hint;
GdkGeometry geometry_hints;
GdkSurfaceHints geometry_hints_mask;

View File

@@ -26,6 +26,7 @@
#include "gdkcontentformats.h"
#include "gdkcontentserializer.h"
#include "gdkcontentdeserializer.h"
#include "gdkdebugprivate.h"
#include <gio/gio.h>
@@ -213,6 +214,8 @@ file_transfer_portal_register_files (const char **files,
afd->len = g_strv_length ((char **)files);
afd->start = 0;
GDK_DEBUG (DND, "file transfer portal: registering %d files", afd->len);
g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&options, "{sv}", "writable", g_variant_new_boolean (writable));
g_variant_builder_add (&options, "{sv}", "autostop", g_variant_new_boolean (TRUE));
@@ -348,9 +351,8 @@ portal_ready (GObject *object,
static void
portal_file_serializer (GdkContentSerializer *serializer)
{
GFile *file;
const GValue *value;
GPtrArray *files;
const GValue *value;
files = g_ptr_array_new_with_free_func (g_free);
@@ -358,9 +360,24 @@ portal_file_serializer (GdkContentSerializer *serializer)
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
GFile *file;
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
if (file)
g_ptr_array_add (files, g_file_get_path (file));
if (file && g_file_peek_path (file))
{
GDK_DEBUG (DND, "file transfer portal: Adding %s", g_file_peek_path (file));
g_ptr_array_add (files, g_file_get_path (file));
}
#ifdef G_ENABLE_DEBUG
else if (GDK_DEBUG_CHECK (DND))
{
char *uri = g_file_get_uri (file);
gdk_debug_message ("file transfer portal: %s has no path, dropping\n", uri);
g_free (uri);
}
#endif
g_ptr_array_add (files, NULL);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
@@ -368,7 +385,21 @@ portal_file_serializer (GdkContentSerializer *serializer)
GSList *l;
for (l = g_value_get_boxed (value); l; l = l->next)
g_ptr_array_add (files, g_file_get_path (l->data));
{
GFile *file = l->data;
if (file && g_file_peek_path (file))
{
GDK_DEBUG (DND, "file transfer portal: Adding %s", g_file_peek_path (file));
g_ptr_array_add (files, g_file_get_path (file));
}
else
{
char *uri = g_file_get_uri (file);
gdk_debug_message ("file transfer portal: %s has no path, dropping", uri);
g_free (uri);
}
}
g_ptr_array_add (files, NULL);
}
@@ -395,6 +426,15 @@ portal_finish (GObject *object,
return;
}
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (DND))
{
char *s = g_strjoinv (", ", files);
gdk_debug_message ("file transfer portal: Receiving files: %s", s);
g_free (s);
}
#endif
value = gdk_content_deserializer_get_value (deserializer);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{

View File

@@ -69,6 +69,7 @@
#include <gdk/gdksnapshot.h>
#include <gdk/gdksurface.h>
#include <gdk/gdktexture.h>
#include <gdk/gdktexturedownloader.h>
#include <gdk/gdktoplevel.h>
#include <gdk/gdktoplevellayout.h>
#include <gdk/gdktoplevelsize.h>

View File

@@ -471,8 +471,8 @@ gdk_display_get_event (GdkDisplay *display)
* Appends the given event onto the front of the event
* queue for @display.
*
* This function is only useful in very special situations
* and should not be used by applications.
* Deprecated: 4.10: This function is only useful in very
* special situations and should not be used by applications.
**/
void
gdk_display_put_event (GdkDisplay *display,
@@ -1114,7 +1114,7 @@ gdk_display_get_app_launch_context (GdkDisplay *display)
/**
* gdk_display_open:
* @display_name: the name of the display to open
* @display_name: (nullable): the name of the display to open
*
* Opens a display.
*
@@ -1148,6 +1148,8 @@ _gdk_display_get_next_serial (GdkDisplay *display)
* with custom startup-notification identifier unless
* [method@Gtk.Window.set_auto_startup_notification]
* is called to disable that feature.
*
* Deprecated: 4.10: Using [method@Gdk.Toplevel.set_startup_id] is sufficient
*/
void
gdk_display_notify_startup_complete (GdkDisplay *display,
@@ -1166,6 +1168,8 @@ gdk_display_notify_startup_complete (GdkDisplay *display,
* if no ID has been defined.
*
* Returns: (nullable): the startup notification ID for @display
*
* Deprecated: 4.10
*/
const char *
gdk_display_get_startup_notification_id (GdkDisplay *display)
@@ -1775,11 +1779,11 @@ gdk_display_init_egl (GdkDisplay *self,
gpointer
gdk_display_get_egl_display (GdkDisplay *self)
{
#ifdef HAVE_EGL
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
#ifdef HAVE_EGL
if (!priv->egl_display &&
!gdk_display_prepare_gl (self, NULL))
return NULL;
@@ -2013,10 +2017,7 @@ gdk_display_get_monitors (GdkDisplay *self)
* Gets the monitor in which the largest area of @surface
* resides.
*
* Returns a monitor close to @surface if it is outside
* of all monitors.
*
* Returns: (transfer none): the monitor with the largest
* Returns: (transfer none) (nullable): the monitor with the largest
* overlap with @surface
*/
GdkMonitor *

View File

@@ -83,10 +83,10 @@ GdkClipboard * gdk_display_get_clipboard (GdkDisplay
GDK_AVAILABLE_IN_ALL
GdkClipboard * gdk_display_get_primary_clipboard (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10_FOR(gdk_toplevel_set_startup_id)
void gdk_display_notify_startup_complete (GdkDisplay *display,
const char *startup_id);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
const char * gdk_display_get_startup_notification_id (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
@@ -104,7 +104,7 @@ GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display,
GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gdk_display_put_event (GdkDisplay *display,
GdkEvent *event);

View File

@@ -1511,7 +1511,6 @@ gdk_button_event_get_button (GdkEvent *event)
}
/* }}} */
/* {{{ GdkKeyEvent */
/**
@@ -1972,7 +1971,6 @@ gdk_key_event_get_match (GdkEvent *event,
}
/* }}} */
/* {{{ GdkTouchEvent */
/**
@@ -2109,7 +2107,6 @@ gdk_touch_event_get_emulating_pointer (GdkEvent *event)
}
/* }}} */
/* {{{ GdkCrossingEvent */
/**
@@ -2253,7 +2250,6 @@ gdk_crossing_event_get_detail (GdkEvent *event)
}
/* }}} */
/* {{{ GdkDeleteEvent */
/**
@@ -2284,7 +2280,6 @@ gdk_delete_event_new (GdkSurface *surface)
}
/* }}} */
/* {{{ GdkFocusEvent */
/**
@@ -2341,7 +2336,6 @@ gdk_focus_event_get_in (GdkEvent *event)
}
/* }}} */
/* {{{ GdkScrollEvent */
/**
@@ -2600,7 +2594,6 @@ gdk_scroll_event_get_unit (GdkEvent *event)
}
/* }}} */
/* {{{ GdkTouchpadEvent */
/**
@@ -2859,7 +2852,6 @@ gdk_touchpad_event_get_pinch_scale (GdkEvent *event)
}
/* }}} */
/* {{{ GdkPadEvent */
/**
@@ -3033,7 +3025,6 @@ gdk_pad_event_get_group_mode (GdkEvent *event,
}
/* }}} */
/* {{{ GdkMotionEvent */
/**
@@ -3195,7 +3186,6 @@ gdk_event_get_history (GdkEvent *event,
}
/* }}} */
/* {{{ GdkProximityEvent */
/**
@@ -3258,7 +3248,6 @@ gdk_proximity_event_new (GdkEventType type,
}
/* }}} */
/* {{{ GdkDNDEvent */
/**
@@ -3364,7 +3353,6 @@ gdk_dnd_event_get_drop (GdkEvent *event)
}
/* }}} */
/* {{{ GdkGrabBrokenEvent */
/**
@@ -3442,3 +3430,5 @@ gdk_grab_broken_event_get_implicit (GdkEvent *event)
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

View File

@@ -584,6 +584,8 @@ gdk_frame_clock_paint_idle (void *data)
{
priv->requested &= ~GDK_FRAME_CLOCK_PHASE_LAYOUT;
_gdk_frame_clock_emit_layout (clock);
if (priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT)
g_print ("looping in layout %d\n", iter);
}
if (iter == 5)
g_warning ("gdk-frame-clock: layout continuously requested, giving up after 4 tries");
@@ -621,8 +623,11 @@ gdk_frame_clock_paint_idle (void *data)
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
}
#ifdef G_ENABLE_DEBUG
if (GDK_DEBUG_CHECK (FRAMES))
timings->frame_end_time = g_get_monotonic_time ();
if (GDK_DEBUG_CHECK (FRAMES))
{
if (timings)
timings->frame_end_time = g_get_monotonic_time ();
}
#endif /* G_ENABLE_DEBUG */
G_GNUC_FALLTHROUGH;
@@ -806,3 +811,12 @@ _gdk_frame_clock_idle_new (void)
return GDK_FRAME_CLOCK (clock);
}
GdkFrameClockPhase
gdk_frame_clock_get_current_phase (GdkFrameClock *clock)
{
GdkFrameClockIdle *clock_idle = GDK_FRAME_CLOCK_IDLE (clock);
GdkFrameClockIdlePrivate *priv = clock_idle->priv;
return priv->phase;
}

View File

@@ -127,6 +127,8 @@ void _gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock);
void _gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock);
void _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock);
GdkFrameClockPhase gdk_frame_clock_get_current_phase (GdkFrameClock *frame_clock);
G_END_DECLS
#endif /* __GDK_FRAME_CLOCK_PRIVATE_H__ */

View File

@@ -501,11 +501,23 @@ gdk_gl_context_real_is_shared (GdkGLContext *self,
return TRUE;
}
static gboolean
gdk_gl_context_real_is_current (GdkGLContext *self)
{
#ifdef HAVE_EGL
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
return priv->egl_context == eglGetCurrentContext ();
#else
return TRUE;
#endif
}
static gboolean
gdk_gl_context_real_clear_current (GdkGLContext *context)
{
GdkDisplay *display = gdk_gl_context_get_display (context);
#ifdef HAVE_EGL
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
if (priv->egl_context == NULL)
@@ -670,6 +682,7 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
klass->is_shared = gdk_gl_context_real_is_shared;
klass->make_current = gdk_gl_context_real_make_current;
klass->clear_current = gdk_gl_context_real_clear_current;
klass->is_current = gdk_gl_context_real_is_current;
klass->get_default_framebuffer = gdk_gl_context_real_get_default_framebuffer;
draw_context_class->begin_frame = gdk_gl_context_real_begin_frame;
@@ -1551,6 +1564,12 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->extensions_checked = TRUE;
}
static gboolean
gdk_gl_context_check_is_current (GdkGLContext *context)
{
return GDK_GL_CONTEXT_GET_CLASS (context)->is_current (context);
}
/**
* gdk_gl_context_make_current:
* @context: a `GdkGLContext`
@@ -1569,7 +1588,7 @@ gdk_gl_context_make_current (GdkGLContext *context)
masked_context = mask_context (context, surfaceless);
current = g_private_get (&thread_current_context);
if (current == masked_context)
if (current == masked_context && gdk_gl_context_check_is_current (context))
return;
/* we need to realize the GdkGLContext if it wasn't explicitly realized */
@@ -1740,10 +1759,18 @@ GdkGLContext *
gdk_gl_context_get_current (void)
{
MaskedContext *current;
GdkGLContext *context;
current = g_private_get (&thread_current_context);
context = unmask_context (current);
return unmask_context (current);
if (context && !gdk_gl_context_check_is_current (context))
{
g_private_replace (&thread_current_context, NULL);
context = NULL;
}
return context;
}
gboolean

View File

@@ -83,6 +83,7 @@ struct _GdkGLContextClass
gboolean (* make_current) (GdkGLContext *context,
gboolean surfaceless);
gboolean (* clear_current) (GdkGLContext *context);
gboolean (* is_current) (GdkGLContext *context);
cairo_region_t * (* get_damage) (GdkGLContext *context);
gboolean (* is_shared) (GdkGLContext *self,

View File

@@ -24,7 +24,6 @@
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
#include <epoxy/gl.h>
@@ -53,10 +52,8 @@ struct _GdkGLTextureClass {
G_DEFINE_TYPE (GdkGLTexture, gdk_gl_texture, GDK_TYPE_TEXTURE)
static void
gdk_gl_texture_dispose (GObject *object)
drop_gl_resources (GdkGLTexture *self)
{
GdkGLTexture *self = GDK_GL_TEXTURE (object);
if (self->destroy)
{
self->destroy (self->data);
@@ -66,17 +63,29 @@ gdk_gl_texture_dispose (GObject *object)
g_clear_object (&self->context);
self->id = 0;
}
static void
gdk_gl_texture_dispose (GObject *object)
{
GdkGLTexture *self = GDK_GL_TEXTURE (object);
drop_gl_resources (self);
g_clear_object (&self->saved);
G_OBJECT_CLASS (gdk_gl_texture_parent_class)->dispose (object);
}
typedef void (* GLFunc) (GdkGLTexture *self,
GdkGLContext *context,
gpointer data);
typedef struct _InvokeData
{
GdkGLTexture *self;
volatile int spinlock;
GFunc func;
GLFunc func;
gpointer data;
} InvokeData;
@@ -91,7 +100,7 @@ gdk_gl_texture_invoke_callback (gpointer data)
gdk_gl_context_make_current (context);
glBindTexture (GL_TEXTURE_2D, invoke->self->id);
invoke->func (invoke->self, invoke->data);
invoke->func (invoke->self, context, invoke->data);
g_atomic_int_set (&invoke->spinlock, 1);
@@ -100,7 +109,7 @@ gdk_gl_texture_invoke_callback (gpointer data)
static void
gdk_gl_texture_run (GdkGLTexture *self,
GFunc func,
GLFunc func,
gpointer data)
{
InvokeData invoke = { self, 0, func, data };
@@ -145,19 +154,19 @@ gdk_gl_texture_find_format (gboolean use_es,
}
static inline void
gdk_gl_texture_do_download (gpointer texture_,
gpointer download_)
gdk_gl_texture_do_download (GdkGLTexture *self,
GdkGLContext *context,
gpointer download_)
{
GdkTexture *texture = GDK_TEXTURE (self);
gsize expected_stride;
GdkGLTexture *self = texture_;
GdkTexture *texture = texture_;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
if (download->stride == expected_stride &&
!gdk_gl_context_get_use_es (self->context) &&
!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type))
{
glGetTexImage (GL_TEXTURE_2D,
@@ -175,11 +184,11 @@ gdk_gl_texture_do_download (gpointer texture_,
glGenFramebuffers (1, &fbo);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (self->context, 4, 3, 3, 1))
if (gdk_gl_context_check_version (context, 4, 3, 3, 1))
{
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (self->context), gl_read_format, gl_read_type, &actual_format))
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
@@ -193,7 +202,7 @@ gdk_gl_texture_do_download (gpointer texture_,
(download->stride == expected_stride))
{
glReadPixels (0, 0,
texture->width, texture->height,
texture->width, texture->height,
gl_read_format,
gl_read_type,
download->data);
@@ -204,7 +213,7 @@ gdk_gl_texture_do_download (gpointer texture_,
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
glReadPixels (0, 0,
texture->width, texture->height,
texture->width, texture->height,
gl_read_format,
gl_read_type,
pixels);
@@ -297,15 +306,7 @@ gdk_gl_texture_release (GdkGLTexture *self)
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture)));
if (self->destroy)
{
self->destroy (self->data);
self->destroy = NULL;
self->data = NULL;
}
g_clear_object (&self->context);
self->id = 0;
drop_gl_resources (self);
}
static void

View File

@@ -222,7 +222,7 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, format, data, stride);
bytes = g_bytes_new_take (data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
format,
@@ -233,15 +233,11 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
return GDK_MEMORY_TEXTURE (result);
}
const guchar *
gdk_memory_texture_get_data (GdkMemoryTexture *self)
GBytes *
gdk_memory_texture_get_bytes (GdkMemoryTexture *self,
gsize *out_stride)
{
return g_bytes_get_data (self->bytes, NULL);
}
gsize
gdk_memory_texture_get_stride (GdkMemoryTexture *self)
{
return self->stride;
*out_stride = self->stride;
return self->bytes;
}

View File

@@ -37,8 +37,8 @@ GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *
int width,
int height);
const guchar * gdk_memory_texture_get_data (GdkMemoryTexture *self);
gsize gdk_memory_texture_get_stride (GdkMemoryTexture *self);
GBytes * gdk_memory_texture_get_bytes (GdkMemoryTexture *self,
gsize *out_stride);
G_END_DECLS

View File

@@ -39,6 +39,7 @@
enum {
PROP_0,
PROP_DESCRIPTION,
PROP_DISPLAY,
PROP_MANUFACTURER,
PROP_MODEL,
@@ -81,6 +82,10 @@ gdk_monitor_get_property (GObject *object,
switch (prop_id)
{
case PROP_DESCRIPTION:
g_value_set_string (value, monitor->description);
break;
case PROP_DISPLAY:
g_value_set_object (value, monitor->display);
break;
@@ -154,6 +159,7 @@ gdk_monitor_finalize (GObject *object)
{
GdkMonitor *monitor = GDK_MONITOR (object);
g_free (monitor->description);
g_free (monitor->connector);
g_free (monitor->manufacturer);
g_free (monitor->model);
@@ -170,6 +176,18 @@ gdk_monitor_class_init (GdkMonitorClass *class)
object_class->get_property = gdk_monitor_get_property;
object_class->set_property = gdk_monitor_set_property;
/**
* GdkMonitor:description: (attributes org.gtk.Property.get=gdk_monitor_get_description)
*
* A short description of the monitor, meant for display to the user.
*
* Since: 4.10
*/
props[PROP_DESCRIPTION] =
g_param_spec_string ("description", NULL, NULL,
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* GdkMonitor:display: (attributes org.gtk.Property.get=gdk_monitor_get_display)
*
@@ -377,6 +395,10 @@ gdk_monitor_get_height_mm (GdkMonitor *monitor)
*
* Gets the name of the monitor's connector, if available.
*
* These are strings such as "eDP-1", or "HDMI-2". They depend
* on software and hardware configuration, and should not be
* relied on as stable identifiers of a specific monitor.
*
* Returns: (transfer none) (nullable): the name of the connector
*/
const char *
@@ -619,3 +641,33 @@ gdk_monitor_is_valid (GdkMonitor *monitor)
return monitor->valid;
}
/**
* gdk_monitor_get_description: (attributes org.gtk.Method.get_property=description)
* @monitor: a `GdkMonitor`
*
* Gets a string describing the monitor, if available.
*
* This can be used to identify a monitor in the UI.
*
* Returns: (transfer none) (nullable): the monitor description
*
* Since: 4.10
*/
const char *
gdk_monitor_get_description (GdkMonitor *monitor)
{
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
return monitor->description;
}
void
gdk_monitor_set_description (GdkMonitor *monitor,
const char *description)
{
g_free (monitor->description);
monitor->description = g_strdup (description);
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
}

View File

@@ -86,6 +86,8 @@ GDK_AVAILABLE_IN_ALL
GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
gboolean gdk_monitor_is_valid (GdkMonitor *monitor);
GDK_AVAILABLE_IN_4_10
const char * gdk_monitor_get_description (GdkMonitor *monitor);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkMonitor, g_object_unref)

View File

@@ -37,6 +37,7 @@ struct _GdkMonitor {
char *manufacturer;
char *model;
char *connector;
char *description;
GdkRectangle geometry;
int width_mm;
int height_mm;
@@ -70,6 +71,8 @@ void gdk_monitor_set_refresh_rate (GdkMonitor *monitor,
void gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
GdkSubpixelLayout subpixel);
void gdk_monitor_invalidate (GdkMonitor *monitor);
void gdk_monitor_set_description (GdkMonitor *monitor,
const char *description);
G_END_DECLS

View File

@@ -27,7 +27,7 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdksurface.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -218,9 +218,9 @@ gdk_pixbuf_get_from_surface (cairo_surface_t *surface,
static void
pixbuf_texture_unref_cb (guchar *pixels,
gpointer texture)
gpointer bytes)
{
g_object_unref (texture);
g_bytes_unref (bytes);
}
/**
@@ -238,22 +238,27 @@ pixbuf_texture_unref_cb (guchar *pixels,
GdkPixbuf *
gdk_pixbuf_get_from_texture (GdkTexture *texture)
{
GdkMemoryTexture *memtex;
GdkTextureDownloader downloader;
GBytes *bytes;
gsize stride;
gboolean alpha;
alpha = gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_OPAQUE;
memtex = gdk_memory_texture_from_texture (texture,
alpha ? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader,
alpha ? GDK_MEMORY_GDK_PIXBUF_ALPHA
: GDK_MEMORY_GDK_PIXBUF_OPAQUE);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
return gdk_pixbuf_new_from_data (gdk_memory_texture_get_data (memtex),
return gdk_pixbuf_new_from_data (g_bytes_get_data (bytes, NULL),
GDK_COLORSPACE_RGB,
alpha,
8,
gdk_texture_get_width (GDK_TEXTURE (memtex)),
gdk_texture_get_height (GDK_TEXTURE (memtex)),
gdk_memory_texture_get_stride (memtex),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
stride,
pixbuf_texture_unref_cb,
memtex);
bytes);
}

View File

@@ -586,7 +586,7 @@ gdk_rgba_parser_parse (GtkCssParser *parser,
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_UNRESTRICTED))
{
const char *s = token->string.string;
const char *s = gtk_css_token_get_string (token);
switch (strlen (s))
{
@@ -637,13 +637,13 @@ gdk_rgba_parser_parse (GtkCssParser *parser,
{
*rgba = (GdkRGBA) { 0, 0, 0, 0 };
}
else if (gdk_rgba_parse (rgba, token->string.string))
else if (gdk_rgba_parse (rgba, gtk_css_token_get_string (token)))
{
/* everything's fine */
}
else
{
gtk_css_parser_error_syntax (parser, "\"%s\" is not a valid color name.", token->string.string);
gtk_css_parser_error_syntax (parser, "\"%s\" is not a valid color name.", gtk_css_token_get_string (token));
return FALSE;
}

View File

@@ -463,7 +463,7 @@ gdk_texture_new_from_resource (const char *resource_path)
* Creates a new texture by loading an image from a file.
*
* The file format is detected automatically. The supported formats
* are PNG and JPEG, though more formats might be available.
* are PNG, JPEG and TIFF, though more formats might be available.
*
* If %NULL is returned, then @error will be set.
*
@@ -556,7 +556,7 @@ gdk_texture_new_from_bytes_pixbuf (GBytes *bytes,
* Creates a new texture by loading an image from memory,
*
* The file format is detected automatically. The supported formats
* are PNG and JPEG, though more formats might be available.
* are PNG, JPEG and TIFF, though more formats might be available.
*
* If %NULL is returned, then @error will be set.
*
@@ -602,7 +602,7 @@ gdk_texture_new_from_bytes (GBytes *bytes,
* Creates a new texture by loading an image from a file.
*
* The file format is detected automatically. The supported formats
* are PNG and JPEG, though more formats might be available.
* are PNG, JPEG and TIFF, though more formats might be available.
*
* If %NULL is returned, then @error will be set.
*
@@ -722,6 +722,9 @@ gdk_texture_download_surface (GdkTexture *texture)
* cairo_image_surface_get_stride (surface));
* cairo_surface_mark_dirty (surface);
* ```
*
* For more flexible download capabilites, see
* [struct@Gdk.TextureDownloader].
*/
void
gdk_texture_download (GdkTexture *texture,
@@ -738,9 +741,29 @@ gdk_texture_download (GdkTexture *texture,
stride);
}
/**
* gdk_texture_get_format:
* @self: a GdkTexture
*
* Gets the memory format most closely associated with the data of
* the texture.
*
* Note that it may not be an exact match for texture data
* stored on the GPU or with compression.
*
* The format can give an indication about the bit depth and opacity
* of the texture and is useful to determine the best format for
* downloading the texture.
*
* Returns: the preferred format for the texture's data
*
* Since: 4.10
**/
GdkMemoryFormat
gdk_texture_get_format (GdkTexture *self)
{
g_return_val_if_fail (GDK_IS_TEXTURE (self), GDK_MEMORY_DEFAULT);
return self->format;
}

View File

@@ -24,6 +24,7 @@
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdkenums.h>
#include <gdk/gdktypes.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -82,6 +83,8 @@ GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,

268
gdk/gdktexturedownloader.c Normal file
View File

@@ -0,0 +1,268 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* GdkTextureDownloader:
*
* The `GdkTextureDownloader` is used to download the contents of a
* [class@Gdk.Texture].
*
* It is intended to be created as a short-term object for a single download,
* but can be used for multipe downloads of different textures or with different
* settings.
*
* `GdkTextureDownloader` can be used to convert data between different formats.
* Create a `GdkTexture` for the existing format and then download it in a
* different format.
*
* Since: 4.10
*/
#include "config.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
G_DEFINE_BOXED_TYPE (GdkTextureDownloader, gdk_texture_downloader,
gdk_texture_downloader_copy,
gdk_texture_downloader_free)
void
gdk_texture_downloader_init (GdkTextureDownloader *self,
GdkTexture *texture)
{
self->texture = g_object_ref (texture);
self->format = GDK_MEMORY_DEFAULT;
}
void
gdk_texture_downloader_finish (GdkTextureDownloader *self)
{
g_object_unref (self->texture);
}
/**
* gdk_texture_downloader_new:
* @texture: texture to download
*
* Creates a new texture downloader for @texture.
*
* Returns: A new texture downloader
*
* Since: 4.10
**/
GdkTextureDownloader *
gdk_texture_downloader_new (GdkTexture *texture)
{
GdkTextureDownloader *self;
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
self = g_slice_new (GdkTextureDownloader);
gdk_texture_downloader_init (self, texture);
return self;
}
/**
* gdk_texture_downloader_copy:
* @self: the downloader to copy
*
* Creates a copy of the downloader.
*
* This function is meant for language bindings.
*
* Returns: A copy of the downloader
*
* Since: 4.10
**/
GdkTextureDownloader *
gdk_texture_downloader_copy (const GdkTextureDownloader *self)
{
GdkTextureDownloader *copy;
g_return_val_if_fail (self != NULL, NULL);
copy = gdk_texture_downloader_new (self->texture);
gdk_texture_downloader_set_format (copy, self->format);
return copy;
}
/**
* gdk_texture_downloader_free:
* @self: texture downloader to free
*
* Frees the given downloader and all its associated resources.
*
* Since: 4.10
**/
void
gdk_texture_downloader_free (GdkTextureDownloader *self)
{
g_return_if_fail (self != NULL);
gdk_texture_downloader_finish (self);
g_slice_free (GdkTextureDownloader, self);
}
/**
* gdk_texture_downloader_set_texture:
* @self: a texture downloader
* @texture: the new texture to download
*
* Changes the texture the downloader will download.
*
* Since: 4.10
**/
void
gdk_texture_downloader_set_texture (GdkTextureDownloader *self,
GdkTexture *texture)
{
g_return_if_fail (self != NULL);
g_return_if_fail (GDK_IS_TEXTURE (texture));
g_set_object (&self->texture, texture);
}
/**
* gdk_texture_downloader_get_texture:
* @self: a texture downloader
*
* Gets the texture that the downloader will download.
*
* Returns: (transfer none): The texture to download
*
* Since: 4.10
**/
GdkTexture *
gdk_texture_downloader_get_texture (const GdkTextureDownloader *self)
{
g_return_val_if_fail (self != NULL, NULL);
return self->texture;
}
/**
* gdk_texture_downloader_set_format:
* @self: a texture downloader
* @format: the format to use
*
* Sets the format the downloader will download.
*
* By default, GDK_MEMORY_DEFAULT is set.
*
* Since: 4.10
*/
void
gdk_texture_downloader_set_format (GdkTextureDownloader *self,
GdkMemoryFormat format)
{
g_return_if_fail (self != NULL);
self->format = format;
}
/**
* gdk_texture_downloader_get_format:
* @self: a texture downloader
*
* Gets the format that the data will be downloaded in.
*
* Returns: The format of the download
*
* Since: 4.10
**/
GdkMemoryFormat
gdk_texture_downloader_get_format (const GdkTextureDownloader *self)
{
g_return_val_if_fail (self != NULL, GDK_MEMORY_DEFAULT);
return self->format;
}
/**
* gdk_texture_downloader_download_into:
* @self: a texture downloader
* @data: (array): pointer to enough memory to be filled with the
* downloaded data of the texture
* @stride: rowstride in bytes
*
* Downloads the @texture into local memory.
*
* Since: 4.10
**/
void
gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
guchar *data,
gsize stride)
{
g_return_if_fail (self != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (self->texture) * gdk_memory_format_bytes_per_pixel (self->format));
gdk_texture_do_download (self->texture, self->format, data, stride);
}
/**
* gdk_texture_downloader_download_bytes:
* @self: the downloader
* @out_stride: (out): The stride of the resulting data in bytes.
*
* Downloads the given texture pixels into a `GBytes`. The rowstride will
* be stored in the stride value.
*
* This function will abort if it tries to download a large texture and
* fails to allocate memory. If you think that may happen, you should
* handle memory allocation yourself and use
* gdk_texture_downloader_download_into() once allocation succeeded.
*
* Returns: The downloaded pixels.
*
* Since: 4.10
**/
GBytes *
gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
gsize *out_stride)
{
guchar *data;
gsize stride;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (out_stride != NULL, NULL);
if (GDK_IS_MEMORY_TEXTURE (self->texture) &&
gdk_texture_get_format (self->texture) == self->format)
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (self->texture);
return g_bytes_ref (gdk_memory_texture_get_bytes (memtex, out_stride));
}
stride = self->texture->width * gdk_memory_format_bytes_per_pixel (self->format);
data = g_malloc_n (stride, self->texture->height);
gdk_texture_do_download (self->texture, self->format, data, stride);
*out_stride = stride;
return g_bytes_new_take (data, stride * self->texture->height);
}

View File

@@ -0,0 +1,69 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_TEXTURE_DOWNLOADER_H__
#define __GTK_TEXTURE_DOWNLOADER_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdkenums.h>
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_TEXTURE_DOWNLOADER (gdk_texture_downloader_get_type ())
GDK_AVAILABLE_IN_4_10
GType gdk_texture_downloader_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_10
GdkTextureDownloader * gdk_texture_downloader_new (GdkTexture *texture);
GDK_AVAILABLE_IN_4_10
GdkTextureDownloader * gdk_texture_downloader_copy (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_free (GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_set_texture (GdkTextureDownloader *self,
GdkTexture *texture);
GDK_AVAILABLE_IN_4_10
GdkTexture * gdk_texture_downloader_get_texture (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_set_format (GdkTextureDownloader *self,
GdkMemoryFormat format);
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_downloader_get_format (const GdkTextureDownloader *self);
GDK_AVAILABLE_IN_4_10
void gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
guchar *data,
gsize stride);
GDK_AVAILABLE_IN_4_10
GBytes * gdk_texture_downloader_download_bytes (const GdkTextureDownloader *self,
gsize *out_stride);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkTextureDownloader, gdk_texture_downloader_free)
G_END_DECLS
#endif /* __GTK_TEXTURE_DOWNLOADER_H__ */

View File

@@ -0,0 +1,41 @@
/* GTK - The GIMP Toolkit
*
* Copyright (C) 2023 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__
#define __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__
#include "gdktexturedownloader.h"
G_BEGIN_DECLS
struct _GdkTextureDownloader
{
/*< private >*/
GdkTexture *texture;
GdkMemoryFormat format;
};
void gdk_texture_downloader_init (GdkTextureDownloader *self,
GdkTexture *texture);
void gdk_texture_downloader_finish (GdkTextureDownloader *self);
G_END_DECLS
#endif /* __GTK_TEXTURE_DOWNLOADER_PRIVATE_H__ */

View File

@@ -43,7 +43,6 @@ void gdk_texture_do_download (GdkTexture
GdkMemoryFormat format,
guchar *data,
gsize stride);
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self);
gboolean gdk_texture_set_render_data (GdkTexture *self,
gpointer key,
gpointer data,

View File

@@ -77,6 +77,7 @@ typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
typedef struct _GdkTexture GdkTexture;
typedef struct _GdkTextureDownloader GdkTextureDownloader;
typedef struct _GdkDevice GdkDevice;
typedef struct _GdkDrag GdkDrag;
typedef struct _GdkDrop GdkDrop;

View File

@@ -23,7 +23,7 @@
#include <glib/gi18n-lib.h>
#include "gdktexture.h"
#include "gdkmemorytextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gdkprofilerprivate.h"
@@ -251,7 +251,8 @@ gdk_save_jpeg (GdkTexture *texture)
guchar *data = NULL;
gulong size = 0;
guchar *input = NULL;
GdkMemoryTexture *memtex = NULL;
GdkTextureDownloader downloader;
GBytes *texbytes;
const guchar *texdata;
gsize texstride;
guchar *row;
@@ -270,7 +271,7 @@ gdk_save_jpeg (GdkTexture *texture)
free (data);
g_free (input);
jpeg_destroy_compress (&info);
g_clear_object (&memtex);
g_clear_pointer (&texbytes, g_bytes_unref);
return NULL;
}
@@ -289,10 +290,11 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_mem_dest (&info, &data, &size);
memtex = gdk_memory_texture_from_texture (texture,
GDK_MEMORY_R8G8B8);
texdata = gdk_memory_texture_get_data (memtex);
texstride = gdk_memory_texture_get_stride (memtex);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_R8G8B8);
texbytes = gdk_texture_downloader_download_bytes (&downloader, &texstride);
gdk_texture_downloader_finish (&downloader);
texdata = g_bytes_get_data (texbytes, NULL);
jpeg_start_compress (&info, TRUE);
@@ -304,7 +306,7 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_finish_compress (&info);
g_object_unref (memtex);
g_bytes_unref (texbytes);
g_free (input);
jpeg_destroy_compress (&info);

View File

@@ -21,10 +21,9 @@
#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexture.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include "gsk/gl/fp16private.h"
#include <png.h>
#include <stdio.h>
@@ -297,11 +296,12 @@ gdk_save_png (GdkTexture *texture)
png_info *info;
png_io io = { NULL, 0, 0 };
int width, height;
int y;
GdkMemoryFormat format;
GdkTextureDownloader downloader;
GBytes *bytes;
gsize stride;
const guchar *data;
int y;
GdkMemoryTexture *memtex;
GdkMemoryFormat format;
int png_format;
int depth;
@@ -370,11 +370,15 @@ gdk_save_png (GdkTexture *texture)
return NULL;
}
memtex = gdk_memory_texture_from_texture (texture, format);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
data = g_bytes_get_data (bytes, NULL);
if (sigsetjmp (png_jmpbuf (png), 1))
{
g_object_unref (memtex);
g_bytes_unref (bytes);
g_free (io.data);
png_destroy_read_struct (&png, &info, NULL);
return NULL;
@@ -394,8 +398,6 @@ gdk_save_png (GdkTexture *texture)
png_set_swap (png);
#endif
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
for (y = 0; y < height; y++)
png_write_row (png, data + y * stride);
@@ -403,7 +405,7 @@ gdk_save_png (GdkTexture *texture)
png_destroy_write_struct (&png, &info);
g_object_unref (memtex);
g_bytes_unref (bytes);
return g_bytes_new_take (io.data, io.size);
}

View File

@@ -21,10 +21,9 @@
#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
#include "gdktexture.h"
#include "gdktextureprivate.h"
#include "gdktexturedownloaderprivate.h"
#include <tiffio.h>
@@ -260,11 +259,12 @@ GBytes *
gdk_save_tiff (GdkTexture *texture)
{
TIFF *tif;
int width, height, stride;
int width, height;
gsize stride;
const guchar *line;
const guchar *data;
GBytes *result = NULL;
GdkMemoryTexture *memtex;
GBytes *bytes, *result = NULL;
GdkTextureDownloader downloader;
GdkMemoryFormat format;
const FormatData *fdata = NULL;
@@ -292,9 +292,11 @@ gdk_save_tiff (GdkTexture *texture)
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
memtex = gdk_memory_texture_from_texture (texture, fdata->format);
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, fdata->format);
bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
gdk_texture_downloader_finish (&downloader);
data = g_bytes_get_data (bytes, NULL);
line = (const guchar *)data;
for (int y = 0; y < height; y++)
@@ -302,7 +304,7 @@ gdk_save_tiff (GdkTexture *texture)
if (TIFFWriteScanline (tif, (void *)line, y, 0) == -1)
{
TIFFClose (tif);
g_object_unref (memtex);
g_bytes_unref (bytes);
return NULL;
}
@@ -314,7 +316,7 @@ gdk_save_tiff (GdkTexture *texture)
g_assert (result);
g_object_unref (memtex);
g_bytes_unref (bytes);
return result;
}

View File

@@ -27,10 +27,12 @@
#import "GdkMacosView.h"
#import "GdkMacosWindow.h"
#include "gdkmacosclipboard-private.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosdrag-private.h"
#include "gdkmacosdrop-private.h"
#include "gdkmacoseventsource-private.h"
#include "gdkmacosmonitor-private.h"
#include "gdkmacospasteboard-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacospopupsurface-private.h"
#include "gdkmacostoplevelsurface-private.h"
@@ -144,7 +146,7 @@ typedef NSString *CALayerContentsGravity;
*
* TODO: Can we improve grab breaking to fix this?
*/
_gdk_macos_display_send_button_event ([self gdkDisplay], event);
_gdk_macos_display_send_event ([self gdkDisplay], event);
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
@@ -246,7 +248,7 @@ typedef NSString *CALayerContentsGravity;
[view release];
/* TODO: We might want to make this more extensible at some point */
_gdk_macos_clipboard_register_drag_types (self);
_gdk_macos_pasteboard_register_drag_types (self);
return self;
}
@@ -576,6 +578,8 @@ typedef NSString *CALayerContentsGravity;
initialResizeLocation = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]);
}
// NSDraggingDestination protocol
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPoint location = [sender draggingLocation];
@@ -665,10 +669,64 @@ typedef NSString *CALayerContentsGravity;
return NO;
}
-(void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
// NSDraggingSource protocol
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
{
NSInteger sequence_number = [session draggingSequenceNumber];
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (gdk_surface));
GdkDrag *drag = _gdk_macos_display_find_drag (GDK_MACOS_DISPLAY (display), sequence_number);
GdkModifierType state = _gdk_macos_display_get_current_keyboard_modifiers (GDK_MACOS_DISPLAY (display));
_gdk_macos_drag_set_actions (GDK_MACOS_DRAG (drag), state);
return _gdk_macos_drag_operation (GDK_MACOS_DRAG (drag));
}
- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint
{
NSInteger sequence_number = [session draggingSequenceNumber];
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (gdk_surface));
GdkDrag *drag = _gdk_macos_display_find_drag (GDK_MACOS_DISPLAY (display), sequence_number);
int x, y;
_gdk_macos_display_from_display_coords (GDK_MACOS_DISPLAY (display), screenPoint.x, screenPoint.y, &x, &y);
_gdk_macos_drag_set_start_position (GDK_MACOS_DRAG (drag), x, y);
_gdk_macos_drag_surface_move (GDK_MACOS_DRAG (drag), x, y);
}
- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint
{
NSInteger sequence_number = [session draggingSequenceNumber];
GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (gdk_surface)));
GdkDrag *drag = _gdk_macos_display_find_drag (GDK_MACOS_DISPLAY (display), sequence_number);
int x, y;
_gdk_macos_display_send_event (display, [NSApp currentEvent]);
_gdk_macos_display_from_display_coords (display, screenPoint.x, screenPoint.y, &x, &y);
_gdk_macos_drag_surface_move (GDK_MACOS_DRAG (drag), x, y);
}
- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
{
NSInteger sequence_number = [session draggingSequenceNumber];
GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (gdk_surface)));
GdkDrag *drag = _gdk_macos_display_find_drag (display, sequence_number);
_gdk_macos_display_send_event (display, [NSApp currentEvent]);
gdk_drag_set_selected_action (drag, _gdk_macos_drag_ns_operation_to_action (operation));
if (gdk_drag_get_selected_action (drag) != 0)
g_signal_emit_by_name (drag, "drop-performed");
else
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
_gdk_macos_display_set_drag (display, [session draggingSequenceNumber], NULL);
}
// end
-(void)setStyleMask:(NSWindowStyleMask)styleMask
{
gboolean was_fullscreen;

View File

@@ -32,7 +32,7 @@
#define GDK_IS_MACOS_WINDOW(obj) ([obj isKindOfClass:[GdkMacosWindow class]])
@interface GdkMacosWindow : NSWindow {
@interface GdkMacosWindow : NSWindow <NSDraggingSource, NSDraggingDestination> {
GdkMacosSurface *gdk_surface;
BOOL inMove;

View File

@@ -24,6 +24,7 @@
#include "gdkclipboardprivate.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacospasteboard-private.h"
G_BEGIN_DECLS
@@ -41,30 +42,6 @@ NSPasteboardType _gdk_macos_clipboard_to_ns_type (const char
NSPasteboardType *alternate);
const char *_gdk_macos_clipboard_from_ns_type (NSPasteboardType ns_type);
void _gdk_macos_clipboard_register_drag_types (NSWindow *window);
GdkContentFormats *_gdk_macos_pasteboard_load_formats (NSPasteboard *pasteboard);
void _gdk_macos_pasteboard_read_async (GObject *object,
NSPasteboard *pasteboard,
GdkContentFormats *formats,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GInputStream *_gdk_macos_pasteboard_read_finish (GObject *object,
GAsyncResult *result,
const char **out_mime_type,
GError **error);
@interface GdkMacosClipboardDataProvider : NSObject <NSPasteboardItemDataProvider>
{
GCancellable *cancellable;
GdkClipboard *clipboard;
char **mimeTypes;
}
-(id)initClipboard:(GdkClipboard *)gdkClipboard mimetypes:(const char * const *)mime_types;
-(NSArray<NSPasteboardType> *)types;
@end
G_END_DECLS

View File

@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
#include "gdkmacosclipboard-private.h"
#include "gdkmacospasteboard-private.h"
#include "gdkmacosutils-private.h"
#include "gdkprivate.h"
@@ -32,163 +33,8 @@ struct _GdkMacosClipboard
NSInteger last_change_count;
};
typedef struct
{
GMemoryOutputStream *stream;
NSPasteboardItem *item;
NSPasteboardType type;
GMainContext *main_context;
guint done : 1;
} WriteRequest;
enum {
TYPE_STRING,
TYPE_PBOARD,
TYPE_URL,
TYPE_FILE_URL,
TYPE_COLOR,
TYPE_TIFF,
TYPE_PNG,
TYPE_LAST
};
#define PTYPE(k) (get_pasteboard_type(TYPE_##k))
static NSPasteboardType pasteboard_types[TYPE_LAST];
G_DEFINE_TYPE (GdkMacosClipboard, _gdk_macos_clipboard, GDK_TYPE_CLIPBOARD)
static NSPasteboardType
get_pasteboard_type (int type)
{
static gsize initialized = FALSE;
g_assert (type >= 0);
g_assert (type < TYPE_LAST);
if (g_once_init_enter (&initialized))
{
pasteboard_types[TYPE_PNG] = NSPasteboardTypePNG;
pasteboard_types[TYPE_STRING] = NSPasteboardTypeString;
pasteboard_types[TYPE_TIFF] = NSPasteboardTypeTIFF;
pasteboard_types[TYPE_COLOR] = NSPasteboardTypeColor;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pasteboard_types[TYPE_PBOARD] = NSStringPboardType;
G_GNUC_END_IGNORE_DEPRECATIONS
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
pasteboard_types[TYPE_URL] = NSPasteboardTypeURL;
pasteboard_types[TYPE_FILE_URL] = NSPasteboardTypeFileURL;
#else
pasteboard_types[TYPE_URL] = [[NSString alloc] initWithUTF8String:"public.url"];
pasteboard_types[TYPE_FILE_URL] = [[NSString alloc] initWithUTF8String:"public.file-url"];
#endif
g_once_init_leave (&initialized, TRUE);
}
return pasteboard_types[type];
}
static void
write_request_free (WriteRequest *wr)
{
g_clear_pointer (&wr->main_context, g_main_context_unref);
g_clear_object (&wr->stream);
[wr->item release];
g_slice_free (WriteRequest, wr);
}
const char *
_gdk_macos_clipboard_from_ns_type (NSPasteboardType type)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([type isEqualToString:PTYPE(STRING)] ||
[type isEqualToString:PTYPE(PBOARD)])
return g_intern_string ("text/plain;charset=utf-8");
else if ([type isEqualToString:PTYPE(URL)] ||
[type isEqualToString:PTYPE(FILE_URL)])
return g_intern_string ("text/uri-list");
else if ([type isEqualToString:PTYPE(COLOR)])
return g_intern_string ("application/x-color");
else if ([type isEqualToString:PTYPE(TIFF)])
return g_intern_string ("image/tiff");
else if ([type isEqualToString:PTYPE(PNG)])
return g_intern_string ("image/png");
G_GNUC_END_IGNORE_DEPRECATIONS;
return NULL;
}
NSPasteboardType
_gdk_macos_clipboard_to_ns_type (const char *mime_type,
NSPasteboardType *alternate)
{
if (alternate)
*alternate = NULL;
if (g_strcmp0 (mime_type, "text/plain;charset=utf-8") == 0)
{
return PTYPE(STRING);
}
else if (g_strcmp0 (mime_type, "text/uri-list") == 0)
{
if (alternate)
*alternate = PTYPE(URL);
return PTYPE(FILE_URL);
}
else if (g_strcmp0 (mime_type, "application/x-color") == 0)
{
return PTYPE(COLOR);
}
else if (g_strcmp0 (mime_type, "image/tiff") == 0)
{
return PTYPE(TIFF);
}
else if (g_strcmp0 (mime_type, "image/png") == 0)
{
return PTYPE(PNG);
}
return nil;
}
static void
populate_content_formats (GdkContentFormatsBuilder *builder,
NSPasteboardType type)
{
const char *mime_type;
g_return_if_fail (builder != NULL);
g_return_if_fail (type != NULL);
mime_type = _gdk_macos_clipboard_from_ns_type (type);
if (mime_type != NULL)
gdk_content_formats_builder_add_mime_type (builder, mime_type);
}
static GdkContentFormats *
load_offer_formats (NSPasteboard *pasteboard)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkContentFormatsBuilder *builder;
GdkContentFormats *formats;
builder = gdk_content_formats_builder_new ();
for (NSPasteboardType type in [pasteboard types])
populate_content_formats (builder, type);
formats = gdk_content_formats_builder_free_to_formats (builder);
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&formats);
}
static void
_gdk_macos_clipboard_load_contents (GdkMacosClipboard *self)
{
@@ -199,22 +45,13 @@ _gdk_macos_clipboard_load_contents (GdkMacosClipboard *self)
change_count = [self->pasteboard changeCount];
formats = load_offer_formats (self->pasteboard);
formats = _gdk_macos_pasteboard_load_formats (self->pasteboard);
gdk_clipboard_claim_remote (GDK_CLIPBOARD (self), formats);
gdk_content_formats_unref (formats);
self->last_change_count = change_count;
}
static GInputStream *
create_stream_from_nsdata (NSData *data)
{
const guint8 *bytes = [data bytes];
gsize len = [data length];
return g_memory_input_stream_new_from_data (g_memdup2 (bytes, len), len, g_free);
}
static void
_gdk_macos_clipboard_read_async (GdkClipboard *clipboard,
GdkContentFormats *formats,
@@ -245,34 +82,26 @@ static void
_gdk_macos_clipboard_send_to_pasteboard (GdkMacosClipboard *self,
GdkContentProvider *content)
{
GdkMacosPasteboardItem *item;
NSArray<NSPasteboardItem *> *items;
g_assert (GDK_IS_MACOS_CLIPBOARD (self));
g_assert (GDK_IS_CONTENT_PROVIDER (content));
if (self->pasteboard == NULL)
return;
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkMacosClipboardDataProvider *dataProvider;
GdkContentFormats *serializable;
NSPasteboardItem *item;
const char * const *mime_types;
gsize n_mime_types;
g_return_if_fail (GDK_IS_MACOS_CLIPBOARD (self));
g_return_if_fail (GDK_IS_CONTENT_PROVIDER (content));
serializable = gdk_content_provider_ref_storable_formats (content);
serializable = gdk_content_formats_union_serialize_mime_types (serializable);
mime_types = gdk_content_formats_get_mime_types (serializable, &n_mime_types);
dataProvider = [[GdkMacosClipboardDataProvider alloc] initClipboard:GDK_CLIPBOARD (self)
mimetypes:mime_types];
item = [[NSPasteboardItem alloc] init];
[item setDataProvider:dataProvider forTypes:[dataProvider types]];
item = [[GdkMacosPasteboardItem alloc] initForClipboard:GDK_CLIPBOARD (self) withContentProvider:content];
items = [NSArray arrayWithObject:item];
[self->pasteboard clearContents];
if ([self->pasteboard writeObjects:[NSArray arrayWithObject:item]] == NO)
g_warning ("Failed to write object to pasteboard");
if ([self->pasteboard writeObjects:items] == NO)
g_warning ("Failed to send clipboard to pasteboard");
self->last_change_count = [self->pasteboard changeCount];
g_clear_pointer (&serializable, gdk_content_formats_unref);
GDK_END_MACOS_ALLOC_POOL;
}
@@ -365,305 +194,3 @@ _gdk_macos_clipboard_check_externally_modified (GdkMacosClipboard *self)
if ([self->pasteboard changeCount] != self->last_change_count)
_gdk_macos_clipboard_load_contents (self);
}
@implementation GdkMacosClipboardDataProvider
-(id)initClipboard:(GdkClipboard *)gdkClipboard mimetypes:(const char * const *)mime_types;
{
[super init];
self->mimeTypes = g_strdupv ((char **)mime_types);
self->clipboard = g_object_ref (gdkClipboard);
return self;
}
-(void)dealloc
{
g_cancellable_cancel (self->cancellable);
g_clear_pointer (&self->mimeTypes, g_strfreev);
g_clear_object (&self->clipboard);
g_clear_object (&self->cancellable);
[super dealloc];
}
-(void)pasteboardFinishedWithDataProvider:(NSPasteboard *)pasteboard
{
g_clear_object (&self->clipboard);
}
-(NSArray<NSPasteboardType> *)types
{
NSMutableArray *ret = [[NSMutableArray alloc] init];
for (guint i = 0; self->mimeTypes[i]; i++)
{
const char *mime_type = self->mimeTypes[i];
NSPasteboardType type;
NSPasteboardType alternate = nil;
if ((type = _gdk_macos_clipboard_to_ns_type (mime_type, &alternate)))
{
[ret addObject:type];
if (alternate)
[ret addObject:alternate];
}
}
return g_steal_pointer (&ret);
}
static void
on_data_ready_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkClipboard *clipboard = (GdkClipboard *)object;
WriteRequest *wr = user_data;
GError *error = NULL;
NSData *data = nil;
g_assert (GDK_IS_CLIPBOARD (clipboard));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (wr != NULL);
g_assert (G_IS_MEMORY_OUTPUT_STREAM (wr->stream));
g_assert ([wr->item isKindOfClass:[NSPasteboardItem class]]);
if (gdk_clipboard_write_finish (clipboard, result, &error))
{
gsize size;
gpointer bytes;
g_output_stream_close (G_OUTPUT_STREAM (wr->stream), NULL, NULL);
size = g_memory_output_stream_get_data_size (wr->stream);
bytes = g_memory_output_stream_steal_data (wr->stream);
data = [[NSData alloc] initWithBytesNoCopy:bytes
length:size
deallocator:^(void *alloc, NSUInteger length) { g_free (alloc); }];
}
else
{
g_warning ("Failed to serialize clipboard contents: %s",
error->message);
g_clear_error (&error);
}
[wr->item setData:data forType:wr->type];
wr->done = TRUE;
GDK_END_MACOS_ALLOC_POOL;
}
-(void) pasteboard:(NSPasteboard *)pasteboard
item:(NSPasteboardItem *)item
provideDataForType:(NSPasteboardType)type
{
const char *mime_type = _gdk_macos_clipboard_from_ns_type (type);
GMainContext *main_context = g_main_context_default ();
WriteRequest *wr;
if (self->clipboard == NULL || mime_type == NULL)
{
[item setData:[NSData data] forType:type];
return;
}
wr = g_slice_new0 (WriteRequest);
wr->item = [item retain];
wr->stream = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new_resizable ());
wr->type = type;
wr->main_context = g_main_context_ref (main_context);
wr->done = FALSE;
gdk_clipboard_write_async (self->clipboard,
mime_type,
G_OUTPUT_STREAM (wr->stream),
G_PRIORITY_DEFAULT,
self->cancellable,
on_data_ready_cb,
wr);
/* We're forced to provide data synchronously via this API
* so we must block on the main loop. Using another main loop
* than the default tends to get us locked up here, so that is
* what we'll do for now.
*/
while (!wr->done)
g_main_context_iteration (wr->main_context, TRUE);
write_request_free (wr);
}
void
_gdk_macos_clipboard_register_drag_types (NSWindow *window)
{
[window registerForDraggedTypes:[NSArray arrayWithObjects:PTYPE(STRING),
PTYPE(PBOARD),
PTYPE(URL),
PTYPE(FILE_URL),
PTYPE(COLOR),
PTYPE(TIFF),
PTYPE(PNG),
nil]];
}
@end
GdkContentFormats *
_gdk_macos_pasteboard_load_formats (NSPasteboard *pasteboard)
{
return load_offer_formats (pasteboard);
}
void
_gdk_macos_pasteboard_read_async (GObject *object,
NSPasteboard *pasteboard,
GdkContentFormats *formats,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkContentFormats *offer_formats = NULL;
const char *mime_type;
GInputStream *stream = NULL;
GTask *task = NULL;
g_assert (G_IS_OBJECT (object));
g_assert (pasteboard != NULL);
g_assert (formats != NULL);
task = g_task_new (object, cancellable, callback, user_data);
g_task_set_source_tag (task, _gdk_macos_pasteboard_read_async);
g_task_set_priority (task, io_priority);
offer_formats = load_offer_formats (pasteboard);
mime_type = gdk_content_formats_match_mime_type (formats, offer_formats);
if (mime_type == NULL)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"%s",
_("No compatible transfer format found"));
goto cleanup;
}
if (strcmp (mime_type, "text/plain;charset=utf-8") == 0)
{
NSString *nsstr = [pasteboard stringForType:NSPasteboardTypeString];
if (nsstr != NULL)
{
const char *str = [nsstr UTF8String];
stream = g_memory_input_stream_new_from_data (g_strdup (str),
strlen (str) + 1,
g_free);
}
}
else if (strcmp (mime_type, "text/uri-list") == 0)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([[pasteboard types] containsObject:PTYPE(FILE_URL)])
{
GString *str = g_string_new (NULL);
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
gsize n_files = [files count];
char *data;
guint len;
for (gsize i = 0; i < n_files; ++i)
{
NSString* uriString = [files objectAtIndex:i];
uriString = [@"file://" stringByAppendingString:uriString];
uriString = [uriString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
g_string_append_printf (str,
"%s\r\n",
[uriString cStringUsingEncoding:NSUTF8StringEncoding]);
}
len = str->len;
data = g_string_free (str, FALSE);
stream = g_memory_input_stream_new_from_data (data, len, g_free);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
}
else if (strcmp (mime_type, "application/x-color") == 0)
{
NSColorSpace *colorspace;
NSColor *nscolor;
guint16 color[4];
colorspace = [NSColorSpace genericRGBColorSpace];
nscolor = [[NSColor colorFromPasteboard:pasteboard]
colorUsingColorSpace:colorspace];
color[0] = 0xffff * [nscolor redComponent];
color[1] = 0xffff * [nscolor greenComponent];
color[2] = 0xffff * [nscolor blueComponent];
color[3] = 0xffff * [nscolor alphaComponent];
stream = g_memory_input_stream_new_from_data (g_memdup2 (&color, sizeof color),
sizeof color,
g_free);
}
else if (strcmp (mime_type, "image/tiff") == 0)
{
NSData *data = [pasteboard dataForType:PTYPE(TIFF)];
stream = create_stream_from_nsdata (data);
}
else if (strcmp (mime_type, "image/png") == 0)
{
NSData *data = [pasteboard dataForType:PTYPE(PNG)];
stream = create_stream_from_nsdata (data);
}
if (stream != NULL)
{
g_task_set_task_data (task, g_strdup (mime_type), g_free);
g_task_return_pointer (task, g_steal_pointer (&stream), g_object_unref);
}
else
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
_("Failed to decode contents with mime-type of '%s'"),
mime_type);
}
cleanup:
g_clear_object (&task);
g_clear_pointer (&offer_formats, gdk_content_formats_unref);
GDK_END_MACOS_ALLOC_POOL;
}
GInputStream *
_gdk_macos_pasteboard_read_finish (GObject *object,
GAsyncResult *result,
const char **out_mime_type,
GError **error)
{
GTask *task = (GTask *)result;
g_assert (G_IS_OBJECT (object));
g_assert (G_IS_TASK (task));
if (out_mime_type != NULL)
*out_mime_type = g_strdup (g_task_get_task_data (task));
return g_task_propagate_pointer (task, error);
}

View File

@@ -23,6 +23,10 @@
#include "gdkmacoscursor-private.h"
@interface NSCursor()
-(long long)_coreCursorType;
@end
/* OS X only exports a number of cursor types in its public NSCursor interface.
* By overriding the private _coreCursorType method, we can tell OS X to load
* one of its internal cursors instead (since cursor images are loaded on demand

View File

@@ -155,12 +155,13 @@ void _gdk_macos_display_surface_became_key (GdkMacosDisp
GdkMacosSurface *surface);
void _gdk_macos_display_clear_sorting (GdkMacosDisplay *self);
const GList *_gdk_macos_display_get_surfaces (GdkMacosDisplay *self);
void _gdk_macos_display_send_button_event (GdkMacosDisplay *self,
void _gdk_macos_display_send_event (GdkMacosDisplay *self,
NSEvent *nsevent);
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_last_nsevent (void);
GdkDrag *_gdk_macos_display_find_drag (GdkMacosDisplay *self,
NSInteger sequence_number);
GdkDrop *_gdk_macos_display_find_drop (GdkMacosDisplay *self,

View File

@@ -723,6 +723,85 @@ fill_scroll_event (GdkMacosDisplay *self,
return g_steal_pointer (&ret);
}
static GdkEvent *
fill_event (GdkMacosDisplay *self,
GdkMacosWindow *window,
NSEvent *nsevent,
int x,
int y)
{
GdkMacosSurface *surface = [window gdkSurface];
NSEventType event_type = [nsevent type];
GdkEvent *ret = NULL;
switch ((int)event_type)
{
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
ret = fill_button_event (self, surface, nsevent, x, y);
break;
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
case NSEventTypeMouseMoved:
ret = fill_motion_event (self, surface, nsevent, x, y);
break;
case NSEventTypeMagnify:
case NSEventTypeRotate:
ret = fill_pinch_event (self, surface, nsevent, x, y);
break;
case NSEventTypeMouseExited:
case NSEventTypeMouseEntered:
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
GdkDevice *pointer = gdk_seat_get_pointer (seat);
GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (GDK_DISPLAY (self), pointer);
if ([(GdkMacosWindow *)window isInManualResizeOrMove])
{
ret = GDK_MACOS_EVENT_DROP;
}
else if (grab == NULL || grab->owner_events)
{
if (event_type == NSEventTypeMouseExited)
[[NSCursor arrowCursor] set];
ret = synthesize_crossing_event (self, surface, nsevent, x, y);
}
}
break;
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
case NSEventTypeFlagsChanged: {
GdkEventType type = _gdk_macos_keymap_get_event_type (nsevent);
if (type)
ret = fill_key_event (self, surface, nsevent, type);
break;
}
case NSEventTypeScrollWheel:
ret = fill_scroll_event (self, surface, nsevent, x, y);
break;
default:
break;
}
return ret;
}
static gboolean
is_mouse_button_press_event (NSEventType type)
{
@@ -1025,16 +1104,12 @@ find_surface_for_ns_event (GdkMacosDisplay *self,
GdkMacosBaseView *view;
GdkSurface *surface;
NSPoint point;
int x_tmp;
int y_tmp;
g_assert (GDK_IS_MACOS_DISPLAY (self));
g_assert (nsevent != NULL);
g_assert (x != NULL);
g_assert (y != NULL);
_gdk_macos_display_from_display_coords (self, point.x, point.y, &x_tmp, &y_tmp);
switch ((int)[nsevent type])
{
case NSEventTypeLeftMouseDown:
@@ -1083,7 +1158,6 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
GdkMacosWindow *window;
NSEventType event_type;
NSWindow *event_window;
GdkEvent *ret = NULL;
int x;
int y;
@@ -1191,79 +1265,15 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
_gdk_macos_display_clear_sorting (self);
}
}
switch ((int)event_type)
{
case NSEventTypeLeftMouseDown:
case NSEventTypeRightMouseDown:
case NSEventTypeOtherMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeRightMouseUp:
case NSEventTypeOtherMouseUp:
ret = fill_button_event (self, surface, nsevent, x, y);
break;
case NSEventTypeLeftMouseDragged:
case NSEventTypeRightMouseDragged:
case NSEventTypeOtherMouseDragged:
case NSEventTypeMouseMoved:
ret = fill_motion_event (self, surface, nsevent, x, y);
break;
case NSEventTypeMagnify:
case NSEventTypeRotate:
ret = fill_pinch_event (self, surface, nsevent, x, y);
break;
case NSEventTypeMouseExited:
case NSEventTypeMouseEntered:
{
GdkSeat *seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
GdkDevice *pointer = gdk_seat_get_pointer (seat);
GdkDeviceGrabInfo *grab = _gdk_display_get_last_device_grab (GDK_DISPLAY (self), pointer);
if ([(GdkMacosWindow *)window isInManualResizeOrMove])
{
ret = GDK_MACOS_EVENT_DROP;
}
else if (grab == NULL)
{
if (event_type == NSEventTypeMouseExited)
[[NSCursor arrowCursor] set];
ret = synthesize_crossing_event (self, surface, nsevent, x, y);
}
}
break;
case NSEventTypeKeyDown:
case NSEventTypeKeyUp:
case NSEventTypeFlagsChanged: {
GdkEventType type = _gdk_macos_keymap_get_event_type (nsevent);
if (type)
ret = fill_key_event (self, surface, nsevent, type);
break;
}
case NSEventTypeScrollWheel:
ret = fill_scroll_event (self, surface, nsevent, x, y);
break;
default:
break;
}
return ret;
return fill_event (self, window, nsevent, x, y);
}
void
_gdk_macos_display_send_button_event (GdkMacosDisplay *self,
NSEvent *nsevent)
_gdk_macos_display_send_event (GdkMacosDisplay *self,
NSEvent *nsevent)
{
GdkMacosSurface *surface;
GdkMacosWindow *window;
GdkEvent *event;
int x;
int y;
@@ -1272,7 +1282,8 @@ _gdk_macos_display_send_button_event (GdkMacosDisplay *self,
g_return_if_fail (nsevent != NULL);
if ((surface = find_surface_for_ns_event (self, nsevent, &x, &y)) &&
(event = fill_button_event (self, surface, nsevent, x, y)))
(window = (GdkMacosWindow *)_gdk_macos_surface_get_native (surface)) &&
(event = fill_event (self, window, nsevent, x, y)))
_gdk_windowing_got_event (GDK_DISPLAY (self),
_gdk_event_queue_append (GDK_DISPLAY (self), event),
event,

View File

@@ -1024,6 +1024,16 @@ _gdk_macos_display_get_nsevent (GdkEvent *event)
return NULL;
}
NSEvent *
_gdk_macos_display_get_last_nsevent ()
{
const GdkToNSEventMap *map = g_queue_peek_tail (&event_map);
if (map)
return map->nsevent;
return NULL;
}
GdkDrag *
_gdk_macos_display_find_drag (GdkMacosDisplay *self,
NSInteger sequence_number)

View File

@@ -41,7 +41,6 @@ struct _GdkMacosDrag
GdkDrag parent_instance;
GdkMacosDragSurface *drag_surface;
GdkSeat *drag_seat;
GdkCursor *cursor;
int hot_x;
@@ -62,8 +61,22 @@ struct _GdkMacosDragClass
GdkDragClass parent_class;
};
GType gdk_macos_drag_get_type (void) G_GNUC_CONST;
gboolean _gdk_macos_drag_begin (GdkMacosDrag *self);
GType gdk_macos_drag_get_type (void) G_GNUC_CONST;
gboolean _gdk_macos_drag_begin (GdkMacosDrag *self,
GdkContentProvider *content,
GdkMacosWindow *window);
NSDragOperation _gdk_macos_drag_operation (GdkMacosDrag *self);
GdkDragAction _gdk_macos_drag_ns_operation_to_action
(NSDragOperation operation);
void _gdk_macos_drag_surface_move (GdkMacosDrag *self,
int x_root,
int y_root);
void _gdk_macos_drag_set_start_position (GdkMacosDrag *self,
int start_x,
int start_y);
void _gdk_macos_drag_set_actions (GdkMacosDrag *self,
GdkModifierType mods);
G_END_DECLS

View File

@@ -25,6 +25,7 @@
#include "gdkmacoscursor-private.h"
#include "gdkmacosdisplay-private.h"
#include "gdkmacosdragsurface-private.h"
#include "gdkmacospasteboard-private.h"
#include "gdk/gdkdeviceprivate.h"
#include "gdk/gdkeventsprivate.h"
@@ -187,41 +188,6 @@ gdk_macos_drag_set_cursor (GdkDrag *drag,
[nscursor set];
}
static gboolean
drag_grab (GdkMacosDrag *self)
{
GdkSeat *seat;
g_assert (GDK_IS_MACOS_DRAG (self));
seat = gdk_device_get_seat (gdk_drag_get_device (GDK_DRAG (self)));
if (gdk_seat_grab (seat,
GDK_SURFACE (self->drag_surface),
GDK_SEAT_CAPABILITY_ALL_POINTING,
FALSE,
self->cursor,
NULL,
NULL,
NULL) != GDK_GRAB_SUCCESS)
return FALSE;
g_set_object (&self->drag_seat, seat);
return TRUE;
}
static void
drag_ungrab (GdkMacosDrag *self)
{
GdkDisplay *display;
g_assert (GDK_IS_MACOS_DRAG (self));
display = gdk_drag_get_display (GDK_DRAG (self));
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), GDK_CURRENT_TIME);
}
static void
gdk_macos_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
@@ -234,7 +200,6 @@ gdk_macos_drag_cancel (GdkDrag *drag,
return;
self->cancelled = TRUE;
drag_ungrab (self);
gdk_drag_drop_done (drag, FALSE);
}
@@ -247,7 +212,6 @@ gdk_macos_drag_drop_performed (GdkDrag *drag,
g_assert (GDK_IS_MACOS_DRAG (self));
g_object_ref (self);
drag_ungrab (self);
g_signal_emit_by_name (drag, "dnd-finished");
gdk_drag_drop_done (drag, TRUE);
g_object_unref (self);
@@ -310,225 +274,6 @@ gdk_drag_get_current_actions (GdkModifierType state,
}
}
static void
gdk_drag_update (GdkDrag *drag,
double x_root,
double y_root,
GdkModifierType mods,
guint32 evtime)
{
GdkMacosDrag *self = (GdkMacosDrag *)drag;
GdkDragAction suggested_action;
GdkDragAction possible_actions;
g_assert (GDK_IS_MACOS_DRAG (self));
self->last_x = x_root;
self->last_y = y_root;
gdk_drag_get_current_actions (mods,
GDK_BUTTON_PRIMARY,
gdk_drag_get_actions (drag),
&suggested_action,
&possible_actions);
if (GDK_IS_MACOS_SURFACE (self->drag_surface))
_gdk_macos_surface_move (GDK_MACOS_SURFACE (self->drag_surface),
x_root - self->hot_x,
y_root - self->hot_y);
if (!self->did_update)
{
self->start_x = self->last_x;
self->start_y = self->last_y;
self->did_update = TRUE;
}
gdk_drag_set_actions (drag, possible_actions);
}
static gboolean
gdk_dnd_handle_motion_event (GdkDrag *drag,
GdkEvent *event)
{
double x, y;
int x_root, y_root;
g_assert (GDK_IS_MACOS_DRAG (drag));
g_assert (event != NULL);
/* Ignore motion while doing zoomback */
if (GDK_MACOS_DRAG (drag)->cancelled)
return FALSE;
gdk_event_get_position (event, &x, &y);
x_root = event->surface->x + x;
y_root = event->surface->y + y;
gdk_drag_update (drag, x_root, y_root,
gdk_event_get_modifier_state (event),
gdk_event_get_time (event));
return TRUE;
}
static gboolean
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
GdkEvent *event)
{
GdkMacosDrag *self = GDK_MACOS_DRAG (drag);
gboolean is_implicit = gdk_grab_broken_event_get_implicit (event);
GdkSurface *grab_surface = gdk_grab_broken_event_get_grab_surface (event);
/* Don't cancel if we break the implicit grab from the initial button_press. */
if (is_implicit || grab_surface == (GdkSurface *)self->drag_surface)
return FALSE;
if (gdk_event_get_device (event) != gdk_drag_get_device (drag))
return FALSE;
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
return TRUE;
}
static gboolean
gdk_dnd_handle_button_event (GdkDrag *drag,
GdkEvent *event)
{
GdkMacosDrag *self = GDK_MACOS_DRAG (drag);
g_assert (GDK_IS_MACOS_DRAG (self));
g_assert (event != NULL);
#if 0
/* FIXME: Check the button matches */
if (event->button != self->button)
return FALSE;
#endif
if (gdk_drag_get_selected_action (drag) != 0)
g_signal_emit_by_name (drag, "drop-performed");
else
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
return TRUE;
}
static gboolean
gdk_dnd_handle_key_event (GdkDrag *drag,
GdkEvent *event)
{
GdkMacosDrag *self = GDK_MACOS_DRAG (drag);
GdkModifierType state;
GdkDevice *pointer;
GdkSeat *seat;
int dx, dy;
dx = dy = 0;
state = gdk_event_get_modifier_state (event);
seat = gdk_event_get_seat (event);
pointer = gdk_seat_get_pointer (seat);
if (event->event_type == GDK_KEY_PRESS)
{
guint keyval = gdk_key_event_get_keyval (event);
switch (keyval)
{
case GDK_KEY_Escape:
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
return TRUE;
case GDK_KEY_space:
case GDK_KEY_Return:
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_KP_Space:
if (gdk_drag_get_selected_action (drag) != 0)
g_signal_emit_by_name (drag, "drop-performed");
else
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
return TRUE;
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
default:
break;
}
}
/* The state is not yet updated in the event, so we need
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
gdk_macos_device_query_state (pointer, NULL, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
GdkDisplay *display = gdk_event_get_display ((GdkEvent *)event);
self->last_x += dx;
self->last_y += dy;
_gdk_macos_display_warp_pointer (GDK_MACOS_DISPLAY (display),
self->last_x,
self->last_y);
}
gdk_drag_update (drag,
self->last_x, self->last_y,
state,
gdk_event_get_time (event));
return TRUE;
}
static gboolean
gdk_macos_drag_handle_event (GdkDrag *drag,
GdkEvent *event)
{
g_assert (GDK_IS_MACOS_DRAG (drag));
g_assert (event != NULL);
switch ((guint) event->event_type)
{
case GDK_MOTION_NOTIFY:
return gdk_dnd_handle_motion_event (drag, event);
case GDK_BUTTON_RELEASE:
return gdk_dnd_handle_button_event (drag, event);
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return gdk_dnd_handle_key_event (drag, event);
case GDK_GRAB_BROKEN:
return gdk_dnd_handle_grab_broken_event (drag, event);
default:
return FALSE;
}
}
static void
gdk_macos_drag_finalize (GObject *object)
{
@@ -536,7 +281,6 @@ gdk_macos_drag_finalize (GObject *object)
GdkMacosDragSurface *drag_surface = g_steal_pointer (&self->drag_surface);
g_clear_object (&self->cursor);
g_clear_object (&self->drag_seat);
G_OBJECT_CLASS (gdk_macos_drag_parent_class)->finalize (object);
@@ -598,7 +342,6 @@ gdk_macos_drag_class_init (GdkMacosDragClass *klass)
drag_class->set_cursor = gdk_macos_drag_set_cursor;
drag_class->cancel = gdk_macos_drag_cancel;
drag_class->drop_performed = gdk_macos_drag_drop_performed;
drag_class->handle_event = gdk_macos_drag_handle_event;
properties [PROP_DRAG_SURFACE] =
g_param_spec_object ("drag-surface", NULL, NULL,
@@ -614,11 +357,113 @@ gdk_macos_drag_init (GdkMacosDrag *self)
}
gboolean
_gdk_macos_drag_begin (GdkMacosDrag *self)
_gdk_macos_drag_begin (GdkMacosDrag *self,
GdkContentProvider *content,
GdkMacosWindow *window)
{
NSArray<NSDraggingItem *> *items;
NSDraggingSession *session;
NSPasteboardItem *item;
NSEvent *nsevent;
g_return_val_if_fail (GDK_IS_MACOS_DRAG (self), FALSE);
g_return_val_if_fail (GDK_IS_MACOS_WINDOW (window), FALSE);
_gdk_macos_surface_show (GDK_MACOS_SURFACE (self->drag_surface));
GDK_BEGIN_MACOS_ALLOC_POOL;
return drag_grab (self);
item = [[GdkMacosPasteboardItem alloc] initForDrag:GDK_DRAG (self) withContentProvider:content];
items = [NSArray arrayWithObject:item];
nsevent = _gdk_macos_display_get_last_nsevent ();
session = [[window contentView] beginDraggingSessionWithItems:items
event:nsevent
source:window];
GDK_END_MACOS_ALLOC_POOL;
_gdk_macos_display_set_drag (GDK_MACOS_DISPLAY (gdk_drag_get_display (GDK_DRAG (self))),
[session draggingSequenceNumber],
GDK_DRAG (self));
return TRUE;
}
NSDragOperation
_gdk_macos_drag_operation (GdkMacosDrag *self)
{
NSDragOperation operation = NSDragOperationNone;
GdkDragAction actions;
g_return_val_if_fail (GDK_IS_MACOS_DRAG (self), NSDragOperationNone);
actions = gdk_drag_get_actions (GDK_DRAG (self));
if (actions & GDK_ACTION_LINK)
operation |= NSDragOperationLink;
if (actions & GDK_ACTION_MOVE)
operation |= NSDragOperationMove;
if (actions & GDK_ACTION_COPY)
operation |= NSDragOperationCopy;
return operation;
}
GdkDragAction
_gdk_macos_drag_ns_operation_to_action (NSDragOperation operation)
{
if (operation & NSDragOperationCopy)
return GDK_ACTION_COPY;
if (operation & NSDragOperationMove)
return GDK_ACTION_MOVE;
if (operation & NSDragOperationLink)
return GDK_ACTION_LINK;
return 0;
}
void
_gdk_macos_drag_surface_move (GdkMacosDrag *self,
int x_root,
int y_root)
{
g_return_if_fail (GDK_IS_MACOS_DRAG (self));
self->last_x = x_root;
self->last_y = y_root;
if (GDK_IS_MACOS_SURFACE (self->drag_surface))
_gdk_macos_surface_move (GDK_MACOS_SURFACE (self->drag_surface),
x_root - self->hot_x,
y_root - self->hot_y);
}
void
_gdk_macos_drag_set_start_position (GdkMacosDrag *self,
int start_x,
int start_y)
{
g_return_if_fail (GDK_IS_MACOS_DRAG (self));
self->start_x = start_x;
self->start_y = start_y;
}
void
_gdk_macos_drag_set_actions (GdkMacosDrag *self,
GdkModifierType mods)
{
GdkDragAction suggested_action;
GdkDragAction possible_actions;
g_assert (GDK_IS_MACOS_DRAG (self));
gdk_drag_get_current_actions (mods,
GDK_BUTTON_PRIMARY,
gdk_drag_get_actions (GDK_DRAG (self)),
&suggested_action,
&possible_actions);
gdk_drag_set_selected_action (GDK_DRAG (self), suggested_action);
gdk_drag_set_actions (GDK_DRAG (self), possible_actions);
}

View File

@@ -37,11 +37,15 @@
/*
* This file implementations integration between the GLib main loop and
* the native system of the Core Foundation run loop and Cocoa event
* handling. There are basically two different cases that we need to
* handle: either the GLib main loop is in control (the application
* has called gtk_main(), or is otherwise iterating the main loop), or
* CFRunLoop is in control (we are in a modal operation such as window
* resizing or drag-and-drop.)
* handling. There are basically three different cases that we need to
* handle:
*
* - the GLib main loop is in control. The application has called
* gtk_main(), or is otherwise iterating the main loop.
* - CFRunLoop is in control. We are in a modal operation such as window
* resizing.
* - CFRunLoop is running a nested loop. This happens when a drag-and-drop
* operation has been initiated.
*
* When the GLib main loop is in control we integrate in native event
* handling in two ways: first we add a GSource that handles checking
@@ -57,14 +61,23 @@
* stages of the GLib main loop (prepare, check, dispatch), and make the
* appropriate calls into GLib.
*
* Both cases share a single problem: the OS X APIs dont allow us to
* When initiating a drag operation, a nested CFRunLoop is executed.
* The nested run loop is started when fetching a native event in our GLib
* main loop. The application does not receive any events until the nested loop
* is finished. We work around this by forwarding the
* events that trigger the callbacks of the NSDraggingSource protocol.
* The "run loop observer" is executing the GLib main loop stages as long as we're
* in the nested run loop, as if CFRunLoop were in control.
* See also GdkMacosWindow.
*
* All cases share a single problem: the macOS APIs dont allow us to
* wait simultaneously for file descriptors and for events. So when we
* need to do a blocking wait that includes file descriptor activity, we
* push the actual work of calling select() to a helper thread (the
* "select thread") and wait for native events in the main thread.
*
* The main known limitation of this code is that if a callback is triggered
* via the OS X run loop while we are "polling" (in either case described
* via the macOS run loop while we are "polling" (in either case described
* above), iteration of the GLib main loop is not possible from within
* that callback. If the programmer tries to do so explicitly, then they
* will get a warning from GLib "main loop already active in another thread".
@@ -640,6 +653,23 @@ _gdk_macos_event_source_get_pending (void)
return event;
}
static void
_gdk_macos_event_source_queue_event (NSEvent *event)
{
/* Just used to wake us up; if an event and a FD arrived at the same
* time; could have come from a previous iteration in some cases,
* but the spurious wake up is harmless if a little inefficient.
*/
if (!event ||
([event type] == NSEventTypeApplicationDefined &&
[event subtype] == GDK_MACOS_EVENT_SUBTYPE_EVENTLOOP))
return;
if (!current_events)
current_events = g_queue_new ();
g_queue_push_head (current_events, [event retain]);
}
static gboolean
gdk_macos_event_source_prepare (GSource *source,
int *timeout)
@@ -782,23 +812,7 @@ poll_func (GPollFD *ufds,
if (last_ufds == ufds && n_ready < 0)
n_ready = select_thread_collect_poll (ufds, nfds);
if (event &&
[event type] == NSEventTypeApplicationDefined &&
[event subtype] == GDK_MACOS_EVENT_SUBTYPE_EVENTLOOP)
{
/* Just used to wake us up; if an event and a FD arrived at the same
* time; could have come from a previous iteration in some cases,
* but the spurious wake up is harmless if a little inefficient.
*/
event = NULL;
}
if (event)
{
if (!current_events)
current_events = g_queue_new ();
g_queue_push_head (current_events, [event retain]);
}
_gdk_macos_event_source_queue_event (event);
return n_ready;
}
@@ -1018,7 +1032,10 @@ run_loop_observer_callback (CFRunLoopObserverRef observer,
break;
}
if (getting_events > 0) /* Activity we triggered */
/* DnD starts a nested runloop, or so it seems.
If we have such a loop, we still want to run
our idle handlers. */
if (getting_events > 0 && current_loop_level < 2)
return;
switch (activity)
@@ -1042,7 +1059,6 @@ run_loop_observer_callback (CFRunLoopObserverRef observer,
run_loop_exit ();
break;
case kCFRunLoopAllActivities:
/* TODO: Do most of the above? */
default:
break;
}

View File

@@ -548,6 +548,14 @@ gdk_macos_gl_context_clear_current (GdkGLContext *context)
return TRUE;
}
static gboolean
gdk_macos_gl_context_is_current (GdkGLContext *context)
{
GdkMacosGLContext *self = GDK_MACOS_GL_CONTEXT (context);
return self->cgl_context == CGLGetCurrentContext ();
}
static gboolean
gdk_macos_gl_context_make_current (GdkGLContext *context,
gboolean surfaceless)
@@ -639,6 +647,7 @@ gdk_macos_gl_context_class_init (GdkMacosGLContextClass *klass)
gl_class->get_damage = gdk_macos_gl_context_get_damage;
gl_class->clear_current = gdk_macos_gl_context_clear_current;
gl_class->is_current = gdk_macos_gl_context_is_current;
gl_class->make_current = gdk_macos_gl_context_make_current;
gl_class->realize = gdk_macos_gl_context_real_realize;
gl_class->get_default_framebuffer = gdk_macos_gl_context_get_default_framebuffer;

View File

@@ -0,0 +1,74 @@
/*
* Copyright © 2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef __GDK_MACOS_PASTEBOARD_PRIVATE_H__
#define __GDK_MACOS_PASTEBOARD_PRIVATE_H__
#include <AppKit/AppKit.h>
#include <gio/gio.h>
#include "gdkclipboardprivate.h"
G_BEGIN_DECLS
@interface GdkMacosPasteboardItemDataProvider : NSObject <NSPasteboardItemDataProvider>
{
GdkContentProvider *_contentProvider;
GdkClipboard *_clipboard;
GdkDrag *_drag;
}
-(id)initForClipboard:(GdkClipboard *)clipboard withContentProvider:(GdkContentProvider *)contentProvider;
-(id)initForDrag:(GdkDrag *)drag withContentProvider:(GdkContentProvider *)contentProvider;
@end
@interface GdkMacosPasteboardItem : NSPasteboardItem
{
GdkContentProvider *_contentProvider;
GdkClipboard *_clipboard;
GdkDrag *_drag;
NSRect _draggingFrame;
}
-(id)initForClipboard:(GdkClipboard *)clipboard withContentProvider:(GdkContentProvider *)contentProvider;
-(id)initForDrag:(GdkDrag *)drag withContentProvider:(GdkContentProvider *)contentProvider;
@end
NSPasteboardType _gdk_macos_pasteboard_to_ns_type (const char *mime_type,
NSPasteboardType *alternate);
const char *_gdk_macos_pasteboard_from_ns_type (NSPasteboardType type);
GdkContentFormats *_gdk_macos_pasteboard_load_formats (NSPasteboard *pasteboard);
void _gdk_macos_pasteboard_register_drag_types (NSWindow *window);
void _gdk_macos_pasteboard_read_async (GObject *object,
NSPasteboard *pasteboard,
GdkContentFormats *formats,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GInputStream *_gdk_macos_pasteboard_read_finish (GObject *object,
GAsyncResult *result,
const char **out_mime_type,
GError **error);
G_END_DECLS
#endif /* __GDK_MACOS_PASTEBOARD_PRIVATE_H__ */

View File

@@ -0,0 +1,602 @@
/*
* Copyright © 2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include <glib/gi18n.h>
#include "gdkdragprivate.h"
#include "gdkmacospasteboard-private.h"
#include "gdkmacosutils-private.h"
enum {
TYPE_STRING,
TYPE_PBOARD,
TYPE_URL,
TYPE_FILE_URL,
TYPE_COLOR,
TYPE_TIFF,
TYPE_PNG,
TYPE_LAST
};
#define PTYPE(k) (get_pasteboard_type(TYPE_##k))
static NSPasteboardType pasteboard_types[TYPE_LAST];
static NSPasteboardType
get_pasteboard_type (int type)
{
static gsize initialized = FALSE;
g_assert (type >= 0);
g_assert (type < TYPE_LAST);
if (g_once_init_enter (&initialized))
{
pasteboard_types[TYPE_PNG] = NSPasteboardTypePNG;
pasteboard_types[TYPE_STRING] = NSPasteboardTypeString;
pasteboard_types[TYPE_TIFF] = NSPasteboardTypeTIFF;
pasteboard_types[TYPE_COLOR] = NSPasteboardTypeColor;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pasteboard_types[TYPE_PBOARD] = NSStringPboardType;
G_GNUC_END_IGNORE_DEPRECATIONS
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
pasteboard_types[TYPE_URL] = NSPasteboardTypeURL;
pasteboard_types[TYPE_FILE_URL] = NSPasteboardTypeFileURL;
#else
pasteboard_types[TYPE_URL] = [[NSString alloc] initWithUTF8String:"public.url"];
pasteboard_types[TYPE_FILE_URL] = [[NSString alloc] initWithUTF8String:"public.file-url"];
#endif
g_once_init_leave (&initialized, TRUE);
}
return pasteboard_types[type];
}
const char *
_gdk_macos_pasteboard_from_ns_type (NSPasteboardType type)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([type isEqualToString:PTYPE(STRING)] ||
[type isEqualToString:PTYPE(PBOARD)])
return g_intern_string ("text/plain;charset=utf-8");
else if ([type isEqualToString:PTYPE(URL)] ||
[type isEqualToString:PTYPE(FILE_URL)])
return g_intern_string ("text/uri-list");
else if ([type isEqualToString:PTYPE(COLOR)])
return g_intern_string ("application/x-color");
else if ([type isEqualToString:PTYPE(TIFF)])
return g_intern_string ("image/tiff");
else if ([type isEqualToString:PTYPE(PNG)])
return g_intern_string ("image/png");
G_GNUC_END_IGNORE_DEPRECATIONS;
return NULL;
}
NSPasteboardType
_gdk_macos_pasteboard_to_ns_type (const char *mime_type,
NSPasteboardType *alternate)
{
if (alternate)
*alternate = NULL;
if (g_strcmp0 (mime_type, "text/plain;charset=utf-8") == 0)
{
return PTYPE(STRING);
}
else if (g_strcmp0 (mime_type, "text/uri-list") == 0)
{
if (alternate)
*alternate = PTYPE(URL);
return PTYPE(FILE_URL);
}
else if (g_strcmp0 (mime_type, "application/x-color") == 0)
{
return PTYPE(COLOR);
}
else if (g_strcmp0 (mime_type, "image/tiff") == 0)
{
return PTYPE(TIFF);
}
else if (g_strcmp0 (mime_type, "image/png") == 0)
{
return PTYPE(PNG);
}
return nil;
}
static void
populate_content_formats (GdkContentFormatsBuilder *builder,
NSPasteboardType type)
{
const char *mime_type;
g_assert (builder != NULL);
g_assert (type != NULL);
if ((mime_type = _gdk_macos_pasteboard_from_ns_type (type)))
gdk_content_formats_builder_add_mime_type (builder, mime_type);
}
static GdkContentFormats *
load_offer_formats (NSPasteboard *pasteboard)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkContentFormatsBuilder *builder;
GdkContentFormats *formats;
builder = gdk_content_formats_builder_new ();
for (NSPasteboardType type in [pasteboard types])
populate_content_formats (builder, type);
formats = gdk_content_formats_builder_free_to_formats (builder);
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&formats);
}
GdkContentFormats *
_gdk_macos_pasteboard_load_formats (NSPasteboard *pasteboard)
{
return load_offer_formats (pasteboard);
}
static GInputStream *
create_stream_from_nsdata (NSData *data)
{
const guint8 *bytes = [data bytes];
gsize len = [data length];
return g_memory_input_stream_new_from_data (g_memdup2 (bytes, len), len, g_free);
}
void
_gdk_macos_pasteboard_read_async (GObject *object,
NSPasteboard *pasteboard,
GdkContentFormats *formats,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkContentFormats *offer_formats = NULL;
const char *mime_type;
GInputStream *stream = NULL;
GTask *task = NULL;
g_assert (G_IS_OBJECT (object));
g_assert (pasteboard != NULL);
g_assert (formats != NULL);
task = g_task_new (object, cancellable, callback, user_data);
g_task_set_source_tag (task, _gdk_macos_pasteboard_read_async);
g_task_set_priority (task, io_priority);
offer_formats = load_offer_formats (pasteboard);
mime_type = gdk_content_formats_match_mime_type (formats, offer_formats);
if (mime_type == NULL)
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"%s",
_("No compatible transfer format found"));
goto cleanup;
}
if (strcmp (mime_type, "text/plain;charset=utf-8") == 0)
{
NSString *nsstr = [pasteboard stringForType:NSPasteboardTypeString];
if (nsstr != NULL)
{
const char *str = [nsstr UTF8String];
stream = g_memory_input_stream_new_from_data (g_strdup (str),
strlen (str) + 1,
g_free);
}
}
else if (strcmp (mime_type, "text/uri-list") == 0)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if ([[pasteboard types] containsObject:PTYPE(FILE_URL)])
{
GString *str = g_string_new (NULL);
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
gsize n_files = [files count];
char *data;
guint len;
for (gsize i = 0; i < n_files; ++i)
{
NSString* uriString = [files objectAtIndex:i];
uriString = [@"file://" stringByAppendingString:uriString];
uriString = [uriString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
g_string_append_printf (str,
"%s\r\n",
[uriString cStringUsingEncoding:NSUTF8StringEncoding]);
}
len = str->len;
data = g_string_free (str, FALSE);
stream = g_memory_input_stream_new_from_data (data, len, g_free);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
}
else if (strcmp (mime_type, "application/x-color") == 0)
{
NSColorSpace *colorspace;
NSColor *nscolor;
guint16 color[4];
colorspace = [NSColorSpace genericRGBColorSpace];
nscolor = [[NSColor colorFromPasteboard:pasteboard]
colorUsingColorSpace:colorspace];
color[0] = 0xffff * [nscolor redComponent];
color[1] = 0xffff * [nscolor greenComponent];
color[2] = 0xffff * [nscolor blueComponent];
color[3] = 0xffff * [nscolor alphaComponent];
stream = g_memory_input_stream_new_from_data (g_memdup2 (&color, sizeof color),
sizeof color,
g_free);
}
else if (strcmp (mime_type, "image/tiff") == 0)
{
NSData *data = [pasteboard dataForType:PTYPE(TIFF)];
stream = create_stream_from_nsdata (data);
}
else if (strcmp (mime_type, "image/png") == 0)
{
NSData *data = [pasteboard dataForType:PTYPE(PNG)];
stream = create_stream_from_nsdata (data);
}
if (stream != NULL)
{
g_task_set_task_data (task, g_strdup (mime_type), g_free);
g_task_return_pointer (task, g_steal_pointer (&stream), g_object_unref);
}
else
{
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
_("Failed to decode contents with mime-type of '%s'"),
mime_type);
}
cleanup:
g_clear_object (&task);
g_clear_pointer (&offer_formats, gdk_content_formats_unref);
GDK_END_MACOS_ALLOC_POOL;
}
GInputStream *
_gdk_macos_pasteboard_read_finish (GObject *object,
GAsyncResult *result,
const char **out_mime_type,
GError **error)
{
GTask *task = (GTask *)result;
g_assert (G_IS_OBJECT (object));
g_assert (G_IS_TASK (task));
if (out_mime_type != NULL)
*out_mime_type = g_strdup (g_task_get_task_data (task));
return g_task_propagate_pointer (task, error);
}
void
_gdk_macos_pasteboard_register_drag_types (NSWindow *window)
{
[window registerForDraggedTypes:[NSArray arrayWithObjects:PTYPE(STRING),
PTYPE(PBOARD),
PTYPE(URL),
PTYPE(FILE_URL),
PTYPE(COLOR),
PTYPE(TIFF),
PTYPE(PNG),
nil]];
}
@implementation GdkMacosPasteboardItemDataProvider
-(id)initForClipboard:(GdkClipboard*)clipboard withContentProvider:(GdkContentProvider*)contentProvider
{
[super init];
g_set_object (&self->_clipboard, clipboard);
g_set_object (&self->_contentProvider, contentProvider);
return self;
}
-(id)initForDrag:(GdkDrag*)drag withContentProvider:(GdkContentProvider*)contentProvider
{
[super init];
g_set_object (&self->_drag, drag);
g_set_object (&self->_contentProvider, contentProvider);
return self;
}
-(void)dealloc
{
g_clear_object (&self->_contentProvider);
g_clear_object (&self->_clipboard);
g_clear_object (&self->_drag);
[super dealloc];
}
-(NSArray<NSPasteboardType> *)types
{
NSMutableArray *ret = [[NSMutableArray alloc] init];
GdkContentFormats *serializable;
const char * const *mime_types;
gsize n_mime_types;
serializable = gdk_content_provider_ref_storable_formats (self->_contentProvider);
serializable = gdk_content_formats_union_serialize_mime_types (serializable);
mime_types = gdk_content_formats_get_mime_types (serializable, &n_mime_types);
for (gsize i = 0; i < n_mime_types; i++)
{
const char *mime_type = mime_types[i];
NSPasteboardType type;
NSPasteboardType alternate = nil;
if ((type = _gdk_macos_pasteboard_to_ns_type (mime_type, &alternate)))
{
[ret addObject:type];
if (alternate)
[ret addObject:alternate];
}
}
gdk_content_formats_unref (serializable);
/* Default to an url type (think gobject://internal)
* to support internal, GType-based DnD.
*/
if (n_mime_types == 0)
{
GdkContentFormats *formats;
gsize n_gtypes;
formats = gdk_content_provider_ref_formats (self->_contentProvider);
gdk_content_formats_get_gtypes (formats, &n_gtypes);
if (n_gtypes)
[ret addObject:NSPasteboardTypeURL];
gdk_content_formats_unref (formats);
}
return g_steal_pointer (&ret);
}
typedef struct
{
GMemoryOutputStream *stream;
NSPasteboardItem *item;
NSPasteboardType type;
GMainContext *main_context;
guint done : 1;
} WriteRequest;
static void
write_request_free (WriteRequest *wr)
{
g_clear_pointer (&wr->main_context, g_main_context_unref);
g_clear_object (&wr->stream);
[wr->item release];
g_slice_free (WriteRequest, wr);
}
static void
on_data_ready_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
WriteRequest *wr = user_data;
GError *error = NULL;
NSData *data = nil;
gboolean ret;
g_assert (G_IS_OBJECT (object));
g_assert (GDK_IS_CLIPBOARD (object) || GDK_IS_DRAG (object));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (wr != NULL);
g_assert (G_IS_MEMORY_OUTPUT_STREAM (wr->stream));
g_assert ([wr->item isKindOfClass:[NSPasteboardItem class]]);
if (GDK_IS_CLIPBOARD (object))
ret = gdk_clipboard_write_finish (GDK_CLIPBOARD (object), result, &error);
else if (GDK_IS_DRAG (object))
ret = gdk_drag_write_finish (GDK_DRAG (object), result, &error);
else
g_return_if_reached ();
if (ret)
{
gsize size;
gpointer bytes;
g_output_stream_close (G_OUTPUT_STREAM (wr->stream), NULL, NULL);
size = g_memory_output_stream_get_data_size (wr->stream);
bytes = g_memory_output_stream_steal_data (wr->stream);
data = [[NSData alloc] initWithBytesNoCopy:bytes
length:size
deallocator:^(void *alloc, NSUInteger length) { g_free (alloc); }];
}
else
{
g_warning ("Failed to serialize pasteboard contents: %s",
error->message);
g_clear_error (&error);
}
[wr->item setData:data forType:wr->type];
wr->done = TRUE;
GDK_END_MACOS_ALLOC_POOL;
}
-(void)pasteboard:(NSPasteboard *)pasteboard item:(NSPasteboardItem *)item provideDataForType:(NSPasteboardType)type
{
const char *mime_type = _gdk_macos_pasteboard_from_ns_type (type);
GMainContext *main_context = g_main_context_default ();
WriteRequest *wr;
if (self->_contentProvider == NULL || mime_type == NULL)
{
[item setData:[NSData data] forType:type];
return;
}
wr = g_slice_new0 (WriteRequest);
wr->item = [item retain];
wr->stream = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new_resizable ());
wr->type = type;
wr->main_context = g_main_context_ref (main_context);
wr->done = FALSE;
if (GDK_IS_CLIPBOARD (self->_clipboard))
gdk_clipboard_write_async (self->_clipboard,
mime_type,
G_OUTPUT_STREAM (wr->stream),
G_PRIORITY_DEFAULT,
NULL,
on_data_ready_cb,
wr);
else if (GDK_IS_DRAG (self->_drag))
gdk_drag_write_async (self->_drag,
mime_type,
G_OUTPUT_STREAM (wr->stream),
G_PRIORITY_DEFAULT,
NULL,
on_data_ready_cb,
wr);
else
g_return_if_reached ();
/* We're forced to provide data synchronously via this API
* so we must block on the main loop. Using another main loop
* than the default tends to get us locked up here, so that is
* what we'll do for now.
*/
while (!wr->done)
g_main_context_iteration (wr->main_context, TRUE);
write_request_free (wr);
}
-(void)pasteboardFinishedWithDataProvider:(NSPasteboard *)pasteboard
{
g_clear_object (&self->_clipboard);
g_clear_object (&self->_drag);
g_clear_object (&self->_contentProvider);
}
@end
@implementation GdkMacosPasteboardItem
-(id)initForClipboard:(GdkClipboard*)clipboard withContentProvider:(GdkContentProvider*)contentProvider
{
GdkMacosPasteboardItemDataProvider *dataProvider;
dataProvider = [[GdkMacosPasteboardItemDataProvider alloc] initForClipboard:clipboard withContentProvider:contentProvider];
[super init];
g_set_object (&self->_clipboard, clipboard);
g_set_object (&self->_contentProvider, contentProvider);
[self setDataProvider:dataProvider forTypes:[dataProvider types]];
[dataProvider release];
return self;
}
-(id)initForDrag:(GdkDrag*)drag withContentProvider:(GdkContentProvider*)contentProvider
{
GdkMacosPasteboardItemDataProvider *dataProvider;
dataProvider = [[GdkMacosPasteboardItemDataProvider alloc] initForDrag:drag withContentProvider:contentProvider];
[super init];
g_set_object (&self->_drag, drag);
g_set_object (&self->_contentProvider, contentProvider);
[self setDataProvider:dataProvider forTypes:[dataProvider types]];
[dataProvider release];
return self;
}
-(void)dealloc
{
g_clear_object (&self->_contentProvider);
g_clear_object (&self->_clipboard);
g_clear_object (&self->_drag);
[super dealloc];
}
-(NSRect)draggingFrame
{
return self->_draggingFrame;
}
-(void)setDraggingFrame:(NSRect)draggingFrame;
{
self->_draggingFrame = draggingFrame;
}
-(id)item
{
return self;
}
-(NSArray* (^) (void))imageComponentsProvider
{
return nil;
}
@end

View File

@@ -431,7 +431,7 @@ gdk_macos_surface_drag_begin (GdkSurface *surface,
_gdk_macos_surface_get_root_coords (GDK_MACOS_SURFACE (surface), &sx, &sy);
drag_surface = _gdk_macos_surface_new (GDK_MACOS_DISPLAY (surface->display),
GDK_SURFACE_DRAG,
surface,
NULL,
sx, sy, 1, 1);
drag = g_object_new (GDK_TYPE_MACOS_DRAG,
"drag-surface", drag_surface,
@@ -446,7 +446,7 @@ gdk_macos_surface_drag_begin (GdkSurface *surface,
gdk_drag_get_selected_action (GDK_DRAG (drag)));
gdk_drag_set_cursor (GDK_DRAG (drag), cursor);
if (!_gdk_macos_drag_begin (drag))
if (!_gdk_macos_drag_begin (drag, content, self->window))
{
g_object_unref (drag);
return NULL;

View File

@@ -19,6 +19,7 @@ gdk_macos_sources = files([
'gdkmacoseventsource.c',
'gdkmacoskeymap.c',
'gdkmacosmonitor.c',
'gdkmacospasteboard.c',
'gdkmacospopupsurface.c',
'gdkmacosseat.c',
'gdkmacossurface.c',

View File

@@ -43,6 +43,7 @@ gdk_public_sources = files([
'gdkseatdefault.c',
'gdksnapshot.c',
'gdktexture.c',
'gdktexturedownloader.c',
'gdkvulkancontext.c',
'gdksurface.c',
'gdkpopuplayout.c',
@@ -95,6 +96,7 @@ gdk_public_headers = files([
'gdkseat.h',
'gdksnapshot.h',
'gdktexture.h',
'gdktexturedownloader.h',
'gdktypes.h',
'gdkvulkancontext.h',
'gdksurface.h',

View File

@@ -87,7 +87,7 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
xdg_activation_token_v1_commit (token);
while (app_launch_data.token == NULL)
wl_display_dispatch_queue (display->wl_display, event_queue);
gdk_wayland_display_dispatch_queue (GDK_DISPLAY (display), event_queue);
xdg_activation_token_v1_destroy (token);
id = app_launch_data.token;

View File

@@ -2,6 +2,236 @@
#define __GDK_DEVICE_WAYLAND_PRIVATE_H__
#include "gdkwaylanddevice.h"
#include "gdkwaylandseat.h"
#include <gdk/gdkdeviceprivate.h>
#include <gdk/gdkkeysprivate.h>
#include <xkbcommon/xkbcommon.h>
struct _GdkWaylandDevice
{
GdkDevice parent_instance;
};
struct _GdkWaylandDeviceClass
{
GdkDeviceClass parent_class;
};
typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
typedef struct _GdkWaylandPointerFrameData GdkWaylandPointerFrameData;
typedef struct _GdkWaylandPointerData GdkWaylandPointerData;
typedef struct _GdkWaylandTabletPadGroupData GdkWaylandTabletPadGroupData;
typedef struct _GdkWaylandTabletPadData GdkWaylandTabletPadData;
typedef struct _GdkWaylandTabletData GdkWaylandTabletData;
typedef struct _GdkWaylandTabletToolData GdkWaylandTabletToolData;
struct _GdkWaylandTouchData
{
uint32_t id;
double x;
double y;
GdkSurface *surface;
uint32_t touch_down_serial;
guint initial_touch : 1;
};
struct _GdkWaylandPointerFrameData
{
GdkEvent *event;
/* Specific to the scroll event */
double delta_x, delta_y;
int32_t value120_x, value120_y;
gint8 is_scroll_stop;
enum wl_pointer_axis_source source;
};
struct _GdkWaylandPointerData {
GdkSurface *focus;
double surface_x, surface_y;
GdkModifierType button_modifiers;
uint32_t time;
uint32_t enter_serial;
uint32_t press_serial;
GdkSurface *grab_surface;
uint32_t grab_time;
struct wl_surface *pointer_surface;
guint cursor_is_default: 1;
GdkCursor *cursor;
guint cursor_timeout_id;
guint cursor_image_index;
guint cursor_image_delay;
guint touchpad_event_sequence;
guint current_output_scale;
GSList *pointer_surface_outputs;
/* Accumulated event data for a pointer frame */
GdkWaylandPointerFrameData frame;
};
struct _GdkWaylandTabletPadGroupData
{
GdkWaylandTabletPadData *pad;
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group;
GList *rings;
GList *strips;
GList *buttons;
guint mode_switch_serial;
guint n_modes;
guint current_mode;
struct {
guint source;
gboolean is_stop;
double value;
} axis_tmp_info;
};
struct _GdkWaylandTabletPadData
{
GdkSeat *seat;
struct zwp_tablet_pad_v2 *wp_tablet_pad;
GdkDevice *device;
GdkWaylandTabletData *current_tablet;
guint enter_serial;
uint32_t n_buttons;
char *path;
GList *rings;
GList *strips;
GList *mode_groups;
};
struct _GdkWaylandTabletToolData
{
GdkSeat *seat;
struct zwp_tablet_tool_v2 *wp_tablet_tool;
GdkAxisFlags axes;
GdkDeviceToolType type;
guint64 hardware_serial;
guint64 hardware_id_wacom;
GdkDeviceTool *tool;
GdkWaylandTabletData *current_tablet;
};
struct _GdkWaylandTabletData
{
struct zwp_tablet_v2 *wp_tablet;
char *name;
char *path;
uint32_t vid;
uint32_t pid;
GdkDevice *logical_device;
GdkDevice *stylus_device;
GdkSeat *seat;
GdkWaylandPointerData pointer_info;
GList *pads;
GdkWaylandTabletToolData *current_tool;
int axis_indices[GDK_AXIS_LAST];
double axes[GDK_AXIS_LAST];
};
struct _GdkWaylandSeat
{
GdkSeat parent_instance;
guint32 id;
struct wl_seat *wl_seat;
struct wl_pointer *wl_pointer;
struct wl_keyboard *wl_keyboard;
struct wl_touch *wl_touch;
struct zwp_pointer_gesture_swipe_v1 *wp_pointer_gesture_swipe;
struct zwp_pointer_gesture_pinch_v1 *wp_pointer_gesture_pinch;
struct zwp_pointer_gesture_hold_v1 *wp_pointer_gesture_hold;
struct zwp_tablet_seat_v2 *wp_tablet_seat;
GdkDisplay *display;
GdkDevice *logical_pointer;
GdkDevice *logical_keyboard;
GdkDevice *pointer;
GdkDevice *wheel_scrolling;
GdkDevice *finger_scrolling;
GdkDevice *continuous_scrolling;
GdkDevice *keyboard;
GdkDevice *logical_touch;
GdkDevice *touch;
GdkCursor *cursor;
GdkKeymap *keymap;
GHashTable *touches;
GList *tablets;
GList *tablet_tools;
GList *tablet_pads;
GdkWaylandPointerData pointer_info;
GdkWaylandPointerData touch_info;
GdkModifierType key_modifiers;
GdkSurface *keyboard_focus;
GdkSurface *grab_surface;
uint32_t grab_time;
gboolean have_server_repeat;
uint32_t server_repeat_rate;
uint32_t server_repeat_delay;
struct wl_data_offer *pending_offer;
GdkContentFormatsBuilder *pending_builder;
GdkDragAction pending_source_actions;
GdkDragAction pending_action;
struct wl_callback *repeat_callback;
guint32 repeat_timer;
guint32 repeat_key;
guint32 repeat_count;
gint64 repeat_deadline;
uint32_t keyboard_time;
uint32_t keyboard_key_serial;
GdkClipboard *clipboard;
GdkClipboard *primary_clipboard;
struct wl_data_device *data_device;
GdkDrag *drag;
GdkDrop *drop;
/* Some tracking on gesture events */
guint gesture_n_fingers;
double gesture_scale;
GdkCursor *grab_cursor;
};
#define GDK_TYPE_WAYLAND_DEVICE_PAD (gdk_wayland_device_pad_get_type ())
GType gdk_wayland_device_pad_get_type (void);
void gdk_wayland_seat_stop_cursor_animation (GdkWaylandSeat *seat,
GdkWaylandPointerData *pointer);
GdkWaylandPointerData * gdk_wayland_device_get_pointer (GdkWaylandDevice *wayland_device);
void gdk_wayland_device_set_pointer (GdkWaylandDevice *wayland_device,
GdkWaylandPointerData *pointer);
GdkWaylandTouchData * gdk_wayland_device_get_emulating_touch (GdkWaylandDevice *wayland_device);
void gdk_wayland_device_set_emulating_touch (GdkWaylandDevice *wayland_device,
GdkWaylandTouchData *touch);
void gdk_wayland_device_query_state (GdkDevice *device,
GdkSurface *surface,
@@ -14,4 +244,24 @@ void gdk_wayland_device_pad_set_feedback (GdkDevice *device,
guint feature_idx,
const char *label);
GdkWaylandTabletPadData * gdk_wayland_seat_find_pad (GdkWaylandSeat *seat,
GdkDevice *device);
GdkWaylandTabletData * gdk_wayland_seat_find_tablet (GdkWaylandSeat *seat,
GdkDevice *device);
GdkWaylandTouchData * gdk_wayland_seat_get_touch (GdkWaylandSeat *seat,
uint32_t id);
void gdk_wayland_device_maybe_emit_grab_crossing (GdkDevice *device,
GdkSurface *window,
guint32 time);
GdkSurface * gdk_wayland_device_maybe_emit_ungrab_crossing (GdkDevice *device,
guint32 time_);
gboolean gdk_wayland_device_update_surface_cursor (GdkDevice *device);
GdkModifierType gdk_wayland_device_get_modifiers (GdkDevice *device);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,266 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkwaylanddevice.h"
#include "gdkdevice-wayland-private.h"
#include "tablet-unstable-v2-client-protocol.h"
#include <gdk/gdkdevicepadprivate.h>
typedef struct _GdkWaylandDevicePad GdkWaylandDevicePad;
typedef struct _GdkWaylandDevicePadClass GdkWaylandDevicePadClass;
struct _GdkWaylandDevicePad
{
GdkWaylandDevice parent_instance;
};
struct _GdkWaylandDevicePadClass
{
GdkWaylandDeviceClass parent_class;
};
static void gdk_wayland_device_pad_iface_init (GdkDevicePadInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDevicePad, gdk_wayland_device_pad,
GDK_TYPE_WAYLAND_DEVICE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_DEVICE_PAD,
gdk_wayland_device_pad_iface_init))
static int
gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
{
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadData *data;
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return 0;
#else
g_assert (data != NULL);
#endif
return g_list_length (data->mode_groups);
}
static int
gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
int n_group)
{
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadGroupData *group;
GdkWaylandTabletPadData *data;
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return 0;
#else
g_assert (data != NULL);
#endif
group = g_list_nth_data (data->mode_groups, n_group);
if (!group)
return -1;
return group->n_modes;
}
static int
gdk_wayland_device_pad_get_n_features (GdkDevicePad *pad,
GdkDevicePadFeature feature)
{
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadData *data;
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
g_assert (data != NULL);
switch (feature)
{
case GDK_DEVICE_PAD_FEATURE_BUTTON:
return data->n_buttons;
case GDK_DEVICE_PAD_FEATURE_RING:
return g_list_length (data->rings);
case GDK_DEVICE_PAD_FEATURE_STRIP:
return g_list_length (data->strips);
default:
return -1;
}
}
static int
gdk_wayland_device_pad_get_feature_group (GdkDevicePad *pad,
GdkDevicePadFeature feature,
int idx)
{
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
GdkWaylandTabletPadGroupData *group;
GdkWaylandTabletPadData *data;
GList *l;
int i;
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return -1;
#else
g_assert (data != NULL);
#endif
for (l = data->mode_groups, i = 0; l; l = l->next, i++)
{
group = l->data;
switch (feature)
{
case GDK_DEVICE_PAD_FEATURE_BUTTON:
if (g_list_find (group->buttons, GINT_TO_POINTER (idx)))
return i;
break;
case GDK_DEVICE_PAD_FEATURE_RING:
{
gpointer ring;
ring = g_list_nth_data (data->rings, idx);
if (ring && g_list_find (group->rings, ring))
return i;
break;
}
case GDK_DEVICE_PAD_FEATURE_STRIP:
{
gpointer strip;
strip = g_list_nth_data (data->strips, idx);
if (strip && g_list_find (group->strips, strip))
return i;
break;
}
default:
break;
}
}
return -1;
}
static void
gdk_wayland_device_pad_iface_init (GdkDevicePadInterface *iface)
{
iface->get_n_groups = gdk_wayland_device_pad_get_n_groups;
iface->get_group_n_modes = gdk_wayland_device_pad_get_group_n_modes;
iface->get_n_features = gdk_wayland_device_pad_get_n_features;
iface->get_feature_group = gdk_wayland_device_pad_get_feature_group;
}
static void
gdk_wayland_device_pad_class_init (GdkWaylandDevicePadClass *klass)
{
}
static void
gdk_wayland_device_pad_init (GdkWaylandDevicePad *pad)
{
}
static GdkWaylandTabletPadGroupData *
tablet_pad_lookup_button_group (GdkWaylandTabletPadData *pad,
uint32_t button)
{
GdkWaylandTabletPadGroupData *group;
GList *l;
for (l = pad->mode_groups; l; l = l->next)
{
group = l->data;
if (g_list_find (group->buttons, GUINT_TO_POINTER (button)))
return group;
}
return NULL;
}
/*<private>
* gdk_wayland_device_pad_set_feedback:
* @device: (type GdkWaylandDevice): a %GDK_SOURCE_TABLET_PAD device
* @feature: Feature to set the feedback label for
* @feature_idx: 0-indexed index of the feature to set the feedback label for
* @label: Feedback label
*
* Sets the feedback label for the given feature/index.
*
* This may be used by the compositor to provide user feedback
* of the actions available/performed.
*/
void
gdk_wayland_device_pad_set_feedback (GdkDevice *device,
GdkDevicePadFeature feature,
guint feature_idx,
const char *label)
{
GdkWaylandTabletPadData *pad;
GdkWaylandTabletPadGroupData *group;
GdkSeat *seat;
seat = gdk_device_get_seat (device);
pad = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat), device);
if (!pad)
return;
if (feature == GDK_DEVICE_PAD_FEATURE_BUTTON)
{
group = tablet_pad_lookup_button_group (pad, feature_idx);
if (!group)
return;
zwp_tablet_pad_v2_set_feedback (pad->wp_tablet_pad, feature_idx, label,
group->mode_switch_serial);
}
else if (feature == GDK_DEVICE_PAD_FEATURE_RING)
{
struct zwp_tablet_pad_ring_v2 *wp_pad_ring;
wp_pad_ring = g_list_nth_data (pad->rings, feature_idx);
if (!wp_pad_ring)
return;
group = zwp_tablet_pad_ring_v2_get_user_data (wp_pad_ring);
zwp_tablet_pad_ring_v2_set_feedback (wp_pad_ring, label,
group->mode_switch_serial);
}
else if (feature == GDK_DEVICE_PAD_FEATURE_STRIP)
{
struct zwp_tablet_pad_strip_v2 *wp_pad_strip;
wp_pad_strip = g_list_nth_data (pad->strips, feature_idx);
if (!wp_pad_strip)
return;
group = zwp_tablet_pad_strip_v2_get_user_data (wp_pad_strip);
zwp_tablet_pad_strip_v2_set_feedback (wp_pad_strip, label,
group->mode_switch_serial);
}
}

View File

@@ -49,6 +49,7 @@
#include "gdkvulkancontext-wayland.h"
#include "gdkwaylandmonitor.h"
#include "gdkprofilerprivate.h"
#include "gdktoplevel-wayland-private.h"
#include <wayland/pointer-gestures-unstable-v1-client-protocol.h>
#include "tablet-unstable-v2-client-protocol.h"
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
@@ -831,6 +832,8 @@ gdk_wayland_display_get_next_serial (GdkDisplay *display)
* if no ID has been defined.
*
* Returns: (nullable): the startup notification ID for @display
*
* Deprecated: 4.10.
*/
const char *
gdk_wayland_display_get_startup_notification_id (GdkDisplay *display)
@@ -852,6 +855,8 @@ gdk_wayland_display_get_startup_notification_id (GdkDisplay *display)
* The startup ID is also what is used to signal that the startup is
* complete (for example, when opening a window or when calling
* [method@Gdk.Display.notify_startup_complete]).
*
* Deprecated: 4.10. Use [method@Gdk.Toplevel.set_startup_id]
*/
void
gdk_wayland_display_set_startup_notification_id (GdkDisplay *display,
@@ -980,7 +985,9 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->queue_events = _gdk_wayland_display_queue_events;
display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->create_surface = _gdk_wayland_display_create_surface;
display_class->get_keymap = _gdk_wayland_display_get_keymap;
@@ -2325,6 +2332,7 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
monitor->x, monitor->y,
monitor->width, monitor->height });
gdk_monitor_set_connector (GDK_MONITOR (monitor), monitor->name);
gdk_monitor_set_description (GDK_MONITOR (monitor), monitor->description);
monitor->wl_output_done = FALSE;
monitor->xdg_output_done = FALSE;
@@ -2381,7 +2389,7 @@ xdg_output_handle_name (void *data,
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
GDK_DEBUG (MISC, "handle name xdg-output %d", monitor->id);
GDK_DEBUG (MISC, "handle name xdg-output %d: %s", monitor->id, name);
monitor->name = g_strdup (name);
}
@@ -2391,8 +2399,11 @@ xdg_output_handle_description (void *data,
struct zxdg_output_v1 *xdg_output,
const char *description)
{
GDK_DEBUG (MISC, "handle description xdg-output %d",
((GdkWaylandMonitor *)data)->id);
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
GDK_DEBUG (MISC, "handle description xdg-output %d: %s", monitor->id, description);
monitor->description = g_strdup (description);
}
static const struct zxdg_output_v1_listener xdg_output_listener = {
@@ -2683,3 +2694,17 @@ gdk_wayland_display_query_registry (GdkDisplay *display,
return FALSE;
}
void
gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
if (wl_display_dispatch_queue (display_wayland->wl_display, event_queue) == -1)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
errno, g_strerror (errno));
_exit (1);
}
}

View File

@@ -158,6 +158,9 @@ struct _GdkWaylandDisplayClass
gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display);
void gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue);
G_END_DECLS
#endif /* __GDK_WAYLAND_DISPLAY__ */

View File

@@ -367,10 +367,10 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkWaylandDrag *drag_wayland;
GdkDrag *drag;
GdkSeat *seat;
GdkWaylandDisplay *display_wayland;
GdkDisplay *display;
GdkCursor *cursor;
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
display = gdk_device_get_display (device);
seat = gdk_device_get_seat (device);
drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG,
@@ -382,17 +382,13 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
drag = GDK_DRAG (drag_wayland);
drag_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
drag_wayland->dnd_surface = _gdk_wayland_display_create_surface (display, GDK_SURFACE_DRAG, NULL, 0, 0, 100, 100);
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
gdk_wayland_drag_create_data_source (drag);
if (display_wayland->data_device_manager_version >=
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
{
wl_data_source_set_actions (drag_wayland->data_source,
gdk_to_wl_actions (actions));
}
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >= WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
wl_data_source_set_actions (drag_wayland->data_source, gdk_to_wl_actions (actions));
gdk_wayland_seat_set_drag (seat, drag);

View File

@@ -0,0 +1,136 @@
/*
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdksurface-wayland.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplay-wayland.h"
#include "gdkdragsurfaceprivate.h"
#include "gdkeventsprivate.h"
#include "gdkframeclockidleprivate.h"
#include "gdkglcontext-wayland.h"
#include "gdkmonitor-wayland.h"
#include "gdkpopupprivate.h"
#include "gdkprivate-wayland.h"
#include "gdkprivate-wayland.h"
#include "gdkseat-wayland.h"
#include "gdksurfaceprivate.h"
#include "gdktoplevelprivate.h"
#include "gdkdevice-wayland-private.h"
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <unistd.h>
#include "gdksurface-wayland-private.h"
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandDragSurface;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandDragSurfaceClass;
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
#define GDK_IS_WAYLAND_DRAG_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_SURFACE))
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
gdk_wayland_drag_surface_iface_init))
static void
gdk_wayland_drag_surface_init (GdkWaylandDragSurface *surface)
{
}
static gboolean
gdk_wayland_drag_surface_compute_size (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (impl->next_layout.surface_geometry_dirty)
{
gdk_wayland_surface_update_size (surface,
impl->next_layout.configured_width,
impl->next_layout.configured_height,
impl->scale);
impl->next_layout.surface_geometry_dirty = FALSE;
}
return FALSE;
}
static void
gdk_wayland_drag_surface_class_init (GdkWaylandDragSurfaceClass *class)
{
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
surface_class->compute_size = gdk_wayland_drag_surface_compute_size;
}
static void
maybe_notify_mapped (GdkSurface *surface)
{
if (surface->destroyed)
return;
if (!GDK_SURFACE_IS_MAPPED (surface))
gdk_surface_set_is_mapped (surface, TRUE);
}
static gboolean
gdk_wayland_drag_surface_present (GdkDragSurface *drag_surface,
int width,
int height)
{
GdkSurface *surface = GDK_SURFACE (drag_surface);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!impl->display_server.wl_surface)
gdk_wayland_surface_create_wl_surface (surface);
impl->next_layout.configured_width = width;
impl->next_layout.configured_height = height;
impl->next_layout.surface_geometry_dirty = TRUE;
gdk_surface_request_layout (surface);
maybe_notify_mapped (surface);
return TRUE;
}
static void
gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
{
iface->present = gdk_wayland_drag_surface_present;
}

View File

@@ -25,6 +25,7 @@
#include "gdkdisplay-wayland.h"
#include "gdksurface-wayland.h"
#include "gdksurface-wayland-private.h"
#include "gdkwaylanddisplay.h"
#include "gdkwaylandglcontext.h"
@@ -60,10 +61,17 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
int dx = impl->pending_buffer_offset_x;
int dy = impl->pending_buffer_offset_y;
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
if (wl_surface_get_version (impl->display_server.wl_surface) >=
WL_SURFACE_OFFSET_SINCE_VERSION)
wl_surface_offset (impl->display_server.wl_surface, dx, dy);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
gdk_wayland_surface_notify_committed (surface);

View File

@@ -46,6 +46,7 @@ gdk_wayland_monitor_finalize (GObject *object)
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)object;
g_free (monitor->name);
g_free (monitor->description);
g_clear_pointer (&monitor->xdg_output, zxdg_output_v1_destroy);

View File

@@ -38,6 +38,7 @@ struct _GdkWaylandMonitor {
int32_t width;
int32_t height;
char *name;
char *description;
gboolean wl_output_done;
gboolean xdg_output_done;
};

File diff suppressed because it is too large Load Diff

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