Commit Graph

72568 Commits

Author SHA1 Message Date
Matthias Clasen
d0aedbc9fc Merge branch 'bilelmoussaoui/docs' into 'main'
headerbar: Fix docs

See merge request GNOME/gtk!4545
2022-03-03 14:11:25 +00:00
Changwoo Ryu
5557a528b6 Update Korean translation
(cherry picked from commit 156f99560d)
2022-03-03 12:46:55 +00:00
Christian Hergert
5316eb0c35 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-03 01:22:01 -08:00
Bilal Elmoussaoui
e6afe28de5 headerbar: Fix docs 2022-03-03 08:36:33 +00:00
Matthias Clasen
eaf0353205 Merge branch 'wip/chergert/for-main' into 'main'
macos: various fixes

See merge request GNOME/gtk!4543
2022-03-02 13:37:06 +00:00
Carlos Garnacho
f9f9bd3f5b Merge branch 'xdg-activation-no-surface' into 'main'
wayland: xdg-activation: Don't assume there's a focus surface

See merge request GNOME/gtk!4366
2022-03-02 12:44:52 +00:00
Christian Hergert
ca79688f52 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-02 01:04:53 -08:00
Christian Hergert
efa8f903c2 macos: invalidate surface contents when mapping 2022-03-02 00:48:06 -08:00
Christian Hergert
f7d0b91267 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-02 00:47:27 -08:00
Christian Hergert
ed4f0de2b0 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-02 00:45:44 -08:00
Christian Hergert
50b96dcdd5 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-02 00:43:33 -08:00
Christian Hergert
cf25f2c04b 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-02 00:42:09 -08:00
Christian Hergert
ddf07ffe22 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-02 00:40:21 -08:00
Christian Hergert
82f1eaacc9 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-02 00:38:39 -08:00
Christian Hergert
4cdb07fa02 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-02 00:37:07 -08:00
Christian Hergert
bdd5393084 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-02 00:36:17 -08:00
Christian Hergert
27b87ebec5 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-02 00:34:27 -08:00
Christian Hergert
8c0df66d5f macos: style cleanup 2022-03-02 00:33:13 -08:00
Christian Hergert
e5238bf54f macos: add re-entrancy check when monitors change 2022-03-02 00:32:50 -08:00
Christian Hergert
e9abcde031 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-02 00:32:07 -08:00
Goran Vidović
d45281e6c7 Update Croatian translation
(cherry picked from commit 4eee322654)
2022-03-01 13:05:13 +00:00
Goran Vidović
3fd5ebffcb Update Croatian translation
(cherry picked from commit 67ae05d855)
2022-03-01 12:54:18 +00:00
Carlos Garnacho
88a621fa13 Merge branch 'wip/carlosg/focus-request-over-xdg-activation' into 'main'
wayland: Use xdg-activation for non-startup initiated focus requests

See merge request GNOME/gtk!4535
2022-03-01 11:21:12 +00:00
Marek Černocký
ce4b799f1e Updated Czech translation 2022-03-01 12:08:18 +01:00
Carlos Garnacho
4dcacff312 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-01 11:38:51 +01:00
Matthias Clasen
fd7667246d Merge branch 'wip/chergert/for-main' into 'main'
macos: various fixes and multi-monitor frame clocks

Closes #4736, #4735, #4732, #4733, and #4734

See merge request GNOME/gtk!4533
2022-02-28 22:13:03 +00:00
Matthias Clasen
b8cb15f28d Merge branch 'wip/carlosg/scrolledwindow-warning' into 'main'
gtkscrolledwindow: Do not try to doubly trigger deceleration

Closes #4730

See merge request GNOME/gtk!4536
2022-02-28 21:50:19 +00:00
Christian Hergert
51607ce93c 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-02-28 13:09:57 -08:00
Christian Hergert
66284cd245 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-02-28 12:20:24 -08:00
Christian Hergert
f9faecd5b7 macos: add GDK_NOTE when surface changes monitor 2022-02-28 12:13:29 -08:00
Christian Hergert
92261b5022 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-02-28 11:50:21 -08:00
Christian Hergert
91f5bfd211 macos: leave note about monitor discovery 2022-02-28 11:36:27 -08:00
Christian Hergert
63f20b173d 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-02-28 11:36:27 -08:00
Christian Hergert
25b3bd64af macos: fix redisplay of GdkPopup
This broke recently during the configure cleanups and also needed to have
the tail directions fixed again.
2022-02-28 11:36:27 -08:00
Christian Hergert
fc4d36e50a 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-02-28 11:36:27 -08:00
Christian Hergert
dbede0b115 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-02-28 11:36:27 -08:00
Christian Hergert
1e40033852 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-02-28 11:36:27 -08:00
Christian Hergert
478bf45320 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-02-28 11:36:27 -08:00
Christian Hergert
dac0b7d609 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-02-28 11:36:27 -08:00
Christian Hergert
d14987e819 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-02-28 11:36:27 -08:00
Christian Hergert
3a0077f65f 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-02-28 11:36:27 -08:00
Christian Hergert
03882ef8e5 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-02-28 11:36:27 -08:00
Christian Hergert
505e10f3ea 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-02-28 11:36:27 -08:00
Christian Hergert
1e01444de8 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-02-28 11:36:27 -08:00
Christian Hergert
4404c43cd3 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-02-28 11:36:27 -08:00
Christian Hergert
92a7c7cdc3 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-02-28 11:36:23 -08:00
Carlos Garnacho
33db142eab 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-02-28 20:27:43 +01:00
Carlos Garnacho
68319afd23 Merge branch 'startup-vs-xdg-activation' into 'main'
Startup tracking with xdg-activation

See merge request GNOME/gtk!3883
2022-02-28 17:29:09 +00:00
Guido Günther
25f4e597ee print-editor: Use gtk_window_present()
This lets xdg-activation work as otherwise gdk_wayland_surface_focus is
never invoked.
2022-02-28 16:55:54 +00:00
Guido Günther
db8339ca66 demo: Use gtk_window_present()
This lets xdg-activation work as otherwise gdk_wayland_surface_focus is
never invoked.
2022-02-28 16:55:54 +00:00