Commit Graph

88 Commits

Author SHA1 Message Date
Christian Hergert
9320148d71 macos: implement compute_size and request_layout
These functions were not implemented when the sizing changes
landed before GTK 4 was released. This fixes an issue with non-
resizeable windows not reacting to layout changes.

Fixes #3532
2021-01-01 13:17:47 -08:00
Christian Hergert
ad617a0e06 macos: avoid setHasShadow unless shadow changes 2021-01-01 13:17:47 -08:00
Christian Hergert
62af8365f6 macos: fix toplevel present function prototype
No need to return anything here.
2021-01-01 13:17:47 -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
Ignacio Casal Quinteiro
4ad5e77907 macos: do not crash in mojave
The localizedName property is not available in Mojave
so just ifdef in that case the code out.
2020-12-31 11:35:04 +01:00
Tom Schoonjans
81c55b06d2 macos: fix typo that breaks compilation 2020-12-16 19:16:19 +00:00
Jonas Ådahl
142f7862ed gdk/toplevellayout: Change API to be about intent, not full state
When being fullscreen, and wanting to unfullscreen but not caring about
whether to go unmaximized or maximized (as this information is lost), if
the GdkToplevelLayout represents the full intended state, we won't be
able to do the right thing.

To avoid this issue, make the GdkToplevelLayout API intend based, where
if one e.g. doesn't call gdk_toplevel_set_maximized() with anything, the
backend will not attempt to change the maximized state.

This means we can also remove the old 'initially_maximized' and
'initially_fullscreen' fields from the private GtkWindow struct, as we
only deal with intents now.
2020-12-16 14:16:08 +01:00
Emmanuele Bassi
99e0929d6c build: Use a consistent style for Meson files 2020-12-15 12:46:59 +00:00
Emmanuele Bassi
7975bbfcaa build: Remove linker flags from static libraries
We only need hardening linker flags on the libgtk shared library;
internal static libraries don't really need them.
2020-12-15 11:36:20 +00:00
Christian Hergert
0236fe80c1 macos: fix macOS build breakage
Fixes breakages due to recent refactoring around sizing changes.
2020-12-08 11:29:31 -08:00
Matthias Clasen
1f141c1953 Merge branch 'wip/surface-state-rework' into 'master'
Rework surface state and geometry computation

See merge request GNOME/gtk!2885
2020-12-08 15:38:36 +00:00
Christian Hergert
6e0fffa0f8 macos: use CGLSetParameter and CGLEnable
We don't need to go through the NSOpenGLContext for these.
We can just use the C API directly. It's also clearer what is using
CGLEnable() vs CGLSetParameter().
2020-12-07 11:47:51 -08:00
Jonas Ådahl
d2c95a1b13 gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.

It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.

To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 20:37:30 +01:00
Jonas Ådahl
5eee1dfcd1 gdk/popup: Remove the popup-layout-changed signal
It was replaced with GdkSurface::layout.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
6ee7535af0 gdk/toplevelsize: Rename 'margin' to 'shadow' and 'shadow_width'
This makes it more consistent with everywhere else.
2020-12-07 20:37:29 +01:00
Jonas Ådahl
42679f2903 gdk: Replace all GDK_CONFIGURE usage with GdkSurface::layout
This removes the GDK_CONFIGURE event and all related functions and data
types; it includes untested changes to the MacOSX, Win32 and Broadway
backends.
2020-12-07 20:37:29 +01:00
Christian Hergert
b431e39d4e macos: we only need 24-bit for color 2020-12-07 11:27:11 -08:00
Jonas Ådahl
3f96d4b6da gdk: Always get shadow width via GdkToplevelSize
This removes the gdk_surface_set_shadow_width() function and related
vfuncs. The point here is that the shadow width and surface size can now
be communicated to GDK atomically, meaning it's possible to avoid
intermediate stages where the surface size includes the shadow, but
without the shadow width set, or the other way around.
2020-12-07 09:46:39 +01:00
Christian Hergert
285781724f macos: set opengl view as opaque in opaque windows
We don't need the OpenGL view to be transparent if the window itself
is not transparent. This has the potential to speed up the compositing
of the GL view onto the NSWindow.
2020-12-06 20:14:52 -08:00
Emmanuele Bassi
f1ff8f9aad Merge branch 'wip/chergert/macos-decelerate' into 'master'
macos: fix typo when creating scroll events

Closes #3418

See merge request GNOME/gtk!2916
2020-12-03 22:54:46 +00: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
92f0216605 macos: ensure element is part of queue
We don't want to risk decrementing length field unless this is actually
part of the queue.
2020-12-02 19:44:02 -08:00
Christian Hergert
e317b9be00 macos: maintain GList element consistency
We need to keep this consistent so that we can look things up
faster in other places. Therefore, just take the hit here and clear
the entire list ensuring prev/next poniters are cleared.
2020-12-02 19:44:01 -08:00
Christian Hergert
2e52386be5 macos: send focus-out event to windowing 2020-12-02 19:44:01 -08:00
Christian Hergert
9431c70a6a macos: freeze updates until surface is mapped
This more closely matches the X11 backend in terms of freezing
updates on the surface initially until we get mapped.
2020-12-02 19:44:01 -08:00
Christian Hergert
b38d0d7d9e macos: resign main/key when hiding window
This isn't done automatically for us, so we need to synthesize it in
our hide helper.

With this commit, we properly re-focus the new main/key window after
we have closed a transient-for window.
2020-12-02 11:36:38 -08:00
Christian Hergert
853a9c7a8c macos: disconnect frame clock when destroying surface 2020-12-02 11:35:02 -08:00
Christian Hergert
26b9254ac7 macos: track grab serial like other backends
This is what is done elsewhere, so copy that here too now that we actually
generate serials for events.
2020-12-02 11:34:31 -08:00
Christian Hergert
f11c23f407 Revert "macos: specify a window level for surfaces"
This reverts commit ca8b00e871.

This isn't needed and causes issues with other applications getting
stacked beneath our windows.
2020-12-02 11:15:57 -08:00
Christian Hergert
9b9fb4d7a3 macos: place above transient-for when presenting
We need to re-attach to the transient-for window whenever we present or
we risk getting placed behind the window by the display server. Apparently
that setting does not persist across a hide of the NSWindow.
2020-12-02 10:21:16 -08:00
Christian Hergert
ca8b00e871 macos: specify a window level for surfaces 2020-12-02 10:15:43 -08:00
Christian Hergert
27b9a9e7ef macos: glFlush() when switching GL contexts
The Mac OpenGL programming guide suggests that you glFlush() before changing
contexts to ensure that the commands have been submitted.
2020-12-01 16:19:04 -08:00
Christian Hergert
a020c901ba macos: treat some toplevel NSWindow like document windows
This makes the window animate in by the window manager like other
application windows on macOS. Currently ignored for transient windows.
2020-12-01 16:19:04 -08:00
Christian Hergert
f32ae2964a macos: fix various compiler warnings 2020-11-18 20:16:37 -08:00
Christian Hergert
dd7f52c59a macos: fix rendering artifacts with hover transitions
Using an image surface seems to fix some rendering artifacts when
performing cross-fade CSS transitions.
2020-11-17 18:20:55 -08:00
Christian Hergert
90141ef305 macos: use NSOpenGLContext directly for current tracking
We don't need to interact with GdkGLContext here to keep the
current context active.
2020-11-05 13:57:41 -08:00
Christian Hergert
bc05da8dc0 macos: explicitly request color and alpha sizes 2020-11-05 13:37:25 -08:00
Christian Hergert
bf3e1e5b40 macos: use opaque GL context when possible
This is better for situations where the window is decorated and therefore we can
rely on window system clipping of rounded corners.
2020-11-05 13:34:29 -08:00
Matthias Clasen
7f16067383 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: gl context improvements and event cleanup

See merge request GNOME/gtk!2780
2020-11-05 02:21:02 +00:00
Christian Hergert
c31c3848df macos: fix calculation of mouse position
This fixes the calculation of the position of the pointer over the surface
which was incorrectly providing negative values.
2020-11-04 18:03:54 -08:00
Christian Hergert
65b2ea1888 macos: resize extra GL window/view when surface changes
Once we figure out what is going on with textures, changes are we'll be
able to let this stay a zero rect. But that is still a bit up in the air right now.
2020-11-04 17:21:21 -08:00
Christian Hergert
6309bd12ac macos: clip damage when swapping buffers
This ensures that we only copy the changed area.
2020-11-04 17:21:17 -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
ce9cc2db86 macos: always create dummy window/view for GL context
This simplifies the creation by always creating the dummy views, and then
removes it if necessary by detecting the begin_frame/end_frame pair.
2020-11-04 16:52:12 -08:00
Christian Hergert
d8192013f3 macos: add more aggressive clip to transparent subview
The Cairo implementation for the Macos backend uses a toplevel
window with full transparency and a series of NSView to create opaque
regions. This improves compositor performance because it allows the
display server to avoid costly blends.

However, we want to ensure we clip better when exposing the
transparent region so that we only expose the shadows/corners as
necessary.
2020-10-29 19:41:21 -07:00
Matthias Clasen
5a77994516 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2760
2020-10-29 18:55:53 +00:00
Matthias Clasen
574a3a456d gdk: Drop GdkPoint from the api
This typedef was not used in any public APIs, and is
only used in the MacOS backend. It is not worth preserving
as public API, move it to the only user.
2020-10-29 14:23:46 -04:00
Christian Hergert
de9c9efa6f macos: implement GL context
This implements the basics for a GdkGLContext on macOS. Currently, rendering
only is fully working for the GskCairoRenderer case where we read back pixels
into a cairo surface for rendering. More work on synchronization is required for
the GL on GskGLRenderer case.

When we attempt to render a surface itself with GL, the context will ensure that
the new GdkMacosGLView is placed within the NSWindow. In other cases, we
use a dummy NSView and NSWindow for backing the NSOpenGLContext to
ensure that we can get accelerated drawing.

This gets GtkGLArea working when running with GSK_RENDERER=cairo.
2020-10-29 10:57:02 -07:00
Christian Hergert
eb809ba425 macos: tweak gravity while resizing
This helps a situation where the window contents has not changed
in time for a drawing. Setting the texture gravity helps that side or
corner to be less jittery while moving.

Ideally, we can get to a point where we are synchronized and keeping
up with drawing fast enough to not need this. That may require some
work to drive frame clocks from drawRect: though.
2020-10-29 10:57:02 -07:00
Christian Hergert
adf60fb3a1 macos: be tolerant of NULL GL context
Some code appears to unconditionally attempt to make the context current,
so this makes things tolerant to a NULL GdkGLContext and just return FALSE.
2020-10-29 10:57:02 -07:00