Commit Graph

608 Commits

Author SHA1 Message Date
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 b019c918eb winemac: Fix test for simple non-restrictive window region optimization.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-11-27 16:15:25 +01:00
Akihiro Sagawa 4adfb1be29 user32: Send WM_IME_CHAR messages from DefWindowProc.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-11-16 21:48:49 +01:00
Akihiro Sagawa fdd376e514 winemac: Keep the result string in the IME UI window procedure.
This is winemac.drv port from winex11.drv.
Please refer to b8dc1e7cde.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-11-16 21:48:48 +01:00
Alexandre Julliard 5632c82c42 include: Get rid of wglext.h.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-10-11 19:49:29 +02:00
Alexandre Julliard 17dffaac7d opengl32: Get WGL function definitions from the XML files.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-10-10 10:06:10 +02:00
Ken Thomases 611c15953e winemac: Scale cursors for Retina mode, now that user32 scales them with DPI.
When they were always 32x32, treating that size as though it were in Cocoa's
virtual "points" rather than pixels produced good results even though it wasn't
really correct.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-07-31 22:00:33 +02:00
Huw Davies 97546cfbb7 winemac: Use logical co-ords to call GdiAlphaBlend().
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-06-29 19:02:47 +02: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
Piotr Caban 1cd883fcb5 winemac: Don't update clipboard if its content didn't change.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-30 21:49:49 +02:00
Ken Thomases 416180a856 winemac: Fall back to the null driver for common device capabilities.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-22 13:45:08 +02:00
Ken Thomases feb19ee669 winemac: Ignore spurious or redundant notifications that the keyboard input source changed.
In particular, when an input method for an Asian language (e.g. Pinyin) is
selected, we were getting repeated notifications.  Querying the selected input
method upon receiving them suggested that the keyboard layout changed to U.S.
then back to Pinyin, then several redundant notifications with no apparent
change.

Since the handler for the posted KEYBOARD_CHANGED events sends WM_CANCELMODE to
the active window, this was having bad effects.

The spurious notifications can be distinguished by there being no current
text input context or client.  To detect redundant notifications, we track the
last keyboard input source and keyboard layout input source and compare with
the new ones to see if they really changed.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-16 12:08:57 +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
Stefan Dösinger 7003ec34c9 winemac.drv: Implement systray version 1-4 notifications.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-05-11 13:40:14 -05: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
Huw Davies d74348f9b5 winemac: Try to read the dpi from the user key first.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-27 22:22:44 +02:00
Ken Thomases e49feb63f4 winemac: Opt out of macOS 10.12's automatic window tabbing feature.
It doesn't seem to work well.  In full-screen mode, newly-added windows don't
always properly resize to fill the screen, so they're not the same size as the
windows they're nominally tabbed with.  In non-full-screen mode, switching
between tabs sometimes causes the windows to grow in height each time.  Etc.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:32:20 +02: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 af2690ab06 winemac: Add a category on NSEvent to simplify checking if the Command key (and only that modifier) is pressed for an event.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:31:50 +02:00
Ken Thomases 04317b5571 winemac: Move the window to the front of the z-order in SetFocus if it's the foreground window and not already in the front.
Ideally, user32 would adjust its z-order for window activation as happens on
Windows.  Then, the Mac driver would just reflect such changes in the Cocoa
windows.  But user32 doesn't do that.  SetActiveWindow() and SetForegroundWindow()
just adjust focus and status.

This is an attempt to achieve a similar result.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:31:43 +02:00
Ken Thomases 49964b3bc4 winemac: Sync the frame of the Cocoa view for a window's client area while handling a frame-changed event.
Fixes a problem where the client area view would not be resized as the user
resizes the Cocoa window.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-24 20:31:39 +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
Piotr Caban 34b108dd1d user32: Switch to normal window drawing on SetLayeredWindowAttributes call.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-19 20:02:55 +02:00
Ken Thomases 4b8c0d8784 winemac: Send Help key presses directly to the window, bypassing -[NSApplication sendEvent:].
-[NSApplication sendEvent:] seems to consume the event and doesn't pass it along
to the window.

Mac keyboards haven't included a Help key for a long time, but users with PC
keyboards can use the Insert key, which is in the same position.  The Mac
driver translates either one to VK_INSERT.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-04-04 09:42:15 +02:00
Akihiro Sagawa 2680971ef4 winemac.drv: Use neutral language for the version resource.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-03-22 16:13:32 +01: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 02c6e45302 winemac: Pass correct buffer length to RegQueryValueExW().
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-02-08 17:02:59 +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 c95d2de3dd winemac: Ignore clipboard updates provoked by our own call to GetClipboardData().
During a call to GetClipboardData(), the app may be asked to render the data
for a promised format.  This will cause us to receive WM_CLIPBOARDUPDATE.

Almost always, the app will have just rendered the requested format and not
made any other changes.  Therefore, we don't need to rebuild the Mac pasteboard
from the Win32 clipboard.  Doing so can cause a race with the other Mac app
which is querying the pasteboard (for a paste operation, for example).  We
basically delete the data we _just_ added and rebuild the list of available
types.  The symptom is that the other Mac app sees the available types change
and maybe be incomplete.

In theory, the Windows app could make other changes to the clipboard and this
change would cause us to fail to convey them to the Mac pasteboard.  I consider
that very unlikely and the tradeoff to improve the common case is worth it.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-02-03 09:35:18 +01:00
Ken Thomases 2a28e4d843 winemac: Don't set a view's frame if the backend's value hasn't changed.
With windows, the Cocoa main thread may have changed the frame and messages to
that effect may be in the queue, so it can be important to reassert the
"current" value and discard those messages.  With views, by contrast, Cocoa
will never change the frame on its own and there are no messages to discard.

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 af54f956bf winemac: Don't attempt to set surface for child windows in macdrv_WindowPosChanged().
The skipped code is a no-op for the child window case, except that the call to
set_window_surface() synchronizes with the main thread, even with null arguments.

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 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 52e20d82f8 winemac: Ignore an additional expected error in the clipboard pipe communication code.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-13 20:42:06 +01:00
Ken Thomases 961703427d winemac: Export HTML Format clipboard data to the public.html pasteboard type.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-13 20:42:05 +01:00
Ken Thomases ed0de54f45 winemac: Add basic support for importing the public.html pasteboard format.
Continue exporting in the original format under org.winehq.registered.HTML Format
for fidelity when copying and pasting within Wine.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-13 20:41:42 +01:00
Ken Thomases 5f5807cbfe winemac: Periodically check for pasteboard changes using a timer.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-11 19:06:25 +01:00
Ken Thomases 525c0b1795 winemac: Don't update the clipboard if the Mac pasteboard hasn't changed.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-11 19:06:19 +01:00
Ken Thomases 3208d1497a winemac: Change some clipboard functions to void return.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-01-11 19:06:06 +01:00
Aric Stewart 333c5bd9dd ime: Do not send WM_IME_ENDCOMPOSITION on CPS_COMPLETE if there is no composition.
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-14 20:36:16 +01:00
Ken Thomases e5a9055dac winemac: Update the clipboard when the process activates.
If another app grabbed the clipboard, that most likely happened while it was
active and the Wine process was inactive.  Our process being made active again
is a good opportunity to check for that.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-12 19:14:19 +01:00
Lauri Kenttä f447b644a5 winemac.drv: Compare handle to INVALID_HANDLE_VALUE, not NULL.
Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-06 15:02:35 +01:00
Ken Thomases 7161df136f winemac: Keep floating windows in a higher window level than non-floating full-screen windows.
When windows aren't full-screen, non-floating windows go in NSNormalWindowLevel
and floating ones go in NSFloatingWindowLevel, which is higher.  However, a
non-floating full-screen window will go into a level higher than either of
those.  The prior logic of the -adjustWindowLevels: method would keep the
floating windows at a window level at least that high.  They should actually
be in a strictly higher level.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-02 11:43:44 +01:00
Ken Thomases b5194d6f83 winemac: Set the parent of Cocoa views for child windows when they are created.
This fixes an oversight in commit d91e56863.  Some of the views created for
Win32 child windows were being left out of any view hierarchy.  OpenGL contexts
attached to such child windows and views were not able to render to screen,
leaving blank areas.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-12-02 11:43:30 +01:00
Ken Thomases 2a09548b59 winemac: Use min() rather than MIN(), which is not reliably defined.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-26 18:39:14 +02:00
Huw Davies c3dbe44347 winemac: Update the keyboard layout data immediately after changing the input source.
It would eventually get updated by the keyboard changed event, but
only after the message queue was pumped.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 19:42:24 +02: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 e7568d342a winemac: Implement the UpdateClipboard entry point to have the clipboard manager update its status.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:10:15 +02:00
Ken Thomases fa573553bc winemac: Run a single clipboard manager thread per window station, inside the explorer process.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:10:10 +02:00
Ken Thomases 782959168a winemac: Change macdrv_copy_pasteboard_formats() to return a C array instead of a CFArray.
Renamed it to macdrv_get_pasteboard_formats(), since the "copy" was meant to
convey Core Foundation ownership semantics which no longer apply.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:10:06 +02:00
Ken Thomases 019983e2c6 winemac: Reimplement query_pasteboard_data() using the user32 clipboard API.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:09:27 +02:00
Ken Thomases 33b9494ecf winemac: Simplify format_for_type() and callers since there's at most one format for a given Mac pasteboard type.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:09:24 +02:00
Ken Thomases 9cedf37205 winemac: Remove no-longer-called clipboard entry points.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:09:22 +02:00
Ken Thomases 1837210159 winemac: Use GetDIBits to retrieve the bitmap header when exporting a bitmap.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:09:18 +02:00
Ken Thomases 12ea83acb5 winemac: Clamp the number of colors to <= 256 in bitmap_info_size().
… as is done in user32's and gdi32's version of the same function.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:08:34 +02:00
Ken Thomases 8b75e66a5b winemac: Don't export/import CF_TEXT or CF_OEMTEXT to/from Mac-native data types.
The relevant Mac-native types, public.utf16-plain-text and public.utf8-plain-text,
are handled by CF_UNICODETEXT and user32 handles the synthesis of CF_TEXT and
CF_OEMTEXT from that.

CF_TEXT and CF_OEMTEXT are still exported and imported with a Wine-specific
type to preserve cross-prefix copy/paste fidelity.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:06:04 +02:00
Ken Thomases c22590b697 winemac: Don't export/import CF_BITMAP or CF_DIBV5 to/from a Mac-native data type.
The relevant Mac-native type, com.microsoft.bmp, is handled by CF_DIB and
user32 handles the synthesis of CF_BITMAP and CF_DIBV5 from that.

CF_BITMAP and CF_DIBV5 are still exported and imported with a Wine-specific
type to preserve cross-prefix copy/paste fidelity.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:05:51 +02:00
Ken Thomases 40eb776aaa winemac: Remove support for converting among standard clipboard formats.
User32 handles that now.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:05:47 +02:00
Ken Thomases b47183812a winemac: Remove support for owner-displayed clipboard formats.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:02:57 +02:00
Ken Thomases e846da321a winemac: Convert old-Mac-style line breaks (CR) to Windows-style CRLF when importing UTF-16.
At least one Mac app, TextWrangler, puts UTF-16 data on the pasteboard with
lines separated by CR (although it uses LF for the UTF-8 form of the same text).
Other Mac apps handle it properly; we should, too.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:02:52 +02:00
Ken Thomases 861541c5e6 winemac: Allocate clipboard data as GMEM_FIXED.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-24 11:02:42 +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
Hadrien Boizard 5d96ef42a5 winemac.drv: Use EqualRect() instead of memcmp() to compare RECTs.
Signed-off-by: Hadrien Boizard <h.boizard@gmail.com>
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-10-04 20:33:33 +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 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
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