Compare commits

..

500 Commits

Author SHA1 Message Date
Matthias Clasen 61f7ac09bc Replace some uses of custom buildables
Use string syntax instead of <attributes>
for PangoAttrList in a few places.
2022-01-18 12:49:01 -05:00
Matthias Clasen 688085cfaf builder: Parse some pango types
PangoAttrList and PangoFontDescription
have from-string apis, so we can just
support them as property values.
2022-01-18 12:34:58 -05:00
Matthias Clasen 7257d1c15f Revert "gir: Annotate GdkTexture constructors for reading from a file/memory/resource to return a GdkMemoryTexture"
This reverts commit ae8e844dec.

No agreement that this will stay this way going forward.
2022-01-12 14:11:20 -05:00
Matthias Clasen 21d40fc038 Merge branch 'fix-directory-list' into 'main'
directorylist: Fix several issues

Closes #3784

See merge request GNOME/gtk!4367
2022-01-12 02:58:25 +00:00
Matthias Clasen 93ff65c685 Merge branch 'should_be_mapped' into 'main'
gdk/wayland/surface: Remove redundant `should_be_mapped` code

See merge request GNOME/gtk!4203
2022-01-12 02:48:10 +00:00
Matthias Clasen 7e7201745d Merge branch 'wip/keep-scale' into 'main'
wayland/surface: Only update the scale if on any outputs

See merge request GNOME/gtk!4352
2022-01-12 02:46:43 +00:00
Matthias Clasen 50a986605c Merge branch 'ebassi/for-main' into 'main'
tests: Don't drop chdir()'s return value on the floor

See merge request GNOME/gtk!4328
2022-01-12 02:45:15 +00:00
Matthias Clasen 96994568fd Merge branch 'bilelmoussaoui/build' into 'main'
meson: only update-icon-cache when the demos are built

See merge request GNOME/gtk!4358
2022-01-12 02:44:29 +00:00
Matthias Clasen b494d94bdb Merge branch 'drop-script-names' into 'main'
Drop the script name data

See merge request GNOME/gtk!4361
2022-01-12 02:43:54 +00:00
Matthias Clasen 9d6ccc0fe0 Merge branch 'texture-new-return-types' into 'main'
gir: Annotate `GdkTexture` constructors for reading from a...

See merge request GNOME/gtk!4365
2022-01-12 02:42:17 +00:00
Matthias Clasen a56e187352 Merge branch 'nielsdg/gsk-gl-renderer-assertion' into 'main'
gsk: Document gsk_renderer_realize()

See merge request GNOME/gtk!4363
2022-01-12 02:41:32 +00:00
Matthias Clasen dcdcc659ef directorylist: Fix several issues
We were handling events in the wrong order,
by doing async calls for some of them, but not
for all of them.

And we were not taking into account that GFileMonitors
RENAMED events may or may not move a file on top
of an existing file.

Fixes: #3784
2022-01-11 21:35:19 -05:00
Sebastian Dröge ae8e844dec gir: Annotate GdkTexture constructors for reading from a file/memory/resource to return a GdkMemoryTexture 2022-01-11 15:46:22 +02:00
Niels De Graef e566ba54d9 gsk: Document gsk_renderer_realize()
Document the return value and more importantly, specify that a call to
`gsk_renderer_realize()` needs to be matched with a call
`gsk_renderer_unrealize()`.

Prevents issues like https://gitlab.gnome.org/GNOME/gtk/-/issues/4625
2022-01-11 13:09:53 +01:00
Matthias Clasen 70732afb95 Drop the script name data
It is not used in GTK itself, and gtk4-demo
has its own copy.
2022-01-10 10:43:05 -05:00
Danial Behzadi f2aed69f87 Update Persian translation 2022-01-10 11:39:53 +00:00
Emmanuele Bassi 6bd96522e8 Merge branch 'docs-typo-list' into 'main'
Fix typo in IconView docs

See merge request GNOME/gtk!4360
2022-01-09 13:28:57 +00:00
Sebastian Dröge 1e26c352d6 Fix typo in IconView docs
g_lsit_free_full() -> g_list_free_full()
2022-01-09 13:59:59 +02:00
Timm Bäder 2de65ebd4d Merge branch 'wip/smcv/png-endian' into 'main'
png: Correct endianness for big-endian machines

Closes #4616

See merge request GNOME/gtk!4357
2022-01-09 08:21:54 +00:00
Bilal Elmoussaoui ed3d9aaaed meson: only update-icon-cache when the demos are built
Without building the demos, nothing gets installed into $prefix/share/icons/hicolor. Which makes running 
`gtk4-update-icon-cache` on the machine causes an error. This is easily reproducible on a Windows machine with MSVC where 
there is nothing pre-installed on hicolor icon theme and that makes building gtk without the demos fails with "No such file or directory".
2022-01-09 07:27:59 +00:00
Jordi Mas 27a3998c8f Update Catalan translation 2022-01-08 22:55:05 +01:00
Simon McVittie 979c124e57 png: Correct endianness for big-endian machines
libpng wants to receive samples in either RGB or RGBA order, whether
each sample is big-endian or not. This resolves test failures in
testsuite/gdk/memorytexture.c (and a lot of reftests) on s390x, and
probably the PowerPC family too.

Modifying the test to show the color in use and write out the PNG bytes
to a file, and running the memorytexture test on s390x, produces a PNG
that loads with the correct color values in GIMP (on an x86_64 machine),
which seems like evidence that this is the correct change and not just
compensating errors.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/4616
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-01-08 17:09:29 +00:00
Emmanuele Bassi 20ad839075 tests: Don't drop chdir()'s return value on the floor
Avoid a compile time warning, and ensure that the test suite is actually
doing its job.
2022-01-08 15:17:25 +00:00
Emmanuele Bassi bed67edd2e Merge branch 'ebassi/docs-for-main' into 'main'
Document side effect of GLArea:has-depth-buffer

Closes #838

See merge request GNOME/gtk!4351
2022-01-07 19:14:59 +00:00
Jonas Ådahl 6efcc02806 wayland/surface: Only update the scale if on any outputs
If we ended up on no output at all, keep the HiDPI scale as is, as it
likely means we were on a workspace that was switched away from. By
keeping the same scale, we avoid unnecessary scale changes that would
otherwise take place if the scale when on monitors would end up being
more than 1.
2022-01-07 19:32:04 +01:00
Emmanuele Bassi 8a6dd2805f Document side effect of GLArea:has-depth-buffer
We enable depth testing when creating a depth buffer.

Fixes: #838
2022-01-07 18:30:54 +00:00
Matthias Clasen 464219c0fa Merge branch 'wip/baedert/for-master' into 'main'
label: Remove a redundant assignment

See merge request GNOME/gtk!4348
2022-01-07 16:47:07 +00:00
Timm Bäder e602768794 Merge branch 'ebassi/docs-for-main' into 'main'
docs: Clean up the ToggleButton description

See merge request GNOME/gtk!4347
2022-01-07 16:25:41 +00:00
Timm Bäder 262f2a1453 Make some code samples compile 2022-01-07 17:21:37 +01:00
Timm Bäder b408967278 label: Remove a redundant assignment
clang-tidy says:

gtklabel.c:1188:15: warning: Although the value stored to 'mid' is used in the enclosing expression, the value is never actually read from 'mid'
        min = mid = text_width;
              ^     ~~~~~~~~~~

Which seems right since mid will be assigned to at the beginning of the
next loop iteration anyway.
2022-01-07 17:21:37 +01:00
Emmanuele Bassi 1fd97fed91 docs: Clean up the ToggleButton description
- Use different headings
- Fix the coding style of the example
2022-01-07 15:42:08 +00:00
Matthias Clasen fef179b625 Merge branch 'matthiasc/for-main' into 'main'
docs; Update supported backends

See merge request GNOME/gtk!4344
2022-01-07 03:16:47 +00:00
Matthias Clasen 87ac411c50 Merge branch 'doc-improvs-ii' into 'main'
Doc improvements on textures

See merge request GNOME/gtk!4342
2022-01-07 03:16:19 +00:00
Matthias Clasen 46a7aaac76 Merge branch 'wip/chergert/fix-textview-dnd-move-same-view' into 'main'
textview: remove drag selection after dnd move action

See merge request GNOME/gtk!4346
2022-01-07 03:15:48 +00:00
Christian Hergert e14d6fe9d5 textview: remove drag selection after dnd move action
If we have a GDK_ACTION_MOVE, we need to delete the selection. However,
previously this only worked when the drop target and drag source were
different applications, as the selection would get messed up along the
way.

Instead, we stash marks for the duration of the operation so that we can
delete the appropriate selection when completing the move.
2022-01-06 16:30:34 -08:00
Matthias Clasen fb5b2d3d8e docs; Update supported backends
Some strings have changed here.
2022-01-06 14:56:16 -05:00
Matthias Clasen 9dccdd1008 Merge branch 'docs-improvs-i' into 'main'
docs: Improve docs for four classes

See merge request GNOME/gtk!4337
2022-01-06 19:19:31 +00:00
Benjamin Otte 8e8a746cce Merge branch 'wip/otte/for-main' into 'main'
testsuite: clear_current() when done

See merge request GNOME/gtk!4343
2022-01-06 19:07:58 +00:00
Maximiliano Sandoval R ee71effe98 docs: State that Textures are thread safe gobjects 2022-01-06 19:30:54 +01:00
Maximiliano Sandoval R ce2c4f0f08 docs: Improve docs for MemoryTexture 2022-01-06 19:30:30 +01:00
Maximiliano Sandoval R ef9dbf73cc gir: Add type annotations for {GL,Memory}Texture 2022-01-06 19:30:29 +01:00
Maximiliano Sandoval R 3bed5334bf docs: Improve docs for gdktexture.c 2022-01-06 19:30:28 +01:00
Benjamin Otte 5dc940ead2 glcontext: Don't spew warnings on surfaceless contexts
Get the display directly instead of via the nonexisting surface.
2022-01-06 19:23:29 +01:00
Benjamin Otte 7872b41f16 testsuite: clear_current() when done
That way we ensure that the GL context(s) get disposed, which they
previously weren't due to them still being the current context.

This also implicitly adds testing of gLContext destruction, which
previously wasn't ever done by any test.
2022-01-06 19:22:47 +01:00
Jordi Mas be81f6b4ab Update Catalan translation 2022-01-06 08:25:29 +01:00
Maximiliano Sandoval R 1229032b4e docs: Add misc links 2022-01-05 14:06:43 +01:00
Maximiliano Sandoval R ad73e2d07b docs: Improve docs for gskrendernode.c 2022-01-05 14:06:42 +01:00
Maximiliano Sandoval R 6d80135342 docs: Improve docs for gtksnapshot.c 2022-01-05 14:06:41 +01:00
Maximiliano Sandoval R c36a10da83 docs: Improve docs for gtkversion.h 2022-01-05 13:24:32 +01:00
Maximiliano Sandoval R c30d09cef4 docs: Improve docs for gtkactionable.c 2022-01-05 13:24:30 +01:00
Aleksandr Melman 716e0b97bd Update Russian translation 2022-01-05 11:03:11 +00:00
Matthias Clasen ff862dc926 Merge branch 'wip/smcv/gresource-internal' into 'main'
build: Tell glib-compile-resources to make symbols internal where possible

See merge request GNOME/gtk!4334
2022-01-04 18:58:14 +00:00
Simon McVittie 17c2a1cb4e build: Tell glib-compile-resources to make symbols internal where possible
Partial solution to https://gitlab.gnome.org/GNOME/gtk/-/issues/4598

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-01-04 18:08:22 +00:00
Aleksandr Melman 895e640fd0 Update Russian translation 2022-01-04 17:00:55 +00:00
Emmanuele Bassi e8f5f86ad5 Merge branch 'label-fix-section-link' into 'main'
docs: Fix link to section in GtkLabel

See merge request GNOME/gtk!4333
2022-01-04 15:54:05 +00:00
Marco Melorio 5055b41ee7 docs: Fix link to section in GtkLabel 2022-01-04 16:33:00 +01:00
Matthias Clasen 7efd08ca2e Merge branch 'fix-hc-warning' into 'main'
gdk/display-wayland: Don't bypass portal for theme entries

Closes #4593

See merge request GNOME/gtk!4331
2022-01-04 14:51:05 +00:00
Hugo Carvalho 76b421e064 Update Portuguese translation 2022-01-04 14:12:59 +00:00
Luca Bacci 063e6baa0a Merge branch 'gtk-grab-file-chooser-native-win32' into 'main'
GTK grab for GtkFileChooserNativeWin32

Closes #4582

See merge request GNOME/gtk!4329
2022-01-04 13:59:08 +00:00
Florian Müllner 9e5d412a8b gdk/display-wayland: Don't bypass portal for theme entries
When commit 49589e1da added support for the new high-contrast key,
it missed that the getter should only use the setting directly when
not going through the portal.

https://gitlab.gnome.org/GNOME/gtk/-/issues/4593
2022-01-04 14:58:58 +01:00
Daniel Mustieles fa9b634d8f Updated Spanish translation 2022-01-04 14:38:09 +01:00
Matthias Clasen d76379428d Merge branch 'noexecstack' into 'main'
Make our stack noexec

Closes #4598

See merge request GNOME/gtk!4330
2022-01-04 13:09:39 +00:00
Matthias Clasen 46509b6dd2 Make our stack noexec
The change to use ld and objcopy for resources
had some side-effects: it leaked a few symbols
and made our stack executable. We don't want that.

Use -z nonexecstack and --strip-all to avoid this.

Fixes: #4598
2022-01-04 07:51:56 -05:00
Daniel Mustieles 89dbf9cc81 Updated Spanish translation 2022-01-04 12:18:11 +01:00
Luca Bacci c138aaabf3 Use a GTK grab when showing a modal GtkFileChooserNativeWin32 2022-01-04 10:46:20 +01:00
Yuri Chornoivan 7cef454c86 Update Ukrainian translation 2022-01-03 20:51:23 +00:00
Emmanuele Bassi 5cb8d15505 Merge branch 'fredmorcos-master-patch-48389' into 'main'
Minor doc fix

See merge request GNOME/gtk!4325
2022-01-03 13:34:00 +00:00
Luca Bacci 2aab55983d Merge branch 'wgl-legacy' into 'main'
GSK/GL: Relax check for GL 3.x+ legacy contexts

See merge request GNOME/gtk!4187
2022-01-03 13:11:04 +00:00
Fred Morcos 31714e5c1d Minor doc fix 2022-01-03 10:27:51 +00:00
Luca Bacci 96c351e792 Merge branch 'for-main' into 'main'
For main

See merge request GNOME/gtk!4322
2022-01-03 09:51:10 +00:00
Matthias Clasen edd57004d3 Merge branch 'matthiasc/for-main' into 'main'
fontchooser: Use new hb api

See merge request GNOME/gtk!4323
2022-01-03 02:52:45 +00:00
Matthias Clasen 234d20641c fontbutton: Pass the fontmap to the dialog 2022-01-02 21:37:32 -05:00
Matthias Clasen dd802f21e7 fontchooser: Cosmetics
Use harfbuzz api to format variations and features.
That matches what pango uses to parse them.
2022-01-02 21:37:32 -05:00
Matthias Clasen dbbc990c72 fontchooser: Use new hb api
Use hb_font_get_var_coords_design if we have it.
This should fix our handling of fonts with AVAR.
2022-01-02 21:37:32 -05:00
Matthias Clasen 3a6e772cba Merge branch 'wip/antoniof/expression-autocleanup' into 'main'
gtk: Define the GtkExpression autocleanup func

See merge request GNOME/gtk!4319
2022-01-02 17:49:49 +00:00
António Fernandes c9fa16fcfa gtk: Define the GtkExpression autocleanup func 2022-01-02 17:49:48 +00:00
Luca Bacci 07b04fbea9 Remove some unneeded files from gdk/win32
bdfcursor.c, cursor.bdf and libwntab32x.la
2022-01-02 18:49:44 +01:00
Luca Bacci 1c633cbea2 Add hid.lib to pkg-config file listing 2022-01-02 18:45:17 +01:00
Luca Bacci 2f685d5d2a Remove leftover code dealing with input-only windows 2022-01-02 18:42:33 +01:00
Luca Bacci 0fdf2cc195 Fix compilation with clang
From https://github.com/msys2/MINGW-packages/pull/9509
2022-01-02 18:42:33 +01:00
Luca Bacci 4f7d18a28f Do not use GetProcAddress for FlashWindowEx
It's available since Windows XP
2022-01-02 18:42:32 +01:00
Luca Bacci c77272a7d7 Remove call to ShowOwnedPopups (FALSE) to hide owned windows
This is needed to fully support windows with the property
"destroy-with-parent" set to FALSE.
2022-01-02 18:42:31 +01:00
Luca Bacci 7a1004df73 Remove WM_SYNCPAINT message handler
It was added to work around what seemed to be an OS or graphics
driver issue on Windows XP. The issue was not reproducible on
Windows Vista anyway.

References:
* https://bugzilla.gnome.org/show_bug.cgi?id=153567
* https://gitlab.gnome.org/GNOME/gtk/-/commit/c8fef535
* https://devblogs.microsoft.com/oldnewthing/20120723-00/?p=7073
2022-01-02 18:42:31 +01:00
Matthias Clasen 0e86d2b345 Merge branch 'ebassi/issue-4576' into 'main'
Update the accessible description of MenuButton

Closes #4576

See merge request GNOME/gtk!4317
2022-01-02 01:12:53 +00:00
Matthias Clasen 2441bdb900 Merge branch 'radioactiveman-main-patch-13472' into 'main'
texture: Fix typo in error message

See merge request GNOME/gtk!4311
2022-01-02 00:51:43 +00:00
Matthias Clasen 57679b7b7f Merge branch 'wip-fontchooser-tewaks' into 'main'
Revert "fontchoserwidget: Do our own face filtering"

See merge request GNOME/gtk!4314
2022-01-02 00:50:57 +00:00
Emmanuele Bassi 37063e7a05 Update the accessible description of MenuButton
We update the labelled-by relation, but we never update the described-by
one.

Fixes: #4576
2022-01-02 00:35:53 +00:00
Matthias Clasen 791dc7b9be fontchooser: Speed up fature examples
We were doing unnecessary work here, which could
get really slow with some fonts. Just compute
the reverse charmap once and reuse it.
2022-01-01 15:38:04 -05:00
Matthias Clasen ff24dfb2e7 Revert "fontchooserwidget: Revise handling of named instances"
This reverts commit 2dc56a6e9b.

This wasn't ready yet.
2022-01-01 15:36:29 -05:00
Matthias Clasen 4db60fa5a8 Revert "fontchoserwidget: Do our own face filtering"
This reverts commit b7b6c147f9.

This was premature.
2022-01-01 15:36:27 -05:00
Emmanuele Bassi 5301367630 Merge branch 'bilelmoussaoui/g-i' into 'main'
gdk: add missing nullable annotations

See merge request GNOME/gtk!4310
2022-01-01 20:22:18 +00:00
Bilal Elmoussaoui 9409b7ef7d gtk: mark few GtkPrinterSettings as nullable
Everything that makes use of gtk_printer_settings_get should be nullable
Because the hashtable might not contain the key and there's no default value provided
2022-01-01 19:20:29 +01:00
Bilal Elmoussaoui afeb7f668b gtk: mark few GtkFileChooser functions as nullable
- get_file, if no file is selected returns a NULL
- get_id, if the interface doesn't implement such function returns NULL
2022-01-01 19:11:10 +01:00
Bilal Elmoussaoui 38b8da0f5f gtk: mark gtk_flatten_list_model_get_model_for_item as nullable 2022-01-01 19:07:13 +01:00
Bilal Elmoussaoui d029b62d23 gtk: mark gtk_mount_operation_get_parent as nullable 2022-01-01 19:05:33 +01:00
Bilal Elmoussaoui 1e9bdb4647 gtk: mark gtk_list_box_get_adjustment as nullable
similar to its setter function
2022-01-01 19:05:06 +01:00
Bilal Elmoussaoui 1d72024605 gtk: mark MenuButton::get_label/get_icon_name as nullable 2022-01-01 18:38:56 +01:00
Bilal Elmoussaoui 06570443b7 gtk: mark gtk_icon_view_create_drag_icon as nullable 2022-01-01 18:33:29 +01:00
Bilal Elmoussaoui 77f7caf18d gtk: mark gtk_glarea_get_context as nullable 2022-01-01 18:26:40 +01:00
Thomas Lange 8767ffde2f texture: Fix typo in error message 2022-01-01 17:23:22 +00:00
Bilal Elmoussaoui d58b7fa779 gtk: mark gtk_text_mark_get_buffer as nullable 2022-01-01 18:19:41 +01:00
Bilal Elmoussaoui dcbf3f8879 gtk: mark gtk_lock_button_get_permission as nullable
like the constructor/setter
2022-01-01 18:17:31 +01:00
Bilal Elmoussaoui 30d8c8e17c gtk: mark buildable_get_id as nullable
the vfunc can return a nullable
2022-01-01 18:12:05 +01:00
Bilal Elmoussaoui b803bb5edb gtk: mark MultiSelection::get_model as nullable
the constructor & setter takes a nullable model
2022-01-01 18:04:24 +01:00
Bilal Elmoussaoui 985a39d41f gtk: mark gtk_native_get_for_surface as nullable 2022-01-01 17:59:35 +01:00
Bilal Elmoussaoui f846eec894 gtk: mark gtk_no_selection_get_model nullable
The constructor is nullable so should the getter be
2022-01-01 17:56:07 +01:00
Bilal Elmoussaoui e7fc8ad1f5 gtk: fix PasswordEntry annotation 2022-01-01 17:49:11 +01:00
Bilal Elmoussaoui 95169ad54b gtk: add nullable annotations to PopoverMenuBar/PopoverMenu
The constructor/setter accepts a null as a model so should the getter
2022-01-01 17:47:21 +01:00
Bilal Elmoussaoui ddb2e91a42 gtk: add nullable annotations for Scrollable getters
The adjustment setters takes a nullable and so should the getters be annotated
2022-01-01 17:39:45 +01:00
Bilal Elmoussaoui 90357193c9 gtk: add nullable annotation to gtk_css_section_get_file
The constructor takes a nullable file param
2022-01-01 17:31:38 +01:00
Bilal Elmoussaoui a336fe2850 gdk: add missing nullable annotations 2022-01-01 17:03:10 +01:00
Matthias Clasen fcb8e4cf37 Merge branch 'fontchooser-tweaks' into 'main'
fontchooserwidget: Avoid a crash

See merge request GNOME/gtk!4309
2021-12-31 18:32:49 +00:00
Matthias Clasen b7b6c147f9 fontchoserwidget: Do our own face filtering
Pango may not do this for us, so don't rely on it.
We only show one face with a given name, and we
prefer a variable face over a non-variable one.

The check for variable faces requires new Pango
API that will be in Pango 1.52.
2021-12-31 09:58:26 -05:00
Emmanuele Bassi 35ee82ca07 Merge branch 'wip/baedert/for-master' into 'main'
baseline = -1 means no baseline

Closes #4385

See merge request GNOME/gtk!4307
2021-12-31 14:55:20 +00:00
Matthias Clasen 2dc56a6e9b fontchooserwidget: Revise handling of named instances
Allowing to tweak the axes of named instances does
not do any harm. If we don't, we have to worry that
we need at least one non-named-instance in the face
list, and make it more obvious how to pick it out.
2021-12-31 09:50:47 -05:00
Matthias Clasen e12ef76de5 fontchooserwidget: Avoid a crash
languages may be NULL, we need to be more careful here.
2021-12-31 09:49:40 -05:00
Matthias Clasen 536b05e35b maplistmodel: Cosmetics 2021-12-31 09:48:34 -05:00
Timm Bäder 1354854d23 inspector: Fix coding style
ffs
2021-12-31 14:41:35 +01:00
Timm Bäder 2b062d60f2 baseline = -1 means no baseline
Fixes #4385
2021-12-31 13:08:01 +01:00
Matthias Clasen c8bdb4c7fb Merge branch 'fontchooser-cleanups' into 'main'
fontchooser: Stop using pangofc api

See merge request GNOME/gtk!4306
2021-12-31 04:30:04 +00:00
Matthias Clasen 80328e8a4f fontchooser: Stop using pangofc api
Pango now has backend-independent api for all
we need, so we can drop all the ifdefs.
2021-12-30 22:52:52 -05:00
Emmanuele Bassi 1138e3770b Merge branch 'bilelmoussaoui/g-i' into 'main'
g-i: add missing nullable annotation

See merge request GNOME/gtk!4304
2021-12-30 17:12:59 +00:00
Bilal Elmoussaoui ec58013b22 g-i: add missing nullable annotation
the constructor takes a nullable expression parameter, so should the getter be
2021-12-30 16:52:53 +00:00
Matthias Clasen 70cb61fb71 4.6.0 2021-12-30 10:31:52 -05:00
Yuri Chornoivan 8e6a0ec23d Update Ukrainian translation 2021-12-29 22:17:32 +00:00
Matthias Clasen e2ab334636 Merge branch 'doc-window' into 'main'
Document built-in actions on GtkWindow

See merge request GNOME/gtk!4297
2021-12-29 17:23:16 +00:00
Matthias Clasen dd0effe957 Merge branch 'wip/chergert/4575-fix-texthistory-selection' into 'main'
testsuite: ignore texthistory selection on delete/backspace

Closes #4575

See merge request GNOME/gtk!4287
2021-12-29 14:58:53 +00:00
Hofer-Julian ac210c1765 docs: Add missing star to block comment 2021-12-29 15:46:59 +01:00
Hofer-Julian c58e48e648 doc: Fix docs of window.minimize 2021-12-29 15:45:44 +01:00
Hofer-Julian acdadab617 docs: Document built-in actions on GtkWindow 2021-12-29 15:45:43 +01:00
Matthias Clasen aa19194f7b Merge branch 'wip/exalm/inspector' into 'main'
inspector: Register extension on startup

See merge request GNOME/gtk!4296
2021-12-29 14:38:28 +00:00
Matthias Clasen 9319a6e39b Merge branch 'matthiasc/for-main' into 'main'
tests: Make fontchooser test build on macOS

See merge request GNOME/gtk!4300
2021-12-29 14:34:26 +00:00
Matthias Clasen b41206abab tests: Make fontchooser test build on macOS
Not sure what changed here, but we want to
be able to build this without fontconfig too.
2021-12-29 09:15:26 -05:00
Matthias Clasen 07c3dc6b6f Merge branch 'nullable' into 'main'
popover: Add missing nullable annotation

Closes #4556

See merge request GNOME/gtk!4295
2021-12-29 00:28:09 +00:00
Matthias Clasen fa71a2a993 Merge branch 'wip/baedert/for-master' into 'main'
application demo: Resolve a keyboard shortcut conflict

See merge request GNOME/gtk!4290
2021-12-29 00:24:46 +00:00
Alexander Mikhaylenko b997d1e892 inspector: Register extension on startup 2021-12-29 04:42:51 +05:00
Alexander Mikhaylenko 4b71fba540 Revert "inspector: Export gtk_inspector_init"
This reverts commit 3f5107cea5.
2021-12-29 04:12:16 +05:00
Ian Douglas Scott 48d39c0a57 popover: Add missing nullable annotation
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4556.

Looks like the other `Popover` methods are have correct nullable
annotations.
2021-12-28 09:43:06 -08:00
Hugo Carvalho 0aad053507 Update Portuguese translation 2021-12-27 22:53:20 +00:00
Matthias Clasen 6ed14b2a5f Merge branch 'm-shinder-master-patch-90567' into 'main'
gdk_content_provider_get_value() argument should have 'out' direction

See merge request GNOME/gtk!4283
2021-12-27 15:08:48 +00:00
Matthias Clasen c7df5ef957 Merge branch 'get-key-capture-widget-nullable' into 'main'
GtkSearchBar - Mark get_key_capture_widget() return value as nullable

See merge request GNOME/gtk!4286
2021-12-27 15:06:56 +00:00
Yuri Chornoivan a9013febcf Update Ukrainian translation 2021-12-27 14:08:03 +00:00
Benjamin Otte 815c430ba1 Merge branch 'wip/otte/for-main' into 'main'
inspector: Add dnd inspection support

See merge request GNOME/gtk!4289
2021-12-27 13:54:27 +00:00
Timm Bäder e94d5bf006 applicationwindow: Don't pass for_size < -1 to measure()
If the application window is measured with for_size -1 horizontally,
this code clearly passes something lower to the parent class measure()
implementation. Only subtract the menubar_height if we're passed a
for_size > -1.
2021-12-27 12:15:02 +01:00
Timm Bäder a00480f4a1 application demo: Resolve a keyboard shortcut conflict
There were two menu entries side-by-side with the same keyboard shortcut
2021-12-27 10:02:03 +01:00
Benjamin Otte 6da952100c inspector: Add dnd inspection support
This has lots of issues:
 * It randomly crashes when data is loading while the dnd goes away.
 * The data gets randomly reset at the wrong time
 * Can't scroll the window on Wayland
 * ...

But it's better than nothing, so better get it committed.
2021-12-27 05:59:16 +01:00
Benjamin Otte df8588e9b7 Merge branch 'wip/otte/for-main' into 'main'
widget: Don't queue an allocate on a nonexisting parent

See merge request GNOME/gtk!4288
2021-12-26 23:20:34 +00:00
Benjamin Otte fce9b35e4d css: Don't crash on invalid rotate3d() 2021-12-26 22:58:09 +01:00
m-shinder 6fd4421add Merge branch 'main' into 'm-shinder-master-patch-90567'
# Conflicts:
#   NEWS
2021-12-26 21:20:33 +00:00
Benjamin Otte 7149bfd100 widget: Don't queue an allocate on a nonexisting parent
No test, no idea how to trigger this reliably.
2021-12-26 22:17:54 +01:00
Christian Hergert 344ad0355e textview: scroll insert onscreen after undo/redo
After performing an action such as undo/redo, we need to actually scroll
to the position where the operation occurred.

I do note that the scroll here seems to often get invalidated if it is
pages away, and we never make the full scroll. But I've seen this all over
the place elsewhere too and that needs to be handled, most likely, as a
more comprehensive fix for scrolling during line validation.

Related #4575
2021-12-26 12:56:42 -08:00
Christian Hergert e7871fbc43 texthistory: always track selection bounds
It's cheap to store the selection position, so always set it even if we
are in a user section. Otherwise, we risk not having the right position
when starting a delete action within a begin_user_action(),
end_user_action() pair.

Related #4575
2021-12-26 12:47:45 -08:00
Christian Hergert 99d8dd751e testsuite: add failing test for delete selection
This adds a test to expose the failure of #4575 which results in the
selection being incorrect when performing a delete as we are likely
already in a begin_user_action()/end_user_action() pair.

Related #4575
2021-12-26 12:46:16 -08:00
Christian Hergert 22b1abb36d testsuite: ignore texthistory selection on delete/backspace
We don't need to apply these here, as it will clear the selection which is
needed for the undo. Otherwise we won't be able to test that we end up at
the right selection afterwards.
2021-12-26 12:43:22 -08:00
Sebastian Dröge aa289d1023 GtkSearchBar - Mark get_key_capture_widget() return value as nullable
The setter allows setting NULL so this can clearly also return NULL
under normal circumstances.

Same for the corresponding API in GtkSearchEntry.
2021-12-26 11:06:34 +02:00
Emmanuele Bassi ef51e02767 Merge branch 'ebassi/build-fixes' into 'main'
build: Replace source_root()

See merge request GNOME/gtk!4281
2021-12-25 17:26:06 +00:00
Benjamin Otte 7118127139 Merge branch 'wip/otte/gles' into 'main'
Fix GLES

Closes #4571

See merge request GNOME/gtk!4285
2021-12-25 15:34:01 +00:00
Benjamin Otte 2ce2afa036 gles: Be picky abpout glGetFramebufferAttachmentParameter()
This function does not at all work like in OpenGL - if it works at all.
So make it behave accordingly.

Fixes #4571
2021-12-25 15:07:44 +01:00
Benjamin Otte 5803dd765d gles: glGetTexLevelParameter() isn't supported 2021-12-25 15:07:44 +01:00
Benjamin Otte 6a310b5069 gles: GLES 2 doesn't have glDrawBuffers()
So don't call it.
2021-12-25 15:07:44 +01:00
Benjamin Otte 2caab68be9 gl: Change gdk_gl_context_check_version()
Instead of just passing major/minor, pass them twice, once for GL and
once for GLES. This way, we don't need to check for GL and GLES
separately.

If something is supported unconditionally, passing 0/0 works fine.

That said, I'd like to group the arguments somehow, because otherwise
it's just a confusing list of numbers - but I have no idea how to do
that.
2021-12-25 15:07:44 +01:00
Benjamin Otte 4e2dbc1258 glcontext: Use different log levels for GL debug
We want critical GL debug messages to be critical, so that the testsuite
sudokus itself when they appear.

This is relevant in particular for GLES warnings in the GLES runner,
because its warnings can cause crashes on GL drivers less forgiving than
Mesa.

Related: #4571
2021-12-25 15:07:44 +01:00
Emmanuele Bassi 40eca1a68e Apply 1 suggestion(s) to 1 file(s) 2021-12-25 13:29:07 +00:00
m-shinder 98f937ba15 Fix: Set direction for value parameter 2021-12-25 10:04:43 +00:00
Emmanuele Bassi a70988ecd5 build: Remove deprecated get_pkgconfig_variable()
Replace it with `get_variable(pkgconfig:...)`.
2021-12-24 15:55:26 +00:00
Emmanuele Bassi 6f2ff620bd build: Replace deprecated 'gui_app'
Use `win_subsystem: 'windows'` instead.
2021-12-24 15:51:11 +00:00
Emmanuele Bassi bd772610b1 build: Replace source_root()
Use project_source_root(), which replaces the deprecated source_root().
2021-12-24 15:48:06 +00:00
Matthias Clasen de42b5bfae sizerequest: Remove critical warning for now
At last as long as widgets like GtkFlowBox and
GtkGrid still trigger this, it is not a great
idea to have this warning in a stable release.
So remove it for 4.6
2021-12-23 16:59:26 -05:00
Benjamin Otte fcdd5173bd Merge branch 'wip/otte/for-main' into 'main'
gl: Clear current when destroying current's surface

Closes #4554

See merge request GNOME/gtk!4279
2021-12-22 19:45:53 +00:00
Benjamin Otte c419799313 gl: Clear current when destroying current's surface
When destroying the EGLSurface or GLXDrawable of a GdkSurface, make sure
the current context is not still bound to it.

If it is, clear the current context.

Fixes #4554
2021-12-22 20:00:52 +01:00
Matthias Clasen c5973a630b Merge branch 'wip/baedert/for-master' into 'main'
label: Fix get_natural_wrap_mode() precondition check

See merge request GNOME/gtk!4278
2021-12-22 16:54:18 +00:00
Timm Bäder e5a88b64b1 label: Fix get_natural_wrap_mode() precondition check 2021-12-22 17:38:33 +01:00
Hugo Carvalho 74f58a49b9 Update Portuguese translation 2021-12-22 14:05:50 +00:00
Yuri Chornoivan cff9d9f5eb Update Ukrainian translation 2021-12-22 12:52:52 +00:00
Timm Bäder ddd64f2918 Merge branch 'fix_typos' into 'main'
Fix minor typo

See merge request GNOME/gtk!4275
2021-12-22 08:08:38 +00:00
Yuri Chornoivan 9f06f53a59 Fix minor typo 2021-12-21 23:42:12 +02:00
Yuri Chornoivan 4c00d7a306 Update Ukrainian translation 2021-12-21 21:36:53 +00:00
Matthias Clasen 88726e12f7 Merge branch 'high-contrast-4' into 'main'
gdk/wayland: Support new `high-contrast` key

See merge request GNOME/gtk!4271
2021-12-21 19:20:34 +00:00
Matthias Clasen 248bb148af Merge branch 'discrete-scroll' into 'main'
Don't keep discrete scroll events in the queue

See merge request GNOME/gtk!4274
2021-12-21 18:22:53 +00:00
Florian Müllner 49589e1da1 gdk/wayland: Support new high-contrast key
We now have a boolean setting that determines whether the high-contrast
theme should be used. Support it by automatically setting the existing
`gtk-theme-name` and `gtk-icon-theme-name` properties when enabled.

With that, it is no longer necessary to change the regular theme settings
for high-contrast, so toggling between high-contrast and a non-default
theme finally works reliably.
2021-12-21 14:02:02 +01:00
Matthias Clasen 552267b93d Don't keep discrete scroll events in the queue
We are not going to compress those anyway.
2021-12-20 14:51:37 -05:00
Matthias Clasen 855357f871 Merge branch 'testsuite-introspection-extend-envvars' into 'main'
testsuite: introspection: Do not override environment variables.

See merge request GNOME/gtk!4268
2021-12-20 19:08:59 +00:00
Benjamin Otte c83cba2322 Merge branch 'wip/otte/diff' into 'main'
Make render node diffing not slow

Closes #4560 and #2396

See merge request GNOME/gtk!4269
2021-12-20 19:01:52 +00:00
Benjamin Otte 20dcc31d19 rendernode: Limit diff region
Limit the diff region to 30 rectangles (randomly chosen because it
looked big enough to not trigger by accident and small enough to not
cause performance issues).

If the diff region gets more complicated, we abort to the parent node
and use its bounds as the diff region instead and then continue diffing
the rest of the node tree.

Fixes: #4560
Fixes: #2396
2021-12-20 18:40:02 +01:00
Maxim Cournoyer 29e6cc5808 testsuite: introspection: Do not override environment variables.
Functional package managers such as GNU Guix rely on environment
variables such as GI_TYPELIB_PATH to discover the system libraries and
resources; extend rather than override them.

* testsuite/introspection/meson.build (env): New variable that extends
rather than override the GI_TYPELIB_PATH and LD_PRELOAD environment
variables.
(api): Use the above as the value of the 'env' keyword argument.
2021-12-20 11:22:41 -05:00
Benjamin Otte 4e6ee28bcb gsk: Allow diffing code to abort
Now the vfuncs can decide they don't want to diff anymore, not just the
actual diff function.
2021-12-20 17:08:15 +01:00
Hugo Carvalho 4b3247576a Update Portuguese translation 2021-12-20 16:07:31 +00:00
Matthias Clasen 69edf17c2a Merge branch 'wip/otte/wrapping-is-natural' into 'main'
label: Add gtk_label_set_natural_wrap_mode()

See merge request GNOME/gtk!4267
2021-12-20 15:49:05 +00:00
Matthias Clasen d91a4ad1dd Merge branch 'progressbar-queue-allocate' into 'main'
progressbar: Queue allocate when setting "inverted"

See merge request GNOME/gtk!4264
2021-12-20 15:45:36 +00:00
Matthias Clasen 9b750ef69f Merge branch 'ebassi/find-gi' into 'main'
build: Check for the gi python module

See merge request GNOME/gtk!4266
2021-12-20 15:41:51 +00:00
Fran Dieguez 0bf22ee3ce Update Galician translation 2021-12-20 08:50:36 +00:00
Benjamin Otte 981ed22dff label: Add gtk_label_set_natural_wrap_mode()
Allows influencing natural size requests so that labels can request more
width than necessary for a given height.

Related: !4245
Related: #4535
2021-12-20 02:28:37 +01:00
Emmanuele Bassi d40321ef63 ci: Add pygobject to the MSYS2 job 2021-12-19 16:26:37 +00:00
Emmanuele Bassi c94996e8e8 build: Check for the gi python module
The introspection tests depend on the pygobject module, but we currently
are not checking if it's available at configuration time, which means we
can get build failures like:

> ModuleNotFoundError: No module named 'gi'

when running the test suite.
2021-12-19 16:06:49 +00:00
Marco Melorio 4b19dd46dd progressbar: Queue allocate when setting "inverted" 2021-12-18 18:45:28 +01:00
Piotr Drąg 942e841cbc Update POTFILES.skip 2021-12-18 13:36:19 +01:00
Yuri Chornoivan e0a595273a Update Ukrainian translation 2021-12-18 06:29:43 +00:00
Matthias Clasen 92ca52822c Merge branch 'meson-msvc-cleanup' into 'main'
Remove Visual Studio 2013 bits from Meson files

See merge request GNOME/gtk!4249
2021-12-17 12:58:01 +00:00
Hugo Carvalho f89dbce93c Update Portuguese translation 2021-12-17 12:41:33 +00:00
Matthias Clasen 28f0e2eb2a 4.5.1 2021-12-16 21:43:20 -05:00
Matthias Clasen 47ac080565 Merge branch 'wip/otte/for-main' into 'main'
label: word-char wrapping should word-wrap for natural size

Closes #4535

See merge request GNOME/gtk!4245
2021-12-17 02:11:50 +00:00
Matthias Clasen afdf5cfde9 NEWS: Updates 2021-12-16 21:00:47 -05:00
Matthias Clasen a4760bcff7 Merge branch 'toolbar-combobox' into 'main'
Don't make all buttons in toolbars flat

Closes #4384

See merge request GNOME/gtk!4103
2021-12-17 00:35:18 +00:00
Matthias Clasen 72e571a3de Merge branch 'main' into 'main'
docs: Mention GtkImage and GtkPicture changes

Closes #4415

See merge request GNOME/gtk!4251
2021-12-17 00:32:08 +00:00
Jakub Kulík 484c0fdd15 docs: Mention GtkImage and GtkPicture changes 2021-12-17 00:32:08 +00:00
Matthias Clasen 2636fb7c8d Merge branch 'wip/baedert/for-master' into 'main'
settings test: Print expected and seen values

See merge request GNOME/gtk!4259
2021-12-17 00:31:20 +00:00
Benjamin Otte 99c2936e90 Merge branch 'wip/otte/inspector' into 'main'
inspector: Add measure graph

See merge request GNOME/gtk!4260
2021-12-16 21:46:52 +00:00
Benjamin Otte 66c74d6091 inspector: Add measure graph
Generates a graph visualizing calls to gtk_widget_measure().

Generation of the graph can be slow - like when it forces Pango to wrap
a huge label 1000s of times.

You can dnd the graph to look at it closer or to impress people in
gitlab issues.
2021-12-16 19:36:54 +01:00
Benjamin Otte a43ba245e2 inspector: Remove a stray g_print() 2021-12-16 19:36:54 +01:00
Benjamin Otte 810d734eda label: Fix docs 2021-12-16 19:36:54 +01:00
Hugo Carvalho 687d6c5dc4 Update Portuguese translation 2021-12-16 15:48:11 +00:00
Luca Bacci 5e090c1fac Merge branch 'fix-3728-3799' into 'main'
GDK-Win32: Force toplevel surfaces to configure as needed (fix issues #3728 and #3799)

Closes #3728 and #3799

See merge request GNOME/gtk!3712
2021-12-16 14:58:03 +00:00
Timm Bäder ceb61e6600 gskglcommandqueue: Mark some variables G_GNUC_UNUSED
These are unused if sysprof isn't being used.
2021-12-16 11:06:50 +01:00
Timm Bäder ae60293c24 textlayout: Remove unused-but-set variables 2021-12-16 11:06:50 +01:00
Timm Bäder e411081c84 settings test: Print expected and seen values
That test breaks locally (and in CI it seems?), so at least print the
values we see.
2021-12-16 11:06:50 +01:00
Matthias Clasen 0682a5e45e Merge branch 'event-recorder' into 'main'
inspector: Add axes to event details in recorder

See merge request GNOME/gtk!4258
2021-12-16 04:34:01 +00:00
Matthias Clasen 4f751aa53d inspector: Highlight event sequences
Optionally, highlight rows of events whose
event sequences match the selected event.
2021-12-15 22:07:07 -05:00
Matthias Clasen 27fa51cfa6 wayland: Add sequences for touchpad gestures
It makes sense.
2021-12-15 21:58:57 -05:00
Matthias Clasen 2772ff624f gdk: Prepare touchpad events for sequences
It makes sense to connect the begin/update/end events
for touchpad swipes and pinches in a sequence. This
commit adds the plumbing for it, but not backends
are setting sequences yet.
2021-12-15 21:58:57 -05:00
Matthias Clasen 69b160cfe8 inspector: Details about touchpad events
Useful to have for debugging these.
2021-12-15 21:58:57 -05:00
Matthias Clasen ee7541c032 inspector: Add axes to event details in recorder
This is useful information if you have devices
producing such events.
2021-12-15 21:58:57 -05:00
Matthias Clasen abf6068d91 docs: Add some information about event axes 2021-12-15 21:58:57 -05:00
Sveinn í Felli 9d5f3e787d Update Icelandic translation 2021-12-15 19:44:49 +00:00
Sveinn í Felli ab2b9ba444 Update Icelandic translation 2021-12-15 18:37:57 +00:00
Matthias Clasen 6ab1aff531 Merge branch 'event-recorder' into 'main'
inspector: Tweaks to the recorder

See merge request GNOME/gtk!4256
2021-12-15 05:51:28 +00:00
Matthias Clasen 6012276093 Fix event history
Collecting of history wasn't working correctly
for either motion or scroll events.
2021-12-15 00:30:50 -05:00
Matthias Clasen 9648cf226b inspector: Show event history in recorder
This was instrumental in debugging why
scroll compression does not work.
2021-12-14 23:43:29 -05:00
Matthias Clasen 56532a505d Cosmetrics: Remove mention of a nonexisting type
No such thing as GdkScrollHistory.
2021-12-14 23:42:35 -05:00
Matthias Clasen 6bb2e5625a inspector: Remove debug spew 2021-12-14 22:03:52 -05:00
Matthias Clasen d57a5dffa1 inspector: Add event recording
Make the recorder also keep track of events,
and show them in some detail.
2021-12-14 22:01:40 -05:00
Matthias Clasen 1028ca0841 inspector: More tweaks to the recorder
Put the two left columns in a stack, and add
an empty page there. This will let us add
other recording types in the future, with
their own pages.
2021-12-14 19:51:35 -05:00
Matthias Clasen 6dbe6b42c2 inspector: Tweaks to the recorder
Don't show the profiler data in the frame list,
instead show timestamps there.
2021-12-14 19:34:53 -05:00
Matthias Clasen 7611c3ea03 Merge branch 'matthiasc/for-main' into 'main'
inspector: Use a listview in the recorder

See merge request GNOME/gtk!4255
2021-12-15 00:06:11 +00:00
Christian Hergert 2fa9f934b6 a11y: return -1 if parent is NULL 2021-12-14 21:18:13 +01:00
Matthias Clasen e9fd7b7ed6 inspector: Use a listview in the recorder
Its the awesome new list widget, lets use it!
2021-12-14 15:10:11 -05:00
Matthias Clasen 075e954b71 Merge branch 'ebassi/issue-4543' into 'main'
Add a boxed GType for GtkBitsetIter

Closes #4543

See merge request GNOME/gtk!4253
2021-12-14 18:09:01 +00:00
Emmanuele Bassi 3f7122b3d2 Add a boxed GType for GtkBitsetIter
This way language bindings have a chance at managing the memory of
GtkBitset iterators.

Fixes: #4543
2021-12-14 15:51:13 +00:00
Hugo Carvalho 35251c6d9c Update Portuguese translation 2021-12-14 14:20:25 +00:00
Hugo Carvalho 173594365c Update Portuguese translation 2021-12-14 14:03:49 +00:00
Yuri Chornoivan 2fc44fb27d Update Ukrainian translation 2021-12-14 13:21:33 +00:00
Aurimas Černius 0264630c90 Updated Lithuanian translation 2021-12-14 13:41:59 +02:00
Matthias Clasen 208769f70f Merge branch 'optimize-precompile' into 'main'
builder: Use a string chunk for precompile

See merge request GNOME/gtk!4233
2021-12-14 06:34:49 +00:00
Matthias Clasen c5bffb9fb5 builder: Drop empty text chunks when precompiling
These don't add any value either.
2021-12-14 01:21:06 -05:00
Matthias Clasen c7afa5452b builder: Drop irrelevant whitespace in precompile
Drop text nodes that won't contribute to the end result.
This gets rid of a lot of text nodes in the replay.
2021-12-14 00:35:35 -05:00
Matthias Clasen c7c6e83779 Merge branch 'matthiasc/for-main' into 'main'
builder: Use GMarkup properly

See merge request GNOME/gtk!4250
2021-12-14 04:58:06 +00:00
Garrett Regier fcb6adaaaa builder: Use g_slice_free_chain() for strings in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier 9c12b58e32 builder: Remove root special case from precompile 2021-12-13 23:44:02 -05:00
Garrett Regier 6c8b505f93 builder: Avoid g_hash_table_get_values() in precompile
Embed the GList link in the RecordDataString.
2021-12-13 23:44:02 -05:00
Garrett Regier 8b228e7471 builder: Use a flexible array for attributes in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier 4ce07f41ca builder: Reduce memory usage in precompile
Split the Element and Text nodes into separate structures.
2021-12-13 23:44:02 -05:00
Garrett Regier 1bfd0e5e38 builder: Use a GQueue in precompile
This avoids g_list_last() and
embeds the GList link in the RecordDataTree.
2021-12-13 23:44:02 -05:00
Garrett Regier b962d37f79 builder: Use a reasonable default string size in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier c6ecf02a07 builder: Embed text length in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier 8b7d4b423c builder: Combine attribute name and value allocations 2021-12-13 23:44:02 -05:00
Garrett Regier 83dc126565 builder: Use a string chunk for precompile
Also use an explicit length and avoid g_strndup().
2021-12-13 23:44:02 -05:00
Garrett Regier f2d3d7e710 builder: Avoid double string lookup in precompile 2021-12-13 23:44:02 -05:00
Matthias Clasen f991428cb9 builder: Use GMarkup properly
We must call end_parse to ensure we get errors
for incomplete documents.
2021-12-13 23:42:47 -05:00
Chun-wei Fan e2b4108377 Revert "gtk/meson.build: Fix linking on Visual Studio 2013"
We now require a Pango version that requires Visual Studio 2015 or later to
build, and non-UCRT-based (VS2013) binaries may not bode well with
UCRT-based binaries (VS2015+). Drop the support for VS2013 as a result.

This reverts commit e208e0e07886248d4d86118aa5591c9882f0ed5c.
2021-12-14 10:29:28 +08:00
Matthias Clasen c9cf7b1e08 Merge branch 'matthiasc/for-main' into 'main'
tiff loader: Catch more errors

See merge request GNOME/gtk!4248
2021-12-14 00:31:49 +00:00
Matthias Clasen 4d865cd7ba tiff loader: Catch more errors
tiff_open_read may fail, and we should not crash
in that case but return an error.
2021-12-13 17:54:11 -05:00
Matthias Clasen a55458a84a Merge branch 'builder-tool-fixes' into 'main'
builderparser: Be more robust

See merge request GNOME/gtk!4247
2021-12-13 21:29:48 +00:00
Matthias Clasen 66d8631c23 buildertool: Be more robust
Don't pass a NULL string to gtk_builder_value_from_string.
2021-12-13 15:09:48 -05:00
Matthias Clasen 5c1ad88137 builderparser: Be more robust
If a document contains no useful content,
just say so instead of crashing.
2021-12-13 15:09:48 -05:00
Matthias Clasen e230c9c6f0 Merge branch 'builder-tool-fixes' into 'main'
buildertool: Fix a possible crash

See merge request GNOME/gtk!4246
2021-12-13 19:54:56 +00:00
Matthias Clasen 6d24a2c942 buildertool: Be more robust
A lot of crashes in simplify can be avoided
if get_class_name does not return NULL.
2021-12-13 14:33:19 -05:00
Matthias Clasen 5222dc0cd1 buildertool: Fix a possible crash
We need to call g_markup_parse_context_end_parse
to catch incomplete documents that we might not
handle well later.
2021-12-13 13:52:50 -05:00
Benjamin Otte 02c484e844 label: Fix docs 2021-12-13 18:23:32 +01:00
Benjamin Otte 5face79cd0 label: word-char wrapping should word-wrap for natural size
Testcase added

Fixes #4535
2021-12-13 14:49:39 +01:00
Yuri Chornoivan 51a72a9c53 Update Ukrainian translation 2021-12-13 13:16:42 +00:00
Matthias Clasen f609d9cd59 Merge branch 'wip/baedert/for-master' into 'main'
gl: Imply that node_supports_transforms() means 2D transforms

Closes #4501

See merge request GNOME/gtk!4232
2021-12-13 12:55:04 +00:00
Matthias Clasen 3901c6ab91 Merge branch 'fix-x11-drag-icons' into 'main'
colorswatch: Make drag source optional

See merge request GNOME/gtk!4244
2021-12-13 03:39:48 +00:00
Matthias Clasen da6f86bd79 colorbutton: No nested drag sources, please
This is causing trouble on X11.
2021-12-12 22:23:31 -05:00
Matthias Clasen 42fd499af4 dragicon: Make color icons work in X11
We need to disable the DND support in
GtkColorSwatch completely for this to work
in X11.
2021-12-12 22:09:28 -05:00
Matthias Clasen de5b88477a colorswatch: Make drag source optional
When using a colorswatch as a drag icon,
this can get in the way, so make it optional.
2021-12-12 22:09:16 -05:00
Matthias Clasen cd49a7f9e9 Merge branch 'matthiasc/for-main' into 'main'
dragicon: Provide default icons for paintables

See merge request GNOME/gtk!4243
2021-12-13 02:43:48 +00:00
Matthias Clasen df025fcb88 dragicon: Provide default icons for more types
Provide default icons for paintables and files.
This is easy to do, and makes sense.

fixup drag icon
2021-12-12 21:29:36 -05:00
Matthias Clasen bbb1404bd3 dragicon: No events, please
We run into trouble on X11 if the widgets
in the drag icon have drop targets attached.
Prevent this by suppressing event delivery
to drag icons outright.
2021-12-12 21:28:34 -05:00
Benjamin Otte af2a172197 Merge branch 'wip/otte/for-main' into 'main'
x11: Fix a deadlock in INCR transfers

See merge request GNOME/gtk!4242
2021-12-13 01:17:00 +00:00
Benjamin Otte 252b9fc39c x11: Don't delete important signal handlers randomly
We finish the write to the output stream long after the stream has been
closed, so we want to keep the event handler around to do just that.

Instead, remove the handler on finalize.
2021-12-13 01:54:21 +01:00
Benjamin Otte 6fc5e04d7c x11: Explicitly track end of stream
The OutputStream needs to write a 0 byte end of stream Property. We need
to track if that has been written, and we do that with that new
property.

We also use that property to always request flushes when the stream is
being closed, so that we don't wait for another flush() call.
2021-12-13 01:52:30 +01:00
Benjamin Otte 66f1fef083 x11: Explicitly close_async() the output stream
We need to be very careful when writing data, because if we aren't, sync
functions will be called on the output stream and X11 does not like that
at all.
2021-12-13 01:51:35 +01:00
Benjamin Otte 645d4807c3 x11: Keep a reference to the SelectionOutputStream while writing
This ensures close() isn't called from dispose() while we're still busy
writing.

In theory this should never happen, but in practice it just did.
2021-12-13 01:42:45 +01:00
Matthias Clasen e2c360ada0 Merge branch 'clipboard-demo-improvements' into 'main'
inspector: Show more datatypes for the clipboard

See merge request GNOME/gtk!4241
2021-12-12 23:51:30 +00:00
Matthias Clasen a463ead739 gdk: Drop some pointless code
There is no point in sorting png first when
registering (de)serializers, since we ignore
the png format now when walking the list.
2021-12-12 18:36:58 -05:00
Matthias Clasen dbe5e57b8e inspector: Show more datatypes for the clipboard
It is easy enough to show colors, files and pixbufs.
2021-12-12 18:36:58 -05:00
Matthias Clasen 99b99d7b23 Merge branch 'clipboard-demo-improvements' into 'main'
droptarget: Improve the docs

See merge request GNOME/gtk!4240
2021-12-12 21:42:31 +00:00
Matthias Clasen 787111a145 gtk-demo: Add dnd back to the clipboard demo 2021-12-12 16:27:36 -05:00
Matthias Clasen 9a872f059f droptarget: Improve the docs
Add the signal connection to the example.
2021-12-12 16:27:36 -05:00
Matthias Clasen eadc94e0a1 Merge branch 'clipboard-demo-improvements' into 'main'
gtk-demo: Small followup fixes

See merge request GNOME/gtk!4239
2021-12-12 18:58:07 +00:00
Matthias Clasen f8855e892a gtk-demo: Small followup fixes
Make image copy work remotely.
2021-12-12 13:41:24 -05:00
Matthias Clasen 27d05014e3 Merge branch 'new-clipboard-demo' into 'main'
docs: Small improvement

See merge request GNOME/gtk!4238
2021-12-12 18:30:27 +00:00
Matthias Clasen ebb58b7cbc gtk-demo: Rewrite the clipboard demo
This is more in line with the current clipboard
api, and shows handling colors and files.
2021-12-12 13:13:11 -05:00
Yuri Chornoivan 7f6895a4bb Update Ukrainian translation 2021-12-12 17:18:14 +00:00
Hugo Carvalho 80ae4c1a69 Update Portuguese translation 2021-12-12 16:26:05 +00:00
Matthias Clasen e72df9cd5f docs: Small improvement
I could not find the attributes of the <binding>
element mentioned anywhere in the docs.
2021-12-12 09:03:11 -05:00
Piotr Drąg 80ba529fb9 Update POTFILES.in and POTFILES.skip 2021-12-12 13:54:41 +01:00
Timm Bäder fd6b3ef5a0 gl: Linear gradients don't support 3d transforms
Add another helper similar to the one for transforms, but that only
works on 2d transforms.

Fixes #4501
2021-12-12 12:57:44 +01:00
Benjamin Otte 4cd0a39794 Merge branch 'wip/otte/inspector' into 'main'
inspector: Add a clipboard page

See merge request GNOME/gtk!4237
2021-12-11 22:46:30 +00:00
Benjamin Otte 5fbc510f94 contentformats: Make sure 0 elements means the array is NULL
Don't return arrays with 0 elements, return NULL.
2021-12-11 23:21:53 +01:00
Benjamin Otte 600ab5ba5f inspector: Add a clipboard page
Shows all the formats supported by the clipboard (and primary clipboard)
and allows displaying them (by potentially downloading them)
2021-12-11 23:01:42 +01:00
Matthias Clasen ae92181d02 Merge branch 'fix-textchild-abi' into 'main'
Restore the GtkTextchild abi

Closes #4531

See merge request GNOME/gtk!4236
2021-12-11 16:32:45 +00:00
Matthias Clasen 66910ed998 Restore the GtkTextchild abi
Move the new chars field to a private struct.

Fixes: #4531
2021-12-11 10:58:58 -05:00
Matthias Clasen 5371e4403e Merge branch 'deprecate-device-source' into 'main'
Deprecate GdkDevice:source

See merge request GNOME/gtk!4207
2021-12-10 18:35:00 +00:00
Matthias Clasen 79375dd7dd Merge branch 'fix-printer-enumeration' into 'main'
Fix dialog-less printing

Closes #4439

See merge request GNOME/gtk!4215
2021-12-10 18:01:59 +00:00
Matthias Clasen 6889609ab9 Merge branch 'bump-meson-dep' into 'main'
Require meson 0.59

Closes #4486

See merge request GNOME/gtk!4230
2021-12-10 18:00:50 +00:00
Matthias Clasen 0bf87281e0 Merge branch 'missing-since-tag' into 'main'
Add a missing since tag

See merge request GNOME/gtk!4229
2021-12-10 17:15:32 +00:00
Matthias Clasen bc7bed7517 ci: Use meson 0.59 for msvc 2021-12-10 12:14:04 -05:00
Matthias Clasen cfac6fd752 ci: Use meson 0.59 on macos 2021-12-10 12:12:52 -05:00
Matthias Clasen 97c09c827b Fix the targets variable in pc files
This is meant as a space-separated list of
string, so escaping the spaces is uncalled
for.

Fixes: #4486
2021-12-10 11:36:07 -05:00
Matthias Clasen 0370672886 Require meson 0.59
This is needed to fix a regression in our pc file
generation.
2021-12-10 11:34:23 -05:00
Matthias Clasen 2d062fedd9 Add a missing since tag
gtk_text_child_anchor_new_with_replacement was
recently added.
2021-12-10 11:26:46 -05:00
Matthias Clasen c6a68f3de2 Fix dialog-less printing
We were sometimes ending printer enumeration prematurely,
and the code was confused about the meaning of found_printer.

The new setup follows these rules:
- We *only* end the search prematurely if found_printer
  is set, which indicates that we found the right printer
- We *always* call find_printer_idle exactly once, and
  make it return less than perfect matches like the
  default printer, or the first printer we found

Fixes: #4439
2021-12-10 11:26:23 -05:00
Matthias Clasen d6181b2335 Merge branch 'wip/jimmac/unfocused-selection-dejavu' into 'main'
Revert "styling: Have unfocused selections"

Closes #4393

See merge request GNOME/gtk!4228
2021-12-10 13:17:32 +00:00
Jakub Steiner d74e62886c selections: have unfocused state
- text selections for unfocused elements - textview, label, entry,
  spinbutton

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4393
2021-12-10 12:00:12 +01:00
Jakub Steiner d8505f09eb Revert "styling: Have unfocused selections"
This reverts commit 96f63a6bf3.
2021-12-10 11:36:10 +01:00
Matthias Clasen 935c6aade0 Merge branch 'bilelmoussaoui/header' into 'main'
gdk: drop removed method from the header

See merge request GNOME/gtk!4225
2021-12-09 23:50:21 +00:00
Matthias Clasen a35c35f849 Merge branch 'wip/chergert/fix-macos-crash' into 'main'
macos: fix crash in imcontextquartz

See merge request GNOME/gtk!4226
2021-12-09 23:49:39 +00:00
Bilal Elmoussaoui 57518a2bb4 gdk: drop removed method from the header 2021-12-09 20:29:17 +00:00
Christian Hergert 99a8202015 macos: fix crash in imcontextquartz 2021-12-09 12:26:33 -08:00
Benjamin Otte 17c903e246 Merge branch 'fix-picture-natural-size-0' into 'main'
picture: Return natural size 0 for size 0

See merge request GNOME/gtk!4177
2021-12-08 19:33:28 +00:00
Benjamin Otte 4de5d225db reftests: Add center-center reftests without GtkOverlay 2021-12-08 22:16:52 +03:00
Benjamin Otte 7741df9963 reftests: Rename a bunch of tests
They use a GtkOverlay, so reflect that in the name.
2021-12-08 22:16:52 +03:00
Ivan Molodetskikh 7ef54e9c53 picture: Return natural size 0 for size 0
It was returning the full natural size (same as -1) due to default value
handling in the code below.

Tests have been updated to match this output.
2021-12-08 19:20:24 +01:00
Matthias Clasen 12bb700c62 Merge branch 'wip/chergert/fix-recursive-action-muxer' into 'main'
actionmuxer: avoid duplicate and recursive work

Closes #4422, #4519, and gnome-text-editor#220

See merge request GNOME/gtk!4223
2021-12-08 10:47:40 +00:00
Matthias Clasen e3ba7250f1 Merge branch 'wip/chergert/layout-marshaller' into 'main'
surface: add missing va_marshaller for layout signal

See merge request GNOME/gtk!4221
2021-12-08 10:46:35 +00:00
Matthias Clasen 54842095c3 Merge branch 'wip/chergert/reduce-action-muxer-allocations' into 'main'
menutracker: reduce allocations and signal emission

See merge request GNOME/gtk!4222
2021-12-08 10:45:56 +00:00
Christian Hergert d1aec0c3f1 actionmuxer: avoid duplicate and recursive work
If we've already done the tracking into the parent muxer, there is no need
to do it again. This can save a great deal of recursive work when adding
items to the muxer.

This makes showing the context menu in gnome-text-editor repeatedly fast
even as spelling corrections are changed.

It is likely that this could fix #4422 as well.

Fixes #4519
Fixes https://gitlab.gnome.org/GNOME/gnome-text-editor/-/issues/220
2021-12-08 00:32:36 -08:00
Christian Hergert 00d5f72d6e menutracker: reduce allocations and signal emission
When handling action-added callbacks the code was previously using a
freeze_notify/thaw_notify in all cases. This turns out to allocate a
significant amount of memory when called a lot.

That said, it shouldn't be getting called this much but given the current
state of affairs elsewhere in GtkActionMuxer, this brought temporary
allocations down from 9MiB to 9KiB in gnome-text-editor after showing
the context menu a few times.

Related #4422
2021-12-07 22:42:04 -08:00
Christian Hergert 15d01d4315 surface: add missing va_marshaller for layout signal
I saw this coming across through a ffi boundary in Sysprof, and we wanted
to keep most things within GDK using native marshalling to improve
profiler results when frame pointers are not used.
2021-12-07 22:21:19 -08:00
Benjamin Otte 348e34f221 Merge branch 'wip/otte/viewport' into 'main'
viewport: Handle things differently

See merge request GNOME/gtk!4220
2021-12-07 23:31:06 +00:00
Benjamin Otte ce7b0656c0 viewport: Allocate properly
Instead of allocation width for height for width for height or whatever
that code was doing, actually allocate the size we were given or the
requested size, whatever is larger.
2021-12-08 00:12:35 +01:00
Benjamin Otte fd0d360f9b Revert "viewport: Actually report the size we're gonna allocate"
This reverts commit b8468af411.
2021-12-07 23:52:21 +01:00
Benjamin Otte f26cae3838 Merge branch 'wip/otte/viewport' into 'main'
viewport: Use array for member variables

See merge request GNOME/gtk!4219
2021-12-07 21:19:58 +00:00
Benjamin Otte b8468af411 viewport: Actually report the size we're gonna allocate
Don't just pass on measure() calls, but actually behave in the way we
behave during size allocate.

This should improve cases where GtkScrolledWindow is used with GTK_POLICY_NEVER.
2021-12-07 21:58:42 +01:00
Benjamin Otte 9fd7e319f3 viewport: Use array for member variables
That way we can index them by orientation in future commits.
2021-12-07 21:58:42 +01:00
Benjamin Otte 80a8b59f24 Merge branch 'wip/otte/for-main' into 'main'
gtktypes: GTK_INVALID_LIST_POSITION should be an int

See merge request GNOME/gtk!4218
2021-12-07 15:30:48 +00:00
Benjamin Otte b9d4da9cfe gtktypes: GTK_INVALID_LIST_POSITION should be an int
GListModel uses guint, so the macros we define for it should match that.

Related: !3738
2021-12-07 16:15:17 +01:00
Emmanuele Bassi 5bf5b58eb3 Merge branch 'gi-const' into 'main'
gtk: fix GTK_INVALID_LIST_POSITION type

See merge request GNOME/gtk!3738
2021-12-07 14:22:40 +00:00
Hugo Carvalho b2c227e9c5 Update Portuguese translation 2021-12-04 19:46:16 +00:00
Yuri Chornoivan d854228d58 Update Ukrainian translation 2021-12-04 16:46:08 +00:00
Benjamin Otte a0c09bc2a9 Merge branch 'check-for-unknown-duration' into 'main'
gstmediafile: Correctly report unknown duration

See merge request GNOME/gtk!4217
2021-12-04 09:45:34 +00:00
Anders Jonsson aca3b2da58 Update Swedish translation 2021-12-04 09:34:37 +00:00
Ivan Molodetskikh 604541863c gstmediafile: Correctly report unknown duration
When loading .mp3 files the duration is initially unknown. Before this
change it was reported as a large integer (since GST_CLOCK_TIME_NONE is
-1). Now it's correctly reported as 0.
2021-12-04 11:48:30 +03:00
Matthias Clasen fc67b5a8cf Merge branch 'wip/carlosg/im-wayland-module-priority' into 'main'
gtkimcontextwayland: Set a higher IO extension priority

Closes #4443

See merge request GNOME/gtk!4216
2021-12-03 23:55:31 +00:00
Carlos Garnacho ce1b970b46 gtkimcontextwayland: Set a higher IO extension priority
We want this to take precedence in the wayland platform to other
modules that might be loaded via the IO extension point. None of
those is going to bode well in this platform.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4443
2021-12-04 00:21:53 +01:00
Matthias Clasen ceb77d6100 Merge branch 'wip/hadess/listbox-fixes' into 'main'
listbox: Explain behaviour of GtkListBoxCreateWidgetFunc

See merge request GNOME/gtk!4194
2021-12-03 23:05:13 +00:00
Matthias Clasen 02579a1333 Merge branch 'wip/chergert/inspector-im-module' into 'main'
inspector: add im-module

Closes #4512

See merge request GNOME/gtk!4214
2021-12-03 22:51:32 +00:00
Matthias Clasen 2f7fa10434 Merge branch 'textview-im-surrounding' into 'main'
textview: Provide more context to input methods

See merge request GNOME/gtk!4209
2021-12-03 20:26:54 +00:00
Christian Hergert 6be352f446 inspector: add im-module
This adds a new row to the Global/Information section which displays the
GTK im-module that is likely to be in use unless changed by an application.
It responds to updates of GtkSettings:gtk-im-module unless the
GTK_IM_MODULE environment variable is set.

Fixes #4512
2021-12-03 12:11:25 -08:00
Matthias Clasen 4d2be2e322 Merge branch 'text-scroll-test' into 'main'
Improve scroll-to mark behavior

Closes #4325

See merge request GNOME/gtk!4208
2021-12-03 20:00:05 +00:00
Matthias Clasen d5c01098fd textview: Provide more context to input methods
When returning surrounding context to input methods,
include at least 2 words before and after the insertion
point.

Update the affected input method tests.
2021-12-03 14:44:05 -05:00
Matthias Clasen d2bda8ea77 Merge branch 'text-anchor-replacement-char' into 'main'
textchildanchor: allow to specify replacement character

See merge request GNOME/gtk!4213
2021-12-03 16:02:49 +00:00
Georg Vienna c517e945de textchildanchor: allow to specify replacement character 2021-12-03 16:02:48 +00:00
Matthias Clasen e3a1a2e0c6 Merge branch 'better-tabs-demo' into 'main'
Beef up the tabs demo

See merge request GNOME/gtk!4200
2021-12-03 13:30:22 +00:00
Matthias Clasen b9c2a925e2 Beef up the tabs demo
Show various alignments, including numeric.
2021-12-03 07:55:20 -05:00
Benjamin Otte 59238c6e73 Merge branch 'gtk4-win32-egl' into 'main'
Fix running GTK4 under EGL on Windows

See merge request GNOME/gtk!4188
2021-12-03 10:48:50 +00:00
Chun-wei Fan 652ab1ac72 gskglcompiler.c: Force GLSL version 300 es as needed
For libANGLE to work with our shaders, we must use "300 es" for
the #version directive in our shaders, as well as using the non-legacy/
non-GLES codepath in the shaders.  In order to check whether we are
using the GLSL 300 es shaders, we check whether we are using a GLES 3.0+
context.  As a result, make ->glsl_version a const char* and make sure
the existing shader version macros are defined apprpriately, and add a
new macro for the "300 es" shader version string.

This will allow the gtk4 programs to run under Windows using EGL via
libANGLE.  Some of the GL demos won't work for now, but at least this
makes things a lot better for using GL-accelerated graphics under Windows
for those that want to or need to use libANGLE (such as those with
graphics drivers that aren't capable of our Desktop (W)GL requirements in
GTK.
2021-12-03 10:39:59 +08:00
Chun-wei Fan bdf879427c gdksurface-win32.c: Call gdk_surface_set_egl_native_window()
.. when creating the surface (with the HWND associated with the
newly-created surface) as well as destroying the surface (with NULL,
since the HWND is going to be destroyed), so that we can tie the EGL
calls to the HWND that we want to do the EGL stuff.
2021-12-03 10:39:59 +08:00
Matthias Clasen 4058b80d56 Bump pango req
Require pango 1.50.
2021-12-02 21:24:24 -05:00
Matthias Clasen be949496ac Merge branch 'issue-4376' into 'main'
Update placeholder visibility when setting a buffer

Closes #4376

See merge request GNOME/gtk!4211
2021-12-02 17:38:16 +00:00
Emmanuele Bassi b57b12fdb7 Update placeholder visibility when setting a buffer
If we set the placeholder text before setting a buffer, we end up with
both the placeholder *and* the buffer's contents visible at the same
time.

Fixes: #4376
2021-12-02 17:17:12 +00:00
Matthias Clasen e64bb40d0b Merge branch 'wip/carlosg/tablet-fixes' into 'main'
Wayland tablet device modifier fixes

Closes #4103 and #4102

See merge request GNOME/gtk!4210
2021-12-02 16:34:35 +00:00
Carlos Garnacho c8d83b7a63 gesturestylus: Use GtkEventControllerEvent events to track changes
We use gtk_gesture_get_last_event() underneath at places that need to
work during ::proximity emission. Since GtkGesture only tracks events
while there are button/touch presses involved, this is not going to
bring the right result there.

Use gtk_event_controller_get_current_event() consistently inside,
which always pokes at the event being handled (which is the correct
intent here).
2021-12-02 17:06:35 +01:00
Carlos Garnacho 9539cc4a93 gdk/wayland: Unset GDK_BUTTON1_MASK on proximity_in
In some circumstances (e.g. activating with a stylus something that
closes a window), we can receive zwp_tablet_tool.proximity_out without
receiving a zwp_tablet_tool.up beforehand.

In those cases, we are not expecting neither .up nor .button, so
reset the stylus device button modifiers on proximity_out.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4103
2021-12-02 17:06:35 +01:00
Carlos Garnacho 72cf304a86 gdk/wayland: Use right modifiers for tablet button events
We are looking up the seat logical pointer modifiers (i.e. the wl_pointer),
not the ones for the tablet tool device. This breaks accounting further
along in GTK leaving stuck implicit grabs.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4102
2021-12-02 17:06:35 +01:00
Matthias Clasen 67ad566188 textview: Improve scroll-to-mark behavior
The idea of within-margin is to scroll as little
as possible to bring the mark within the margins
defined by the factor. The code was achieving
that when scrolling down, but not when scrolling
up. This change makes things symmetrical.

Fixes: #4325
2021-12-01 19:35:11 -05:00
Matthias Clasen db46a8dd06 Add a testcase for scroll-to-mark
This should help for figuring out #4325.
2021-12-01 17:22:19 -05:00
Matthias Clasen fd9e0dd13a Deprecate GdkDevice:source
GdkDeviceTool is more consistently supported across
backends, and provides the same information.
2021-12-01 14:04:35 -05:00
Chun-wei Fan da535164b4 gdksurface-win32.c: Rename window->surface as appropriate
Update the functions that were updated in the previous commit to have all
GdkSurface variables named as 'surface' instead of the GTK-3.x-era window, to
make things more consistent across the board.  Also fix formatting a bit.
2021-12-01 17:32:40 +08:00
Chun-wei Fan 82d9570ed4 GDK-Win32: Make surface ready for updates
Make the toplevel surface respond to size computations unless it is just being
created, or maximized, made fullscreen or underwent an AeroSnap operation.

This will ensure that the surface size is properly computed in time, so that
surfaces can be resized as needed.

This will fix issues 3728 and 3799.
2021-12-01 17:32:40 +08:00
Chun-wei Fan a619e8af4a gskglcompiler.c: Relax check for GL 3.x+ legacy contexts
On Windows with nVidia drivers at least, when we create a legacy context
via wglCreateContext(), we may still get a (W)GL 4.x context.  Allow
such contexts to also use GLSL version 130 instead of 110, so that
things do continue to work.
2021-12-01 17:29:02 +08:00
Matthias Clasen 2611a996ff Merge branch 'matthiasc/for-main' into 'main'
textbuffer: Fix pasting text

Closes #4357

See merge request GNOME/gtk!4205
2021-12-01 02:59:10 +00:00
Matthias Clasen 3e7618fef7 textbuffer: Try harder to fix pasting
It turns out we can't just use the size returned
by the memory stream as-is, since it may contain
unfilled garbage at the end, which utf8 validation
will choke on. So, cut it off at the first '\0'
we find.
2021-11-30 21:42:19 -05:00
Matthias Clasen 5b1b75b055 textbuffer: Fix pasting text
The memory stolen from a memory outputstream
isn't guaranteed to be 0-terminated, so don't
make that assumption.

Fixes: #4357
2021-11-30 20:37:25 -05:00
Matthias Clasen f1612e36ee Merge branch 'update_focus_indicators_in_popovers' into 'main'
update focus indicators in popovers

See merge request GNOME/gtk!4124
2021-12-01 01:21:32 +00:00
Matthias Clasen bfd3d714b9 Merge branch 'matthiasc/for-main' into 'main'
textview: Respect editability for Emoji

Closes #4479 and #4503

See merge request GNOME/gtk!4204
2021-12-01 01:13:48 +00:00
Matthias Clasen 5a42ccc575 docs: Clarify a sentence in the migration guide
Make it clear that we are giving examples of
no-longer existing APIs here.

Fixes: #4479
2021-11-30 19:51:22 -05:00
Matthias Clasen b3b0321620 textview: Avoid misplacing the Emoji chooser
When the iter is at the end of the buffer,
gtk_text_view_get_iter_location returns a
rectangle with width 0, which in turn makes
gdk_rectangle_intersect return FALSE.

Avoid that by always giving the rectangle
non-empty dimensions.

Fixes: #4503
2021-11-30 19:44:26 -05:00
Matthias Clasen e0deacd236 inspector: Make dropdowns bigger
If there's enough values to warrant scrolling,
the dropdown was much too small for comfort.
2021-11-30 18:38:33 -05:00
Matthias Clasen f66172451d textview: Respect editability for Emoji
Switch the Emoji chooser keybinding to use the
action, so that disabling the action has the
desired effect.
2021-11-30 18:37:33 -05:00
Ian Douglas Scott 25ec20d861 gdk/wayland/surface: Remove redundant should_be_mapped code
As far as I can tell, the code here is redundant and probably ended up
this way for historical reasons. A drag surface without
`->is_drag_surface` would be created if `gdk_display_create_surface`
were called with `GDK_SURFACE_TEMP`, but drag surfaces never seem to be
created that way.

In `gtk4-demos`, drag and drop and popovers seem to be working normally
with this.
2021-11-30 10:36:46 -08:00
Benjamin Otte e80238120e Merge branch 'wip/otte/for-main' into 'main'
texture: Remove gdk_texture_download_float()

See merge request GNOME/gtk!4202
2021-11-30 14:25:22 +00:00
Benjamin Otte 07cfdd8ca0 label: Don't set ellipsized size as natural size
Natural size should never ellipsize.

Tests added.
2021-11-30 15:10:02 +01:00
Benjamin Otte ade7509b97 GL renderer: Remove noperspective usage
It causes issues with compilation of GLES shaders and isn't in any
way correct.
2021-11-30 14:12:10 +01:00
Benjamin Otte 8d1956921d node-editor: Display errors
When opening a file or pasting DND fails, display the error as the
actual node.
2021-11-30 14:12:10 +01:00
Benjamin Otte 354fa6544a texture: Remove gdk_texture_download_float()
The download API is not well thought out yet, so postpone it until
there's an actual usecase for it.

Remove testcases, too.
2021-11-30 14:12:10 +01:00
Benjamin Otte 291c50202a rendernode: Simplify conic gradient code 2021-11-30 14:12:10 +01:00
Benjamin Otte ce8faa2e90 testsuite: Make function arguments const 2021-11-30 14:12:10 +01:00
Matthias Clasen 0579220546 Mention 'main' branch in NEWS
The default development branch is now `main`.
This commit only exists on `master` to point people
towards that.
2021-11-29 18:13:06 -05:00
Matthias Clasen 50e4ca8593 Mention main in NEWS and README.md 2021-11-29 17:42:40 -05:00
Matthias Clasen ddd5704c92 Update references to master in the repository 2021-11-29 17:37:49 -05:00
Benjamin Otte 3ba6d2bd27 Merge branch 'wip/otte/hfw-min-size' into 'master'
window: Implement height-for-width for min size

See merge request GNOME/gtk!4183
2021-11-29 10:31:42 +00:00
Matthias Clasen cd9b730735 Merge branch 'font-chooser-variations-fix' into 'master'
fontchooser: Avoid setting variations needlessly

See merge request GNOME/gtk!4197
2021-11-28 12:56:09 +00:00
Piotr Drąg f593f3da0a Update POTFILES.skip 2021-11-28 13:30:19 +01:00
Matthias Clasen e9d8bf96e0 fontchooser: Avoid setting variations needlessly
Setting variations to their default value causes
them to show up in the serialization of the font
description - a font description has no idea about
the default values, so can't filter them out.

Avoid that.
2021-11-27 17:13:23 -05:00
Bastien Nocera 6b3a612bbc listbox: Explain behaviour of GtkListBoxCreateWidgetFunc
It might be an interesting shortcut for applications to use, but it
needs to be documented to be useful and agreed.
2021-11-25 12:33:10 +01:00
Emmanuele Bassi c742debea8 Merge branch 'fix_typo_gesture' into 'master'
gesture: fix typo in docs

See merge request GNOME/gtk!4191
2021-11-24 19:56:42 +00:00
Alexandros Theodotou cd60ec1576 gesture: fix typo in docs 2021-11-24 19:34:49 +00:00
Fabio Tomat 95e6453823 Update Friulian translation 2021-11-22 09:19:32 +00:00
Aurimas Černius 7e0279b15c Updated Lithuanian translation 2021-11-21 21:58:20 +02:00
Quentin PAGÈS 791f0d70ac Update Occitan translation 2021-11-21 19:38:33 +00:00
Benjamin Otte 0709dc7a6a window: Add a new fancy way to compute min size
Try to compute a min size that matches the current aspect ratio.

This means that when interactively resizing, we adapt the min size to
the current window area dynamically.

And that means that we always have a min size that is large enough, but
users can interactively cause it to be small-width x large-height,
large-width x small-width or anything inbetween.
2021-11-21 18:52:42 +00:00
Benjamin Otte 15528599f4 Merge branch 'wip/otte/for-master' into 'master'
window: Always clamp to max size

See merge request GNOME/gtk!4185
2021-11-21 18:44:26 +00:00
Emmanuele Bassi 031aab3ef6 Merge branch 'ebassi/issue-4421' into 'master'
Unrealize ATContext on unroot

Closes #4421

See merge request GNOME/gtk!4136
2021-11-21 15:36:25 +00:00
Benjamin Otte c990134e49 window: Properly distribute size between title and child
Otherwise we can end up with a window that's too small in certain corner
cases after resizing.
2021-11-21 08:19:07 +01:00
Benjamin Otte 822508f33e widget: Clear size request cache on queue_resize()
... and not later.

Otherwise future calls to sizing fucntions will reuse an outdated cache
and compute wrong values.
2021-11-21 06:08:06 +01:00
Benjamin Otte 358893aa84 window: Always clamp to max size
When computing the window size, always try to clamp to the max size.
This will shrink a window down into a sane size if it was too big
before.
2021-11-21 05:33:28 +01:00
Benjamin Otte 344fac5aa7 Merge branch 'wip/otte/for-master' into 'master'
Fixes

Closes #4469

See merge request GNOME/gtk!4182
2021-11-21 03:55:28 +00:00
Benjamin Otte 27965d5fdc builder-tool: Don't simplify enums too much
Store the enum nick, not the enum value. That way the file remains
human-readable.

Updated reftests to new expected output.
2021-11-21 02:19:57 +01:00
Benjamin Otte c025bc5098 paned: Compute the right handle size
Testcase included

Fixes #4469
2021-11-21 01:49:40 +01:00
Benjamin Otte 170bc0a8de window: properly compute desired size
Previously, the code did not expand the size properly when a default
size was already set.

Reftest included.
2021-11-21 01:31:06 +01:00
Matthias Clasen 891fd5c604 Merge branch 'missing-the-missing-glyphs' into 'master'
Go back to using pango for glyph rendering

See merge request GNOME/gtk!4181
2021-11-20 21:56:37 +00:00
Matthias Clasen 5b1cd335bb Go back to using pango for glyph rendering
Using just cairo makes us lose hexboxes. So, until
we implement that ourselves, go back to using pango.
2021-11-20 11:13:52 -05:00
Benjamin Otte eefb6a0dd4 sizerequest: Change critical message
Printing the affected widget leads people to assume that it is to blame
for the error. However, the widget is the object the function is being
called on, not the caller. And the caller is doing it wrong.

Usually the caller is the parent widget, so we could print that one, but
it's only usually, it can be an issue propagating from a grandparent and
it doesn't tell you from where the function is called (allocation or
measuring), so you need a debugger anyway.

So don't put anything there instead.
2021-11-20 17:05:36 +01:00
Matthias Clasen 9aaf54140f Merge branch 'wip/fix-randr-race' into 'master'
x11: Trap error when getting CRTC info

See merge request GNOME/gtk!4169
2021-11-20 14:43:48 +00:00
Samuel Thibault c5786916f7 Revert "a11y: return -1 if parent is NULL"
This reverts commit 22847563ce.
2021-11-20 10:59:00 +01:00
Samuel Thibault b8e009eb05 Merge branch 'wip/chergert/fix-a11y-critical' into 'master'
a11y: return -1 if parent is NULL

See merge request GNOME/gtk!4179
2021-11-20 08:14:35 +00:00
Asier Sarasua Garmendia 256d226d4b Update Basque translation 2021-11-20 07:52:06 +00:00
Benjamin Otte 7b3208092c Merge branch 'wip/otte/for-master' into 'master'
Lots of sizing fixes

See merge request GNOME/gtk!4180
2021-11-20 06:06:08 +00:00
Benjamin Otte 1eb86d6394 widget: Remove a check
That consistency check is entirely outdated and just prints confusing
stuff.
2021-11-20 06:04:10 +01:00
Benjamin Otte a0ca936e8d sizerequestcache: Increase size
This is a quickfix to avoid infinite runtime in nested boxes with
wrapped labels.

Test included
2021-11-20 06:04:10 +01:00
Benjamin Otte de3c50a237 sizerequest: Use g_printerr() for debug messages
glib doesn't print debug messages by default anymore.
2021-11-20 06:04:10 +01:00
Benjamin Otte 244ddea0ea paned: Always query at least min size
For shrinking children, we would not make sure of this and just throw
the current size at them.
2021-11-20 06:04:10 +01:00
Benjamin Otte 6c94835f5d stack: Make sure to not under-measure children
When the stack is homogeneous in only one direction, the other direction
may produce min sizes to small for all children. Make sure to query at
least the min size for those.
2021-11-20 06:04:10 +01:00
Benjamin Otte 617566128d stack: Index the homogeneous array by orientation 2021-11-20 06:04:10 +01:00
Benjamin Otte 7bf772111c stack: Turn the homogenenous variables into an array
that way, we can index them by orientation.
2021-11-20 06:04:10 +01:00
Benjamin Otte 50e0893497 widget: force adjustment method is one size is FILL
If halign=fill, force adjustment to height-for-width.
If valign=fill, force adjustment to width-for-height.
Otherwise look at request mode.

This way we don't try to adapt the filled dimension and only adjust
the one that is not set to fill.
2021-11-20 06:04:10 +01:00
Benjamin Otte 7459d430eb widget: Don't forget margins when adjusting
This could lead to the wrong values being passed and computing invalid
sizes which would then lead to very unhappy code.

Test included.
2021-11-19 23:46:59 +01:00
Benjamin Otte 163616cc0a sizerequest: Add a critical when for_size is too small
It's not expensive to check it because we'll cache the dfault size
request anyway, and people do it wrong a lot.
As a bonus, don't do any return_if_fail(), just use the min size
instead.
2021-11-19 23:46:59 +01:00
Fran Dieguez e378dc4c28 Update Galician translation 2021-11-19 22:23:26 +00:00
Fran Dieguez 4876028f29 Update Galician translation 2021-11-19 22:23:10 +00:00
Christian Hergert 22847563ce a11y: return -1 if parent is NULL 2021-11-19 11:59:29 -08:00
Emmanuele Bassi 0996113d14 Merge branch 'gtk-init-doc-update' into 'master'
Documentation fix and whitespace cleanup

See merge request GNOME/gtk!4176
2021-11-19 13:40:07 +00:00
Fred Morcos f019e9d856 Documentation fix and whitespace cleanup
- gtk_init() does not parse command-line options anymore.
- Gitlab's  WebIDE automatically cleans up whitespace.
2021-11-19 13:21:56 +00:00
Luca Bacci 48b83d3e97 Merge branch 'win32-egl-cleanup' into 'master'
GDK-Win32: Port EGL code to newer common GDK code

See merge request GNOME/gtk!4040
2021-11-19 08:42:40 +00:00
Danial Behzadi c3211e32ae Update Persian translation 2021-11-18 22:55:28 +00:00
Matthias Clasen c1790bf0d8 Merge branch 'matthiasc/for-master' into 'master'
node-editor: Don't make paned shrinkable

See merge request GNOME/gtk!4175
2021-11-18 22:42:25 +00:00
Matthias Clasen 6690197673 node-editor: Don't make paned shrinkable
When the handle is dragged all the way to the left,
it is impossible to get it back. Which is not fun.
2021-11-18 17:25:29 -05:00
Luca Bacci 384196efb1 Merge branch 'fix-aerosnap-4' into 'master'
GDK-Win32: Fix AeroSnap indicator and positioning

See merge request GNOME/gtk!3795
2021-11-18 12:40:21 +00:00
Chun-wei Fan b801125797 GDK-Win32: Fix AeroSnap indicator and positioning
Ensure that we take the DPI scaling into account so that surfaces will
be placed at their correct positions upon an AeroSnap operation on HiDPI
displays.

Also, use the X coordinate of the surface as-is during snap up so that
we do not inadvertently move the surface to the very left.  Also fix the
AeroSnap indicator drawing for snap up so that it is drawn at the
correct places.

Since we are updating these functions, make the old GdkWindow-era
variable names to match better the names we use nowadays.
2021-11-18 12:40:57 +01:00
Benjamin Otte aecdd6f68f Merge branch 'wip/otte/for-master' into 'master'
label: Don't add a pixel where none should be added

See merge request GNOME/gtk!4173
2021-11-18 07:38:53 +00:00
Benjamin Otte 899cb44519 label: Don't add a pixel where none should be added
When the text width is larger than the measuring width, set the min
width to that value, don't also add 1 to it.
2021-11-18 07:16:09 +00:00
Matthias Clasen 86175f043c Merge branch 'msal4-master-patch-74685' into 'master'
docs: use px unit for font size

See merge request GNOME/gtk!4171
2021-11-18 04:54:43 +00:00
Matthias Clasen 74c6b8e9bc Merge branch 'picture-ratio-redraw' into 'master'
picture: Setting keep-aspect-ratio requires a redraw

See merge request GNOME/gtk!4172
2021-11-18 03:43:54 +00:00
Marco Melorio d3347e64ba picture: Setting keep-aspect-ratio requires a redraw 2021-11-18 02:39:15 +01:00
Mohammed Salman 4c8081bafc Update section-text-widget.md 2021-11-17 22:48:14 +00:00
Matthias Clasen 5995e89a80 Merge branch 'matthiasc/for-master' into 'master'
Don't spam debug messages into TAP output

See merge request GNOME/gtk!4167
2021-11-17 11:59:15 +00:00
Jonas Ådahl b9bdbe9aae x11: Trap error when getting CRTC info
This should fix a race happening when RANDR changes quickly, e.g. during
unit testing where tests change monitor configurations rapidly.
2021-11-17 11:15:40 +01:00
Matthias Clasen c86789427d Don't spam debug messages into TAP output
g_log_writer_standard_streams just puts all the logs
out onto stderr and stdout if we don't stop it. Pango
recently grew a bunch of g_debug calls, and those were
now showing up, making all the reftests fail.
2021-11-16 18:45:34 -05:00
Matthias Clasen 0852084884 Merge branch 'matthiasc/for-master' into 'master'
Fix formatting error in demo about dialogs

See merge request GNOME/gtk!4166
2021-11-16 22:23:31 +00:00
Matthias Clasen 96778fca92 Fix formatting error in demo about dialogs
Try harder to format things nicely.
2021-11-16 16:45:56 -05:00
Matthias Clasen 0c53b608f9 Merge branch 'bilelmoussaoui/since-annotations' into 'master'
g-i: add missing since annotations

See merge request GNOME/gtk!4154
2021-11-16 21:34:58 +00:00
Matthias Clasen 27350ad71b Merge branch 'wip/otte/for-master' into 'master'
build: Actually use the extra warnings

See merge request GNOME/gtk!4157
2021-11-16 21:31:48 +00:00
Matthias Clasen d9d220cfc9 Merge branch 'wip/carlosg/x11-wm-drags' into 'master'
gtkmain: Disable implicit grab active state on CROSSING_GRAB leave events

Closes #4416

See merge request GNOME/gtk!4162
2021-11-16 17:21:38 +00:00
Matthias Clasen 2026256823 Merge branch 'compose-cache-symlinks' into 'master'
composetable: invalidate cache based on symlink mtime too

See merge request GNOME/gtk!4163
2021-11-16 17:21:04 +00:00
Matthias Clasen 012baeb909 Merge branch 'wip/carlosg/cancelled-gestures' into 'master'
gtkwidget: Do not check event sequence state before cancelling gesture

Closes #4387

See merge request GNOME/gtk!4160
2021-11-16 17:19:55 +00:00
Asier Sarasua Garmendia 7249961aa4 Update Basque translation 2021-11-16 16:28:52 +00:00
Emmanuele Bassi 3d77e526d6 Merge branch 'ebassi/docs-fixes' into 'master'
Small documentation fixes

See merge request GNOME/gtk!4158
2021-11-16 14:04:50 +00:00
Emmanuele Bassi c4b2fe6ee5 docs: Add blurb for GtkEditableProperties. 2021-11-16 13:50:52 +00:00
Emmanuele Bassi cea320af24 docs: Fix description for CellRendererAccelMode
Link to the property, instead of copy-pasting its description.
2021-11-16 13:41:52 +00:00
Emmanuele Bassi a5bf0591ee docs: Fix link in GtkSymbolicColor description 2021-11-16 13:37:33 +00:00
Naïm Favier 22f5236943 composetable: invalidate cache based on symlink mtime too
When the compose file is a symbolic link, take the link itself's
modification time into account (in addition to its target's) in
determining whether to invalidate the compose cache.

This is useful e.g. on NixOS systems where the compose file might point
to a store path with an irrelevant modification time, and we want the
cache to expire when the symlink itself changes.
2021-11-16 12:53:38 +01:00
Carlos Garnacho f84bcfbb97 gtkmain: Disable implicit grab active state on CROSSING_GRAB leave events
This grab-induced crossing event may come from outer means while there are
buttons pressed (e.g. WM window drags/resizes in X11), the implicit active
state should be undone in that situation.

Also, separate the handling of GDK_LEAVE_NOTIFY, as it's fundamentally
different from GDK_TOUCH_END/CANCEL handling.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4416
2021-11-16 10:58:03 +01:00
Carlos Garnacho f36ee67226 gtkgesture: Do not cancel gesture when setting DENIED state
Touchpoint state and tracking are tangential, this is mixing up both.
This change was added in the fixes for
https://gitlab.gnome.org/GNOME/gtk/-/issues/3016 but is now unnecessary.
2021-11-16 00:47:57 +01:00
Carlos Garnacho 615b8fc569 gtkwidget: Do not check event sequence state before cancelling gesture
The sequence should be cancelled from the gesture despite its current state.
Also, there was a piece of pointer emulation that was not dropped here,
maybe breaking things further for the pointer emulated touchpoint.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4387
2021-11-16 00:41:17 +01:00
Emmanuele Bassi ff3bb7f671 docs: Annotate Label.get_selection_bounds() out arguments
They are optional, and should be marked as such.

See issue: #4452
2021-11-15 15:35:13 +00:00
Emmanuele Bassi 39e4e48fdc docs: Enable OpenSearch on our references
By adding the `docs_url` key in the project configuration file,
gi-docgen will generate an OpenSearch XML file, which allows to add
docs.gtk.org/<reference> as a "search engine" in web browsers.
2021-11-15 15:31:35 +00:00
Benjamin Otte 300a88922e build: Disable gcc warnings as warnings, too
We use -Werror in the build, so even if some warnings are just warnings,
they'd be errors.
2021-11-15 15:35:10 +01:00
Benjamin Otte c003260d63 build: Actually use the extra warnings
I forgot to remove the '-Werror=' part from all the extra warnings, so
the warning/error flags we generated were '-Werror=-Werror=warning-flag'
or 'W-Werror=warning-flag' - but because our compiler flag checking
infrastructure works so nicely, it just ignored these obviously wrong
flags.

Fixes commit 362e91c40b
2021-11-15 14:59:18 +01:00
Bilal Elmoussaoui 40c08954db g-i: add missing since annotations 2021-11-13 17:50:53 +01:00
Goran Vidović fd69b41748 Update Croatian translation 2021-11-12 13:58:59 +00:00
Goran Vidović a2191c0a68 Update Croatian translation 2021-11-12 13:06:50 +00:00
Yaron Shahrabani c17451557f Update Hebrew translation 2021-11-11 22:30:08 +00:00
Yaron Shahrabani b91dca9ad0 Update Hebrew translation 2021-11-11 22:29:14 +00:00
Piotr Drąg 7586e535ff Update POTFILES.skip 2021-11-11 14:23:08 +01:00
Benjamin Otte 7859b88f19 Merge branch 'wip/otte/for-master' into 'master'
label: Don't do more work than necessary

See merge request GNOME/gtk!4149
2021-11-11 04:39:58 +00:00
Benjamin Otte 7f7809f523 label: Don't do more work than necessary
We only want to determine the size pixel-exact, not pango-unit-exact, so
don't spend lots of time wondering if text is half a pixel or a quarter
pixel wider.
2021-11-11 05:24:58 +01:00
Matthias Clasen b4c2d1dabb Merge branch 'wip/otte/no-errors-ever-again' into 'master'
build: Don't use any -Werror in release builds

Closes #4388

See merge request GNOME/gtk!4148
2021-11-11 00:50:09 +00:00
Benjamin Otte 362e91c40b build: Don't use any -Werror in release builds
Do kep them for debug and debugoptimized builds though.

Keeping -Werror flags in release builds causes issues with forward
compatibility, when new compiler releases or different toolchains
suddenly cause those warnings to be emitted during compilation.

While we certainly want those issues to be investigated and fixed, they
should not prevent anyone from building GTK until they are.

Resolves #4388
2021-11-10 20:04:07 +01:00
Quentin PAGÈS acf6d47b6f Update Occitan translation
(cherry picked from commit 7520524aed)
2021-11-10 18:18:00 +00:00
Benjamin Otte 0903ad48f0 Merge branch 'wip/otte/for-master' into 'master'
css: Don't crash when color stop offsets descend

Closes #4424

See merge request GNOME/gtk!4143
2021-11-10 16:44:56 +00:00
Benjamin Otte 46f8600b6a css: Don't crash when color stop offsets descend
Testcase included.

Fixes #4424
2021-11-10 17:28:14 +01:00
Daniel Mustieles fcb3638ac3 Updated Spanish translation 2021-11-10 11:32:36 +01:00
Matthias Clasen e599b2548a Merge branch 'flatpak-build-fix' into 'master'
flatpak: Add pango to manifest

See merge request GNOME/gtk!4142
2021-11-09 20:49:31 +00:00
Matthias Clasen 98d14b4655 flatpak: Add pango to manifest
We have a tight coupling with pango, whenever new
pango API appears, our build usually breaks. So
just make our flatpak manifests build pango from git.
2021-11-09 15:25:48 -05:00
Benjamin Otte 96f7e59832 Merge branch 'wip/otte/for-master' into 'master'
gtk-demo: Don't use deprecated librsvg API

See merge request GNOME/gtk!4141
2021-11-09 19:49:37 +00:00
Benjamin Otte 061026f21f gtk-demo: Don't use deprecated librsvg API
New API requires a newer librsvg version, so require that one.
2021-11-09 20:29:49 +01:00
Benjamin Otte 330e9a8424 Merge branch 'wip/otte/for-master' into 'master'
label: Handle width-chars > text width

See merge request GNOME/gtk!4139
2021-11-09 18:31:42 +00:00
Benjamin Otte 1e47b1c610 label: Handle width-chars > text width
This was broken in wrapping labels.

Testcase included.
2021-11-09 18:34:35 +01:00
Emmanuele Bassi 018388d321 Unrealize ATContext on unroot
Non-root widgets should unrealize their ATContext, if they have one,
when they are unrooted, as they don't have a connection to a top level
any more.

Fixes: #4421
2021-11-08 10:18:22 +00:00
Chun-wei Fan 41599e5e90 GDK-Win32: Make EGL a runtime opt-in
Use the debug envvar 'GDK_DEBUG=gl-egl' to determine whether we want to try to
initialize EGL first before trying WGL, as a means for people to more easily
enable EGL support on Windows to test EGL there (such as to debug the shaders,
for instance)
2021-11-08 15:40:59 +08:00
Chun-wei Fan 1b2e69f6c0 GDK-Win32: Realize EGL using common realization code
This will clean up the EGL code in GDK-Win32, as well as fixing crashes caused
by using an invalid EGL context in gdk_gl_context_make_current() as we did not
store up the EGL context in the correct place (lost during the transition to
the common EGL initialization code).

On the Windows/libANGLE side, the initialization of EGL has now fully moved to
the common code in GDK, but we will still default on WGL for now.  Help is
really appreciated for fixing the shaders on libANGLE!
2021-11-08 15:40:49 +08:00
Chun-wei Fan ee45869759 gdkdisplay.c: Fix builds without EGL
We need to ensure that gdk_display_get_egl_display() is available even if EGL
is not enabled in the build, so that things will continue to link and work.

For builds without EGL, just return NULL.
2021-11-08 15:25:24 +08:00
Chun-wei Fan 048fe84888 GDK-Win32: Port to common EGL handling code
This will port the EGL code in GDK-Win32 to use the common GDK code to
initialize EGL.  However, at the current state, although EGL is
correctly initialized, this code is disabled for now since
gdk_gl_context_make_current() fails as the shaders do not work for EGL
via libANGLE on Windows.

We can now clean things up in gdkglcontext-win32-egl.c as a result.
2021-11-08 15:25:24 +08:00
Chun-wei Fan 480031439f GDK-Win32: Drop GDK_WIN32_ENABLE_EGL flag
Instead, use HAVE_EGL check macro instead, which is used by the other
platforms as well.
2021-11-08 15:25:24 +08:00
Caolán McNamara 155b791d43 update focus indicators in popovers
https://gitlab.gnome.org/GNOME/gtk/-/issues/4383
2021-11-05 13:50:48 +00:00
Matthias Clasen 031c37c7b0 theme: Remove GtkToolbar remnants
We don't ship a widget with css name 'toolbar'
anymore, so don't waste selectors on it.
2021-10-29 11:51:18 -04:00
Matthias Clasen 860821114a Don't make all buttons in toolbars flat
When a combobox is put in a toolbar, we don't want
its button to lose its border.

Fixes: #4384
2021-10-29 11:51:18 -04:00
Matthias Clasen 73bba62d82 widget-factory: Add a color button to the toolbar
This is to check that our 'nested' buttons come out as
expected in a toolbar context.
2021-10-29 11:51:18 -04:00
Marc-André Lureau 42249ce28e gtk: fix GTK_INVALID_LIST_POSITION type
Unless there is an explicit front cast, constants are generally int for g-i.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-07-08 13:08:43 +04:00
356 changed files with 45742 additions and 45446 deletions
+17 -17
View File
@@ -167,7 +167,7 @@ macos:
needs: []
before_script:
- bash .gitlab-ci/show-info-osx.sh
- pip3 install --user meson==0.56
- pip3 install --user meson==0.59
- pip3 install --user ninja
- export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH
- export MESON_FORCE_BACKTRACE=1
@@ -221,11 +221,11 @@ vs2017-x64:
extends: .flatpak-defaults
when: manual
# Only build Flatpak bundles automatically on master
.flatpak-master:
# Only build Flatpak bundles automatically on main
.flatpak-main:
extends: .flatpak-defaults
only:
- master
- main
flatpak-manual:demo:
extends: .flatpak-manual
@@ -233,8 +233,8 @@ flatpak-manual:demo:
variables:
APPID: org.gtk.Demo4
flatpak-master:demo:
extends: .flatpak-master
flatpak-main:demo:
extends: .flatpak-main
needs: []
variables:
APPID: org.gtk.Demo4
@@ -245,8 +245,8 @@ flatpak-manual:widget-factory:
variables:
APPID: org.gtk.WidgetFactory4
flatpak-master:widget-factory:
extends: .flatpak-master
flatpak-main:widget-factory:
extends: .flatpak-main
needs: []
variables:
APPID: org.gtk.WidgetFactory4
@@ -257,8 +257,8 @@ flatpak-manual:icon-browser:
variables:
APPID: org.gtk.IconBrowser4
flatpak-master:icon-browser:
extends: .flatpak-master
flatpak-main:icon-browser:
extends: .flatpak-main
needs: []
variables:
APPID: org.gtk.IconBrowser4
@@ -268,18 +268,18 @@ flatpak-master:icon-browser:
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
nightly demo:
extends: '.publish_nightly'
dependencies: ['flatpak-master:demo']
needs: ['flatpak-master:demo']
dependencies: ['flatpak-main:demo']
needs: ['flatpak-main:demo']
nightly factory:
extends: '.publish_nightly'
dependencies: ['flatpak-master:widget-factory']
needs: ['flatpak-master:widget-factory']
dependencies: ['flatpak-main:widget-factory']
needs: ['flatpak-main:widget-factory']
nightly icon-browser:
extends: '.publish_nightly'
dependencies: ['flatpak-master:icon-browser']
needs: ['flatpak-master:icon-browser']
dependencies: ['flatpak-main:icon-browser']
needs: ['flatpak-main:icon-browser']
static-scan:
image: $FEDORA_IMAGE
@@ -346,4 +346,4 @@ publish-docs:
- "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:
- master
- main
+1 -1
View File
@@ -43,6 +43,6 @@ flatpak build-bundle \
${appid}
# to be consumed by the nightly publish jobs
if [[ $CI_COMMIT_BRANCH == master ]]; then
if [[ $CI_COMMIT_BRANCH == main ]]; then
tar cf repo.tar ${repodir}
fi
+1 -1
View File
@@ -268,7 +268,7 @@ aparser.add_argument('--job-id', metavar='ID',
default=None)
aparser.add_argument('--branch', metavar='NAME',
help='Branch of the project being tested',
default='master')
default='main')
aparser.add_argument('--output', metavar='FILE',
help='The output HTML file, stdout by default',
type=argparse.FileType('w', encoding='UTF-8'),
+1 -1
View File
@@ -27,7 +27,7 @@ aparser.add_argument('--job-id', metavar='ID',
default='Unknown')
aparser.add_argument('--branch', metavar='NAME',
help='Branch of the project being tested',
default='master')
default='main')
aparser.add_argument('--output', metavar='FILE',
help='The output file, stdout by default',
type=argparse.FileType('w', encoding='UTF-8'),
+3 -3
View File
@@ -2,7 +2,7 @@
set -e
# We need to add a new remote for the upstream master, since this script could
# We need to add a new remote for the upstream main, since this script could
# be running in a personal fork of the repository which has out of date branches.
if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
@@ -16,7 +16,7 @@ fi
# Work out the newest common ancestor between the detached HEAD that this CI job
# has checked out, and the upstream target branch (which will typically be
# `upstream/master` or `upstream/gtk-3-24`).
# `upstream/main` or `upstream/gtk-3-24`).
#
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if were running in
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
@@ -36,7 +36,7 @@ exit_status=$?
echo ""
echo "Note that clang-format output is advisory and cannot always match the"
echo "GTK coding style, documented at:"
echo " https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/CODING-STYLE"
echo " https://gitlab.gnome.org/GNOME/gtk/blob/main/docs/CODING-STYLE"
echo "Warnings from this tool can be ignored in favour of the documented "
echo "coding style, or in favour of matching the style of existing"
echo "surrounding code."
+1 -1
View File
@@ -5,7 +5,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliar
@echo on
:: FIXME: make warnings fatal
pip3 install --upgrade --user meson==0.56.2 || goto :error
pip3 install --upgrade --user meson==0.59 || goto :error
meson -Dmedia-gstreamer=disabled _build || goto :error
ninja -C _build || goto :error
+3 -2
View File
@@ -31,7 +31,8 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-pango \
mingw-w64-$MSYS2_ARCH-fribidi \
mingw-w64-$MSYS2_ARCH-gst-plugins-bad \
mingw-w64-$MSYS2_ARCH-shared-mime-info
mingw-w64-$MSYS2_ARCH-shared-mime-info \
mingw-w64-$MSYS2_ARCH-python-gobject
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
@@ -48,7 +49,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.49.3 pango; then
if ! pkg-config --atleast-version=1.50.0 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build
+1 -1
View File
@@ -1,7 +1,7 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/CONTRIBUTING.md
-->
## Steps to reproduce
<!--
+1 -1
View File
@@ -1,7 +1,7 @@
<!--
Please, read the CONTRIBUTING.md guide on how to file a new issue.
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/CONTRIBUTING.md
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/CONTRIBUTING.md
-->
## Steps to reproduce
+1 -1
View File
@@ -256,7 +256,7 @@ people committing to GTK to follow a few rules:
0. Always write a meaningful commit message. Changes without a sufficient
commit message will be reverted.
0. Never push to the `master` branch, or any stable branches, directly; you
0. Never push to the `main` branch, or any stable branches, directly; you
should always go through a merge request, to ensure that the code is
tested on the CI infrastructure at the very least. A merge request is
also the proper place to get a comprehensive code review from the core
+124
View File
@@ -1,3 +1,127 @@
Overview of Changes
===================
* GtkProgressBar:
- Fix handling of "inverted"
* GtkLabel:
- Add a "natural wrap mode" property to influence how
natural width is determined
* GtkTextView
- Scroll insertion on-screen after undo / redo
* gsk:
- Abort region diffing when changes are too complex
* gdk:
- Avoid compressing discrete scroll events
- Fix problems with hiding windows
- Improve GL and GLES version checks
* Wayland:
- Support new high-contrast setting
* Inspector:
- Add DND inspection support
* build:
- Avoid deprecated meson apis
* Translation updates
Galician
Portuguese
Ukrainian
Overview of Changes in 4.5.1, 16-12-2021
========================================
* GtkWidget sizing has been rewritten to implement
width-for-height more properly. This had some fallout,
and some widgets may still not react kindly to the
new way of doing things.
See https://blog.gtk.org/2021/12/03/sizable-news/
for details, and please file issues if you notice fallout.
* Rename git `master` branch to `main`
* Css:
- Fully support font-variant-caps
- Fix a crash with gradients
* Make various widgets activatable:
- GtkComboBox
- GtkDropDown
* GtkPopover:
- Make focus indicators not disappear
* GtkTextView:
- Don't leave embedded children stranded when scrolling
- Don't insert Emoji into non-editable textviews
- Fix Emoji chooser positioning
- Fix problems with pasting text
- Improve scroll-to-mark behavior
- Support right-aligned, centered and decimal tabs
- Make child anchor replacement character settable
- Provide more context to input methods
* GtkDragIcon:
- Provide default icons for paintables and files
* GtkBuilder:
- Speed up template precompilation
* Actions:
- Reduce allocations during signal emissions
- Avoid duplication and unnecessary recursion
* Inspector:
- Show the selected im-module in the General tab
- Add a clipboard viewer
- Make the recorder record events too
- Add a graph visualizing gtk_widget_measure()
* Gsk:
- Fix hexbox rendering
- Fix transformed linear gradient rendering
* Printing:
- Fix dialog-less printing
* Windows:
- Use the common EGL setup code
- Respect GDK_DEBUG=gl-egl
- Fix AeroSnap indicator and positioning
* X11:
- Improve behavior of windows drags on headerbar controls
- Trap errors for RANDR changes
- Fix problems with drag icons
* Wayland:
- Ensure we prefer the Wayland im-module over others
* Translation updates
Basque
Catalan
Croatian
Friulian
Galician
Hebrew
Icelandic
Italian
Latvian
Lithuanian
Occitan
Persian
Portuguese
Spanish
Swedish
Ukrainian
Overview of Changes in 4.5.0
============================
+16 -2
View File
@@ -1,7 +1,7 @@
GTK — The GTK toolkit
=====================
[![Build status](https://gitlab.gnome.org/GNOME/gtk/badges/master/pipeline.svg)](https://gitlab.gnome.org/GNOME/gtk/-/commits/master)
[![Build status](https://gitlab.gnome.org/GNOME/gtk/badges/main/pipeline.svg)](https://gitlab.gnome.org/GNOME/gtk/-/commits/main)
General information
-------------------
@@ -40,7 +40,7 @@ Nightly documentation can be found at
Nightly flatpaks of our demos can be installed from the
[GNOME Nightly](https://wiki.gnome.org/Apps/Nightly) repository:
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
- `flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo`
- `flatpak install gnome-nightly org.gtk.Demo4`
- `flatpak install gnome-nightly org.gtk.WidgetFactory4`
- `flatpak install gnome-nightly org.gtk.IconBrowser4`
@@ -116,6 +116,20 @@ docs/reference/gtk/html/gtk-building.html
Or [online](https://docs.gtk.org/gtk4/building.html)
Default branch renamed to `main`
--------------------------------
The default development branch of GTK has been renamed to `main`.
To update your local checkout, use:
```sh
git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
```
How to report bugs
------------------
+17 -1
View File
@@ -164,6 +164,21 @@
}
]
},
{
"name" : "pango",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
"branch" : "main"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
@@ -177,7 +192,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}
+17 -1
View File
@@ -93,6 +93,21 @@
}
]
},
{
"name" : "pango",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
"branch" : "main"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
@@ -106,7 +121,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}
+17 -1
View File
@@ -93,6 +93,21 @@
}
]
},
{
"name" : "pango",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
"branch" : "main"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
@@ -106,7 +121,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}
+1 -1
View File
@@ -17,7 +17,7 @@ executable('gtk4-constraint-editor',
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: false,
)
+316 -127
View File
@@ -1,12 +1,10 @@
/* Clipboard
*
* GdkClipboard is used for clipboard handling. This demo shows how to
* copy and paste text to and from the clipboard.
* copy and paste text, images, colors or files to and from the clipboard.
*
* It also shows how to transfer images via the clipboard or via
* drag-and-drop, and how to make clipboard contents persist after
* the application exits. Clipboard persistence requires a clipboard
* manager to run.
* You can also use Drag-And-Drop to copy the data from the source to the
* target.
*/
#include <glib/gi18n.h>
@@ -14,22 +12,103 @@
#include <string.h>
#include "demoimage.h"
static GtkWidget *window = NULL;
static void
copy_button_clicked (GtkStack *source_stack,
gpointer user_data)
{
GdkClipboard *clipboard;
const char *visible_child_name;
GtkWidget *visible_child;
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (source_stack));
visible_child = gtk_stack_get_visible_child (source_stack);
visible_child_name = gtk_stack_get_visible_child_name (source_stack);
if (strcmp (visible_child_name, "Text") == 0)
{
gdk_clipboard_set_text (clipboard, gtk_editable_get_text (GTK_EDITABLE (visible_child)));
}
else if (strcmp (visible_child_name, "Image") == 0)
{
GtkWidget *child;
for (child = gtk_widget_get_first_child (visible_child); child; child = gtk_widget_get_next_sibling (child))
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (child)))
{
GtkWidget *image = gtk_widget_get_first_child (child);
GdkPaintable *paintable = gtk_image_get_paintable (GTK_IMAGE (image));
if (GDK_IS_TEXTURE (paintable))
gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, paintable);
else
gdk_clipboard_set (clipboard, GDK_TYPE_PAINTABLE, paintable);
break;
}
}
}
else if (strcmp (visible_child_name, "Color") == 0)
{
GdkRGBA color;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (visible_child), &color);
gdk_clipboard_set (clipboard, GDK_TYPE_RGBA, &color);
}
else if (strcmp (visible_child_name, "File") == 0)
{
gdk_clipboard_set (clipboard, G_TYPE_FILE, g_object_get_data (G_OBJECT (visible_child), "file"), NULL);
}
else
{
g_print ("TODO");
}
}
static void
copy_button_clicked (GtkWidget *button,
gpointer user_data)
present_value (GtkStack *dest_stack,
const GValue *value)
{
GtkWidget *entry;
GdkClipboard *clipboard;
GtkWidget *child;
entry = GTK_WIDGET (user_data);
if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
GFile *file;
/* Get the clipboard object */
clipboard = gtk_widget_get_clipboard (entry);
gtk_stack_set_visible_child_name (dest_stack, "File");
child = gtk_stack_get_visible_child (dest_stack);
/* Set clipboard text */
gdk_clipboard_set_text (clipboard, gtk_editable_get_text (GTK_EDITABLE (entry)));
file = g_value_get_object (value);
g_object_set (child, "label", g_file_peek_path (file), NULL);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_RGBA))
{
GdkRGBA *color;
gtk_stack_set_visible_child_name (dest_stack, "Color");
child = gtk_widget_get_first_child (gtk_stack_get_visible_child (dest_stack));
color = g_value_get_boxed (value);
g_object_set (child, "rgba", color, NULL);
}
else if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE) ||
G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE))
{
GdkPaintable *paintable;
gtk_stack_set_visible_child_name (dest_stack, "Image");
child = gtk_stack_get_visible_child (dest_stack);
paintable = g_value_get_object (value);
g_object_set (child, "paintable", paintable, NULL);
}
else if (G_VALUE_HOLDS (value, G_TYPE_STRING))
{
gtk_stack_set_visible_child_name (dest_stack, "Text");
child = gtk_stack_get_visible_child (dest_stack);
gtk_label_set_label (GTK_LABEL (child), g_value_get_string (value));
}
}
static void
@@ -37,149 +116,259 @@ paste_received (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GtkStack *dest_stack = user_data;
GdkClipboard *clipboard;
GtkWidget *entry;
char *text;
const GValue *value;
GError *error = NULL;
clipboard = GDK_CLIPBOARD (source_object);
entry = GTK_WIDGET (user_data);
/* Get the resulting text of the read operation */
text = gdk_clipboard_read_text_finish (clipboard, result, &error);
if (text)
value = gdk_clipboard_read_value_finish (clipboard, result, &error);
if (value)
{
/* Set the entry text */
gtk_editable_set_text (GTK_EDITABLE (entry), text);
g_free (text);
present_value (dest_stack, value);
}
else
{
GtkWidget *dialog;
/* Show an error about why pasting failed.
* Usually you probably want to ignore such failures,
* but for demonstration purposes, we show the error.
*/
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Could not paste text: %s",
error->message);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
paste_button_clicked (GtkWidget *button,
gpointer user_data)
paste_button_clicked (GtkStack *dest_stack,
gpointer user_data)
{
GtkWidget *entry;
GdkClipboard *clipboard;
GdkContentFormats *formats;
entry = GTK_WIDGET (user_data);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (dest_stack));
formats = gdk_clipboard_get_formats (clipboard);
/* Get the clipboard object */
clipboard = gtk_widget_get_clipboard (entry);
if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_TEXTURE))
gdk_clipboard_read_value_async (clipboard, GDK_TYPE_TEXTURE, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_PAINTABLE))
gdk_clipboard_read_value_async (clipboard, GDK_TYPE_PAINTABLE, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_RGBA))
gdk_clipboard_read_value_async (clipboard, GDK_TYPE_RGBA, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, G_TYPE_FILE))
gdk_clipboard_read_value_async (clipboard, G_TYPE_FILE, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, G_TYPE_STRING))
gdk_clipboard_read_value_async (clipboard, G_TYPE_STRING, 0, NULL, paste_received, dest_stack);
}
/* Request the contents of the clipboard, contents_received will be
called when we do get the contents.
*/
gdk_clipboard_read_text_async (clipboard, NULL, paste_received, entry);
static void
update_copy_button_sensitivity (GtkWidget *source_stack)
{
GtkButton *copy_button;
const char *visible_child_name;
GtkWidget *visible_child;
gboolean sensitive;
copy_button = GTK_BUTTON (g_object_get_data (G_OBJECT (source_stack), "copy-button"));
visible_child = gtk_stack_get_visible_child (GTK_STACK (source_stack));
visible_child_name = gtk_stack_get_visible_child_name (GTK_STACK (source_stack));
if (strcmp (visible_child_name, "Text") == 0)
{
sensitive = strlen (gtk_editable_get_text (GTK_EDITABLE (visible_child))) > 0;
}
else if (strcmp (visible_child_name, "Color") == 0 ||
strcmp (visible_child_name, "Image") == 0)
{
sensitive = TRUE;
}
else if (strcmp (visible_child_name, "File") == 0)
{
sensitive = g_object_get_data (G_OBJECT (visible_child), "file") != NULL;
}
else
{
sensitive = FALSE;
}
gtk_widget_set_sensitive (GTK_WIDGET (copy_button), sensitive);
}
static void
source_changed_cb (GtkButton *copy_button,
GParamSpec *pspec,
GtkWidget *source_stack)
{
update_copy_button_sensitivity (source_stack);
}
static void
text_changed_cb (GtkButton *copy_button,
GParamSpec *pspec,
GtkWidget *entry)
{
update_copy_button_sensitivity (gtk_widget_get_ancestor (entry, GTK_TYPE_STACK));
}
static void
file_button_set_file (GtkButton *button,
GFile *file)
{
gtk_label_set_label (GTK_LABEL (gtk_button_get_child (button)), g_file_peek_path (file));
g_object_set_data_full (G_OBJECT (button), "file", g_object_ref (file), g_object_unref);
}
static void
file_chooser_response (GtkNativeDialog *dialog,
int response,
GtkButton *button)
{
gtk_native_dialog_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
file_button_set_file (button, file);
g_object_unref (file);
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
}
gtk_native_dialog_destroy (dialog);
}
static void
open_file_cb (GtkWidget *button)
{
GtkFileChooserNative *chooser;
chooser = gtk_file_chooser_native_new ("Choose a file",
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Open",
"_Cancel");
g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), button);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
}
static void
update_paste_button_sensitivity (GdkClipboard *clipboard,
GtkWidget *paste_button)
{
GdkContentFormats *formats;
gboolean sensitive = FALSE;
formats = gdk_clipboard_get_formats (clipboard);
if (gdk_content_formats_contain_gtype (formats, G_TYPE_FILE) ||
gdk_content_formats_contain_gtype (formats, GDK_TYPE_RGBA) ||
gdk_content_formats_contain_gtype (formats, GDK_TYPE_TEXTURE) ||
gdk_content_formats_contain_gtype (formats, GDK_TYPE_PAINTABLE) ||
gdk_content_formats_contain_gtype (formats, G_TYPE_STRING))
sensitive = TRUE;
gtk_widget_set_sensitive (paste_button, sensitive);
}
static void
unset_clipboard_handler (gpointer data)
{
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
g_signal_handlers_disconnect_by_func (clipboard, update_paste_button_sensitivity, data);
}
static gboolean
on_drop (GtkStack *dest_stack,
const GValue *value,
double x,
double y,
gpointer data)
{
present_value (dest_stack, value);
return TRUE;
}
static GdkContentProvider *
drag_prepare (GtkDragSource *drag_source,
double x,
double y,
gpointer data)
{
GtkWidget *button;
GValue value = G_VALUE_INIT;
button = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (drag_source));
if (GTK_IS_TOGGLE_BUTTON (button))
{
GtkWidget *image = gtk_widget_get_first_child (button);
GdkPaintable *paintable = gtk_image_get_paintable (GTK_IMAGE (image));
if (GDK_IS_TEXTURE (paintable))
{
g_value_init (&value, GDK_TYPE_TEXTURE);
g_value_set_object (&value, paintable);
}
else
{
g_value_init (&value, GDK_TYPE_PAINTABLE);
g_value_set_object (&value, paintable);
}
}
else
{
GFile *file = g_object_get_data (G_OBJECT (button), "file");
if (file)
{
g_value_init (&value, G_TYPE_FILE);
g_value_set_object (&value, file);
}
else
return NULL;
}
return gdk_content_provider_new_for_value (&value);
}
GtkWidget *
do_clipboard (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *vbox, *hbox;
GtkWidget *label;
GtkWidget *entry, *button;
GtkWidget *image;
GtkBuilderScope *scope;
GtkBuilder *builder;
GtkWidget *button;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Clipboard");
scope = gtk_builder_cscope_new ();
gtk_builder_cscope_add_callback_symbols (GTK_BUILDER_CSCOPE (scope),
"copy_button_clicked", G_CALLBACK (copy_button_clicked),
"paste_button_clicked", G_CALLBACK (paste_button_clicked),
"source_changed_cb", G_CALLBACK (source_changed_cb),
"text_changed_cb", G_CALLBACK (text_changed_cb),
"open_file_cb", G_CALLBACK (open_file_cb),
"on_drop", G_CALLBACK (on_drop),
"drag_prepare", G_CALLBACK (drag_prepare),
NULL);
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/clipboard/clipboard.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
button = GTK_WIDGET (gtk_builder_get_object (builder, "copy_button"));
g_object_set_data (gtk_builder_get_object (builder, "source_stack"), "copy-button", button);
gtk_window_set_child (GTK_WINDOW (window), vbox);
button = GTK_WIDGET (gtk_builder_get_object (builder, "paste_button"));
g_signal_connect (gtk_widget_get_clipboard (button), "changed",
G_CALLBACK (update_paste_button_sensitivity), button);
g_object_set_data_full (G_OBJECT (button), "clipboard-handler", button, unset_clipboard_handler);
label = gtk_label_new ("\"Copy\" will copy the text\nin the entry to the clipboard");
gtk_box_append (GTK_BOX (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_box_append (GTK_BOX (vbox), hbox);
/* Create the first entry */
entry = gtk_entry_new ();
gtk_box_append (GTK_BOX (hbox), entry);
/* Create the button */
button = gtk_button_new_with_mnemonic (_("_Copy"));
gtk_box_append (GTK_BOX (hbox), button);
g_signal_connect (button, "clicked",
G_CALLBACK (copy_button_clicked), entry);
label = gtk_label_new ("\"Paste\" will paste the text from the clipboard to the entry");
gtk_box_append (GTK_BOX (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_box_append (GTK_BOX (vbox), hbox);
/* Create the second entry */
entry = gtk_entry_new ();
gtk_box_append (GTK_BOX (hbox), entry);
/* Create the button */
button = gtk_button_new_with_mnemonic (_("_Paste"));
gtk_box_append (GTK_BOX (hbox), button);
g_signal_connect (button, "clicked",
G_CALLBACK (paste_button_clicked), entry);
label = gtk_label_new ("Images can be transferred via the clipboard, too");
gtk_box_append (GTK_BOX (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_box_append (GTK_BOX (vbox), hbox);
/* Create the first image */
image = demo_image_new ("dialog-warning");
gtk_box_append (GTK_BOX (hbox), image);
/* Create the second image */
image = demo_image_new ("process-stop");
gtk_box_append (GTK_BOX (hbox), image);
/* Create the third image */
image = demo_image_new ("weather-clear");
gtk_box_append (GTK_BOX (hbox), image);
g_object_unref (builder);
g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))
+288
View File
@@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="resizable">1</property>
<property name="title">Clipboard</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="label">“Copy” will copy the selected data the clipboard, “Paste” will show the current clipboard contents. You can also drag the data to the bottom.</property>
<property name="wrap">1</property>
<property name="max-width-chars">40</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<child>
<object class="GtkDropDown" id="source_chooser">
<property name="valign">center</property>
<property name="model">
<object class="GtkStringList">
<items>
<item>Text</item>
<item>Color</item>
<item>Image</item>
<item>File</item>
</items>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStack" id="source_stack">
<signal name="notify::visible-child" handler="source_changed_cb" object="copy_button"/>
<property name="vexpand">1</property>
<binding name="visible-child-name">
<lookup name="string" type="GtkStringObject">
<lookup name="selected-item">
source_chooser
</lookup>
</lookup>
</binding>
<child>
<object class="GtkStackPage">
<property name="name">Text</property>
<property name="child">
<object class="GtkEntry" id="source_text">
<property name="valign">center</property>
<signal name="notify::text" handler="text_changed_cb" object="copy_button"/>
<property name="text">Copy this!</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">Color</property>
<property name="child">
<object class="GtkColorButton" id="source_color">
<property name="valign">center</property>
<property name="rgba">purple</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">Image</property>
<property name="child">
<object class="GtkBox">
<property name="valign">center</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkToggleButton" id="image_rose">
<property name="active">1</property>
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="drag_prepare"/>
</object>
</child>
<child>
<object class="GtkImage">
<style>
<class name="large-icons"/>
</style>
<property name="paintable">resource:///transparent/portland-rose.jpg</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="image_floppy">
<property name="group">image_rose</property>
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="drag_prepare"/>
</object>
</child>
<child>
<object class="GtkImage">
<style>
<class name="large-icons"/>
</style>
<property name="paintable">resource:///images/floppybuddy.gif</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="image_logo">
<property name="group">image_floppy</property>
<child>
<object class="GtkDragSource">
<signal name="prepare" handler="drag_prepare"/>
</object>
</child>
<child>
<object class="GtkImage">
<style>
<class name="large-icons"/>
</style>
<property name="paintable">resource:///images/org.gtk.Demo4.svg</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">File</property>
<property name="child">
<object class="GtkButton" id="source_file">
<child>
<object class="GtkDragSource">
<property name="propagation-phase">capture</property>
<signal name="prepare" handler="drag_prepare"/>
</object>
</child>
<property name="valign">center</property>
<property name="child">
<object class="GtkLabel">
<property name="label">—</property>
<property name="xalign">0</property>
<property name="ellipsize">start</property>
</object>
</property>
<signal name="clicked" handler="open_file_cb"/>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="copy_button">
<property name="valign">center</property>
<property name="label" translatable="yes">_Copy</property>
<signal name="clicked" handler="copy_button_clicked" object="source_stack"/>
<property name="use-underline">1</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<child>
<object class="GtkDropTarget">
<property name="actions">copy</property>
<property name="formats">GdkTexture GdkPaintable GFile GdkRGBA gchararray</property>
<signal name="drop" handler="on_drop" object="dest_stack"/>
</object>
</child>
<child>
<object class="GtkButton" id="paste_button">
<property name="label" translatable="yes">_Paste</property>
<signal name="clicked" handler="paste_button_clicked" object="dest_stack"/>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="visible-child-name" type="GtkStack">
dest_stack
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkStack" id="dest_stack">
<property name="halign">end</property>
<property name="valign">center</property>
<child>
<object class="GtkStackPage">
<property name="name"></property>
<property name="child">
<object class="GtkLabel">
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">Text</property>
<property name="child">
<object class="GtkLabel">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="ellipsize">end</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">Image</property>
<property name="child">
<object class="GtkImage">
<property name="halign">end</property>
<property name="valign">center</property>
<style>
<class name="large-icons"/>
</style>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">Color</property>
<property name="child">
<object class="GtkBox">
<property name="halign">end</property>
<property name="valign">center</property>
<child>
<object class="GtkColorSwatch">
<property name="accessible-role">img</property>
<property name="can-focus">0</property>
<property name="selectable">0</property>
<property name="has-menu">0</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">File</property>
<property name="child">
<object class="GtkLabel">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
<property name="ellipsize">start</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
+1
View File
@@ -15,6 +15,7 @@
<file>demo.ui</file>
</gresource>
<gresource prefix="/clipboard">
<file>clipboard.ui</file>
<file>demoimage.c</file>
<file>demoimage.h</file>
</gresource>
+2 -6
View File
@@ -45,9 +45,7 @@
<object class="GtkLabel">
<property name="xalign">0</property>
<property name="label" translatable="yes">Font Features</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<property name="attributes" translatable="yes">0 -1 weight bold</property>
</object>
</child>
<child>
@@ -75,9 +73,7 @@
<object class="GtkLabel" id="variations_heading">
<property name="label" translatable="yes">Font Variations</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<property name="attributes" translatable="yes">0 -1 weight bold</property>
</object>
</child>
<child>
+8 -2
View File
@@ -7,7 +7,8 @@
* shows.
*
* We also demonstrate adding other things to a text view, such as
* clickable icons.
* clickable icons and widgets which can also replace a character
* (try copying the ghost text).
*/
#include <gtk/gtk.h>
@@ -113,7 +114,12 @@ show_page (GtkTextView *text_view,
gtk_level_bar_set_value (GTK_LEVEL_BAR (child), 50);
gtk_widget_set_size_request (child, 100, -1);
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
gtk_text_buffer_insert (buffer, &iter, ".", -1);
gtk_text_buffer_insert (buffer, &iter, " and labels with ", -1);
anchor = gtk_text_child_anchor_new_with_replacement ("👻");
gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor);
child = gtk_label_new ("ghost");
gtk_text_view_add_child_at_anchor (text_view, child, anchor);
gtk_text_buffer_insert (buffer, &iter, " text.", -1);
}
else if (page == 2)
{
+1 -15
View File
@@ -177,15 +177,6 @@ file_open_cb (GtkWidget *button,
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
listview_activate_cb (GtkListView *listview,
guint pos,
gpointer unused)
{
gtk_fixed_item_selection_set_selected_position (GTK_FIXED_ITEM_SELECTION (gtk_list_view_get_model (listview)),
pos);
}
GtkWidget *
do_listview_words (GtkWidget *do_widget)
{
@@ -194,7 +185,6 @@ do_listview_words (GtkWidget *do_widget)
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
GtkFilterListModel *filter_model;
GtkStringList *stringlist;
GtkFixedItemSelection *selection;
GtkFilter *filter;
GFile *file;
@@ -251,15 +241,11 @@ do_listview_words (GtkWidget *do_widget)
gtk_widget_set_vexpand (sw, TRUE);
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
selection = gtk_fixed_item_selection_new (G_LIST_MODEL (filter_model));
listview = gtk_list_view_new (
GTK_SELECTION_MODEL (selection),
GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model))),
gtk_builder_list_item_factory_new_from_bytes (NULL,
g_bytes_new_static (factory_text, strlen (factory_text))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
gtk_list_view_set_single_click_activate (GTK_LIST_VIEW (listview), TRUE);
g_signal_connect (listview, "activate", G_CALLBACK (listview_activate_cb), NULL);
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
+1 -1
View File
@@ -192,7 +192,7 @@ activate_about (GSimpleAction *action,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
+1 -1
View File
@@ -21,7 +21,7 @@
<item>
<attribute name="label" translatable="yes">Save _As...</attribute>
<attribute name="action">app.save-as</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;s</attribute>
</item>
</section>
<section>
+6 -4
View File
@@ -140,7 +140,7 @@ if os_unix
demos += files('pagesetup.c')
endif
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.46.0', required: false)
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.52.0', required: false)
if librsvg_dep.found()
demos += files('paintable_svg.c')
@@ -228,7 +228,9 @@ endif
# Use a subset of compiler flags
demo_cflags = []
foreach flag: common_cflags
if flag not in ['-Werror=missing-prototypes', '-Werror=missing-declarations', '-fvisibility=hidden']
if flag not in ['-Werror=missing-prototypes', '-Wmissing-prototypes',
'-Werror=missing-declarations', '-Wmissing-declarations',
'-fvisibility=hidden']
demo_cflags += flag
endif
endforeach
@@ -240,7 +242,7 @@ executable('gtk4-demo',
c_args: gtkdemo_args + demo_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
@@ -250,7 +252,7 @@ executable('gtk4-demo-application',
c_args: gtkdemo_args + common_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
+8 -6
View File
@@ -47,22 +47,24 @@ static int
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
double width;
rsvg_handle_get_dimensions (self->handle, &data);
if (!rsvg_handle_get_intrinsic_size_in_pixels (self->handle, &width, NULL))
return 0;
return data.width;
return ceil (width);
}
static int
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
SvgPaintable *self = SVG_PAINTABLE (paintable);
RsvgDimensionData data;
double height;
rsvg_handle_get_dimensions (self->handle, &data);
if (!rsvg_handle_get_intrinsic_size_in_pixels (self->handle, NULL, &height))
return 0;
return data.height;
return ceil (height);
}
static void
+11 -5
View File
@@ -1,6 +1,11 @@
/* Text View/Tabs
*
* GtkTextView can position text at fixed positions, using tabs.
* Tabs can specify alignment, and also allow aligning numbers
* on the decimal point.
*
* The example here has three tabs, with left, numeric and right
* alignment.
*/
#include <gtk/gtk.h>
@@ -22,7 +27,7 @@ do_tabs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Tabs");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 330, 330);
gtk_window_set_default_size (GTK_WINDOW (window), 330, 130);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
@@ -35,17 +40,18 @@ do_tabs (GtkWidget *do_widget)
tabs = pango_tab_array_new (3, TRUE);
pango_tab_array_set_tab (tabs, 0, PANGO_TAB_LEFT, 0);
pango_tab_array_set_tab (tabs, 1, PANGO_TAB_LEFT, 100);
pango_tab_array_set_tab (tabs, 2, PANGO_TAB_LEFT, 200);
pango_tab_array_set_tab (tabs, 1, PANGO_TAB_DECIMAL, 150);
pango_tab_array_set_decimal_point (tabs, 1, '.');
pango_tab_array_set_tab (tabs, 2, PANGO_TAB_RIGHT, 290);
gtk_text_view_set_tabs (GTK_TEXT_VIEW (view), tabs);
pango_tab_array_free (tabs);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "one\ttwo\tthree\nfour\tfive\tsix\nseven\teight\tnine", -1);
gtk_text_buffer_set_text (buffer, "one\t2.0\tthree\nfour\t5.555\tsix\nseven\t88.88\tnine", -1);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_window_set_child (GTK_WINDOW (window), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view);
+1 -1
View File
@@ -72,7 +72,7 @@ about_activated (GSimpleAction *action,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
+1 -1
View File
@@ -16,7 +16,7 @@ executable('gtk4-icon-browser',
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
+1 -1
View File
@@ -3,7 +3,7 @@ demo_profile = get_option('profile')
demo_conf_h = declare_dependency(
sources: custom_target('demo-header',
command: [gen_demo_header, meson.source_root(), demo_profile],
command: [gen_demo_header, meson.project_source_root(), demo_profile],
capture: true,
output: 'demo_conf.h',
build_by_default: true,
+1 -1
View File
@@ -17,7 +17,7 @@ executable('gtk4-node-editor',
c_args: [
'-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())
] + common_cflags,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: false,
)
+1 -1
View File
@@ -79,7 +79,7 @@ activate_about (GSimpleAction *action,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
+37 -4
View File
@@ -336,12 +336,39 @@ text_view_query_tooltip_cb (GtkWidget *widget,
}
}
static gboolean
load_bytes (NodeEditorWindow *self,
GBytes *bytes);
static void
load_error (NodeEditorWindow *self,
const char *error_message)
{
PangoLayout *layout;
GtkSnapshot *snapshot;
GskRenderNode *node;
GBytes *bytes;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), error_message);
pango_layout_set_width (layout, 300 * PANGO_SCALE);
snapshot = gtk_snapshot_new ();
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA) { 0.7, 0.13, 0.13, 1.0 });
node = gtk_snapshot_free_to_node (snapshot);
bytes = gsk_render_node_serialize (node);
load_bytes (self, bytes);
gsk_render_node_unref (node);
g_object_unref (layout);
}
static gboolean
load_bytes (NodeEditorWindow *self,
GBytes *bytes)
{
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
{
load_error (self, "Invalid UTF-8");
g_bytes_unref (bytes);
return FALSE;
}
@@ -359,11 +386,16 @@ static gboolean
load_file_contents (NodeEditorWindow *self,
GFile *file)
{
GError *error = NULL;
GBytes *bytes;
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
bytes = g_file_load_bytes (file, NULL, NULL, &error);
if (bytes == NULL)
return FALSE;
{
load_error (self, error->message);
g_clear_error (&error);
return FALSE;
}
return load_bytes (self, bytes);
}
@@ -473,17 +505,18 @@ node_editor_window_load (NodeEditorWindow *self,
{
GError *error = NULL;
g_clear_object (&self->file_monitor);
if (!load_file_contents (self, file))
return FALSE;
g_clear_object (&self->file_monitor);
self->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
if (error)
{
g_warning ("couldn't monitor file: %s", error->message);
g_error_free (error);
g_clear_object (&self->file_monitor);
}
else
{
+5 -4
View File
@@ -161,9 +161,10 @@
</child>
<child>
<object class="GtkPaned">
<property name="shrink-start-child">false</property>
<property name="shrink-end-child">false</property>
<property name="position">400</property>
<child>
<property name="start-child">
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="hexpand">1</property>
@@ -184,8 +185,8 @@
</object>
</child>
</object>
</child>
<child>
</property>
<property name="end-child">
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
@@ -231,7 +232,7 @@
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</template>
+1 -1
View File
@@ -3,7 +3,7 @@ executable('gtk4-print-editor',
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
+17 -17
View File
@@ -42,7 +42,7 @@ update_statusbar (void)
const char *print_str;
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
gtk_text_buffer_get_iter_at_mark (buffer,
&iter,
gtk_text_buffer_get_insert (buffer));
@@ -56,7 +56,7 @@ update_statusbar (void)
GtkPrintOperation *op = active_prints->data;
print_str = gtk_print_operation_get_status_string (op);
}
msg = g_strdup_printf ("%d, %d%s %s",
row, col,
file_changed?" - Modified":"",
@@ -188,10 +188,10 @@ save_file (GFile *save_filename)
"Error saving to file %s:\n%s",
display_name,
error->message);
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (error_dialog);
g_error_free (error);
g_object_unref (info);
}
@@ -229,7 +229,7 @@ begin_print (GtkPrintOperation *operation,
pango_font_description_free (desc);
pango_layout_set_width (print_data->layout, width * PANGO_SCALE);
pango_layout_set_text (print_data->layout, print_data->text, -1);
num_lines = pango_layout_get_line_count (print_data->layout);
@@ -241,7 +241,7 @@ begin_print (GtkPrintOperation *operation,
{
PangoRectangle ink_rect, logical_rect;
double line_height;
layout_line = pango_layout_get_line (print_data->layout, line);
pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect);
@@ -258,7 +258,7 @@ begin_print (GtkPrintOperation *operation,
page_breaks = g_list_reverse (page_breaks);
gtk_print_operation_set_n_pages (operation, g_list_length (page_breaks) + 1);
print_data->page_breaks = page_breaks;
}
@@ -287,11 +287,11 @@ draw_page (GtkPrintOperation *operation,
end = pango_layout_get_line_count (print_data->layout);
else
end = GPOINTER_TO_INT (pagebreak->data);
cr = gtk_print_context_get_cairo_context (context);
cairo_set_source_rgb (cr, 0, 0, 0);
i = 0;
start_pos = 0;
iter = pango_layout_get_iter (print_data->layout);
@@ -307,12 +307,12 @@ draw_page (GtkPrintOperation *operation,
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
if (i == start)
start_pos = logical_rect.y / 1024.0;
cairo_move_to (cr, logical_rect.x / 1024.0, baseline / 1024.0 - start_pos);
pango_cairo_show_layout_line (cr, line);
}
i++;
@@ -383,9 +383,9 @@ print_done (GtkPrintOperation *op,
{
GtkWidget *error_dialog;
gtk_print_operation_get_error (op, &error);
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@@ -405,13 +405,13 @@ print_done (GtkPrintOperation *op,
g_free (print_data->text);
g_free (print_data->font);
g_free (print_data);
if (!gtk_print_operation_is_finished (op))
{
g_object_ref (op);
active_prints = g_list_append (active_prints, op);
update_statusbar ();
/* This ref is unref:ed when we get the final state change */
g_signal_connect (op, "status_changed",
G_CALLBACK (status_changed_cb), NULL);
@@ -628,7 +628,7 @@ activate_about (GSimpleAction *action,
glib_micro_version);
g_string_append_printf (sysinfo, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (sysinfo, "\tGTK\t%d.%d.%d\n",
g_string_append_printf (sysinfo, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
+1 -1
View File
@@ -74,7 +74,7 @@ executable('gtk4-widget-factory',
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
gui_app: true,
win_subsystem: 'windows',
link_args: extra_demo_ldflags,
install: true,
)
+20 -4
View File
@@ -78,6 +78,21 @@ change_theme_state (GSimpleAction *action,
NULL);
}
static void
change_fullscreen (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkWindow *window = user_data;
if (g_variant_get_boolean (state))
gtk_window_fullscreen (window);
else
gtk_window_unfullscreen (window);
g_simple_action_set_state (action, state);
}
static GtkWidget *page_stack;
static void
@@ -283,7 +298,7 @@ activate_about (GSimpleAction *action,
glib_micro_version);
g_string_append_printf (s, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
@@ -384,7 +399,7 @@ print_operation_done (GtkPrintOperation *op,
g_clear_error (&error);
break;
case GTK_PRINT_OPERATION_RESULT_APPLY:
break;
break;
case GTK_PRINT_OPERATION_RESULT_CANCEL:
g_print ("Printing was canceled\n");
break;
@@ -2012,11 +2027,12 @@ activate (GApplication *app)
GMenuModel *model;
static GActionEntry win_entries[] = {
{ "dark", NULL, NULL, "false", change_dark_state },
{ "theme", NULL, "s", "'current'", change_theme_state },
{ "theme", NULL, "s", "'current'", change_theme_state },
{ "transition", NULL, NULL, "true", change_transition_state },
{ "search", activate_search, NULL, NULL, NULL },
{ "delete", activate_delete, NULL, NULL, NULL },
{ "busy", get_busy, NULL, NULL, NULL },
{ "fullscreen", NULL, NULL, "false", change_fullscreen },
{ "background", activate_background, NULL, NULL, NULL },
{ "open", activate_open, NULL, NULL, NULL },
{ "record", activate_record, NULL, NULL, NULL },
@@ -2182,7 +2198,7 @@ activate (GApplication *app)
g_object_set_data (G_OBJECT (window), "searchbar", widget);
widget = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
g_signal_connect (widget, "response", G_CALLBACK (info_bar_response), NULL);
g_signal_connect (widget, "response", G_CALLBACK (info_bar_response), NULL);
g_object_set_data (G_OBJECT (window), "infobar", widget);
dialog = (GtkWidget *)gtk_builder_get_object (builder, "info_dialog");
+10
View File
@@ -6,6 +6,10 @@
<attribute name="label" translatable="yes">Get Busy</attribute>
<attribute name="action">win.busy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Fullscreen</attribute>
<attribute name="action">win.fullscreen</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Style</attribute>
<section>
@@ -1923,6 +1927,12 @@ microphone-sensitivity-medium-symbolic</property>
<property name="tooltip-text" translatable="1">Insert something</property>
</object>
</child>
<child>
<object class="GtkColorButton">
<property name="rgba">#9141AC</property>
<property name="tooltip-text" translatable="1">Select a color</property>
</object>
</child>
</object>
</child>
<child>
+1
View File
@@ -3,6 +3,7 @@ version = "@version@"
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
website_url = "https://www.gtk.org"
docs_url = "https://docs.gtk.org/gdk4/"
authors = "GTK Development Team"
logo_url = "gtk-logo.svg"
license = "LGPL-2.1-or-later"
+1
View File
@@ -3,6 +3,7 @@ version = "@version@"
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
website_url = "https://www.gtk.org"
docs_url = "https://docs.gtk.org/gsk4/"
authors = "GTK Development Team"
logo_url = "gtk-logo.svg"
license = "LGPL-2.1-or-later"
+1
View File
@@ -3,6 +3,7 @@ version = "@version@"
browse_url = "https://gitlab.gnome.org/GNOME/gtk/"
repository_url = "https://gitlab.gnome.org/GNOME/gtk.git"
website_url = "https://www.gtk.org"
docs_url = "https://docs.gtk.org/gtk4/"
authors = "GTK Development Team"
logo_url = "gtk-logo.svg"
license = "LGPL-2.1-or-later"
+11 -2
View File
@@ -410,8 +410,8 @@ have been removed. Update your code accordingly.
Any APIs that deal with global (or root) coordinates have been
removed in GTK 4, since not all backends support them. You should
replace your use of such APIs with surface-relative equivalents.
Examples of this are `gdk_surface_get_origin()`, `gdk_surface_move()`
or `gdk_event_get_root_coords()`.
Examples of such removed APIs are `gdk_window_get_origin()`,
`gdk_window_move()` or `gdk_event_get_root_coords()`.
### Adapt to `GdkKeymap` API changes
@@ -1276,6 +1276,15 @@ is provided in the form of a `GtkIconPaintable` (this can be checked with
[method@Gtk.IconPaintable.is_symbolic]), you have to call
[method@Gtk.IconPaintable.get_icon_name] and set the icon name on a `GtkImage`.
### Adapt to GtkImage changes
`GtkPicture`'s behaviour was "split out" of `GtkImage` as the latter was covering
too many use cases; if you're loading an icon, [class@Gtk.Image] in GTK3 and GTK4 are
perfectly equivalent. If you are loading a more complex image asset, like a picture
or a thumbnail, then [class@Gtk.Picture] is the appropriate widget.
One noteworthy distinction is that while `GtkImage` has its size computed by
GTK, `GtkPicture` lets you decide about the size.
### Update to GtkFileChooser API changes
`GtkFileChooser` moved to a GFile-based API. If you need to convert a path
+1 -4
View File
@@ -286,7 +286,7 @@ requires that GTK is compiled with support for that backend.
The following backends can be selected, provided they are
included in the GDK libraries you are using:
`quartz`
`macos`
: Selects the native Quartz backend
`win32`
@@ -336,9 +336,6 @@ using and the GDK backend supports them:
`gl`
: Selects the "gl" OpenGL renderer
`ngl`
: Selects the "ngl" OpenGL renderer
`vulkan`
: Selects the Vulkan renderer
+4 -4
View File
@@ -133,7 +133,7 @@ gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"textview {"
" font: 15 serif;"
" font: 15px serif;"
" color: green;"
"}",
-1);
@@ -149,9 +149,9 @@ gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 30);
tag = gtk_text_buffer_create_tag (buffer, "blue_foreground",
"foreground", "blue",
NULL);
gtk_text_buffer_get_iter_at_offset (buffer, &amp;start, 7);
gtk_text_buffer_get_iter_at_offset (buffer, &amp;end, 12);
gtk_text_buffer_apply_tag (buffer, tag, &amp;start, &amp;end);
gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
```
The `gtk4-demo` application that comes with
+2 -21
View File
@@ -49,7 +49,7 @@
typedef struct _Deserializer Deserializer;
struct _Deserializer
struct _Deserializer
{
const char * mime_type; /* interned */
GType type;
@@ -264,7 +264,7 @@ gdk_content_deserializer_get_priority (GdkContentDeserializer *deserializer)
*
* This is the `GCancellable` that was passed to [func@Gdk.content_deserialize_async].
*
* Returns: (transfer none): the cancellable for the current operation
* Returns: (transfer none) (nullable): the cancellable for the current operation
*/
GCancellable *
gdk_content_deserializer_get_cancellable (GdkContentDeserializer *deserializer)
@@ -934,25 +934,6 @@ init (void)
formats = gdk_pixbuf_get_formats ();
/* Make sure png comes first */
for (f = formats; f; f = f->next)
{
GdkPixbufFormat *fmt = f->data;
char *name;
name = gdk_pixbuf_format_get_name (fmt);
if (g_str_equal (name, "png"))
{
formats = g_slist_delete_link (formats, f);
formats = g_slist_prepend (formats, fmt);
g_free (name);
break;
}
g_free (name);
}
for (f = formats; f; f = f->next)
{
GdkPixbufFormat *fmt = f->data;
+26 -12
View File
@@ -718,19 +718,33 @@ gdk_content_formats_builder_to_formats (GdkContentFormatsBuilder *builder)
g_return_val_if_fail (builder != NULL, NULL);
gtypes = g_new (GType, builder->n_gtypes + 1);
i = builder->n_gtypes;
gtypes[i--] = G_TYPE_INVALID;
/* add backwards because most important type is last in the list */
for (l = builder->gtypes; l; l = l->next)
gtypes[i--] = GPOINTER_TO_SIZE (l->data);
if (builder->n_gtypes > 0)
{
gtypes = g_new (GType, builder->n_gtypes + 1);
i = builder->n_gtypes;
gtypes[i--] = G_TYPE_INVALID;
/* add backwards because most important type is last in the list */
for (l = builder->gtypes; l; l = l->next)
gtypes[i--] = GPOINTER_TO_SIZE (l->data);
}
else
{
gtypes = NULL;
}
mime_types = g_new (const char *, builder->n_mime_types + 1);
i = builder->n_mime_types;
mime_types[i--] = NULL;
/* add backwards because most important type is last in the list */
for (l = builder->mime_types; l; l = l->next)
mime_types[i--] = l->data;
if (builder->n_mime_types > 0)
{
mime_types = g_new (const char *, builder->n_mime_types + 1);
i = builder->n_mime_types;
mime_types[i--] = NULL;
/* add backwards because most important type is last in the list */
for (l = builder->mime_types; l; l = l->next)
mime_types[i--] = l->data;
}
else
{
mime_types = NULL;
}
result = gdk_content_formats_new_take (gtypes, builder->n_gtypes,
mime_types, builder->n_mime_types);
+1 -1
View File
@@ -342,7 +342,7 @@ gdk_content_provider_write_mime_type_finish (GdkContentProvider *provider,
/**
* gdk_content_provider_get_value:
* @provider: a `GdkContentProvider`
* @value: the `GValue` to fill
* @value: (out caller-allocates): the `GValue` to fill
* @error: a `GError` location to store the error occurring
*
* Gets the contents of @provider stored in @value.
+7 -26
View File
@@ -54,7 +54,7 @@
typedef struct _Serializer Serializer;
struct _Serializer
struct _Serializer
{
const char * mime_type; /* interned */
GType type;
@@ -270,7 +270,7 @@ gdk_content_serializer_get_priority (GdkContentSerializer *serializer)
*
* This is the `GCancellable` that was passed to [func@content_serialize_async].
*
* Returns: (transfer none): the cancellable for the current operation
* Returns: (transfer none) (nullable): the cancellable for the current operation
*/
GCancellable *
gdk_content_serializer_get_cancellable (GdkContentSerializer *serializer)
@@ -446,7 +446,7 @@ lookup_serializer (const char *mime_type,
serializer->type == type)
return serializer;
}
return NULL;
}
@@ -630,7 +630,7 @@ pixbuf_serializer (GdkContentSerializer *serializer)
const GValue *value;
GdkPixbuf *pixbuf;
const char *name;
name = gdk_content_serializer_get_user_data (serializer);
value = gdk_content_serializer_get_value (serializer);
@@ -651,7 +651,7 @@ pixbuf_serializer (GdkContentSerializer *serializer)
gdk_pixbuf_save_to_stream_async (pixbuf,
gdk_content_serializer_get_output_stream (serializer),
name,
gdk_content_serializer_get_cancellable (serializer),
gdk_content_serializer_get_cancellable (serializer),
pixbuf_serializer_finish,
serializer,
g_str_equal (name, "png") ? "compression" : NULL, "2",
@@ -823,7 +823,7 @@ file_uri_serializer (GdkContentSerializer *serializer)
else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST))
{
GSList *l;
for (l = g_value_get_boxed (value); l; l = l->next)
{
uri = g_file_get_uri (l->data);
@@ -867,7 +867,7 @@ file_text_serializer (GdkContentSerializer *serializer)
{
GString *str;
GSList *l;
str = g_string_new (NULL);
for (l = g_value_get_boxed (value); l; l = l->next)
@@ -966,25 +966,6 @@ init (void)
formats = gdk_pixbuf_get_formats ();
/* Make sure png comes first */
for (f = formats; f; f = f->next)
{
GdkPixbufFormat *fmt = f->data;
char *name;
name = gdk_pixbuf_format_get_name (fmt);
if (g_str_equal (name, "png"))
{
formats = g_slist_delete_link (formats, f);
formats = g_slist_prepend (formats, fmt);
g_free (name);
break;
}
g_free (name);
}
for (f = formats; f; f = f->next)
{
GdkPixbufFormat *fmt = f->data;
+1 -2
View File
@@ -47,8 +47,7 @@
* Cursors by themselves are not very interesting: they must be bound to a
* window for users to see them. This is done with [method@Gdk.Surface.set_cursor]
* or [method@Gdk.Surface.set_device_cursor]. Applications will typically
* use higher-level GTK functions such as [method@Gtk.Widget.set_cursor]`
* instead.
* use higher-level GTK functions such as [method@Gtk.Widget.set_cursor] instead.
*
* Cursors are not bound to a given [class@Gdk.Display], so they can be shared.
* However, the appearance of cursors may vary when used on different
+4
View File
@@ -132,6 +132,8 @@ gdk_device_class_init (GdkDeviceClass *klass)
* GdkDevice:source: (attributes org.gtk.Property.get=gdk_device_get_source)
*
* Source type for the device.
*
* Deprecated: 4.6: Use GdkDeviceTool:tool-type instead
*/
device_props[PROP_SOURCE] =
g_param_spec_enum ("source",
@@ -596,6 +598,8 @@ gdk_device_get_has_cursor (GdkDevice *device)
* Determines the type of the device.
*
* Returns: a `GdkInputSource`
*
* Deprecated: 4.6: Use gdk_device_tool_get_tool_type() instead
*/
GdkInputSource
gdk_device_get_source (GdkDevice *device)
+1 -1
View File
@@ -92,7 +92,7 @@ GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_device_get_display (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkSeat * gdk_device_get_seat (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_6_FOR(gdk_device_tool_get_tool_type)
GdkDeviceTool * gdk_device_get_device_tool (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
+29 -25
View File
@@ -1438,31 +1438,6 @@ describe_egl_config (EGLDisplay egl_display,
}
#endif
/*<private>
* gdk_display_get_egl_display:
* @self: a display
*
* Retrieves the EGL display connection object for the given GDK display.
*
* This function returns `NULL` if GL is not supported or GDK is using
* a different OpenGL framework than EGL.
*
* Returns: (nullable): the EGL display object
*/
gpointer
gdk_display_get_egl_display (GdkDisplay *self)
{
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
g_return_val_if_fail (GDK_IS_DISPLAY (self), NULL);
if (!priv->egl_display &&
!gdk_display_prepare_gl (self, NULL))
return NULL;
return priv->egl_display;
}
gpointer
gdk_display_get_egl_config (GdkDisplay *self)
{
@@ -1789,6 +1764,35 @@ gdk_display_init_egl (GdkDisplay *self,
}
#endif
/*<private>
* gdk_display_get_egl_display:
* @self: a display
*
* Retrieves the EGL display connection object for the given GDK display.
*
* This function returns `NULL` if GL is not supported or GDK is using
* a different OpenGL framework than EGL.
*
* Returns: (nullable): the EGL display object
*/
gpointer
gdk_display_get_egl_display (GdkDisplay *self)
{
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;
return priv->egl_display;
#else
return NULL;
#endif
}
GdkDebugFlags
gdk_display_get_debug_flags (GdkDisplay *display)
{
+135 -62
View File
@@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
@@ -522,7 +522,9 @@ _gdk_event_queue_find_first (GdkDisplay *display)
if (pending_motion)
return pending_motion;
if (event->event_type == GDK_MOTION_NOTIFY && (event->flags & GDK_EVENT_FLUSHED) == 0)
if ((event->event_type == GDK_MOTION_NOTIFY ||
(event->event_type == GDK_SCROLL && gdk_scroll_event_get_direction (event) == GDK_SCROLL_SMOOTH)) &&
(event->flags & GDK_EVENT_FLUSHED) == 0)
pending_motion = tmp_list;
else
return tmp_list;
@@ -596,6 +598,9 @@ _gdk_event_unqueue (GdkDisplay *display)
/*
* If the last N events in the event queue are smooth scroll events
* for the same surface and device, combine them into one.
*
* We give the remaining event a history with N items, and deltas
* that are the sum over the history entries.
*/
void
gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
@@ -605,7 +610,6 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
GdkDevice *device = NULL;
GdkEvent *last_event = NULL;
GList *scrolls = NULL;
double delta_x, delta_y;
GArray *history = NULL;
GdkTimeCoord hist;
@@ -640,35 +644,42 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
l = l->prev;
}
delta_x = delta_y = 0;
while (scrolls && scrolls->next != NULL)
{
GdkEvent *event = scrolls->data;
GList *next = scrolls->next;
double dx, dy;
gboolean inherited = FALSE;
if (!history && ((GdkScrollEvent *)event)->history)
{
history = ((GdkScrollEvent *)event)->history;
((GdkScrollEvent *)event)->history = NULL;
inherited = TRUE;
}
if (!history)
history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
gdk_scroll_event_get_deltas (event, &dx, &dy);
delta_x += dx;
delta_y += dy;
if (!inherited)
{
gdk_scroll_event_get_deltas (event, &dx, &dy);
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (event);
hist.flags = GDK_AXIS_FLAG_DELTA_X | GDK_AXIS_FLAG_DELTA_Y;
hist.axes[GDK_AXIS_DELTA_X] = dx;
hist.axes[GDK_AXIS_DELTA_Y] = dy;
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (event);
hist.flags = GDK_AXIS_FLAG_DELTA_X | GDK_AXIS_FLAG_DELTA_Y;
hist.axes[GDK_AXIS_DELTA_X] = dx;
hist.axes[GDK_AXIS_DELTA_Y] = dy;
g_array_append_val (history, hist);
g_array_append_val (history, hist);
}
gdk_event_unref (event);
g_queue_delete_link (&display->queued_events, scrolls);
scrolls = next;
}
if (scrolls)
if (scrolls && history)
{
GdkEvent *old_event, *event;
double dx, dy;
@@ -676,13 +687,29 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
old_event = scrolls->data;
gdk_scroll_event_get_deltas (old_event, &dx, &dy);
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (old_event);
hist.flags = GDK_AXIS_FLAG_DELTA_X | GDK_AXIS_FLAG_DELTA_Y;
hist.axes[GDK_AXIS_DELTA_X] = dx;
hist.axes[GDK_AXIS_DELTA_Y] = dy;
g_array_append_val (history, hist);
dx = dy = 0;
for (int i = 0; i < history->len; i++)
{
GdkTimeCoord *val = &g_array_index (history, GdkTimeCoord, i);
dx += val->axes[GDK_AXIS_DELTA_X];
dy += val->axes[GDK_AXIS_DELTA_Y];
}
event = gdk_scroll_event_new (surface,
device,
gdk_event_get_device_tool (old_event),
gdk_event_get_time (old_event),
gdk_event_get_modifier_state (old_event),
delta_x + dx,
delta_y + dy,
dx,
dy,
gdk_scroll_event_is_stop (old_event));
((GdkScrollEvent *)event)->history = history;
@@ -714,24 +741,41 @@ gdk_motion_event_push_history (GdkEvent *event,
g_assert (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY));
g_assert (GDK_IS_EVENT_TYPE (history_event, GDK_MOTION_NOTIFY));
if (!self->tool)
return;
if (G_UNLIKELY (!self->history))
self->history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
if (((GdkMotionEvent *)history_event)->history)
{
GArray *history = ((GdkMotionEvent *)history_event)->history;
g_array_append_vals (self->history, history->data, history->len);
}
tool = gdk_event_get_device_tool (history_event);
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (history_event);
hist.flags = gdk_device_tool_get_axes (tool);
for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
gdk_event_get_axis (history_event, i, &hist.axes[i]);
if (G_UNLIKELY (!self->history))
self->history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
if (tool)
{
hist.flags = gdk_device_tool_get_axes (tool);
for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
gdk_event_get_axis (history_event, i, &hist.axes[i]);
}
else
{
hist.flags = GDK_AXIS_FLAG_X | GDK_AXIS_FLAG_Y;
gdk_event_get_position (history_event, &hist.axes[GDK_AXIS_X], &hist.axes[GDK_AXIS_Y]);
}
g_array_append_val (self->history, hist);
}
/* If the last N events in the event queue are motion notify
* events for the same surface, drop all but the last.
*
* If a button is held down or the device has a tool, then
* we give the remaining events a history containing the N-1
* dropped events.
*/
void
_gdk_event_queue_handle_motion_compression (GdkDisplay *display)
{
@@ -741,9 +785,6 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
GdkDevice *pending_motion_device = NULL;
GdkEvent *last_motion = NULL;
/* If the last N events in the event queue are motion notify
* events for the same surface, drop all but the last */
tmp_list = g_queue_peek_tail_link (&display->queued_events);
while (tmp_list)
@@ -780,12 +821,11 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
if (last_motion != NULL)
{
GdkModifierType state = gdk_event_get_modifier_state (last_motion);
if (state &
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
GDK_BUTTON4_MASK | GDK_BUTTON5_MASK))
gdk_motion_event_push_history (last_motion, pending_motions->data);
if ((gdk_event_get_modifier_state (last_motion) &
(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)) ||
gdk_event_get_device_tool (last_motion) != NULL)
gdk_motion_event_push_history (last_motion, pending_motions->data);
}
gdk_event_unref (pending_motions->data);
@@ -903,6 +943,9 @@ gdk_event_get_pointer_emulated (GdkEvent *event)
* Extract the axis value for a particular axis use from
* an event structure.
*
* To find out which axes are used, use [method@Gdk.DeviceTool.get_axes]
* on the device tool returned by [method@Gdk.Event.get_device_tool].
*
* Returns: %TRUE if the specified axis was found, otherwise %FALSE
*/
gboolean
@@ -1129,6 +1172,9 @@ G_DEFINE_BOXED_TYPE (GdkEventSequence, gdk_event_sequence,
*
* Extracts all axis values from an event.
*
* To find out which axes are used, use [method@Gdk.DeviceTool.get_axes]
* on the device tool returned by [method@Gdk.Event.get_device_tool].
*
* Returns: %TRUE on success, otherwise %FALSE
*/
gboolean
@@ -1179,7 +1225,7 @@ gdk_event_get_event_type (GdkEvent *event)
*
* Extracts the surface associated with an event.
*
* Returns: (transfer none): The `GdkSurface` associated with the event
* Returns: (transfer none) (nullable): The `GdkSurface` associated with the event
*/
GdkSurface *
gdk_event_get_surface (GdkEvent *event)
@@ -2431,6 +2477,14 @@ gdk_touchpad_event_get_state (GdkEvent *event)
return self->state;
}
static GdkEventSequence *
gdk_touchpad_event_get_sequence (GdkEvent *event)
{
GdkTouchpadEvent *self = (GdkTouchpadEvent *) event;
return self->sequence;
}
static gboolean
gdk_touchpad_event_get_position (GdkEvent *event,
double *x,
@@ -2450,7 +2504,7 @@ static const GdkEventTypeInfo gdk_touchpad_event_info = {
NULL,
gdk_touchpad_event_get_state,
gdk_touchpad_event_get_position,
NULL,
gdk_touchpad_event_get_sequence,
NULL,
NULL,
};
@@ -2461,19 +2515,28 @@ GDK_DEFINE_EVENT_TYPE (GdkTouchpadEvent, gdk_touchpad_event,
GDK_EVENT_TYPE_SLOT (GDK_TOUCHPAD_PINCH))
GdkEvent *
gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers,
double dx,
double dy)
gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers,
double dx,
double dy)
{
GdkTouchpadEvent *self = gdk_event_alloc (GDK_TOUCHPAD_SWIPE, surface, device, time);
GdkTouchpadEvent *self;
g_return_val_if_fail (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_END ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL, NULL);
self = gdk_event_alloc (GDK_TOUCHPAD_SWIPE, surface, device, time);
self->sequence = sequence;
self->state = state;
self->phase = phase;
self->x = x;
@@ -2486,21 +2549,30 @@ gdk_touchpad_event_new_swipe (GdkSurface *surface,
}
GdkEvent *
gdk_touchpad_event_new_pinch (GdkSurface *surface,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers,
double dx,
double dy,
double scale,
double angle_delta)
gdk_touchpad_event_new_pinch (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers,
double dx,
double dy,
double scale,
double angle_delta)
{
GdkTouchpadEvent *self = gdk_event_alloc (GDK_TOUCHPAD_PINCH, surface, device, time);
GdkTouchpadEvent *self;
g_return_val_if_fail (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_END ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL, NULL);
self = gdk_event_alloc (GDK_TOUCHPAD_PINCH, surface, device, time);
self->sequence = sequence;
self->state = state;
self->phase = phase;
self->x = x;
@@ -2907,7 +2979,8 @@ gdk_motion_event_new (GdkSurface *surface,
* to the application because they occurred in the same frame as @event.
*
* Note that only motion and scroll events record history, and motion
* events do it only if one of the mouse buttons is down.
* events do it only if one of the mouse buttons is down, or the device
* has a tool.
*
* Returns: (transfer container) (array length=out_n_coords) (nullable): an
* array of time and coordinates
+14 -11
View File
@@ -209,7 +209,7 @@ struct _GdkTouchEvent
* @pointer_emulated: whether the scroll event was the result of
* a pointer emulation
* @tool: a `GdkDeviceTool`
* @history: (element-type GdkScrollHistory): array of times and deltas
* @history: (element-type GdkTimeCoord): array of times and deltas
* for other scroll events that were compressed before delivering the
* current event
*
@@ -233,7 +233,7 @@ struct _GdkScrollEvent
gboolean pointer_emulated;
gboolean is_stop;
GdkDeviceTool *tool;
GArray *history; /* <GdkScrollHistory> */
GArray *history; /* <GdkTimeCoord> */
};
/*
@@ -402,6 +402,7 @@ struct _GdkTouchpadEvent
{
GdkEvent parent_instance;
GdkEventSequence *sequence;
GdkModifierType state;
gint8 phase;
gint8 n_fingers;
@@ -506,18 +507,20 @@ GdkEvent * gdk_touch_event_new (GdkEventType type,
double *axes,
gboolean emulating);
GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkEvent * gdk_touchpad_event_new_swipe (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers,
double dx,
double dy);
double x,
double y,
int n_fingers,
double dx,
double dy);
GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
GdkEventSequence *sequence,
GdkDevice *device,
guint32 time,
GdkModifierType state,
+70 -13
View File
@@ -151,6 +151,12 @@ unmask_context (MaskedContext *mask)
return GDK_GL_CONTEXT (GSIZE_TO_POINTER (GPOINTER_TO_SIZE (mask) & ~(gsize) 1));
}
static inline gboolean
mask_is_surfaceless (MaskedContext *mask)
{
return GPOINTER_TO_SIZE (mask) & (gsize) 1;
}
static void
unref_unmasked (gpointer data)
{
@@ -179,8 +185,7 @@ gdk_gl_context_dispose (GObject *gobject)
if (priv->egl_context != NULL)
{
GdkSurface *surface = gdk_gl_context_get_surface (context);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
EGLDisplay *egl_display = gdk_display_get_egl_display (display);
if (eglGetCurrentContext () == priv->egl_context)
@@ -574,8 +579,8 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
glViewport (0, 0, ww, wh);
#ifdef HAVE_EGL
if (priv->egl_context)
glDrawBuffers (1, (GLenum[1]) { GL_BACK_LEFT });
if (priv->egl_context && gdk_gl_context_check_version (context, 0, 0, 3, 0))
glDrawBuffers (1, (GLenum[1]) { gdk_gl_context_get_use_es (context) ? GL_BACK : GL_BACK_LEFT });
#endif
}
@@ -997,16 +1002,33 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
}
gboolean
gdk_gl_context_check_version (GdkGLContext *context,
int required_major,
int required_minor)
gdk_gl_context_check_version (GdkGLContext *self,
int required_gl_major,
int required_gl_minor,
int required_gles_major,
int required_gles_minor)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
g_return_val_if_fail (required_minor < 10, FALSE);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
g_return_val_if_fail (required_gl_minor < 10, FALSE);
g_return_val_if_fail (required_gles_minor < 10, FALSE);
return priv->gl_version >= required_major * 10 + required_minor;
if (!gdk_gl_context_is_realized (self))
return FALSE;
switch (priv->api)
{
case GDK_GL_API_GL:
return priv->gl_version >= required_gl_major * 10 + required_gl_minor;
case GDK_GL_API_GLES:
return priv->gl_version >= required_gles_major * 10 + required_gles_minor;
default:
g_return_val_if_reached (FALSE);
}
}
/**
@@ -1323,6 +1345,7 @@ gl_debug_message_callback (GLenum source,
const char *message_source;
const char *message_type;
const char *message_severity;
GLogLevelFlags log_level;
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
return;
@@ -1384,22 +1407,31 @@ gl_debug_message_callback (GLenum source,
{
case GL_DEBUG_SEVERITY_HIGH:
message_severity = "High";
log_level = G_LOG_LEVEL_CRITICAL;
break;
case GL_DEBUG_SEVERITY_MEDIUM:
message_severity = "Medium";
log_level = G_LOG_LEVEL_WARNING;
break;
case GL_DEBUG_SEVERITY_LOW:
message_severity = "Low";
log_level = G_LOG_LEVEL_MESSAGE;
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
message_severity = "Notification";
log_level = G_LOG_LEVEL_INFO;
break;
default:
message_severity = "Unknown";
log_level = G_LOG_LEVEL_MESSAGE;
}
g_warning ("OPENGL:\n Source: %s\n Type: %s\n Severity: %s\n Message: %s",
message_source, message_type, message_severity, message);
/* There's no higher level function taking a log level argument... */
g_log_structured_standard (G_LOG_DOMAIN, log_level,
__FILE__, G_STRINGIFY (__LINE__),
G_STRFUNC,
"OPENGL:\n Source: %s\n Type: %s\n Severity: %s\n Message: %s",
message_source, message_type, message_severity, message);
}
/**
@@ -1655,6 +1687,31 @@ gdk_gl_context_clear_current (void)
}
}
/*<private>
* gdk_gl_context_clear_current_if_surface:
* @surface: surface to clear for
*
* Does a gdk_gl_context_clear_current() if the current context is attached
* to @surface, leaves the current context alone otherwise.
**/
void
gdk_gl_context_clear_current_if_surface (GdkSurface *surface)
{
MaskedContext *current;
current = g_private_get (&thread_current_context);
if (current != NULL && !mask_is_surfaceless (current))
{
GdkGLContext *context = unmask_context (current);
if (gdk_gl_context_get_surface (context) != surface)
return;
if (GDK_GL_CONTEXT_GET_CLASS (context)->clear_current (context))
g_private_replace (&thread_current_context, NULL);
}
}
/**
* gdk_gl_context_get_current:
*
+6 -2
View File
@@ -99,6 +99,8 @@ gboolean gdk_gl_backend_can_be_used (GdkGLBackend
GError **error);
void gdk_gl_backend_use (GdkGLBackend backend_type);
void gdk_gl_context_clear_current_if_surface (GdkSurface *surface);
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface);
@@ -109,8 +111,10 @@ void gdk_gl_context_set_is_legacy (GdkGLContext
gboolean is_legacy);
gboolean gdk_gl_context_check_version (GdkGLContext *context,
int required_major,
int required_minor);
int required_gl_major,
int required_gl_minor,
int required_gles_major,
int required_gles_minor);
gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context);
void gdk_gl_context_push_debug_group (GdkGLContext *context,
+7 -3
View File
@@ -21,6 +21,7 @@
#include "gdkgltextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
@@ -305,9 +306,11 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
GLint active_texture;
GLint internal_format;
if (self->context != gdk_gl_context_get_current ())
/* Abort if somebody else is GL-ing here... */
if (self->context != gdk_gl_context_get_current () ||
/* ... or glGetTexLevelParameter() isn't supported */
!gdk_gl_context_check_version (self->context, 0, 0, 3, 1))
{
/* Somebody else is GL-ing here, abort! */
texture->format = GDK_MEMORY_DEFAULT;
return;
}
@@ -380,7 +383,8 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
* which will happen when the GdkTexture object is finalized, or due to
* an explicit call of [method@Gdk.GLTexture.release].
*
* Return value: (transfer full): A newly-created `GdkTexture`
* Return value: (transfer full) (type GdkGLTexture): A newly-created
* `GdkTexture`
*/
GdkTexture *
gdk_gl_texture_new (GdkGLContext *context,
+1
View File
@@ -2,3 +2,4 @@ BOOLEAN:BOXED
BOOLEAN:OBJECT
BOOLEAN:POINTER
VOID:POINTER,POINTER,BOOLEAN,BOOLEAN
VOID:INT,INT
+2 -2
View File
@@ -133,10 +133,10 @@ gdk_memory_sanitize (GBytes *bytes,
*
* Creates a new texture for a blob of image data.
*
* The `GBytes` must contain @stride x @height pixels
* The `GBytes` must contain @stride × @height pixels
* in the given format.
*
* Returns: A newly-created `GdkTexture`
* Returns: (type GdkMemoryTexture): A newly-created `GdkTexture`
*/
GdkTexture *
gdk_memory_texture_new (int width,
+1 -1
View File
@@ -187,7 +187,7 @@ gdk_popup_get_rect_anchor (GdkPopup *popup)
*
* Returns the parent surface of a popup.
*
* Returns: (transfer none): the parent surface
* Returns: (transfer none) (nullable): the parent surface
*/
GdkSurface *
gdk_popup_get_parent (GdkPopup *popup)
+6 -1
View File
@@ -605,11 +605,14 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
0,
NULL,
NULL,
NULL,
_gdk_marshal_VOID__INT_INT,
G_TYPE_NONE,
2,
G_TYPE_INT,
G_TYPE_INT);
g_signal_set_va_marshaller (signals[LAYOUT],
G_OBJECT_CLASS_TYPE (object_class),
_gdk_marshal_VOID__INT_INTv);
/**
* GdkSurface::render:
@@ -1092,6 +1095,7 @@ gdk_surface_set_egl_native_window (GdkSurface *self,
if (priv->egl_surface != NULL)
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
priv->egl_surface = NULL;
}
@@ -1120,6 +1124,7 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
priv->egl_surface = NULL;
}
+11 -54
View File
@@ -25,15 +25,14 @@
* multiple frames, and will be used for a long time.
*
* There are various ways to create `GdkTexture` objects from a
* `GdkPixbuf`, or a Cairo surface, or other pixel data.
* [class@GdkPixbuf.Pixbuf], or a Cairo surface, or other pixel data.
*
* The ownership of the pixel data is transferred to the `GdkTexture`
* instance; you can only make a copy of it, via [method@Gdk.Texture.download]
* or [method@Gdk.Texture.download_float].
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
*
* `GdkTexture` is an immutable object: That means you cannot change
* anything about it other than increasing the reference count via
* g_object_ref().
* [method@GObject.Object.ref], and consequently, it is a thread-safe object.
*/
#include "config.h"
@@ -347,7 +346,7 @@ gdk_texture_init (GdkTexture *self)
*
* Creates a new texture object representing the surface.
*
* @surface must be an image surface with format CAIRO_FORMAT_ARGB32.
* @surface must be an image surface with format `CAIRO_FORMAT_ARGB32`.
*
* Returns: a new `GdkTexture`
*/
@@ -385,7 +384,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
* Creates a new texture object representing the `GdkPixbuf`.
*
* This function is threadsafe, so that you can e.g. use GTask
* and g_task_run_in_thread() to avoid blocking the main thread
* and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
* while loading a big image.
*
* Returns: a new `GdkTexture`
@@ -431,7 +430,7 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
* [ctor@Gdk.Texture.new_from_file] to load it.
*
* This function is threadsafe, so that you can e.g. use GTask
* and g_task_run_in_thread() to avoid blocking the main thread
* and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
* while loading a big image.
*
* Return value: A newly-created `GdkTexture`
@@ -455,7 +454,7 @@ gdk_texture_new_from_resource (const char *resource_path)
texture = NULL;
if (texture == NULL)
g_error ("Resource path %s s not a valid image: %s", resource_path, error->message);
g_error ("Resource path %s is not a valid image: %s", resource_path, error->message);
return texture;
}
@@ -473,7 +472,7 @@ gdk_texture_new_from_resource (const char *resource_path)
* If %NULL is returned, then @error will be set.
*
* This function is threadsafe, so that you can e.g. use GTask
* and g_task_run_in_thread() to avoid blocking the main thread
* and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
* while loading a big image.
*
* Return value: A newly-created `GdkTexture`
@@ -566,7 +565,7 @@ gdk_texture_new_from_bytes_pixbuf (GBytes *bytes,
* If %NULL is returned, then @error will be set.
*
* This function is threadsafe, so that you can e.g. use GTask
* and g_task_run_in_thread() to avoid blocking the main thread
* and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
* while loading a big image.
*
* Return value: A newly-created `GdkTexture`
@@ -612,7 +611,7 @@ gdk_texture_new_from_bytes (GBytes *bytes,
* If %NULL is returned, then @error will be set.
*
* This function is threadsafe, so that you can e.g. use GTask
* and g_task_run_in_thread() to avoid blocking the main thread
* and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
* while loading a big image.
*
* Return value: A newly-created `GdkTexture`
@@ -743,48 +742,6 @@ gdk_texture_download (GdkTexture *texture,
stride);
}
/**
* gdk_texture_download_float:
* @texture: a `GdkTexture`
* @data: (array): pointer to enough memory to be filled with the
* downloaded data of @texture
* @stride: rowstride in elements, will usually be equal to
* gdk_texture_get_width() * 4
*
* Downloads the @texture into local memory in a high dynamic range format.
*
* This may be an expensive operation, as the actual texture data
* may reside on a GPU or on a remote display server and because the data
* may need to be upsampled if it was not already available in this
* format.
*
* You may want to use [method@Gdk.Texture.download] instead if you don't
* need high dynamic range support.
*
* The data format of the downloaded data is equivalent to
* GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, so every downloaded
* pixel requires 16 bytes of memory.
*
* Note that the caller is responsible to provide sufficiently
* aligned memory to access the resulting data directly as floats.
*
* Since: 4.6
*/
void
gdk_texture_download_float (GdkTexture *texture,
float *data,
gsize stride)
{
g_return_if_fail (GDK_IS_TEXTURE (texture));
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (texture) * 4);
gdk_texture_do_download (texture,
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
(guchar *) data,
stride);
}
GdkMemoryFormat
gdk_texture_get_format (GdkTexture *self)
{
@@ -839,7 +796,7 @@ gdk_texture_get_render_data (GdkTexture *self,
*
* This is a utility function intended for debugging and testing.
* If you want more control over formats, proper error handling or
* want to store to a `GFile` or other location, you might want to
* want to store to a [iface@Gio.File] or other location, you might want to
* use [method@Gdk.Texture.save_to_png_bytes] or look into the
* gdk-pixbuf library.
*
-4
View File
@@ -89,10 +89,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
guchar *data,
gsize stride);
GDK_AVAILABLE_IN_4_6
void gdk_texture_download_float (GdkTexture *texture,
float *data,
gsize stride);
GDK_AVAILABLE_IN_ALL
gboolean gdk_texture_save_to_png (GdkTexture *texture,
const char *filename);
+7
View File
@@ -727,6 +727,13 @@ gdk_toplevel_begin_move (GdkToplevel *toplevel,
timestamp);
}
/**
* gdk_toplevel_titlebar_gesture:
* @toplevel: a `GdkToplevel`
* @gesture: a `GdkTitlebarGesture`
*
* Since: 4.4
*/
gboolean
gdk_toplevel_titlebar_gesture (GdkToplevel *toplevel,
GdkTitlebarGesture gesture)
+8
View File
@@ -115,6 +115,14 @@ typedef enum
GDK_TOPLEVEL_STATE_LEFT_RESIZABLE = 1 << 15
} GdkToplevelState;
/**
* GdkTitlebarGesture:
* @GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
* @GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
* @GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
*
* Since: 4.4
*/
typedef enum
{
GDK_TITLEBAR_GESTURE_DOUBLE_CLICK = 1,
-16
View File
@@ -222,11 +222,7 @@ gdk_load_png (GBytes *bytes,
case PNG_COLOR_TYPE_RGB_ALPHA:
if (depth == 8)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GDK_MEMORY_R8G8B8A8;
#elif G_BYTE_ORDER == G_BIG_ENDIAN
format = GDK_MEMORY_A8B8G8R8;
#endif
}
else
{
@@ -236,11 +232,7 @@ gdk_load_png (GBytes *bytes,
case PNG_COLOR_TYPE_RGB:
if (depth == 8)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GDK_MEMORY_R8G8B8;
#elif G_BYTE_ORDER == G_BIG_ENDIAN
format = GDK_MEMORY_B8G8R8;
#endif
}
else if (depth == 16)
{
@@ -325,22 +317,14 @@ gdk_save_png (GdkTexture *texture)
case GDK_MEMORY_A8R8G8B8:
case GDK_MEMORY_R8G8B8A8:
case GDK_MEMORY_A8B8G8R8:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GDK_MEMORY_R8G8B8A8;
#elif G_BYTE_ORDER == G_BIG_ENDIAN
format = GDK_MEMORY_A8B8G8R8;
#endif
png_format = PNG_COLOR_TYPE_RGB_ALPHA;
depth = 8;
break;
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GDK_MEMORY_R8G8B8;
#elif G_BYTE_ORDER == G_BIG_ENDIAN
format = GDK_MEMORY_B8G8R8;
#endif
png_format = PNG_COLOR_TYPE_RGB;
depth = 8;
break;
+8 -1
View File
@@ -240,7 +240,7 @@ static const FormatData format_data[] = {
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
@@ -376,6 +376,13 @@ gdk_load_tiff (GBytes *input_bytes,
G_GNUC_UNUSED gint64 before = GDK_PROFILER_CURRENT_TIME;
tif = tiff_open_read (input_bytes);
if (!tif)
{
g_set_error_literal (error,
GDK_TEXTURE_ERROR, GDK_TEXTURE_ERROR_CORRUPT_IMAGE,
_("Could not load TIFF data"));
return NULL;
}
TIFFSetDirectory (tif, 0);
+1
View File
@@ -537,6 +537,7 @@ fill_pinch_event (GdkMacosDisplay *display,
seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
return gdk_touchpad_event_new_pinch (GDK_SURFACE (surface),
NULL, /* FIXME make up sequences */
gdk_seat_get_pointer (seat),
get_time_from_ns_event (nsevent),
get_keyboard_modifiers_from_ns_event (nsevent),
+18 -6
View File
@@ -137,6 +137,7 @@ struct _GdkWaylandPointerData {
guint cursor_timeout_id;
guint cursor_image_index;
guint cursor_image_delay;
guint touchpad_event_sequence;
guint current_output_scale;
GSList *pointer_surface_outputs;
@@ -1127,7 +1128,7 @@ data_offer_source_actions (void *data,
seat->pending_source_actions = gdk_wayland_actions_to_gdk_actions (source_actions);
return;
}
if (seat->drop == NULL)
return;
@@ -1152,7 +1153,7 @@ data_offer_action (void *data,
seat->pending_action = gdk_wayland_actions_to_gdk_actions (action);
return;
}
if (seat->drop == NULL)
return;
@@ -2164,7 +2165,7 @@ deliver_key_event (GdkWaylandSeat *seat,
key,
device_get_modifiers (seat->logical_pointer),
_gdk_wayland_keymap_key_is_modifier (keymap, key),
&translated,
&translated,
&no_lock);
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2667,7 +2668,11 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
seat->pointer_info.time = _time;
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
seat->pointer_info.touchpad_event_sequence++;
event = gdk_touchpad_event_new_swipe (seat->pointer_info.focus,
GDK_SLOT_TO_EVENT_SEQUENCE (seat->pointer_info.touchpad_event_sequence),
seat->logical_pointer,
_time,
device_get_modifiers (seat->logical_pointer),
@@ -2763,7 +2768,11 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
seat->pointer_info.time = _time;
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
seat->pointer_info.touchpad_event_sequence++;
event = gdk_touchpad_event_new_pinch (seat->pointer_info.focus,
GDK_SLOT_TO_EVENT_SEQUENCE (seat->pointer_info.touchpad_event_sequence),
seat->logical_pointer,
_time,
device_get_modifiers (seat->logical_pointer),
@@ -3606,6 +3615,10 @@ tablet_tool_handle_proximity_out (void *data,
g_object_unref (tablet->pointer_info.focus);
tablet->pointer_info.focus = NULL;
tablet->pointer_info.button_modifiers &=
~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK |
GDK_BUTTON4_MASK | GDK_BUTTON5_MASK);
gdk_device_update_tool (tablet->stylus_device, NULL);
g_clear_object (&tablet->pointer_info.cursor);
}
@@ -3621,7 +3634,6 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
GdkEventType evtype,
guint button)
{
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkEvent *event;
event = gdk_button_event_new (evtype,
@@ -3629,7 +3641,7 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
tablet->logical_device,
tablet->current_tool->tool,
tablet->pointer_info.time,
device_get_modifiers (seat->logical_pointer),
device_get_modifiers (tablet->logical_device),
button,
tablet->pointer_info.surface_x,
tablet->pointer_info.surface_y,
@@ -4085,7 +4097,7 @@ tablet_pad_strip_handle_frame (void *data,
event = gdk_pad_event_new_strip (seat->keyboard_focus,
pad->device,
time,
g_list_index (pad->mode_groups, group),
g_list_index (pad->mode_groups, group),
g_list_index (pad->strips, wp_tablet_pad_strip),
group->current_mode,
group->axis_tmp_info.value);
+43
View File
@@ -1662,6 +1662,7 @@ static TranslationEntry translations[] = {
{ FALSE, "org.gnome.desktop.wm.preferences", "action-middle-click-titlebar", "gtk-titlebar-middle-click", G_TYPE_STRING, { .s = "none" } },
{ FALSE, "org.gnome.desktop.wm.preferences", "action-right-click-titlebar", "gtk-titlebar-right-click", G_TYPE_STRING, { .s = "menu" } },
{ FALSE, "org.gnome.desktop.a11y", "always-show-text-caret", "gtk-keynav-use-caret", G_TYPE_BOOLEAN, { .b = FALSE } },
{ FALSE, "org.gnome.desktop.a11y.interface", "high-contrast", "high-contast", G_TYPE_NONE, { .b = FALSE } },
/* Note, this setting doesn't exist, the portal and gsd fake it */
{ FALSE, "org.gnome.fontconfig", "serial", "gtk-fontconfig-timestamp", G_TYPE_NONE, { .i = 0 } },
};
@@ -1711,6 +1712,13 @@ find_translation_entry_by_setting (const char *setting)
return NULL;
}
static void
high_contrast_changed (GdkDisplay *display)
{
gdk_display_setting_changed (display, "gtk-theme-name");
gdk_display_setting_changed (display, "gtk-icon-theme-name");
}
static void
settings_changed (GSettings *settings,
const char *key,
@@ -1724,6 +1732,8 @@ settings_changed (GSettings *settings,
{
if (entry->type != G_TYPE_NONE)
gdk_display_setting_changed (display, entry->setting);
else if (strcmp (key, "high-contrast") == 0)
high_contrast_changed (display);
else
update_xft_settings (display);
}
@@ -2090,6 +2100,36 @@ set_decoration_layout_from_entry (GdkDisplay *display,
}
}
static void
set_theme_from_entry (GdkDisplay *display,
TranslationEntry *entry,
GValue *value)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GSettings *settings = NULL;
GSettingsSchema *schema = NULL;
gboolean hc = FALSE;
if (display_wayland->settings_portal == NULL)
{
settings = (GSettings *)g_hash_table_lookup (display_wayland->settings,
"org.gnome.desktop.a11y.interface");
}
if (settings)
g_object_get (settings, "settings-schema", &schema, NULL);
if (schema && g_settings_schema_has_key (schema, "high-contrast"))
hc = g_settings_get_boolean (settings, "high-contrast");
g_clear_pointer (&schema, g_settings_schema_unref);
if (hc)
g_value_set_static_string (value, "HighContrast");
else
set_value_from_entry (display, entry, value);
}
static gboolean
set_capability_setting (GdkDisplay *display,
GValue *value,
@@ -2121,6 +2161,9 @@ gdk_wayland_display_get_setting (GdkDisplay *display,
{
if (strcmp (name, "gtk-decoration-layout") == 0)
set_decoration_layout_from_entry (display, entry, value);
else if (strcmp (name, "gtk-theme-name") == 0 ||
strcmp (name, "gtk-icon-theme-name") == 0)
set_theme_from_entry (display, entry, value);
else
set_value_from_entry (display, entry, value);
return TRUE;
+16 -22
View File
@@ -118,7 +118,6 @@ struct _GdkWaylandSurface
unsigned int mapped : 1;
unsigned int awaiting_frame : 1;
unsigned int awaiting_frame_frozen : 1;
unsigned int is_drag_surface : 1;
int pending_buffer_offset_x;
int pending_buffer_offset_y;
@@ -780,11 +779,22 @@ gdk_wayland_surface_update_scale (GdkSurface *surface)
return;
}
scale = 1;
for (l = impl->display_server.outputs; l != NULL; l = l->next)
if (!impl->display_server.outputs)
{
guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, l->data);
scale = MAX (scale, output_scale);
scale = impl->scale;
}
else
{
scale = 1;
for (l = impl->display_server.outputs; l != NULL; l = l->next)
{
struct wl_output *output = l->data;
uint32_t output_scale;
output_scale = gdk_wayland_display_get_output_scale (display_wayland,
output);
scale = MAX (scale, output_scale);
}
}
/* Notify app that scale changed */
@@ -2825,27 +2835,12 @@ find_grab_input_seat (GdkSurface *surface,
return NULL;
}
static gboolean
should_be_mapped (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
/* Don't map crazy temp that GTK uses for internal X11 shenanigans. */
if (GDK_IS_DRAG_SURFACE (surface) && surface->x < 0 && surface->y < 0)
return FALSE;
if (impl->is_drag_surface)
return FALSE;
return TRUE;
}
static void
gdk_wayland_surface_map_toplevel (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!should_be_mapped (surface))
if (!GDK_IS_WAYLAND_TOPLEVEL (surface))
return;
if (impl->mapped)
@@ -4703,7 +4698,6 @@ create_dnd_surface (GdkDisplay *display)
GDK_SURFACE_TEMP,
NULL,
0, 0, 100, 100);
GDK_WAYLAND_SURFACE (surface)->is_drag_surface = TRUE;
return surface;
}
-406
View File
@@ -1,406 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2001 Stefan Ondrejicka
*
* 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 <string.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <glib.h>
typedef struct {
char *name;
int id;
char *bitmap;
int hotx;
int hoty;
} font_info_t;
typedef struct {
char *name;
int id;
int width;
int height;
int hotx;
int hoty;
char *data;
} cursor_info_t;
static GSList *fonts = NULL;
static GSList *cursors = NULL;
static int dw,dh;
static gboolean debug = FALSE;
#define HEX(c) (((c) >= '0' && (c) <= '9') ? \
((c) - '0') : (toupper(c) - 'A' + 10))
static void print_font(fi)
font_info_t *fi;
{
int x,y;
for (y = 0; y < dh; y++)
{
for (x = 0; x < dw; x++)
{
printf(fi->bitmap[y*dw+x]? "X" : " ");
}
printf("\n");
}
}
static void print_cursor(ci)
cursor_info_t *ci;
{
int x,y;
for (y = 0; y < ci->height; y++)
{
printf("/* ");
for (x = 0; x < ci->width; x++)
{
if (ci->hotx == x && ci->hoty == y)
printf("o");
else
switch (ci->data[y*ci->width+x])
{
case 0:
printf(" ");
break;
case 1:
printf(".");
break;
case 2:
printf("X");
break;
}
}
printf(" */\n");
}
}
static int read_bdf_font(fname)
char *fname;
{
FILE *f;
char line[2048];
int rv = 0;
gboolean startchar = FALSE, startbitmap = FALSE;
char *charname,*p,*bitmap;
int dx = 0,dy = 0;
int w,h,x,y,py;
int id,tmp;
dw = 0;
dh = 0;
if (!(f = fopen(fname, "r")))
{
perror(fname);
return -1;
}
if (fgets(line, sizeof(line), f) && strncasecmp("STARTFONT ", line, 10))
{
printf("!BDF font file\n");
fclose(f);
return -1;
}
p = line;
while (fgets(line, sizeof(line), f))
{
if (!startchar)
{
if (!strncasecmp("STARTCHAR ", line, 10))
{
startchar = TRUE;
charname = g_strndup(p + 10,
strcspn(p+10, "\r\n"));
}
else if (!strncasecmp("FONTBOUNDINGBOX ", line, 16))
sscanf(p+16, "%d %d %d %d", &dw, &dh, &dx, &dy);
}
else
{
if (!strncasecmp("ENDCHAR", line, 7))
{
font_info_t *nfi;
if (debug)
printf(" %*s*/\n", dw, "");
startchar = FALSE;
startbitmap = FALSE;
nfi = g_malloc(sizeof(font_info_t));
memset(nfi, '\0', sizeof(font_info_t));
nfi->name = charname;
nfi->id = id;
nfi->bitmap = bitmap;
nfi->hotx = 0 - dx;
nfi->hoty = 0 - dy;
fonts = g_slist_append(fonts, nfi);
}
else if (startbitmap)
{
int px,cx;
guchar mask;
px = x - dx + py * dw;
for (cx = 0; cx < w; cx++)
{
mask = 1 << (3 - (cx % 4));
bitmap[px+cx] =
(mask & HEX(line[cx/4])) != 0;
if (debug)
printf(bitmap[px+cx] ? "X" : " ");
}
py++;
if (debug)
printf(" %*s*/\n/* %*s", dw-w, "", dw+dx, "");
}
else if (!strncasecmp("BBX ", line, 4))
{
sscanf(p+4, "%d %d %d %d", &w, &h, &x, &y);
if (debug)
printf("/* %s: */\n/* %*s", charname, dw+dx, "");
}
else if (!strncasecmp("ENCODING ", line, 9))
{
if (sscanf(p+9, "%d %d", &tmp, &id) != 2)
id = tmp;
}
else if (!strncasecmp("BITMAP", line, 6))
{
py = y - dy;
startbitmap = TRUE;
bitmap = g_malloc(dw*dh);
memset(bitmap, '\0', dw*dh);
}
}
}
if (strncasecmp("ENDFONT", line, 7))
rv = -1;
fclose(f);
return rv;
}
static int font_info_compare(fi, name)
font_info_t *fi;
char *name;
{
return strcmp(name, fi->name);
}
static cursor_info_t *gen_cursor(bmap, mask)
font_info_t *bmap;
font_info_t *mask;
{
cursor_info_t *ci;
int bx = dw,by = dh,ex = 0,ey = 0;
int i,j;
for (j = 0; j < dh; j++)
{
gboolean havep = FALSE;
for (i = 0; i < dw; i++)
{
if (bmap->bitmap[j*dw+i] || mask->bitmap[j*dw+i])
{
havep = TRUE;
bx = MIN(bx, i);
ex = MAX(i+1, ex);
}
}
if (havep)
{
by = MIN(by, j);
ey = MAX(ey, j+1);
}
}
ci = g_malloc(sizeof(cursor_info_t));
ci->name = g_strdup(bmap->name);
ci->id = bmap->id;
ci->width = ex - bx;
ci->height = ey - by;
ci->hotx = bmap->hotx - bx;
ci->hoty = ci->height - (bmap->hoty - by);
ci->data = g_malloc(ci->width * ci->height);
memset(ci->data, '\0', ci->width * ci->height);
for (j = 0; j < ci->height; j++)
{
for (i = 0; i < ci->width; i++)
{
int ofs = (by + j) * dw + bx + i;
ci->data[j*ci->width + i] = mask->bitmap[ofs] *
(1 + bmap->bitmap[ofs]);
}
}
return ci;
}
static void compose_cursors_from_fonts()
{
GSList *l;
for (l = g_slist_copy (fonts); l; l = g_slist_delete_link (l,l))
{
font_info_t *fi = l->data;
char *name;
GSList *ml;
name = g_strconcat(fi->name, "_mask", NULL);
if ((ml = g_slist_find_custom(fonts, name,
(GCompareFunc) font_info_compare)))
{
cursors = g_slist_append(cursors, gen_cursor(l->data, ml->data));
fonts = g_slist_remove(fonts, l->data);
fonts = g_slist_remove(fonts, ml->data);
}
g_free(name);
}
}
static char *dump_cursor(ci, id)
cursor_info_t *ci;
int id;
{
static char cdata[8192];
char *p;
int i;
int c;
gboolean flushed;
sprintf(cdata, " { \"%s\", %d, %d, %d, %d, %d, \n \"",
ci->name, ci->id, ci->width, ci->height, ci->hotx, ci->hoty);
p = cdata + strlen(cdata);
for (i = 0; i < ci->width * ci->height; i++)
{
flushed = FALSE;
if (!(i%4))
c = 0;
c = c << 2;
c += ci->data[i];
if ((i % 4) == 3)
{
flushed = TRUE;
sprintf(p, "\\%03o", c);
p += strlen(p);
}
if (i > 0 && !(i % 64))
{
strcpy(p ,"\"\n \"");
p += strlen(p);
}
}
if (!flushed)
{
sprintf(p, "\\%03o", c);
p += strlen(p);
}
strcpy(p, "\" }");
return cdata;
}
static int dump_cursors()
{
GSList *ptr;
FILE *f = stdout;
fprintf(f, "static const struct { const char *name; int type; guchar width; guchar height; guchar hotx; guchar hoty; guchar *data; } cursors[] = {\n");
for (ptr = cursors; ptr; ptr = ptr->next)
{
if (debug)
print_cursor(ptr->data);
fprintf(f, "%s, \n", dump_cursor(ptr->data));
}
fprintf(f, " { NULL, 0, 0, 0, 0, 0, NULL },\n};\n");
return 0;
}
int main(argc, argv)
int argc;
char **argv;
{
if (argc != 2)
{
printf("missing parameters !\n");
printf("Usage: %s [BDF cursor file]\n", argv[0]);
return -1;
}
if (g_getenv ("BDFCURSOR_DEBUG") != NULL)
debug = TRUE;
if (read_bdf_font(argv[1]) || !fonts)
{
printf("Error reading font\n");
return 1;
}
compose_cursors_from_fonts();
if (!cursors)
{
printf("failed to generate cursors from font!\n");
return 1;
}
dump_cursors();
if (fonts)
{
printf("some fonts remained unconverted!\n");
return 1;
}
return 0;
}
-3385
View File
File diff suppressed because it is too large Load Diff
+41 -33
View File
@@ -38,7 +38,7 @@
#include <dwmapi.h>
#include "gdkwin32langnotification.h"
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
@@ -645,14 +645,6 @@ gdk_win32_display_dispose (GObject *object)
{
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (object);
#ifdef GDK_WIN32_ENABLE_EGL
if (display_win32->egl_disp != EGL_NO_DISPLAY)
{
eglTerminate (display_win32->egl_disp);
display_win32->egl_disp = EGL_NO_DISPLAY;
}
#endif
if (display_win32->hwnd != NULL)
{
if (display_win32->dummy_context_wgl.hglrc != NULL)
@@ -1146,23 +1138,54 @@ gdk_win32_display_get_setting (GdkDisplay *display,
return _gdk_win32_get_setting (name, value);
}
#ifndef EGL_PLATFORM_ANGLE_ANGLE
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#endif
static gboolean
gdk_win32_display_init_gl_backend (GdkDisplay *display,
GError **error)
{
gboolean result = FALSE;
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
/* No env vars set, do the regular GL initialization, first WGL and then EGL,
if (display_win32->dummy_context_wgl.hdc == NULL)
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
/*
* No env vars set, do the regular GL initialization, first WGL and then EGL,
* as WGL is the more tried-and-tested configuration.
*/
result = gdk_win32_display_init_wgl (display, error);
#ifdef HAVE_EGL
/*
* Disable defaulting to EGL for now, since shaders need to be fixed for
* usage against libANGLE EGL. EGL is used more as a compatibility layer
* on Windows rather than being a native citizen on Windows
*/
if (_gdk_debug_flags & GDK_DEBUG_GL_EGL)
result = gdk_display_init_egl (display,
EGL_PLATFORM_ANGLE_ANGLE,
display_win32->dummy_context_wgl.hdc,
FALSE,
error);
#endif
#ifdef GDK_WIN32_ENABLE_EGL
if (!result)
{
g_clear_error (error);
result = gdk_win32_display_init_egl (display, error);
result = gdk_win32_display_init_wgl (display, error);
}
#ifdef HAVE_EGL
if (!result)
{
g_clear_error (error);
result = gdk_display_init_egl (display,
EGL_PLATFORM_ANGLE_ANGLE,
display_win32->dummy_context_wgl.hdc,
TRUE,
error);
}
#endif
@@ -1179,13 +1202,12 @@ gdk_win32_display_init_gl (GdkDisplay *display,
if (!gdk_win32_display_init_gl_backend (display, error))
return NULL;
#ifdef GDK_WIN32_ENABLE_EGL
if (display_win32->egl_disp)
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
else
#endif
if (display_win32->wgl_pixel_format != 0)
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, "display", display, NULL);
#ifdef HAVE_EGL
else if (gdk_display_get_egl_display (display))
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
#endif
g_return_val_if_fail (gl_context != NULL, NULL);
@@ -1203,23 +1225,9 @@ gdk_win32_display_init_gl (GdkDisplay *display,
gpointer
gdk_win32_display_get_egl_display (GdkDisplay *display)
{
#ifdef GDK_WIN32_ENABLE_EGL
GdkWin32Display *display_win32;
#endif
g_return_val_if_fail (GDK_IS_WIN32_DISPLAY (display), NULL);
#ifdef GDK_WIN32_ENABLE_EGL
display_win32 = GDK_WIN32_DISPLAY (display);
if (display_win32->wgl_pixel_format != 0)
return NULL;
return display_win32->egl_disp;
#else
/* no EGL support */
return NULL;
#endif
return gdk_display_get_egl_display (display);
}
static void
+2 -10
View File
@@ -25,7 +25,7 @@
#include "gdkwin32screen.h"
#include "gdkwin32cursor.h"
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
@@ -135,14 +135,6 @@ struct _GdkWin32Display
int wgl_pixel_format;
guint gl_version;
#ifdef GDK_WIN32_ENABLE_EGL
/* EGL (Angle) Items */
guint egl_version;
EGLDisplay egl_disp;
EGLConfig egl_config;
HDC hdc_egl_temp;
#endif
GListModel *monitors;
guint hasWglARBCreateContext : 1;
@@ -151,7 +143,7 @@ struct _GdkWin32Display
guint hasWglARBPixelFormat : 1;
guint hasWglARBmultisample : 1;
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
guint hasEglKHRCreateContext : 1;
guint hasEglSurfacelessContext : 1;
EGLint egl_min_swap_interval;
-24
View File
@@ -157,7 +157,6 @@ static HKL latin_locale = NULL;
static gboolean in_ime_composition = FALSE;
static UINT modal_timer;
static UINT sync_timer = 0;
static int debug_indent = 0;
@@ -1453,23 +1452,6 @@ _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind)
}
}
static VOID CALLBACK
sync_timer_proc (HWND hwnd,
UINT msg,
UINT_PTR id,
DWORD time)
{
MSG message;
if (PeekMessageW (&message, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE))
{
return;
}
RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
KillTimer (hwnd, sync_timer);
}
static gboolean
handle_nchittest (HWND hwnd,
GdkSurface *window,
@@ -2854,12 +2836,6 @@ gdk_event_translate (MSG *msg,
*ret_valp = 1;
break;
case WM_SYNCPAINT:
sync_timer = SetTimer (GDK_SURFACE_HWND (window),
1,
200, sync_timer_proc);
break;
case WM_PAINT:
handle_wm_paint (msg, window);
break;
+3 -365
View File
@@ -53,30 +53,6 @@ typedef struct _GdkWin32GLContextClass GdkWin32GLContextEGLClass;
G_DEFINE_TYPE (GdkWin32GLContextEGL, gdk_win32_gl_context_egl, GDK_TYPE_WIN32_GL_CONTEXT)
static void
gdk_win32_gl_context_egl_dispose (GObject *gobject)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (gobject);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (gdk_gl_context_get_display (context));
GdkSurface *surface = gdk_gl_context_get_surface (context);
if (display_win32 != NULL)
{
if (eglGetCurrentContext () == context_egl->egl_context)
eglMakeCurrent(display_win32->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
GDK_NOTE (OPENGL, g_message ("Destroying EGL (ANGLE) context"));
eglDestroyContext (display_win32->egl_disp,
context_egl->egl_context);
context_egl->egl_context = EGL_NO_CONTEXT;
}
G_OBJECT_CLASS (gdk_win32_gl_context_egl_parent_class)->dispose (gobject);
}
static gboolean
is_egl_force_redraw (GdkSurface *surface)
{
@@ -109,7 +85,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
GdkSurface *surface = gdk_gl_context_get_surface (context);
GdkWin32Display *display_win32 = (GDK_WIN32_DISPLAY (gdk_gl_context_get_display (context)));
GdkDisplay *display = gdk_gl_context_get_display (context);
cairo_rectangle_int_t whole_window;
EGLSurface egl_surface;
@@ -122,7 +98,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
gdk_surface_get_height (surface)
};
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, FALSE);
egl_surface = gdk_surface_get_egl_surface (surface);
if (is_egl_force_redraw (surface))
{
@@ -135,338 +111,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
reset_egl_force_redraw (surface);
}
eglSwapBuffers (display_win32->egl_disp, egl_surface);
}
#ifndef EGL_PLATFORM_ANGLE_ANGLE
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#endif
#ifndef EGL_PLATFORM_ANGLE_TYPE_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#endif
#ifndef EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#endif
static EGLDisplay
gdk_win32_get_egl_display (GdkWin32Display *display)
{
EGLDisplay disp;
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
{
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
if (getPlatformDisplay)
{
EGLint disp_attr[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_NONE};
disp = getPlatformDisplay (EGL_PLATFORM_ANGLE_ANGLE, display->hdc_egl_temp, disp_attr);
if (disp != EGL_NO_DISPLAY)
return disp;
}
}
return eglGetDisplay (display->hdc_egl_temp);
}
#define MAX_EGL_ATTRS 30
static gboolean
find_eglconfig_for_window (GdkWin32Display *display,
EGLConfig *egl_config_out,
EGLint *min_swap_interval_out,
GError **error)
{
EGLint attrs[MAX_EGL_ATTRS];
EGLint count;
EGLConfig *configs, chosen_config;
int i = 0;
EGLDisplay egl_disp = display->egl_disp;
attrs[i++] = EGL_CONFORMANT;
attrs[i++] = EGL_OPENGL_ES2_BIT;
attrs[i++] = EGL_SURFACE_TYPE;
attrs[i++] = EGL_WINDOW_BIT;
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
attrs[i++] = EGL_RGB_BUFFER;
attrs[i++] = EGL_RED_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_GREEN_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_BLUE_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_NONE;
g_assert (i < MAX_EGL_ATTRS);
if (!eglChooseConfig (display->egl_disp, attrs, NULL, 0, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
configs = g_new (EGLConfig, count);
if (!eglChooseConfig (display->egl_disp, attrs, configs, count, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
/* Pick first valid configuration i guess? */
chosen_config = configs[0];
if (!eglGetConfigAttrib (display->egl_disp, chosen_config,
EGL_MIN_SWAP_INTERVAL, min_swap_interval_out))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
"Could not retrieve the minimum swap interval");
g_free (configs);
return FALSE;
}
if (egl_config_out != NULL)
*egl_config_out = chosen_config;
g_free (configs);
return TRUE;
}
gboolean
gdk_win32_display_init_egl (GdkDisplay *display,
GError **error)
{
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
int best_idx = 0;
EGLDisplay egl_disp;
if (!gdk_gl_backend_can_be_used (GDK_GL_EGL, error))
return FALSE;
if (display_win32->egl_disp != EGL_NO_DISPLAY)
return TRUE;
egl_disp = gdk_win32_get_egl_display (display_win32);
if (egl_disp == EGL_NO_DISPLAY)
return FALSE;
if (!eglInitialize (egl_disp, NULL, NULL))
{
eglTerminate (egl_disp);
egl_disp = EGL_NO_DISPLAY;
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("No GL implementation is available"));
return FALSE;
}
display_win32->egl_disp = egl_disp;
display_win32->egl_version = epoxy_egl_version (egl_disp);
eglBindAPI (EGL_OPENGL_ES_API);
display_win32->hasEglSurfacelessContext =
epoxy_has_egl_extension (egl_disp, "EGL_KHR_surfaceless_context");
GDK_NOTE (OPENGL,
g_print ("EGL API version %d.%d found\n"
" - Vendor: %s\n"
" - Checked extensions:\n"
"\t* EGL_KHR_surfaceless_context: %s\n",
display_win32->egl_version / 10,
display_win32->egl_version % 10,
eglQueryString (display_win32->egl_disp, EGL_VENDOR),
display_win32->hasEglSurfacelessContext ? "yes" : "no"));
return find_eglconfig_for_window (display_win32, &display_win32->egl_config,
&display_win32->egl_min_swap_interval, error);
}
#define N_EGL_ATTRS 16
static EGLContext
create_egl_context (EGLDisplay display,
EGLConfig config,
GdkGLContext *share,
int flags,
int major,
int minor,
gboolean *is_legacy)
{
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
int i = 0;
/* ANGLE does not support the GL_OES_vertex_array_object extension, so we need to use ES3 directly */
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
context_attribs[i++] = 3;
/* Specify the flags */
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
context_attribs[i++] = flags;
context_attribs[i++] = EGL_NONE;
g_assert (i < N_EGL_ATTRS);
ctx = eglCreateContext (display,
config,
share != NULL ? GDK_WIN32_GL_CONTEXT_EGL (share)->egl_context
: EGL_NO_CONTEXT,
context_attribs);
if (ctx != EGL_NO_CONTEXT)
GDK_NOTE (OPENGL, g_message ("Created EGL context[%p]", ctx));
return ctx;
}
static gboolean
gdk_win32_gl_context_egl_realize (GdkGLContext *context,
GError **error)
{
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
gboolean debug_bit, compat_bit, legacy_bit;
gboolean use_es = FALSE;
EGLContext egl_context;
EGLContext ctx;
/* request flags and specific versions for core (3.2+) WGL context */
int flags = 0;
int major = 0;
int minor = 0;
GdkSurface *surface = gdk_gl_context_get_surface (context);
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
GdkGLContext *share = gdk_display_get_gl_context (display);
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
/*
* A legacy context cannot be shared with core profile ones, so this means we
* must stick to a legacy context if the shared context is a legacy context
*/
/* if GDK_GL_LEGACY is set, we default to a legacy context */
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ?
TRUE :
share != NULL && gdk_gl_context_is_legacy (share);
use_es = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
(share != NULL && gdk_gl_context_get_use_es (share));
if (debug_bit)
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
if (compat_bit)
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
GDK_NOTE (OPENGL, g_message ("Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s)",
major, minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no",
legacy_bit ? "yes" : "no"));
ctx = create_egl_context (display_win32->egl_disp,
display_win32->egl_config,
share,
flags,
major,
minor,
&legacy_bit);
if (ctx == EGL_NO_CONTEXT)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return FALSE;
}
GDK_NOTE (OPENGL, g_print ("Created EGL context[%p]\n", ctx));
context_egl->egl_context = ctx;
/* We are using GLES here */
gdk_gl_context_set_use_es (context, TRUE);
/* Ensure that any other context is created with a legacy bit set */
gdk_gl_context_set_is_legacy (context, legacy_bit);
return TRUE;
}
static gboolean
gdk_win32_gl_context_egl_clear_current (GdkGLContext *context)
{
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
if (display_win32->egl_disp != EGL_NO_DISPLAY)
return eglMakeCurrent (display_win32->egl_disp,
EGL_NO_SURFACE,
EGL_NO_SURFACE,
EGL_NO_CONTEXT);
else
return TRUE;
}
static gboolean
gdk_win32_gl_context_egl_make_current (GdkGLContext *context,
gboolean surfaceless)
{
GdkWin32GLContextEGL *context_egl = GDK_WIN32_GL_CONTEXT_EGL (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
GdkSurface *surface;
gboolean do_frame_sync = FALSE;
EGLSurface egl_surface;
surface = gdk_gl_context_get_surface (context);
if (!surfaceless)
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, FALSE);
else
{
if (display_win32->hasEglSurfacelessContext)
egl_surface = EGL_NO_SURFACE;
else
egl_surface = gdk_win32_surface_get_egl_surface (surface, display_win32->egl_config, TRUE);
}
if (!eglMakeCurrent (display_win32->egl_disp,
egl_surface,
egl_surface,
context_egl->egl_context))
return FALSE;
if (display_win32->egl_min_swap_interval == 0)
eglSwapInterval (display_win32->egl_disp, 0);
else
g_debug ("Can't disable GL swap interval");
return TRUE;
eglSwapBuffers (gdk_display_get_egl_display (display), egl_surface);
}
static void
@@ -484,18 +129,11 @@ gdk_win32_gl_context_egl_class_init (GdkWin32GLContextClass *klass)
{
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS(klass);
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS(klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
context_class->backend_type = GDK_GL_EGL;
context_class->realize = gdk_win32_gl_context_egl_realize;
context_class->make_current = gdk_win32_gl_context_egl_make_current;
context_class->clear_current = gdk_win32_gl_context_egl_clear_current;
draw_context_class->begin_frame = gdk_win32_gl_context_egl_begin_frame;
draw_context_class->end_frame = gdk_win32_gl_context_egl_end_frame;
gobject_class->dispose = gdk_win32_gl_context_egl_dispose;
}
static void
-3
View File
@@ -226,9 +226,6 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
gboolean set_pixel_format_result = FALSE;
int best_idx = 0;
if (display_win32->dummy_context_wgl.hdc == NULL)
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
+1 -1
View File
@@ -40,7 +40,7 @@
#include <cairo.h>
#include <epoxy/wgl.h>
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
+1 -1
View File
@@ -24,7 +24,7 @@
#include <epoxy/gl.h>
#include <epoxy/wgl.h>
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
+164 -217
View File
@@ -638,6 +638,7 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
return NULL;
}
gdk_surface_set_egl_native_window (surface, (void *) impl->handle);
if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
gdk_winpointer_initialize_surface (surface);
@@ -652,6 +653,7 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
g_object_unref (frame_clock);
impl->hdc = GetDC (impl->handle);
impl->inhibit_configure = TRUE;
return surface;
}
@@ -685,22 +687,6 @@ gdk_win32_surface_destroy (GdkSurface *window,
gdk_win32_surface_set_transient_for (child, NULL);
}
#ifdef GDK_WIN32_ENABLE_EGL
GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (window));
/* Get rid of any EGLSurfaces that we might have created */
if (surface->egl_surface != EGL_NO_SURFACE)
{
eglDestroySurface (display->egl_disp, surface->egl_surface);
surface->egl_surface = EGL_NO_SURFACE;
}
if (surface->egl_dummy_surface != EGL_NO_SURFACE)
{
eglDestroySurface (display->egl_disp, surface->egl_dummy_surface);
surface->egl_dummy_surface = EGL_NO_SURFACE;
}
#endif
/* Remove ourself from our transient owner */
if (surface->transient_owner != NULL)
{
@@ -709,6 +695,7 @@ gdk_win32_surface_destroy (GdkSurface *window,
if (!foreign_destroy)
{
gdk_surface_set_egl_native_window (window, NULL);
window->destroyed = TRUE;
DestroyWindow (GDK_SURFACE_HWND (window));
}
@@ -800,26 +787,6 @@ show_window_internal (GdkSurface *window,
if (!unminimize && !already_mapped && IsWindowVisible (GDK_SURFACE_HWND (window)))
return;
/* Other cases */
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
/* Use SetWindowPos to show transparent windows so automatic redraws
* in other windows can be suppressed.
*/
if (exstyle & WS_EX_TRANSPARENT)
{
UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
if (GDK_IS_DRAG_SURFACE (window))
flags |= SWP_NOACTIVATE;
SetWindowPos (GDK_SURFACE_HWND (window),
SWP_NOZORDER_SPECIFIED, 0, 0, 0, 0, flags);
return;
}
/* For initial map of "normal" windows we want to emulate WM window
* positioning behaviour, which means:
* + default to the initial CW_USEDEFAULT placement,
@@ -966,6 +933,8 @@ show_window_internal (GdkSurface *window,
GtkShowWindow (window, SW_SHOW);
}
exstyle = GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE);
/* Sync STATE_ABOVE to TOPMOST */
if (!GDK_IS_DRAG_SURFACE (window) &&
(((window->state & GDK_TOPLEVEL_STATE_ABOVE) &&
@@ -1002,22 +971,7 @@ gdk_win32_surface_hide (GdkSurface *window)
_gdk_surface_clear_update_area (window);
if (GDK_IS_TOPLEVEL (window))
ShowOwnedPopups (GDK_SURFACE_HWND (window), FALSE);
/* Use SetWindowPos to hide transparent windows so automatic redraws
* in other windows can be suppressed.
*/
if (GetWindowLong (GDK_SURFACE_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
{
SetWindowPos (GDK_SURFACE_HWND (window), SWP_NOZORDER_SPECIFIED,
0, 0, 0, 0,
SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
}
else
{
GtkShowWindow (window, SW_HIDE);
}
GtkShowWindow (window, SW_HIDE);
}
static void
@@ -1056,14 +1010,15 @@ gdk_win32_surface_do_move (GdkSurface *window,
}
void
gdk_win32_surface_resize (GdkSurface *window,
int width, int height)
gdk_win32_surface_resize (GdkSurface *surface,
int width,
int height)
{
RECT outer_rect;
g_return_if_fail (GDK_IS_SURFACE (window));
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_SURFACE_DESTROYED (window))
if (GDK_SURFACE_DESTROYED (surface))
return;
if (width < 1)
@@ -1072,28 +1027,29 @@ gdk_win32_surface_resize (GdkSurface *window,
height = 1;
GDK_NOTE (MISC, g_print ("gdk_win32_surface_resize: %p: %dx%d\n",
GDK_SURFACE_HWND (window), width, height));
GDK_SURFACE_HWND (surface), width, height));
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
if (surface->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
return;
get_outer_rect (window, width, height, &outer_rect);
get_outer_rect (surface, width, height, &outer_rect);
GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
"NOACTIVATE|NOMOVE|NOZORDER)\n",
GDK_SURFACE_HWND (window),
GDK_SURFACE_HWND (surface),
outer_rect.right - outer_rect.left,
outer_rect.bottom - outer_rect.top));
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (window),
API_CALL (SetWindowPos, (GDK_SURFACE_HWND (surface),
SWP_NOZORDER_SPECIFIED,
0, 0,
outer_rect.right - outer_rect.left,
outer_rect.bottom - outer_rect.top,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
window->resize_count += 1;
surface->resize_count += 1;
gdk_surface_request_layout (window);
if (!GDK_WIN32_SURFACE (surface)->force_recompute_size)
gdk_surface_request_layout (surface);
}
static void
@@ -1347,33 +1303,22 @@ gdk_win32_surface_set_urgency_hint (GdkSurface *window,
gboolean urgent)
{
FLASHWINFO flashwinfo;
typedef BOOL (WINAPI *PFN_FlashWindowEx) (FLASHWINFO*);
PFN_FlashWindowEx flashWindowEx = NULL;
g_return_if_fail (GDK_IS_SURFACE (window));
if (GDK_SURFACE_DESTROYED (window))
return;
flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
if (flashWindowEx)
{
flashwinfo.cbSize = sizeof (flashwinfo);
flashwinfo.hwnd = GDK_SURFACE_HWND (window);
if (urgent)
flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
else
flashwinfo.dwFlags = FLASHW_STOP;
flashwinfo.uCount = 0;
flashwinfo.dwTimeout = 0;
flashWindowEx (&flashwinfo);
}
flashwinfo.cbSize = sizeof (flashwinfo);
flashwinfo.hwnd = GDK_SURFACE_HWND (window);
if (urgent)
flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
else
{
FlashWindow (GDK_SURFACE_HWND (window), urgent);
}
flashwinfo.dwFlags = FLASHW_STOP;
flashwinfo.uCount = 0;
flashwinfo.dwTimeout = 0;
FlashWindowEx (&flashwinfo);
}
static gboolean
@@ -2291,95 +2236,87 @@ stash_window (GdkSurface *window,
}
static void
snap_up (GdkSurface *window)
snap_up (GdkSurface *surface)
{
SHORT maxysize;
int x, y;
int width, height;
GdkWin32Surface *impl;
impl = GDK_WIN32_SURFACE (window);
impl = GDK_WIN32_SURFACE (surface);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_FULLUP;
stash_window (window, impl);
stash_window (surface, impl);
maxysize = GetSystemMetrics (SM_CYVIRTUALSCREEN) / impl->surface_scale;
x = y = 0;
width = gdk_surface_get_width (window);
width = gdk_surface_get_width (surface);
y = 0;
height = maxysize;
x = x - impl->shadow.left;
y = y - impl->shadow.top;
x = surface->x - impl->shadow.left / impl->surface_scale;
y = y - impl->shadow.top / impl->surface_scale;
width += impl->shadow_x;
height += impl->shadow_y;
/* XXX: FIXME, AeroSnap snap_up() not really working well,
*
* * The snap_up() puts the window at the top left corner.
* * Without the following call, the height maximizes but we see a spew of
* "GdkToplevelSize: geometry size (x,y) exceeds bounds" warnings
*/
compute_toplevel_size (window, TRUE, &width, &height);
gdk_win32_surface_move_resize (window, x, y, width, height);
gdk_win32_surface_move_resize (surface, x, y, width, height);
}
static void
snap_left (GdkSurface *window,
snap_left (GdkSurface *surface,
GdkMonitor *monitor,
GdkMonitor *snap_monitor)
{
GdkRectangle rect;
GdkWin32Surface *impl;
impl = GDK_WIN32_SURFACE (window);
impl = GDK_WIN32_SURFACE (surface);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFLEFT;
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
stash_window (window, impl);
stash_window (surface, impl);
rect.width = rect.width / 2;
rect.x = rect.x - impl->shadow.left;
rect.y = rect.y - impl->shadow.top;
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
rect.width = rect.width + impl->shadow_x;
rect.height = rect.height + impl->shadow_y;
gdk_win32_surface_move_resize (window,
gdk_win32_surface_move_resize (surface,
rect.x, rect.y,
rect.width, rect.height);
}
static void
snap_right (GdkSurface *window,
snap_right (GdkSurface *surface,
GdkMonitor *monitor,
GdkMonitor *snap_monitor)
{
GdkRectangle rect;
GdkWin32Surface *impl;
impl = GDK_WIN32_SURFACE (window);
impl = GDK_WIN32_SURFACE (surface);
impl->snap_state = GDK_WIN32_AEROSNAP_STATE_HALFRIGHT;
gdk_win32_monitor_get_workarea (snap_monitor, &rect);
stash_window (window, impl);
stash_window (surface, impl);
rect.width = rect.width / 2;
rect.x += rect.width;
rect.x = rect.x - impl->shadow.left;
rect.y = rect.y - impl->shadow.top;
rect.x = rect.x - impl->shadow.left / impl->surface_scale;
rect.y = rect.y - impl->shadow.top / impl->surface_scale;
rect.width = rect.width + impl->shadow_x;
rect.height = rect.height + impl->shadow_y;
gdk_win32_surface_move_resize (window,
gdk_win32_surface_move_resize (surface,
rect.x, rect.y,
rect.width, rect.height);
}
@@ -2517,35 +2454,41 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
}
static void
apply_snap (GdkSurface *window,
GdkWin32AeroSnapState snap)
apply_snap (GdkSurface *surface,
GdkWin32AeroSnapState snap)
{
GdkMonitor *monitor;
GdkDisplay *display;
display = gdk_surface_get_display (window);
monitor = gdk_display_get_monitor_at_surface (display, window);
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_monitor_at_surface (display, surface);
switch (snap)
{
case GDK_WIN32_AEROSNAP_STATE_UNDETERMINED:
break;
case GDK_WIN32_AEROSNAP_STATE_MAXIMIZE:
unsnap (window, monitor);
gdk_win32_surface_maximize (window);
unsnap (surface, monitor);
gdk_win32_surface_maximize (surface);
break;
case GDK_WIN32_AEROSNAP_STATE_HALFLEFT:
unsnap (window, monitor);
snap_left (window, monitor, monitor);
unsnap (surface, monitor);
snap_left (surface, monitor, monitor);
break;
case GDK_WIN32_AEROSNAP_STATE_HALFRIGHT:
unsnap (window, monitor);
snap_right (window, monitor, monitor);
unsnap (surface, monitor);
snap_right (surface, monitor, monitor);
break;
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
snap_up (window);
snap_up (surface);
break;
}
if (snap != GDK_WIN32_AEROSNAP_STATE_UNDETERMINED)
{
GDK_WIN32_SURFACE (surface)->inhibit_configure = TRUE;
GDK_WIN32_SURFACE (surface)->force_recompute_size = FALSE;
}
}
/* Registers a dumb window class. This window
@@ -3010,6 +2953,7 @@ update_fullup_indicator (GdkSurface *window,
to.height = gdk_surface_get_height (window);
to.y = 0;
to.x = window->x;
to.height = maxysize;
from = context->indicator_target;
@@ -3162,6 +3106,7 @@ start_indicator (GdkSurface *window,
end_size.height = workarea.height;
break;
case GDK_WIN32_AEROSNAP_STATE_FULLUP:
start_size.x = end_size.x = window->x;
end_size.y = 0;
end_size.height = maxysize;
break;
@@ -3423,10 +3368,10 @@ get_cursor_name_from_op (GdkW32WindowDragOp op,
}
static void
setup_drag_move_resize_context (GdkSurface *window,
setup_drag_move_resize_context (GdkSurface *surface,
GdkW32DragMoveResizeContext *context,
GdkW32WindowDragOp op,
GdkSurfaceEdge edge,
GdkSurfaceEdge edge,
GdkDevice *device,
int button,
double x,
@@ -3435,12 +3380,13 @@ setup_drag_move_resize_context (GdkSurface *window,
{
RECT rect;
const char *cursor_name;
GdkSurface *pointer_window;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
gboolean maximized = gdk_toplevel_get_state (GDK_TOPLEVEL (window)) & GDK_TOPLEVEL_STATE_MAXIMIZED;
GdkSurface *pointer_surface;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
gboolean maximized = gdk_toplevel_get_state (GDK_TOPLEVEL (surface)) & GDK_TOPLEVEL_STATE_MAXIMIZED;
int root_x, root_y;
gboolean restore_configure = FALSE;
gdk_win32_surface_get_root_coords (window, x, y, &root_x, &root_y);
gdk_win32_surface_get_root_coords (surface, x, y, &root_x, &root_y);
/* Before we drag, we need to undo any maximization or snapping.
* AeroSnap behaviour:
@@ -3463,7 +3409,7 @@ setup_drag_move_resize_context (GdkSurface *window,
* resize
* don't unsnap
* apply new width and x position to unsnapped cache,
* so that unsnapped window only regains its height
* so that unsnapped surface only regains its height
* and y position, but inherits x and width from
* the fullup snapped state
* vertical resize:
@@ -3478,7 +3424,7 @@ setup_drag_move_resize_context (GdkSurface *window,
*
* TODO: make this implementation behave as AeroSnap on resizes?
* There's also the case where
* a halfleft/halfright window isn't unsnapped when it's
* a halfleft/halfright surface isn't unsnapped when it's
* being moved horizontally, but it's more difficult to implement.
*/
if (op == GDK_WIN32_DRAGOP_RESIZE &&
@@ -3486,7 +3432,8 @@ setup_drag_move_resize_context (GdkSurface *window,
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFLEFT ||
impl->snap_state == GDK_WIN32_AEROSNAP_STATE_FULLUP))
{
discard_snapinfo (window);
discard_snapinfo (surface);
restore_configure = TRUE;
}
else if (maximized ||
(impl->snap_state == GDK_WIN32_AEROSNAP_STATE_HALFRIGHT ||
@@ -3496,24 +3443,25 @@ setup_drag_move_resize_context (GdkSurface *window,
GdkMonitor *monitor;
int wx, wy, wwidth, wheight;
int swx, swy, swwidth, swheight;
gboolean pointer_outside_of_window;
gboolean pointer_outside_of_surface;
int offsetx, offsety;
gboolean left_half;
GdkDisplay *display;
display = gdk_surface_get_display (window);
monitor = gdk_display_get_monitor_at_surface (display, window);
gdk_surface_get_geometry (window, &wx, &wy, &wwidth, &wheight);
restore_configure = TRUE;
display = gdk_surface_get_display (surface);
monitor = gdk_display_get_monitor_at_surface (display, surface);
gdk_surface_get_geometry (surface, &wx, &wy, &wwidth, &wheight);
swx = wx;
swy = wy;
swwidth = wwidth;
swheight = wheight;
/* Subtract window shadow. We don't want pointer to go outside of
* the visible window during drag-move. For drag-resize it's OK.
* Don't take shadow into account if the window is maximized -
* maximized windows don't have shadows.
/* Subtract surface shadow. We don't want pointer to go outside of
* the visible surface during drag-move. For drag-resize it's OK.
* Don't take shadow into account if the surface is maximized -
* maximized surfaces don't have shadows.
*/
if (op == GDK_WIN32_DRAGOP_MOVE && !maximized)
{
@@ -3523,16 +3471,16 @@ setup_drag_move_resize_context (GdkSurface *window,
swheight -= impl->shadow_y;
}
pointer_outside_of_window = root_x < swx || root_x > swx + swwidth ||
pointer_outside_of_surface = root_x < swx || root_x > swx + swwidth ||
root_y < swy || root_y > swy + swheight;
/* Calculate the offset of the pointer relative to the window */
/* Calculate the offset of the pointer relative to the surface */
offsetx = root_x - swx;
offsety = root_y - swy;
/* Figure out in which half of the window the pointer is.
/* Figure out in which half of the surface the pointer is.
* The code currently only concerns itself with horizontal
* dimension (left/right halves).
* There's no upper/lower half, because usually window
* There's no upper/lower half, because usually surface
* is dragged by its upper half anyway. If that changes, adjust
* accordingly.
*/
@@ -3542,26 +3490,26 @@ setup_drag_move_resize_context (GdkSurface *window,
if (!left_half)
offsetx = swwidth - offsetx;
GDK_NOTE (MISC, g_print ("Pointer at %d : %d, this is %d : %d relative to the window's %s\n",
GDK_NOTE (MISC, g_print ("Pointer at %d : %d, this is %d : %d relative to the surface's %s\n",
root_x, root_y, offsetx, offsety,
left_half ? "left half" : "right half"));
/* Move window in such a way that on unmaximization/unsnapping the pointer
* is still pointing at the appropriate half of the window,
/* Move surface in such a way that on unmaximization/unsnapping the pointer
* is still pointing at the appropriate half of the surface,
* with the same offset from the left or right edge. If the new
* window size is too small, and adding that offset puts the pointer
* surface size is too small, and adding that offset puts the pointer
* into the other half or even beyond, move the pointer to the middle.
*/
if (!pointer_outside_of_window && maximized)
if (!pointer_outside_of_surface && maximized)
{
WINDOWPLACEMENT placement;
int unmax_width, unmax_height;
int shadow_unmax_width, shadow_unmax_height;
placement.length = sizeof (placement);
API_CALL (GetWindowPlacement, (GDK_SURFACE_HWND (window), &placement));
API_CALL (GetWindowPlacement, (GDK_SURFACE_HWND (surface), &placement));
GDK_NOTE (MISC, g_print ("W32 WM unmaximized window placement is %ld x %ld @ %ld : %ld\n",
GDK_NOTE (MISC, g_print ("W32 WM unmaximized surface placement is %ld x %ld @ %ld : %ld\n",
placement.rcNormalPosition.right - placement.rcNormalPosition.left,
placement.rcNormalPosition.bottom - placement.rcNormalPosition.top,
placement.rcNormalPosition.left,
@@ -3607,9 +3555,9 @@ setup_drag_move_resize_context (GdkSurface *window,
placement.rcNormalPosition.left,
placement.rcNormalPosition.top));
API_CALL (SetWindowPlacement, (GDK_SURFACE_HWND (window), &placement));
API_CALL (SetWindowPlacement, (GDK_SURFACE_HWND (surface), &placement));
}
else if (!pointer_outside_of_window && impl->snap_stash_int)
else if (!pointer_outside_of_surface && impl->snap_stash_int)
{
GdkRectangle new_pos;
GdkRectangle snew_pos;
@@ -3639,22 +3587,22 @@ setup_drag_move_resize_context (GdkSurface *window,
new_pos.y = root_y - new_pos.height / 2;
}
GDK_NOTE (MISC, g_print ("Unsnapped window to %d : %d\n",
GDK_NOTE (MISC, g_print ("Unsnapped surface to %d : %d\n",
new_pos.x, new_pos.y));
discard_snapinfo (window);
gdk_win32_surface_move_resize (window, new_pos.x, new_pos.y,
discard_snapinfo (surface);
gdk_win32_surface_move_resize (surface, new_pos.x, new_pos.y,
new_pos.width, new_pos.height);
}
if (maximized)
gdk_win32_surface_unmaximize (window);
gdk_win32_surface_unmaximize (surface);
else
unsnap (window, monitor);
unsnap (surface, monitor);
if (pointer_outside_of_window)
if (pointer_outside_of_surface)
{
/* Pointer outside of the window, move pointer into window */
/* Pointer outside of the surface, move pointer into surface */
GDK_NOTE (MISC, g_print ("Pointer at %d : %d is outside of %d x %d @ %d : %d, move it to %d : %d\n",
root_x, root_y, wwidth, wheight, wx, wy, wx + wwidth / 2, wy + wheight / 2));
root_x = wx + wwidth / 2;
@@ -3667,26 +3615,29 @@ setup_drag_move_resize_context (GdkSurface *window,
}
}
_gdk_win32_get_window_rect (window, &rect);
if (restore_configure)
impl->inhibit_configure = FALSE;
_gdk_win32_get_window_rect (surface, &rect);
cursor_name = get_cursor_name_from_op (op, edge);
context->cursor = gdk_cursor_new_from_name (cursor_name, NULL);
pointer_window = window;
pointer_surface = surface;
/* Note: This triggers a WM_CAPTURECHANGED, which will trigger
* gdk_win32_surface_end_move_resize_drag(), which will end
* our op before it even begins, but only if context->op is not NONE.
* This is why we first do the grab, *then* set the op.
*/
gdk_device_grab (device, pointer_window,
gdk_device_grab (device, pointer_surface,
FALSE,
GDK_ALL_EVENTS_MASK,
context->cursor,
timestamp);
context->window = g_object_ref (window);
context->window = g_object_ref (surface);
context->op = op;
context->edge = edge;
context->device = device;
@@ -3706,10 +3657,10 @@ setup_drag_move_resize_context (GdkSurface *window,
calculate_aerosnap_regions (context);
GDK_NOTE (EVENTS,
g_print ("begin drag moveresize: window %p, toplevel %p, "
g_print ("begin drag moveresize: surface %p, toplevel %p, "
"op %u, edge %d, device %p, "
"button %d, coord %d:%d, time %u\n",
pointer_window, window,
pointer_surface, surface,
context->op, context->edge, context->device,
context->button, context->start_root_x,
context->start_root_y, context->timestamp));
@@ -4104,45 +4055,61 @@ gdk_win32_surface_minimize (GdkSurface *window)
}
static void
gdk_win32_surface_maximize (GdkSurface *window)
gdk_win32_surface_maximize (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (window));
GdkWin32Surface *impl;
if (GDK_SURFACE_DESTROYED (window))
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_SURFACE_DESTROYED (surface))
return;
GDK_NOTE (MISC, g_print ("gdk_surface_maximize: %p: %s\n",
GDK_SURFACE_HWND (window),
_gdk_win32_surface_state_to_string (window->state)));
GDK_SURFACE_HWND (surface),
_gdk_win32_surface_state_to_string (surface->state)));
if (GDK_SURFACE_IS_MAPPED (window))
GtkShowWindow (window, SW_MAXIMIZE);
impl = GDK_WIN32_SURFACE (surface);
impl->inhibit_configure = TRUE;
impl->force_recompute_size = FALSE;
if (GDK_SURFACE_IS_MAPPED (surface))
GtkShowWindow (surface, SW_MAXIMIZE);
else
gdk_synthesize_surface_state (window,
gdk_synthesize_surface_state (surface,
0,
GDK_TOPLEVEL_STATE_MAXIMIZED);
}
static void
gdk_win32_surface_unmaximize (GdkSurface *window)
gdk_win32_surface_unmaximize (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (window));
GdkWin32Surface *impl;
if (GDK_SURFACE_DESTROYED (window))
g_return_if_fail (GDK_IS_SURFACE (surface));
if (GDK_SURFACE_DESTROYED (surface))
return;
GDK_NOTE (MISC, g_print ("gdk_surface_unmaximize: %p: %s\n",
GDK_SURFACE_HWND (window),
_gdk_win32_surface_state_to_string (window->state)));
GDK_SURFACE_HWND (surface),
_gdk_win32_surface_state_to_string (surface->state)));
_gdk_win32_surface_invalidate_egl_framebuffer (window);
_gdk_win32_surface_invalidate_egl_framebuffer (surface);
if (GDK_SURFACE_IS_MAPPED (window))
GtkShowWindow (window, SW_RESTORE);
if (GDK_SURFACE_IS_MAPPED (surface))
GtkShowWindow (surface, SW_RESTORE);
else
gdk_synthesize_surface_state (window,
gdk_synthesize_surface_state (surface,
GDK_TOPLEVEL_STATE_MAXIMIZED,
0);
impl = GDK_WIN32_SURFACE (surface);
if (impl->inhibit_configure)
{
impl->inhibit_configure = FALSE;
impl->force_recompute_size = TRUE;
}
}
static void
@@ -4567,6 +4534,9 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
&surface->x, &surface->y,
NULL, NULL);
}
if (!impl->inhibit_configure)
impl->force_recompute_size = TRUE;
}
}
@@ -4581,8 +4551,18 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
if (!impl->drag_move_resize_context.native_move_resize_pending)
{
surface->width = impl->next_layout.configured_width;
surface->height = impl->next_layout.configured_height;
if (GDK_IS_TOPLEVEL (surface) && impl->force_recompute_size)
{
surface->width = width;
surface->height = height;
gdk_win32_surface_resize (surface, width, height);
impl->force_recompute_size = FALSE;
}
else
{
surface->width = impl->next_layout.configured_width;
surface->height = impl->next_layout.configured_height;
}
_gdk_surface_update_size (surface);
}
@@ -5032,39 +5012,6 @@ gdk_win32_drag_surface_iface_init (GdkDragSurfaceInterface *iface)
iface->present = gdk_win32_drag_surface_present;
}
#ifdef GDK_WIN32_ENABLE_EGL
EGLSurface
gdk_win32_surface_get_egl_surface (GdkSurface *surface,
EGLConfig config,
gboolean is_dummy)
{
GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (surface));
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
if (is_dummy)
{
if (impl->egl_dummy_surface == EGL_NO_SURFACE)
{
EGLint attribs[] = {EGL_WIDTH, 1, EGL_WIDTH, 1, EGL_NONE};
impl->egl_dummy_surface = eglCreatePbufferSurface (display->egl_disp,
config,
attribs);
}
return impl->egl_dummy_surface;
}
else
{
if (impl->egl_surface == EGL_NO_SURFACE)
impl->egl_surface = eglCreateWindowSurface (display->egl_disp,
config,
GDK_SURFACE_HWND (surface),
NULL);
return impl->egl_surface;
}
}
#endif
static void
gdk_win32_surface_get_queued_window_rect (GdkSurface *surface,
@@ -5143,7 +5090,7 @@ _gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface)
* as we need to re-acquire the EGL surfaces that we rendered to upload to Cairo explicitly,
* using gdk_window_invalidate_rect (), when we maximize or restore or use aerosnap
*/
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
if (surface->gl_paint_context != NULL && gdk_gl_context_get_use_es (surface->gl_paint_context))
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
+4 -5
View File
@@ -33,7 +33,7 @@
#include <windows.h>
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
@@ -337,10 +337,9 @@ struct _GdkWin32Surface
int configured_height;
RECT configured_rect;
} next_layout;
gboolean force_recompute_size;
#ifdef GDK_WIN32_ENABLE_EGL
EGLSurface egl_surface;
EGLSurface egl_dummy_surface;
#ifdef HAVE_EGL
guint egl_force_redraw_all : 1;
#endif
};
@@ -373,7 +372,7 @@ void gdk_win32_surface_move_resize (GdkSurface *window,
RECT
gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context);
#ifdef GDK_WIN32_ENABLE_EGL
#ifdef HAVE_EGL
EGLSurface gdk_win32_surface_get_egl_surface (GdkSurface *surface,
EGLConfig config,
gboolean is_dummy);
-30
View File
@@ -1,30 +0,0 @@
# libwntab32x.la - a libtool library file
# Generated by hand, compatible with libtool
# Just a wrapper for libwntab32x.a, which is just a copy of wntab32x.lib
#
# The name that we can dlopen(3).
dlname=''
# Names of this library.
library_names=''
# The name of the static archive.
old_library='libwntab32x.a'
# Libraries that this one depends upon.
dependency_libs=''
# Version information
current=0
age=0
revision=0
# Is this an already installed library?
installed=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir=''
+1 -4
View File
@@ -46,10 +46,7 @@ gdk_win32_public_headers = files([
install_headers(gdk_win32_public_headers, 'gdkwin32.h', subdir: 'gtk-4.0/gdk/win32/')
GDK_WIN32_EGL_CFLAGS = []
if have_egl
GDK_WIN32_EGL_CFLAGS = ['-DGDK_WIN32_ENABLE_EGL']
gdk_win32_sources += ['gdkglcontext-win32-egl.c']
endif
@@ -67,6 +64,6 @@ libgdk_win32 = static_library('gdk-win32',
'-DINSIDE_GDK_WIN32',
'-D_WIN32_WINNT=0x0601',
'-DWINVER=0x0601',
] + GDK_WIN32_EGL_CFLAGS,
],
dependencies: [ gdk_deps, gdk_win32_deps ],
)
+26 -2
View File
@@ -76,11 +76,30 @@ print_atoms (GdkX11Clipboard *cb,
});
}
static void
gdk_x11_clipboard_default_output_closed (GObject *stream,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
if (!g_output_stream_close_finish (G_OUTPUT_STREAM (stream), result, &error))
{
GDK_NOTE (CLIPBOARD,
g_printerr ("-------: failed to close stream: %s\n",
error->message));
g_error_free (error);
}
g_object_unref (stream);
}
static void
gdk_x11_clipboard_default_output_done (GObject *clipboard,
GAsyncResult *result,
gpointer user_data)
{
GOutputStream *stream = user_data;
GError *error = NULL;
if (!gdk_clipboard_write_finish (GDK_CLIPBOARD (clipboard), result, &error))
@@ -90,6 +109,12 @@ gdk_x11_clipboard_default_output_done (GObject *clipboard,
GDK_X11_CLIPBOARD (clipboard)->selection, error->message));
g_error_free (error);
}
g_output_stream_close_async (stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_clipboard_default_output_closed,
NULL);
}
static void
@@ -103,8 +128,7 @@ gdk_x11_clipboard_default_output_handler (GOutputStream *stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_clipboard_default_output_done,
NULL);
g_object_unref (stream);
stream);
}
static GInputStream *
+5 -3
View File
@@ -1665,7 +1665,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
direction,
FALSE);
}
else
{
@@ -1799,7 +1799,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
_gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group),
x, y,
axes);
}
break;
@@ -1838,7 +1838,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
x = (double) xev->event_x / scale;
y = (double) xev->event_y / scale;
event = gdk_touch_event_new (ev->evtype == XI_TouchBegin
? GDK_TOUCH_BEGIN
: GDK_TOUCH_END,
@@ -1946,6 +1946,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
y = (double) xev->event_y / scale;
event = gdk_touchpad_event_new_pinch (surface,
NULL, /* FIXME make up sequences */
device,
xev->time,
state,
@@ -2006,6 +2007,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
y = (double) xev->event_y / scale;
event = gdk_touchpad_event_new_swipe (surface,
NULL, /* FIXME make up sequences */
device,
xev->time,
state,
+26 -2
View File
@@ -1612,11 +1612,30 @@ gdk_x11_drag_set_hotspot (GdkDrag *drag,
}
}
static void
gdk_x11_drag_default_output_closed (GObject *stream,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
if (!g_output_stream_close_finish (G_OUTPUT_STREAM (stream), result, &error))
{
GDK_NOTE (DND,
g_printerr ("failed to close stream: %s\n",
error->message));
g_error_free (error);
}
g_object_unref (stream);
}
static void
gdk_x11_drag_default_output_done (GObject *drag,
GAsyncResult *result,
gpointer user_data)
{
GOutputStream *stream = user_data;
GError *error = NULL;
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
@@ -1624,6 +1643,12 @@ gdk_x11_drag_default_output_done (GObject *drag,
GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_printerr ("failed to write stream: %s\n", error->message));
g_error_free (error);
}
g_output_stream_close_async (stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_drag_default_output_closed,
NULL);
}
static void
@@ -1637,8 +1662,7 @@ gdk_x11_drag_default_output_handler (GOutputStream *stream,
G_PRIORITY_DEFAULT,
NULL,
gdk_x11_drag_default_output_done,
NULL);
g_object_unref (stream);
stream);
}
static gboolean
+2
View File
@@ -71,6 +71,8 @@ gdk_x11_surface_destroy_glx_drawable (GdkX11Surface *self)
if (self->glx_drawable == None)
return;
gdk_gl_context_clear_current_if_surface (GDK_SURFACE (self));
glXDestroyWindow (gdk_x11_display_get_xdisplay (gdk_surface_get_display (GDK_SURFACE (self))),
self->glx_drawable);
+10 -1
View File
@@ -492,9 +492,18 @@ init_randr15 (GdkX11Screen *x11_screen)
if (output_info->crtc)
{
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
XRRCrtcInfo *crtc;
int j;
gdk_x11_display_error_trap_push (display);
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources,
output_info->crtc);
if (gdk_x11_display_error_trap_pop (display))
{
XRRFreeOutputInfo (output_info);
continue;
}
for (j = 0; j < resources->nmode; j++)
{
XRRModeInfo *xmode = &resources->modes[j];
+19 -60
View File
@@ -57,7 +57,8 @@ struct _GdkX11SelectionOutputStreamPrivate {
GTask *pending_task;
guint incr : 1;
guint delete_pending : 1;
guint sent_end_of_stream : 1;
guint delete_pending : 1; /* owns a reference */
};
struct _GdkX11PendingSelectionNotify
@@ -176,12 +177,16 @@ gdk_x11_selection_output_stream_needs_flush_unlocked (GdkX11SelectionOutputStrea
{
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
if (priv->data->len == 0 && priv->notify == NULL)
if (priv->sent_end_of_stream)
return FALSE;
if (g_output_stream_is_closing (G_OUTPUT_STREAM (stream)))
if (g_output_stream_is_closing (G_OUTPUT_STREAM (stream)) ||
g_output_stream_is_closed (G_OUTPUT_STREAM (stream)))
return TRUE;
if (priv->data->len == 0 && priv->notify == NULL)
return FALSE;
if (priv->flush_requested)
return TRUE;
@@ -284,6 +289,8 @@ gdk_x11_selection_output_stream_perform_flush (GdkX11SelectionOutputStream *stre
g_byte_array_remove_range (priv->data, 0, n_elements * element_size);
if (priv->data->len < element_size)
priv->flush_requested = FALSE;
if (!priv->incr || n_elements == 0)
priv->sent_end_of_stream = TRUE;
}
if (priv->notify)
@@ -292,6 +299,7 @@ gdk_x11_selection_output_stream_perform_flush (GdkX11SelectionOutputStream *stre
priv->notify = NULL;
}
g_object_ref (stream);
priv->delete_pending = TRUE;
g_cond_broadcast (&priv->cond);
g_mutex_unlock (&priv->mutex);
@@ -494,60 +502,6 @@ gdk_x11_selection_output_stream_flush_finish (GOutputStream *stream,
return g_task_propagate_boolean (G_TASK (result), error);
}
static gboolean
gdk_x11_selection_output_stream_invoke_close (gpointer stream)
{
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
g_signal_handlers_disconnect_by_func (priv->display,
gdk_x11_selection_output_stream_xevent,
stream);
g_object_unref (stream);
return G_SOURCE_REMOVE;
}
static gboolean
gdk_x11_selection_output_stream_close (GOutputStream *stream,
GCancellable *cancellable,
GError **error)
{
g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, g_object_ref (stream));
return TRUE;
}
static void
gdk_x11_selection_output_stream_close_async (GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
task = g_task_new (stream, cancellable, callback, user_data);
g_task_set_source_tag (task, gdk_x11_selection_output_stream_close_async);
g_task_set_priority (task, io_priority);
gdk_x11_selection_output_stream_invoke_close (stream);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static gboolean
gdk_x11_selection_output_stream_close_finish (GOutputStream *stream,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, stream), FALSE);
g_return_val_if_fail (g_async_result_is_tagged (result, gdk_x11_selection_output_stream_close_async), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
static void
gdk_x11_selection_output_stream_finalize (GObject *object)
{
@@ -557,6 +511,13 @@ gdk_x11_selection_output_stream_finalize (GObject *object)
/* not sending a notify is terrible */
g_assert (priv->notify == NULL);
GDK_DISPLAY_NOTE (priv->display, SELECTION, g_printerr ("%s:%s: finalizing\n",
priv->selection, priv->target));
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
g_signal_handlers_disconnect_by_func (priv->display,
gdk_x11_selection_output_stream_xevent,
stream);
g_byte_array_unref (priv->data);
g_cond_clear (&priv->cond);
g_mutex_clear (&priv->mutex);
@@ -579,14 +540,11 @@ gdk_x11_selection_output_stream_class_init (GdkX11SelectionOutputStreamClass *kl
output_stream_class->write_fn = gdk_x11_selection_output_stream_write;
output_stream_class->flush = gdk_x11_selection_output_stream_flush;
output_stream_class->close_fn = gdk_x11_selection_output_stream_close;
output_stream_class->write_async = gdk_x11_selection_output_stream_write_async;
output_stream_class->write_finish = gdk_x11_selection_output_stream_write_finish;
output_stream_class->flush_async = gdk_x11_selection_output_stream_flush_async;
output_stream_class->flush_finish = gdk_x11_selection_output_stream_flush_finish;
output_stream_class->close_async = gdk_x11_selection_output_stream_close_async;
output_stream_class->close_finish = gdk_x11_selection_output_stream_close_finish;
}
static void
@@ -628,6 +586,7 @@ gdk_x11_selection_output_stream_xevent (GdkDisplay *display,
if (gdk_x11_selection_output_stream_needs_flush (stream) &&
gdk_x11_selection_output_stream_can_flush (stream))
gdk_x11_selection_output_stream_perform_flush (stream);
g_object_unref (stream); /* from unsetting the delete_pending */
return FALSE;
default:
+1 -1
View File
@@ -3535,7 +3535,7 @@ gdk_x11_surface_unfullscreen (GdkSurface *surface)
*
* Returns the group this surface belongs to.
*
* Returns: (transfer none): The group of this surface;
* Returns: (transfer none) (nullable): The group of this surface;
*/
GdkSurface *
gdk_x11_surface_get_group (GdkSurface *surface)
+3 -3
View File
@@ -952,9 +952,9 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
guint program = 0;
guint width = 0;
guint height = 0;
guint n_binds = 0;
G_GNUC_UNUSED guint n_binds = 0;
guint n_fbos = 0;
guint n_uniforms = 0;
G_GNUC_UNUSED guint n_uniforms = 0;
guint n_programs = 0;
guint vao_id;
guint vbo_id;
@@ -1396,7 +1396,7 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
}
else if (stride % bpp == 0 &&
(!use_es || gdk_gl_context_check_version (context, 3, 0) || gdk_gl_context_has_unpack_subimage (context)))
(gdk_gl_context_check_version (context, 0, 0, 3, 0) || gdk_gl_context_has_unpack_subimage (context)))
{
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
+22 -10
View File
@@ -28,10 +28,11 @@
#include "gskglcompilerprivate.h"
#include "gskglprogramprivate.h"
#define SHADER_VERSION_GLES 100
#define SHADER_VERSION_GL2_LEGACY 110
#define SHADER_VERSION_GL3_LEGACY 130
#define SHADER_VERSION_GL3 150
#define SHADER_VERSION_GLES "100"
#define SHADER_VERSION_GLES3 "300 es"
#define SHADER_VERSION_GL2_LEGACY "110"
#define SHADER_VERSION_GL3_LEGACY "130"
#define SHADER_VERSION_GL3 "150"
struct _GskGLCompiler
{
@@ -49,7 +50,7 @@ struct _GskGLCompiler
GArray *attrib_locations;
int glsl_version;
const char *glsl_version;
guint gl3 : 1;
guint gles : 1;
@@ -98,7 +99,7 @@ gsk_gl_compiler_class_init (GskGLCompilerClass *klass)
static void
gsk_gl_compiler_init (GskGLCompiler *self)
{
self->glsl_version = 150;
self->glsl_version = "150";
self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskGLProgramAttrib));
self->all_preamble = g_bytes_ref (empty_bytes);
self->vertex_preamble = g_bytes_ref (empty_bytes);
@@ -127,8 +128,18 @@ gsk_gl_compiler_new (GskGLDriver *driver,
if (gdk_gl_context_get_use_es (context))
{
self->glsl_version = SHADER_VERSION_GLES;
self->gles = TRUE;
int maj, min;
/* for OpenGL/ES 3.0+, use "300 es" as our shader version */
gdk_gl_context_get_version (context, &maj, &min);
if (maj >= 3)
self->glsl_version = SHADER_VERSION_GLES3;
else
{
self->glsl_version = SHADER_VERSION_GLES;
self->gles = TRUE;
}
}
else if (gdk_gl_context_is_legacy (context))
{
@@ -136,7 +147,8 @@ gsk_gl_compiler_new (GskGLDriver *driver,
gdk_gl_context_get_version (context, &maj, &min);
if (maj == 3)
/* On Windows, legacy contexts can give us a GL 4.x context */
if (maj >= 3)
self->glsl_version = SHADER_VERSION_GL3_LEGACY;
else
self->glsl_version = SHADER_VERSION_GL2_LEGACY;
@@ -546,7 +558,7 @@ gsk_gl_compiler_compile (GskGLCompiler *self,
gsk_gl_command_queue_make_current (self->driver->command_queue);
g_snprintf (version, sizeof version, "#version %d\n", self->glsl_version);
g_snprintf (version, sizeof version, "#version %s\n", self->glsl_version);
if (self->debug_shaders)
debug = "#define GSK_DEBUG 1\n";
+11 -15
View File
@@ -161,25 +161,27 @@ gsk_gl_glyph_library_create_surface (GskGLGlyphLibrary *self,
static void
render_glyph (cairo_surface_t *surface,
const cairo_scaled_font_t *scaled_font,
const GskGLGlyphKey *key,
const GskGLGlyphValue *value)
{
cairo_t *cr;
cairo_glyph_t glyph;
PangoGlyphString glyph_string;
PangoGlyphInfo glyph_info;
g_assert (surface != NULL);
g_assert (scaled_font != NULL);
cr = cairo_create (surface);
cairo_set_scaled_font (cr, scaled_font);
cairo_set_source_rgba (cr, 1, 1, 1, 1);
glyph.index = key->glyph;
glyph.x = 0.25 * key->xshift - value->ink_rect.x;
glyph.y = 0.25 * key->yshift - value->ink_rect.y;
glyph_info.glyph = key->glyph;
glyph_info.geometry.width = value->ink_rect.width * 1024;
glyph_info.geometry.x_offset = 0.25 * key->xshift - value->ink_rect.x * 1024;
glyph_info.geometry.y_offset = 0.25 * key->yshift - value->ink_rect.y * 1024;
cairo_show_glyphs (cr, &glyph, 1);
glyph_string.num_glyphs = 1;
glyph_string.glyphs = &glyph_info;
pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
cairo_destroy (cr);
cairo_surface_flush (surface);
@@ -198,7 +200,6 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
{
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
cairo_scaled_font_t *scaled_font;
cairo_surface_t *surface;
guchar *pixel_data;
guchar *free_data = NULL;
@@ -211,11 +212,6 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
g_assert (key != NULL);
g_assert (value != NULL);
scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
if G_UNLIKELY (scaled_font == NULL ||
cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)
return;
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
@@ -223,7 +219,7 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
key->glyph);
surface = gsk_gl_glyph_library_create_surface (self, stride, width, height, uwidth, uheight);
render_glyph (surface, scaled_font, key, value);
render_glyph (surface, key, value);
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
+74 -18
View File
@@ -245,6 +245,47 @@ gsk_rounded_rect_shrink_to_minimum (GskRoundedRect *self)
self->corner[1].height + self->corner[2].height);
}
static inline gboolean G_GNUC_PURE
node_supports_2d_transform (const GskRenderNode *node)
{
switch ((int)gsk_render_node_get_node_type (node))
{
case GSK_COLOR_NODE:
case GSK_OPACITY_NODE:
case GSK_COLOR_MATRIX_NODE:
case GSK_TEXTURE_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_CONIC_GRADIENT_NODE:
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_DEBUG_NODE:
case GSK_TEXT_NODE:
case GSK_CAIRO_NODE:
case GSK_BLEND_NODE:
case GSK_BLUR_NODE:
return TRUE;
case GSK_SHADOW_NODE:
return node_supports_2d_transform (gsk_shadow_node_get_child (node));
case GSK_TRANSFORM_NODE:
return node_supports_2d_transform (gsk_transform_node_get_child (node));
case GSK_CONTAINER_NODE:
for (guint i = 0, p = gsk_container_node_get_n_children (node); i < p; i++)
{
if (!node_supports_2d_transform (gsk_container_node_get_child (node, i)))
return FALSE;
}
return TRUE;
default:
return FALSE;
}
}
static inline gboolean G_GNUC_PURE
node_supports_transform (const GskRenderNode *node)
{
@@ -257,24 +298,26 @@ node_supports_transform (const GskRenderNode *node)
switch ((int)gsk_render_node_get_node_type (node))
{
case GSK_COLOR_NODE:
case GSK_OPACITY_NODE:
case GSK_COLOR_MATRIX_NODE:
case GSK_TEXTURE_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_DEBUG_NODE:
case GSK_TEXT_NODE:
return TRUE;
case GSK_COLOR_NODE:
case GSK_OPACITY_NODE:
case GSK_COLOR_MATRIX_NODE:
case GSK_TEXTURE_NODE:
case GSK_CROSS_FADE_NODE:
case GSK_DEBUG_NODE:
case GSK_TEXT_NODE:
case GSK_CAIRO_NODE:
case GSK_BLEND_NODE:
case GSK_BLUR_NODE:
return TRUE;
case GSK_SHADOW_NODE:
return node_supports_transform (gsk_shadow_node_get_child (node));
case GSK_SHADOW_NODE:
return node_supports_transform (gsk_shadow_node_get_child (node));
case GSK_TRANSFORM_NODE:
return node_supports_transform (gsk_transform_node_get_child (node));
case GSK_TRANSFORM_NODE:
return node_supports_transform (gsk_transform_node_get_child (node));
default:
return FALSE;
default:
return FALSE;
}
}
@@ -2017,6 +2060,14 @@ gsk_gl_render_job_visit_transform_node (GskGLRenderJob *job,
break;
case GSK_TRANSFORM_CATEGORY_2D:
if (node_supports_2d_transform (child))
{
gsk_gl_render_job_push_modelview (job, transform);
gsk_gl_render_job_visit_node (job, child);
gsk_gl_render_job_pop_modelview (job);
return;
}
G_GNUC_FALLTHROUGH;
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
@@ -4066,14 +4117,19 @@ gsk_gl_render_job_set_debug_fallback (GskGLRenderJob *job,
}
static int
get_framebuffer_format (guint framebuffer)
get_framebuffer_format (GdkGLContext *context,
guint framebuffer)
{
int size;
if (!gdk_gl_context_check_version (context, 0, 0, 3, 0))
return GL_RGBA8;
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
framebuffer ? GL_COLOR_ATTACHMENT0
: GL_BACK_LEFT,
: gdk_gl_context_get_use_es (context) ? GL_BACK
: GL_BACK_LEFT,
GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &size);
if (size > 16)
@@ -4110,7 +4166,7 @@ gsk_gl_render_job_new (GskGLDriver *driver,
job->scale_x = scale_factor;
job->scale_y = scale_factor;
job->viewport = *viewport;
job->target_format = get_framebuffer_format (framebuffer);
job->target_format = get_framebuffer_format (job->command_queue->context, framebuffer);
gsk_gl_render_job_set_alpha (job, 1.0f);
gsk_gl_render_job_set_projection_from_rect (job, viewport, NULL);
+2 -2
View File
@@ -3,7 +3,7 @@
uniform vec4 u_geometry;
_NOPERSPECTIVE_ _OUT_ vec2 coord;
_OUT_ vec2 coord;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -29,7 +29,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
uniform vec4 u_geometry;
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
_NOPERSPECTIVE_ _IN_ vec2 coord;
_IN_ vec2 coord;
float get_offset(int index) {
// u_color_stops[5 * index] makes Intel Windows driver crash.
+2 -2
View File
@@ -2,7 +2,7 @@
// linear_gradient.glsl
uniform vec4 u_points;
_NOPERSPECTIVE_ _OUT_ vec4 info;
_OUT_ vec4 info;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -53,7 +53,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
uniform bool u_repeat;
_NOPERSPECTIVE_ _IN_ vec4 info;
_IN_ vec4 info;
float get_offset(int index) {
// u_color_stops[5 * index] makes Intel Windows driver crash.
-2
View File
@@ -5,12 +5,10 @@ precision highp float;
#if defined(GSK_GLES) || defined(GSK_LEGACY)
#define _OUT_ varying
#define _IN_ varying
#define _NOPERSPECTIVE_
#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
#else
#define _OUT_ out
#define _IN_ in
#define _NOPERSPECTIVE_ noperspective
#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
#endif
+2 -2
View File
@@ -3,7 +3,7 @@
uniform vec4 u_geometry;
_NOPERSPECTIVE_ _OUT_ vec2 coord;
_OUT_ vec2 coord;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -32,7 +32,7 @@ uniform bool u_repeat;
uniform vec2 u_range;
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
_NOPERSPECTIVE_ _IN_ vec2 coord;
_IN_ vec2 coord;
float get_offset(int index) {
// u_color_stops[5 * index] makes Intel Windows driver crash.

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