Compare commits

...

1008 Commits

Author SHA1 Message Date
Matthias Clasen
21103ad811 4.6.3 2022-04-21 20:58:13 -04:00
Matthias Clasen
6e5573f5bb theme: Fix vertical spin button selection
The selection should be black-on-blue as it is
everywhere else now. This was just a leftover.

Fixes: #4788
2022-04-21 19:28:14 -04:00
Emmanuele Bassi
e17d51df66 Quench the anger of GCC
Direct access of the fields of the union trips compiler warnings with
GCC 12, such as:

  ../gtk/gtkimagedefinition.c:135:13: error: array subscript
  ‘GtkImageDefinition {aka union _GtkImageDefinition}[0]’ is partly
  outside array bounds of ‘GtkImageDefinitionEmpty[1]’ {aka
  ‘struct _GtkImageDefinitionEmpty[1]’} [-Werror=array-bounds]
2022-04-21 19:27:48 -04:00
Matthias Clasen
01f63c87b2 Fix file filter buildable support
File filters creates from ui files had some
extraneous gunk in them. Fix that. Test included.

Fixes: #4787
2022-04-21 19:27:37 -04:00
Marcel Tiede
e449bd8459 docs: Fix typo in description of GtkExpression 2022-04-21 19:27:26 -04:00
Alexander Mikhaylenko
edb69f0bb3 scrolledwindow: Pick up gtk-overlay-scrolling changes on the fly 2022-04-21 19:26:25 -04:00
Alexander Mikhaylenko
cf48d15c2c scrolledwindow: Fix :kinetic-scrolling setter 2022-04-21 19:26:17 -04:00
Alexander Mikhaylenko
7cc49ba288 tooltipwindow: Don't restrict minimum tooltip label length
We only care about wrapping at that length, we still want short tooltips
for short labels.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3741
2022-04-21 19:26:03 -04:00
Alexander Mikhaylenko
6809a78321 tooltipwindow: Remove a duplicate gtk_widget_class_set_css_name() call 2022-04-21 19:25:52 -04:00
Emmanuele Bassi
c1002b20ee Mark nullable arguments in GtkPaned
The set_start_child() and set_end_child() methods take NULL for the
child argument, as a way to remove the child from the paned widget.
2022-04-21 19:25:42 -04:00
Emmanuele Bassi
fdf3ae31c6 docs: Fix the GtkPaned style
Use proper links to properties and methods, and drop gtk-doc'isms.
2022-04-21 19:25:36 -04:00
Julian Sparber
f915c6bb5c label: Move focus out of widget after last link
This allows the user to navigate via tab the links in a label and exits
the widget after the last link, when moving forward, and first link,
when moving backward.

This also ensures that ellipsised links arn't focused.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4681
2022-04-21 19:25:09 -04:00
Julian Sparber
659c1c41de label: Maintain value for has-tooltip for labels with links
The `has-tooltip` property gets set to `false` for label with links if no
link is selected. This makes sure to only change the property to `true`
but never to `false`.
2022-04-21 19:24:59 -04:00
Ivan Molodetskikh
8f2be7e840 scrollable: Clarify when to set adjustment props
Instead of populating the properties right away (when the widget might
not have been allocated yet, and hence cannot know the right values),
the widget should queue an allocation, where it will populate the
values.
2022-04-21 19:24:52 -04:00
Matthias Clasen
14772602a0 gsk/gl: Typo fix 2022-04-21 19:24:41 -04:00
Matthias Clasen
93921f32bd gtk-demo: Small fixup to the cursors demo 2022-04-21 19:24:24 -04:00
Carlos Garnacho
812c8926ec imwayland: Do not defer commit() after set_surrounding_text()
For reasons that only apply to the old serial handling, asking for
the surrounding after IM changes resulted in lazy handling of
commit() afterwards.

With the recent interpretation of serials, this problem became more
apparent, since it is in fact very likely that the last interaction
step after an IM change is notifying of the changed surrounding
text after the IM change was applied.

Make handling of surrounding text similar to caret position changes,
always commit() after the state change, but skip through non-changes.

This makes the compositor state fully up-to-date after an IM change.
2022-04-21 19:24:00 -04:00
Carlos Garnacho
b14bc4749e imwayland: Connect OSK activating gesture to parent widget on editables
The gesture as connected currently on the child GtkText is easily overridden
by the parent editables (and gently done so in the attempt to consume all
clicks).

Connect this gesture to the parent editable widget in these cases, so the
gesture can cohabit with the click-consuming one. It's not part of the same
group, but it won't be abruptly cancelled.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4795
2022-04-21 19:23:48 -04:00
Sebastian Keller
d56276f6d6 testsuite: Add unaligned-offscreen test
Tests whether text rendered to an offscreen node unaligned with the
pixel grid introduces blurriness.
2022-04-21 19:23:13 -04:00
Sebastian Keller
f1d44635bd gsk/gl: Always align offscreen rendering with the pixel grid
This fixes two issues with the offscreen rendering code for nodes with
bounds not aligned with the pixel grid:

1.) When drawing to an offscreen buffer the size of the offscreen buffer
was rounded up, but then later when used as texture the vertices
correspond to the original bounds with the unrounded size. This could
then result in the offscreen texture being drawn onscreen at a slightly
smaller size, which then lead to it being visually shifted and blurry.

This is fixed by adjusting the u/v coordinates to ignore the padding
region in the offscreen texture that got added by the size increase from
rounding.

2.) The viewport used when rendering to the offscreen buffer was not
aligned with the pixel grid for nodes at coordinates not aligned with
the pixel grid. Then because the content of the offscreen buffer is not
aligned with the pixel grid and later when used as textures sampling
from it will result in interpolated values for an onscreen pixel. This
could also result in shifting and blurriness, especially for nested
offscreen rendering at different offsets.

This is fixed by adding similar padding at the beginning of the
texture and also adjusting the u/v coordinates to ignore this region.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3833
2022-04-21 19:23:06 -04:00
Maximiliano Sandoval R
de8cb17ee8 application: Add link and inline code blocks 2022-04-21 19:22:38 -04:00
Maximiliano Sandoval R
e69eb24b32 filter: Add link to FilterListmodel 2022-04-21 19:22:33 -04:00
Maximiliano Sandoval R
4a388b5540 texttag: Correct typo
Does not generate a gir docstring without it.
2022-04-21 19:22:27 -04:00
Matthias Clasen
25bedcd85d inspector: Avoid another crash
We need to handle all event types here.
This was tripping over GDK_TOUCHPAD_HOLD events.
2022-04-21 19:20:10 -04:00
Matthias Clasen
feb3d3b274 inspector: Avoid a crash
Attribute lists can be NULL, it turns out.
2022-04-21 19:19:45 -04:00
Matthias Clasen
e191519d30 css: Plug a memory leak
We were leaking the terms of calc values. Oops.
2022-04-21 19:19:33 -04:00
illiliti
aa1921cbef meson: Use proper type for bools
Fix invalid usage of bools which violates official meson specification and thus
breaks muon, an implementation of meson written in C.
2022-04-21 19:18:55 -04:00
Matthias Clasen
e2abb0211c imcontextsimple: Plug a memory leak 2022-04-21 19:18:34 -04:00
Maximiliano Sandoval R
b024c9a743 docs: Fix links in selection models 2022-04-21 19:18:25 -04:00
Xavier Claessens
91c60dcac0 Remove #ifdef ENABLE_NLS
libintl API is guaranteed to always be available, glib will fallback to
proxy-libintl in case gettext is not found.
2022-04-21 19:18:00 -04:00
Dr. David Alan Gilbert
66117d1017 x11: Check return of gdk_x11_get_xatom_name_for_display
When given an invalid atom, gdk_x11_get_xatom_name_for_display can
return NULL and trigger a seg in gdk_x11_clipboard_formats_from_atoms.
Check for NULL.

Why I'm seeing a bad atom there is probably a separate question.
https://bugzilla.redhat.com/show_bug.cgi?id=2037786
2022-04-21 19:17:54 -04:00
Chun-wei Fan
177302cf4d inspector/general.c: Check whether GL context supports WGL
We may well be using an EGL context that does not support Desktop (W)GL on
Windows, such as in the case of using libANGLE.  So, check whether WGL is
supported for this running instance before trying to query WGL extensions.

This will get rid of warning messages from libepoxy.
2022-04-21 19:16:13 -04:00
Alexander Mikhaylenko
d1fc90e8a2 eventcontrollerscroll: Always propagate hold events
Otherwise a stray scroll controller may prevent others from getting hold
events, even if it always propagates scroll events and does absolutely
nothing.
2022-04-21 19:15:58 -04:00
Christoph Reiter
da152ac37e CI: clean up MSYS2 build dependencies
We only need a C compiler and not the whole toolchain,
and gst-plugins-bad was split into libraries and plugins.
pkg-config -> pkgconf.

This should speed the CI setup up a bit.
2022-04-21 19:15:52 -04:00
Matthias Clasen
29d4821e3d inspector: Allow viewing PangoAttrList properties
We have pango_attr_list_to/from_string, so this is
easy. The editing UI isn't ideal, but it solves my
immediate need to see attributes.
2022-04-21 19:15:20 -04:00
Christian Hergert
cbd03cda56 gdk/gl: handle GL_RGBA/GL_UNSIGNED_NORMALIZED
WebKit's GTK 4 port can give us textures with an internal format of
GL_RGBA with GL_UNSIGNED_NORMALIZED and a bit-depth of 8. This fixes
warnings for every GdkGLTexture created/delivered to the GskGLRenderer.

The format is essentially the same as GL_RGBA8 since it is normalized
between 0.0..1.0 for 8-bit components.

Fixes #4783
2022-04-21 19:15:05 -04:00
Sebastian Keller
018bbd6774 surface: Use correct display when destroying a surface for depth switch
When surface depth switches from non-high-depth to high-depth (or vice
versa) the current surface has to be destroyed before a new one can be
created for this window. eglDestroySurface however was getting passed a
GdkDisplay, rather than the EGLDisplay it expects. As a result the old
surface did not get destroyed and the new surface could not be created
causing rendering to freeze.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4773
2022-04-21 19:14:32 -04:00
Christian Hergert
e50e2136d2 Default: avoid use of opacity for overlay scrollbars
If using the opacity CSS property the renderer cannot optimize these
handles without the use of offscreens due to the use of both a border
and rgb render node.

Instead, we can apply the alpha to the color values and get the same
effect in a way that the GL renderer can optimize without the use of
offscreen textures for a sizeable reduction in runtime overhead.
2022-04-21 19:14:14 -04:00
Yosef Or Boczko
a5eeb99f37 popover-menu: Fix buttons' position in RTL
The radio/check/previous buttons shows in
the wrong place in RTL. Fix it.

#4641

Signed-off-by: Yosef Or Boczko <yoseforb@gmail.com>
2022-04-21 19:14:03 -04:00
aneejit1
52cb3b2ec4 Check for 'rst2man' misses installed 'rst2man.py' (#4728)
By default, 'docutils' installs 'rst2man' as 'rst2man.py'. Amend the
check for 'rst2man' to look for 'rst2man.py' as well if 'rst2man' is
not found.
2022-04-21 19:13:54 -04:00
Matthias Clasen
9ca55cb5bf Merge branch 'cherry-pick-b67da389' into 'gtk-4-6'
Backport: gtkimmulticontext: Handle switches between displays

See merge request GNOME/gtk!4660
2022-04-20 15:35:21 +00:00
Carlos Garnacho
bc4b2c142f gtkimmulticontext: Handle switches between displays
Currently the GtkIMMultiContext may stick to a delegate GtkIMContext
that no longer applies after the multicontext is dissociated from
any widget.

Handle set_client_widget() so that it can handle changes between
widgets from 2 different display, but also so the delegate is made
NULL whenever the context has a NULL widget.

Doing so, any new client widget results in a new delegate IM context
lookup from the right GdkDisplay and GtkSettings, which avoids any
mix up.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4805


(cherry picked from commit b67da38916)
2022-04-20 14:54:04 +00:00
Matthias Clasen
b65d7c86d7 Merge branch 'filechooser-fixes-4-6' into 'gtk-4-6'
filechooser: cherry-pick fixes from main for 4.6

See merge request GNOME/gtk!4654
2022-04-20 01:34:51 +00:00
Matthias Clasen
cc37c9c86c Merge branch 'ebassi/issue-4825-backport' into 'gtk-4-6'
a11y: Defer object registration after root registration

See merge request GNOME/gtk!4658
2022-04-20 01:30:51 +00:00
Emmanuele Bassi
e41a4ced8b a11y: Defer object registration after root registration
The root accessible object is registered asynchronously, as it needs to
call a method on the AT-SPI registry daemon. This means we need to defer
registering the GtkAtSpiContext on the accessibility bus and in the
cache until after the registration is complete.

Fixes: #4825
2022-04-19 22:05:46 +01:00
Matthias Clasen
eb2699aa9f filechooser: Small fix for save mode
When changing folders, we were making the select
button insensitive when there's no files around.
That doesn't make sense in save mode when we don't
want to select a file but create one.

Fixes: #4851
2022-04-19 13:51:44 +02:00
Matthias Clasen
fcab393c3b filechooser: Prevent random completion popups
It is very irritating when the entry completion popup
appears not in response to user input in the entry.
In particular, when that happens right as the dialog
is shown.

To prevent that, temporarily disable completion
when setting the entry text programmatically.
2022-04-19 13:49:31 +02:00
Luca Bacci
8a6de521e7 Merge branch 'gdk-win32-fix-mouse-move-crossing-events-gtk-4-6' into 'gtk-4-6'
GdkWin32: Mouse events fixes

See merge request GNOME/gtk!4627
2022-04-08 13:58:29 +00:00
Luca Bacci
88db5509a3 GdkWin32: Generate crossing event after button release
Fixes #4813
2022-04-08 15:26:48 +02:00
Luca Bacci
7538ff9798 GdkWin32: Correct generation of crossing events when holding an implicit grab
Fixes #4722
2022-04-08 15:26:37 +02:00
Luca Bacci
c0a60ece97 GdkWin32: Report serial for events 2022-04-08 15:26:26 +02:00
Luca Bacci
c799b05f2a Merge branch 'backport-4406-4.6' into 'gtk-4-6'
gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote() (backport MR !4604 to gtk-4-6)

See merge request GNOME/gtk!4608
2022-04-08 08:30:48 +00:00
Christian Hergert
d468dd2f3b Merge branch 'sumibi-yakitori/fix-minimize-window-macos' into 'main'
macos: Fix problem that window cannot be minimized by user operation

Closes #4811

See merge request GNOME/gtk!4613

(cherry picked from commit d75147db0a)

d3cf7088 macos: Skip running `showAndMakeKey` when a window is minimized by user action
2022-04-04 18:53:35 +00:00
Christian Hergert
029fc0fdef Merge branch 'sumibi-yakitori/fix-maximize-window-macos' into 'main'
macos: prohibit fullscreen transition if in transtion

This prevents performing additional fullscreen transitions while
a transition is already in progress.

Closes #4808

See merge request GNOME/gtk!4612

(cherry picked from commit 15b7a4572b)

69a0a5cf macos: Prohibit changing the full-screen state of a window during a full-screen transition
229e4b58 macos: Corrected code style
2022-04-03 22:15:16 +00:00
Andika Triwidada
c43737324a Update Indonesian translation 2022-04-01 04:10:57 +00:00
Andika Triwidada
270e643c7b Update Indonesian translation 2022-04-01 04:04:49 +00:00
Chun-wei Fan
edd8d55b42 gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote()
The call to gdk_win32_clipboard_request_contentformats() can return NULL even
without an error condition being hit (such as when the system clipboard is
empty), so check whether the returned GdkContentFormat pointer is not NULL
before calling gdk_clipboard_claim_remote(), which expects it to be not NULL,
otherwise we face a warning from that funtion and the subsequent
g_object_unref().

This at least partially fixes issue #4796.
2022-04-01 10:28:37 +08:00
Rūdolfs Mazurs
3b50f2e8b9 Update Latvian translation 2022-03-27 20:19:10 +00:00
Rūdolfs Mazurs
d4dd7969d6 Update Latvian translation 2022-03-27 19:53:51 +00:00
Emmanuele Bassi
a0bebefef8 Merge branch 'cherry-pick-351ffef7' into 'gtk-4-6'
overlaylayout: Set position style class on child

See merge request GNOME/gtk!4598
2022-03-27 18:24:38 +00:00
António Fernandes
42a4c62025 overlaylayout: Set position style class on child
As documented:
> Overlay children whose alignments cause them to be positioned
> at an edge get the style classes “.left”, “.right”, “.top”, 
> and/or “.bottom” according to their position.

Likely accidental regression in b7ee2cbc28

Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2099

(cherry picked from commit 351ffef704)
2022-03-27 17:50:16 +00:00
Bruce Cowan
dd198cfc06 Update British English translation 2022-03-24 13:19:20 +00:00
Marek Černocký
3ef96c445f Updated Czech translation 2022-03-21 12:16:07 +01:00
Philipp Kiemle
d9c39f6795 Update German translation 2022-03-19 12:32:20 +00:00
Matthias Clasen
aec7ca8200 4.6.2 2022-03-18 20:38:15 -04:00
Matthias Clasen
f567bf62e1 Merge branch 'alatiera/stable-wraps-4-6' into 'gtk-4-6'
meson: use proper handling of wayland-protocols dependency

See merge request GNOME/gtk!4580
2022-03-19 00:37:58 +00:00
James Westman
1f00cdc7a6 filefilter: Fix <suffixes> in buildable
A bug in GtkFileFilter's GtkBuildable implementation caused the
<suffixes> tag not to be recognized.
2022-03-17 16:18:28 -04:00
Jordan Petridis
dc875b6af9 meson: switch some .wrap files to stable branches
To avoid random failures if one of the projects starts
depending on new things or has incompatible changes.
2022-03-17 12:54:58 +02:00
Eli Schwartz
e2873bc614 meson: use proper handling of wayland-protocols dependency
Ensure that resolution of the subproject occurs via the dependency
interface, not the "poke at subprojects manually" interface, and make
that actually work via --wrap-mode=forcefallback.

There's no need to mark it as not-required and then manually invoke
subproject(), since fallback should work correctly and it is always
needed.

However, if fallback was performed (or forced) it would error out since
get_variable() was instructed to only use pkg-config while the relevant
variable was exported by the subproject as an internal fallback
dependency.
2022-03-17 12:54:58 +02:00
Milo Casagrande
3e4bfa2bae Update Italian translation 2022-03-17 08:35:42 +00:00
Milo Casagrande
9bbf09fb0a Update Italian translation 2022-03-17 08:34:04 +00:00
Мирослав Николић
c874f65d95 Update Serbian translation 2022-03-17 06:04:15 +00:00
Matthias Clasen
8a12628af9 Merge branch 'wip/carlosg/backports-4-6' into 'gtk-4-6'
Backport fixes to 4.6

See merge request GNOME/gtk!4577
2022-03-17 01:50:18 +00:00
Matthias Clasen
17e0618ff6 Merge branch 'wip/chergert/for-4-6' into 'gtk-4-6'
backport macOS fixes to gtk-4-6

See merge request GNOME/gtk!4578
2022-03-16 20:03:38 +00:00
Christian Hergert
73d5f7061b macos: exclude popups from window list
This probably only matters if you do window list integration for the global
menu on macOS.
2022-03-16 12:25:10 -07:00
Christian Hergert
ccbaa020ff macos: pass events to foreign windows 2022-03-16 12:25:10 -07:00
Christian Hergert
a9c89fa23e macos: dont steal key window from NSPanel
Or we risk making it really difficult to use native file choosers.
2022-03-16 12:25:10 -07:00
Christian Hergert
36730537cc macos: fix window level for popups
This comment isn't really accurate anymore it seems, so we can start
setting the proper stacking order for popups now.
2022-03-16 12:25:10 -07:00
Christian Hergert
9456f6eea1 macos: fix attachment of popups to parents
We had code to do it and it never actually got used correctly. This ensures
that the popup services are attached to the parents so that they get proper
stacking orders when displayed. Additionally, it fixes popups from being
shown as their own windows in Exposé.
2022-03-16 12:25:10 -07:00
Christian Hergert
2c630a74cd macos: fix window activation during shadow click-through
If we are clicking through the shadow of a window, we need to take special
care to not raise the old window on mouseUp. This is normally done by the
display server for us, so we need to use the proper API that is public to
handle this (rather than CGSSetWindowTags()). Doing so requires us to
dispatch the event to the NSView and then cancel the activcation from
the mouseDown: event there.
2022-03-16 12:25:10 -07:00
Christian Hergert
9462b3fea2 macos: select new key window after processing events
If we closed a key window in response to events, we need to denote another
window as the new key window. This is easiest to do from an idle so that
we don't clobber notification pairs of "did resign"/"did become" key
window.

We have a sorted set of surfaces by display server stacking, so we can
take the first one we come across that is already mapped and re-show it
to become key/main.
2022-03-16 12:25:10 -07:00
Christian Hergert
d62313e75c macos: request layout with server-side decoration
If we have server-side decorations we might need to request a layout in
response to the resize notification. We don't need to do this in other
cases because we already handle that in the process of doing the resize
(and that code is that way because of delayed delivery of NSNotification).
2022-03-16 12:25:10 -07:00
Christian Hergert
023bf9aea7 macos: fix resize when using server-side decorations
If we are using NSWindow titled windows, we don't end up waking up the
frame clock when the window is resized on the display server. This ensures
that we do that after getting a notification of resize.
2022-03-16 12:25:10 -07:00
Christian Hergert
4bc593c761 macos: set main window in addition to key
If we are showing the window, we might also want to make it the main
window for the application when shown.
2022-03-16 12:25:10 -07:00
Christian Hergert
f47e6dda78 macos: make transient-for key window when hiding surface
This only handled the popover case before and not the transient-for case.
2022-03-16 12:25:10 -07:00
Christian Hergert
5c2d9d6f19 macos: actually drop unnecessary momentum events
These would get passed along to the NSApplication which we don't really
need to have happen. Denote it as such.
2022-03-16 12:25:10 -07:00
Christian Hergert
5efa8071d6 macos: queue all pending events
Rather than process these a single event at a time, queue all of the
outstanding events from the NSEvent queue.
2022-03-16 12:25:10 -07:00
Christian Hergert
659832ccab macos: drop enter/exit when in manual drag/resize
If we are in a manual resize/drag then we don't want to generate crossing
events as they can just confuse things.
2022-03-16 12:25:10 -07:00
Christian Hergert
913f6d4a4f macos: allow dropping NSEvent without propagation
There are cases we might want to consume a NSEvent without creating a
GdkEvent or passing it along to the NSApplication for processing. This
creates a new value we can use and check against to propagate that without
having to do out parameters at the slightly odd invalid pointer value for
a GdkEvent (similar to how MMAP_FAILED is done).
2022-03-16 12:25:10 -07:00
Christian Hergert
cb386ec2a2 macos: do not focus new window when resigning main
This can get in the way of how we track changes while events are actively
processing. Instead, we may want to delay this until the next main loop
idle and then check to see if we have a main window as the NSNotification
may have come in right after this.
2022-03-16 12:25:10 -07:00
Christian Hergert
2f873052f9 macos: fix cursor blink time
The value from settings is for the duration of the blink period, not the
timeout. This fixes the blink lasting longer than 10 seconds.
2022-03-16 12:25:10 -07:00
Christian Hergert
60aceb984f macos: require input region to become key
Some things cannot become key windows (like tooltips). We can use the
input_region existence to determine if we should allow it as a key window.
2022-03-16 12:25:10 -07:00
Christian Hergert
9dbd79f2d8 macos: clear window stack before requesting motion
We want to ensure that we recalculate the sort order of windows before
processing the motion. Generally this would be done in response from the
display server in GdkMacosWindow, but I've seen it possible to race there.
2022-03-16 12:25:10 -07:00
Christian Hergert
0aabf47f09 macos: invalidate surface contents when mapping 2022-03-16 12:25:10 -07:00
Christian Hergert
2961cc44c5 macos: move children when monitor changes
We can rely on other code to move monitors, but specifically with children
we want to try harder to move them as a group and keep positioning in tact.
2022-03-16 12:25:09 -07:00
Christian Hergert
46da364289 macos: make move_resize possibly idempotent
We need to handle the case where we might be racing against an incoming
configure event due to how notifications are queued from the display
server. Rather than calling configure (and possibly causing other things
to move around) this just queries the display server directly for the
coordinates that we care about.

Additionally, we can display:NO as we are in control of all the display
process now using CALayer.
2022-03-16 12:25:09 -07:00
Christian Hergert
cb99370ce4 macos: handle transient-for from configure
We failed to handle the toplevel with transient-for case here which could
cause our X/Y calculations to be off in other areas such as best monitor
detection.
2022-03-16 12:25:09 -07:00
Christian Hergert
c2d1a21f9c macos: use parent frame clock again
We do actually need the parent frame clock here because it is the way we
ensure that we get layout called for our popup surfaces at the same time
as the parent surface.
2022-03-16 12:25:09 -07:00
Christian Hergert
edc6790fbb macos: reduce chances for layout cycles
We need to be more careful about when we request a layout because it can
cause us to get into a layout cycle at maximum frame rate.
2022-03-16 12:25:09 -07:00
Christian Hergert
b0d7889b20 macos: improve initial placement of toplevels with parent
This doesn't appear to happen much, but if it does it is nice to setup
the window placement initially. Generally, transient-for is set after
the creation of the toplevel rather than here.
2022-03-16 12:25:09 -07:00
Christian Hergert
867f2de194 macos: leave a note about monitor configuration
It can be helpful to see what the range of monitor values is when emulating
the GDK coordinate system.
2022-03-16 12:25:09 -07:00
Christian Hergert
50e2a8239b macos: use GdkMacosBuffer for storing damage region
The GdkMacosBuffer object already has storage for tracking the damage
region as it is used in GdkMacosCairoContext to manually copy regions from
the front buffer to the back buffer. This makes the GdkMacosGLContext also
use that field so that we can easily drop old damage regions when the
buffer is lost. This happens during resizes, monitor changes, etc.
2022-03-16 12:25:09 -07:00
Christian Hergert
42f9ea07e2 macos: add clamp helper to keep rectangle in workarea
This helper is useful to ensure we are consistent with how we keep a
window clamped to the workarea of a monitor when placing windows on
screen. (This does not affect snap-to-edges).
2022-03-16 12:25:09 -07:00
Christian Hergert
9b28153571 macos: style cleanup 2022-03-16 12:24:12 -07:00
Christian Hergert
2e1e7e7265 macos: add re-entrancy check when monitors change 2022-03-16 12:24:12 -07:00
Christian Hergert
7369ce58da macos: check for best_monitor before using
Make sure we have a monitor to enqueue/dequeue from before using it. That
also allows us to use this from destroy and what-not.
2022-03-16 12:24:11 -07:00
Christian Hergert
c7a6d1e8bf macos: avoid size/origin changes when possible
If _gdk_macos_surface_move_resize() was called with various -1 parameters
we really want to avoid changing anything even if we think we know what
the value might be. Otherwise, we risk messing up in-flight operations that
we have not yet been notified of yet.

This improves the chances we place windows in an appropriate location as
they don't et screwed up before window-manager placement.
2022-03-16 12:24:11 -07:00
Christian Hergert
17b40ca148 macos: start application in foreground
We need to bring the application to the foreground in multiple ways, and
this call to [NSApp activateIgnoringOtherApps:YES] ensures that we become
foreground before the first window is opened. Otherwise we end up starting
applications in the background.

Fixes #4736
2022-03-16 12:24:11 -07:00
Christian Hergert
29d424ef91 macos: add GDK_NOTE when surface changes monitor 2022-03-16 12:24:11 -07:00
Christian Hergert
27e9b87fbd macos: add GDK_NOTE for surface sizing and placement
This can be useful to debug sizing issues with the surface as well as the
"window manager" placement code.
2022-03-16 12:24:11 -07:00
Christian Hergert
f2ac5576c2 macos: leave note about monitor discovery 2022-03-16 12:24:11 -07:00
Christian Hergert
590a1c2f3a macos: external access to display name helpers
These can be handy to print debug information when we don't have a
GdkMacosMonitor to work with.
2022-03-16 12:24:11 -07:00
Christian Hergert
75b186eb62 macos: fix redisplay of GdkPopup
This broke recently during the configure cleanups and also needed to have
the tail directions fixed again.
2022-03-16 12:24:11 -07:00
Christian Hergert
998c787638 macos: fix cairo renderer with double buffering
If we are double buffering surfaces with IOSurface then we need to copy
the area that was damaged in the previous frame to the back buffer. This
can be done with IOSurface but we need to hold the read-only lock so that
we don't cause the underlying IOSurface contents to be invalidated.

Additionally, since this is only used in the context of rendering to a
GdkMacosSurface, we know the life-time of the cairo_surface_t and can
simply lock/unlock the IOSurface buffer from begin_frame/end_frame to have
the buffer flushing semantics we want.

To ensure that we don't over damage, we store the damage in begin_frame
(and copy it) and then subtract it from the next frames damage to determine
the smallest amount we need to copy (taking scale factor into account).

We don't care to modify the damage region to swapBuffers because they
already have the right contents and could potentially fall into another
tile anyway and we'd like to avoid damaging that.

Fixes #4735
2022-03-16 12:24:11 -07:00
Christian Hergert
b2ab0b1fcb macos: add readonly IOSurfaceLock helper
This can be used to lock a surface for reading to avoid causing the
surface contents to be invalidated. This is needed when reading back from
a front-buffer to the back-buffer as is needed when using Cairo surfaces
to implement something similar to BufferAge.
2022-03-16 12:24:11 -07:00
Christian Hergert
b19526489e macos: short-circuit on NSEventPhaseMayBegin
We only need to send a single event in this case, so just short-circuit
instead of trying to return an additional event.
2022-03-16 12:24:11 -07:00
Christian Hergert
856728ea10 macos: support mix-rate monitors
Previously, a single CVDisplayLink was used to drive updates for all
surfaces across all monitors. It used a 'best guess' rate which would
allow for updates across monitors of mixed rates. This is undesirable for
situations where you might have a 144hz monitor as it does not allow for
reaching up to that frame rate.

Instead, we want to use a per-monitor CVDisplayLink which will fire at the
rate of the monitor down to the level of updates we require. This commit
does just that.

When a surface crosses onto a new monitor, that monitor is used to drive
the GdkFrameClock.

Fixes #4732
2022-03-16 12:24:11 -07:00
Christian Hergert
df2fb3b520 macos: use video mode for refresh rate and interval
Using the mode allows better detection of refresh rate and refresh
interval for the CVDisplayLink bridge to GdkFrameClock. Using it can help
ensure that our 144hz displays can actually reach that rather than falling
back to just 60hz.

This will also need future commits to rework the displaylink source to be
per-monitor.
2022-03-16 12:24:11 -07:00
Christian Hergert
48c650c102 macos: send stop event when fingers touch
When the fingers are placed on the touchpad, we get a scroll event with
the phase NSEventPhaseMayBegin. We can use this to synthesize an is_stop
event. This results in the scrolledwindow stopping scroll with stop
gestures.

This can cause another warning as well, however, which should be addressed
from #4730.

Fixes #4733
2022-03-16 12:24:11 -07:00
Christian Hergert
ccf18c239d macos: remove emulated scroll events
We don't appear to actually need the emulated scroll events and they get
in the way of proper scrolling with the touchpad.

Fixes #4734
2022-03-16 12:24:11 -07:00
Christian Hergert
48b408e2c3 macos: do not inherit parents frame clock
Windows can end up on different monitors despite having a parent or
transient-for ancestor. We want them to be driven by the CVDisplayLink
for the best-monitor, and so this needs to be unshared.
2022-03-16 12:24:11 -07:00
Christian Hergert
433de2849d macos: calculate best monitor when changing screens
When we change screens, we can keep track of the best monitor so that we
can use it to register CVDisplayLink callbacks.
2022-03-16 12:24:11 -07:00
Christian Hergert
94deb551aa macos: remove duplicated opaque_region field
This can be relied upon from GdkSurface and we do not need to keep a copy
of it. Just remove it and use the GdkSurface.opaque_region field.
2022-03-16 12:24:11 -07:00
Christian Hergert
9767b3a97e macos: use display id when creating CVDisplayLink
Currently we're using a display link that is for all active displays which
is just the display server trying to find some timings that try to overlap
as many as possible.

That was fine for a prototype, but we really need to do better for
situations with mixed frame rate (such as 60hz and 120hz promotion
displays). Additionally, the 144hz external monitor I have will never
reach 144hz using the current design.

This is just the first step in changing this, but the goal is to have
one of these attached to each GdkMacosMonitor which we can then use to
thaw surfaces specific to that monitor.
2022-03-16 12:24:11 -07:00
Christian Hergert
676e9ab127 macos: move feedback mechanisms into separate file
We will eventually be needing additional feedback from the display server
which would be nice to keep away from the rest of GdkMacosDisplay for
cleanliness sake. Particularly for feedback from mission control and other
environment factors that requires private API for proper integration.
2022-03-16 12:23:34 -07:00
Christian Hergert
5b15bc86a3 macos: fix origin during live resize of titled window
When using server-side-decorations, we need to avoid potential cycles with
compute-size as it may not have the new sizing information yet. We can
just short circuit during "live resize" to get that effect.

Fixes poor window resizing from top-left on titled windows.
2022-03-16 12:23:04 -07:00
Christian Hergert
bad392eb2a macos: restore unfullscreen frame with style mask
This doesn't give us appropriate results if we use the window delegate.
Instead, we need to adjust the frame at the same time we change the
style mask so that we end up in the same location.
2022-03-16 12:23:04 -07:00
Christian Hergert
278f976add macos: fix kinetic scrolling with overshoot
Previously we had issues on macos where the overshoot would keep showing.
To fix this we need to actually use discrete events instead of the
generated deltas from macOS in the scroll wheel case. Additionally, we need
to drop the kinetic momentum events from macOS and rely on the gtk kinetic
events which are already happening anyway. We also need to submit the
is_stop event for the GDK_SCROLL_SMOOTH case when we detect it.

To keep the discrete scroll events correct, we need to alter the hack in
gtkscrolledwindow.c to use the same path as other platforms except for
when a smooth scroll event is in place. In the future, I would imagine that
this falls into the boundary of high-precision scrolling and would share
the same code paths as other platforms.

With all of these in place, kinetic scrolling with overshoot appears the
same on macOS as other platforms.
2022-03-16 12:23:04 -07:00
Christian Hergert
f58ece72cf macos: remove unused code 2022-03-16 12:23:04 -07:00
Christian Hergert
af3f34ca94 macos: create new windows with slight origin offset
When creating new windows, it is better if we create them with a slight
offset to where they were created before so that they are visible to the
user separately from what they might be overshadowing.
2022-03-16 12:22:52 -07:00
Carlos Garnacho
07a5cf4996 gtk/imwayland: Use serial to control outbound messages
Following the text-input protocol changes at
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/115,
use the serial number to have the client push changes to the
zwp_text_input_v3 object only after compositor/client states match.

This specifically is more lenient to compositors pushing multiple
.done events ahead of the client replying to them.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3641
2022-03-16 19:50:21 +01:00
Carlos Garnacho
d808298b68 gtkimcontextwayland: Add native surface offset to input coordinates
We were missing the surface offset (e.g. shadows) at the time of expressing
the text caret location in surface coordinates. Add this offset so the
coordinates are as expected by the compositor.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4668
2022-03-16 19:50:21 +01:00
Guido Günther
108b7025dc wayland: xdg-activation: Don't assume there's a focus surface
Tools like gtk4-launch can't set surface on the activation token so
don't require it. If the compositor requires it we can't do anything
about it anyway. This avoids a critical:

   (gtk4-launch:23497): Gdk-CRITICAL **: 17:07:24.704: gdk_wayland_surface_get_wl_surface: assertion 'GDK_IS_WAYLAND_SURFACE (surface)' failed

Fixes: be4216e051 ("gdk/wayland: Support the xdg-activation wayland protocol")

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2022-03-16 19:50:21 +01:00
Carlos Garnacho
9822d2b6b2 wayland: Use xdg-activation for non-startup initiated focus requests
Currently, we have all the plumbing in place so that GTK consumes the
startup notification ID when focusing a window through the xdg-activation
protocol.

This however misses the case that a window might be requested to be
focused with no startup ID (i.e. via interaction with the application,
not through GApplication or other application launching logic).

In this case, we let the application create a token that will be
consumed by itself. The serial used is that from the last
interaction, so the compositor will still be able to do focus prevention
logic if it applies.

Since we already do have a last serial at hand, prefer xdg-activation
all the way over the now stale gtk-shell focusing support. The timestamp
argument becomes unused, but that is a weak argument to prefer the
private protocol over the standard one. The gtk-shell protocol support
is so far left for interaction with older Mutter.
2022-03-16 19:50:21 +01:00
Guido Günther
a36594e754 print-editor: Use gtk_window_present()
This lets xdg-activation work as otherwise gdk_wayland_surface_focus is
never invoked.
2022-03-16 19:50:21 +01:00
Guido Günther
c331e22f3a demo: Use gtk_window_present()
This lets xdg-activation work as otherwise gdk_wayland_surface_focus is
never invoked.
2022-03-16 19:50:21 +01:00
Guido Günther
d077f113b2 widget-factory: Use gtk_window_present()
This lets xdg-activation work as otherwise gdk_wayland_surface_focus is
never invoked.
2022-03-16 19:50:21 +01:00
Guido Günther
1ab89b3908 wayland: Keep startup_notification_id around long enough
When using xdg_activation we need to keep the id around until we send
the first activate to signal succesful startup.
2022-03-16 19:50:21 +01:00
Guido Günther
c5da579cda window: Make sure we call gdk_wayland_surface_focus
When using xdg_activation this is responsible for submitting
the activation token / startup id to the compositor.
2022-03-16 19:50:21 +01:00
Matthias Clasen
38bbcb7411 gtk-builder-tool: Operate without display
The simplify and validate commands can function
without a display connection, only preview absolutely
needs one. Allow this, by using gtk_init_check().
2022-03-15 22:08:01 -04:00
Matthias Clasen
3223f3e3b8 build: Avoid objcopy on arm
The trickery we do with objcopy and ld to speed up
resource inclusion does not seem to work right on
32bit Arm, so just skip it there.

Fixes: #4757, #4748, #4752
2022-03-15 22:07:52 -04:00
Matthias Clasen
ba885e2ace Apply 1 suggestion(s) to 1 file(s) 2022-03-15 22:07:35 -04:00
Fina Wilke
9cc051ffa5 gtkplacessidebar: Prevent calling g_object_unref on null
g_object_unref would be called on a null end_icon when provider_account_status
is CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE
2022-03-15 22:07:20 -04:00
Ting-Wei Lan
e8dd40ccca build: Don't use ld and objcopy when cross-compiling
These commands don't work when compiling Windows binaries on Linux.
2022-03-15 22:06:30 -04:00
Caolán McNamara
53263d3d27 fix docs for gtk_accessible_update_relation example 2022-03-15 22:06:04 -04:00
Sebastien Bacher
71c935d1f4 Use the correct name for installed gdk tests 2022-03-15 22:05:31 -04:00
Matthias Clasen
5e07e216d3 Fix a documentation typo
It is XDG_DATA_HOME.

Fixes: #4747
2022-03-15 22:05:22 -04:00
Matthias Clasen
88894b705b Fix up preconditions of gsk_gl_shader_node_new
These were not quite right, and implied that args
may be NULL, when it really can't.

Fixes: #4739
2022-03-15 22:05:14 -04:00
Emmanuel Gil Peyrot
b8d01bf041 gdk: Add a rgb8 → rgba8 conversion macro
This one can be used for both premultiplied and non-premultiplied alpha
formats, since alpha is always 255.  It is useful for opaque PNG upload
on both cairo and GL renderers.
2022-03-15 22:05:00 -04:00
Emmanuel Gil Peyrot
c636ea036a gdk: Make the optimized premultiply function a macro
That way, all permutations are possible.  Previously it was only useful
in the cairo renderer, which required rgba8 → premultiplied bgra8, while
the GL renderer required rgba8 → premultiplied rgba8.  Now both are
available.
2022-03-15 22:04:52 -04:00
Emmanuel Gil Peyrot
08099ed17d gdk: Remove pixel format conversion ARM intrinsics
This was only useful when building for AArch32 without -mfpu=neon, on
AArch64 or with -mfpu=neon gcc is smart enough to do the auto-
vectorisation, leading to code almost as good as what I wrote in
1fdf5b7cf8.
2022-03-15 22:04:44 -04:00
Christian Hergert
f0e8ee3c29 gdk: use EGL_KHR_swap_buffers_with_damage
It appears that NVIDIA does not implement EGL_EXT_swap_buffers_with_damage
on their EGL implementation, but does implement the KHR variant of it.
This checks for a suitable implementation and stores a pointer to the
compatible implementation within the GdkGLContextPrivate struct.
2022-03-15 22:04:30 -04:00
Bilal Elmoussaoui
33a1cf203e headerbar: Fix docs 2022-03-15 22:04:23 -04:00
Matthias Clasen
5adce748cb text: Stop blinking when we lose focus
We were looking at GtkWidget:has-focus from
event controller signal handlers here, but
the widget property is only changed after
the event controllers.
2022-03-15 22:03:50 -04:00
Matthias Clasen
21d39b6054 focus controller: Update for active window
When the window gains or looses active status,
update the focus controllers status.
2022-03-15 22:03:42 -04:00
Matthias Clasen
a2f30ac1ab window: Update has-focus property
Update the :has-focus property of the focus
widget when the active status of the window
changes.

We change the property after generating the
GDK_CROSSING_ACTIVE crossing events.
2022-03-15 22:03:34 -04:00
Carlos Garnacho
3764b27bab gtkscrolledwindow: Do not try to doubly trigger deceleration
This may come from different sources at around the same time, e.g.
a hold gesture while on overshoot. Avoid doing that if an
animation is already set.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4730
2022-03-15 22:02:45 -04:00
Rico Tzschichholz
8fb610915c gdk: Add missing out annotation on gdk_content_deserialize_finish 2022-03-15 22:01:19 -04:00
Benjamin Otte
16a7e3e3d8 listview: Fix return_if_fail()s 2022-03-15 22:00:58 -04:00
Benjamin Otte
47ea51efab flattenlistmodel: Fix indentation 2022-03-15 22:00:47 -04:00
Benjamin Otte
50554bb92b renderers: Handle large viewports
When large viewports are passed to gsk_renderer_render_texture(), don't
fail (or even return NULL).

Instead, draw multiple tiles and assemble them into a memory texture.

Tests added to the testsuite for this.
2022-03-15 22:00:39 -04:00
Christoph Reiter
0ea0fc9c7b CI: disable debug for MSVC
CI currently fails with "fatal error LNK1318: Unexpected PDB error; OK (0) ''"
Google tells me it might be related to hitting a memory limit. Let's try
disabling debug for now.
2022-03-15 22:00:30 -04:00
Luca Bacci
206e837dde Fix last error reporting when calling GetClipboardOwner
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1402
2022-03-15 22:00:10 -04:00
Matej Urbančič
f43d0365dd Update Slovenian translation 2022-03-15 21:27:06 +00:00
Kjartan Maraas
72a557087c Update Norwegian Bokmål translation 2022-03-15 15:26:33 +00:00
Мирослав Николић
b59f9b97f3 Update Serbian translation 2022-03-15 06:33:22 +00:00
Christian Kirbach
a1f4735652 Update German translation 2022-03-13 22:08:50 +00:00
Balázs Úr
c5e372490d Update Hungarian translation 2022-03-13 00:25:05 +00:00
Baurzhan Muftakhidinov
78e083b014 Update Kazakh translation 2022-03-12 16:34:02 +00:00
Baurzhan Muftakhidinov
6ac723321f Update Kazakh translation 2022-03-12 13:23:19 +00:00
Anders Jonsson
343b08f3e6 Update Swedish translation 2022-03-12 11:39:05 +00:00
Dušan Kazik
c8d1f23ff5 Update Slovak translation 2022-03-11 07:43:53 +00:00
Balázs Úr
8a7fd71697 Update Hungarian translation 2022-03-11 01:08:54 +00:00
Yosef Or Boczko
39fcfa4473 Update Hebrew translation 2022-03-10 18:42:34 +00:00
Jiri Grönroos
d188c6dbaf Update Finnish translation 2022-03-09 19:03:37 +00:00
Marek Černocký
8aec0dc200 Fixed Czech translation 2022-03-09 19:07:33 +01:00
Anders Jonsson
9053fd8335 Update Swedish translation 2022-03-09 10:49:50 +00:00
Danial Behzadi
a9720259f0 Update Persian translation 2022-03-08 15:00:39 +00:00
Ask Hjorth Larsen
b012886294 Updated Danish translation of gtk-properties 2022-03-08 01:21:58 +01:00
Ask Hjorth Larsen
5de26c684b Updated Danish translation 2022-03-08 01:21:58 +01:00
Aurimas Černius
b1d9259e7d Updated Lithuanian translation 2022-03-07 18:29:36 +02:00
Luna Jernberg
89bba41fd7 Update Swedish translation 2022-03-07 08:09:32 +00:00
Luming Zh
248d7ec93c Update Chinese (China) translation 2022-03-05 23:45:12 +00:00
Jordi Mas i Hernandez
2be2912e43 Update Catalan translation 2022-03-04 21:40:27 +00:00
Changwoo Ryu
2755ad19be Update Korean translation 2022-03-04 14:20:21 +00:00
Changwoo Ryu
156f99560d Update Korean translation 2022-03-03 12:46:34 +00:00
Daniel Mustieles
159e9de034 Updated Spanish translation 2022-03-03 11:45:15 +01:00
Luca Bacci
f679b0648b Merge branch 'backport-mr-4506-to-gtk-4-6' into 'gtk-4-6'
GdkWin32: Configure as needed when going fullscreen

See merge request GNOME/gtk!4547
2022-03-03 10:09:38 +00:00
Luca Bacci
f1ffa6eae9 Merge branch 'backport-mr-4531-to-gtk-4-6' into 'gtk-4-6'
gdkkeys-win32: Only perform substitution as last-resort

See merge request GNOME/gtk!4546
2022-03-03 09:33:27 +00:00
Luca Bacci
ec1b61494f GdkWin32: Configure as needed when going fullscreen
Apply the fixes made by Chun-Wei Fan in [1] also for fullscreening /
unfullscreen. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4631

Also set the SWP_FRAMECHANGED flag as written by Raymond Chen in "How
do I switch a window between normal and fullscreen?" [2]

> An important flag to pass here is SWP_FRAME­CHANGED, which tells
> the window manager to recalculate the window decorations (which we
> need it to do because we just changed them).

References:
[1] - https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3712
[2] - https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353
2022-03-03 10:01:41 +01:00
Philip Zander
cc561915b7 gdkkeys-win32: Only perform substitution as last-resort
Instead of performing keyboard layout substitution whenever we find a matching
entry in the registry, first try to load the original layout and only attempt
substitution when that fails.

See #4724
2022-03-03 09:59:53 +01:00
Aleksandr Melman
15707acb82 Update Russian translation 2022-03-02 19:29:31 +00:00
Emin Tufan Çetin
a8ce293bfc Update Turkish translation 2022-03-02 13:05:48 +00:00
Goran Vidović
4eee322654 Update Croatian translation 2022-03-01 13:04:47 +00:00
Goran Vidović
67ae05d855 Update Croatian translation 2022-03-01 12:53:52 +00:00
Marek Černocký
5c535517b5 Updated Czech translation 2022-03-01 12:07:36 +01:00
Rafael Fontenelle
ded6bc04ff Update Brazilian Portuguese translation 2022-02-28 14:46:55 +00:00
Fran Dieguez
3e8179c66e Update Galician translation 2022-02-27 22:45:33 +00:00
Asier Sarasua Garmendia
3c21d6bf92 Update Basque translation 2022-02-27 08:05:18 +00:00
Hugo Carvalho
4c7af43eb3 Update Portuguese translation 2022-02-26 18:09:30 +00:00
Yuri Chornoivan
5ce96d5f3b Update Ukrainian translation 2022-02-26 13:05:23 +00:00
Piotr Drąg
6b61cd1869 Update Polish translation 2022-02-26 13:29:19 +01:00
Christian Hergert
9bbf5966d3 macos: fix positioning of popover tails
This broke with the previous fixes for initial window positioning. We need
the initial positioning so that tails will be displayed correctly when the
popover surface is displayed.
2022-02-25 10:51:19 -05:00
Matthias Clasen
bcb6cf04ed Merge branch 'wip/chergert/macos-window-manager' into 'main'
macos: improve placement of windows

See merge request GNOME/gtk!4510
2022-02-23 03:53:33 +00:00
Matthias Clasen
c9dbb30aff Merge branch 'ebassi/docs-related' into 'main'
docs: Split dependencies from related libraries

See merge request GNOME/gtk!4474
2022-02-23 03:28:47 +00:00
Matthias Clasen
2c88797195 Merge branch 'wip/chergert/macos-iosurface' into 'main'
macos: modernize rendering with CALayer and IOSurface

See merge request GNOME/gtk!4477
2022-02-23 03:10:43 +00:00
Christian Hergert
89a351fd66 macos: improve placement of windows
This does some very basic window management so that we place surfaces in
locations where they can actually be interacted with correctly.
2022-02-22 18:43:46 -08:00
Christian Hergert
e1d3d01e2f macos: update CGL context when surface resizes 2022-02-22 13:15:25 -08:00
Christian Hergert
76a58c40db macos: force pixel format without depth/stencil
We don't need either depth or stencil buffers, so we want a pixel format
without them so that things like glClear() can do less work.
2022-02-22 13:09:30 -08:00
Yosef Or Boczko
3b0ceeb09a Update Hebrew translation 2022-02-22 20:22:59 +00:00
Danial Behzadi
f95e082186 Update Persian translation 2022-02-22 20:08:03 +00:00
Christian Hergert
df8e2bc0a0 macos: only invalidate tiles when size changes
If the size changes, we need to relayout the tiles. Otherwise we can keep
using what we had before. Generally, that shouldn't happen, but the
previous check was failing in a number of ways.
2022-02-22 12:01:29 -08:00
Christian Hergert
42164fa8bb macos: reload IOSurface when monitor configuration changes
We also want to reload buffer contents if the display server changes the
monitor configuration, such as after changing resolution or orientation.
2022-02-22 12:01:29 -08:00
Christian Hergert
6016e17a38 macos: double buffer IOSurface
It looks like, particularly on the M1, we might need to double buffer the
contents of the IOSurface<->OpenGL texture bindings. This doesn't appear
to show up on the Intel macbooks I've tried, but I've seen it in the wild
on an M1.
2022-02-22 12:01:29 -08:00
Christian Hergert
b2de83efcb macos: restore key window after hiding popup
This fixes the focus returning to the parent window after the popup has
been hidden in the form of being a "Key Window" in macOS.
2022-02-22 12:01:29 -08:00
Christian Hergert
493f90499b macos: fix window drag across mixed-scale monitors
If we have a 2x scale laptop with a 1x scale external display, we would
need to create a new IOSurface for the external display once it crosses
a boundary, otherwise we won't have something capable of displaying
correctly on the second monitor.
2022-02-22 12:01:29 -08:00
Christian Hergert
8b71cff71d macos: use CALayer and IOSurface for rendering
This provides a major shift in how we draw both when accelerated OpenGL
as well as software rendering with Cairo. In short, it uses tiles of Core
Animation's CALayer to display contents from an OpenGL or Cairo rendering
so that the window can provide partial damage updates. Partial damage is
not generally available when using OpenGL as the whole buffer is flipped
even if you only submitted a small change using a scissor rect.

Thankfully, this speeds up Cairo rendering a bit too by using IOSurface to
upload contents to the display server. We use the tiling system we do for
OpenGL which reduces overall complexity and differences between them.

A New Buffer
============

GdkMacosBuffer is a wrapper around an IOSurfaceRef. The term buffer was
used because 1) surface is already used and 2) it loosely maps to a
front/back buffer semantic.

However, it appears that IOSurfaceRef contents are being retained in
some fashion (likely in the compositor result) so we can update the same
IOSurfaceRef without flipping as long as we're fast. This appears to be
what Chromium does as well, but Firefox uses two IOSurfaceRef and flips
between them. We would like to avoid two surfaces because it doubles the
GPU VRAM requirements of the application.

Changes to Windows
==================

Previously, the NSWindow would dynamically change between different
types of NSView based on the renderer being used. This is no longer
necessary as we just have a single NSView type, GdkMacosView, which
inherits from GdkMacosBaseView just to keep the tedius stuff separate
from the machinery of GdkMacosView. We can merge those someday if we
are okay with that.

Changes to Views
================

GdkMacosCairoView, GdkMacosCairoSubView, GdkMacosGLView have all been
removed and replaced with GdkMacosView. This new view has a single
CALayer (GdkMacosLayer) attached to it which itself has sublayers.

The contents of the CALayer is populated with an IOSurfaceRef which
we allocated with the GdkMacosSurface. The surface is replaced when
the NSWindow resizes.

Changes to Layers
=================

We now have a dedicated GdkMacosLayer which contains sublayers of
GdkMacosTile. The tile has a maximum size of 128x128 pixels in device
units.

The GdkMacosTile is partitioned by splitting both the transparent
region (window bounds minus opaque area) and then by splitting the
opaque area.

A tile has either translucent contents (and therefore is not opaque) or
has opaque contents (and therefore is opaque). An opaque tile never
contains transparent contents. As such, the opaque tiles contain a black
background so that Core Animation will consider the tile's bounds as
opaque. This can be verified with "Quartz Debug -> Show opaque regions".

Changes to Cairo
================

GTK 4 cannot currently use cairo-quartz because of how CSS borders are
rendered. It simply causes errors in the cairo_quartz_surface_t backend.

Since we are restricted to using cairo_image_surface_t (which happens to
be faster anyway) we can use the IOSurfaceBaseAddress() to obtain a
mapping of the IOSurfaceRef in user-space. It always uses BGRA 32-bit
with alpha channel even if we will discard the alpha channel as that is
necessary to hit the fast paths in other parts of the platform. Note
that while Cairo says CAIRO_FORMAT_ARGB32, it is really 32-bit BGRA on
little-endian as we expect.

OpenGL will render flipped (Quartz Native Co-ordinates) while Cairo
renders with 0,O in the top-left. We could use cairo_translate() and
cairo_scale() to reverse this, but it looks like some cairo things may
not look quite as right if we do so. To reduce the chances of one-off
bugs this continues to draw as Cairo would normally, but instead uses
an CGAffineTransform in the tiles and some CGRect translation when
swapping buffers to get the same effect.

Changes to OpenGL
=================

To simplify things, removal of all NSOpenGL* related components have
been removed and we strictly use the Core GL (CGL*) API. This probably
should have been done long ago anyay.

Most examples found in the browsers to use IOSurfaceRef with OpenGL are
using Legacy GL and there is still work underway to make this fit in
with the rest of how the GSK GL renderer works.

Since IOSurfaceRef bound to a texture/framebuffer will not have a
default framebuffer ID of 0, we needed to add a default framebuffer id
to the GdkGLContext. GskGLRenderer can use this to setup the command
queue in such a way that our IOSurface destination has been
glBindFramebuffer() as if it were the default drawable.

This stuff is pretty slight-of-hand, so where things are and what needs
flushing when and where has been a bit of an experiment to see what
actually works to get synchronization across subsystems.

Efficient Damages
=================

After we draw with Cairo, we unlock the IOSurfaceRef and the contents
are uploaded to the GPU. To make the contents visible to the app,
we must clear the tiles contents with `layer.contents=nil;` and then
re-apply the IOSurfaceRef. Since the buffer has likely not changed, we
only do this if the tile overlaps the damage region.

This gives the effect of having more tightly controlled damage regions
even though updating the layer would damage be the whole window (as it
is with OpenGL/Metal today with the exception of scissor-rect).

This too can be verified usign "Quartz Debug -> Flash screen udpates".

Frame Synchronized Resize
=========================

In GTK 4, we have the ability to perform sizing changes from compute-size
during the layout phase. Since the macOS backend already tracks window
resizes manually, we can avoid doing the setFrame: immediately and instead
do it within the frame clock's layout phase.

Doing so gives us vastly better resize experience as we're more likely to
get the size-change and updated-contents in the same frame on screen. It
makes things feel "connected" in a way they weren't before.

Some additional effort to tweak gravity during the process is also
necessary but we were already doing that in the GTK 4 backend.

Backporting
===========

The design here has made an attempt to make it possible to backport by
keeping GdkMacosBuffer, GdkMacosLayer, and GdkMacosTile fairly
independent. There may be an opportunity to integrate this into GTK 3's
quartz backend with a fair bit of work. Doing so could improve the
situation for applications which are damage-rich such as The GIMP.
2022-02-22 12:01:29 -08:00
Christian Hergert
f9268e8137 gsk/gl: support non-standard default framebuffer
There are situations where our "default framebuffer" is not actually
zero, yet we still want to apply a scissor rect.

Generally, 0 is the default framebuffer. But on platforms where we need
to bind a platform-specific feature to a GL_FRAMEBUFFER, we might have a
default that is not 0. For example, on macOS we bind an IOSurfaceRef to
a GL_TEXTURE_RECTANGLE which then is assigned as the backing store for a
framebuffer. This is different than using gsk_gl_renderer_render_texture()
in that we don't want to incur an extra copy to the destination surface
nor do we even have a way to pass a texture_id into render_texture().
2022-02-22 12:01:24 -08:00
Christian Hergert
b4b282dc81 macos: fix allocation for filechoosernative filter
The GtkFileCHooserNativeQuartz injects a NSComboBox into the NSSavePanel
(which is displayed in a remote process since 10.15 whether or not you are
a sandboxed application). The style has changed and we need more space
here to not clip part of the combobox out of view.

I tried every size from 22 to 30 and this seemed to look the most natural
without skewing the location of the text within the combobox.
2022-02-22 11:53:33 -08:00
Matthias Clasen
d4d328f96f Merge branch 'scale-button-empty-icon-list' into 'main'
Don't crash when updating the icon on a `GtkScaleButton` with a non-`NULL` empty icon list

See merge request GNOME/gtk!4475
2022-02-22 19:39:32 +00:00
Matthias Clasen
553eb55f8a Merge branch 'wip/hadess/app-id-inspector-4' into 'main'
inspector: Show app ID and resource path in the General tab

See merge request GNOME/gtk!4493
2022-02-22 19:37:36 +00:00
Matthias Clasen
9ea43096d4 Merge branch 'wip/chergert/macos-fix-event-filter' into 'main'
macos: improve event filtering for foreign panels

See merge request GNOME/gtk!4495
2022-02-22 19:36:43 +00:00
Matthias Clasen
e9ffe8f212 Merge branch 'wip/chergert/macos-fix-fullscreen' into 'main'
macos: allow windows to enter fullscreen

See merge request GNOME/gtk!4494
2022-02-22 19:36:20 +00:00
Matthias Clasen
931be7d729 Merge branch 'optimise-png-premultiply' into 'main'
gdk: Specialise RGBA8 → premultiplied BGRA8 conversion

See merge request GNOME/gtk!4481
2022-02-22 19:25:41 +00:00
Matthias Clasen
378bb481fa Merge branch 'ebassi/graphene-build-opts' into 'main'
build: Disable graphene tests

See merge request GNOME/gtk!4500
2022-02-22 18:05:14 +00:00
Matthias Clasen
8f83c7e255 Merge branch 'emoji-40' into 'main'
emoji: Update data to CLDRv40 and add more locales

Closes #4568

See merge request GNOME/gtk!4507
2022-02-22 18:04:24 +00:00
Matthias Clasen
3c99b50d2c Merge branch 'wip/chergert/gsk-gl-less-glClear' into 'main'
gsk/gl: avoid clearing opaque regions

See merge request GNOME/gtk!4504
2022-02-22 17:56:40 +00:00
Matthias Clasen
9fccbeaa75 Merge branch 'wip/chergert/macos-fix-backdrop' into 'main'
macos: fix backdrop when displaying popover

See merge request GNOME/gtk!4505
2022-02-22 17:54:20 +00:00
Matthias Clasen
d35bac452b Merge branch 'wip/chergert/macos-fix-toplevel-resize' into 'main'
macos: fix configure, move-resize, and compute-size

See merge request GNOME/gtk!4486
2022-02-22 13:10:34 +00:00
Kévin Commaille
d8c79e91a2 emoji: Add more locales
Based on the locales that are at least 85% translated in Damned Lies:
https://l10n.gnome.org/releases/gnome-41/
Limited by the locales available in emojibase

Closes #4568
2022-02-22 11:28:15 +01:00
Kévin Commaille
7f5a249056 emoji: Update data to CLDR v40
Based on emojibase-data v7.0.1
Contains the changes in Unicode 14.0

https://unicode.org/versions/Unicode14.0.0/
https://cldr.unicode.org/index/downloads/cldr-40
https://github.com/milesj/emojibase/blob/b85382524c/packages/data/CHANGELOG.md
2022-02-22 11:28:15 +01:00
Kévin Commaille
70ce353a58 emoji: Fix the convert-emoji program
The annotation field has been renamed to label in emojibase-data

https://github.com/milesj/emojibase/blob/b85382524c/packages/data/CHANGELOG.md
2022-02-22 11:28:06 +01:00
Christian Hergert
c0ede8d46e macos: fix backdrop when displaying popover
Previously, the popover would cause the window to go into the :backdrop
state which is not what we want for consistency with other platforms. This
fixes that by walking up the surface chain when we get notified of
loosing or acquiring "key" input from the display server.
2022-02-22 00:08:37 -08:00
Luca Bacci
8f02ea39e5 Merge branch 'gdk-win32-implicit-grabs-cleanup' into 'main'
GdkWin32: Remove implicit_grab_surface

Closes #4188

See merge request GNOME/gtk!4503
2022-02-22 07:53:54 +00:00
Luca Bacci
8a8cd4e248 Merge branch 'win32-ime-fix-popup-positioning' into 'main'
Win32 IME: Fix popup positioning

Closes #374 and #2338

See merge request GNOME/gtk!4501
2022-02-22 07:52:59 +00:00
Christian Hergert
08d0575ed0 gsk/gl: avoid clearing opaque regions
If the rendering operation is over an opaque region, we can potentially
avoid clearing a large section of the framebuffer destination. Some cases
you do want to clear, such as when clearing the whole contents as some
drivers have fast paths for that to avoid bringing data back into the
framebuffer.
2022-02-21 23:43:17 -08:00
Luca Bacci
43476c09ed GdkWin32: Remove implicit_grab_surface 2022-02-21 17:38:50 +01:00
Luca Bacci
6123212a68 Win32 IME: Fix popup position 2022-02-21 16:13:06 +01:00
Luca Bacci
6106207b93 Win32 IME: Rename a variable 2022-02-21 15:53:22 +01:00
Luca Bacci
b5036faa2a Win32 IME: Keep track of the client widget 2022-02-21 15:53:13 +01:00
Luca Bacci
56fd3af4d0 Win32 IME: Remove the get_window_position util function
It always returns (0, 0)
2022-02-21 15:49:52 +01:00
Emmanuele Bassi
26beab6064 build: Disable graphene tests
When building Graphene as a subproject we don't really need
to build tests. Disabling tests also removes the dependency
on mutest.
2022-02-21 13:41:40 +00:00
Emmanuele Bassi
f41fe7b8e4 Merge branch 'msvc-cmake-dep' into 'main'
Meson: Use CMake more for finding deps on Visual Studio-like builds

See merge request GNOME/gtk!4499
2022-02-21 13:37:12 +00:00
Luca Bacci
7d6797c9ed Merge branch 'forward-port-mr-775-to-gtk4' into 'main'
gtkimcontextime.c: Fix preedit window placement on HiDPI

See merge request GNOME/gtk!4498
2022-02-21 12:01:21 +00:00
Chun-wei Fan
2e34d62111 meson.build: Use CMake to find libjpeg on MSVC-like builds
One may be using IJG libjpeg or libjpeg-turbo to build GTK, and their
build files may or may not generate pkg-config files for us.  To make
things easier, we can make use of CMake's built-in support for finding
IJG libjpeg or libjpeg-turbo.
2022-02-21 17:53:50 +08:00
Chun-wei Fan
6eda5deeff meson.build: Use CMake to find libtiff on MSVC-like
The CMake build files for libtiff may or may not generate pkg-config
files for us, so we can use Meson's CMake support to help us find
libtiff, as CMake has built-in support for finding libtiff.
2022-02-21 17:53:40 +08:00
Chun-wei Fan
83b98738b6 meson.build: Consolidate items with MSVC-like compilers
Add a variable in meson.build that covers Visual Studio-like compilers,
so that we can use it to help us find depedencies using CMake rather
than via pkg-config, where applicable.

Change the existing use case for finding libpng accordingly.
2022-02-21 17:53:31 +08:00
Emin Tufan Çetin
a07455aa0d Update Turkish translation 2022-02-20 15:04:41 +00:00
Emin Tufan Çetin
49a4d27245 Update Turkish translation 2022-02-20 14:47:56 +00:00
Danial Behzadi
ff59bf356b Update Persian translation 2022-02-20 11:14:09 +00:00
Chun-wei Fan
c6ce05b782 gtkimcontextime.c: Fix preedit window placement on HiDPI
We must also take the scaling factor into account for placing the IME
preedit window that is often used for Chinese and Japanese input on
Windows.
2022-02-19 18:31:28 +01:00
Christian Hergert
db77204a52 macos: improve event filtering for foreign panels
We might have panels with controls in them where the window is running in
another process. The control could have a wrapper window which we would
see from this process. This can happen with the GtkFileChooserNative, but
any NSSavePanel in macOS 10.15+ is out of process (not just sandboxed
applications).
2022-02-18 03:39:52 -08:00
Christian Hergert
4c08d1643f macos: fix configure, move-resize, and compute-size
This significantly cleans up how we handle various move-resize, compute-
size, and configure (notification of changes) in the macOS GDK backend.

Originally when prototyping this backend, there were some bits that came
over from the quartz backend and some bits which did not. It got confusing
and so this makes an attempt to knock down all that technical debt.

It is much simpler now in that the GdkMacosSurface makes requests of the
GdkMacosWindow, and the GdkMacosWindow notifies the GdkMacosSurface of
changes that happen.

User resizes are delayed until the next compute-size so that we are much
closer to the layout phase, reducing chances for in-between frames.

This also improves the situation of leaving maximized state so that a
grab and drag feels like you'd expect on other platforms.

I removed the opacity hack we had in before, because that is all coming
out anyway and it's a bit obnoxious to maintain through the async flows
here.
2022-02-18 02:50:46 -08:00
Christian Hergert
592436503c macos: allow windows to enter fullscreen
This fixes GTK's NSWindow for toplevels so that they are allowed to enter
fullscreen. We were already handlign the state transitions from the
setStyleMask: halper, but we didn't previously tell the window we are
allowed to transition into that.

There is a bit of a mismatch here in that GTK doesn't have any such flag
that determines if a window is "allowed" by policy to enter fullscreen
since window managers on Linux are free to do that at will.
2022-02-18 01:54:10 -08:00
Bastien Nocera
1877bb8a27 inspector: Show app ID and resource path in the General tab
This makes it easier to figure out those values (which are mentioned in
the GtkApplication documentation) rather than working that out from the
way they're generated (or documented as being generated).
2022-02-17 15:14:16 +01:00
Matthias Clasen
67a5120b5b Merge branch 'wip/chergert/macos-gst-cgl' into 'main'
media: support OpenGL-based video playback on macOS

See merge request GNOME/gtk!4491
2022-02-17 13:54:42 +00:00
Matthias Clasen
9d8f56edaa Merge branch 'wip/chergert/macos-fix-popup-input' into 'main'
macos: fix keyboard input on popovers

See merge request GNOME/gtk!4490
2022-02-17 13:53:04 +00:00
Christian Hergert
7ec9c5181d media: support OpenGL-based video playback on macOS
If we have GStreamer on macOS we likely have support for CGL to get an
OpenGL context we can use. This provides the missing pieces to get
accelerated video playback in gtk4-widget-factory working.
2022-02-16 21:31:20 -08:00
Christian Hergert
853ef43dae macos: fix keyboard input on popovers
GdkPopup can also become the "key" window (just not the "main" window).
2022-02-16 17:53:59 -08:00
Emmanuel Gil Peyrot
1fdf5b7cf8 gdk: Optimise RGBA8 → premultiplied BGRA8 for ARM
This more than halves the total runtime of this function since the
previous commit, from 8.36% to 4.02%, and is most likely memory
bandwidth limited on this specific board now.

I tried to do a SSE2 version as well, but couldn’t find any equivalent
of the LD4/ST4 ARM instruction.
2022-02-16 16:36:33 +01:00
Emmanuel Gil Peyrot
0e3ed7a738 gdk: Specialise RGBA8 → premultiplied BGRA8 conversion
On x86 on a Kaby Lake CPU, this makes it go from 6.63% of the total
execution time (loading some PNGs using the cairo backend) down to
3.20%.

On ARM on a Cortex-A7, on the same workload, this makes it go from 57%
to 8.36%.
2022-02-16 16:35:39 +01:00
Matthias Clasen
9c1a66518b Merge branch 'wip/chergert/for-macos-1' into 'main'
macos: various correctness fixes

See merge request GNOME/gtk!4485
2022-02-16 13:54:43 +00:00
Matthias Clasen
280544b874 Merge branch 'wip/baedert/for-master' into 'main'
gtkgstpaintable: Handle a NULL value

See merge request GNOME/gtk!4484
2022-02-16 13:48:51 +00:00
Christian Hergert
3c9687fcf1 macos: add helper to check if surface is opaque 2022-02-16 03:08:55 -08:00
Christian Hergert
f207402228 macos: use input_region to specify tracking areas
We want our tracking area to be limited to the input region so that we
don't pass along events outside of them for the window. This improves the
chances we click-out of a popover with a large shadow.

This still doesn't let us pass-through clicks for large shadows on top-
level windows though.
2022-02-16 03:07:51 -08:00
Christian Hergert
a080f1197a macos: ignore mouse events outside tracking area
We also need to ignore events outside the tracking areas when we are
translating them from NSevent into GdkEvent.
2022-02-16 03:06:51 -08:00
Christian Hergert
8f0b9bf5ae macos: fix incorrect signal disconnect 2022-02-16 01:46:25 -08:00
Timm Bäder
b74d3c2221 gtkgstpaintable: Handle a NULL value
gst_element_factory_make can return NULL.
2022-02-16 10:02:24 +01:00
Benjamin Otte
49b0ee21c1 Merge branch 'wip/otte/for-main' into 'main'
glcontext: Remove leftover function call

Closes #4697

See merge request GNOME/gtk!4483
2022-02-16 03:07:05 +00:00
Benjamin Otte
481634930c glcontext: Remove leftover function call
That call should have been removed way back when.

Add a testcase to make sure this keeps working.

Fixes #4697
2022-02-16 03:48:15 +01:00
Christian Hergert
d58c038fe8 macos: remove assertion from external API
We only should be asserting in static functions. Furthermore, this function
did not need to have GDK_BEGIN_MACOS_ALLOC_POOL as nothing is being
allocated there which would cause pooling to get used.
2022-02-15 12:38:07 -08:00
Christian Hergert
056e9012d2 macos: improve monitor detection at display coordinates
This needs to handle the boundary case where the value is exactly equal
to the edge of a rectangle (which gdk_rectangle_contains_point() does not
consider to be containing). However, if there is a monitor in the list
that is a better match, we still want to prefer it.
2022-02-15 12:38:07 -08:00
Benjamin Otte
82e4690564 Merge branch 'viewport-scroll-to-focus' into 'main'
scrolledwindow: Set scroll-to-focus on viewports

See merge request GNOME/gtk!4356
2022-02-15 16:05:32 +00:00
Maximiliano Sandoval R
8dc2c4b24a viewport: Set scroll-to-focus to TRUE by default
In GTK 3 this was the default.
2022-02-15 16:29:08 +01:00
Christian Hergert
3e913ff16e Merge branch 'mac-scrolling-fix' into 'main'
gdk: fix reversed and sluggish scrolling on MacOS

See merge request GNOME/gtk!4479
2022-02-14 23:00:27 +00:00
Andy Russell
37702af22b gdk: fix reversed and sluggish scrolling on MacOS
When using an external mouse on MacOS, the scrolling behavior is
reversed from the user's scrolling preference. Additionally, it is
noticeably sluggish.

This commit fixes both issues by negating the deltas and multiplying
them by 32 before constructing a new scroll event. 32 seems to be the
"traditional" scaling factor according to [Druid], but I'm not sure
where that value actually comes from. Regardless, scaling the deltas by
this amount makes scrolling feel a lot more responsive in the GTK demos.

Scrolling with a trackpad is not affected by either issue because it
triggers a different code path that uses more precise deltas, and
already negates them.

[Druid]: https://linebender.gitbook.io/linebender-graphics-wiki/mouse-wheel#external-mouse-wheel-vs-trackpad
2022-02-14 14:05:39 -05:00
Benjamin Otte
12908ab863 docs: Add Since annotations to GDK_VERSION macros 2022-02-14 00:30:50 +01:00
Matej Urbančič
4cb599f378 Update Slovenian translation 2022-02-13 18:58:22 +00:00
Matej Urbančič
fe210fb0dd Update Slovenian translation 2022-02-13 18:56:28 +00:00
Asier Sarasua Garmendia
1fee30af36 Update Basque translation 2022-02-13 09:22:58 +00:00
Sebastian Dröge
3f329b2d0f Don't crash when updating the icon on a GtkScaleButton with a non-NULL empty icon list 2022-02-13 11:16:32 +02:00
Marek Černocký
1fd03acf9d Updated Czech translation 2022-02-12 19:48:40 +01:00
Benjamin Otte
a26c1a5f0d widget-factory: Make <F11> toggle fullscreen 2022-02-12 19:05:19 +01:00
Emmanuele Bassi
7a608bda27 docs: Split dependencies from related libraries
We currently list everything as a dependencies, regardless of whether
it actually is; this is a source of confusion for users that read the
GTK documentation.

Gi-docgen has a new "related" key in the project configuration which
allows us to list libraries that are merely related to the namespace
we are documenting; the "dependencies" key is used to document the
actual namespace dependencies, now.
2022-02-12 17:28:00 +00:00
Jordi Mas i Hernandez
c400dce0b1 Update Catalan translation 2022-02-12 14:41:46 +00:00
Matthias Clasen
5912b2d64a Merge branch 'wip/chergert/fix-text-overdraw' into 'main'
css: reduce overdraws from "textview > text"

See merge request GNOME/gtk!4472
2022-02-12 08:34:18 +00:00
Christian Hergert
e38e8ed73e css: reduce overdraws from "textview > text"
This was causing us to draw the same background content twice which is a
significant amount of bits to flip in the GPU for maximized windows,
especially twice.
2022-02-11 23:06:16 -08:00
Matthias Clasen
5088103d31 4.6.1 2022-02-11 20:09:15 -05:00
Matthias Clasen
76b185e6f6 Merge branch 'wip/chergert/popover-opaque-region' into 'main'
add opaque regions to popovers

Closes #4689

See merge request GNOME/gtk!4468
2022-02-11 23:16:43 +00:00
Christian Hergert
f3999f7ebf popover: use GtkNative opaque region API
This updates GtkPopover to use the new GtkNative abstraction for
reporting opaque regions of the window, in hopes that it can speed
up compositors for things like animated lists, menu transitions,
and more.

Fixes #4689
2022-02-11 14:37:46 -08:00
Christian Hergert
f8e7ecfde1 window: use GtkNative API to update opaque region
This switches to using the new GtkNative machinery for updating the
opaque region. Some amount of local calculation is still required for
determining when we should apply shadows, and this inherits what was
done previous for that.

Related #4689
2022-02-11 14:37:46 -08:00
Christian Hergert
cc49e044a5 native: add API to update opaque region
This abstracts the machinery to update the opaque region for a GtkWindow
into GtkNative so it may be used from other native impelementations such
as GtkPopover.

Related #4689
2022-02-11 14:37:43 -08:00
Matthias Clasen
9205193147 Merge branch 'bilelmoussaoui/entry-completion' into 'main'
entry completion: add checks that entry is set already

See merge request GNOME/gtk!4450
2022-02-11 17:49:26 +00:00
Matthias Clasen
124d689f45 Merge branch 'enum-docs' into 'main'
docs: Use links in enums

See merge request GNOME/gtk!4452
2022-02-11 17:35:42 +00:00
Matthias Clasen
d2a2591d28 Merge branch 'bilelmoussaoui/g-i' into 'main'
g-i: add a couple of missing nullable annotations

See merge request GNOME/gtk!4470
2022-02-11 17:33:05 +00:00
Carlos Garnacho
64a1a1dd6b Merge branch 'primary' into 'main'
gdk: don't leak wayland primary selection offers

See merge request GNOME/gtk!4458
2022-02-11 14:29:19 +00:00
Bilal Elmoussaoui
3b383569a4 g-i: Add nullable annotations to EventControllerKey::im-context
Fixes https://github.com/gtk-rs/gtk4-rs/issues/874
2022-02-11 12:59:55 +01:00
Bilal Elmoussaoui
c2fe438676 g-i: Add nullable annotations to CellArea getters
Fixes https://github.com/gtk-rs/gtk4-rs/issues/891
2022-02-11 12:55:28 +01:00
Emmanuele Bassi
0ade146e26 Merge branch 'bilelmoussaoui/layout-manager' into 'main'
layout manager: add a check if the widget exists

See merge request GNOME/gtk!4469
2022-02-11 11:51:44 +00:00
Bilal Elmoussaoui
ba266325d0 g-i: Mark FileChooser [s|g]et_current_[folder|name] as nullable
The code seems to already check if folder/name is NULL
Fixes https://github.com/gtk-rs/gtk4-rs/issues/896
2022-02-11 12:21:58 +01:00
Bilal Elmoussaoui
e6322e177e g-i: Mark get_print_settings as nullable
Fixes https://github.com/gtk-rs/gtk4-rs/issues/880
2022-02-11 12:07:54 +01:00
Maximiliano Sandoval R
080a4cda49 docs: Use links in enums
Properties already refer to their object, so

    [property@Widget:sensitive] property on [class@Widget]

is redundant.
2022-02-11 12:07:09 +01:00
Bilal Elmoussaoui
6b63868641 g-i: mark get_selected_printer as nullable
There is no selected printer if the user closes the dialog
Fixes https://github.com/gtk-rs/gtk4-rs/issues/882
2022-02-11 12:05:42 +01:00
Bilal Elmoussaoui
cb710f1999 g-i: mark EventController::name as nullable
Fixes https://github.com/gtk-rs/gtk4-rs/issues/893
2022-02-11 12:02:07 +01:00
Bilal Elmoussaoui
85bb9aaefc g-i: add nullable annotation to gtk_single_selection_get_model 2022-02-11 11:56:40 +01:00
Bilal Elmoussaoui
6c02017212 layout manager: add a check if the widget exists
Avoid a crash when calling _gtk_widget_get_first_child
Fixes https://github.com/gtk-rs/gtk4-rs/issues/889
2022-02-11 11:44:16 +01:00
Matthias Clasen
90bccf4e82 Merge branch 'fix-wayland-subproject-build' into 'main'
NEWS: Updates

See merge request GNOME/gtk!4466
2022-02-10 21:57:27 +00:00
Matthias Clasen
18db7ad470 NEWS: Updates 2022-02-10 15:06:37 -05:00
Julian Orth
468ddd4d49 gdk: don't leak wayland primary selection offers
Signed-off-by: Julian Orth <ju.orth@gmail.com>
2022-02-10 20:44:32 +01:00
Matthias Clasen
ff4b5c8996 Merge branch 'fix-wayland-subproject-build' into 'main'
Fix build with wayland-protocols subproject

Closes #4530

See merge request GNOME/gtk!4465
2022-02-10 19:13:33 +00:00
Matthias Clasen
06aa640664 Fix build with wayland-protocols subproject
The missing files() was pointed out in #4530.

Fixes: #4530
2022-02-10 13:21:28 -05:00
Matthias Clasen
9f24229f82 Merge branch 'column-view-column-new-nullable-factory' into 'main'
Allow passing a `NULL` factory to `gtk_column_view_column_new()`

See merge request GNOME/gtk!4454
2022-02-10 11:42:38 +00:00
Matthias Clasen
214370ee23 Merge branch 'icon-view-drag-dest-item-nullable' into 'main'
Mark `path` out parameter of `gtk_icon_view_get_drag_dest_item()` as `(nullable)`

See merge request GNOME/gtk!4451
2022-02-10 11:24:04 +00:00
Matthias Clasen
217d817408 Merge branch 'gwagner/gtkbuilder-rng' into 'main'
tools: updated gtk4builder.rng to current state

See merge request GNOME/gtk!4457
2022-02-09 19:25:32 +00:00
Matthias Clasen
6dfaafc9f2 Merge branch 'update-keysyms' into 'main'
gdk: Update keyboard symbols from libxkbcommon

See merge request GNOME/gtk!4422
2022-02-09 19:23:59 +00:00
Matthias Clasen
287de3844d Merge branch 'gtk_assisten_set_current_page-no-pages-guard' into 'main'
Don't dereference a `NULL` page in `gtk_assistant_set_current_page()` if there are no pages at all

See merge request GNOME/gtk!4464
2022-02-09 19:19:24 +00:00
Sebastian Dröge
878e4a34d3 Don't dereference a NULL page in gtk_assistant_set_current_page() if there are no pages at all 2022-02-09 17:50:55 +02:00
Matthias Clasen
b893dc9552 Merge branch 'bilelmoussaoui/g-i' into 'main'
gdk: mark gdk_device_get_device_tool as nullable

See merge request GNOME/gtk!4463
2022-02-09 13:43:50 +00:00
Matthias Clasen
687b80a037 Merge branch 'revert-misdeprecation' into 'main'
Revert "Deprecate GdkDevice:source"

See merge request GNOME/gtk!4462
2022-02-09 13:13:35 +00:00
Bilal Elmoussaoui
a8a98523db gdk: mark gdk_device_get_device_tool as nullable 2022-02-09 13:09:47 +00:00
Matthias Clasen
0a224964a6 Revert "Deprecate GdkDevice:source"
This reverts commit fd9e0dd13a.
2022-02-09 07:55:28 -05:00
Luca Bacci
0457c37847 Merge branch 'win32-fix-ctrl-shift-gtk4' into 'main'
gdkkeys-win32: Also ignore Ctrl + Shift (etc.)

See merge request GNOME/gtk!4460
2022-02-09 10:08:52 +00:00
Philip Zander
037c0e4005 gdkkeys-win32: Also ignore Ctrl + Shift (etc.)
Some Windows keymaps have bogus mappings for the Ctrl modifier. !4423 attempted
to fix this by ignoring the Ctrl layer, but that was not enough. We also need to
ignore combinations of Ctrl with other modifiers, i.e. Ctrl + Shift. For example,
Ctrl + Shift + 6 is mapped to the character 0x1E on a US keyboard (but it should
be treated as Ctrl + ^). Basically, always ignore Ctrl unless it is used in
conjunction with Alt, i.e. as part of AltGr.

Related issue: #4667
2022-02-09 10:43:07 +01:00
Christian Hergert
b9389d3784 Merge branch 'bilelmoussaoui/macos-gdk-display' into 'main'
macos: Don't set NULL as a display name

See merge request GNOME/gtk!4453
2022-02-09 00:30:04 +00:00
Günther Wagner
86a3400f2e tools: updated gtk4builder.rng to current state 2022-02-08 21:42:41 +01:00
Sebastian Dröge
8245fd4beb Allow passing a NULL factory to gtk_column_view_column_new() 2022-02-08 16:25:28 +02:00
Bilal Elmoussaoui
f41cfd3caa macos: Don't set NULL as a display name
Other GDK backends ensure there is always a default name set.
Fixes https://github.com/gtk-rs/gtk4-rs/issues/868
2022-02-08 13:38:33 +01:00
Sebastian Dröge
07d6ef13c5 Mark path out parameter of gtk_icon_view_get_drag_dest_item() as (nullable)
It can be set to `NULL` and the function body handles `NULL` explictly,
so annotate it accordingly.
2022-02-08 12:50:24 +02:00
Bilal Elmoussaoui
883e8328e0 entry completion: add checks that entry is set already
If any of the APIs that assumes that the entry is set already is used
before having one already set, things break pretty badly.

Fixes a downstream issue reported at https://github.com/gtk-rs/gtk4-rs/issues/873
2022-02-08 11:22:52 +01:00
Benjamin Otte
c6d5816c95 Merge branch 'wip/otte/for-main' into 'main'
gltexture: Only use glGetFramebufferParameter() when available

Closes #4678

See merge request GNOME/gtk!4449
2022-02-08 02:08:26 +00:00
Benjamin Otte
f37c5ebd26 rgba: Fix GDK_RGBA() macro to work with alpha
Previously we dividied by an integer, so alpha was either 0.0 or 1.0.
2022-02-08 01:34:19 +01:00
Benjamin Otte
2c71825324 gltexture: Only use glGetFramebufferParameter() when available
Fixes #4678
2022-02-08 01:34:19 +01:00
Matthias Clasen
38ad56e6a1 Merge branch 'wip/jimmac/selected_text' into 'main'
style: legible text selections

Closes #4664

See merge request GNOME/gtk!4433
2022-02-08 00:15:45 +00:00
Matthias Clasen
84d698464c Merge branch 'antoniof-main-patch-89408' into 'main'
columnviewcolumn: Define autocleanup function

See merge request GNOME/gtk!4440
2022-02-07 23:57:46 +00:00
Matthias Clasen
9363269ceb Merge branch 'more-noexecstack' into 'main'
demos: Make our stack noexec

See merge request GNOME/gtk!4439
2022-02-07 23:57:26 +00:00
Matthias Clasen
59eb9aeb73 Merge branch 'wip/chergert/macos-fixes' into 'main'
various macOS fixes

See merge request GNOME/gtk!4424
2022-02-07 23:56:40 +00:00
Matthias Clasen
d9109a0e92 Merge branch 'mg/gdk-macos-gdkdisplaylinksource' into 'main'
Include `gdk-private.h` to fix error about `g_source_set_static_name`

See merge request GNOME/gtk!4443
2022-02-07 23:54:55 +00:00
Matthias Clasen
f27c0c65b1 Merge branch 'mg/implicit-declaration-free' into 'main'
gdkjpeg: include `stdlib.h` necessary for `free`

See merge request GNOME/gtk!4445
2022-02-07 23:53:36 +00:00
Matej Urbančič
212f629876 Update Slovenian translation 2022-02-07 19:39:08 +00:00
Matej Urbančič
05f2f3ba8c Update Slovenian translation 2022-02-07 19:30:34 +00:00
Emmanuele Bassi
a66072f312 Merge branch 'drop-target-get-formats-transfer-none' into 'main'
Mark `gtk_drop_target_get_formats()` return value as `transfer none`

See merge request GNOME/gtk!4446
2022-02-07 15:17:39 +00:00
Sebastian Dröge
3ba582375d Mark gtk_drop_target_get_formats() return value as transfer none
It was wrongly inferred as `transfer full` by gobject-introspection.
2022-02-07 16:23:01 +02:00
Mosè Giordano
4c211f1872 gdkjpeg: include stdlib.h necessary for free
`free` is defined in `stdlib.h`, see for example
<https://pubs.opengroup.org/onlinepubs/009604499/functions/free.html>.  Without
this include compilation can fail with the following error:

```
../gdk/loaders/gdkjpeg.c: In function ‘gdk_save_jpeg’:
../gdk/loaders/gdkjpeg.c:264:7: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
       free (data);
       ^
../gdk/loaders/gdkjpeg.c:264:7: warning: incompatible implicit declaration of built-in function ‘free’
../gdk/loaders/gdkjpeg.c:264:7: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
../gdk/loaders/gdkjpeg.c:302:67: error: ‘free’ undeclared (first use in this function)
   return g_bytes_new_with_free_func (data, size, (GDestroyNotify) free, NULL);
                                                                   ^
../gdk/loaders/gdkjpeg.c:302:67: note: each undeclared identifier is reported only once for each function it appears in
../gdk/loaders/gdkjpeg.c:303:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
```
2022-02-06 15:41:33 +00:00
Mosè Giordano
2ceba0d31c Include gdk-private.h to fix error about g_source_set_static_name
Without this change we get the following error:

```
[1/13] Compiling C object gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o
ninja: job failed: /opt/bin/aarch64-apple-darwin20-libgfortran5-cxx11/aarch64-apple-darwin20-clang -Igdk/macos/libgdk-macos.a.p -Igdk/macos -I../gdk/macos -I. -I.. -Igdk -I../gdk -Isubprojects/pango/pango -I../subprojects/pango/pango -Isubprojects/pango -I../subprojects/pango -I/workspace/destdir/include/gdk-pixbuf-2.0 -I/workspace/destdir/include -I/workspace/destdir/include/glib-2.0 -I/workspace/destdir/lib/glib-2.0/include -I/workspace/destdir/lib/libffi-3.2.1/include -I/workspace/destdir/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/workspace/destdir/include/cairo -I/workspace/destdir/include/pixman-1 -I/workspace/destdir/include/freetype2 -I/workspace/destdir/include/fribidi -I/workspace/destdir/include/harfbuzz -I/workspace/destdir/include/graphene-1.0 -I/workspace/destdir/lib/graphene-1.0/include -I/workspace/destdir/include/gio-unix-2.0 -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu99 -O2 -g -DG_LOG_USE_STRUCTURED=1 -DGLIB_DISABLE_DEPRECATION_WARNINGS '-DGTK_VERSION="4.6.0"' -D_GNU_SOURCE -DG_ENABLE_DEBUG -DGTK_COMPILATION '-DG_LOG_DOMAIN="Gdk"' -xobjective-c -fno-strict-aliasing -Wno-c++11-extensions -Wno-missing-include-dirs -Wno-typedef-redefinition -Wformat=2 -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-function-declaration -Wmisleading-indentation -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-fallthrough -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=missing-declarations -Werror=missing-prototypes -Werror=nonnull -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=vla -Werror=write-strings -Wnull-dereference -fvisibility=hidden -MD -MQ gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o -MF gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o.d -o gdk/macos/libgdk-macos.a.p/gdkdisplaylinksource.c.o -c ../gdk/macos/gdkdisplaylinksource.c
../gdk/macos/gdkdisplaylinksource.c:201:3: error: implicit declaration of function 'g_source_set_static_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  g_source_set_static_name (source, "[gdk] quartz frame clock");
  ^
1 error generated.
ninja: subcommand failed
```
2022-02-05 21:51:40 +00:00
Christian Hergert
95168e179c macos: fallback to conversion on WCG colorspace
We don't want to risk having something really weird come out if we have a
WCG colorspace, so instead only do the performance hack on systems where
the output is likely reasonable.

We will want to eventually just be drawing in the appropriate colorspace,
but that is not available yet.
2022-02-05 12:42:57 -08:00
Asier Sarasua Garmendia
34959b58f4 Update Basque translation 2022-02-05 11:21:02 +00:00
Christian Hergert
2be51dc3b1 macos: handle sizing changes when switching monitors
This should make sure that our scales are updated as well as
ensuring we repaint the whole surface.
2022-02-04 12:29:57 -08:00
Benjamin Otte
14bdf82e33 Merge branch 'wip/hadess/inspector-search-by-pointer-gtk4' into 'main'
inspector: Search by pointer address

See merge request GNOME/gtk!4442
2022-02-04 18:07:28 +00:00
Christian Hergert
6b85d501f0 macos: assume monitor colorspace when drawing
When using software rendering w/ cairo, assume we're drawing in
the best-monitor's colorspace rather than RGB to avoid colorspace
conversions on every frame.
2022-02-04 09:46:10 -08:00
Christian Hergert
473aceea68 macos: add API to get monitor colorspace 2022-02-04 09:45:55 -08:00
Bastien Nocera
0621dbc745 inspector: Search by pointer address
Useful to find a widget that corresponds to a pointer address in gdb.
2022-02-04 18:39:56 +01:00
Christian Hergert
8ea0a4fc50 macos: precalculate clip regions as CGRect
We can make our drawRect do less work if we precalculate the clip
and damage regions upfront by intersecting them with the bounds.
2022-02-04 09:31:37 -08:00
António Fernandes
94ef818c9a columnviewcolumn: Define autocleanup function 2022-02-04 11:13:46 +00:00
Christian Hergert
8112b49c36 macos: fix unmaximize opacity around edges of window 2022-02-03 19:26:16 -08:00
Christian Hergert
58b9c3a6d4 macos: use CGContext to draw cairo surfaces
Instead of relying on cairo_t to perform drawing from our backing
image surface to the Core Graphics context, we can convert the
cairo_image_surface_t into a CGImageRef without having to copy
data if we are certain of the alignment of the image up front.

Without this, there are many situations, based on the size of the
window that could cause cairo to take a slow path and malloc/copy
the data to ensure that alignment.

The previous commit titled "macos: align image surface rowstride to
16-bytes" ensures that this invariant is true so that our drawing
code can assume we can reference the framebuffer from the
cairo_image_surface_t using a CGDataProvider.

Since GdkMacosCairoContext and GdkMacosCairoSubview are coordinating,
we can also setup the transformation/scale early when drawing the
cairo_image_surface_t instead of when copying it to Core Graphics.

Furthermore, the CGImageRef is created with an RGB colorspace so
that we are not performing colorspace conversion to the output
device. We don't get color matching between displays, but we don't
expect that anyway, particularly with the software renderer.
2022-02-03 19:26:16 -08:00
Christian Hergert
4373743d4c macos: align image surface rowstride to 16-bytes
When creating a cairo_image_surface_t we want both the framebuffer pointer
and each row to be aligned to 16-bytes so that Core Graphics will use more
optimal paths.

However, cairo_image_surface_create() will not guarantee that the rowstride
is aligned to 16-bytes so we must do that ourselves.
2022-02-03 19:26:16 -08:00
Christian Hergert
58159552ba macos: avoid unnecessarily destroying cairo_t
This avoids destroying a cairo_t when we are within the frame as it
otherwise causes the surface to unnecessarily flush.
2022-02-03 19:26:16 -08:00
Christian Hergert
4bff24f83a macos: cleanup window surface when destroying context
Make sure we release the cairo_surface_t for the window when
disposing the GdkMacosCairoContext.
2022-02-03 19:26:16 -08:00
Christian Hergert
f644925570 macos: be more careful about freezing/thawing surfaces
We need to avoid conflating the managing of frame callbacks from
the freeze/thaw mechanics and ensure we don't perform extra thaw
requests at the wrong time.
2022-02-03 19:26:16 -08:00
Christian Hergert
8a4fd3f2af macos: check for destroyed surfaces in vfuncs 2022-02-03 19:26:16 -08:00
Christian Hergert
b7130a1ce3 macos: be more defensive about freezing updates
We only need to freeze the updates if we weren't in the queue already.
That should be the case, but just better to be defensive here.
2022-02-03 19:26:16 -08:00
Christian Hergert
519a44d224 macos: push to head of awaiting frames
Always add to the head of awaiting frames as the list is processed
in the opposite direction.
2022-02-03 19:26:16 -08:00
Christian Hergert
936034e07a macos: remove popup surface from parent 2022-02-03 19:26:16 -08:00
Christian Hergert
ea43939f52 macos: handle NULL frame-clock when thawing 2022-02-03 19:26:16 -08:00
Jan Alexander Steffens (heftig)
d8befc612f demos: Make our stack noexec
This is similar to https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4330
and https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4334, which fixed
the main library but missed the demos.
2022-02-03 19:14:36 +00:00
Emmanuele Bassi
06ec4ec148 Merge branch 'zbrown/its-a-filename' into 'main'
cssprovider: from_path takes a path

See merge request GNOME/gtk!4436
2022-02-02 23:11:44 +00:00
Zander Brown
6fbcb967a0 cssprovider: from_path takes a path
Annotate it as such so that bindings can expose that appropriately

Related: https://github.com/gtk-rs/gtk4-rs/issues/861
2022-02-02 22:47:39 +00:00
Emmanuele Bassi
82e0241c42 Merge branch 'fix-app-launch-context-docs' into 'main'
gdkapplaunchcontext: Fix docs a bit

See merge request GNOME/gtk!4434
2022-02-01 20:34:41 +00:00
Phaedrus Leeds
8e000c2dbf gdkapplaunchcontext: Fix docs a bit
The set_screen() and set_display() methods no longer exist.
2022-02-01 11:17:55 -08:00
Jakub Steiner
1f1aafd5c2 style: legible text selections
- follow adwaita styling

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4664
2022-02-01 17:12:52 +01:00
Luca Bacci
d314298644 Merge branch 'win32-keys-ignore-ctrl-gtk4' into 'main'
gdkkeys-win32: Ignore CTRL bit for key translation

Closes #4667

See merge request GNOME/gtk!4431
2022-02-01 15:33:01 +00:00
Emmanuele Bassi
3cbe3abf67 Merge branch '4602-fix-kerning-of-gl-rendered-glyphs' into 'main'
Fix kerning of GL rendered glyphs

Closes #4602

See merge request GNOME/gtk!4429
2022-02-01 14:31:47 +00:00
Philip Zander
90ab8b8dd3 gdkkeys-win32: Ignore CTRL bit for key translation
Some keymaps on Windows contain bogus mappings for Ctrl+key for certain
keys, e.g. Ctrl+Backspace = Delete, or Ctrl+[ = 0x1B. These are never
used on Windows, so we should ignore them.

Fixes #4667
2022-02-01 14:12:56 +01:00
Marek Kasik
cb1dd66220 Fix kerning of GL rendered glyphs
Multiple scaled shifts by 1024 too.

Fixes: #4602
2022-02-01 09:31:35 +01:00
Boyuan Yang
d033a099ae Update Chinese (China) translation 2022-01-31 03:51:23 +00:00
Boyuan Yang
78d9e5e181 Update Chinese (China) translation 2022-01-31 03:46:30 +00:00
sicklylife
41270ba8c9 Update Japanese translation 2022-01-30 15:26:50 +00:00
sicklylife
e2277438e9 Update Japanese translation 2022-01-30 15:15:27 +00:00
Piotr Drąg
b0936c913b Update Polish translation 2022-01-29 14:59:17 +01:00
Väinö Mäkelä
4b05eb62c9 gdk: Update keyboard symbols from libxkbcommon
GTK's old key symbol list is missing a few symbols like the per mille
sign that is included in some keyboard layouts. This commit updates
gdkkeyuni.c to match libxkbcommon's current key symbol list.
2022-01-29 14:31:09 +02:00
Aleksandr Melman
fbacf0cb65 Update Russian translation 2022-01-28 11:05:57 +00:00
Emmanuele Bassi
05a53a1582 Merge branch 'infobar-xml' into 'main'
Escape Builder XML in GtkInfoBar docs

See merge request GNOME/gtk!4421
2022-01-28 10:49:37 +00:00
Elliott Sales de Andrade
be5873a057 Escape Builder XML in GtkInfoBar docs 2022-01-28 05:32:16 -05:00
Daniel Mustieles
c97f46bf28 Updated Spanish translation 2022-01-28 11:01:09 +01:00
Emmanuele Bassi
1d47882eab Merge branch 'ebassi/manifest-dep-fix' into 'main'
flatpak: Add wayland-protocols to the manifests

See merge request GNOME/gtk!4420
2022-01-28 02:05:59 +00:00
Emmanuele Bassi
9dcbbb4300 flatpak: Use "main" branch for wayland
The default branch for wayland has changed, but the "master" branch
is still available with an older version.
2022-01-28 01:25:04 +00:00
Matthias Clasen
c9eda02fa1 Merge branch 'tiled-window-bracket-fix' into 'main'
theme: Drop shadow and border fixes for tiled windows

See merge request GNOME/gtk!4418
2022-01-27 17:29:13 +00:00
Matthias Clasen
a37584a404 Merge branch 'wip/baedert/for-master' into 'main'
build: Make GCC ignore fallthrough comments

Closes #4663

See merge request GNOME/gtk!4419
2022-01-27 16:27:12 +00:00
Leônidas Araújo
566f217f6f Update Brazilian Portuguese translation 2022-01-27 16:25:07 +00:00
Matheus Barbosa
ca34c79443 Update Brazilian Portuguese translation 2022-01-27 15:47:53 +00:00
Timm Bäder
4be6c5b197 gesturesingle: Get rid of a fallthrough comment
Fixes #4663
2022-01-27 16:06:56 +01:00
Timm Bäder
7194196100 build: Make GCC ignore fallthrough comments
From the GCC manpage:

> Wimplicit-fallthrough=5 doesn't recognize any comments as
> fallthrough comments, only attributes disable
> the warning.

So, check for the =5 version after checking for the simple version. This
way we get -Wfallhrough with clang and -Wfallthrough -Wfallthrough=5
with GCC, which works.
2022-01-27 16:05:33 +01:00
Yuri Chornoivan
d9d2eb978d Update Ukrainian translation 2022-01-27 14:47:37 +00:00
Carlos Garnacho
c8460c51bd Merge branch 'realize-vs-focus-in' into 'main'
gtktext: Make sure input method sees focus in

See merge request GNOME/gtk!4402
2022-01-27 14:13:55 +00:00
Joonas Henriksson
b4d0235a05 theme: Fix incorrect border color for tiled windows 2022-01-27 06:08:40 +02:00
Joonas Henriksson
a5d1f78bf2 theme: Fix drop shadow for tiled windows
Misplaced curly bracket prevented the :backdrop styling from getting
applied. Also fix the indentation while at it.
2022-01-27 05:50:06 +02:00
Carlos Garnacho
9a7750e339 Merge branch 'hold-gestures' into 'main'
Add hold gestures

See merge request GNOME/gtk!3454
2022-01-26 23:37:28 +00:00
Fran Dieguez
d7c4ac7d02 Update Galician translation 2022-01-26 23:36:27 +00:00
Hugo Carvalho
1a08be066e Update Portuguese translation 2022-01-26 22:48:02 +00:00
José Expósito
fe86aa5f6b gtkgestureswipe: Don't filter hold events
Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
34133ec1e8 gtkgesturerotate: Don't filter hold events
Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
a99a75827c gtkgesturezoom: Don't filter hold events
Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
3bfcc12ec0 gtkgesture: Handle hold gestures
Hold gestures are used to bring existing gestures on touchpad
semantically closer to touchscreen gestures.

Touchpad gestures observe hold gestures with a matching amount of
fingers and emit their begin and end signals when fingers are detected
or removed on/from the touchpad.

When a hold cancel event is detected, it is required to wait a few
milliseconds until the next event(s) are received to avoid emitting
multiple begin signals.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
382341e1bf gtkgesture: Add hold to EVENT_IS_TOUCHPAD_GESTURE
Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
44b0d8b330 scrolledwindow: Stop kinetic scrolling on begin
Stop kinetic scrolling when a scroll begin signal is sent during the
event capture phase.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
62808722d2 kineticscrolling: Add stop function
Move the logic to stop kinetic scrolling to its own function and allow
to call it from the outside.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
f09338c8de gtkeventcontrollerscroll: Handle hold gestures
Handle hold events:

 - GDK_TOUCHPAD_GESTURE_PHASE_BEGIN: scroll-begin is emitted.
 - GDK_TOUCHPAD_GESTURE_PHASE_END: A hold gesture ends only when all
   fingers are lifted from the touchpad without movement, so
   scroll-end is emitted right away.
 - GDK_TOUCHPAD_GESTURE_PHASE_CANCEL: A hold gesture is cancelled when
   some fingers are lifted/put down or movement is detected. In this
   case, scroll-end is emitted after a small timeout only if
   GDK_SCROLL wasn't detected.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
ec91b2de10 gtkeventcontrollerscroll: Refactor scroll end
Move the logic to end scrolling to its own function to be able to
reuse it.

Refactor, no functional changes.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
5cd289dc1d gtkeventcontrollerscroll: Refactor scroll begin
Move the logic to begin scrolling to its own function to be able to
reuse it.

Refactor, no functional changes.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
299caaa383 wayland/pointer-gestures: Receive hold gesture
Add the glue code to receive hold gesture events from the compositor,
transform them into GdkEvents and finally enqueue them.

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
0aa2a4ef14 gtkmain: Handle hold events
Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
331f1ee722 gdk/events: Add hold GdkEvent
Allow to create hold events as well as the required functions to get
information about the event: gesture phase, finger count, etc

Part-of: <!3454>
2022-01-26 22:49:53 +01:00
José Expósito
0f351508bc build: Bump wayland-protocols to v1.23
Part-of: <!3454>
2022-01-26 22:47:51 +01:00
Matthias Clasen
304527ab01 Merge branch 'sri-main-patch-28302' into 'main'
Update docs/reference/gtk/migrating-3to4.md

See merge request GNOME/gtk!4404
2022-01-26 19:37:28 +00:00
Matthias Clasen
b3d778469a Merge branch 'rafaelff-hig' into 'main'
buildertool: use curly apostrophe

See merge request GNOME/gtk!4414
2022-01-26 19:35:21 +00:00
Matthias Clasen
6f5210afea Merge branch 'wip/carlosg/touchpad-gesture-fixes' into 'main'
Touchpad gesture fixes

See merge request GNOME/gtk!4417
2022-01-26 19:32:33 +00:00
Matthias Clasen
6b1de35c01 Merge branch 'antoniof-main-patch-39484' into 'main'
gtkbitset: Define autocleanup function

See merge request GNOME/gtk!4416
2022-01-26 19:29:08 +00:00
Matthias Clasen
8fccfc7a3d Merge branch 'bilelmoussaoui/g-i' into 'main'
g-i: mark GtkSnapshot to_(node|paintable) as nullable

See merge request GNOME/gtk!4413
2022-01-26 19:19:42 +00:00
Carlos Garnacho
6fd3645713 gtk/gesture: Fix point info lookup on touchpad events
Since the addition of GdkEventSequence in touchpad events, these
are now stored in the gesture using that sequence. This bit of touchpad
gesture handling was however missing to be updated, still looking up
the special NULL sequence.

Use the last sequence here, which will be the one coming from touchpad
gesture events.
2022-01-26 16:02:00 +01:00
Carlos Garnacho
8e86e6325b gtk/main: Do not use touchpad event sequence for pointer focus lookup
Despite touchpad gestures having a sequence, these must use the logical
pointer focus. Avoid using the sequence for GtkPointerFocus lookups with
those events, in order to ensure those events make it all the way to the
intended target.

This is fallout from adding GdkEventSequence information to touchpad
gestures.
2022-01-26 15:59:36 +01:00
Carlos Garnacho
2b41e72196 gdk: Always request "flush events" frame clock phase on events
This change is done for 2 reasons:

- The logic to request this phase when compressing scroll events is
  slightly broken. If there are multiple scroll events that are
  coalesced into one, the surface frame clock will not get this request.
  The worst case is having >= 2 scroll events on every frame, as the
  compressed event will be left in the queue, and be further compressed
  on future events.

- Even scroll events aside, this phase is requested in oddly specific
  places that are not enough to cover all events, others do rely on
  unrelated GdkFrameClock activity that happens to flush the events
  as well.

Unify this phase request so it explicitly happens on the arrival of any
event. This ensures that events (compressed or not) will be handled
promptly after arrival.
2022-01-26 15:49:29 +01:00
António Fernandes
1a64eeb88e gtkbitset: Define autocleanup function 2022-01-25 21:33:31 +00:00
Emmanuele Bassi
2f8eac2c0a Merge branch 'fix-popovermenu-removechild' into 'main'
popovermenu: Fix crash when removing child

See merge request GNOME/gtk!4393
2022-01-25 15:40:28 +00:00
Kévin Commaille
aaba777ad0 popovermenu: Fix crash when removing child
gtk_menu_section_box_remove_custom was looking in the wrong place for the
stack ancestor, causing an assertion error.
2022-01-25 15:31:00 +01:00
Guido Günther
a580547f47 gtktext: Make sure input method sees focus in
Currently when the widget is realized after the focus in event the input
method isn't activated as enable is never sent. The call trace is

  gtk_text_focus_changed ->
    gtk_im_context_focus_in ->
      gtk_im_context_wayland_focus_in

which returns early as self->widget is NULL since it's set up in
gtk_text_realize() via gtk_im_context_set_client_widget(). Handle that
case by invoking gtk_im_context_focus_in() from gtk_text_realize() too.

A case where the above happens is a GtkSearchEntry in a GtkSearchBar.
E.g. in gtk4-demo when starting the demo and then hitting the search
button right away.
2022-01-25 11:15:29 +01:00
Boyuan Yang
00ee7ffa6a Update Chinese (China) translation 2022-01-24 19:46:37 +00:00
Leônidas Araújo
f02b7d55b1 Update Brazilian Portuguese translation 2022-01-24 17:08:46 +00:00
Rafael Fontenelle
bed709a322 buildertool: use curly apostrophe 2022-01-24 17:04:17 +00:00
Bilal Elmoussaoui
b362eeefdf g-i: mark GtkSnapshot to_(node|paintable) as nullable
Fixes an upstream issue reported at https://github.com/gtk-rs/gtk4-rs/issues/845
2022-01-23 22:11:07 +00:00
Matthias Clasen
7b02498963 Merge branch 'matthiasc/for-main' into 'main'
Use pango api better

See merge request GNOME/gtk!4412
2022-01-23 15:19:39 +00:00
Matthias Clasen
6fd53f28f3 Use pango api better
Avoid direct access to PangoLayoutLine members,
use pango api for it where we can.#
2022-01-23 09:55:46 -05:00
Matthias Clasen
fefc8b5a82 Merge branch 'matthiasc/for-main' into 'main'
Use pango api better

See merge request GNOME/gtk!4411
2022-01-23 14:34:58 +00:00
Matthias Clasen
4fe976549e Use pango api better
Avoid direct access to PangoLayoutLine members,
use pango api for it where we can.
2022-01-23 09:09:57 -05:00
Matthias Clasen
044ff82d0b Merge branch 'matthiasc/for-main' into 'main'
Use pango api better

See merge request GNOME/gtk!4409
2022-01-23 04:29:58 +00:00
Matthias Clasen
feac1e5fba Use pango api better
Avoid direct access to PangoLayoutLine members,
use pango api for it where we can.
2022-01-22 23:10:53 -05:00
Yaron Shahrabani
dd5455fcd2 Update Hebrew translation 2022-01-21 16:04:24 +00:00
Yaron Shahrabani
315971f02d Update Hebrew translation 2022-01-21 15:53:39 +00:00
Emmanuele Bassi
a092986af3 Merge branch 'targz' into 'main'
ci: Put gtk dll into an archive

Closes #4653

See merge request GNOME/gtk!4403
2022-01-19 19:58:36 +00:00
Sri Ramkrishna
6633f4e02f Update docs/reference/gtk/migrating-3to4.md 2022-01-19 19:24:01 +00:00
Guido Günther
ee8970f23d ci: Only use letters in "expose_as" 2022-01-19 18:51:29 +01:00
Guido Günther
46f1e4c414 ci: Put gtk dll into an archive
This avoids the wild card that makes the CI fail
2022-01-19 18:51:16 +01:00
Dz Chen
a853e27765 Update Chinese (China) translation 2022-01-19 15:44:00 +00:00
Matthias Clasen
68985d42bb Merge branch 'win32-gl-improvements' into 'main'
Windows: Some fixes to GL context realization (EGL/GLES in particular)

See merge request GNOME/gtk!4386
2022-01-19 13:49:40 +00:00
Matthias Clasen
9146a21738 Merge branch 'bilelmoussaoui/g-i' into 'main'
g-i: mark gtk_text_iter_get_child_anchor as nullable

See merge request GNOME/gtk!4401
2022-01-19 13:48:57 +00:00
Luca Bacci
8c2128703b Merge branch 'provide-libgtk-dll-as-ci-artifact' into 'main'
Provide GTK DLL as GitLab CI artifact

See merge request GNOME/gtk!4395
2022-01-19 11:17:28 +00:00
Luca Bacci
b2d9cae0ec Provide GTK DLL as GitLab CI artifact 2022-01-19 11:17:28 +00:00
Carlos Garnacho
11eb66298d Merge branch 'context-early' into 'main'
gtkimcontextwayland: Remember context on focus-in so enable can happen later

See merge request GNOME/gtk!4397
2022-01-19 10:48:48 +00:00
Bilal Elmoussaoui
0f67e46549 g-i: mark gtk_text_iter_get_paintable as nullable 2022-01-19 10:22:40 +00:00
Guido Günther
45397534eb gtkimcontextwayland: Save context even when text_input isn't around yet
Remember the current context on focus-in even though the text-input
isn't set up yet. This helps in the case where the text-input is not yet
created but a widget already got focused. Without that the enable()
invocation in text_input_enter() woulnd't be invoked leaving the input
method disabled.

This fixes

    gtk4-demo --run=search_entry

which would initially not show the on-screen keyboard when e.g using
phoc/sway as compositor.
2022-01-19 10:20:46 +00:00
Bilal Elmoussaoui
ffa93b87f8 g-i: mark gtk_text_iter_get_child_anchor as nullable 2022-01-19 10:18:40 +00:00
Chun-wei Fan
0fe37d1828 gdkdisplay-win32.c: Clean up GL initialization further 2022-01-19 11:56:32 +08:00
Chun-wei Fan
43839898b3 GDK: Force GLES 3.0+ on libANGLE
...when libANGLE is being used on Windows, by checking for a
Windows-specific an ANGLE-specific extension.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
6f2848c311 Cleanup "GDK/Win32: Try to fix initializing GLES contexts"
As per Benjamin's suggestions, cleanup the previous implementation on
initializing the GLES context on Windows, so that we use more items that are
already in GDK proper and integrate two functions into one.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
38c17c1f79 gdkglcontext-win32-wgl.c: Cleanup GL context creation
Instead of first trying to explicitly ask for a WGL 4.1 context, ask for
the WGL context version that matches what is reported via
epoxy_gl_version(), so that we get the maximum WGL version that is
supported by the graphics drivers, and make sure any WGL contexts that
are shared with this (initial) WGL context are created likewise.

We can try to do a default-bog-standard 3.2 core WGL context creation
if the need arises, but let's leave that alone for now.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
b85aa10700 gdkglcontext.c: Ensure EGL contexts are in-sync with shared context
The EGL context that we are actually creating must have matching OpenGL/ES
versions and allowed GL API set with the previously-created EGL context
that will be shared with it so that they can interoperate together, if
applicable.

This will fix the situation by making sure that we request for the
OpenGL/ES version and OpenGL API set that match with what we have in our shared
EGL context.  Otherwise, the newly-created EGL context assumed a OpenGL/ES 2.0
context that supported desktop OpenGL, which may not be what we wanted, such as
in the case of libANGLE.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
598c7d9cf4 GDK/Win32: Try to fix initializing GLES contexts
We are now able to create EGL contexts properly on Windows, but not GLES.  This
tries to fix things by doing the following:

*  Record the GL context type in a more proper fashion, using an Enum.  This
   makes things a bit cleaner.
*  Force GLES-3.0+ contexts, since libANGLE requires this to properly work with
   the shaders-its 2.0 contexts don't work well with our shaders.
2022-01-19 11:56:32 +08:00
Chun-wei Fan
3e9d858af1 gskrenderer.c: Use GL renderer on Windows by default
Since now we have the shaders working on Windows under GLES with libANGLE using
a 3.0+ context, drop the check to fall back to the Cairo renderer when GLES is
being used.
2022-01-19 11:56:32 +08:00
Matthias Clasen
6fd29e6600 Merge branch 'wip/wayland-surface-offset' into 'main'
Fix DND hotspot position under Wayland + EGL/Vulkan

See merge request GNOME/gtk!3705
2022-01-18 23:48:26 +00:00
Matthias Clasen
b67636747b Merge branch 'gdksurface-wayland-assert' into 'main'
gdksurface-wayland: Fix contradictory assert

See merge request GNOME/gtk!4385
2022-01-18 23:46:59 +00:00
Matthias Clasen
ea464c9874 Merge branch 'gsk-transform-nullable' into 'main'
Mark various GskTransform functions as nullable in their return value

See merge request GNOME/gtk!4378
2022-01-18 23:44:23 +00:00
Matthias Clasen
0e9c4a3964 Merge branch 'document_shortcut_func_ret' into 'main'
gtk: document return value of ShortcutFunc

See merge request GNOME/gtk!4389
2022-01-18 23:41:15 +00:00
Matthias Clasen
1b15f89dfd Merge branch 'wip/dont-always-restore-saved-gtk4' into 'main'
wayland: Don't always restore the saved size when floating

Closes #4634

See merge request GNOME/gtk!4394
2022-01-18 23:40:49 +00:00
Matthias Clasen
7192ff672e Merge branch 'build-post-install-query-media-modules' into 'main'
Meson: Also query media modules in post-install

See merge request GNOME/gtk!4380
2022-01-18 23:39:26 +00:00
Matthias Clasen
7a99e03888 Merge branch 'ebassi/fix-release-test' into 'main'
reftest: Avoid assertions being compiled out

See merge request GNOME/gtk!4391
2022-01-18 15:07:37 +00:00
Jonas Ådahl
be7a391a13 wayland: Don't always restore the saved size when floating
We only save the size when we transition from floating to fixed, so that
we can restore the size to the one prior to being fixed.

However, we should not restore to this size whenever we see a 0x0 size
from xdg_toplevel, as it can do that any time it doesn't care about the
size, e.g. when the surface is floating and just changing state.

Fix this by only using the saved size when transitioning from fixed to
floating, not when staying floating while previously floating.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4634
2022-01-18 15:46:10 +01:00
Emmanuele Bassi
23aec81f1a reftest: Avoid assertions being compiled out
Calling functions inside a g_assert() means those functions will be
compiled out when building with G_DISABLE_ASSERT.

This fixes the release job in the CI pipeline.
2022-01-18 14:07:37 +00:00
Alexandros Theodotou
738d962aca gtk: document return value of ShortcutFunc 2022-01-18 10:58:47 +00:00
Luca Bacci
93bc97b7ec Merge branch 'fix-keyboard-shortcuts-win32' into 'main'
Win32 key events cleanup

See merge request GNOME/gtk!4349
2022-01-17 13:34:17 +00:00
Luca Bacci
243bb57a27 GdkWin32: Add translation result w/o CAPS LOCK to key events for accelerator matching 2022-01-17 14:14:55 +01:00
Luca Bacci
4916ebd05e GdkWin32: Remove _gdk_input_codepage variable
It's unused
2022-01-17 14:14:55 +01:00
Luca Bacci
8bbf48eb64 GdkWin32: Code reorganization for gdk_event_translate 2022-01-17 14:14:47 +01:00
Matthias Clasen
56920092b9 Merge branch 'ebassi/issue-4596' into 'main'
i18n: Detect more translatable attribute values

Closes #4596

See merge request GNOME/gtk!4383
2022-01-17 12:58:01 +00:00
Luca Bacci
672ab4fc35 Merge branch 'win32-imcontextime-ignore-control-characters' into 'main'
Fix handling of control characters & remove Win32-specific hacks from gdkkeyuni.c

Closes #2865

See merge request GNOME/gtk!4387
2022-01-17 11:44:12 +00:00
Philip Zander
52616dee8e GtkIMContextIME: Ignore ASCII control characters
Make GtkIMContextIME ignore ASCII control characters just like other
IMContext implementations (e.G. GtkIMContextSimple). Fixes bogus
characters appearing in text input fields (old bug 676077).
2022-01-17 12:03:01 +01:00
Chun-wei Fan
905f021bbd Revert "Bug 676077: Fix handling of Keyboard Input on Windows"
The actual code that does the IM context code handling on Windows now uses the
native Windows APIs to handle keystrokes, so this patch is no longer needed, as
it was found that it instead caused issues.

Pointed out in issue #2865.

This reverts commit fd6ce9975e.
2022-01-17 11:38:37 +01:00
Kritphong Mongkhonvanit
55016ada92 gdksurface-wayland: Fix contradictory assert
gdk_wayland_toplevel_inhibit_idle() contained a contradictory assert
that always fail. More specifically, in the branch that is supposed to
create the idle inhibitor, there is an assertion that it must already
exist and that the refcount must be greater than zero. This causes a
crash on WMs/DEs that use the ZWP idle inhibit manager protocol such as
KDE Plasma and Sway. Fix this by just asserting that the refcount is
zero instead.
2022-01-17 15:50:08 +07:00
Aurimas Černius
3bfaaab4f7 Updated Lithuanian translation 2022-01-16 21:38:08 +02:00
Emmanuele Bassi
9e83eb6501 i18n: Detect more translatable attribute values
GtkBuilder uses GMarkup, which defines a boolean attribute value as:

- yes/no
- true/false
- 1/0

The ITS file for GtkBuilder UI definitions is only using the first pair,
likely because Glade only ever used those values. GTK's own tools, though,
will typically simplify the full yes/no and true/false strings to 1 and 0,
to minimise the parsing time.

Fixes: #4596
2022-01-16 14:03:05 +00:00
Luca Bacci
ef1905a665 post install: query media modules 2022-01-14 18:57:03 +01:00
Sebastian Dröge
c44badd26a Mark various GskTransform functions as nullable in their return value
Various transforms are normalized with their next transform, and if they
end up being the identity transform will return NULL.

For example a translation by (x,y,z) and followed by (-x,-y,-z) will
result in NULL.
2022-01-14 11:57:23 +02:00
Jonas Ådahl
66ebc660b4 wayland/surface: Use wl_surface_offset() instead of x,y of attach()
This makes the hotspot of DND surfaces work when using the Vulkan and
OpenGL renderers.

This bumps the CI image used to the newly built image. This is needed to
install a new enough libwayland-client.so needed for wl_surface.offset.

This is done by adding wayland as a meson subproject, building it
on-demand if the version in the system is not new enough. As
libwayland-client.so is pulled in implicitly when linking to gtk4, the
compile step needs LD_LIBRARY_PATH set to make ld find the right library
to link to.
2022-01-14 09:27:07 +01:00
Luca Bacci
06e5da456f Merge branch 'win32-fix-altgr-gtk4' into 'main'
IMContextSimple/IMContextIME: Fix AltGr not working on Win32 [GTK4]

See merge request GNOME/gtk!4375
2022-01-13 23:02:50 +00:00
Boyuan Yang
689486eae5 Update Chinese (China) translation 2022-01-13 20:20:45 +00:00
Emmanuele Bassi
48dc6ecfe3 Merge branch 'ebassi/docs-repo-link' into 'main'
docs: Point source links to the correct branch

See merge request GNOME/gtk!4373
2022-01-13 16:58:47 +00:00
Philip Zander
b9bc7d9166 IMContextSimple/IMContextIME: Fix AltGr not working on Win32
The old code assumed that any key press containing Ctrl or Alt cannot be
regular text input. This is not correct on Win32 as AltGr = Ctrl + Alt.
2022-01-13 17:26:59 +01:00
Emmanuele Bassi
63ee135a1e Update the link to the development branch
The default development branch for GTK is now "main".
2022-01-13 14:42:34 +00:00
Emmanuele Bassi
ca2aa52ba9 docs: Point to the correct development branch
The default development branch of GTK is now "main".
2022-01-13 14:39:39 +00:00
Emmanuele Bassi
96d28738c9 docs: Point source links to the correct branch
The default development branch for GTK is now "main".
2022-01-13 14:39:03 +00:00
Piotr Drąg
e4b05e55e1 Update POTFILES.in 2022-01-13 13:43:15 +01:00
Luca Bacci
4a4a579fd9 Merge branch 'forward-port-gdk-win32-keymap-bugfixes-to-gtk4' into 'main'
GdkWin32Keymap bugfixes

See merge request GNOME/gtk!4372
2022-01-12 21:36:19 +00:00
Fran Dieguez
df716e5c9f Update Galician translation 2022-01-12 21:35:13 +00:00
Fran Dieguez
52000177d9 Update Galician translation 2022-01-12 21:34:57 +00:00
David Hogan
7d6257cb1e gdkkeys-win32: Perform keyboard layout substitution
For some users, GetKeyboardLayoutNameA() returns an alias instead of the
fully resolved keyboard layout identifier. In that case, we have to
query the registry to resolve the alias before we can look up the DLL
path.

See comments under https://gitlab.gnome.org/GNOME/gtk/-/issues/4610
2022-01-12 21:44:28 +01:00
Philip Zander
db0234ecb4 gdkkeys-win32: Fix handling of SGCAPS
Contrary to what you can read on the internet, SGCAPS keys don't work
by having capslock toggle the KBDCTRL bit, they actually have two
consecutive table entries, the first of which is for the normal
version and the second of which is for the capslocked version.

Background: SGCAPS is short for Swiss German caps because Swiss German
was the first layout to use this feature. For keys with the SGCAPS flag,
capslock has a different effect than pressing shift. For example:
Shift + ü = è,  CapsLock + ü = Ü,  CapsLock + Shift + ü = È
2022-01-12 21:44:24 +01:00
Philip Zander
438fad803e gdkkeys-win32: Fix crash when keyboard DLL failed to load
DLL loading failures should not happen under normal circumstances, but
we should at least try not to crash and and print better diagnostic
messages if they do happen.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/4610
2022-01-12 21:44:15 +01:00
Philip Zander
82f8f878bc gdkkeys-win32: Add keysym mapping for capslock key
Add missing mapping between VK_CAPITAL and GDK_KEY_Caps_Lock, so
applications get a meaningful keyval rather than ffffff.
2022-01-12 21:44:07 +01:00
Philip Zander
b0818f9535 gdkkeys-win32: Fix capslock handling
Previously, we treated CapsLock and KanaLock as part of the global
keyboard state, much like NumLock and ScrollLock, rather than using
the supplied modifier mask. This was because GDK does not have a
modifier mask for KanaLock, only for CapsLock, so it would not have been
possible to properly support it.

However, this approach ended up causing problems, with certain keyboard
shortcuts not registering when capslock was active. This was first
observed in Inkscape [0] and appears to affect shortcuts consisting of a
single key (like 'a') with no additional modifiers (wheareas shortcuts
like 'ctrl+a' work).

So now we are using the supplied GDK_LOCK_MASK instead, and dropped
support for KanaLock, which we probably don't need anyway (since regular
text input should be handled by the IME input module -- the keymap is
mainly for shortcuts and keybindings, where you don't really want
KanaLock).

[0] https://gitlab.com/inkscape/inkscape/-/issues/3082
2022-01-12 21:43:53 +01:00
Luca Bacci
c71cb35e9d Merge branch 'forward-port-rewrite-gdkwin32keymap-to-gtk4' into 'main'
Rewrite GdkWin32Keymap (V2)

Closes #1033 and #2055

See merge request GNOME/gtk!4338
2022-01-12 19:53:54 +00:00
Luca Bacci
5bf5d25bc1 Merge branch 'fix-build-no-pangoft' into 'main'
Improve and fix building font features on Windows (was: Fix builds without PangoFT2)

Closes #4605

See merge request GNOME/gtk!4339
2022-01-12 19:53:39 +00:00
Matthias Clasen
45d6b3ba51 Merge branch 'fabian.kirsch-main-patch-28134' into 'main'
corrected small typo input-handling.md

See merge request GNOME/gtk!4368
2022-01-12 19:38:10 +00:00
Matthias Clasen
e4e1b9ccbe Merge branch '4627-printing-Unref-old-spool_io-before-setting-new-one' into 'main'
printing: Unref old spool_io before setting new one

Closes #4627

See merge request GNOME/gtk!4370
2022-01-12 19:37:18 +00:00
Matthias Clasen
d50df7db37 Merge branch 'revert-texture-annotations' into 'main'
Revert "gir: Annotate `GdkTexture` constructors for reading from a...

See merge request GNOME/gtk!4371
2022-01-12 19:34:18 +00: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
Philip Zander
ea65abc7e2 Rewrite GdkWin32Keymap (load table directly from layout DLL)
The old code used repeated calls to `ToUnicodeEx` to populate
the translation table, which is slow and buggy. The new code
directly loads the layout driver DLLs from Windows.

See https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4338
2022-01-12 19:01:35 +01:00
Marek Kasik
915090f118 printing: Unref old spool_io before setting new one
Unref private spool_io of GtkPrintJob before setting it to a new one
in gtk_print_job_set_source_file() and gtk_print_job_set_source_fd()
to prevent a leak.

Fixes: #4627
2022-01-12 12:47:28 +01:00
Chun-wei Fan
629dcd3dcf meson.build: Don't apply iso-codes cflag on Windows
They are no longer applicable for Windows builds.
2022-01-12 17:29:30 +08:00
Chun-wei Fan
169172a9e0 demos: Always build font explorer demo
We are no longer using PangoFT2 APIs in this demo, so make sure that we build
it on all builds since we already depend on a HarfBuzz/Pango version that
provide everything that we need here.

Drop the unnecessary pangofc-font.h include as a result.
2022-01-12 17:29:30 +08:00
Chun-wei Fan
0a3fad4d47 gtk-demo/language-names.c: Acquire language names natively on Windows
Like what was done on gtk/language-names.c, acquire the language names via the
native Windows NLS APIs, eliminating a run-time dependency on iso-codes on
Windows.
2022-01-12 17:29:30 +08:00
Chun-wei Fan
b666a767e4 language-names: Use Windows APIs to acquire language names
Instead of relying on the iso-codes package, use the native Windows NLS APIs to
acquire the localized (translated) language names so that we do not need to
incur an extra runtime dependency on Windows.  It's not coverering 100% of the
languages that we would like to support through this, but should cover much of
the things that are required.
2022-01-12 17:29:30 +08:00
Chun-wei Fan
ee2dd1acc7 gtk/meson.build: Fix builds without PangoFT2
We aren't really using PangoFT2 for [language|script]-names.c, and are
always using items from them, so make sure they are being built.

Also always include the pangoft2 dependency in gtk_dep if it is found.
2022-01-12 17:29:28 +08:00
Fabian Kirsch
4f36583898 corrected small typo input-handling.md 2022-01-12 09:02:01 +00: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
563 changed files with 120739 additions and 125968 deletions

View File

@@ -25,7 +25,7 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v35"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v36"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
.only-default:
@@ -88,7 +88,7 @@ fedora-x86_64:
- meson compile -C _build
- meson install -C _build
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
- meson compile -C _build_hello
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
- .gitlab-ci/run-tests.sh _build x11
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build waylandgles
@@ -156,6 +156,11 @@ msys2-mingw64:
variables:
MSYSTEM: "MINGW64"
CHERE_INVOKING: "yes"
artifacts:
when: always
expose_as: 'Windows_DLL_MSYS2_64_bit_toolchain'
paths:
- "${CI_PROJECT_DIR}/_build/gtkdll.tar.gz"
macos:
extends: .only-default
@@ -167,7 +172,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 +226,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 +238,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 +250,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 +262,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 +273,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 +351,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

View File

@@ -95,6 +95,8 @@ RUN dnf -y install \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf install -y 'dnf-command(builddep)' \
&& dnf builddep -y wayland \
&& dnf clean all
# Enable sudo for wheel users

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

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'),

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'),

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."

View File

@@ -5,8 +5,8 @@ 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
meson -Dmedia-gstreamer=disabled _build || goto :error
pip3 install --upgrade --user meson==0.59 || goto :error
meson -Ddebug=false -Dmedia-gstreamer=disabled _build || goto :error
ninja -C _build || goto :error
goto :EOF

View File

@@ -15,9 +15,9 @@ pacman --noconfirm -Suy
pacman --noconfirm -S --needed \
base-devel \
git \
mingw-w64-$MSYS2_ARCH-toolchain \
mingw-w64-$MSYS2_ARCH-cc \
mingw-w64-$MSYS2_ARCH-ccache \
mingw-w64-$MSYS2_ARCH-pkg-config \
mingw-w64-$MSYS2_ARCH-pkgconf \
mingw-w64-$MSYS2_ARCH-gobject-introspection \
mingw-w64-$MSYS2_ARCH-meson \
mingw-w64-$MSYS2_ARCH-adwaita-icon-theme \
@@ -30,8 +30,9 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-libepoxy \
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-gst-plugins-bad-libs \
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
@@ -72,3 +73,5 @@ unset CCACHE_DISABLE
ninja -C _build
ccache --show-stats
tar zcf _build/gtkdll.tar.gz _build/gtk/libgtk*.dll

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
<!--

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

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

331
NEWS
View File

@@ -1,3 +1,334 @@
Overview of Changes in 4.6.3, 21-04-2022
========================================
* GtkOverlay:
- Bring back positional style classes
* GtkFileChooser:
- Prevent unwanted completion popups
- Fix small problems in save mode
- Fix buildable suport of GtkFileFilter
* GtkPopover:
- Fix button positions in right-to-left locales
* GtkLabel:
- Fix small issues with link handling
* Tooltips:
- Don't restrict the minimum tooltip length
* Theme:
- Don't use opacity for overlay scrollbars
- Fix selection text color in vertical spin buttons
* GSK:
- Accept textures that are generated by webkit
- Align offscreen rendering to the pixel grid
* Accessibility
- Fix a crash in startup when orca is running
* Input:
- Fix display changes in GtkIMMultiContext
- Fix activating on-screen keyboards
- Always propagate hold events in GtkEventControllerScroll
* Windows:
- Fix a critical warning in clipboard handling
- Report serial numbers for events
* MacOS:
- Prevent fullscreen transition reentrancy
* Translation updates
British English
Czech
German
Indonesian
Latvian
Overview of Changes in 4.6.2, 18-03-2022
========================================
* GtkScrolledWindow:
- Set scroll-to-focus on viewports
- Avoid doubly triggering deceleration
* GtkEntry:
- Stop cursor blinking on focus-out
* Emoji:
- Update Emoji data to CLDR 40 and Unicode 14
- Add more locales for Emoji data (da, de, en, es,
fr hu, it, ko, lt, ms, nl, pl, pt, ru, s, uk zh)
* GDK
- Optimize texture conversions on x86 and ARM
- Use EGK_KHR_swap_buffers_with_damage if available
* GSK
- Avoid clearing opaque regions
- Support using a non-default framebuffer
- Handle large viewports by tiling
* Wayland:
- Prefer xdg-activation over gtk-shell
- text protocol: Fix text caret location
- text protocol: Use serials to control outbound messages
* Inspector:
- Show app ID and resource path
* Demos:
- widget-factory: Handle F11 to toggle fullscreen
* Tools:
- gtk-builder-tool: Allow use without display
* Windows:
- Fix preedit window placement on HiDPI
- Build improvements
- Fix fullscreen handling
* MacOS:
- Fix scrolling with an external mouse
- Fix kinetic scrolling with overshoot
- Improve monitor detection
- Many input handling fixes
- Support OpenGL accelerated video playback
- Support fullscreen
- Improve interactive window resizing and moving
- Fix backdrop state handling
- Fix GtkFileChooserNative filtering
- Use CALayer and IOSurface for rendering
- Use per monitor CVDisplayLink to support mixed-rate monitors
- Start applications in foreground
- Fix cursor blink time
* Translation updates
Basque
Brazilian Portuguese
Catalan
Chinese (China)
Croatian
Czech
Danish
Finnish
Galician
German
Hebrew
Hungarian
Italian
Kazakh
Korean
Lithuanian
Norwegian Bokmål
Persian
Poliah
Portuguese
Russian
Slovak
Slovenian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.6.1, 11-02-2022
========================================
* GtkFontChooser:
- Stop using PangoFc api
- Fix a crash
- Use new HarfBuzz api
* GtkMenuButton:
- Update accessible description
* GtkTextView:
- Fix intra-widget dnd
* Printing:
- Fix an fd leak
* Input:
- Make sure input methods get focus-in events
- Always flush events to avoid scroll event pileup
- Support hold events
- Update keysyms from libxkbcommon
* Theme:
- Improve text selection legibility
* Introspection:
- Add missing nullable annotations everywhere
* Build:
- Make stack noexec again
- Avoid symbol leaks
- Drop unneeded script data
* Windows:
- Stop using WM_SYNCPAINT
- Relax check for GL 3.x legacy contexts
- Use native apis for language names
- Rewrite the keymap code
- Use the GL renderer by default
* Wayland:
- Fix support for the new high-contrast setting
- Avoid redundant scale changes
- Fix DND hotspot handling
- Don't always restore the saved size when floating
* MacOS:
- Various performance improvements
* Translation updates:
Brazilian Portuguese
Catalan
Chinese (China)
Galician
Hebrew
Japanese
Lithuanian
Persian
Polish
Portuguese
Russian
Slovenian
Spanish
Ukrainian
Overview of Changes in 4.6.0, 30-12-2021
========================================
* 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
============================

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
------------------

View File

@@ -43,7 +43,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git",
"branch" : "main"
}
]
},
@@ -164,6 +165,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 +193,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}

View File

@@ -43,7 +43,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git",
"branch" : "main"
}
]
},
@@ -93,6 +94,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 +122,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}

View File

@@ -43,7 +43,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git"
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git",
"branch" : "main"
}
]
},
@@ -93,6 +94,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 +122,8 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}

View File

@@ -13,7 +13,7 @@ if 'DESTDIR' not in os.environ:
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version)
gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends')
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
gtk_mediamodule_dir = os.path.join(gtk_moduledir, 'media')
print('Compiling GSettings schemas...')
glib_compile_schemas = subprocess.check_output(['pkg-config',
@@ -40,6 +40,6 @@ if 'DESTDIR' not in os.environ:
gio_querymodules = 'gio-querymodules'
subprocess.call([gio_querymodules, gtk_printmodule_dir])
print('Updating module cache for input methods...')
os.makedirs(gtk_immodule_dir, exist_ok=True)
subprocess.call([gio_querymodules, gtk_immodule_dir])
print('Updating module cache for media backends...')
os.makedirs(gtk_mediamodule_dir, exist_ok=True)
subprocess.call([gio_querymodules, gtk_mediamodule_dir])

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,
)

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
demos/gtk-demo/clipboard.ui Normal file
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>

View File

@@ -24,6 +24,7 @@ do_cursors (GtkWidget *do_widget)
builder = gtk_builder_new_from_resource ("/cursors/cursors.ui");
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));
g_signal_connect (window, "destroy",
@@ -34,9 +35,7 @@ do_cursors (GtkWidget *do_widget)
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
{
gtk_window_destroy (GTK_WINDOW (window));
}
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

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>

View File

@@ -12,7 +12,6 @@
*/
#include <gtk/gtk.h>
#include <pango/pangofc-font.h>
#include <hb.h>
#include <hb-ot.h>
#include <glib/gi18n.h>

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)
{

View File

@@ -18,15 +18,81 @@
#include "language-names.h"
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#ifndef ISO_CODES_PREFIX
#define ISO_CODES_PREFIX "/usr"
#endif
#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes"
#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale"
#endif
static GHashTable *language_map;
#ifdef G_OS_WIN32
/* if we are using native Windows use native Windows API for language names */
static BOOL CALLBACK
get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
{
wchar_t *langname_w = NULL;
wchar_t locale_abbrev_w[9];
gchar *langname, *locale_abbrev, *locale, *p;
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
PangoLanguage *lang;
gint langname_size, locale_abbrev_size;
langname_size = GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, 0);
if (langname_size == 0)
return FALSE;
langname_w = g_new0 (wchar_t, langname_size);
if (langname_size == 0)
return FALSE;
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
/*
* Track 3+-letter ISO639-2/3 language codes as well (these have a max length of 9 including terminating NUL)
* ISO639-2: iso639_lctypes[0] = LOCALE_SISO639LANGNAME
* ISO639-3: iso639_lctypes[1] = LOCALE_SISO639LANGNAME2
*/
for (i = 0; i < 2; i++)
{
locale_abbrev_size = GetLocaleInfoEx (locale_w, iso639_lctypes[i], locale_abbrev_w, 0);
if (locale_abbrev_size > 0)
{
GetLocaleInfoEx (locale_w, iso639_lctypes[i], locale_abbrev_w, locale_abbrev_size);
locale_abbrev = g_utf16_to_utf8 (locale_abbrev_w, -1, NULL, NULL, NULL);
lang = pango_language_from_string (locale_abbrev);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
g_free (locale_abbrev);
}
}
g_free (locale);
g_free (langname_w);
return TRUE;
}
#else /* non-Windows */
static char *
get_first_item_in_semicolon_list (const char *list)
{
@@ -210,6 +276,7 @@ languages_variant_init (const char *variant)
g_free (filename);
g_free (buf);
}
#endif
static void
languages_init (void)
@@ -218,8 +285,13 @@ languages_init (void)
return;
language_map = g_hash_table_new_full (NULL, NULL, NULL, g_free);
#ifdef G_OS_WIN32
g_return_if_fail (EnumSystemLocalesEx (&get_win32_all_locales_scripts, LOCALE_ALL, (LPARAM) language_map, NULL));
#else
languages_variant_init ("iso_639");
languages_variant_init ("iso_639_3");
#endif
}
const char *

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 ());
@@ -1040,7 +1040,7 @@ out:
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
}
else
gtk_widget_show (GTK_WIDGET (window));
gtk_window_present (GTK_WINDOW (window));
if (autoquit)
g_timeout_add_seconds (1, auto_quit, app);

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>

View File

@@ -98,6 +98,7 @@ demos = files([
'transparent.c',
'tree_store.c',
'video_player.c',
'font_features.c',
])
gtkdemo_deps = [ libgtk_dep, ]
@@ -128,19 +129,14 @@ extra_demo_sources = files([
'script-names.c',
'unicode-names.c',
'suggestionentry.c',
'language-names.c',
])
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files(['font_features.c'])
extra_demo_sources += files(['language-names.c'])
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
endif
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')
@@ -164,7 +160,7 @@ endif
ld = find_program('ld', required : false)
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
glib_compile_resources = find_program('glib-compile-resources')
# Create the resource blob
@@ -174,6 +170,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
depfile : 'gtkdemo.gresource.d',
command : [glib_compile_resources,
'--generate',
'--internal',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
@@ -187,6 +184,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
depfile : 'gtkdemo_resources.c.d',
command : [glib_compile_resources,
'--generate-source',
'--internal',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
@@ -200,6 +198,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
input : gtkdemo_gresource,
output : 'gtkdemo_resources.o',
command : [ld,
'-z', 'noexecstack',
'-r',
'-b','binary',
'@INPUT@',
@@ -210,6 +209,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
input : gtkdemo_resources_binary,
output : 'gtkdemo_resources2.o',
command : [objcopy,
'--strip-all',
'--add-symbol','_g_binary_gtkdemo_resource_data=.data:0',
'@INPUT@',
'@OUTPUT@'])
@@ -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,
)

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

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);

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 ());

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,
)

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,

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,
)

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 ());

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
{

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>

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,
)

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 ());
@@ -871,7 +871,7 @@ activate (GApplication *app)
update_ui ();
gtk_widget_show (main_window);
gtk_window_present (GTK_WINDOW (main_window));
}
static void

View File

@@ -8,7 +8,7 @@ endif
ld = find_program('ld', required : false)
if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
glib_compile_resources = find_program('glib-compile-resources')
# Create the resource blob
@@ -18,6 +18,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
depfile: 'widgetfactory.gresource.d',
command : [glib_compile_resources,
'--generate',
'--internal',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
@@ -31,6 +32,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
depfile: 'widgetfactory_resources.c.d',
command : [glib_compile_resources,
'--generate-source',
'--internal',
'--target=@OUTPUT@',
'--dependency-file=@DEPFILE@',
'--sourcedir=' + meson.current_source_dir(),
@@ -44,6 +46,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
input : widgetfactory_gresource,
output : 'widgetfactory_resources.o',
command : [ld,
'-z', 'noexecstack',
'-r',
'-b','binary',
'@INPUT@',
@@ -54,6 +57,7 @@ if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_ad
input : widgetfactory_resources_binary,
output : 'widgetfactory_resources2.o',
command : [objcopy,
'--strip-all',
'--add-symbol','_g_binary_widgetfactory_resource_data=.data:0',
'@INPUT@',
'@OUTPUT@'])
@@ -74,7 +78,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,
)

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 },
@@ -2037,6 +2053,7 @@ activate (GApplication *app)
{ "win.open", { "<Control>o", NULL } },
{ "win.record", { "<Control>r", NULL } },
{ "win.lock", { "<Control>l", NULL } },
{ "win.fullscreen", { "F11", NULL } },
};
struct {
const char *action_and_target;
@@ -2182,7 +2199,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");
@@ -2343,7 +2360,7 @@ activate (GApplication *app)
model = (GMenuModel *)gtk_builder_get_object (builder, "new_style_context_menu_model");
set_up_context_popover (widget, model);
gtk_widget_show (GTK_WIDGET (window));
gtk_window_present (window);
g_object_unref (builder);
}

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>

View File

@@ -7,20 +7,21 @@ authors = "GTK Development Team"
logo_url = "gtk-logo.svg"
license = "GPL-2.1-or-later"
description = "The GTK toolkit"
dependencies = [ "GObject-2.0" ]
devhelp = true
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
dependencies = ["Gdk-4.0"]
[dependencies."Gdk-4.0"]
name = "GDK"
description = "The GTK drawing kit"
docs_url = "https://docs.gtk.org/gdk/"
[theme]
name = "basic"
show_index_summary = true
[source-location]
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/master/"
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
[extra]
content_images = [

View File

@@ -7,20 +7,20 @@ authors = "GTK Development Team"
logo_url = "gtk-logo.svg"
license = "GPL-2.1-or-later"
description = "The GTK toolkit"
dependencies = [ "GObject-2.0" ]
dependencies = ["Gdk-4.0"]
devhelp = true
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
[dependencies."Gdk-4.0"]
name = "GDK"
description = "The GTK drawing kit"
docs_url = "https://docs.gtk.org/gdk4/"
[theme]
name = "basic"
show_index_summary = true
[source-location]
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/master/"
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
[extra]
content_images = [

View File

@@ -3,11 +3,12 @@ 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"
description = "The GTK toolkit"
dependencies = [ "GObject-2.0", "cairo-1.0", "Pango-1.0", "GdkWayland-4.0", "GdkX11-4.0" ]
dependencies = ["GObject-2.0", "Gio-2.0", "cairo-1.0", "Pango-1.0", "GdkPixbuf-2.0"]
devhelp = true
search_index = true
@@ -16,6 +17,11 @@ search_index = true
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
[dependencies."Gio-2.0"]
name = "GIO"
description = "GObject Interfaces and Objects, Networking, IPC, and I/O"
docs_url = "https://docs.gtk.org/gio/"
[dependencies."cairo-1.0"]
name = "Cairo"
description = "A 2D graphics library with support for multiple output devices"
@@ -26,12 +32,19 @@ search_index = true
description = "Text shaping and rendering"
docs_url = "https://docs.gtk.org/Pango/"
[dependencies."GdkWayland-4.0"]
[dependencies."GdkPixbuf-2.0"]
name = "GdkPixbuf"
description = "Image data loading"
docs_url = "https://docs.gtk.org/gdk-pixbuf/"
related = ["GdkWayland-4.0", "GdkX11-4.0"]
[related."GdkWayland-4.0"]
name = "GdkWayland"
description = "GDK Wayland Backend"
docs_url = "https://docs.gtk.org/gdk4-wayland/"
[dependencies."GdkX11-4.0"]
[related."GdkX11-4.0"]
name = "GdkX11"
description = "GDK X11 Backend"
docs_url = "https://docs.gtk.org/gdk4-x11/"
@@ -42,7 +55,7 @@ show_index_summary = true
show_class_hierarchy = true
[source-location]
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/master/"
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
[extra]
content_files = [

View File

@@ -3,29 +3,21 @@ 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"
description = "The GTK toolkit"
dependencies = [ "GObject-2.0", "Graphene-1.0", "Pango-1.0", "Gdk-4.0" ]
devhelp = true
search_index = true
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
dependencies = ["Graphene-1.0", "Gdk-4.0"]
[dependencies."Graphene-1.0"]
name = "Graphene"
description = "A thin layer of mathematical types for 3D libraries"
docs_url = "https://ebassi.github.io/graphene/docs/"
[dependencies."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://docs.gtk.org/Pango/"
[dependencies."Gdk-4.0"]
name = "GDK"
description = "The GTK windowing system abstraction"
@@ -37,7 +29,7 @@ show_index_summary = true
show_class_hierarchy = true
[source-location]
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/master/"
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
[extra]
content_images = [

View File

@@ -170,7 +170,7 @@ activate (GtkApplication *app,
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
gtk_window_set_child (GTK_WINDOW (window), box);
button = gtk_button_new_with_label ("Hello World");
@@ -752,7 +752,7 @@ templates, resources, application menus, settings, [class@Gtk.HeaderBar], [class
The full, buildable sources for these examples can be found in the
`examples` directory of the GTK source distribution, or
[online](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples) in the GTK
[online](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples) in the GTK
source code repository. You can build each example separately by using make
with the `Makefile.example` file. For more information, see the `README`
included in the examples directory.
@@ -972,7 +972,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application2/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application2/exampleappwin.c))
You may have noticed that we used the `_from_resource()` variant of the function
that sets a template. Now we need to use
@@ -1043,7 +1043,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application3/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application3/exampleappwin.c))
Now we revisit the `example_app_window_open()` function that is called for each
commandline argument, and construct a GtkTextView that we then add as a page
@@ -1087,7 +1087,7 @@ example_app_window_open (ExampleAppWindow *win,
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application3/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application3/exampleappwin.c))
Lastly, we add a [class@Gtk.StackSwitcher] to the titlebar area in the UI file, and we
tell it to display information about our stack.
@@ -1188,7 +1188,7 @@ example_app_class_init (ExampleAppClass *class)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application4/exampleapp.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application4/exampleapp.c))
Our preferences menu item does not do anything yet, but the Quit menu item
is fully functional. Note that it can also be activated by the usual Ctrl-Q
@@ -1258,7 +1258,7 @@ example_app_window_init (ExampleAppWindow *win)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application5/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application5/exampleappwin.c))
The code to connect the font setting is a little more involved, since there
is no simple object property that it corresponds to, so we are not going to
@@ -1429,7 +1429,7 @@ preferences_activated (GSimpleAction *action,
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application6/exampleapp.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application6/exampleapp.c))
After all this work, our application can now show a preference dialog
like this:
@@ -1549,7 +1549,7 @@ example_app_window_init (ExampleAppWindow *win)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application7/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application7/exampleappwin.c))
With the search bar, our application now looks like this:
@@ -1682,7 +1682,7 @@ example_app_window_init (ExampleAppWindow *win)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application8/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application8/exampleappwin.c))
What our application looks like now:
@@ -1760,10 +1760,10 @@ example_app_window_init (ExampleAppWindow *win)
...
```
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application9/exampleappwin.c))
([full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application9/exampleappwin.c))
We also need a function that counts the lines of the currently active tab,
and updates the `lines` label. See the [full source](https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application9/exampleappwin.c)
and updates the `lines` label. See the [full source](https://gitlab.gnome.org/GNOME/gtk/blob/main/examples/application9/exampleappwin.c)
if you are interested in the details.
This brings our example application to this appearance:

View File

@@ -3,28 +3,15 @@ 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"
description = "The GTK toolkit"
dependencies = [ "GObject-2.0", "Graphene-1.0", "Pango-1.0", "Gdk-4.0", "Gsk-4.0" ]
devhelp = true
search_index = true
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
[dependencies."Graphene-1.0"]
name = "Graphene"
description = "A thin layer of mathematical types for 3D libraries"
docs_url = "https://ebassi.github.io/graphene/docs"
[dependencies."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://docs.gtk.org/Pango/"
dependencies = ["Gdk-4.0", "Gsk-4.0"]
[dependencies."Gdk-4.0"]
name = "GDK"
@@ -36,13 +23,35 @@ search_index = true
description = "The GTK rendering abstraction"
docs_url = "https://docs.gtk.org/gsk4/"
related = ["Pango-1.0", "Graphene-1.0", "GObject-2.0", "Gio-2.0"]
[related."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
[related."Gio-2.0"]
name = "GIO"
description = "GObject Interfaces and Objects, Networking, IPC, and I/O"
docs_url = "https://docs.gtk.org/gio/"
[related."Graphene-1.0"]
name = "Graphene"
description = "A thin layer of mathematical types for 3D libraries"
docs_url = "https://ebassi.github.io/graphene/docs"
[related."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://docs.gtk.org/Pango/"
[theme]
name = "basic"
show_index_summary = true
show_class_hierarchy = true
[source-location]
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/master/"
base_url = "https://gitlab.gnome.org/GNOME/gtk/-/blob/main/"
[extra]
# The same order will be used when generating the index

View File

@@ -42,7 +42,7 @@ univocally identifies events that are related to the same
interaction.
When GTK creates a `GdkSurface`, it connects to the ::event
signal on it, which receives all of these input events. Surfaces have
signal on it, which receives all of these input events. Surfaces
have signals and properties, e.g. to deal with window management
related events.

View File

@@ -57,7 +57,7 @@ if get_option('gtk_doc')
)
endif
rst2man = find_program('rst2man', required: false)
rst2man = find_program('rst2man', 'rst2man.py', required: false)
if get_option('man-pages') and not rst2man.found()
error('No rst2man found, but man pages were explicitly enabled')
endif

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
@@ -1373,5 +1382,5 @@ a new family of widgets for this purpose that uses list models instead
of tree models, and widgets instead of cell renderers.
To learn more about the new list widgets, you can read the [List Widget
Overview](#ListWidget).
Overview](https://docs.gtk.org/gtk4/section-list-widget.html).

View File

@@ -26,7 +26,7 @@ GTK with your code applied, and run the test suite, on multiple platforms
and architectures, and verify that nothing breaks. They also allow us to
do proper code reviews, so we can iterate over the changes.
You should follow the [contribution guide](https://gitlab.gnome.org/GNOME/gtk/blob/master/CONTRIBUTING.md)
You should follow the [contribution guide](https://gitlab.gnome.org/GNOME/gtk/blob/main/CONTRIBUTING.md)
for GTK, available on GitLab.
If you want to discuss your approach before or after working on it,

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
@@ -375,7 +372,7 @@ library you are using:
The `test` accessibility backend is recommended for test suites and remote
continuous integration pipelines.
### `XDG_DTA_HOME`, `XDG_DATA_DIRS`
### `XDG_DATA_HOME`, `XDG_DATA_DIRS`
GTK uses these environment variables to locate icon themes
and MIME information. For more information, see the

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

View File

@@ -31,8 +31,7 @@
* `GdkAppLaunchContext` handles launching an application in a graphical context.
*
* It is an implementation of `GAppLaunchContext` that provides startup
* notification and allows to launch applications on a specific screen
* or workspace.
* notification and allows to launch applications on a specific workspace.
*
* ## Launching an application
*
@@ -41,7 +40,6 @@
*
* context = gdk_display_get_app_launch_context (display);
*
* gdk_app_launch_context_set_display (display);
* gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));
*
* if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
@@ -196,6 +194,10 @@ gdk_app_launch_context_get_display (GdkAppLaunchContext *context)
* This only works when running under a window manager that
* supports multiple workspaces, as described in the
* [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec).
* Specifically this sets the `_NET_WM_DESKTOP` property described
* in that spec.
*
* This only works when using the X11 backend.
*
* When the workspace is not specified or @desktop is set to -1,
* it is up to the window manager to pick one, typically it will

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)
@@ -576,7 +576,7 @@ gdk_content_deserialize_async (GInputStream *stream,
/**
* gdk_content_deserialize_finish:
* @result: the `GAsyncResult`
* @value: return location for the result of the operation
* @value: (out): return location for the result of the operation
* @error: return location for an error
*
* Finishes a content deserialization operation.
@@ -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;

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);

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.

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;

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

View File

@@ -1238,7 +1238,7 @@ gdk_device_get_num_touches (GdkDevice *device)
*
* Retrieves the current tool for @device.
*
* Returns: (transfer none): the `GdkDeviceTool`
* Returns: (transfer none) (nullable): the `GdkDeviceTool`
*/
GdkDeviceTool *
gdk_device_get_device_tool (GdkDevice *device)

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)
{
@@ -1746,12 +1721,12 @@ gdk_display_init_egl (GdkDisplay *self,
self->have_egl_buffer_age =
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_buffer_age");
self->have_egl_swap_buffers_with_damage =
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_swap_buffers_with_damage");
self->have_egl_no_config_context =
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
self->have_egl_pixel_format_float =
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_pixel_format_float");
self->have_egl_win32_libangle =
epoxy_has_egl_extension (priv->egl_display, "EGL_ANGLE_d3d_share_handle_client_buffer");
if (self->have_egl_no_config_context)
priv->egl_config_high_depth = gdk_display_create_egl_config (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)
{

View File

@@ -107,9 +107,9 @@ struct _GdkDisplay
/* egl info */
guint have_egl_buffer_age : 1;
guint have_egl_swap_buffers_with_damage : 1;
guint have_egl_no_config_context : 1;
guint have_egl_pixel_format_float : 1;
guint have_egl_win32_libangle : 1;
};
struct _GdkDisplayClass

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;
@@ -692,14 +719,6 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display)
gdk_event_unref (old_event);
}
if (g_queue_get_length (&display->queued_events) == 1 &&
g_queue_peek_head_link (&display->queued_events) == scrolls)
{
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
if (clock) /* might be NULL if surface was destroyed */
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
}
}
static void
@@ -714,24 +733,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 +777,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,26 +813,17 @@ _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);
g_queue_delete_link (&display->queued_events, pending_motions);
pending_motions = next;
}
if (g_queue_get_length (&display->queued_events) == 1 &&
g_queue_peek_head_link (&display->queued_events) == pending_motions)
{
GdkFrameClock *clock = gdk_surface_get_frame_clock (pending_motion_surface);
if (clock) /* might be NULL if surface was destroyed */
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
}
}
void
@@ -903,6 +927,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 +1156,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 +1209,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 +2461,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 +2488,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,
};
@@ -2458,22 +2496,32 @@ static const GdkEventTypeInfo gdk_touchpad_event_info = {
GDK_DEFINE_EVENT_TYPE (GdkTouchpadEvent, gdk_touchpad_event,
&gdk_touchpad_event_info,
GDK_EVENT_TYPE_SLOT (GDK_TOUCHPAD_SWIPE)
GDK_EVENT_TYPE_SLOT (GDK_TOUCHPAD_PINCH))
GDK_EVENT_TYPE_SLOT (GDK_TOUCHPAD_PINCH)
GDK_EVENT_TYPE_SLOT (GDK_TOUCHPAD_HOLD))
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 +2534,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;
@@ -2514,6 +2571,27 @@ gdk_touchpad_event_new_pinch (GdkSurface *surface,
return (GdkEvent *) self;
}
GdkEvent *
gdk_touchpad_event_new_hold (GdkSurface *surface,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers)
{
GdkTouchpadEvent *self = gdk_event_alloc (GDK_TOUCHPAD_HOLD, surface, device, time);
self->state = state;
self->phase = phase;
self->x = x;
self->y = y;
self->n_fingers = n_fingers;
return (GdkEvent *) self;
}
/**
* gdk_touchpad_event_get_gesture_phase:
* @event: (type GdkTouchpadEvent): a touchpad event
@@ -2529,7 +2607,8 @@ gdk_touchpad_event_get_gesture_phase (GdkEvent *event)
g_return_val_if_fail (GDK_IS_EVENT (event), 0);
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_PINCH) ||
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_SWIPE), 0);
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_SWIPE) ||
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_HOLD), 0);
return self->phase;
}
@@ -2549,7 +2628,8 @@ gdk_touchpad_event_get_n_fingers (GdkEvent *event)
g_return_val_if_fail (GDK_IS_EVENT (event), 0);
g_return_val_if_fail (GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_PINCH) ||
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_SWIPE), 0);
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_SWIPE) ||
GDK_IS_EVENT_TYPE (event, GDK_TOUCHPAD_HOLD), 0);
return self->n_fingers;
}
@@ -2907,7 +2987,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

View File

@@ -169,6 +169,8 @@ typedef struct _GdkTouchpadEvent GdkTouchpadEvent;
* @GDK_PAD_RING: A tablet pad axis event from a "ring".
* @GDK_PAD_STRIP: A tablet pad axis event from a "strip".
* @GDK_PAD_GROUP_MODE: A tablet pad group mode change.
* @GDK_TOUCHPAD_HOLD: A touchpad hold gesture event, the current state
* is determined by its phase field. Since: 4.6
* @GDK_EVENT_LAST: marks the end of the GdkEventType enumeration.
*
* Specifies the type of the event.
@@ -203,6 +205,7 @@ typedef enum
GDK_PAD_RING,
GDK_PAD_STRIP,
GDK_PAD_GROUP_MODE,
GDK_TOUCHPAD_HOLD,
GDK_EVENT_LAST /* helper variable for decls */
} GdkEventType;

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,
@@ -530,6 +533,15 @@ GdkEvent * gdk_touchpad_event_new_pinch (GdkSurface *surface,
double scale,
double angle_delta);
GdkEvent * gdk_touchpad_event_new_hold (GdkSurface *surface,
GdkDevice *device,
guint32 time,
GdkModifierType state,
GdkTouchpadGesturePhase phase,
double x,
double y,
int n_fingers);
GdkEvent * gdk_pad_event_new_ring (GdkSurface *surface,
GdkDevice *device,
guint32 time,

View File

@@ -117,6 +117,7 @@ typedef struct {
#ifdef HAVE_EGL
EGLContext egl_context;
EGLBoolean (*eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
#endif
} GdkGLContextPrivate;
@@ -151,6 +152,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 +186,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)
@@ -273,7 +279,11 @@ gdk_gl_context_real_realize (GdkGLContext *context,
int i = 0;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
gdk_gl_context_get_required_version (context, &major, &minor);
if (share != NULL)
gdk_gl_context_get_required_version (share, &major, &minor);
else
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
forward_bit = gdk_gl_context_get_forward_compatible (context);
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ||
@@ -411,6 +421,11 @@ gdk_gl_context_real_realize (GdkGLContext *context,
gdk_gl_context_set_is_legacy (context, legacy_bit);
if (epoxy_has_egl_extension (egl_display, "EGL_KHR_swap_buffers_with_damage"))
priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageKHR");
else if (epoxy_has_egl_extension (egl_display, "EGL_EXT_swap_buffers_with_damage"))
priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageEXT");
gdk_profiler_end_mark (start_time, "realize GdkWaylandGLContext", NULL);
return api;
@@ -574,8 +589,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
}
@@ -599,7 +614,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "EGL", "swap buffers");
if (display->have_egl_swap_buffers_with_damage)
if (priv->eglSwapBuffersWithDamage)
{
EGLint stack_rects[4 * 4]; /* 4 rects */
EGLint *heap_rects = NULL;
@@ -623,7 +638,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
rects[j++] = rect.width * scale;
rects[j++] = rect.height * scale;
}
eglSwapBuffersWithDamageEXT (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
priv->eglSwapBuffersWithDamage (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
g_free (heap_rects);
}
else
@@ -639,6 +654,12 @@ gdk_gl_context_surface_resized (GdkDrawContext *draw_context)
gdk_gl_context_clear_old_updated_area (context);
}
static guint
gdk_gl_context_real_get_default_framebuffer (GdkGLContext *self)
{
return 0;
}
static void
gdk_gl_context_class_init (GdkGLContextClass *klass)
{
@@ -650,6 +671,7 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
klass->is_shared = gdk_gl_context_real_is_shared;
klass->make_current = gdk_gl_context_real_make_current;
klass->clear_current = gdk_gl_context_real_clear_current;
klass->get_default_framebuffer = gdk_gl_context_real_get_default_framebuffer;
draw_context_class->begin_frame = gdk_gl_context_real_begin_frame;
draw_context_class->end_frame = gdk_gl_context_real_end_frame;
@@ -997,16 +1019,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);
}
}
/**
@@ -1026,26 +1065,29 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
gboolean force_gles = FALSE;
#ifdef G_ENABLE_DEBUG
GdkDisplay *display;
#endif
int default_major, default_minor;
int maj, min;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
#ifdef G_ENABLE_DEBUG
display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
#ifdef G_ENABLE_DEBUG
force_gles = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES);
#endif
/* libANGLE on Windows at least requires GLES 3.0+ */
if (display->have_egl_win32_libangle)
force_gles = TRUE;
/* Default fallback values for uninitialised contexts; we
* enforce a context version number of 3.2 for desktop GL,
* and 2.0 for GLES
*/
if (gdk_gl_context_get_use_es (context) || force_gles)
{
default_major = 2;
default_major = display->have_egl_win32_libangle ? 3 : 2;
default_minor = 0;
}
else
@@ -1323,6 +1365,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 +1427,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 +1707,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:
*

View File

@@ -71,6 +71,8 @@ struct _GdkGLContextClass
gboolean (* is_shared) (GdkGLContext *self,
GdkGLContext *other);
guint (* get_default_framebuffer) (GdkGLContext *self);
};
typedef struct {
@@ -99,6 +101,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 +113,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,

View File

@@ -21,6 +21,7 @@
#include "gdkgltextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
@@ -174,10 +175,19 @@ gdk_gl_texture_do_download (gpointer texture_,
glGenFramebuffers (1, &fbo);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (self->context), gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
if (gdk_gl_context_check_version (self->context, 4, 3, 3, 1))
{
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (self->context), gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
}
if (download->format == actual_format &&
(download->stride == expected_stride))
@@ -305,9 +315,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;
}
@@ -353,6 +365,42 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
texture->format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
break;
case GL_RGBA:
{
GLint red_size = 0;
GLint green_size = 0;
GLint blue_size = 0;
GLint alpha_size = 0;
GLint red_type = 0;
GLint green_type = 0;
GLint blue_type = 0;
GLint alpha_type = 0;
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE, &red_type);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_TYPE, &green_type);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_TYPE, &blue_type);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_TYPE, &alpha_type);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red_size);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &green_size);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blue_size);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
#define CHECK_RGBA(rt,gt,bt,at,rs,gs,bs,as) \
(red_type == rt && green_type == gt && blue_type == bt && alpha_type == at && \
red_size == rs && green_size == gs && blue_size == bs && alpha_size == as)
if (CHECK_RGBA (GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8))
{
texture->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
break;
}
#undef CHECK_RGBA
}
G_GNUC_FALLTHROUGH;
default:
g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format);
/* fallback to the dumbest possible format
@@ -380,7 +428,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,

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/.
*/
#ifndef __GDKINTL_H__
@@ -27,10 +27,6 @@
#include <glib/gi18n-lib.h>
#ifdef ENABLE_NLS
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
#else
#define P_(String) (String)
#endif
#define P_(String) dgettext (GETTEXT_PACKAGE "-properties", String)
#endif

View File

@@ -1,16 +1,16 @@
#!/usr/bin/env perl
# Updates https://gitlab.gnome.org/GNOME/gtk/tree/master/gdk/gdkkeysyms.h from upstream (X.org 7.x),
# Updates https://gitlab.gnome.org/GNOME/gtk/tree/main/gdk/gdkkeysyms.h from upstream (X.org 7.x),
# from https://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
#
#
# Author : Simos Xenitellis <simos at gnome dot org>.
# Author : Bastien Nocera <hadess@hadess.net>
# Version : 1.2
#
# Input : https://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
# Input : https://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
# Output : https://gitlab.gnome.org/GNOME/gtk/tree/master/gdk/gdkkeysyms.h
#
# Output : https://gitlab.gnome.org/GNOME/gtk/tree/main/gdk/gdkkeysyms.h
#
# Notes : It downloads keysymdef.h from the Internet, if not found locally,
# Notes : and creates an updated gdkkeysyms.h
# Notes : This version updates the source of gdkkeysyms.h from CVS to the GIT server.
@@ -24,7 +24,7 @@ if ( ! -f "keysymdef.h" )
{
print "Trying to download keysymdef.h from\n";
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n";
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
unless system("wget -c -O keysymdef.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\"") == 0;
print " done.\n\n";
}
@@ -39,7 +39,7 @@ if ( ! -f "XF86keysym.h" )
{
print "Trying to download XF86keysym.h from\n";
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n";
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
unless system("wget -c -O XF86keysym.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\"") == 0;
print " done.\n\n";
}
@@ -82,7 +82,7 @@ print OUT_GDKKEYSYMS $LICENSE_HEADER;
print OUT_GDKKEYSYMS<<EOF;
/*
* File auto-generated from script https://gitlab.gnome.org/GNOME/gtk/tree/master/gdk/gdkkeysyms-update.pl
* File auto-generated from script https://gitlab.gnome.org/GNOME/gtk/tree/main/gdk/gdkkeysyms-update.pl
* using the input file
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
* and
@@ -111,7 +111,7 @@ while (<IN_KEYSYMDEF>)
$_ = $keysymelements[1];
die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
$_ = $keysymelements[2];
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );

View File

@@ -18,7 +18,7 @@
/*
* File auto-generated from script https://gitlab.gnome.org/GNOME/gtk/tree/master/gdk/gdkkeysyms-update.pl
* File auto-generated from script https://gitlab.gnome.org/GNOME/gtk/tree/main/gdk/gdkkeysyms-update.pl
* using the input file
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
* and

View File

@@ -369,7 +369,7 @@ static const struct {
{ 0x07a2, 0x0388 }, /* Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */
{ 0x07a3, 0x0389 }, /* Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */
{ 0x07a4, 0x038a }, /* Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */
{ 0x07a5, 0x03aa }, /* Greek_IOTAdieresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
{ 0x07a5, 0x03aa }, /* Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
{ 0x07a7, 0x038c }, /* Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */
{ 0x07a8, 0x038e }, /* Greek_UPSILONaccent Ύ GREEK CAPITAL LETTER UPSILON WITH TONOS */
{ 0x07a9, 0x03ab }, /* Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
@@ -436,22 +436,22 @@ static const struct {
{ 0x07f7, 0x03c7 }, /* Greek_chi χ GREEK SMALL LETTER CHI */
{ 0x07f8, 0x03c8 }, /* Greek_psi ψ GREEK SMALL LETTER PSI */
{ 0x07f9, 0x03c9 }, /* Greek_omega ω GREEK SMALL LETTER OMEGA */
/* 0x08a1 leftradical ? ??? */
/* 0x08a2 topleftradical ? ??? */
/* 0x08a3 horizconnector ? ??? */
{ 0x08a1, 0x23b7 }, /* leftradical ??? */
{ 0x08a2, 0x250c }, /* topleftradical ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
{ 0x08a3, 0x2500 }, /* horizconnector ─ BOX DRAWINGS LIGHT HORIZONTAL */
{ 0x08a4, 0x2320 }, /* topintegral ⌠ TOP HALF INTEGRAL */
{ 0x08a5, 0x2321 }, /* botintegral ⌡ BOTTOM HALF INTEGRAL */
{ 0x08a6, 0x2502 }, /* vertconnector │ BOX DRAWINGS LIGHT VERTICAL */
/* 0x08a7 topleftsqbracket ? ??? */
/* 0x08a8 botleftsqbracket ? ??? */
/* 0x08a9 toprightsqbracket ? ??? */
/* 0x08aa botrightsqbracket ? ??? */
/* 0x08ab topleftparens ? ??? */
/* 0x08ac botleftparens ? ??? */
/* 0x08ad toprightparens ? ??? */
/* 0x08ae botrightparens ? ??? */
/* 0x08af leftmiddlecurlybrace ? ??? */
/* 0x08b0 rightmiddlecurlybrace ? ??? */
{ 0x08a7, 0x23a1 }, /* topleftsqbracket ??? */
{ 0x08a8, 0x23a3 }, /* botleftsqbracket ??? */
{ 0x08a9, 0x23a4 }, /* toprightsqbracket ??? */
{ 0x08aa, 0x23a6 }, /* botrightsqbracket ??? */
{ 0x08ab, 0x239b }, /* topleftparens ??? */
{ 0x08ac, 0x239d }, /* botleftparens ??? */
{ 0x08ad, 0x239e }, /* toprightparens ??? */
{ 0x08ae, 0x23a0 }, /* botrightparens ??? */
{ 0x08af, 0x23a8 }, /* leftmiddlecurlybrace ??? */
{ 0x08b0, 0x23ac }, /* rightmiddlecurlybrace ??? */
/* 0x08b1 topleftsummation ? ??? */
/* 0x08b2 botleftsummation ? ??? */
/* 0x08b3 topvertsummationconnector ? ??? */
@@ -467,8 +467,8 @@ static const struct {
{ 0x08c1, 0x221d }, /* variation ∝ PROPORTIONAL TO */
{ 0x08c2, 0x221e }, /* infinity ∞ INFINITY */
{ 0x08c5, 0x2207 }, /* nabla ∇ NABLA */
{ 0x08c8, 0x2245 }, /* approximate ≅ APPROXIMATELY EQUAL TO */
/* 0x08c9 similarequal ? ??? */
{ 0x08c8, 0x223c }, /* approximate TILDE OPERATOR */
{ 0x08c9, 0x2243 }, /* similarequal ≃ ASYMPTOTICALLY EQUAL TO */
{ 0x08cd, 0x21d4 }, /* ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */
{ 0x08ce, 0x21d2 }, /* implies ⇒ RIGHTWARDS DOUBLE ARROW */
{ 0x08cf, 0x2261 }, /* identical ≡ IDENTICAL TO */
@@ -485,7 +485,7 @@ static const struct {
{ 0x08fc, 0x2191 }, /* uparrow ↑ UPWARDS ARROW */
{ 0x08fd, 0x2192 }, /* rightarrow → RIGHTWARDS ARROW */
{ 0x08fe, 0x2193 }, /* downarrow ↓ DOWNWARDS ARROW */
{ 0x09df, 0x2422 }, /* blank ␢ BLANK SYMBOL */
/* 0x09df blank ? ??? */
{ 0x09e0, 0x25c6 }, /* soliddiamond ◆ BLACK DIAMOND */
{ 0x09e1, 0x2592 }, /* checkerboard ▒ MEDIUM SHADE */
{ 0x09e2, 0x2409 }, /* ht ␉ SYMBOL FOR HORIZONTAL TABULATION */
@@ -499,11 +499,11 @@ static const struct {
{ 0x09ec, 0x250c }, /* upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
{ 0x09ed, 0x2514 }, /* lowleftcorner └ BOX DRAWINGS LIGHT UP AND RIGHT */
{ 0x09ee, 0x253c }, /* crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
/* 0x09ef horizlinescan1 ? ??? */
/* 0x09f0 horizlinescan3 ? ??? */
{ 0x09ef, 0x23ba }, /* horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 (Unicode 3.2 draft) */
{ 0x09f0, 0x23bb }, /* horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */
{ 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */
/* 0x09f2 horizlinescan7 ? ??? */
/* 0x09f3 horizlinescan9 ? ??? */
{ 0x09f2, 0x23bc }, /* horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */
{ 0x09f3, 0x23bd }, /* horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */
{ 0x09f4, 0x251c }, /* leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
{ 0x09f5, 0x2524 }, /* rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */
{ 0x09f6, 0x2534 }, /* bott ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL */
@@ -519,9 +519,9 @@ static const struct {
{ 0x0aa8, 0x200a }, /* hairspace HAIR SPACE */
{ 0x0aa9, 0x2014 }, /* emdash — EM DASH */
{ 0x0aaa, 0x2013 }, /* endash EN DASH */
/* 0x0aac signifblank ? ??? */
{ 0x0aac, 0x2423 }, /* signifblank ␣ OPEN BOX */
{ 0x0aae, 0x2026 }, /* ellipsis … HORIZONTAL ELLIPSIS */
/* 0x0aaf doubbaselinedot ? ??? */
{ 0x0aaf, 0x2025 }, /* doubbaselinedot ‥ TWO DOT LEADER */
{ 0x0ab0, 0x2153 }, /* onethird ⅓ VULGAR FRACTION ONE THIRD */
{ 0x0ab1, 0x2154 }, /* twothirds ⅔ VULGAR FRACTION TWO THIRDS */
{ 0x0ab2, 0x2155 }, /* onefifth ⅕ VULGAR FRACTION ONE FIFTH */
@@ -532,9 +532,9 @@ static const struct {
{ 0x0ab7, 0x215a }, /* fivesixths ⅚ VULGAR FRACTION FIVE SIXTHS */
{ 0x0ab8, 0x2105 }, /* careof ℅ CARE OF */
{ 0x0abb, 0x2012 }, /* figdash FIGURE DASH */
{ 0x0abc, 0x2329 }, /* leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */
{ 0x0abc, 0x27e8 }, /* leftanglebracket ⟨ MATHEMATICAL LEFT ANGLE BRACKET */
{ 0x0abd, 0x002e }, /* decimalpoint . FULL STOP */
{ 0x0abe, 0x232a }, /* rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */
{ 0x0abe, 0x27e9 }, /* rightanglebracket ⟩ MATHEMATICAL RIGHT ANGLE BRACKET */
/* 0x0abf marker ? ??? */
{ 0x0ac3, 0x215b }, /* oneeighth ⅛ VULGAR FRACTION ONE EIGHTH */
{ 0x0ac4, 0x215c }, /* threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */
@@ -546,12 +546,13 @@ static const struct {
{ 0x0acc, 0x25c1 }, /* leftopentriangle ◁ WHITE LEFT-POINTING TRIANGLE */
{ 0x0acd, 0x25b7 }, /* rightopentriangle ▷ WHITE RIGHT-POINTING TRIANGLE */
{ 0x0ace, 0x25cb }, /* emopencircle ○ WHITE CIRCLE */
{ 0x0acf, 0x25a1 }, /* emopenrectangle WHITE SQUARE */
{ 0x0acf, 0x25af }, /* emopenrectangle WHITE VERTICAL RECTANGLE */
{ 0x0ad0, 0x2018 }, /* leftsinglequotemark LEFT SINGLE QUOTATION MARK */
{ 0x0ad1, 0x2019 }, /* rightsinglequotemark RIGHT SINGLE QUOTATION MARK */
{ 0x0ad2, 0x201c }, /* leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */
{ 0x0ad3, 0x201d }, /* rightdoublequotemark ” RIGHT DOUBLE QUOTATION MARK */
{ 0x0ad4, 0x211e }, /* prescription ℞ PRESCRIPTION TAKE */
{ 0x0ad5, 0x2030 }, /* permille ‰ PER MILLE SIGN */
{ 0x0ad6, 0x2032 }, /* minutes PRIME */
{ 0x0ad7, 0x2033 }, /* seconds ″ DOUBLE PRIME */
{ 0x0ad9, 0x271d }, /* latincross ✝ LATIN CROSS */
@@ -560,7 +561,7 @@ static const struct {
{ 0x0adc, 0x25c0 }, /* filledlefttribullet ◀ BLACK LEFT-POINTING TRIANGLE */
{ 0x0add, 0x25b6 }, /* filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */
{ 0x0ade, 0x25cf }, /* emfilledcircle ● BLACK CIRCLE */
{ 0x0adf, 0x25a0 }, /* emfilledrect BLACK SQUARE */
{ 0x0adf, 0x25ae }, /* emfilledrect BLACK VERTICAL RECTANGLE */
{ 0x0ae0, 0x25e6 }, /* enopencircbullet ◦ WHITE BULLET */
{ 0x0ae1, 0x25ab }, /* enopensquarebullet ▫ WHITE SMALL SQUARE */
{ 0x0ae2, 0x25ad }, /* openrectbullet ▭ WHITE RECTANGLE */
@@ -805,15 +806,16 @@ static const struct {
{ 0x0ef0, 0x3171 }, /* Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */
{ 0x0ef1, 0x3178 }, /* Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */
{ 0x0ef2, 0x317f }, /* Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */
/* 0x0ef3 Hangul_KkogjiDalrinIeung ? ??? */
{ 0x0ef3, 0x3181 }, /* Hangul_KkogjiDalrinIeung ㆁ HANGUL LETTER YESIEUNG */
{ 0x0ef4, 0x3184 }, /* Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */
{ 0x0ef5, 0x3186 }, /* Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */
{ 0x0ef6, 0x318d }, /* Hangul_AraeA ㆍ HANGUL LETTER ARAEA */
{ 0x0ef7, 0x318e }, /* Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */
{ 0x0ef8, 0x11eb }, /* Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */
/* 0x0ef9 Hangul_J_KkogjiDalrinIeung ? ??? */
{ 0x0ef9, 0x11f0 }, /* Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */
{ 0x0efa, 0x11f9 }, /* Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */
{ 0x0eff, 0x20a9 }, /* Korean_Won ₩ WON SIGN */
{ 0x13a4, 0x20ac }, /* Euro € EURO SIGN */
{ 0x13bc, 0x0152 }, /* OE Œ LATIN CAPITAL LIGATURE OE */
{ 0x13bd, 0x0153 }, /* oe œ LATIN SMALL LIGATURE OE */
{ 0x13be, 0x0178 }, /* Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */
@@ -835,18 +837,13 @@ static const struct {
/* Following items added to GTK, not in the xterm table */
/* A few ASCII control characters */
#ifndef GDK_WINDOWING_WIN32
{ 0xFF08 /* Backspace */, '\b' },
{ 0xFF09 /* Tab */, '\t' },
#endif
{ 0xFF0A /* Linefeed */, '\n' },
{ 0xFF0B /* Vert. Tab */, '\v' },
#ifndef GDK_WINDOWING_WIN32
{ 0xFF0D /* Return */, '\r' },
{ 0xFF1B /* Escape */, '\033' },
#endif
/* Numeric keypad */
@@ -871,9 +868,7 @@ static const struct {
/* End numeric keypad */
#ifndef GDK_WINDOWING_WIN32
{ 0xFFFF /* Delete */, '\177' }
#endif
};
/**
@@ -1084,7 +1079,7 @@ static const struct {
{ 0x07d7, 0x03a7 }, /* Greek_CHI Χ GREEK CAPITAL LETTER CHI */
{ 0x07d8, 0x03a8 }, /* Greek_PSI Ψ GREEK CAPITAL LETTER PSI */
{ 0x07d9, 0x03a9 }, /* Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */
{ 0x07a5, 0x03aa }, /* Greek_IOTAdieresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
{ 0x07a5, 0x03aa }, /* Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
{ 0x07a9, 0x03ab }, /* Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
{ 0x07b1, 0x03ac }, /* Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */
{ 0x07b2, 0x03ad }, /* Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */
@@ -1399,6 +1394,7 @@ static const struct {
{ 0x0eed, 0x11c1 }, /* Hangul_J_Phieuf ᇁ HANGUL JONGSEONG PHIEUPH */
{ 0x0eee, 0x11c2 }, /* Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */
{ 0x0ef8, 0x11eb }, /* Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */
{ 0x0ef9, 0x11f0 }, /* Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */
{ 0x0efa, 0x11f9 }, /* Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */
{ 0x0aa2, 0x2002 }, /* enspace EN SPACE */
{ 0x0aa1, 0x2003 }, /* emspace EM SPACE */
@@ -1422,7 +1418,9 @@ static const struct {
{ 0x0af1, 0x2020 }, /* dagger † DAGGER */
{ 0x0af2, 0x2021 }, /* doubledagger ‡ DOUBLE DAGGER */
{ 0x0ae6, 0x2022 }, /* enfilledcircbullet • BULLET */
{ 0x0aaf, 0x2025 }, /* doubbaselinedot ‥ TWO DOT LEADER */
{ 0x0aae, 0x2026 }, /* ellipsis … HORIZONTAL ELLIPSIS */
{ 0x0ad5, 0x2030 }, /* permille ‰ PER MILLE SIGN */
{ 0x0ad6, 0x2032 }, /* minutes PRIME */
{ 0x0ad7, 0x2033 }, /* seconds ″ DOUBLE PRIME */
{ 0x0afc, 0x2038 }, /* caret ‸ CARET */
@@ -1480,7 +1478,8 @@ static const struct {
{ 0x0bd6, 0x222a }, /* downshoe UNION */
{ 0x08bf, 0x222b }, /* integral ∫ INTEGRAL */
{ 0x08c0, 0x2234 }, /* therefore ∴ THEREFORE */
{ 0x08c8, 0x2245 }, /* approximate ≅ APPROXIMATELY EQUAL TO */
{ 0x08c8, 0x223c }, /* approximate TILDE OPERATOR */
{ 0x08c9, 0x2243 }, /* similarequal ≃ ASYMPTOTICALLY EQUAL TO */
{ 0x08bd, 0x2260 }, /* notequal ≠ NOT EQUAL TO */
{ 0x08cf, 0x2261 }, /* identical ≡ IDENTICAL TO */
{ 0x08bc, 0x2264 }, /* lessthanequal ≤ LESS-THAN OR EQUAL TO */
@@ -1498,15 +1497,28 @@ static const struct {
{ 0x0afa, 0x2315 }, /* telephonerecorder ⌕ TELEPHONE RECORDER */
{ 0x08a4, 0x2320 }, /* topintegral ⌠ TOP HALF INTEGRAL */
{ 0x08a5, 0x2321 }, /* botintegral ⌡ BOTTOM HALF INTEGRAL */
{ 0x0abc, 0x2329 }, /* leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */
{ 0x0abe, 0x232a }, /* rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */
{ 0x0bcc, 0x2395 }, /* quad ⎕ APL FUNCTIONAL SYMBOL QUAD (Unicode 3.0) */
{ 0x08a7, 0x23a1 }, /* topleftsqbracket ⎡ ??? */
{ 0x08a8, 0x23a3 }, /* botleftsqbracket ⎣ ??? */
{ 0x08a9, 0x23a4 }, /* toprightsqbracket ⎤ ??? */
{ 0x08aa, 0x23a6 }, /* botrightsqbracket ⎦ ??? */
{ 0x08ab, 0x239b }, /* topleftparens ⎛ ??? */
{ 0x08ac, 0x239d }, /* botleftparens ⎝ ??? */
{ 0x08ad, 0x239e }, /* toprightparens ⎞ ??? */
{ 0x08ae, 0x23a0 }, /* botrightparens ⎠ ??? */
{ 0x08af, 0x23a8 }, /* leftmiddlecurlybrace ⎨ ??? */
{ 0x08b0, 0x23ac }, /* rightmiddlecurlybrace ⎬ ??? */
{ 0x08a1, 0x23b7 }, /* leftradical ⎷ ??? */
{ 0x09ef, 0x23ba }, /* horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 (Unicode 3.2 draft) */
{ 0x09f0, 0x23bb }, /* horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */
{ 0x09f2, 0x23bc }, /* horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */
{ 0x09f3, 0x23bd }, /* horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */
{ 0x09e2, 0x2409 }, /* ht ␉ SYMBOL FOR HORIZONTAL TABULATION */
{ 0x09e5, 0x240a }, /* lf ␊ SYMBOL FOR LINE FEED */
{ 0x09e9, 0x240b }, /* vt ␋ SYMBOL FOR VERTICAL TABULATION */
{ 0x09e3, 0x240c }, /* ff ␌ SYMBOL FOR FORM FEED */
{ 0x09e4, 0x240d }, /* cr ␍ SYMBOL FOR CARRIAGE RETURN */
{ 0x09df, 0x2422 }, /* blank ␢ BLANK SYMBOL */
{ 0x0aac, 0x2423 }, /* signifblank ␣ OPEN BOX */
{ 0x09e8, 0x2424 }, /* nl ␤ SYMBOL FOR NEWLINE */
{ 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */
{ 0x08a6, 0x2502 }, /* vertconnector │ BOX DRAWINGS LIGHT VERTICAL */
@@ -1522,11 +1534,11 @@ static const struct {
{ 0x09ee, 0x253c }, /* crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
{ 0x09e1, 0x2592 }, /* checkerboard ▒ MEDIUM SHADE */
{ 0x0adf, 0x25a0 }, /* emfilledrect ■ BLACK SQUARE */
{ 0x0acf, 0x25a1 }, /* emopenrectangle □ WHITE SQUARE */
{ 0x0ae7, 0x25aa }, /* enfilledsqbullet ▪ BLACK SMALL SQUARE */
{ 0x0ae1, 0x25ab }, /* enopensquarebullet ▫ WHITE SMALL SQUARE */
{ 0x0adb, 0x25ac }, /* filledrectbullet ▬ BLACK RECTANGLE */
{ 0x0ae2, 0x25ad }, /* openrectbullet ▭ WHITE RECTANGLE */
{ 0x0acf, 0x25af }, /* emopenrectangle ▯ WHITE VERTICAL RECTANGLE */
{ 0x0ae8, 0x25b2 }, /* filledtribulletup ▲ BLACK UP-POINTING TRIANGLE */
{ 0x0ae3, 0x25b3 }, /* opentribulletup △ WHITE UP-POINTING TRIANGLE */
{ 0x0add, 0x25b6 }, /* filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */
@@ -1556,6 +1568,8 @@ static const struct {
{ 0x0af4, 0x2717 }, /* ballotcross ✗ BALLOT X */
{ 0x0ad9, 0x271d }, /* latincross ✝ LATIN CROSS */
{ 0x0af0, 0x2720 }, /* maltesecross ✠ MALTESE CROSS */
{ 0x0abc, 0x27e8 }, /* leftanglebracket ⟨ MATHEMATICAL LEFT ANGLE BRACKET */
{ 0x0abe, 0x27e9 }, /* rightanglebracket ⟩ MATHEMATICAL RIGHT ANGLE BRACKET */
{ 0x04a4, 0x3001 }, /* kana_comma 、 IDEOGRAPHIC COMMA */
{ 0x04a1, 0x3002 }, /* kana_fullstop 。 IDEOGRAPHIC FULL STOP */
{ 0x04a2, 0x300c }, /* kana_openingbracket 「 LEFT CORNER BRACKET */
@@ -1674,6 +1688,7 @@ static const struct {
{ 0x0ef0, 0x3171 }, /* Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */
{ 0x0ef1, 0x3178 }, /* Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */
{ 0x0ef2, 0x317f }, /* Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */
{ 0x0ef3, 0x3181 }, /* Hangul_KkogjiDalrinIeung ㆁ HANGUL LETTER YESIEUNG */
{ 0x0ef4, 0x3184 }, /* Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */
{ 0x0ef5, 0x3186 }, /* Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */
{ 0x0ef6, 0x318d }, /* Hangul_AraeA ㆍ HANGUL LETTER ARAEA */

View File

@@ -2,3 +2,4 @@ BOOLEAN:BOXED
BOOLEAN:OBJECT
BOOLEAN:POINTER
VOID:POINTER,POINTER,BOOLEAN,BOOLEAN
VOID:INT,INT

View File

@@ -166,6 +166,54 @@ r32g32b32a32_float_from_float (guchar *dest,
memcpy (dest, src, sizeof (float) * n * 4);
}
#define PREMULTIPLY_FUNC(name, R1, G1, B1, A1, R2, G2, B2, A2) \
static void \
name (guchar *dest, \
const guchar *src, \
gsize n) \
{ \
for (; n > 0; n--) \
{ \
guchar a = src[A1]; \
guint16 r = (guint16)src[R1] * a + 127; \
guint16 g = (guint16)src[G1] * a + 127; \
guint16 b = (guint16)src[B1] * a + 127; \
dest[R2] = (r + (r >> 8) + 1) >> 8; \
dest[G2] = (g + (g >> 8) + 1) >> 8; \
dest[B2] = (b + (b >> 8) + 1) >> 8; \
dest[A2] = a; \
dest += 4; \
src += 4; \
} \
}
PREMULTIPLY_FUNC(r8g8b8a8_to_r8g8b8a8_premultiplied, 0, 1, 2, 3, 0, 1, 2, 3)
PREMULTIPLY_FUNC(r8g8b8a8_to_b8g8r8a8_premultiplied, 0, 1, 2, 3, 2, 1, 0, 3)
PREMULTIPLY_FUNC(r8g8b8a8_to_a8r8g8b8_premultiplied, 0, 1, 2, 3, 1, 2, 3, 0)
PREMULTIPLY_FUNC(r8g8b8a8_to_a8b8g8r8_premultiplied, 0, 1, 2, 3, 3, 2, 1, 0)
#define ADD_ALPHA_FUNC(name, R1, G1, B1, R2, G2, B2, A2) \
static void \
name (guchar *dest, \
const guchar *src, \
gsize n) \
{ \
for (; n > 0; n--) \
{ \
dest[R2] = src[R1]; \
dest[G2] = src[G1]; \
dest[B2] = src[B1]; \
dest[A2] = 255; \
dest += 4; \
src += 3; \
} \
}
ADD_ALPHA_FUNC(r8g8b8_to_r8g8b8a8, 0, 1, 2, 0, 1, 2, 3)
ADD_ALPHA_FUNC(r8g8b8_to_b8g8r8a8, 0, 1, 2, 2, 1, 0, 3)
ADD_ALPHA_FUNC(r8g8b8_to_a8r8g8b8, 0, 1, 2, 1, 2, 3, 0)
ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
struct _GdkMemoryFormatDescription
{
GdkMemoryAlpha alpha;
@@ -475,10 +523,59 @@ gdk_memory_convert (guchar *dest_data,
const GdkMemoryFormatDescription *src_desc = &memory_formats[src_format];
float *tmp;
gsize y;
void (*func) (guchar *, const guchar *, gsize) = NULL;
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8a8_to_b8g8r8a8_premultiplied;
else if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
func = r8g8b8a8_to_b8g8r8a8_premultiplied;
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
func = r8g8b8a8_to_r8g8b8a8_premultiplied;
else if (src_format == GDK_MEMORY_R8G8B8A8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
func = r8g8b8a8_to_a8r8g8b8_premultiplied;
else if (src_format == GDK_MEMORY_B8G8R8A8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
func = r8g8b8a8_to_a8b8g8r8_premultiplied;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8_to_r8g8b8a8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
func = r8g8b8_to_b8g8r8a8;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
func = r8g8b8_to_b8g8r8a8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED)
func = r8g8b8_to_r8g8b8a8;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
func = r8g8b8_to_a8r8g8b8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_A8R8G8B8_PREMULTIPLIED)
func = r8g8b8_to_a8b8g8r8;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_R8G8B8A8)
func = r8g8b8_to_r8g8b8a8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_R8G8B8A8)
func = r8g8b8_to_b8g8r8a8;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_B8G8R8A8)
func = r8g8b8_to_b8g8r8a8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_B8G8R8A8)
func = r8g8b8_to_r8g8b8a8;
else if (src_format == GDK_MEMORY_R8G8B8 && dest_format == GDK_MEMORY_A8R8G8B8)
func = r8g8b8_to_a8r8g8b8;
else if (src_format == GDK_MEMORY_B8G8R8 && dest_format == GDK_MEMORY_A8R8G8B8)
func = r8g8b8_to_a8b8g8r8;
if (func != NULL)
{
for (y = 0; y < height; y++)
{
func (dest_data, src_data, width);
src_data += src_stride;
dest_data += dest_stride;
}
return;
}
tmp = g_new (float, width * 4);
for (y = 0; y < height; y++)

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,

View File

@@ -1,5 +1,5 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2000 Red Hat, Inc.
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -52,25 +52,25 @@ layout_iter_get_line_clip_region (PangoLayoutIter *iter,
i = 0;
while (i < n_ranges)
{
{
int *pixel_ranges = NULL;
int n_pixel_ranges = 0;
int j;
/* Note that get_x_ranges returns layout coordinates
*/
if (index_ranges[i*2+1] >= line->start_index &&
index_ranges[i*2] < line->start_index + line->length)
if (index_ranges[i*2+1] >= pango_layout_line_get_start_index (line) &&
index_ranges[i*2] < pango_layout_line_get_start_index (line) + pango_layout_line_get_length (line))
pango_layout_line_get_x_ranges (line,
index_ranges[i*2],
index_ranges[i*2+1],
&pixel_ranges, &n_pixel_ranges);
for (j = 0; j < n_pixel_ranges; j++)
{
GdkRectangle rect;
int x_off, y_off;
x_off = PANGO_PIXELS (pixel_ranges[2*j] - logical_rect.x);
y_off = PANGO_PIXELS (baseline - logical_rect.y);
@@ -124,14 +124,14 @@ gdk_pango_layout_line_get_clip_region (PangoLayoutLine *line,
{
cairo_region_t *clip_region;
PangoLayoutIter *iter;
g_return_val_if_fail (line != NULL, NULL);
g_return_val_if_fail (index_ranges != NULL, NULL);
iter = pango_layout_get_iter (line->layout);
while (pango_layout_iter_get_line_readonly (iter) != line)
pango_layout_iter_next_line (iter);
clip_region = layout_iter_get_line_clip_region(iter, x_origin, y_origin, index_ranges, n_ranges);
pango_layout_iter_free (iter);
@@ -167,26 +167,26 @@ gdk_pango_layout_get_clip_region (PangoLayout *layout,
const int *index_ranges,
int n_ranges)
{
PangoLayoutIter *iter;
PangoLayoutIter *iter;
cairo_region_t *clip_region;
g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL);
g_return_val_if_fail (index_ranges != NULL, NULL);
clip_region = cairo_region_create ();
iter = pango_layout_get_iter (layout);
do
{
PangoRectangle logical_rect;
cairo_region_t *line_region;
int baseline;
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
line_region = layout_iter_get_line_clip_region(iter,
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
line_region = layout_iter_get_line_clip_region(iter,
x_origin + PANGO_PIXELS (logical_rect.x),
y_origin + PANGO_PIXELS (baseline),
index_ranges,

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)

View File

@@ -33,7 +33,7 @@
((_GDK_RGBA_SELECT_COLOR(str, 0, 0) << 4) | _GDK_RGBA_SELECT_COLOR(str, 0, 1)) / 255., \
((_GDK_RGBA_SELECT_COLOR(str, 1, 2) << 4) | _GDK_RGBA_SELECT_COLOR(str, 1, 3)) / 255., \
((_GDK_RGBA_SELECT_COLOR(str, 2, 4) << 4) | _GDK_RGBA_SELECT_COLOR(str, 2, 5)) / 255., \
((sizeof(str) % 4 == 1) ? ((_GDK_RGBA_SELECT_COLOR(str, 3, 6) << 4) | _GDK_RGBA_SELECT_COLOR(str, 3, 7)) : 0xFF) / 255 })
((sizeof(str) % 4 == 1) ? ((_GDK_RGBA_SELECT_COLOR(str, 3, 6) << 4) | _GDK_RGBA_SELECT_COLOR(str, 3, 7)) : 0xFF) / 255. })
gboolean gdk_rgba_parser_parse (GtkCssParser *parser,

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,7 +1124,8 @@ 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))
{
eglDestroySurface (gdk_surface_get_display (self), priv->egl_surface);
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
priv->egl_surface = NULL;
}
@@ -2239,7 +2244,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
GdkEvent *event,
gulong serial)
{
GdkSurface *event_surface;
GdkSurface *event_surface = NULL;
gboolean unlink_event = FALSE;
GdkDeviceGrabInfo *button_release_grab;
GdkPointerSurfaceInfo *pointer_info = NULL;
@@ -2331,6 +2336,14 @@ _gdk_windowing_got_event (GdkDisplay *display,
*/
_gdk_event_queue_handle_motion_compression (display);
gdk_event_queue_handle_scroll_compression (display);
if (event_surface)
{
GdkFrameClock *clock = gdk_surface_get_frame_clock (event_surface);
if (clock) /* might be NULL if surface was destroyed */
gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
}
}
/**

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.
*

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);

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)

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,

View File

@@ -83,6 +83,8 @@
*
* A macro that evaluates to the 4.2 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.2
*/
#define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2))
@@ -91,6 +93,8 @@
*
* A macro that evaluates to the 4.4 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.4
*/
#define GDK_VERSION_4_4 (G_ENCODE_VERSION (4, 4))
@@ -99,6 +103,8 @@
*
* A macro that evaluates to the 4.6 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.6
*/
#define GDK_VERSION_4_6 (G_ENCODE_VERSION (4, 6))

View File

@@ -15,6 +15,8 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "config.h"
#include "gdkjpegprivate.h"

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;

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);

View File

@@ -45,7 +45,6 @@
options = (NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved |
NSTrackingInVisibleRect |
NSTrackingActiveAlways);
trackingArea = [[NSTrackingArea alloc] initWithRect:rect
options:options
@@ -57,9 +56,26 @@
return self;
}
-(void)setInputArea:(const cairo_rectangle_int_t *)area
{
NSRect rect = NSMakeRect (area->x, area->y, area->width, area->height);
NSTrackingAreaOptions options;
[self removeTrackingArea:trackingArea];
options = (NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved |
NSTrackingActiveAlways);
trackingArea = [[NSTrackingArea alloc] initWithRect:rect
options:options
owner:(id)self
userInfo:nil];
[self addTrackingArea:trackingArea];
}
-(void)setOpaqueRegion:(cairo_region_t *)region
{
/* Do nothing */
/* Handled in Subclass */
}
-(BOOL)acceptsFirstMouse

View File

@@ -42,5 +42,6 @@
-(void)setNeedsInvalidateShadow: (BOOL)invalidate;
-(NSTrackingArea *)trackingArea;
-(void)setOpaqueRegion:(cairo_region_t *)region;
-(void)setInputArea:(const cairo_rectangle_int_t *)area;
@end

View File

@@ -1,201 +0,0 @@
/* GdkMacosCairoSubview.c
*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include <CoreGraphics/CoreGraphics.h>
#include <cairo-quartz.h>
#import "GdkMacosCairoSubview.h"
#import "GdkMacosCairoView.h"
#include "gdkmacossurface-private.h"
@implementation GdkMacosCairoSubview
-(void)dealloc
{
g_clear_pointer (&self->clip, cairo_region_destroy);
[super dealloc];
}
-(BOOL)isOpaque
{
return _isOpaque;
}
-(BOOL)isFlipped
{
return YES;
}
-(GdkSurface *)gdkSurface
{
return GDK_SURFACE ([(GdkMacosBaseView *)[self superview] gdkSurface]);
}
-(void)drawRect:(NSRect)rect
{
CGContextRef cgContext;
GdkSurface *gdk_surface;
cairo_surface_t *dest;
const NSRect *rects = NULL;
NSView *root_view;
NSInteger n_rects = 0;
NSRect abs_bounds;
cairo_t *cr;
CGSize scale;
int scale_factor;
if (self->cairoSurface == NULL)
return;
/* Acquire everything we need to do translations, drawing, etc */
gdk_surface = [self gdkSurface];
scale_factor = gdk_surface_get_scale_factor (gdk_surface);
root_view = [[self window] contentView];
cgContext = [[NSGraphicsContext currentContext] CGContext];
abs_bounds = [self convertRect:[self bounds] toView:root_view];
CGContextSaveGState (cgContext);
/* Translate scaling to remove HiDPI scaling from CGContext as
* cairo will be doing that for us already.
*/
scale = CGSizeMake (1.0, 1.0);
scale = CGContextConvertSizeToDeviceSpace (cgContext, scale);
CGContextScaleCTM (cgContext, 1.0 / scale.width, 1.0 / scale.height);
/* Create the cairo surface to draw to the CGContext and translate
* coordinates so we can pretend we are in the same coordinate system
* as the GDK surface.
*/
dest = cairo_quartz_surface_create_for_cg_context (cgContext,
gdk_surface->width * scale_factor,
gdk_surface->height * scale_factor);
cairo_surface_set_device_scale (dest, scale_factor, scale_factor);
/* Create cairo context and translate things into the origin of
* the topmost contentView so that we just draw at 0,0 with a
* clip region to paint the surface.
*/
cr = cairo_create (dest);
cairo_translate (cr, -abs_bounds.origin.x, -abs_bounds.origin.y);
/* Apply the clip if provided one */
if (self->clip != NULL)
{
cairo_rectangle_int_t area;
n_rects = cairo_region_num_rectangles (self->clip);
for (guint i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (self->clip, i, &area);
cairo_rectangle (cr, area.x, area.y, area.width, area.height);
}
cairo_clip (cr);
}
/* Clip the cairo context based on the rectangles to be drawn
* within the bounding box :rect.
*/
[self getRectsBeingDrawn:&rects count:&n_rects];
for (NSInteger i = 0; i < n_rects; i++)
{
NSRect area = [self convertRect:rects[i] toView:root_view];
cairo_rectangle (cr,
area.origin.x, area.origin.y,
area.size.width, area.size.height);
}
cairo_clip (cr);
/* Now paint the surface (without blending) as we do not need
* any compositing here. The transparent regions (like shadows)
* are already on non-opaque layers.
*/
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface (cr, self->cairoSurface, 0, 0);
cairo_paint (cr);
/* Cleanup state, flush the surface to the backing layer, and
* restore GState for future use.
*/
cairo_destroy (cr);
cairo_surface_flush (dest);
cairo_surface_destroy (dest);
CGContextRestoreGState (cgContext);
}
-(void)setCairoSurface:(cairo_surface_t *)surface
withDamage:(cairo_region_t *)region
{
if (surface != self->cairoSurface)
{
g_clear_pointer (&self->cairoSurface, cairo_surface_destroy);
if (surface != NULL)
self->cairoSurface = cairo_surface_reference (surface);
}
if (region != NULL)
{
NSView *root_view = [[self window] contentView];
NSRect abs_bounds = [self convertRect:[self bounds] toView:root_view];
guint n_rects = cairo_region_num_rectangles (region);
for (guint i = 0; i < n_rects; i++)
{
cairo_rectangle_int_t rect;
NSRect nsrect;
cairo_region_get_rectangle (region, i, &rect);
nsrect = NSMakeRect (rect.x, rect.y, rect.width, rect.height);
if (NSIntersectsRect (abs_bounds, nsrect))
{
nsrect.origin.x -= abs_bounds.origin.x;
nsrect.origin.y -= abs_bounds.origin.y;
[self setNeedsDisplayInRect:nsrect];
}
}
}
for (id view in [self subviews])
[(GdkMacosCairoSubview *)view setCairoSurface:surface
withDamage:region];
}
-(void)setOpaque:(BOOL)opaque
{
self->_isOpaque = opaque;
}
-(void)setClip:(cairo_region_t*)region
{
if (region != self->clip)
{
g_clear_pointer (&self->clip, cairo_region_destroy);
if (region != NULL)
self->clip = cairo_region_reference (region);
}
}
@end

View File

@@ -1,187 +0,0 @@
/* GdkMacosCairoView.c
*
* Copyright © 2020 Red Hat, Inc.
* Copyright © 2005-2007 Imendio AB
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include <CoreGraphics/CoreGraphics.h>
#include <cairo-quartz.h>
#import "GdkMacosCairoView.h"
#import "GdkMacosCairoSubview.h"
#include "gdkmacossurface-private.h"
@implementation GdkMacosCairoView
-(void)dealloc
{
g_clear_pointer (&self->opaque, g_ptr_array_unref);
self->transparent = NULL;
[super dealloc];
}
-(BOOL)isOpaque
{
if ([self window])
return [[self window] isOpaque];
return YES;
}
-(BOOL)isFlipped
{
return YES;
}
-(void)setNeedsDisplay:(BOOL)needsDisplay
{
for (id child in [self subviews])
[child setNeedsDisplay:needsDisplay];
}
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
withDamage:(cairo_region_t *)cairoRegion
{
for (id view in [self subviews])
[(GdkMacosCairoSubview *)view setCairoSurface:cairoSurface
withDamage:cairoRegion];
}
-(void)removeOpaqueChildren
{
[[self->transparent subviews]
makeObjectsPerformSelector:@selector(removeFromSuperview)];
if (self->opaque->len)
g_ptr_array_remove_range (self->opaque, 0, self->opaque->len);
}
-(void)setOpaqueRegion:(cairo_region_t *)region
{
cairo_region_t *transparent_clip;
NSRect abs_bounds;
guint n_rects;
if (region == NULL)
return;
abs_bounds = [self convertRect:[self bounds] toView:nil];
n_rects = cairo_region_num_rectangles (region);
/* First, we create a clip region for the transparent region to use so that
* we dont end up exposing too much other than the corners on CSD.
*/
transparent_clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
abs_bounds.origin.x, abs_bounds.origin.y,
abs_bounds.size.width, abs_bounds.size.height
});
cairo_region_subtract (transparent_clip, region);
[(GdkMacosCairoSubview *)self->transparent setClip:transparent_clip];
cairo_region_destroy (transparent_clip);
/* The common case (at least for opaque windows and CSD) is that we will
* have either one or two opaque rectangles. If we detect that the same
* number of them are available as the previous, we can just resize the
* previous ones to avoid adding/removing views at a fast rate while
* resizing.
*/
if (n_rects == self->opaque->len)
{
for (guint i = 0; i < n_rects; i++)
{
GdkMacosCairoSubview *child;
cairo_rectangle_int_t rect;
child = g_ptr_array_index (self->opaque, i);
cairo_region_get_rectangle (region, i, &rect);
[child setFrame:NSMakeRect (rect.x - abs_bounds.origin.x,
rect.y - abs_bounds.origin.y,
rect.width,
rect.height)];
}
return;
}
[self removeOpaqueChildren];
for (guint i = 0; i < n_rects; i++)
{
GdkMacosCairoSubview *child;
cairo_rectangle_int_t rect;
NSRect nsrect;
cairo_region_get_rectangle (region, i, &rect);
nsrect = NSMakeRect (rect.x - abs_bounds.origin.x,
rect.y - abs_bounds.origin.y,
rect.width,
rect.height);
child = [[GdkMacosCairoSubview alloc] initWithFrame:nsrect];
[child setOpaque:YES];
[child setWantsLayer:YES];
[self->transparent addSubview:child];
g_ptr_array_add (self->opaque, child);
}
}
-(NSView *)initWithFrame:(NSRect)frame
{
if ((self = [super initWithFrame:frame]))
{
/* An array to track all the opaque children placed into
* the child self->transparent. This allows us to reuse them
* when we receive a new opaque area instead of discarding
* them on each draw.
*/
self->opaque = g_ptr_array_new ();
/* Setup our primary subview which will render all content that is not
* within an opaque region (such as shadows for CSD windows). For opaque
* windows, this will all be obscurred by other views, so it doesn't
* matter much to have it here.
*/
self->transparent = [[GdkMacosCairoSubview alloc] initWithFrame:frame];
[self addSubview:self->transparent];
}
return self;
}
-(void)setFrame:(NSRect)rect
{
[super setFrame:rect];
[self->transparent setFrame:NSMakeRect (0, 0, rect.size.width, rect.size.height)];
}
-(BOOL)acceptsFirstMouse
{
return YES;
}
-(BOOL)mouseDownCanMoveWindow
{
return NO;
}
@end

View File

@@ -1,125 +0,0 @@
/* GdkMacosGLView.c
*
* Copyright 2020 Christian Hergert <chergert@redhat.com>
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include <CoreGraphics/CoreGraphics.h>
#include <OpenGL/gl.h>
#include "gdkmacossurface-private.h"
#import "GdkMacosGLView.h"
@implementation GdkMacosGLView
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-(void)lockFocus
{
NSOpenGLContext *context;
[super lockFocus];
context = [self openGLContext];
if ([context view] != self)
[context setView: self];
}
-(void)drawRect:(NSRect)rect
{
}
-(void)clearGLContext
{
if (_openGLContext != nil)
[_openGLContext clearDrawable];
_openGLContext = nil;
}
-(void)setOpenGLContext:(NSOpenGLContext*)context
{
if (_openGLContext != context)
{
if (_openGLContext != nil)
[_openGLContext clearDrawable];
_openGLContext = context;
if (_openGLContext != nil)
{
[_openGLContext setView:self];
[self setWantsLayer:YES];
[self.layer setContentsGravity:kCAGravityBottomLeft];
[_openGLContext update];
}
}
}
-(NSOpenGLContext *)openGLContext
{
return _openGLContext;
}
-(BOOL)isOpaque
{
if ([self window])
return [[self window] isOpaque];
return YES;
}
-(BOOL)isFlipped
{
return YES;
}
-(BOOL)acceptsFirstMouse
{
return YES;
}
-(BOOL)mouseDownCanMoveWindow
{
return NO;
}
-(void)invalidateRegion:(const cairo_region_t *)region
{
if (region != NULL)
{
guint n_rects = cairo_region_num_rectangles (region);
for (guint i = 0; i < n_rects; i++)
{
cairo_rectangle_int_t rect;
NSRect nsrect;
cairo_region_get_rectangle (region, i, &rect);
nsrect = NSMakeRect (rect.x, rect.y, rect.width, rect.height);
[self setNeedsDisplayInRect:nsrect];
}
}
}
G_GNUC_END_IGNORE_DEPRECATIONS
@end

386
gdk/macos/GdkMacosLayer.c Normal file
View File

@@ -0,0 +1,386 @@
/* GdkMacosLayer.c
*
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#import "GdkMacosLayer.h"
#import "GdkMacosTile.h"
@protocol CanSetContentsOpaque
- (void)setContentsOpaque:(BOOL)mask;
@end
@implementation GdkMacosLayer
#define TILE_MAX_SIZE 128
#define TILE_EDGE_MAX_SIZE 512
static CGAffineTransform flipTransform;
static gboolean hasFlipTransform;
typedef struct
{
GdkMacosTile *tile;
cairo_rectangle_int_t cr_area;
CGRect area;
guint opaque : 1;
} TileInfo;
typedef struct
{
const cairo_region_t *region;
guint n_rects;
guint iter;
cairo_rectangle_int_t rect;
cairo_rectangle_int_t stash;
guint finished : 1;
} Tiler;
static void
tiler_init (Tiler *tiler,
const cairo_region_t *region)
{
memset (tiler, 0, sizeof *tiler);
if (region == NULL)
{
tiler->finished = TRUE;
return;
}
tiler->region = region;
tiler->n_rects = cairo_region_num_rectangles (region);
if (tiler->n_rects > 0)
cairo_region_get_rectangle (region, 0, &tiler->rect);
else
tiler->finished = TRUE;
}
static gboolean
tiler_next (Tiler *tiler,
cairo_rectangle_int_t *tile,
int max_size)
{
if (tiler->finished)
return FALSE;
if (tiler->rect.width == 0 || tiler->rect.height == 0)
{
tiler->iter++;
if (tiler->iter >= tiler->n_rects)
{
tiler->finished = TRUE;
return FALSE;
}
cairo_region_get_rectangle (tiler->region, tiler->iter, &tiler->rect);
}
/* If the next rectangle is too tall, slice the bottom off to
* leave just the height we want into tiler->stash.
*/
if (tiler->rect.height > max_size)
{
tiler->stash = tiler->rect;
tiler->stash.y += max_size;
tiler->stash.height -= max_size;
tiler->rect.height = max_size;
}
/* Now we can take the next horizontal slice */
tile->x = tiler->rect.x;
tile->y = tiler->rect.y;
tile->height = tiler->rect.height;
tile->width = MIN (max_size, tiler->rect.width);
tiler->rect.x += tile->width;
tiler->rect.width -= tile->width;
if (tiler->rect.width == 0)
{
tiler->rect = tiler->stash;
tiler->stash.width = tiler->stash.height = 0;
}
return TRUE;
}
static inline CGRect
toCGRect (const cairo_rectangle_int_t *rect)
{
return CGRectMake (rect->x, rect->y, rect->width, rect->height);
}
static inline cairo_rectangle_int_t
fromCGRect (const CGRect rect)
{
return (cairo_rectangle_int_t) {
rect.origin.x,
rect.origin.y,
rect.size.width,
rect.size.height
};
}
-(id)init
{
if (!hasFlipTransform)
{
hasFlipTransform = TRUE;
flipTransform = CGAffineTransformMakeScale (1, -1);
}
self = [super init];
if (self == NULL)
return NULL;
self->_layoutInvalid = TRUE;
[self setContentsGravity:kCAGravityCenter];
[self setContentsScale:1.0f];
[self setGeometryFlipped:YES];
return self;
}
-(BOOL)isOpaque
{
return NO;
}
-(void)_applyLayout:(GArray *)tiles
{
CGAffineTransform transform;
GArray *prev;
gboolean exhausted;
guint j = 0;
if (self->_isFlipped)
transform = flipTransform;
else
transform = CGAffineTransformIdentity;
prev = g_steal_pointer (&self->_tiles);
self->_tiles = tiles;
exhausted = prev == NULL;
/* Try to use existing CALayer to avoid creating new layers
* as that can be rather expensive.
*/
for (guint i = 0; i < tiles->len; i++)
{
TileInfo *info = &g_array_index (tiles, TileInfo, i);
if (!exhausted)
{
TileInfo *other = NULL;
for (; j < prev->len; j++)
{
other = &g_array_index (prev, TileInfo, j);
if (other->opaque == info->opaque)
{
j++;
break;
}
other = NULL;
}
if (other != NULL)
{
info->tile = g_steal_pointer (&other->tile);
[info->tile setFrame:info->area];
[info->tile setAffineTransform:transform];
continue;
}
}
info->tile = [GdkMacosTile layer];
[info->tile setAffineTransform:transform];
[info->tile setContentsScale:1.0f];
[info->tile setOpaque:info->opaque];
[(id<CanSetContentsOpaque>)info->tile setContentsOpaque:info->opaque];
[info->tile setFrame:info->area];
[self addSublayer:info->tile];
}
/* Release all of our old layers */
if (prev != NULL)
{
for (guint i = 0; i < prev->len; i++)
{
TileInfo *info = &g_array_index (prev, TileInfo, i);
if (info->tile != NULL)
[info->tile removeFromSuperlayer];
}
g_array_unref (prev);
}
}
-(void)layoutSublayers
{
Tiler tiler;
GArray *ar;
cairo_region_t *transparent;
cairo_rectangle_int_t rect;
int max_size;
if (!self->_inSwapBuffer)
return;
self->_layoutInvalid = FALSE;
ar = g_array_sized_new (FALSE, FALSE, sizeof (TileInfo), 32);
rect = fromCGRect ([self bounds]);
rect.x = rect.y = 0;
/* Calculate the transparent region (edges usually) */
transparent = cairo_region_create_rectangle (&rect);
if (self->_opaqueRegion)
cairo_region_subtract (transparent, self->_opaqueRegion);
self->_opaque = cairo_region_is_empty (transparent);
/* If we have transparent borders around the opaque region, then
* we are okay with a bit larger tiles since they don't change
* all that much and are generally small in width.
*/
if (!self->_opaque &&
self->_opaqueRegion &&
!cairo_region_is_empty (self->_opaqueRegion))
max_size = TILE_EDGE_MAX_SIZE;
else
max_size = TILE_MAX_SIZE;
/* Track transparent children */
tiler_init (&tiler, transparent);
while (tiler_next (&tiler, &rect, max_size))
{
TileInfo *info;
g_array_set_size (ar, ar->len+1);
info = &g_array_index (ar, TileInfo, ar->len-1);
info->tile = NULL;
info->opaque = FALSE;
info->cr_area = rect;
info->area = toCGRect (&info->cr_area);
}
/* Track opaque children */
tiler_init (&tiler, self->_opaqueRegion);
while (tiler_next (&tiler, &rect, TILE_MAX_SIZE))
{
TileInfo *info;
g_array_set_size (ar, ar->len+1);
info = &g_array_index (ar, TileInfo, ar->len-1);
info->tile = NULL;
info->opaque = TRUE;
info->cr_area = rect;
info->area = toCGRect (&info->cr_area);
}
cairo_region_destroy (transparent);
[self _applyLayout:g_steal_pointer (&ar)];
[super layoutSublayers];
}
-(void)setFrame:(NSRect)frame
{
if (frame.size.width != self.bounds.size.width ||
frame.size.height != self.bounds.size.height)
{
self->_layoutInvalid = TRUE;
[self setNeedsLayout];
}
[super setFrame:frame];
}
-(void)setOpaqueRegion:(const cairo_region_t *)opaqueRegion
{
g_clear_pointer (&self->_opaqueRegion, cairo_region_destroy);
self->_opaqueRegion = cairo_region_copy (opaqueRegion);
self->_layoutInvalid = TRUE;
[self setNeedsLayout];
}
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage
{
IOSurfaceRef ioSurface = _gdk_macos_buffer_get_native (buffer);
gboolean flipped = _gdk_macos_buffer_get_flipped (buffer);
double scale = _gdk_macos_buffer_get_device_scale (buffer);
double width = _gdk_macos_buffer_get_width (buffer) / scale;
double height = _gdk_macos_buffer_get_height (buffer) / scale;
if (flipped != self->_isFlipped)
{
self->_isFlipped = flipped;
self->_layoutInvalid = TRUE;
}
if (self->_layoutInvalid)
{
self->_inSwapBuffer = TRUE;
[self layoutSublayers];
self->_inSwapBuffer = FALSE;
}
if (self->_tiles == NULL)
return;
for (guint i = 0; i < self->_tiles->len; i++)
{
const TileInfo *info = &g_array_index (self->_tiles, TileInfo, i);
cairo_region_overlap_t overlap;
CGRect area;
overlap = cairo_region_contains_rectangle (damage, &info->cr_area);
if (overlap == CAIRO_REGION_OVERLAP_OUT)
continue;
area.origin.x = info->area.origin.x / width;
area.size.width = info->area.size.width / width;
area.size.height = info->area.size.height / height;
if (flipped)
area.origin.y = (height - info->area.origin.y - info->area.size.height) / height;
else
area.origin.y = info->area.origin.y / height;
[info->tile swapBuffer:ioSurface withRect:area];
}
}
@end

44
gdk/macos/GdkMacosLayer.h Normal file
View File

@@ -0,0 +1,44 @@
/* GdkMacosLayer.h
*
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <QuartzCore/QuartzCore.h>
#include <IOSurface/IOSurface.h>
#include <cairo.h>
#include <glib.h>
#include "gdkmacosbuffer-private.h"
#define GDK_IS_MACOS_LAYER(obj) ((obj) && [obj isKindOfClass:[GdkMacosLayer class]])
@interface GdkMacosLayer : CALayer
{
cairo_region_t *_opaqueRegion;
GArray *_tiles;
guint _opaque : 1;
guint _layoutInvalid : 1;
guint _inSwapBuffer : 1;
guint _isFlipped : 1;
};
-(void)setOpaqueRegion:(const cairo_region_t *)opaqueRegion;
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage;
@end

View File

@@ -1,7 +1,6 @@
/* GdkMacosGLView.h
/* GdkMacosTile.c
*
* Copyright © 2020 Red Hat, Inc.
* Copyright © 2005-2007 Imendio AB
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,23 +18,34 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <cairo.h>
#include "config.h"
#import "GdkMacosBaseView.h"
#include <AppKit/AppKit.h>
#define GDK_IS_MACOS_GL_VIEW(obj) ((obj) && [obj isKindOfClass:[GdkMacosGLView class]])
#import "GdkMacosTile.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@implementation GdkMacosTile
@interface GdkMacosGLView : GdkMacosBaseView
-(id)init
{
NSOpenGLContext *_openGLContext;
self = [super init];
[self setContentsScale:1.0];
[self setEdgeAntialiasingMask:0];
[self setDrawsAsynchronously:YES];
return self;
}
-(void)setOpenGLContext:(NSOpenGLContext*)context;
-(NSOpenGLContext *)openGLContext;
-(void)invalidateRegion:(const cairo_region_t *)region;
-(void)swapBuffer:(IOSurfaceRef)buffer withRect:(CGRect)rect
{
if G_LIKELY ([self contents] == (id)buffer)
[(id<CanSetContentsChanged>)self setContentsChanged];
else
[self setContents:(id)buffer];
G_GNUC_END_IGNORE_DEPRECATIONS
if G_UNLIKELY (!CGRectEqualToRect ([self contentsRect], rect))
self.contentsRect = rect;
}
@end

View File

@@ -1,6 +1,6 @@
/* GdkMacosCairoSubview.h
/* GdkMacosTile.h
*
* Copyright © 2020 Red Hat, Inc.
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,20 +18,20 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <AppKit/AppKit.h>
#include <QuartzCore/QuartzCore.h>
#define GDK_IS_MACOS_CAIRO_SUBVIEW(obj) ((obj) && [obj isKindOfClass:[GdkMacosCairoSubview class]])
#include "gdkmacosbuffer-private.h"
@interface GdkMacosCairoSubview : NSView
#define GDK_IS_MACOS_TILE(obj) ((obj) && [obj isKindOfClass:[GdkMacosTile class]])
@protocol CanSetContentsChanged
-(void)setContentsChanged;
@end
@interface GdkMacosTile : CALayer
{
BOOL _isOpaque;
cairo_surface_t *cairoSurface;
cairo_region_t *clip;
}
};
-(void)setOpaque:(BOOL)opaque;
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
withDamage:(cairo_region_t *)region;
-(void)setClip:(cairo_region_t*)region;
-(void)swapBuffer:(IOSurfaceRef)buffer withRect:(CGRect)rect;
@end

100
gdk/macos/GdkMacosView.c Normal file
View File

@@ -0,0 +1,100 @@
/* GdkMacosView.c
*
* Copyright 2022 Christian Hergert <chergert@redhat.com>
*
* 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include <CoreGraphics/CoreGraphics.h>
#import "GdkMacosLayer.h"
#import "GdkMacosView.h"
#import "GdkMacosWindow.h"
@implementation GdkMacosView
-(id)initWithFrame:(NSRect)frame
{
if ((self = [super initWithFrame:frame]))
{
GdkMacosLayer *layer = [GdkMacosLayer layer];
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawNever];
[self setLayer:layer];
[self setWantsLayer:YES];
}
return self;
}
-(BOOL)isFlipped
{
return YES;
}
-(BOOL)acceptsFirstMouse
{
return YES;
}
-(BOOL)mouseDownCanMoveWindow
{
return NO;
}
-(void)mouseDown:(NSEvent *)nsevent
{
if ([(GdkMacosWindow *)[self window] needsMouseDownQuirk])
/* We should only hit this when we are trying to click through
* the shadow of a window into another window. Just request
* that the application not activate this window on mouseUp.
* See gdkmacosdisplay-translate.c for the other half of this.
*/
[NSApp preventWindowOrdering];
else
[super mouseDown:nsevent];
}
-(void)setFrame:(NSRect)rect
{
[super setFrame:rect];
self->_nextFrameDirty = TRUE;
}
-(void)setOpaqueRegion:(const cairo_region_t *)opaqueRegion
{
[(GdkMacosLayer *)[self layer] setOpaqueRegion:opaqueRegion];
}
-(BOOL)wantsUpdateLayer
{
return YES;
}
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage
{
if (self->_nextFrameDirty)
{
self->_nextFrameDirty = FALSE;
[[self layer] setFrame:[self frame]];
}
[(GdkMacosLayer *)[self layer] swapBuffer:buffer withDamage:damage];
}
@end

View File

@@ -1,7 +1,6 @@
/* GdkMacosCairoView.h
/* GdkMacosView.h
*
* Copyright © 2020 Red Hat, Inc.
* Copyright © 2005-2007 Imendio AB
* Copyright 2022 Christian Hergert <chergert@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,15 +22,17 @@
#import "GdkMacosBaseView.h"
#define GDK_IS_MACOS_CAIRO_VIEW(obj) ((obj) && [obj isKindOfClass:[GdkMacosCairoView class]])
#include "gdkmacosbuffer-private.h"
@interface GdkMacosCairoView : GdkMacosBaseView
#define GDK_IS_MACOS_VIEW(obj) ((obj) && [obj isKindOfClass:[GdkMacosView class]])
@interface GdkMacosView : GdkMacosBaseView
{
NSView *transparent;
GPtrArray *opaque;
NSRect _nextFrame;
guint _nextFrameDirty : 1;
}
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
withDamage:(cairo_region_t *)region;
-(void)setOpaqueRegion:(const cairo_region_t *)opaqueRegion;
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage;
@end

View File

@@ -24,8 +24,7 @@
#include <gdk/gdk.h>
#import "GdkMacosBaseView.h"
#import "GdkMacosCairoView.h"
#import "GdkMacosGLView.h"
#import "GdkMacosView.h"
#import "GdkMacosWindow.h"
#include "gdkmacosclipboard-private.h"
@@ -150,8 +149,7 @@ typedef NSString *CALayerContentsGravity;
_gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
/* Reset gravity */
if (GDK_IS_MACOS_GL_VIEW ([self contentView]))
[[[self contentView] layer] setContentsGravity:kCAGravityBottomLeft];
[[[self contentView] layer] setContentsGravity:kCAGravityBottomLeft];
break;
}
@@ -173,6 +171,11 @@ typedef NSString *CALayerContentsGravity;
return inMove;
}
- (BOOL)inFullscreenTransition;
{
return inFullscreenTransition;
}
-(void)checkSendEnterNotify
{
/* When a new window has been created, and the mouse is in the window
@@ -203,69 +206,20 @@ typedef NSString *CALayerContentsGravity;
}
}
-(void)windowDidUnmaximize
{
NSWindowStyleMask style_mask = [self styleMask];
gdk_synthesize_surface_state (GDK_SURFACE (gdk_surface), GDK_TOPLEVEL_STATE_MAXIMIZED, 0);
/* If we are using CSD, then we transitioned to an opaque
* window while we were maximized. Now we need to drop that
* as we are leaving maximized state.
*/
if ((style_mask & NSWindowStyleMaskTitled) == 0 && [self isOpaque])
[self setOpaque:NO];
}
-(void)windowDidMove:(NSNotification *)aNotification
-(void)setFrame:(NSRect)frame display:(BOOL)display
{
NSRect contentRect = [self contentRectForFrameRect:frame];
GdkSurface *surface = GDK_SURFACE (gdk_surface);
gboolean maximized = (surface->state & GDK_TOPLEVEL_STATE_MAXIMIZED) != 0;
/* In case the window is changed when maximized remove the maximized state */
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
[self windowDidUnmaximize];
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, frame))
{
gdk_synthesize_surface_state (surface, GDK_TOPLEVEL_STATE_MAXIMIZED, 0);
_gdk_surface_update_size (surface);
}
_gdk_macos_surface_update_position (gdk_surface);
_gdk_macos_surface_reposition_children (gdk_surface);
[self checkSendEnterNotify];
}
-(void)windowDidResize:(NSNotification *)aNotification
{
NSRect content_rect;
GdkSurface *surface;
GdkDisplay *display;
gboolean maximized;
surface = GDK_SURFACE (gdk_surface);
display = gdk_surface_get_display (surface);
content_rect = [self contentRectForFrameRect:[self frame]];
maximized = (surface->state & GDK_TOPLEVEL_STATE_MAXIMIZED) != 0;
/* see same in windowDidMove */
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
[self windowDidUnmaximize];
surface->width = content_rect.size.width;
surface->height = content_rect.size.height;
/* Certain resize operations (e.g. going fullscreen), also move the
* origin of the window.
*/
_gdk_macos_surface_update_position (GDK_MACOS_SURFACE (surface));
[[self contentView] setFrame:NSMakeRect (0, 0, surface->width, surface->height)];
_gdk_surface_update_size (surface);
gdk_surface_request_layout (surface);
_gdk_macos_surface_reposition_children (gdk_surface);
[self checkSendEnterNotify];
[super setFrame:frame display:display];
[[self contentView] setFrame:NSMakeRect (0, 0, contentRect.size.width, contentRect.size.height)];
}
-(id)initWithContentRect:(NSRect)contentRect
@@ -274,7 +228,7 @@ typedef NSString *CALayerContentsGravity;
defer:(BOOL)flag
screen:(NSScreen *)screen
{
GdkMacosCairoView *view;
GdkMacosView *view;
self = [super initWithContentRect:contentRect
styleMask:styleMask
@@ -285,8 +239,9 @@ typedef NSString *CALayerContentsGravity;
[self setAcceptsMouseMovedEvents:YES];
[self setDelegate:(id<NSWindowDelegate>)self];
[self setReleasedWhenClosed:YES];
[self setPreservesContentDuringLiveResize:NO];
view = [[GdkMacosCairoView alloc] initWithFrame:contentRect];
view = [[GdkMacosView alloc] initWithFrame:contentRect];
[self setContentView:view];
[view release];
@@ -303,7 +258,8 @@ typedef NSString *CALayerContentsGravity;
-(BOOL)canBecomeKeyWindow
{
return GDK_IS_TOPLEVEL (gdk_surface);
return GDK_IS_TOPLEVEL (gdk_surface) ||
(GDK_IS_POPUP (gdk_surface) && GDK_SURFACE (gdk_surface)->input_region != NULL);
}
-(void)showAndMakeKey:(BOOL)makeKey
@@ -311,9 +267,12 @@ typedef NSString *CALayerContentsGravity;
inShowOrHide = YES;
if (makeKey && [self canBecomeKeyWindow])
[self makeKeyAndOrderFront:nil];
[self makeKeyAndOrderFront:self];
else
[self orderFront:nil];
[self orderFront:self];
if (makeKey && [self canBecomeMainWindow])
[self makeMainWindow];
inShowOrHide = NO;
@@ -411,12 +370,31 @@ typedef NSString *CALayerContentsGravity;
windowFrame.origin.x = new_origin.x;
windowFrame.origin.y = new_origin.y;
/* And now apply the frame to the window */
[self setFrameOrigin:NSMakePoint(new_origin.x, new_origin.y)];
[self setFrame:NSMakeRect (new_origin.x, new_origin.y,
window_gdk.width, window_gdk.height)
display:YES];
return YES;
}
-(void)windowDidMove:(NSNotification *)notification
{
_gdk_macos_surface_configure ([self gdkSurface]);
}
-(void)windowDidResize:(NSNotification *)notification
{
_gdk_macos_surface_configure (gdk_surface);
/* If we're using server-side decorations, this notification is coming
* in from a display-side change. We need to request a layout in
* addition to the configure event.
*/
if (GDK_IS_MACOS_TOPLEVEL_SURFACE (gdk_surface) &&
GDK_MACOS_TOPLEVEL_SURFACE (gdk_surface)->decorated)
gdk_surface_request_layout (GDK_SURFACE (gdk_surface));
}
/* Used by gdkmacosdisplay-translate.c to decide if our sendEvent() handler
* above will see the event or if it will be subjected to standard processing
* by GDK.
@@ -428,6 +406,7 @@ typedef NSString *CALayerContentsGravity;
-(void)beginManualMove
{
gboolean maximized = GDK_SURFACE (gdk_surface)->state & GDK_TOPLEVEL_STATE_MAXIMIZED;
NSPoint initialMoveLocation;
GdkPoint point;
GdkMonitor *monitor;
@@ -446,6 +425,13 @@ typedef NSString *CALayerContentsGravity;
initialMoveLocation = [NSEvent mouseLocation];
if (maximized)
[self setFrame:NSMakeRect (initialMoveLocation.x - (int)lastUnmaximizedFrame.size.width/2,
initialMoveLocation.y,
lastUnmaximizedFrame.size.width,
lastUnmaximizedFrame.size.height)
display:YES];
_gdk_macos_display_from_display_coords ([self gdkDisplay],
initialMoveLocation.x,
initialMoveLocation.y,
@@ -537,15 +523,7 @@ typedef NSString *CALayerContentsGravity;
new_frame.size.height = min_size.height;
}
/* We could also apply aspect ratio:
new_frame.size.height = new_frame.size.width / [self aspectRatio].width * [self aspectRatio].height;
*/
[self setFrame:new_frame display:YES];
/* Let the resizing be handled by GTK. */
if (g_main_context_pending (NULL))
g_main_context_iteration (NULL, FALSE);
_gdk_macos_surface_user_resize ([self gdkSurface], new_frame);
inTrackManualResize = NO;
@@ -554,49 +532,46 @@ typedef NSString *CALayerContentsGravity;
-(void)beginManualResize:(GdkSurfaceEdge)edge
{
CALayerContentsGravity gravity = kCAGravityBottomLeft;
if (inMove || inManualMove || inManualResize)
return;
inManualResize = YES;
resizeEdge = edge;
if (GDK_IS_MACOS_GL_VIEW ([self contentView]))
switch (edge)
{
CALayerContentsGravity gravity = kCAGravityBottomLeft;
default:
case GDK_SURFACE_EDGE_NORTH:
gravity = kCAGravityTopLeft;
break;
switch (edge)
{
default:
case GDK_SURFACE_EDGE_NORTH:
gravity = kCAGravityTopLeft;
break;
case GDK_SURFACE_EDGE_NORTH_WEST:
gravity = kCAGravityTopRight;
break;
case GDK_SURFACE_EDGE_NORTH_WEST:
gravity = kCAGravityTopRight;
break;
case GDK_SURFACE_EDGE_SOUTH_WEST:
case GDK_SURFACE_EDGE_WEST:
gravity = kCAGravityBottomRight;
break;
case GDK_SURFACE_EDGE_SOUTH_WEST:
case GDK_SURFACE_EDGE_WEST:
gravity = kCAGravityBottomRight;
break;
case GDK_SURFACE_EDGE_SOUTH:
case GDK_SURFACE_EDGE_SOUTH_EAST:
gravity = kCAGravityBottomLeft;
break;
case GDK_SURFACE_EDGE_SOUTH:
case GDK_SURFACE_EDGE_SOUTH_EAST:
gravity = kCAGravityBottomLeft;
break;
case GDK_SURFACE_EDGE_EAST:
gravity = kCAGravityBottomLeft;
break;
case GDK_SURFACE_EDGE_EAST:
gravity = kCAGravityBottomLeft;
break;
case GDK_SURFACE_EDGE_NORTH_EAST:
gravity = kCAGravityTopLeft;
break;
}
[[[self contentView] layer] setContentsGravity:gravity];
case GDK_SURFACE_EDGE_NORTH_EAST:
gravity = kCAGravityTopLeft;
break;
}
[[[self contentView] layer] setContentsGravity:gravity];
initialResizeFrame = [self frame];
initialResizeLocation = convert_nspoint_to_screen (self, [self mouseLocationOutsideOfEventStream]);
}
@@ -710,7 +685,12 @@ typedef NSString *CALayerContentsGravity;
is_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
if (was_fullscreen != is_fullscreen)
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
{
if (was_fullscreen)
[self setFrame:lastUnfullscreenFrame display:NO];
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
}
if (was_opaque != is_opaque)
{
@@ -760,7 +740,6 @@ typedef NSString *CALayerContentsGravity;
if (state & GDK_TOPLEVEL_STATE_MAXIMIZED)
{
lastMaximizedFrame = newFrame;
[self windowDidUnmaximize];
}
else
{
@@ -775,16 +754,7 @@ typedef NSString *CALayerContentsGravity;
-(void)windowDidEndLiveResize:(NSNotification *)aNotification
{
gboolean maximized = GDK_SURFACE (gdk_surface)->state & GDK_TOPLEVEL_STATE_MAXIMIZED;
inMaximizeTransition = NO;
/* Even if this is CSD, we want to be opaque while maximized
* to speed up compositing by allowing the display server to
* avoid costly blends.
*/
if (maximized)
[self setOpaque:YES];
}
-(NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize
@@ -794,16 +764,37 @@ typedef NSString *CALayerContentsGravity;
-(void)windowWillEnterFullScreen:(NSNotification *)aNotification
{
inFullscreenTransition = YES;
lastUnfullscreenFrame = [self frame];
}
-(void)windowDidEnterFullScreen:(NSNotification *)aNotification
{
inFullscreenTransition = NO;
initialPositionKnown = NO;
[self checkSendEnterNotify];
}
-(void)windowWillExitFullScreen:(NSNotification *)aNotification
{
[self setFrame:lastUnfullscreenFrame display:YES];
inFullscreenTransition = YES;
}
-(void)windowDidExitFullScreen:(NSNotification *)aNotification
{
inFullscreenTransition = NO;
initialPositionKnown = NO;
[self checkSendEnterNotify];
}
-(void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
{
inFullscreenTransition = NO;
}
-(void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
{
inFullscreenTransition = NO;
}
-(void)windowDidChangeScreen:(NSNotification *)aNotification
@@ -845,4 +836,15 @@ typedef NSString *CALayerContentsGravity;
return NO;
}
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage
{
[(GdkMacosView *)[self contentView] swapBuffer:buffer withDamage:damage];
}
-(BOOL)needsMouseDownQuirk
{
return GDK_IS_MACOS_TOPLEVEL_SURFACE (gdk_surface) &&
!GDK_MACOS_TOPLEVEL_SURFACE (gdk_surface)->decorated;
}
@end

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