gtk4.git
3 years agomacos: short-circuit on NSEventPhaseMayBegin
Christian Hergert [Mon, 28 Feb 2022 08:42:47 +0000 (00:42 -0800)]
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.

3 years agomacos: support mix-rate monitors
Christian Hergert [Mon, 28 Feb 2022 07:31:28 +0000 (23:31 -0800)]
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

3 years agomacos: use video mode for refresh rate and interval
Christian Hergert [Mon, 28 Feb 2022 07:17:40 +0000 (23:17 -0800)]
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.

3 years agomacos: send stop event when fingers touch
Christian Hergert [Sat, 26 Feb 2022 21:31:18 +0000 (13:31 -0800)]
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

3 years agomacos: remove emulated scroll events
Christian Hergert [Sat, 26 Feb 2022 07:22:05 +0000 (23:22 -0800)]
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

3 years agomacos: do not inherit parents frame clock
Christian Hergert [Fri, 25 Feb 2022 22:02:06 +0000 (14:02 -0800)]
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.

3 years agomacos: calculate best monitor when changing screens
Christian Hergert [Fri, 25 Feb 2022 21:52:08 +0000 (13:52 -0800)]
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.

3 years agomacos: remove duplicated opaque_region field
Christian Hergert [Fri, 25 Feb 2022 21:14:22 +0000 (13:14 -0800)]
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.

3 years agomacos: use display id when creating CVDisplayLink
Christian Hergert [Fri, 25 Feb 2022 21:09:31 +0000 (13:09 -0800)]
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.

3 years agomacos: move feedback mechanisms into separate file
Christian Hergert [Fri, 25 Feb 2022 20:30:08 +0000 (12:30 -0800)]
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.

3 years agomacos: fix origin during live resize of titled window
Christian Hergert [Fri, 25 Feb 2022 07:27:09 +0000 (23:27 -0800)]
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.

3 years agomacos: restore unfullscreen frame with style mask
Christian Hergert [Fri, 25 Feb 2022 06:31:42 +0000 (22:31 -0800)]
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.

3 years agomacos: fix kinetic scrolling with overshoot
Christian Hergert [Fri, 25 Feb 2022 02:55:42 +0000 (18:55 -0800)]
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.

3 years agomacos: remove unused code
Christian Hergert [Fri, 25 Feb 2022 00:44:22 +0000 (16:44 -0800)]
macos: remove unused code

3 years agomacos: create new windows with slight origin offset
Christian Hergert [Fri, 25 Feb 2022 00:43:14 +0000 (16:43 -0800)]
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.

3 years agogtk-builder-tool: Operate without display
Matthias Clasen [Mon, 14 Mar 2022 19:40:12 +0000 (15:40 -0400)]
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().

3 years agobuild: Avoid objcopy on arm
Matthias Clasen [Mon, 14 Mar 2022 12:44:09 +0000 (08:44 -0400)]
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
3 years agoApply 1 suggestion(s) to 1 file(s)
Matthias Clasen [Tue, 15 Mar 2022 14:35:09 +0000 (14:35 +0000)]
Apply 1 suggestion(s) to 1 file(s)

3 years agogtkplacessidebar: Prevent calling g_object_unref on null
Fina Wilke [Mon, 14 Mar 2022 21:33:35 +0000 (22:33 +0100)]
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

3 years agobuild: Don't use ld and objcopy when cross-compiling
Ting-Wei Lan [Sun, 13 Mar 2022 07:14:12 +0000 (15:14 +0800)]
build: Don't use ld and objcopy when cross-compiling

These commands don't work when compiling Windows binaries on Linux.

3 years agofix docs for gtk_accessible_update_relation example
Caolán McNamara [Wed, 9 Mar 2022 12:27:32 +0000 (12:27 +0000)]
fix docs for gtk_accessible_update_relation example

3 years agoUse the correct name for installed gdk tests
Sebastien Bacher [Mon, 7 Mar 2022 15:13:38 +0000 (16:13 +0100)]
Use the correct name for installed gdk tests

3 years agoFix a documentation typo
Matthias Clasen [Sat, 5 Mar 2022 05:18:06 +0000 (22:18 -0700)]
Fix a documentation typo

It is XDG_DATA_HOME.

Fixes: #4747
3 years agoFix up preconditions of gsk_gl_shader_node_new
Matthias Clasen [Fri, 4 Mar 2022 05:39:02 +0000 (22:39 -0700)]
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
3 years agogdk: Add a rgb8 → rgba8 conversion macro
Emmanuel Gil Peyrot [Thu, 3 Mar 2022 14:36:57 +0000 (14:36 +0000)]
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.

3 years agogdk: Make the optimized premultiply function a macro
Emmanuel Gil Peyrot [Thu, 3 Mar 2022 14:34:29 +0000 (14:34 +0000)]
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.

3 years agogdk: Remove pixel format conversion ARM intrinsics
Emmanuel Gil Peyrot [Thu, 3 Mar 2022 14:12:06 +0000 (14:12 +0000)]
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
1fdf5b7cf8fec2d94389ecad5ec28865f8dcfd99.

3 years agogdk: use EGL_KHR_swap_buffers_with_damage
Christian Hergert [Thu, 3 Mar 2022 06:59:23 +0000 (22:59 -0800)]
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.

3 years agoheaderbar: Fix docs
Bilal Elmoussaoui [Thu, 3 Mar 2022 08:36:33 +0000 (08:36 +0000)]
headerbar: Fix docs

3 years agotext: Stop blinking when we lose focus
Matthias Clasen [Mon, 7 Mar 2022 18:33:45 +0000 (11:33 -0700)]
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.

3 years agofocus controller: Update for active window
Matthias Clasen [Mon, 7 Mar 2022 18:32:22 +0000 (11:32 -0700)]
focus controller: Update for active window

When the window gains or looses active status,
update the focus controllers status.

3 years agowindow: Update has-focus property
Matthias Clasen [Mon, 7 Mar 2022 18:35:09 +0000 (11:35 -0700)]
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.

3 years agogtkscrolledwindow: Do not try to doubly trigger deceleration
Carlos Garnacho [Mon, 28 Feb 2022 19:27:43 +0000 (20:27 +0100)]
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
3 years agogdk: Add missing out annotation on gdk_content_deserialize_finish
Rico Tzschichholz [Sat, 26 Feb 2022 21:05:20 +0000 (22:05 +0100)]
gdk: Add missing out annotation on gdk_content_deserialize_finish

3 years agolistview: Fix return_if_fail()s
Benjamin Otte [Sat, 26 Feb 2022 02:04:53 +0000 (03:04 +0100)]
listview: Fix return_if_fail()s

3 years agoflattenlistmodel: Fix indentation
Benjamin Otte [Sat, 26 Feb 2022 03:36:24 +0000 (04:36 +0100)]
flattenlistmodel: Fix indentation

3 years agorenderers: Handle large viewports
Benjamin Otte [Fri, 25 Feb 2022 02:40:57 +0000 (03:40 +0100)]
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.

3 years agoCI: disable debug for MSVC
Christoph Reiter [Sat, 26 Feb 2022 15:32:15 +0000 (16:32 +0100)]
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.

3 years agoFix last error reporting when calling GetClipboardOwner
Luca Bacci [Fri, 25 Feb 2022 15:53:12 +0000 (16:53 +0100)]
Fix last error reporting when calling GetClipboardOwner

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

3 years agoUpdate Slovenian translation
Matej Urbančič [Tue, 15 Mar 2022 21:27:06 +0000 (21:27 +0000)]
Update Slovenian translation

3 years agoUpdate Norwegian Bokmål translation
Kjartan Maraas [Tue, 15 Mar 2022 15:26:33 +0000 (15:26 +0000)]
Update Norwegian Bokmål translation

3 years agoUpdate Serbian translation
Мирослав Николић [Tue, 15 Mar 2022 06:33:22 +0000 (06:33 +0000)]
Update Serbian translation

3 years agoUpdate German translation
Christian Kirbach [Sun, 13 Mar 2022 22:08:50 +0000 (22:08 +0000)]
Update German translation

3 years agoUpdate Hungarian translation
Balázs Úr [Sun, 13 Mar 2022 00:25:05 +0000 (00:25 +0000)]
Update Hungarian translation

3 years agoUpdate Kazakh translation
Baurzhan Muftakhidinov [Sat, 12 Mar 2022 16:34:02 +0000 (16:34 +0000)]
Update Kazakh translation

3 years agoUpdate Kazakh translation
Baurzhan Muftakhidinov [Sat, 12 Mar 2022 13:23:19 +0000 (13:23 +0000)]
Update Kazakh translation

3 years agoUpdate Swedish translation
Anders Jonsson [Sat, 12 Mar 2022 11:39:05 +0000 (11:39 +0000)]
Update Swedish translation

3 years agoUpdate Slovak translation
Dušan Kazik [Fri, 11 Mar 2022 07:43:53 +0000 (07:43 +0000)]
Update Slovak translation

3 years agoUpdate Hungarian translation
Balázs Úr [Fri, 11 Mar 2022 01:08:54 +0000 (01:08 +0000)]
Update Hungarian translation

3 years agoUpdate Hebrew translation
Yosef Or Boczko [Thu, 10 Mar 2022 18:42:34 +0000 (18:42 +0000)]
Update Hebrew translation

3 years agoUpdate Finnish translation
Jiri Grönroos [Wed, 9 Mar 2022 19:03:37 +0000 (19:03 +0000)]
Update Finnish translation

3 years agoFixed Czech translation
Marek Černocký [Wed, 9 Mar 2022 18:07:33 +0000 (19:07 +0100)]
Fixed Czech translation

3 years agoUpdate Swedish translation
Anders Jonsson [Wed, 9 Mar 2022 10:49:50 +0000 (10:49 +0000)]
Update Swedish translation

3 years agoUpdate Persian translation
Danial Behzadi [Tue, 8 Mar 2022 15:00:39 +0000 (15:00 +0000)]
Update Persian translation

3 years agoUpdated Danish translation of gtk-properties
Ask Hjorth Larsen [Tue, 8 Mar 2022 00:21:58 +0000 (01:21 +0100)]
Updated Danish translation of gtk-properties

3 years agoUpdated Danish translation
Ask Hjorth Larsen [Tue, 8 Mar 2022 00:21:58 +0000 (01:21 +0100)]
Updated Danish translation

3 years agoUpdated Lithuanian translation
Aurimas Černius [Mon, 7 Mar 2022 16:29:36 +0000 (18:29 +0200)]
Updated Lithuanian translation

3 years agoUpdate Swedish translation
Luna Jernberg [Mon, 7 Mar 2022 08:09:32 +0000 (08:09 +0000)]
Update Swedish translation

3 years agoUpdate Chinese (China) translation
Luming Zh [Sat, 5 Mar 2022 23:45:12 +0000 (23:45 +0000)]
Update Chinese (China) translation

3 years agoUpdate Catalan translation
Jordi Mas i Hernandez [Fri, 4 Mar 2022 21:40:27 +0000 (21:40 +0000)]
Update Catalan translation

3 years agoUpdate Korean translation
Changwoo Ryu [Fri, 4 Mar 2022 14:20:21 +0000 (14:20 +0000)]
Update Korean translation

3 years agoUpdate Korean translation
Changwoo Ryu [Thu, 3 Mar 2022 12:46:34 +0000 (12:46 +0000)]
Update Korean translation

3 years agoUpdated Spanish translation
Daniel Mustieles [Thu, 3 Mar 2022 10:45:15 +0000 (11:45 +0100)]
Updated Spanish translation

3 years agoMerge branch 'backport-mr-4506-to-gtk-4-6' into 'gtk-4-6'
Luca Bacci [Thu, 3 Mar 2022 10:09:38 +0000 (10:09 +0000)]
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

3 years agoMerge branch 'backport-mr-4531-to-gtk-4-6' into 'gtk-4-6'
Luca Bacci [Thu, 3 Mar 2022 09:33:27 +0000 (09:33 +0000)]
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

3 years agoGdkWin32: Configure as needed when going fullscreen
Luca Bacci [Tue, 22 Feb 2022 08:15:28 +0000 (09:15 +0100)]
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

3 years agogdkkeys-win32: Only perform substitution as last-resort
Philip Zander [Sun, 27 Feb 2022 15:32:59 +0000 (16:32 +0100)]
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

3 years agoUpdate Russian translation
Aleksandr Melman [Wed, 2 Mar 2022 19:29:31 +0000 (19:29 +0000)]
Update Russian translation

3 years agoUpdate Turkish translation
Emin Tufan Çetin [Wed, 2 Mar 2022 13:05:48 +0000 (13:05 +0000)]
Update Turkish translation

3 years agoUpdate Croatian translation
Goran Vidović [Tue, 1 Mar 2022 13:04:47 +0000 (13:04 +0000)]
Update Croatian translation

3 years agoUpdate Croatian translation
Goran Vidović [Tue, 1 Mar 2022 12:53:52 +0000 (12:53 +0000)]
Update Croatian translation

3 years agoUpdated Czech translation
Marek Černocký [Tue, 1 Mar 2022 11:07:36 +0000 (12:07 +0100)]
Updated Czech translation

3 years agoUpdate Brazilian Portuguese translation
Rafael Fontenelle [Mon, 28 Feb 2022 14:46:55 +0000 (14:46 +0000)]
Update Brazilian Portuguese translation

3 years agoUpdate Galician translation
Fran Dieguez [Sun, 27 Feb 2022 22:45:33 +0000 (22:45 +0000)]
Update Galician translation

3 years agoUpdate Basque translation
Asier Sarasua Garmendia [Sun, 27 Feb 2022 08:05:18 +0000 (08:05 +0000)]
Update Basque translation

3 years agoUpdate Portuguese translation
Hugo Carvalho [Sat, 26 Feb 2022 18:09:30 +0000 (18:09 +0000)]
Update Portuguese translation

3 years agoUpdate Ukrainian translation
Yuri Chornoivan [Sat, 26 Feb 2022 13:05:23 +0000 (13:05 +0000)]
Update Ukrainian translation

3 years agoUpdate Polish translation
Piotr Drąg [Sat, 26 Feb 2022 12:29:19 +0000 (13:29 +0100)]
Update Polish translation

3 years agomacos: fix positioning of popover tails
Christian Hergert [Fri, 25 Feb 2022 00:29:53 +0000 (16:29 -0800)]
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.

3 years agoMerge branch 'wip/chergert/macos-window-manager' into 'main'
Matthias Clasen [Wed, 23 Feb 2022 03:53:33 +0000 (03:53 +0000)]
Merge branch 'wip/chergert/macos-window-manager' into 'main'

macos: improve placement of windows

See merge request GNOME/gtk!4510

3 years agoMerge branch 'ebassi/docs-related' into 'main'
Matthias Clasen [Wed, 23 Feb 2022 03:28:47 +0000 (03:28 +0000)]
Merge branch 'ebassi/docs-related' into 'main'

docs: Split dependencies from related libraries

See merge request GNOME/gtk!4474

3 years agoMerge branch 'wip/chergert/macos-iosurface' into 'main'
Matthias Clasen [Wed, 23 Feb 2022 03:10:43 +0000 (03:10 +0000)]
Merge branch 'wip/chergert/macos-iosurface' into 'main'

macos: modernize rendering with CALayer and IOSurface

See merge request GNOME/gtk!4477

3 years agomacos: improve placement of windows
Christian Hergert [Wed, 23 Feb 2022 02:41:41 +0000 (18:41 -0800)]
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.

3 years agomacos: update CGL context when surface resizes
Christian Hergert [Tue, 22 Feb 2022 21:15:25 +0000 (13:15 -0800)]
macos: update CGL context when surface resizes

3 years agomacos: force pixel format without depth/stencil
Christian Hergert [Tue, 22 Feb 2022 21:09:30 +0000 (13:09 -0800)]
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.

3 years agoUpdate Hebrew translation
Yosef Or Boczko [Tue, 22 Feb 2022 20:22:59 +0000 (20:22 +0000)]
Update Hebrew translation

3 years agoUpdate Persian translation
Danial Behzadi [Tue, 22 Feb 2022 20:08:03 +0000 (20:08 +0000)]
Update Persian translation

3 years agomacos: only invalidate tiles when size changes
Christian Hergert [Tue, 22 Feb 2022 08:51:53 +0000 (00:51 -0800)]
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.

3 years agomacos: reload IOSurface when monitor configuration changes
Christian Hergert [Tue, 22 Feb 2022 08:33:03 +0000 (00:33 -0800)]
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.

3 years agomacos: double buffer IOSurface
Christian Hergert [Tue, 22 Feb 2022 07:53:55 +0000 (23:53 -0800)]
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.

3 years agomacos: restore key window after hiding popup
Christian Hergert [Thu, 17 Feb 2022 02:26:59 +0000 (18:26 -0800)]
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.

3 years agomacos: fix window drag across mixed-scale monitors
Christian Hergert [Thu, 17 Feb 2022 01:09:48 +0000 (17:09 -0800)]
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.

3 years agomacos: use CALayer and IOSurface for rendering
Christian Hergert [Mon, 14 Feb 2022 10:20:19 +0000 (02:20 -0800)]
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.

3 years agogsk/gl: support non-standard default framebuffer
Christian Hergert [Fri, 11 Feb 2022 05:51:15 +0000 (21:51 -0800)]
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().

3 years agomacos: fix allocation for filechoosernative filter
Christian Hergert [Thu, 17 Feb 2022 20:39:21 +0000 (12:39 -0800)]
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.

3 years agoMerge branch 'scale-button-empty-icon-list' into 'main'
Matthias Clasen [Tue, 22 Feb 2022 19:39:32 +0000 (19:39 +0000)]
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

3 years agoMerge branch 'wip/hadess/app-id-inspector-4' into 'main'
Matthias Clasen [Tue, 22 Feb 2022 19:37:36 +0000 (19:37 +0000)]
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

3 years agoMerge branch 'wip/chergert/macos-fix-event-filter' into 'main'
Matthias Clasen [Tue, 22 Feb 2022 19:36:43 +0000 (19:36 +0000)]
Merge branch 'wip/chergert/macos-fix-event-filter' into 'main'

macos: improve event filtering for foreign panels

See merge request GNOME/gtk!4495

3 years agoMerge branch 'wip/chergert/macos-fix-fullscreen' into 'main'
Matthias Clasen [Tue, 22 Feb 2022 19:36:20 +0000 (19:36 +0000)]
Merge branch 'wip/chergert/macos-fix-fullscreen' into 'main'

macos: allow windows to enter fullscreen

See merge request GNOME/gtk!4494

3 years agoMerge branch 'optimise-png-premultiply' into 'main'
Matthias Clasen [Tue, 22 Feb 2022 19:25:41 +0000 (19:25 +0000)]
Merge branch 'optimise-png-premultiply' into 'main'

gdk: Specialise RGBA8 → premultiplied BGRA8 conversion

See merge request GNOME/gtk!4481