Commit Graph

204 Commits

Author SHA1 Message Date
Tim Clem 8dae8ad8d8 winemac.drv: Don't activate the app if its first window is WS_EX_NOACTIVATE.
This matches the behavior on Windows.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-19 20:37:46 +01:00
Tim Clem e58b1a2b39 winemac.drv: Use Cocoa nonactivating panels for WS_EX_NOACTIVATE windows.
NSWindowStyleMaskNonactivatingPanel is almost exactly the same behavior
as WS_EX_NOACTIVATE on Windows: it prevents the window from activating
the app, but does not prevent it from being focused if the app is
already active.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-19 20:37:42 +01:00
Tim Clem 4b4ebef412 winemac.drv: Allow foregrounding WS_EX_NOACTIVATE windows.
The previous behavior denies any attempt to focus such windows, which
is not in line with how they behave on Windows.

Rename the macdrv_window_state no_activate field to no_foreground
so it more accurately reflects its meaning.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-19 20:31:33 +01:00
Keno Fischer 1f17015cea winemac: Unconditionally link to QuartzCore.
This fixes non-Metal builds.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52216
Signed-off-by: Keno Fischer <keno@juliacomputing.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-06 16:01:28 +01:00
Huw Davies 6bb537c8b0 winemac: Don't try to update when the window is closing.
This can happen after the window surface has been destroyed.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52231
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-04 18:35:07 +01:00
Brendan Shanks 32fb017d4a winemac.drv: Remove workarounds for Mac OS X 10.6 and earlier.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-18 22:37:18 +01:00
Tim Clem 5e543fee7a winemac.drv: Stop cursor clipping when all windows are minimized.
There's no analogous state on Windows, where an app is focused but has no
visible windows, but this seems like the best behavior.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-20 20:12:08 +02:00
Tim Clem b5deeff860 winemac.drv: Allow cycling of windows with Cmd+`.
We already set up the Window menu and set the relevant bits in
collectionBehavior, but windows must respond YES to
-canBecomeKeyWindow in order to actually be activated by Cmd+`
window cycling.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-10 09:00:21 +02:00
Jan Sikorski 0d22e8455a winemac.drv: Omit WM_ENTER/EXITSIZEMOVE on non-interactive window changes.
The motivating example is when a newly created window gets moved off the system
menu bar. A program might not be prepared to handle these messages yet.

Fixes a crash in Lord of the Rings online.

Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-06 18:00:41 +02:00
Chip Davis 3f845b34de winemac.drv: Remove now unused -[WineContentView drawRect:].
Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 17:10:09 +02:00
Chip Davis 9e599a89e3 winemac.drv: Set the surface contents directly to the layer.
Use a top-down DIB for the surface instead of a bottom-up DIB. This
seems to match better with how Core Graphics expects to receive image
data, and allows us to avoid a transform to flip the surface image.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 17:10:05 +02:00
Chip Davis cad2a7c8e1 winemac.drv: Move GL context update code to -viewWillDraw method.
Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 17:10:00 +02:00
Chip Davis 01f027b2db winemac.drv: Use a mask layer to support window regions.
Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 17:09:43 +02:00
Chip Davis a5cf847aa4 winemac.drv: Enable layer-backed views.
Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-01 17:09:41 +02:00
Stefan Dösinger 004b1179e9 winemac.drv: Set view.WantsBestResolutionOpenGLSurface.
This used to default to false before Catalina, and it still does so when
the application is built with XCode 10 or earlier. When building with
XCode 11 or later Catalina and newer will create a high DPI GL view even
if the window is low dpi. Because we don't adjust glViewport parameters
(and glDrawPixels, etc) we render only to the lower left quadrant.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-05-12 16:56:27 +02:00
Brendan Shanks 7aa2601f94 winemac.drv: Fix warnings for constants deprecated by macOS 10.12.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-07-27 23:28:16 +02:00
Brendan Shanks 737c54dca0 winemac.drv: Build cocoa_window.m with GL_SILENCE_DEPRECATION.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-07-23 22:30:48 +02:00
Chip Davis 606424bbbc winemac.drv: Pass the CAMetalLayer to MoltenVK.
It isn't safe to access the view object from any thread other than the
main thread. In fact, if you try to call vkCreateMacOSSurfaceMVK() from
any other thread, MoltenVK prints out a big, scary warning telling you
not to do this! Instead, get the layer from the view ourselves and pass
that to MoltenVK. Recent versions of MoltenVK can accept either the view
or the layer.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-12-18 20:54:34 +01:00
Jacek Caban 7c29f5a3b3 winemac.drv: Make sure that NSMiniaturizableWindowMask style mask is set before calling miniaturize.
miniaturize fails to minimize window when NSMiniaturizableWindowMask
style is not set. The style will be restored on window restore (or earlier).

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-11-07 19:44:17 +01:00
Aric Stewart db3864e5b3 winemac.drv: Allow mac IME to clear text in system input method.
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-05-06 13:19:32 -05:00
Ken Thomases 654b27823d winemac: Fix failure to render OpenGL on macOS 10.14 (Mojave).
For programs linked against the macOS 10.14 SDK, Mojave makes all view
hierarchies layer-backed.  For views to which OpenGL contexts have been
attached this caused a regression where they sometimes failed to render and
just remain black.  Updating the OpenGL context after the framework has
assigned a layer to our view works around the problem.  Thanks to Elviss
Strazdins on Stack Overflow for the solution
<https://stackoverflow.com/a/52938517/1312143>.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-02-07 22:45:03 +01:00
Ricky Zhou f621baa00f winemac: Allow Command to be mapped to Ctrl.
Adds the following registry options, which configure the Mac driver to
map Command to Ctrl:

HKEY_CURRENT_USER\Software\Wine\Mac Driver\LeftCommandIsCtrl
HKEY_CURRENT_USER\Software\Wine\Mac Driver\RightCommandIsCtrl

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=35351
Signed-off-by: Ricky Zhou <ricky@rzhou.org>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-09-17 15:37:19 +02:00
Ken Thomases ed7e057388 winemac: Don't change the window's color space.
This was originally done to improve performance at the expense of visually-
correct rendering.  I've reconsidered that trade-off.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-16 09:19:46 +02:00
Ken Thomases 357017cd87 winemac: Implement WineMetalView class.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-13 17:20:43 +02:00
Ken Thomases e27abb0a3a winemac: Extract a new class, WineBaseView, to be the superclass of WineContentView and future view classes.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-07-13 17:20:43 +02:00
Ken Thomases 64704bef18 winemac: Fix z-ordering between two child (owned) windows of the same parent (owner).
The window being ordered was first put in the correct place and then was moved
to the other end of the children list by the loop that was intended to adjust
the windows strictly between the window and the ancestor.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-05-22 00:05:13 +02:00
Ken Thomases 041f59350c winemac: Reenable window autodisplay when the frame is set and redisplayed.
Cocoa will draw the window frame immediately but if autodisplay of its content
view is disabled, that may leave the content area black briefly.  This change
avoids that flicker.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-03-26 11:28:49 +02:00
Ken Thomases 5f80cc43bf winemac: Stop the display link after 2 seconds of idleness, not the first time it's idle.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-12-08 10:56:58 +01:00
Ken Thomases 4e9c3444fb winemac: Leave a window in auto-display mode when it doesn't yet have a display link.
This fixes an issue where some windows (on some systems) would never display
their content area.  If they had a title bar, they'd just display that and
nothing else.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-12-08 10:56:54 +01:00
Ken Thomases fd6f2a1781 winemac: Check the display link running state as well as the window count to decide whether to start/stop it.
The display link may be stopped even if there are associated windows, due to
idleness.  So, it may need to be started when a window is added even if it's
not the first window.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-12-08 10:56:33 +01:00
Ken Thomases 6250eb54fe winemac: Break out of the window-dragging message loop if the window is hidden or destroyed.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-06-21 19:15:12 +02:00
Ken Thomases 48548812fe winemac: Move the logic for posting a KEYBOARD_CHANGED event if the keyboard type changes into the setter of the keyboardType property.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-16 12:08:55 +02:00
Ken Thomases b6a4b2f593 winemac: Track whether a view has ever had an OpenGL context attached.
... rather than whether it currently has one.

This is for OpenGLSurfaceMode=behind.  In that mode, we need to make the window
transparent wherever a GL-rendered view should not be clipped by GDI-rendered
children or sibling views.

Some apps attach a GL context to the view only temporarily, do some rendering,
and then detach it.  But the GL surface remains, with the rendered graphics.
In order for those to show, the window needs to remain transparent even though
none of its views has a GL context currently attached.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-08 16:25:55 -05:00
Ken Thomases 24d3795285 winemac: Move CVDisplayLink operations out of @synchronized blocks to avoid potential deadlock.
The -fire method called by the display link callback also synchronizes on self
(while accessing the windows array).  Display link operations use a lock to
synchronize, too, and it's held while the callback is running.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-08 16:25:54 -05:00
Ken Thomases e0ef30e542 winemac: Don't let child (owned) windows be Cocoa primary full-screen windows.
They shouldn't get a separate space; they should stick with their parent (owner).

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:18 +02:00
Ken Thomases ff3766c759 winemac: Use the -close method rather than -orderOut: for full-screen windows.
Simply ordering them out leaves the user on the full-screen space, which is now
an empty black screen.  Closing the window closes the space, too.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:14 +02:00
Ken Thomases 5ebb83ad4e winemac: Defer ordering a window out if it's in the process of entering or exiting Cocoa full-screen mode.
Cocoa doesn't handle the window being ordered out or closed during the
animation well and leaves a ghost window around.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:11 +02:00
Ken Thomases 302593c9c0 winemac: Better handle z-ordering windows that are in Cocoa parent-child window relationships.
The code had been handling ordering sibling windows relative to each other,
including windows neither of which were child windows.  However, it wasn't
properly handling other relationships (e.g. cousins, nieces, uncles, etc.).

The reason this is complicated is that Cocoa keeps child windows in a fixed
relative order to their parent and siblings.  The normal -orderWindow:relativeTo:
method doesn't work.  One has to remove the children from the parent and re-add
them in the desired order.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:07 +02:00
Ken Thomases e30b1aef1b winemac: When realizing latent child windows, maintain their relative z-order.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:03 +02:00
Ken Thomases 49bb11fef2 winemac: Move a window to the front when its Mac title bar is clicked.
Cocoa does this automatically for non-owned windows and informs the back end
via a different mechanism (WINDOW_BROUGHT_FORWARD).  However, for owned windows
(child windows in Cocoa parlance), Cocoa does not change their z-order relative
to the owner (parent) or sibling owned windows when clicked.  So, we have to
move the window in user32's z-order so that it gets moved appropriately on
screen in response.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:31:59 +02:00
Ken Thomases c9528f0907 winemac: Invalidate cached hasGLDescendant value unconditionally when the view is hidden or unhidden.
Even if the (un)hidden view doesn't have attached GL contexts itself, its
descendants may.  It doesn't make sense not to check them just because this
view doesn't have GL contexts.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-21 10:53:49 +02:00
Ken Thomases c5eca7be91 winemac: Discard key repeat events after a modifier key has been pressed.
Sierra (macOS 10.12) changed the behavior of key repeat.  In previous versions
of macOS, key repeat stops when a modifier key is pressed or released.  In
Sierra, it does not; it just keeps repeating as newly-modified.

On Windows, key repeat stops when a modifier key is pressed, although not when
one is released.  Some programs depend on this behavior.  So, the Mac driver
emulates it.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-03-10 10:03:56 +01:00
Ken Thomases 2128125cbf winemac: Reattach OpenGL contexts to a view after it has been hidden and unhidden.
Hiding a view seems to semi-detach any attached OpenGL contexts such that
rendering no longer works.  There's no GL surface for the view.  Calling
-[NSOpenGLContext update] is not sufficient to reattach the context.  So,
fully detach the contexts and reattach them.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-02-03 09:35:23 +01:00
Ken Thomases 733e22d0c1 winemac: Make some operations on Cocoa views asynchronous.
There's no reason for them to be synchronous and this improves performance.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-02-01 21:19:39 +01:00
Ken Thomases eba417a477 winemac: Detect loss of ownership of the Mac pasteboard and update the clipboard manager status.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:10:18 +02:00
Ken Thomases a85f11c2e6 winemac: Post WINDOW_FRAME_CHANGED with the non-fullscreen frame when exiting of fullscreen mode begins.
We had been posting it when exiting fullscreen mode ended.  However, certain
events during exiting could provoke the back-end to assert the window frame as
it knows it, which would be the one from full-screen mode.  This would be
handled by the Cocoa thread after exiting full-screen mode.  So, the window
would animate to its pre-fullscreen frame and then spontaneously go back to
covering the screen.  This would be Windows-style fullscreen rather than
Cocoa-style and there'd be no obvious way to get out.

The problem occurs on macOS 10.12 (Sierra) due to a change in what methods it
calls on the window while exiting fullscreen.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-11 16:51:34 +02:00
Ken Thomases fdd7db0593 winemac: Set windows to transparent until they have content to draw, to reduce flicker.
When a window is shown, it may not have drawn its content into the backing
surface, yet.  Cocoa will draw the window, starting with its standard light
gray background and then the content view.  However, the content view won't
have anything to draw, yet, though, so the window background is not drawn over.

A short while later, usually, the app will paint its content into the window
backing surface and Cocoa will be told to redraw the window.  This works, but
the user can often see the flash of the window background color first.  This
is especially visible for windows with dark content.

Part of the fix is to set the window background to transparent until the
content view has actually drawn once since the window was shown.

That's not sufficient on its own, though.  We had disabled Cocoa's automatic
display mechanism for windows and put display on a display-link timer.  This
meant that the window was not actually cleared to its transparent color.  When
the window was shown, the Window Server displayed a white backing buffer.  It
is the app process which should fill that backing buffer with clear color but,
because we had disabled auto-display, that wasn't getting done at the same
time the window was displayed.  It was happening some time after.  Again, the
result was a visible flicker of white.

So, we now temporarily re-enable auto-display just before showing a window.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-09-02 23:31:01 +09:00
Ken Thomases 887db3403e winemac: Call -removeFromSuperview on a view before adding it to a superview, on 10.9 and earlier.
This works around a Cocoa bug that causes an exception and hang if the view is
being re-ordered within its current superview (as opposed to being moved to a
new superview).

This reverts commit 9fbc364ea1 but adds some
conditions around the call to avoid the flicker on platforms where it's
unnecessary.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-07-22 15:31:58 +09:00
Ken Thomases 951a6c0338 winemac: Only call -[NSApplication unhide:] if the app is actually hidden.
This avoids a Cocoa bug where, if an app in the background which is not
hidden calls -unhide:, its main menu bar window is brought forward.  The
active app hasn't actually been changed.  Key events continue to go to
the app in the foreground.  But it's confusing to the user when they
look at the menu bar and, if they click in the menu bar, the background
app really will be activated.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-07-21 16:13:39 +09:00
Ken Thomases cac226200d winemac: Don't define kVK_RightCommand when building against the macOS 10.12 SDK.
Apple added the same enum declaration to their headers, causing a build failure.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-24 12:00:06 +09:00