Commit Graph

402 Commits

Author SHA1 Message Date
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
Ken Thomases dbb0bacf67 winemac: Fix how the user's default display mode is determined.
The code had been checking the kDisplayModeDefaultFlag in the mode's IOFlags,
but that doesn't do what I thought.  That indicates which mode the driver
considers to be the default for the hardware.  It turns out there's no way to
query the user's default mode.

So, at the first opportunity during a given Wine session, the Mac driver
queries the current display mode and assumes that's the user's default mode.
It records that in a volatile registry key for use by subsequent processes
during that same session.

This doesn't use the existing registry key under
HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Video that records the
mode when CDS_UPDATEREGISTRY is used with ChangeDisplaySettingsEx() -- which
explorer.exe does during start-up -- because a) that doesn't support the
distinction between pixel size and point size for Retina modes, and b) in
theory, apps could overwrite that.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-27 21:43:31 +09:00
Ken Thomases 02c6676864 winemac: Reorganize copy_display_modes() to clarify that the user's default mode is always included.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-27 21:43:27 +09:00
Ken Thomases 496b001ae0 winemac: Use a snapshot of an owned window when a zero-sized owner window is minimized.
Some apps create a zero-sized window as their "main" window and then create
all of the other top-level windows as owned windows with that main window as
the owner.  The user interacts with these owned windows.  When the user
attempts to minimize one of these owned windows, the app instead minimizes the
zero-sized owner window.  When an owner window is minimized, all of its owned
windows are hidden.

The Mac driver faithfully carries out these window operations.  The only
visible windows are hidden and the zero-sized window is minimized.  This
results in an invisible animation of the window down to a slot in the Dock -
a slot which appears mostly empty.  The invisible window thumbnail is badged
with the app icon, but it still looks strange.

On Windows, the Alt-Tab switcher uses the image of the owned window to
represent the zero-sized owner.

This commit attempts to do something similar.  It takes over drawing of the
Dock icon for minimized, zero-sized window.  It grabs a snapshot of one of the
owned windows and draws the app badge onto it.  Since the owned windows are
hidden before the zero-sized owner is minimized and we can't take snapshots of
hidden windows, we use heuristics to guess when it may be useful to grab the
snapshot.  If the user minimizes an owned window from the Cocoa side, we grab
that window's snapshot.  If an owned window is being hidden and no snapshot has
been taken recently, we grab its snapshot on the theory that this may be the
beginning of hiding all of the owned windows before minimizing the owner.

Unfortunately, this doesn't address the invisible animations when minimizing
and unminimizing the zero-sized owner window.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-23 19:20:00 +09:00
Ken Thomases 10b95d0dc7 winemac: Remove JPEG 2000 from the bitmap formats that other bitmap formats can be converted to.
Since a983cfb01, the Mac driver won't even present formats, like this one,
which don't correspond to a known Windows format through the clipboard APIs, so
it's pointless.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-08 13:07:52 +09:00
Ken Thomases 9372af77a5 winemac: Queue an event to reassert the WinAPI window position before Cocoa adjusts its position for a display change.
When the display mode changes such that the screen height changes, we'd like
our windows to keep their position relative to the top-left of the primary
screen.  That's how WinAPI's coordinate system works and we want the WinAPI
position of the window to not change just because the display mode changed.

Unfortunately that's not achievable in Cocoa.  Cocoa keeps the window
stationary relative to the screen it's on, not necessarily the primary screen,
and it's sometimes relative to the bottom-left and sometimes the top-left of
that screen.

So, what we do instead is queue an event to get the back end to reassert the
WinAPI position of the window.  This is queued before Cocoa can adjust the
Cocoa position of the window which would queue a WINDOW_FRAME_CHANGED to the
back end and mess up the WinAPI position.  The back end's reassertion of the
WinAPI position won't be processed by the Cocoa thread until after Cocoa has
adjusted the position and will thus override it.  It will also discard any
wrong WINDOW_FRAME_CHANGED that may have been queued.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
2015-10-06 17:21:01 +09:00
Ken Thomases 47708c2635 winemac: Add a new registry setting, OpenGLSurfaceMode, to control how GL surfaces relate to the window.
The default behavior is that GL surfaces are on top of all non-GL content in
the window.  This maximizes the performance for the common case of games, but
clipping by parents, siblings, and child windows isn't respected.

Setting OpenGLSurfaceMode to "behind" pushes the GL surface to be behind the
Mac window.  The window has transparent holes punched through it so that the GL
surface shows through.  USER32 and the wineserver take care of making sure the
holes are only where the GL windows would be unclipped and unoccluded.  Because
the OS X window server has to composite the GL surface with the window, this
limits the framerate.

Since the Mac driver has no server-side rendering path, GDI rendering to a
window which has a GL surface doesn't work.  As a partial workaround, mostly
for cases where a GL surface is created but never used, setting
OpenGLSurfaceMode to "transparent" allows the GDI rendering to show through the
transparent parts of the GL surface.  The GDI rendering is drawn to the
top-level window's surface as normal.  (The behavior of user32 to exclude the
portion covered by a GL window from GDI rendering is disabled.)  The GL surface
is in front of the window but potentially wholly or partially transparent.  It
is composited with the window behind it.

The GL surface is initially cleared to be completely transparent.  So, if
no GL rendering is done, the window will appear as though the GL surface didn't
exist.
2015-09-15 16:59:03 +09:00
Nikolay Sivov 7889b17425 gdi32: Added GetFontRealizationInfo() export. 2015-09-01 19:28:16 +09:00
Ken Thomases 793ab7d457 winemac: Tell Wine when Cocoa brought a clicked window forward even if it sent the click event.
Not sending the brought-forward event for a click that was sent was an artifact
of a time when that branch was only used for posting a request for focus.  When
I added the brought-forward event, I didn't reconsider that logic.
2015-08-13 15:04:35 +09:00
Piotr Caban a90592c8d2 winemac.drv: Release mouse capture when destroying window specified in SetCapture call. 2015-07-17 20:19:51 +09:00
Ken Thomases 0c395c24e3 winemac: Remove extraneous CDECL attribute. 2015-06-05 14:10:12 +09:00
Alexandre Julliard 070a82e743 user32: Merge the AcquireClipboard and EmptyClipboard driver entry points. 2015-06-03 18:46:53 +09:00
Alexandre Julliard b7c340de73 user32: Get rid of the unused parameter in the EmptyClipboard driver entry point. 2015-06-03 18:46:53 +09:00
Ken Thomases eea6ba9ae9 winemac: Don't process WM_EXITSIZEMOVE through filters in macdrv_window_drag_begin(). 2015-05-12 15:31:37 +09:00
Ken Thomases 5bba54505d winemac: Cleanup system tray icons when their owner is destroyed instead of polling. 2015-03-31 14:46:52 +09:00
Ken Thomases 792b47ad3b winemac: Restore a maximized window if a user tries to move it by dragging its title bar.
OS X doesn't have the same concept of maximized windows as Windows does.
There's no mode that prevents a normally-movable window from being moved.  If
a window is "zoomed", it mostly fills the screen but the user can still move
or resize it, at which point it ceases to be in the zoomed state.  So, users
are confused and frustrated when they can't move a window that's maximized.

To get similar behavior while still respecting Win32 semantics, we detect when
the user tries to move a maximized window.  When they start, a request is
submitted to the app to restore the window.  Unless and until the window is
restored, we don't actually allow the window to move.

The user expects to move the window from its current (maximized) position.  It
should not jump to its normal position upon being restored.  So, we set the
window's normal position to its current position before restoring it.
2015-03-24 13:55:34 +09:00
Ken Thomases 8d581d0e48 winemac: Allow the user to attempt to resize a maximized window and try to restore it if they do.
OS X doesn't have the same concept of maximized windows as Windows does.
There's no mode that prevents a normally-resizable window from being resized.
If a window is "zoomed", it mostly fills the screen but the user can still
move or resize it, at which point it ceases to be in the zoomed state.  So,
users are confused and frustrated when they can't resize a window that's
maximized.

To get similar behavior while still respecting Win32 semantics, we now let the
user try to resize maximized windows.  (The resize cursors are shown at the
edges of the window frame.)  When they start, a request is submitted to the app
to restore the window.  Unless and until the window is restored, we don't
actually allow the window to change its size.

The user expects to resize the window from its current (maximized) position.
It should not jump to its normal position upon being restored.  So, we set the
window's normal position to its current position before restoring it.
2015-03-24 13:55:18 +09:00
Ken Thomases 14a0fc3ccc winemac: Prevent maximized windows from entering Cocoa full-screen mode.
OS X doesn't really have the concept of windows being maximized; that is, being
in a mode where they can't be moved or resized.  As a consequence, it doesn't
have a button in the window title bar to restore a maximized window to normal.
So, when a Wine window is maximized, the Mac driver hijacks the green zoom
button to act as a restore button.  (When a window is zoomed, the green button
"unzooms" back to its last user size and position, so it's analogous.)

However, with OS X 10.10 (Yosemite), the green button prefers to act as a
toggle for the Cocoa full-screen mode rather than zooming and unzooming.  This
made it difficult for users to restore a maximized window.  They would have to
Option-click the green button, double-click the title bar, or choose Zoom
from the Window menu, none of which is obvious.

The fix is to disable Cocoa full-screen mode for maximized windows.  Then, the
green button reverts to unzoom and restoring the window.
2015-03-13 21:52:14 +09:00
Ken Thomases 4af5d5bd99 winemac: When exiting Cocoa full-screen mode for a no-longer-eligible window, bypass the override of -toggleFullScreen:.
The override checks the disabled state of the window, but that's for user-
driven changes, not programmatic changes.
2015-03-13 21:52:12 +09:00
Ken Thomases 71b9e02265 winemac: Raise full-screen windows in front of the status items in the Mac menu bar.
Status items are the things on the right end of the Mac menu bar, like the
clock and volume widget.  It turns out that they are displayed at a higher
window level than everything else in the menu bar.  For the case where the
displays are not captured for a full-screen window, the window ends up at the
same window level as the status items, and they would sometimes end up on top.
They would draw over the full-screen window and could be clicked.
2015-02-05 19:57:56 +09:00
Ken Thomases 530a039dac winemac: Prevent interpolation of the window surface image when it's blitted to the actual window.
On high-resolution Retina displays, the OS X window backing store has twice the
pixels as Wine's window backing store.  So, our images get scaled up.  Core
Graphics had been interpolating/smoothing the image, which resulted in
fuzziness.  This tells it not to do that.

I had assumed this wouldn't be necessary since we pass FALSE for the
shouldInterpolate parameter of CGImageCreate() when we create the images.
Apparently, that's not sufficient.
2015-02-03 16:30:55 +09:00
Charles Davis a872c21a48 winemac.drv: Always initialize a closure-captured object pointer. 2015-02-02 22:27:42 +09:00
Ken Thomases 8ec1b4f010 winemac: Tell Wine that Cocoa brought a window forward even if a window is being dragged.
When a window is being dragged, we prevent delivery of clicks to Wine.  We were
also preventing telling Wine that a window had been brought forward, but this
was incorrect.  It prevented clicks in the title bar from activating the window.
2015-02-02 22:27:35 +09:00
Ken Thomases 5fe3c4b89e winemac: Track which window was brought forward by Cocoa separately from the window receiving the click event.
If the mouse is captured, we change which window receives the click event, but
that shouldn't change which window we tell Wine was brought forward by Cocoa.
2015-02-02 22:27:30 +09:00
Ken Thomases 2b97f8c1d1 winemac: When Cocoa brings a window forward, tell Wine even if it's disabled or no-activate.
We can't prevent Cocoa from bringing disabled/no-activate windows forward.  So,
we need to tell Wine about the z-order change.

We still do avoid telling Wine to activate disabled/no-activate windows, though.
2015-02-02 22:27:19 +09:00
Ken Thomases 50cd5b6a57 winemac: Fix conversion of empty RECT to an empty CGRect.
For some empty RECTs, such as { INT_MAX, INT_MAX, INT_MIN, INT_MIN }, right
minus left or bottom minus top underflow and wrap around to positive values.
2015-01-20 11:10:36 +01:00
Matteo Bruni d584651960 winemac: Implement wglCreateContextAttribsARB.
It also allows to create core profile contexts.
2015-01-08 17:29:11 +01:00
Matteo Bruni e23f70b266 winemac: Make the implementation of clearToBlackIfNeeded compatible with core contexts. 2015-01-08 17:29:04 +01:00
Ken Thomases b8da8fa4b1 winemac: Ignore Cocoa child windows which aren't instances of WineWindow.
On Yosemite, in full-screen mode, Cocoa adds child windows of its own to our
windows.  These windows are, of course, not instances of WineWindow.  So, when
we call WineWindow-specific methods on them, it throws exceptions.
2014-12-17 17:08:29 +01:00
Huw Davies bc47d4925a winemac: WS_EX_DLGMODALFRAME shouldn't prevent the window being resizeable. 2014-11-13 18:46:40 +09:00
Ken Thomases d9ed0fb8e5 winemac: Don't allow double-clicks in the content area to zoom the window.
On Yosemite, double-clicking a window's title bar zooms it.  (This is to
compensate for the fact that the zoom button has been replaced by a full-screen
button.)  Sometimes, double-clicking in the content area would count as double-
clicking in the title bar.

This is controlled, in part, by the -mouseDownCanMoveWindow method of the view
that was hit in the window.  The default implementation of that returns YES
for non-opaque views, as the views are in the Mac driver.  Overriding it to
return NO prevents the problem.
2014-10-28 15:25:57 +09:00
Ken Thomases 31d7f61cc3 winemac: Properly ignore attempts to set a window's shape to its current shape.
NSBezierPath doesn't override the -isEqual: method to actually compare paths,
so it just falls back to object identity which, in our case, makes paths seem
like they're never equal.

Also, memcmp()-ing the rectangle array is almost certainly faster than any
general test for equality between two paths.
2014-10-03 08:39:49 +02:00
Ken Thomases 170d80dc90 winemac: Don't invalidate the window shadow on every draw if it's merely shaped and not color-keyed or using per-pixel alpha.
This avoids flickering and tearing on some versions of OS X during frequent
redrawing in a shaped window, such as when scrolling a document in Word 2007.

Since we aren't guaranteed that the window surface has updated bits for us to
draw, we mark the whole content view as needing redisplay and draw the window's
shape in the background color on the first -drawRect: after the shape change.
2014-10-03 08:39:43 +02:00
Ken Thomases 9d1cfecc6d winemac: When removing the status item for a systray icon, discard any associated events in the queue. 2014-08-06 14:27:29 +02:00
Ken Thomases c3d7f5b7ec winemac: Use new API when available to list all display modes available on Retina Macs. 2014-07-30 11:33:00 -05:00
Ken Thomases cafb192ecc winemac: Don't query the position of the one-past-the-end character with IMR_QUERYCHARPOSITION.
This means the resulting rectangle will be short, but we don't have much
choice.  Some apps don't cope properly with the one-past-the-end character.
For example, Excel 2007 gets stuck in an infinite loop.
2014-07-16 20:46:32 +02:00
Aric Stewart 20daa8b61c winemac: Reposition cursor for IME composition.
It is more natural for the cursor to be at the end of the selection
being composed instead of being at the beginning.
2014-05-24 11:02:08 +09:00
Ken Thomases 451915100a winemac: Add the ability to disable high-resolution scrolling.
The Mac driver can generate scroll wheel events with values which are not integral
multiples of WHEEL_DELTA.  Apps should handle that by scrolling a corresponding
non-integral multiple of what they'd do for a WHEEL_DELTA-valued scroll or, if
they can't, then at least accumulate scroll distance until its magnitude exceeds
WHEEL_DELTA and do a "chunky" scroll.  However, many apps don't do that properly.
They may scroll way too far/fast or even in the opposite direction.

If the registry setting UsePreciseScrolling is set to "n", the Mac driver will do
that accumulation and chunking itself to work around such broken app behavior.
2014-05-15 11:28:52 +02:00