Commit Graph

87 Commits

Author SHA1 Message Date
Ken Thomases 70c4f43ed3 winemac: Ignore mouse capture during window drags for routing click and move events. 2014-01-29 12:38:52 +01:00
Ken Thomases ce5a87b1ef winemac: Simplify display mode code.
When originalDisplayModes has entries, the app is active.  When the app is
active, latentDisplayModes is empty.
2014-01-10 12:05:41 +01:00
Ken Thomases d4d92a759e winemac: Clear the latentDisplayModes instance variable before realizing the latent modes. 2014-01-10 12:05:38 +01:00
Ken Thomases 42a7d7209b winemac: Restore display mode to original in more cases.
We only care if we have changed the mode and we're changing it back to its
original.  Even if the current mode matches the target mode, we may still
need to release the displays and clear the entry from originalDisplayModes.
2014-01-10 12:05:34 +01:00
Ken Thomases 9c65d672a2 winemac: Don't assume the current display mode is the original if we don't have the displays captured.
Another process may have changed the display mode before we queried the
current mode, so we may be seeing a non-original mode.
2014-01-10 12:05:30 +01:00
Ken Thomases fe1c0ab952 winemac: Don't record original display modes when not the active app.
originalDisplayModes should be used when active, empty when inactive.
latentDisplayModes is used when inactive, empty when active.

The count of entries in originalDisplayModes is used to test whether the
process has the displays captured so adding entries when inactive would give
incorrect results.  This could have led us to mistakenly change the display
mode when we don't have the displays captured.
2014-01-10 12:05:25 +01:00
Ken Thomases 4f9de6bcdf winemac: More thoroughly discard events which have been obsoleted by subsequent Wine- or program-driven changes.
Among other things, this fixes Syberia 2.  That game shows, hides, and then
shows its window.  Hiding it caused a WINDOW_LOST_FOCUS event to be queued.
By the time it was processed, the window was the foreground window again.
In response to being told it had lost focus, the game minimized its window.

Hiding the window should have prevented or discarded the WINDOW_LOST_FOCUS
event since the change was driven from Wine and the Win32 foreground/active
window state would already be correct.  In addition, when the program
re-showed its window and made it foreground, that should have discarded the
event as being out of date.  Now they do.
2013-12-31 12:31:39 +01:00
Ken Thomases 6447e8e75c winemac: Defer adjusting window levels while the process is hidden.
While the process is hidden, it can't get a list of its windows which would
be visible were it not hidden.
2013-12-31 12:31:15 +01:00
Ken Thomases 77f0a63b4f winemac: When ClipCursor() is called redundantly, don't warp the cursor or discard mouse move events.
Fixes a problem in some games which repeatedly (re)establish the same cursor
clipping rect, making it exceedingly difficult to move the camera with the
mouse.
2013-12-17 16:53:44 +01:00
Ken Thomases f068e329c1 winemac: Send WM_{ENTER, EXIT}SIZEMOVE before/after window dragging and run an internal event loop during.
This simulates some of what would happen if user32 were managing the drag.  The
click in the caption would cause WM_SYSCOMMAND/SC_MOVE.  The processing of that
message is synchronous and doesn't return until the move is complete.

Some games require that "blocking" in the internal event loop to prevent them
from misbehaving during the drag.
2013-12-12 12:06:47 +01:00
Ken Thomases b3cc34e5b0 winemac: While a window is being dragged, suppress mouse events and disable cursor clipping and warping. 2013-12-12 12:06:39 +01:00
Ken Thomases cd10a0df5e winemac: Consolidate the logic for deciding if cursor clipping should be active. 2013-12-12 12:06:38 +01:00
Huw Davies c4761d8002 winemac: Actually set the system's keyboard layout. 2013-11-20 19:39:05 +01:00
Huw Davies 22008f7fd9 winemac: Update the thread's active_keyboard_layout on keyboard change. 2013-11-20 19:39:01 +01:00
Huw Davies f344d7a213 winemac: Update the layout list if the enabled input sources change. 2013-11-20 19:38:59 +01:00
Huw Davies fecaab9cfd winemac: Implement GetKeyboardLayoutList. 2013-11-20 19:38:56 +01:00
Ken Thomases 6b9f81271b winemac: Hide cursor when first requested even if we don't know it's over a window.
The tracking of whether it is over a window or not is only updated when the
mouse moves.  If a window was created or moved under it, then the state can be
stale.  That caused us to defer hiding the cursor until the mouse was moved.
This happens at the start of games pretty often.
2013-10-30 15:29:42 +01:00
Ken Thomases 1c049e5031 winemac: Restore app cursor settings when cursor moves back into an app window.
The code had previously set the cursor back to the standard arrow and unhid
it when it left all app windows.  Now it restores the cursor image that the
app set and re-hides it if necessary when it moves back over any app window.
2013-10-18 11:33:32 +02:00
Ken Thomases 8747df094d winemac: Treat mouse moves in a window title bar as outside the window.
Don't queue mouse-moved events.  Reset the cursor.
2013-10-18 11:32:53 +02:00
Ken Thomases f4f50c9e4a winemac: Implement support for Cocoa-style full-screen mode.
Based in large part on a patch submitted by Kevin Eaves.
2013-10-11 11:04:53 +02:00
Ken Thomases c043587d56 winemac: Tell Wine when Cocoa has brought a window to the front. 2013-10-08 15:39:01 +02:00
Ken Thomases 1186c36c89 winemac: Make clicking on the app's dock icon unminimize a window if there are only minimized windows.
Cocoa would automatically do this for a normal app.  However, the Mac driver
makes all of its windows inherit from NSPanel and Cocoa ignores panels for
this feature.
2013-10-04 12:45:56 +02:00
Ken Thomases b7709771d1 winemac: Reapply display modes when switching back to app after "escaping" with Command-Tab.
The Mac driver captures the displays when the program changes the display
mode.  If the user types Command-Tab to switch away, it resets the displays
to their original modes and releases them.  However, if they switched back,
it didn't restore the mode to what the program had set, so the program often
showed the game window in a corner of the screen with the top behind the Mac
menu bar.
2013-10-02 11:00:36 +02:00
Ken Thomases 7c55e912da winemac: Remove a too-early attempt to set the process's Dock icon. 2013-10-01 23:05:08 +02:00
Ken Thomases d7f4d67514 winemac: Fix hiding windows that are minimized using -close instead of -orderOut:.
Cocoa won't order a minimized window out of the screen list using -orderOut:.
This leaves a window that should be hidden still visible in the Dock, where
it can be unminimized.
2013-09-27 10:39:13 +02:00
Ken Thomases 018d629b3c winemac: Use NSMouseInRect() instead of NSPointInRect() to compensate for Cocoa's off-by-one coordinate system.
This matches what Cocoa does when determining how to handle an event so that,
for example, our test if a click is in the window grow box corresponds to
whether Cocoa will run an internal mouse-tracking loop to resize the window
when we pass it the event.  This fixes a problem where both Cocoa and user32
would try to run a resize loop and the cursor would get "stuck" resizing the
window after the button was released.
2013-09-19 09:30:18 +02:00
Ken Thomases b550ee8d59 winemac: On click, don't reorder Cocoa child window after siblings of higher level.
It may be necessary to reorder to some extent because the clicked window is
behind a sibling at the same level, but that shouldn't move it later in the
list than higher-level siblings.

Cocoa gets buggy if the list of child windows isn't in z-order.
2013-08-30 11:18:07 +02:00
Ken Thomases d14f787192 winemac: Don't reorder clicked window relative to sibling owned windows if it's in the right place.
The right place may not be the end of the list of Cocoa child windows if some
of the siblings are at a higher window level (i.e. floating if the clicked
window is not).
2013-08-30 11:17:56 +02:00
Ken Thomases a39b02c3e7 winemac: Dispatch key-up events directly to window to be sure to get them.
For keys pressed in combination with Command, -[NSApplication sendEvent:]
simply doesn't pass the key-up event through to the window.  We have to
track which keys we've told Wine are pressed because Cocoa may consume
key-downs that trigger menus or system behaviors.
2013-07-09 10:30:45 +02:00
Ken Thomases a723af61ac Revert "winemac: Dispatch key events directly to window to be sure to get key-up events.".
This reverts commit 0d20ac02f7.
2013-07-09 10:30:43 +02:00
Ken Thomases 0d20ac02f7 winemac: Dispatch key events directly to window to be sure to get key-up events.
For keys pressed in combination with Command, -[NSApplication sendEvent:]
simply doesn't pass the key-up event through to the window.
2013-06-28 11:40:41 +02:00
Ken Thomases 153f3e27c4 winemac: Forcibly release mouse capture for clicks in Mac menu bar or app deactivation. 2013-06-20 11:31:25 +02:00
Ken Thomases f035cc73d0 winemac: Don't give windows focus on click if the click was sent to Wine.
Only clicks on the title bar (outside the close or minimize buttons) or the
grow box give windows focus.
2013-06-18 12:57:44 +02:00
Ken Thomases 3faf1a92b0 winemac: Don't bring disabled or no-activate windows forward when clicked. 2013-06-18 12:57:43 +02:00
Ken Thomases d22ac28f5e winemac: Allow clicks on owned windows to reorder them relative to other owned windows of the same owner. 2013-06-07 11:59:02 +02:00
Ken Thomases 220b8b7946 winemac: Add an option to capture the displays for full-screen windows in addition to display mode changes.
Under HKCU\Software\Wine\Mac Driver, set string value
CaptureDisplaysForFullscreen to "y" to enable the new behavior.
2013-06-07 11:57:06 +02:00
Ken Thomases 4c651e39e4 winemac: Don't unminimize a window on first activation during start-up. 2013-06-04 15:00:28 +02:00
Ken Thomases d8269a0586 winemac: Add Hide, Hide Others, and Show All items to the application menu. 2013-05-29 19:49:42 +02:00
Ken Thomases 27510fae8e winemac: Centralize adjusting of window levels using the window server's z-order. 2013-05-17 16:36:24 +02:00
Ken Thomases 0d4a26eff5 winemac: Use window server's window list to find next window to offer focus to.
... rather than our orderedWineWindows array, which is going away.
2013-05-17 16:35:54 +02:00
Ken Thomases c3183fc007 winemac: Implement simpler way to find front Wine window.
This uses Cocoa and the window server to track windows and their z-order,
which is more reliable than our own tracking.
2013-05-17 16:35:27 +02:00
Ken Thomases 08e940fb1d winemac: Unminimize a window on activation if there are only minimized windows. 2013-05-08 19:35:04 +02:00
Ken Thomases 1a697e15b9 winemac: Implement SetCapture(). 2013-05-07 11:20:32 +02:00
Ken Thomases 3eee56668a winemac: Mouse drags don't imply anything about z-order of target window because of implicit capture. 2013-05-07 11:20:11 +02:00
Ken Thomases 3e3d982185 winemac: Prefer absolute mouse moves unless cursor is pinned by clipping or desktop edges.
This fixes an issue with sub-pixel-precise pointing devices on Lion and later.
Wine's notion of the cursor position would get out of sync with the actual position
because deltas don't convey the actual movement distance.
2013-05-07 11:19:43 +02:00
Ken Thomases 1c4d8938ec winemac: Apply cursor clipping to events that were in Cocoa's queue when clipping started. 2013-05-07 11:19:37 +02:00
Ken Thomases d9ae2f3e38 winemac: Consolidate scroll wheel handling into -[WineApplicationController handleScrollWheel:]. 2013-05-07 11:19:33 +02:00
Ken Thomases e15b82ad1b winemac: Consolidate mouse button handling into -[WineApplicationController handleMouseButton:]. 2013-05-07 11:19:27 +02:00
Ken Thomases 72e893237c winemac: Consolidate mouse move handling into -[WineApplicationController handleMouseMove:]. 2013-05-07 11:19:21 +02:00
Ken Thomases 76691853f5 winemac: Extract application-level handling of mouse move events to a separate method. 2013-05-07 11:19:00 +02:00