Commit Graph

439 Commits

Author SHA1 Message Date
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 5c5eef8d40 winemac: Trace when a window's per-pixel-alpha setting changes.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-09-02 23:30:52 +09:00
Jacek Caban 8f0557940a winemac.drv: Added ThreadDetach entry point and use it instead of DllMain.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-27 13:24:06 +09:00
Piotr Caban f68e131e88 winemac.drv: Fix setting Cocoa focus when window is shown by other thread.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-25 13:28:08 +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
Piotr Caban a04c393a73 winemac.drv: Don't assume that owner is top-level window in set_cocoa_window_properties.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-07-03 10:23:10 +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
Andrey Gusev 82f3446c5d winemac.drv: Fix a typo in WARN() message.
Signed-off-by: Andrey Gusev <andrey.goosev@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-24 00:07:02 +09:00
Ken Thomases 9fbc364ea1 winemac: Remove an unnecessary call to -[NSView removeFromSuperview].
It's only obliquely documented, but -[NSView addSubview:positioned:relativeTo:]
will remove the view from its old superview if it's changing superviews.  If
it's just changing z-order within its current superview, it won't.

This avoids some flicker of OpenGL surfaces being removed and re-added.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-03 14:39:27 +09:00
Ken Thomases 102cd6dcae winemac: Fix the logic for checking if a view is already in the intended z-order.
-[NSView subviews] returns the views in back-to-front order, not front-to-back
as I had thought.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-03 14:39:25 +09:00
Ken Thomases bdbb3514bb winemac: Use a more idiomatic pattern for an autorelease pool around a loop.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-03 14:39:19 +09:00
Aric Stewart 73bb165ba5 winemac.drv: Correct sizes in COMPOSITIONSTRING structure when updating fields.
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-06-03 12:30:09 +09:00
Ken Thomases 4a76289464 winemac: Adjust sizes of all descendant views when Retina mode changes.
As opposed to just the immediate subviews of the window contentView.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-19 12:00:17 +09:00
Ken Thomases 053b4a81ed winemac: When a child window's client area is equal to its whole area, use a single Cocoa view for both.
This should be a common case and will reduce the number of Cocoa views.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases d91e568635 winemac: Mirror the hierarchy of Win32 child windows with Cocoa views.
This only really affects OpenGL child windows.  GDI rendering to the window
surface is still only blitted to the window's content view.  The descendant
views don't draw and so are transparent, letting the content view show through.

Using Cocoa views for child windows fixes a problem where changes to the
position and visibility of child GL windows didn't properly affect the Cocoa GL
view.  Hiding, showing, and moving the top-level window affected the Cocoa
window and thus, indirectly, the GL view.  Moving the child GL window itself
was propagated to the GL view, so that worked.  But hiding, showing, or moving
any of the intervening ancestors of the child GL window didn't properly affect
the GL view.  Neither did hiding or showing the child GL window itself.

This also slightly improves the clipping of the GL view by its ancestors,
although it still doesn't work quite right due to Cocoa bugs.  There are also
remaining bugs with z-order among multiple GL views and clipping by overlapping
siblings.  I hope to eventually fix those using Core Animation layers, for
which this is a prerequisite.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases 321a1511da winemac: Extract some logic into a new function, sync_window_z_order().
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases 225482f5ad winemac: Make show_window() and hide_window() tolerate being called when there's no Cocoa window.
Minor no-op refactoring that makes subsequent commits cleaner.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases eef99122f7 winemac: Change macdrv_create_view() to not add the new view to a window's content view.
Callers can use macdrv_set_view_superview() to do that separately.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases ca49b8070c winemac: Create views hidden initially and add macdrv_set_view_hidden() to change that.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:54 +09:00
Ken Thomases 587bdb8db7 winemac: Change macdrv_set_view_window_and_frame() to macdrv_set_view_frame().
Remove the no-longer-used functionality of potentially moving the view from one
window to another.  That has been taken over by macdrv_set_view_superview().

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:53 +09:00
Ken Thomases 8223756ba4 winemac: Add function macdrv_set_view_superview().
This allows for nesting views in a hierarchy rather than only ever adding them
as direct subviews of the window content view.  This functionality will be used
in subsequent commits.

This takes over some of the functionality of macdrv_set_view_window_and_frame(),
which will be removed in a subsequent commit.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:53 +09:00
Ken Thomases 742734b44f winemac: Remove the assumption that OpenGL views are always immediate subviews of the window content view.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-14 14:39:53 +09:00
Ken Thomases 1c94bf396f winemac: Add support for a high-resolution ("Retina") rendering mode.
When this Retina mode is enabled and the primary display is in the user's
default configuration, Wine gets told that screen and window sizes and mouse
coordinates are twice what Cocoa reports them as in its virtual coordinate
system ("points").  The Windows apps then renders at that high resolution and
the Mac driver blits it to screen.  If the screen is actually a Retina display
in a high-DPI mode, then this extra detail will be preserved.  Otherwise, the
rendering will be downsampled and blurry.

This is intended to be combined with increasing the Windows DPI, as via winecfg.
If that is doubled to 192, then, in theory, graphical elements will remain the
same visual size on screen but be rendered with finer detail.  Unfortunately,
many Windows programs don't correctly handle non-standard DPI so the results
are not always perfect.

The registry setting to enable Retina mode is:

[HKEY_CURRENT_USER\Software\Wine\Mac Driver]
"RetinaMode"="y"

Note that this setting is not looked for in the AppDefaults\<exe name> key
because it doesn't make sense for only some processes in a Wine session to see
the high-resolution sizes and coordinates.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-06 11:45:24 +09:00
Ken Thomases 3d73f62f01 winemac: Use floor() rather than truncation when converting Cocoa event positions to integers.
This is so negative coordinates are adjusted in the same direction as
positive ones (left and up).

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-05 13:18:39 +09:00
Charles Davis 1dcf51f0fc winemac.drv: Move create_bitmap_from_dib() above the import/export functions.
Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-05 01:27:52 +09:00
Ken Thomases 1df961bd3d winemac: Implement the WGL_WINE_query_renderer extension.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-04 01:03:28 +09:00
Charles Davis 9a18a62fb2 winemac.drv: Fix our handling of bitmaps on the clipboard.
Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-03-02 23:27:26 +09:00
Charles Davis 1eeec9513c Revert "winemac.drv: Actually make the GL context current even if no drawables were given.".
This reverts commits 38f579f9ba and
02416314ab.

No extant application uses this, nor are the wined3d maintainers
interested in using it.

Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-03-01 01:50:06 +09:00
Ken Thomases 38f579f9ba winemac: Simplify and optimize making a GL context current with no view.
If the context is already current, don't do +clearCurrentContext followed by
-makeCurrentContext.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-23 20:22:21 +09:00
Charles Davis 02416314ab winemac.drv: Actually make the GL context current even if no drawables were given.
The spec for GL_ARB_framebuffer_object (and thus, OpenGL 3.x and up) is
quite clear on what happens when a context is made current with no
drawable(s). In fact, the WGL_ARB_create_context extension amends
WGL_ARB_make_current_read (as well as the base spec for wglMakeCurrent)
specifically to allow this.

Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-19 11:19:00 +09:00
Charles Davis d2f7becc0f winemac.drv: Don't print 32-bit values as long integers (Clang).
Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-19 11:05:31 +09:00
Ken Thomases e5c120893d winemac: Wrap performing requests from background threads in an autorelease pool.
Cocoa manages an autorelease pool on the main thread, but it only drains it
when it processes an event.  Our requests come through a run loop source, which
doesn't count as an event.  So, autoreleased objects can accumulate when the
app is not being interacted with.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-18 21:05:49 +09:00
Charles Davis d8eac06940 winemac.drv: Don't bother storing the OpenGL version.
Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-16 12:01:57 +09:00
Ken Thomases 33610da6b4 winemac: Don't process QUERY_IME_CHAR_RECT while waiting in OnMainThread().
Most queries are handled even by threads which are otherwise blocked in
OnMainThread().  There's a problem with QUERY_IME_CHAR_RECT, though, in that it
can be handled before a previously-queued IM_SET_TEXT event, in which case its
character range may be out of bounds.  Some apps (e.g. Excel 2007) hang due to
the bad range.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-05 13:53:36 +09:00
Ken Thomases a1a93ce193 winemac: Change the processEvents parameter of -[WineEventQueue query:timeout:processEvents:] to a flags bitmask.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-05 13:53:22 +09:00
Ken Thomases 3482c47469 winemac: Make macdrv_process_text_input() asynchronous and process internal events while awaiting its result.
It had been using the synchronous OnMainThread() to submit its work to the
Cocoa thread, but only queries are processed while OnMainThread() waits for the
work to complete.  This led to QUERY_IME_CHAR_RECT queries being processed out
of order relative to IM_SET_TEXT events, making the character range out of
bounds with respect to the composition string.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-02-05 13:53:13 +09:00
Ken Thomases 5c992f9653 winemac: Don't post a WINDOW_BROUGHT_FORWARD event for a click on a window which is already frontmost in its level.
Commit 793ab7d45 fixed a bug where WINDOW_BROUGHT_FORWARD events weren't being
posted when they should, but it caused a regression in Scribblenauts Unlimited.
Every click caused a window ordering operation that generated messages and
Scribblenauts would move the mouse cursor to the upper-left corner of the
window in response.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-12-01 12:44:19 +09:00
Ken Thomases ebcf8aadc5 winemac: Remove a window from the NSWorkspace notification center when it's deallocated.
It was added as an observer in commit 3beec95a0.  Failing to remove it caused
the notification center to have a dangling pointer and caused crashes and hangs.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-12-01 12:44:10 +09:00
Sebastian Lackner 0ef9d775f0 winemac.drv: Fix specfile entry for ImeGetRegisterWordStyle.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-29 12:46:28 +09:00
Ken Thomases 66fc13197b winemac: Use the display unit number rather than display ID for the initial display mode registry key.
On Macs with dual GPUs that automatically switch, the display ID is not stable.
It changes when the active GPU changes.  The resulted in the lookup of the
initial display mode failing and games not being able to restore it properly.

The display unit number should be more reliable, although still not perfect.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-17 22:56:40 +09:00
Ken Thomases d8deecab11 winemac: Enable localization of strings used to build Mac menus.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-17 22:56:39 +09:00
Ken Thomases 1aae516a49 winemac: Add resource file.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-17 22:56:39 +09:00
Ken Thomases 682820d3cb winemac: Fix a crash on versions of OS X prior to 10.9 which don't have the -[NSImage drawInRect:] method.
[image drawInRect:rect] is documented as being "exactly equivalent to calling
[image drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver
fraction:1 respectFlipped:YES hints:nil]".  So, that's what I replace it with.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-10 18:29:27 +09:00
Ken Thomases b4fc81bdf2 winemac: Stop the CVDisplayLink when there are no more changes to flush.
The change to a CVDisplayLink-driven display mechanism introduced a problem: a
Wine process never went completely idle for long periods.  The display link
would fire for every refresh cycle of the display, waking a CPU from idle and
wasting energy.

To fix that, I have the display link stop itself when it determines that none
of its windows need to be displayed.  When a window is subsequently marked as
needing display, it either temporarily re-enables Cocoa's normal autodisplay
mechanism so that it displays at the end of the current turn of the run loop,
or it restarts the display link.  It chooses the former if it's been a long
time since the window was last displayed so that the display is done more
immediately.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-10 11:58:42 +09:00
Ken Thomases d6574111c2 winemac: Check the window's display link after adding it as a child of another window, which may order it on screen.
This fixes a problem where child windows ("owned" windows in Windows
parlance) would never display their contents on OS X 10.8 or earlier.
Beginning with 10.9, Cocoa calls -windowDidChangeOcclusionState: when
the window becomes visible, which is why they display on that version
and later.

Reported by Huw Davies.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-10 11:58:36 +09:00
Ken Thomases bb44de787d winemac: Remove the live-resize display timer.
It's redundant with the new CVDisplayLink-driven display mechanism.

This reverts commits d55d2ec85 and 94dc91a45.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-06 23:20:35 +09:00
Ken Thomases 3beec95a09 winemac: Use CVDisplayLink to limit window redrawing to the display refresh rate.
Some Windows apps cause user32 to flush the window surface much faster than the
display refresh rate.  The Mac driver only marks its window as needing to be
redrawn and lets Cocoa decide how often to actually redraw.  Unfortunately,
Cocoa redraws each time through the run loop and, since the Mac driver uses a
run loop source to convey messages from background threads to the main thread,
it redraws after every batch of messages.

On some versions of OS X, this excessive drawing provokes synchronization with
the window server's buffer swaps, preventing the main thread from being
responsive.  Even when that doesn't happen, it's wasteful.

So, we set our windows' autodisplay property to false so that Cocoa never
displays windows itself.  Then, we arrange to call -displayIfNeeded once per
display refresh cycle using a CVDisplayLink.  We maintain one CVDisplayLink per
display (on demand), move windows among them as the windows change screens,
start them when they acquire their first window, and stop them when they have
none left.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-06 23:20:29 +09:00
Ken Thomases 4db8fc394d winemac: Cope with multiple seemingly-identical display modes, only some of which work, by trying them in sequence.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-11-03 13:48:11 +09:00
Ken Thomases 9d6a14305a winemac: Add another workaround for bad side effects of CGWarpMouseCursorPosition().
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-29 10:55:16 +09:00