Commit Graph

10574 Commits

Author SHA1 Message Date
Sebastian Keller
018bbd6774 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-04-21 19:14:32 -04:00
Luca Bacci
88db5509a3 GdkWin32: Generate crossing event after button release
Fixes #4813
2022-04-08 15:26:48 +02:00
Luca Bacci
7538ff9798 GdkWin32: Correct generation of crossing events when holding an implicit grab
Fixes #4722
2022-04-08 15:26:37 +02:00
Luca Bacci
c0a60ece97 GdkWin32: Report serial for events 2022-04-08 15:26:26 +02:00
Luca Bacci
c799b05f2a Merge branch 'backport-4406-4.6' into 'gtk-4-6'
gdkclipboard-win32.c: Fix call to gdk_clipboard_claim_remote() (backport MR !4604 to gtk-4-6)

See merge request GNOME/gtk!4608
2022-04-08 08:30:48 +00:00
Christian Hergert
d468dd2f3b 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

(cherry picked from commit d75147db0a)

d3cf7088 macos: Skip running `showAndMakeKey` when a window is minimized by user action
2022-04-04 18:53:35 +00:00
Christian Hergert
029fc0fdef Merge branch 'sumibi-yakitori/fix-maximize-window-macos' into 'main'
macos: prohibit fullscreen transition if in transtion

This prevents performing additional fullscreen transitions while
a transition is already in progress.

Closes #4808

See merge request GNOME/gtk!4612

(cherry picked from commit 15b7a4572b)

69a0a5cf macos: Prohibit changing the full-screen state of a window during a full-screen transition
229e4b58 macos: Corrected code style
2022-04-03 22:15:16 +00:00
Chun-wei Fan
edd8d55b42 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-04-01 10:28:37 +08:00
Matthias Clasen
8a12628af9 Merge branch 'wip/carlosg/backports-4-6' into 'gtk-4-6'
Backport fixes to 4.6

See merge request GNOME/gtk!4577
2022-03-17 01:50:18 +00:00
Christian Hergert
73d5f7061b macos: exclude popups from window list
This probably only matters if you do window list integration for the global
menu on macOS.
2022-03-16 12:25:10 -07:00
Christian Hergert
ccbaa020ff macos: pass events to foreign windows 2022-03-16 12:25:10 -07:00
Christian Hergert
a9c89fa23e macos: dont steal key window from NSPanel
Or we risk making it really difficult to use native file choosers.
2022-03-16 12:25:10 -07:00
Christian Hergert
36730537cc 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-16 12:25:10 -07:00
Christian Hergert
9456f6eea1 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-16 12:25:10 -07:00
Christian Hergert
2c630a74cd 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-16 12:25:10 -07:00
Christian Hergert
9462b3fea2 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-16 12:25:10 -07:00
Christian Hergert
d62313e75c 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-16 12:25:10 -07:00
Christian Hergert
023bf9aea7 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-16 12:25:10 -07:00
Christian Hergert
4bc593c761 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-16 12:25:10 -07:00
Christian Hergert
f47e6dda78 macos: make transient-for key window when hiding surface
This only handled the popover case before and not the transient-for case.
2022-03-16 12:25:10 -07:00
Christian Hergert
5c2d9d6f19 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-16 12:25:10 -07:00
Christian Hergert
5efa8071d6 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-16 12:25:10 -07:00
Christian Hergert
659832ccab 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-16 12:25:10 -07:00
Christian Hergert
913f6d4a4f 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-16 12:25:10 -07:00
Christian Hergert
cb386ec2a2 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-16 12:25:10 -07:00
Christian Hergert
2f873052f9 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-16 12:25:10 -07:00
Christian Hergert
60aceb984f 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-16 12:25:10 -07:00
Christian Hergert
9dbd79f2d8 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-16 12:25:10 -07:00
Christian Hergert
0aabf47f09 macos: invalidate surface contents when mapping 2022-03-16 12:25:10 -07:00
Christian Hergert
2961cc44c5 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-16 12:25:09 -07:00
Christian Hergert
46da364289 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-16 12:25:09 -07:00
Christian Hergert
cb99370ce4 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-16 12:25:09 -07:00
Christian Hergert
c2d1a21f9c 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-16 12:25:09 -07:00
Christian Hergert
edc6790fbb 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-16 12:25:09 -07:00
Christian Hergert
b0d7889b20 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-16 12:25:09 -07:00
Christian Hergert
867f2de194 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-16 12:25:09 -07:00
Christian Hergert
50e2a8239b 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-16 12:25:09 -07:00
Christian Hergert
42f9ea07e2 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-16 12:25:09 -07:00
Christian Hergert
9b28153571 macos: style cleanup 2022-03-16 12:24:12 -07:00
Christian Hergert
2e1e7e7265 macos: add re-entrancy check when monitors change 2022-03-16 12:24:12 -07:00
Christian Hergert
7369ce58da 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-16 12:24:11 -07:00
Christian Hergert
c7a6d1e8bf 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-03-16 12:24:11 -07:00
Christian Hergert
17b40ca148 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-03-16 12:24:11 -07:00
Christian Hergert
29d424ef91 macos: add GDK_NOTE when surface changes monitor 2022-03-16 12:24:11 -07:00
Christian Hergert
27e9b87fbd 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-03-16 12:24:11 -07:00
Christian Hergert
f2ac5576c2 macos: leave note about monitor discovery 2022-03-16 12:24:11 -07:00
Christian Hergert
590a1c2f3a 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-03-16 12:24:11 -07:00
Christian Hergert
75b186eb62 macos: fix redisplay of GdkPopup
This broke recently during the configure cleanups and also needed to have
the tail directions fixed again.
2022-03-16 12:24:11 -07:00
Christian Hergert
998c787638 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-03-16 12:24:11 -07:00
Christian Hergert
b2ab0b1fcb 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-03-16 12:24:11 -07:00