Commit Graph

10582 Commits

Author SHA1 Message Date
Christian Hergert
e706e14fd9 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-03-24 18:05:11 -07:00
Sebastian Keller
cc02076b75 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-03-22 08:18:26 +01:00
panoplie
3873861b27 macos: fix scroll-unit build 2022-03-19 02:55:02 +01:00
panoplie
fb4927827b gdk: Add enum to indicate the unit of scroll deltas
Add a new GdkScrollUnit enum that represent the
unit of scroll deltas provided by GdkScrollEvent.
The unit is accessible through
gdk_scroll_event_get_unit().
2022-03-19 00:41:26 +01:00
Matthias Clasen
8186cb8bee Merge branch 'wip/chergert/for-main' into 'main'
macos: fit'n'finish fixes for main

See merge request GNOME/gtk!4564
2022-03-12 19:07:41 +00:00
Christian Hergert
166444f115 macos: exclude popups from window list
This probably only matters if you do window list integration for the global
menu on macOS.
2022-03-11 22:36:26 -08:00
Christian Hergert
3cd68c5de5 macos: pass events to foreign windows 2022-03-11 18:25:47 -08:00
Christian Hergert
bd0c68f641 macos: dont steal key window from NSPanel
Or we risk making it really difficult to use native file choosers.
2022-03-11 18:07:34 -08:00
Christian Hergert
c3a7d79154 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-11 18:01:05 -08:00
Christian Hergert
25624083dd 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-11 17:53:42 -08:00
Christian Hergert
407b5246a6 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-11 14:44:07 -08:00
Christian Hergert
6bedcf22bc 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-11 14:44:06 -08:00
Christian Hergert
eeb9d6c398 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-11 14:44:06 -08:00
Christian Hergert
cf8d2374c5 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-11 14:44:06 -08:00
Christian Hergert
9fa5378d83 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-11 14:44:06 -08:00
Matthias Clasen
9f7c9ce6ad Merge branch 'better-format-conversions' into 'main'
gdk: Clean up the optimised premultiply conversion function

See merge request GNOME/gtk!4550
2022-03-10 19:26:25 +00:00
Christian Hergert
84014e3414 macos: make transient-for key window when hiding surface
This only handled the popover case before and not the transient-for case.
2022-03-10 08:04:14 -08:00
Christian Hergert
4ced1c90f1 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-10 03:21:12 -08:00
Christian Hergert
54c3b947fc 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-10 03:20:07 -08:00
Christian Hergert
ea59d174a0 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-09 13:20:53 -08:00
Christian Hergert
32935d9fb0 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-09 13:19:22 -08:00
Christian Hergert
b390e1da4f 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-09 12:33:46 -08:00
Christian Hergert
f5098e4fc5 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-05 12:01:53 -08:00
Christian Hergert
28607f082c 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-05 11:58:43 -08:00
Emmanuel Gil Peyrot
588076d166 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-03 16:05:52 +01:00
Emmanuel Gil Peyrot
3a98b28ab7 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-03 16:04:45 +01:00
Emmanuel Gil Peyrot
cfeedcc321 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-03 16:04:45 +01: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
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
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
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
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