Commit Graph

10747 Commits

Author SHA1 Message Date
Matthias Clasen
f95f992d32 Merge branch 'wip/carlosg/use-press-serial' into 'main'
gdk/wayland: Use last implicit grab serial for DnD start requests

Closes #5048

See merge request GNOME/gtk!4889
2022-07-18 14:18:22 +00:00
Carlos Garnacho
95cf34ab4c gdk/wayland: Stop storing the last serial in GdkWaylandDisplay
This is not used anymore, so we can drop the serial being stored
here.
2022-07-18 15:21:40 +02:00
Carlos Garnacho
5a34b7ecc6 gdk/wayland: Use last press serial for clipboard/primary selections
This serial observes key and button presses, we can use that instead
of relying on the last serial which might come from other
events/devices.
2022-07-18 13:01:27 +02:00
Carlos Garnacho
eb0b98d5f2 gdk/wayland: Use last implicit grab serial for DnD start requests
This serial should be that from a button press/touch down/etc, use
the last implicit grab here, which will presumably be from the same
device that triggered the event.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5048
2022-07-18 13:00:32 +02:00
Corey Berla
16fd2608fd gdkdrop-x11: Use the preferred action if possible
The XDND suggested action is a relic from when the source would control
the action for a drop.  With the new GtkDropTarget the target decides
the action (not the source).  That means the all of the returned
results from the ::enter and ::motion handlers will be unexpectely
ignored. Prefer to use the preferred action over the x11 suggested action.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4259
2022-07-16 14:02:47 -07:00
Corey Berla
c9c48d78bf gdkdrop-x11: Fix preferred action
gdk_x11_drop_update_actions() sets actions to
drop_x11->suggested_action when !drop_x11->xdnd_have_actions
and then sets it again to drop_x11->suggested_action if it is.
If xdnd_have_actions is true use xdnd_actions.
2022-07-16 13:42:58 -07:00
Matthias Clasen
14cb208ec2 png loader: gray can have alpha 2022-07-16 09:43:46 -04:00
Matthias Clasen
c642649311 gdk: Drop an unused function 2022-07-16 09:43:46 -04:00
Benjamin Otte
988e20cd53 frameclock: Run paint idle from flush idle
Don't return to the main loop, instead force a run of the paint idle.
The paint idle will know to skip all the phases that aren't requested.

This is critically important becuase gdksurface.c assumes the
FLUSH_EVENTS and RESUME_EVENTS phases are matched, and we cannot
guarantee that if we return to the main loop and let various reentrant
code change the frame clock state.

This would lead to bugs with events being paused and never unpaused
again or even crashes.

Fixes #4941
2022-07-10 21:33:32 +02:00
Benjamin Otte
813dd0a674 gdk: Replace GTK_USE_PORTAL env var with GDK_DEBUG flag
It's a debug flag, so make it clear that it is one.

Related: Clowns on the Arch wiki on
https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications#Consistent_file_dialog
2022-06-24 03:14:50 +02:00
Matthias Clasen
0660bb834e Merge branch 'bad-popup-extents' into 'main'
[x11] Fix coordinate space of rect in gdk_x11_surface_get_frame_extents when called on popups.

See merge request GNOME/gtk!4820
2022-06-23 11:59:55 +00:00
Matthias Clasen
40e09cf2bb Merge branch 'wip/xdg-toplevel-bounds' into 'main'
wayland: Add supports for xdg_toplevel.bounds

See merge request GNOME/gtk!4261
2022-06-22 14:24:41 +00:00
Emilio Cobos Álvarez
5301a74bd3
[x11] Fix coordinate space of rect in gdk_x11_surface_get_frame_extents when called on popups.
If we take the early return we don't unscale this at the bottom of the
function, causing wrong coordinates in HiDPI screens.

This bug also affects GTK3 (I noticed this running Firefox tests on X).
2022-06-20 10:13:21 +02:00
Luca Bacci
83c780cfad GdkWin32: Add code for gtk-overlay-scrolling setting
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4899
2022-06-17 11:06:43 +02:00
Jonas Ådahl
de1a8c8d89 wayland: Add support for xdg_toplevel.bounds
The GdkToplevelSize struct already has the concept of "bounds", which
means the largest size a window should reasonably have. It's practically
the equivalent of the monitor the window is intended to be mapped on,
with the "struts" (e.g. panels) cut out. It's used by GTK to use this
information to calculate a default window size that is "lagom" (swedish;
not too large, not too small).
2022-06-13 22:12:55 +02:00
Florian Müllner
c3706ea9ec wayland/display: Don't force HighContrast icon theme
The theme is considered deprecated in favor of symbolic icons from
the regular theme.
2022-06-07 19:34:50 +02:00
Matthias Clasen
1f3674cf3e Merge branch 'matthiasc/for-main' into 'main'
gdk: Improve GdkTimeCoord docs

See merge request GNOME/gtk!4795
2022-06-06 13:12:15 +00:00
Matthias Clasen
c76069389c gdk: Improve GdkTimeCoord docs 2022-06-06 08:55:51 -04:00
Benjamin Otte
45422f7b61 Merge branch 'gl-api-es-fix' into 'main'
glcontext: Respect ES API when getting gl version from shared context

Closes #4763

See merge request GNOME/gtk!4687
2022-06-04 20:26:58 +00:00
Pablo Correa Gómez
c4feca1311
glcontext: Simplify get_required_version api
Simplify the API to just return the requirements that the user
has asked for. The rest of the code was undocumented and previously
used as a buggy source for a default value from internal code.
Since the buggy code is now fixed, remove all unnecessary cruft.
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
9426b20759
glcontext: Do not check for correctness in set_required_version
There are two reasons for this:
 * First, the refactored realize code now makes sure that no
   context with unsupported version is ever created.
 * Second, this code could bump into false possitives and negatives, since
   the user is not requested, nor expected to set_required_version
   in any specific order relative to set_allowed_apis. Therefore,
   some version could be rejected or accepted based on a set of
   allowed apis that the user has not yet correctly configured.
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
f97cff1454
glcontext-glx: Refactor realize function
Mimic the behavior of the egl context creation by stablishing
some sane logic for the api and version used. Split the decision
of the type of context (api, legacy) and the creation of a context
of a certain version and all its properties.
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
549a2b4c86
glcontext: Refactor realize function, fix interaction with shared context 2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
f4f0daa113
macosglcontext: Do not rely on default from get_required_version
get_required_version cannot warranty to return any default. Instead,
fetch the user requisites clipped by the requirements in our backend.
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
d4f8a80f2a
glcontext-win32-wgl: Respect user required version, use display as minimum
By setting and then getting the required version in a context, the code
was not respecting user requirements. Instead, simply get the requested
version by the user clipped by the requirements (display version)
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
8d175801d7
glcontext: Add internal get_clipped_version function
It is useful for backends to get user set preferences while
ensuring the correctness of the result, which will be always
greater or equal than the minimum version provided
2022-06-04 20:48:40 +02:00
Pablo Correa Gómez
6bc3ecbe56
glcontext: Improve get_version documentation 2022-06-04 20:48:29 +02:00
Carlos Garnacho
4b41d4f78c gdk/wayland: Check the GdkSurface wl_surface before using it for activation
Double check the GdkSurface has a wl_surface before using it as the activation
token source, since we cannot use NULL surfaces here.

Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1862
2022-06-02 23:08:40 +02:00
Carlos Garnacho
fb68600d88 gdk/wayland: Dispatch GdkAppLaunchContext activation token in its own queue
Use a separate queue to dispatch the token object exclusively, just like we
do on the GdkSurface activation paths.
2022-06-02 23:08:40 +02:00
Pablo Correa Gómez
826fdc4a80
glcontext: Improve documentation on get_use_es api 2022-05-30 20:48:47 +02:00
Nate Eldredge
5faa300c5e Recognize "stylus" devices as GDK_SOURCE_PEN
Add "stylus" to the list of substrings in a device name that cause it to be recognized
as a GDK_SOURCE_PEN device (previously "wacom", "pen" and "eraser").  Some devices
just use "stylus" in their name, and are otherwise recognized as
GDK_SOURCE_TOUCHSCREEN instead.

Fixes #4394.
2022-05-29 15:30:19 -06:00
Matthias Clasen
5507b3f8c1 wayland: scale cursors to the right size
When loading cursors at scale, we expect the
cursor images to have a size of scale * size.
If we don't find such images, load them at their
unscaled size and scale them up ourselves.

Without this, cursors will appear in unexpected
sizes depending on scales and themes.

Related: #4746
2022-05-27 12:26:45 -04:00
Matthias Clasen
23f92ca1c2 Merge branch 'wayland-cursor-scale' into 'main'
wayland: Sanity check cursor image size

Closes #4746

See merge request GNOME/gtk!4761
2022-05-27 10:58:12 +00:00
Matthias Clasen
34a9bc4632 wayland: Make cursors have the right size
The Wayland protocol requires that width and height
of cursor surfaces is an integer multiple of the
surface scale. Make it so.

Fixes: #4746
2022-05-26 22:29:37 -04:00
Matthias Clasen
d603164ec2 wayland: Sanity check cursor image size
On Wayland it is a protocol violation to upload buffers with
dimensions that are not an integer multiple of the buffer scale.

Until recently, Mutter did not enforce this. When it started
doing so, some users started seeing crashes in GTK apps because the
cursor theme ended up with e.g. a 15x16 pixel image at scale of 2.

Add a small sanity check for this case.
2022-05-26 22:29:37 -04:00
Matthias Clasen
c089912a52 Merge branch 'wip/otte/for-main' into 'main'
x11: Always update shadow size

Closes #4136

See merge request GNOME/gtk!4758
2022-05-26 10:03:39 +00:00
Benjamin Otte
213490099b x11: Always update shadow size
Not updating shadow size unconditionally would lead to shadow size not
being set on map, which would lead mutter to think that we are a Window
without extents and then become confused when we suddenly set some.

Make sure that doesn't happen by always having shadows set on map, just
like GTK3.

Fixes #4136
2022-05-26 04:38:29 +02:00
Luca Bacci
7752467847 Drop pointer_emulated discrete scroll events
GTK4 has had smooth scroll events since the beginning, so we
prefer not to emit emulated discrete scroll events at all
2022-05-24 12:30:49 +00:00
Luca Bacci
8514457d0f Wayland: Only send smooth scroll events for tablet tools 2022-05-24 12:30:49 +00:00
Luca Bacci
8a6d6fe6b1 DirectManipulation: Account for DPI scale 2022-05-24 11:37:06 +02:00
Luca Bacci
288dd406e0 GdkWin32: Plug memory leak 2022-05-19 08:49:05 +02:00
Luca Bacci
8f19099f1a GdkWin32: Add support for DirectManipulation
Adds support for Precision TouchPads (PTPs) gestures
and scroll events.
2022-05-15 14:37:55 +02:00
Benjamin Otte
926eb161f8 broadway: Fix gcc 12 complaining 2022-05-14 16:53:44 +02:00
Matthias Clasen
4278e91a46 Merge branch 'texture-fixes' into 'main'
Fixes for gdk_memory_texture_new_subtexture

See merge request GNOME/gtk!4724
2022-05-13 16:38:45 +00:00
Matthias Clasen
f33c521836 Fixes for gdk_memory_texture_new_subtexture
There were several mistakes here.

The width of subtextures was set to the width of
the main texture, the data size wasn't properly
calculated, and the preconditions were inverted.
Yay us!
2022-05-13 09:30:46 -04:00
Loïc Minier
4f2b1b3cfc egl: Fix invalid format string 2022-05-12 09:06:20 -04:00
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Pablo Correa Gómez
0f21f6c273 glcontext: Make the creation of EGL context more obvious
By splitting it into its own function it becomes more that the
EGL code is a shared implementation.
2022-05-10 12:29:08 +02:00
Christian Hergert
4bf07aeef9 gdk/wayland: freeze popups when hidden
Previously, there was an issue with glitching after showing/hiding a
popover that was not also destroyed. This was due to the popover having
an update_freeze_count of zero after hiding the surface.

That resulted in it's toplevel continuously dropping frames such as during
high-frame-rate scrolling in textviews. This problem is much more visible
on high-frame-rate displays such as 120hz/144hz.

With this commit, we freeze the frame clock of the popup until it is
mapped again.
2022-05-10 07:28:25 +03:00
Matthias Clasen
dacca9ece0 Merge branch 'check-half-float' into 'main'
gdk: Check OES_vertex_half_float GLES extension

See merge request GNOME/gtk!4689
2022-05-06 18:02:05 +00:00
Luca Bacci
66a0e0a59e GdkWin32: Send smooth scroll events
Bring back smooth scroll events as the issues mentioned
in [1] do not occur anymore. Also rework code style and
comments.

References:

  [1] GTK4: Scrolling hides mouse on windows
      https://gitlab.gnome.org/GNOME/gtk/-/issues/3581

  [2] Why are mouse wheel messages delivered to the focus window
      instead of the window under the mouse?
      https://devblogs.microsoft.com/oldnewthing/20160420-00/?p=93325
2022-05-06 15:01:59 +02:00
Matthias Clasen
158963ff77 gdk: Check OES_vertex_half_float GLES extension
This will be checked in the GL renderer.
2022-05-05 13:21:25 -04:00
Jonas Ådahl
f1551a87f6 x11: Trap errors happening when getting output properties
This is to avoid getting X11 errors (thus aborting/exiting with a
failure) during rapid hotplugs, which may happen during e.g. CI testing.
2022-05-02 17:28:36 +02:00
Luca Bacci
cb0c1b3f08 GdkWin32: Generate crossing event after button release
Fixes #4813
2022-04-06 20:27:46 +02:00
Luca Bacci
91f200167e GdkWin32: Correct generation of crossing events when holding an implicit grab
Fixes #4722
2022-04-06 20:27:32 +02:00
Luca Bacci
2b6fb005a8 GdkWin32: Report serial for events 2022-04-06 19:45:50 +02:00
Hemidark
0c44851848 gdk: always populate GDK_AXIS_{X,Y} in merged event history
Since GdkTimeCoord stores only axis values, prior to this change,
if a device didn't report GDK_AXIS_X or GDK_AXIS_Y, the history
attached to merged motion events wouldn't contain any positional
information.

Commit 6012276093 already addressed
this issue for devices without tools by storing the event position
in GdkTimeCoord using GDK_AXIS_X and GDK_AXIS_Y and augmenting the
GdkTimeCoord's axis bitmask accordingly.

This change generalizes that workaround to all devices. Note that
if a device DOES report values for GDK_AXIS_X and GDK_AXIS_Y, those
values won't be overwritten.

Closes #4809
2022-04-05 15:35:12 -07:00
Christian Hergert
d75147db0a 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
2022-04-04 18:53:19 +00:00
sumibi-yakitori
d3cf7088b3 macos: Skip running showAndMakeKey when a window is minimized by user action
When a window is minimized by user action, the `showAndMakeKey` method is not executed when idle. This prevents the window from being un-minimized immediately.
And allow programmatic minimization of a window by un-minimizing them in `_gdk_macos_toplevel_surface_present`

Closes #4811
2022-04-05 01:06:44 +09:00
sumibi-yakitori
146bb70c2e macos: prohibit fullscreen transition if in transtion
This prevents performing additional fullscreen transitions while
a transition is already in progress.
2022-04-03 22:14:52 +00:00
Matthias Clasen
a3cedb0163 Merge branch 'clipboard-seg' into 'main'
x11: Check return of gdk_x11_get_xatom_name_for_display

See merge request GNOME/gtk!4607
2022-04-01 00:56:32 +00:00
Matthias Clasen
97bab27d82 Merge branch 'fix-win32-empty-clipboard' into 'main'
gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote() (check GdkContentFormat is not NULL

Closes #4796

See merge request GNOME/gtk!4604
2022-04-01 00:56:02 +00:00
Xavier Claessens
bcd0704511 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-03-31 11:41:34 -04:00
Dr. David Alan Gilbert
506566b6a4 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-03-31 15:56:09 +01:00
Chun-wei Fan
8519ab56f5 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-03-31 10:55:39 +08:00
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
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
Guido Günther
999509be61 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-02-28 16:55:54 +00:00
Luca Bacci
d3acfa8c2b Merge branch 'gdk-win32-configure-as-needed-fullscreen' into 'main'
GdkWin32: Configure as needed when fullscreening toplevels

Closes #4631

See merge request GNOME/gtk!4506
2022-02-28 15:11:36 +00:00
Philip Zander
e5a4b91997 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-02-27 16:40:58 +01:00
Rico Tzschichholz
3faf9d85bb gdk: Add missing out annotation on gdk_content_deserialize_finish 2022-02-26 22:05:20 +01:00
Matthias Clasen
c76b4bdc77 Merge branch 'wip/chergert/macos-add-window-accessor' into 'main'
macos: add getter for NSWindow with macOS windowing

See merge request GNOME/gtk!4509
2022-02-26 03:17:59 +00:00
Christian Hergert
99a40de8ad macos: add getter for NSWindow with macOS windowing
There may be various reasons that an application could need access to the
underlying NSWindow that is being used to display the GdkMacosSurface
contents. This provides a minimal API to do that without exposing our
implementation details through public API.

As our rendering system is likely to change over time, we very much want
to keep GdkMacosView, GdkMacosLayer, GdkMacosTile, and GdkMacosWindow all
private implementation details which are subject to change.

As this is public API, we are a bit long-winded with the name so it is
clear what is being accessed without polluting symbol names with things
like "ns" as we used to.
2022-02-25 11:36:39 -08:00
Luca Bacci
a5643b0c83 Merge branch 'gdk-win32-fix-issue-1402-gtk4' into 'main'
Fix last error reporting when calling GetClipboardOwner

Closes #1402

See merge request GNOME/gtk!4521
2022-02-25 16:54:15 +00:00
Luca Bacci
828688d5cd Fix last error reporting when calling GetClipboardOwner
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1402
2022-02-25 17:14:39 +01:00
Matthias Clasen
fc47b913b1 Merge branch 'wip/chergert/macos-fix-popover-tails' into 'main'
macos: fix positioning of popover tails

See merge request GNOME/gtk!4515
2022-02-25 15:50:15 +00:00
Matthias Clasen
7d8b3357a5 Merge branch 'wip/chergert/better-positioning' into 'main'
macos: fix positioning of popover tails

See merge request GNOME/gtk!4516
2022-02-25 15:49:50 +00:00
Matthias Clasen
e0b98bc7de Merge branch 'wip/chergert/macos-fix-titled-resize' into 'main'
macos: fix origin during live resize of titled window

See merge request GNOME/gtk!4519
2022-02-25 15:49:07 +00:00
Matthias Clasen
493b145496 Merge branch 'wip/chergert/macos-unfullscreen' into 'main'
macos: restore unfullscreen frame with style mask

See merge request GNOME/gtk!4518
2022-02-25 15:48:44 +00:00
Christian Hergert
a56828237a 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-02-24 23:29:18 -08:00
Christian Hergert
56e2a7e8bb 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-02-24 22:32:43 -08:00
Christian Hergert
f278f3610b 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-02-24 18:58:48 -08:00
Christian Hergert
c111e633e9 macos: remove unused code 2022-02-24 18:58:07 -08:00
Christian Hergert
eea7cf30bb 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-02-24 18:58:07 -08:00
Christian Hergert
36bdcfaccb 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-24 16:29:53 -08:00
Benjamin Otte
de705c2a2b Add 4.8 version macros 2022-02-22 22:55:48 -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