Commit Graph

39 Commits

Author SHA1 Message Date
Arjan Molenaar
b7f3beda00 macos: Map Cmd directly to Meta
Why need a mapping via a MOD2 mask?
2024-06-28 10:29:57 +02:00
sumibi-yakitori
37a5ad3a53 Fix coding style 2023-10-04 03:30:32 +09:00
sumibi-yakitori
00e4dab1ef macos: change to send motion events to NSApp
This fix addresses a problem where the mouse cursor cannot be changed after it becomes a resize indicator, even in non-CSD windows
2023-10-03 08:14:27 +09:00
Arjan Molenaar
6757a1b409 macos: Propagate events for child surfaces
Before, popup windows did not respond to mouse clicks.
This change fixes that.

Fixes #5528.
2023-01-24 09:07:33 +01:00
Arjan Molenaar
d6ef39b9a2 macos: remove dead code 2023-01-21 15:22:13 +01:00
Arjan Molenaar
52f6acd398 macos: Send dragging events directly to the display
Instead of adding events to the application event queue, dispatch
them directly to the right display. We know this when the event is
to be dispatched.

This is the same as used for the `sendEvent` method in `GdkMacosWindow`.

To achieve this I factored out the generic NSEvent to GdkEvent translation.
We can send an event directly, when we receive it in the GdkMacosWindow
directly from the OS.
2023-01-21 14:54:12 +01:00
Arjan Molenaar
097d87e502 Cleanup: remove unused variables from macos code
Remove unused variables. In case if Cairo code it would
allocate memory, which would result in a memory leak.
2022-12-04 12:50:20 +01:00
Philip Zander
c84c469b78 Use native Windows API for converting keystrokes to characters 2022-10-17 19:36:48 +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
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
Christian Hergert
3cd68c5de5 macos: pass events to foreign windows 2022-03-11 18:25:47 -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
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
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
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
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
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
db77204a52 macos: improve event filtering for foreign panels
We might have panels with controls in them where the window is running in
another process. The control could have a wrapper window which we would
see from this process. This can happen with the GtkFileChooserNative, but
any NSSavePanel in macOS 10.15+ is out of process (not just sandboxed
applications).
2022-02-18 03:39:52 -08:00
Christian Hergert
a080f1197a macos: ignore mouse events outside tracking area
We also need to ignore events outside the tracking areas when we are
translating them from NSevent into GdkEvent.
2022-02-16 03:06:51 -08:00
Andy Russell
37702af22b
gdk: fix reversed and sluggish scrolling on MacOS
When using an external mouse on MacOS, the scrolling behavior is
reversed from the user's scrolling preference. Additionally, it is
noticeably sluggish.

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

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

[Druid]: https://linebender.gitbook.io/linebender-graphics-wiki/mouse-wheel#external-mouse-wheel-vs-trackpad
2022-02-14 14:05:39 -05:00
Matthias Clasen
2772ff624f gdk: Prepare touchpad events for sequences
It makes sense to connect the begin/update/end events
for touchpad swipes and pinches in a sequence. This
commit adds the plumbing for it, but not backends
are setting sequences yet.
2021-12-15 21:58:57 -05:00
Benjamin Otte
4e836493cc macos: Don't include gdkinternals.h 2021-09-24 22:50:29 +02:00
Christian Hergert
ad1260505d macos: check for GdkMacosBaseView before using as such
We can get events for external windows such as those from native
file chooser dialogs.
2021-06-17 17:18:19 -07:00
Ignacio Casal Quinteiro
f5efb15cba Support stylus devices on macos 2021-01-11 11:41:00 +01:00
Christian Hergert
28a6f0df05 macos: handle point conversion on older macOS
On older systems, the availability of some methods seem to be incorrect
based on Apple documentation. This works around the issue by using
the rect conversion on older systems.
2021-01-05 13:52:11 -08:00
Christian Hergert
d888402bf9 macos: ensure GdkMacosWindow in surface discovery
We want to ignore windows that are not related to those controlled
by the GDK backend.

Fixes #3533
2020-12-31 10:55:50 -08:00
Christian Hergert
115ea624d9 macos: fix typo when creating scroll events
This fixes an issue where we would ignore events with Y delta
and no X delta while scrolling due to a typo when checking for
any delta.

This fixes deceleration of kinetic scrolling on the macOS backend.

Fixes #3418
2020-12-03 13:46:47 -08:00
Christian Hergert
7444a151b2 macos: remove synthesize_motion helper
We can use gdk_surface_request_motion() now instead of our extra
helper to do essentially the same thing.
2020-11-04 16:58:50 -08:00
Christian Hergert
eb82b2a9ca macos: fix discovery of surface under pointer 2020-10-19 12:35:41 -07:00
Christian Hergert
6e84c7c59e macos: fix discover of surface under cursor
This was incorrectly reporting the toplevel surface instead of the
popup surface that was placed above it. This fixes event delivery
to popups for selecting menu items and more.
2020-10-14 16:59:38 -07:00
Christian Hergert
b462bc35c0 macos: allow pointer release event outside surface coords
This helps with grab situations so that we can end it when releasing
the pointer buttons outside of the window coordinates.
2020-10-14 15:45:50 -07:00
Christian Hergert
cdb2c1698c macos: dont send crossing events during grab
Fixes an issue where we can't drag scrollbars or text selections while
outside of the application window.
2020-10-14 15:45:50 -07:00
Christian Hergert
d5b5410b8f macos: use simple monotonic for event serial 2020-10-14 11:34:44 -07:00
Christian Hergert
3f519e4d9b macos: remove workaround for scroll delta
This gets handled differently in gtk/ and so we shouldn't translate it here.
2020-10-09 20:02:38 -07:00
Christian Hergert
58f9413464 macos: track various changes in GDK 2020-10-09 20:02:18 -07:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Christian Hergert
9dbf99d91a macos: prototype new GDK backend for macOS
This is fairly substantial rewrite of the GDK backend for quartz and
renamed to macOS to allow for a greenfield implementation.

Many things have come across from the quartz implementation fairly
intact such as the eventloop integration design and discovery of
event windows from the NSEvent.

However much has been changed to fit in with the new GDK design and
how removal of child GdkWindow have been completely eliminated.
Furthermore, the new GdkPopup allows for regular NSWindow to be used
to provide popovers unlike the previous implementation.

The object design more closely follows the ideal for a GDK backend.

Views have been broken out into subclasses so that we can support
multiple GSK renderer paths such as GL and Cairo (and Metal in the
future). However mixed mode GL and Cairo will not be supported. Currently
only the Cairo renderer has been implemented.

A new frame clock implementation using CVDisplayLink provides more
accurate information about when to draw drawing the next frame. Some
testing will need to be done here to understand the power implications
of this.

This implementation has also gained edge snapping for CSD windows. Some
work was also done to ensure that CSD windows have opaque regions
registered with the display server.

     ** This is still very much a work-in-progress **

Some outstanding work that needs to be done:

 - Finish a GL context for macOS and alternate NSView for GL rendering
   (possibly using speciailized CALayer for OpenGL).
 - Input rework to ensure that we don't loose remapping of keys that was
   dropped from GDK during GTK 4 development.
 - Make sure input methods continue to work.
 - Drag-n-Drop is still very much a work in progress
 - High resolution input scrolling needs various work in GDK to land
   first before we can plumb that to NSEvent.
 - gtk/ has a number of things based on GDK_WINDOWING_QUARTZ that need
   to be updated to use the macOS backend.

But this is good enough to start playing with and breaking things which
is what I'd like to see.
2020-07-21 14:45:12 -07:00