Commit Graph

77954 Commits

Author SHA1 Message Date
Michael Weghorn
fefd856d67 a11y: Convert negative text deletion index to actual offset
`gtk_editable_delete_text` can be called with a
negative `end_pos`, in which case the characters
from the start pos to the end of the text are
removed. [1]

It e.g. gets called this way from
`gtk_editable_set_text`.

So far, that negative index was not converted,
but passed as is in the AT-SPI callback
`delete_text_cb` when calling the `text_changed`
handler (`emit_text_changed` in
`gtk/a11y/gtkatspicontext.c`) which just uses the
index as is, also in it's call to `g_strndup`,
resulting in a crash when negative indices are
used.

Fix this by converting negative values to the
actual end index in `delete_text_cb` before
calling the handler.

[1] https://docs.gtk.org/gtk3/method.Editable.delete_text.html

Fixes: #6149
2023-10-11 15:51:17 +02:00
Sergey Bugaev
39dab6d7bd widget: Queue a resize on Pango context changes
Updating a Pango context can influence the layout of widget, in
particular that of a GtkLabel, not only its rendering. Make sure to
queue a resize when updating the context.

In particular, this fixes window titles getting suddenly truncated when
moving a window from a HiDPI display to a low DPI one, after
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6190 has made font
hinting depend on the widget scale. With hinting enabled on low DPI,
the Pango layout needs ever so slightly more width to not get truncated.
There is plenty of space in the header bar that could be allocated to
the label, but for that to happen, it needs to know to queue a resize.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-11 15:39:37 +03:00
Matthias Clasen
7b5b78b065 Merge branch 'fix-a11y-text-signals-again' into 'main'
a11y: Avoid a crash

Closes #6146

See merge request GNOME/gtk!6470
2023-10-11 01:06:55 +00:00
Matthias Clasen
005b5042f6 Merge branch 'demo-frame-time' into 'main'
demo: Use the frame time for animation

See merge request GNOME/gtk!6468
2023-10-11 00:39:38 +00:00
Matthias Clasen
b5149a483f Merge branch 'wip/chergert/update-stb' into 'main'
gsk/gl: update stb_rect_pack()

See merge request GNOME/gtk!6466
2023-10-11 00:38:36 +00:00
Matthias Clasen
15c43e5284 a11y: Avoid a crash
It is not safe to access text[end],
if text may not be NUL-terminated.

Fixes: #6146
2023-10-10 18:54:27 -04:00
Matthias Clasen
fc4c0f769c Merge branch 'no-enums-in-bitfields' into 'main'
Stop using enums in bitfields

See merge request GNOME/gtk!6467
2023-10-10 22:48:11 +00:00
Sergey Bugaev
e8ecbb2009 demo: Use the frame time for animation
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-10 11:38:13 +03:00
Sergey Bugaev
964affb1cc Stop using enums in bitfields
The C standard does not specify whether the underlying type of an enum
is signed or unsigned, and until C23 there was no way to control this
explicitly. GCC appears to make enums unsigned unless there is a
negative value among cases of the enum, in which case it becomes signed.
MSCV appears to make enums signed by default.

A bitfield of an enum type (which is not specificied in the C standard
either) behaves as if it was an instance of a numeric type with a
reduced value range. Specifically, a 'signed int val : 2;' bitfield will
have the possible values of -2, -1, 0, and 1, with the usual wraparound
behavior for the values that don't fit (although this too is
implementation-defined).

This causes the following issue, if we have:

typedef enum
{
  GTK_ZERO,
  GTK_ONE,
  GTK_TWO
} GtkFoo;

struct _GtkBar
{
  GtkFoo foo : 2;
};

and then assign bar.foo = GTK_TWO and read it back, it will have the
expected value of 2 (aka GTK_TWO) on GCC, but a value of -2 (not
matching any of the enum variants) on MSVC.

There does not seem to be any way to influence signedness of an enum
prior to C23, nor is there a 'unsigned GtkFoo foo : 2;' syntax. The only
remaining options seems to be never using enums in bitfields, which is
what this change implements.

In practice, this fixes GdkPipeIOStream crashing with an assertion when
trying to copy-paste in-app in MSVC builds on GTK.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-10 11:23:08 +03:00
Christian Hergert
05b51af2d5 gsk/gl: update stb_rect_pack() 2023-10-09 22:42:57 -07:00
Emmanuele Bassi
28e51c763b Merge branch 'disable_ccache_macos' into 'main'
Disable ccache in macOS job

See merge request GNOME/gtk!6458
2023-10-09 12:23:31 +00:00
Matthias Clasen
ebf8e18319 Merge branch 'add-bn' into 'main'
add bengali language bn.data for gtkemojichooser

See merge request GNOME/gtk!6459
2023-10-09 03:03:10 +00:00
Christian Hergert
d8bbe1c296 testsuite/gsk: add render test for mask(texture|color) 2023-10-06 10:52:53 -07:00
Christian Hergert
c1417d3d4a gsk/gl: add fast path for texture masking color
This is useful for colorizing in the same fashion we do for the glyph
texture atlas. In fact, for small GdkTexture, you will end up in something
like the icon texture atlas.

The primary motivator for this optimization is to draw various glyph-like
features from VTE such as many forms of boxes, lines, arrows, etc.
2023-10-05 20:30:00 -07:00
René de Hesselle
3b4359d76d ci: Disable ccache in macOS job
As it turns out, ccache accelerates the build so much that it can
trigger a race condition in the gobject-introspection subproject. This
only surfaced recently as the introspection feature was previously
disabled due to missing build time dependencies.

The race condition surfaces as follows: the build breaks because
gobject-introspection starts to build Gdk-4.0.gir before
GdkPixbuf-2.0.gir, despite Gdk-4.0.gir depending on GdkPixbuf-2.0.gir.
2023-10-04 20:07:47 +02:00
sudip
16806294e3 add bengali language bn.data for gtkemojichooser 2023-10-04 18:52:10 +05:30
Luca Bacci
822425072b Merge branch '5724_gdk_win32_ignore_invalid_client_rect' into 'main'
Gdk4 Win32: ignore invalid client rects

Closes #5724

See merge request GNOME/gtk!6414
2023-10-04 07:58:55 +00:00
Emmanuele Bassi
7cc1283a26 Merge branch 'macos_introspec' into 'main'
Enable introspection in macOS CI

Closes Infrastructure/Infrastructure#935

See merge request GNOME/gtk!6453
2023-10-03 22:46:23 +00:00
René de Hesselle
f4198706d1 Enable introspection in macOS CI
This requires providing pkg-config and bison as well as pre-built
wheels for Pycairo and PyGObject to make it work.
2023-10-03 21:00:14 +02:00
Jordi Mas i Hernandez
8478ba66fe Update Catalan translation
(cherry picked from commit d6fecef605)
2023-10-03 06:56:01 +00:00
Matthias Clasen
1d58de6ffb Merge branch 'a11y-textview-crash' into 'main'
a11y: Be safe against non-UTF8

Closes #6131

See merge request GNOME/gtk!6448
2023-10-02 17:34:21 +00:00
Emmanuele Bassi
f5cec5c0f2 Apply 1 suggestion(s) to 1 file(s) 2023-10-02 13:16:17 +00:00
Matthias Clasen
368f2af634 a11y: Be safe against non-UTF8 text
The string we're passed here may not be zero-terminated
since our text insertion APIs take string + length. So
So be safe and copy the text we are interested in if
necessary.

Fixes: #6131
2023-10-02 08:49:41 -04:00
Matthias Clasen
66a9fee071 a11y: Emit text-changed after the insertion
This is necessary, since it is the default handler
that positions the iter at the inserted text, which
is what we assume here.
2023-10-02 08:49:31 -04:00
Matthias Clasen
6e0ac83d99 Merge branch 'print-dialog-revision' into 'main'
print dialog: Some API revisions

See merge request GNOME/gtk!6443
2023-10-01 14:01:33 +00:00
Matthias Clasen
12ad6b3157 gtk-demo: Add a demo for printing a stream
Add a Print button to the path fill demo,
and implement it using gtk_print_dialog_print.
2023-10-01 09:30:38 -04:00
Matthias Clasen
fda9fd5ced print dialog: Some API revisions
Make gtk_print_dialog_setup_finish return a GtkPrintSetup
object, which encapsulates all the data that needs to be
transferred between the setup and print calls, and make
the print_file and print methods take an extra GtkPrintSetup
argument.

Change the print call to return an output stream, rather
than take an input stream. The results are now returned
when the output stream is closed.

With some further cleanup, this makes the GtkPrintDialog
object a proper builder object - you can create multiple
print dialogs from the same GtkPrintDialog object, in
parallel, and they won't interfere with each other.
2023-10-01 09:30:38 -04:00
Matthias Clasen
029ce83a69 print dialog: Cosmetics
Some minor cleanups.
2023-09-30 21:30:22 -04:00
Matthias Clasen
5ced6be416 printjob: Work with non-seekable fds
We want to pass a pipe fd in the future,
and those aren't seekable.
2023-09-30 21:30:22 -04:00
Matthias Clasen
bbda833b01 demos: Cosmetics 2023-09-30 21:30:15 -04:00
Jonas Ådahl
c86bc00330 Merge branch 'master' into 'main'
GdkSurface: prevent popups from appearing offscreen in edge cases

See merge request GNOME/gtk!5320
2023-09-30 15:03:33 +00:00
Matthias Clasen
68755c0fd2 Post-release version bump 2023-09-28 10:49:46 -04:00
Matthias Clasen
9090c28125 4.13.1 2023-09-28 09:50:16 -04:00
Matthias Clasen
3a3244891e Merge branch 'wip-print-dialog' into 'main'
wip: print dialog api

See merge request GNOME/gtk!5484
2023-09-28 01:18:26 +00:00
Matthias Clasen
b55117334c gtk-demo: Add a print dialog 2023-09-27 20:50:52 -04:00
Matthias Clasen
02e5c7b9ad Add a print dialog
Add a simplified print api that only supports
printing preexisting pdf content. For now, it
only has a portal implementation.
2023-09-27 20:50:52 -04:00
Matthias Clasen
7268167f4c Merge branch 'matthiasc/for-main' into 'main'
print portal: Report errors properly

See merge request GNOME/gtk!6441
2023-09-27 21:52:13 +00:00
Matthias Clasen
93c7502cf7 printer: Add private search api 2023-09-27 17:37:11 -04:00
Matthias Clasen
789705cfe4 print portal: Report errors properly
The portal printoperation inmplementation
relies on the file printbackend to be available.
If it isn't, we should report a proper error
status insetad of running into assertions deep
inside the printoperation code.
2023-09-27 17:33:34 -04:00
Emmanuele Bassi
741471a1f8 Merge branch 'michaelweghorn/a11y_add_paragraph_role' into 'main'
a11y: Add paragraph role

See merge request GNOME/gtk!6432
2023-09-27 12:20:19 +00:00
Matthias Clasen
f8da751cc2 Merge branch 'wip/chergert/rendernode-type-checks-for-refcount' into 'main'
gsk: remove excessive type checking within GSK

See merge request GNOME/gtk!6439
2023-09-27 12:12:18 +00:00
Matthias Clasen
8174842d9f Merge branch 'wip/chergert/rendernode-type-check' into 'main'
gsk/gl: remove TypeNode conformity checking for renderjob

See merge request GNOME/gtk!6438
2023-09-27 12:10:52 +00:00
Matthias Clasen
e872952f36 Merge branch 'mcatanzaro/#6122' into 'main'
printoperation: fix case where operation may complete multiple twice

Closes #6122

See merge request GNOME/gtk!6437
2023-09-27 10:37:23 +00:00
Christian Hergert
b010e46d13 gsk/gl: remove TypeNode conformity checking for renderjob
We don't need to be calling type node conformity checking from the tight
loop of the renderjob. Hoist that into the private header and use that
intead through via the Class pointer.
2023-09-26 18:36:56 -07:00
Christian Hergert
eb646a8e8b gsk: remove excessive type checking within GSK
Anything that includes gskrendernodeprivate.h will get an alternate form
of ref/unref for render nodes which does not need to do type checking on
the parameter. We can expect that things are correct within GTK itself and
this saves excessive amounts of TypeNode conformities checking.
2023-09-26 18:28:34 -07:00
Michael Catanzaro
1e2975147d printoperation: fix some strange line spacing 2023-09-26 19:28:12 -05:00
Michael Catanzaro
653c10e8b6 printoperation: add some assertions
Let's assert that we schedule the idle callback exactly once.

These assertions are not perfect because if the callback executes before
we schedule it, then the assertion itself would be a use-after-free,
since I'm using the PrinterFinder to track whether the callback that
frees it has been scheduled. But in practice when using loupe's print
dialog, I was noticing the callback scheduled twice before it was
executed. The assertion would have caught this problem.
2023-09-26 19:25:41 -05:00
Michael Catanzaro
dfbafdf047 printoperation: fix another case where operation may complete twice
This is a little tricky. At first, I thought we had a codepath where we
fail to schedule the idle that completes the print operation: if we take
the gtk_print_backend_printer_list_is_done path for each printer
backend, then printer_list_done_cb() is never executed and we never
schedule the idle. But in fact, in this case, then backends == NULL at
the bottom of find_printer(), and we'll schedule the idle there, so it's
OK. Except it's not really OK, because we'll schedule it even if a
printer was already found, resulting in the callback completing twice
and a double free.

Simplify this. Schedule the idle in find_printer() only if there are
*initially* no backends, not also if all backends are immediately ready
and already removed from consideration. Instead, always call
printer_list_done_cb() for every backend in find_printer_init(). After
the previous commit, printer_list_done_cb() will schedule the idle when
appropriate.

printer_list_done_cb() additionally disconnects signals that we did not
connect in this codepath, but it does so using
g_signal_handlers_disconnect_by_func, which is harmless. Otherwise, the
only extra work it's doing is scheduling the idle, and that's exactly
what find_printer_init() is missing.
2023-09-26 19:08:46 -05:00
Michael Catanzaro
d8c821a851 printoperation: fix case where operation may complete multiple twice
If we are the final backend, then after removing ourselves there is no
backend remaining. We will schedule the idle even if it has already been
scheduled. This idle is required to run exactly once and executing it
twices results in a double free that crashes loupe when printing. It
also causes the user callback to execute twice, which could cause
similar problems.

Fixes #6122
2023-09-26 18:47:01 -05:00
Matthias Clasen
83376648d7 Merge branch 'wip/chergert/fix-clips-uaf' into 'main'
Fix potential UAF in renderjob clipping

See merge request GNOME/gtk!6436
2023-09-26 21:59:56 +00:00