{"action":"created","issue":{"url":"https://api.github.com/repos/SFML/SFML/issues/614","labels_url":"https://api.github.com/repos/SFML/SFML/issues/614/labels{/name}","comments_url":"https://api.github.com/repos/SFML/SFML/issues/614/comments","events_url":"https://api.github.com/repos/SFML/SFML/issues/614/events","html_url":"https://github.com/SFML/SFML/pull/614","id":34274773,"number":614,"title":"Feature/grab mouse","user":{"login":"mantognini","id":693483,"avatar_url":"https://avatars.githubusercontent.com/u/693483?v=3","gravatar_id":"","url":"https://api.github.com/users/mantognini","html_url":"https://github.com/mantognini","followers_url":"https://api.github.com/users/mantognini/followers","following_url":"https://api.github.com/users/mantognini/following{/other_user}","gists_url":"https://api.github.com/users/mantognini/gists{/gist_id}","starred_url":"https://api.github.com/users/mantognini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantognini/subscriptions","organizations_url":"https://api.github.com/users/mantognini/orgs","repos_url":"https://api.github.com/users/mantognini/repos","events_url":"https://api.github.com/users/mantognini/events{/privacy}","received_events_url":"https://api.github.com/users/mantognini/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SFML/SFML/labels/feature","name":"feature","color":"23BA35"},{"url":"https://api.github.com/repos/SFML/SFML/labels/m:sfml-window","name":"m:sfml-window","color":"cccccc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":46,"created_at":"2014-05-25T22:57:38Z","updated_at":"2016-01-14T21:07:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SFML/SFML/pulls/614","html_url":"https://github.com/SFML/SFML/pull/614","diff_url":"https://github.com/SFML/SFML/pull/614.diff","patch_url":"https://github.com/SFML/SFML/pull/614.patch"},"body":"Related to #394.\r\n\r\nAdds `sf::Window::setCursorGrabbed` implementations for Linux, Windows and Mac OS X. Android and iOS devices have a «not applicable» implementation.\r\n\r\n**Requires testing on:**\r\n- Linux\r\n- Windows\r\n- iOS (build check only)\r\n- Android (build check only)\r\n\r\nHere are a few scenarios to be tested:\r\n\r\n1. Grabbing the cursor works when the window has the focus.\r\n2. When grabbed, the cursor should not be able to leave the window.\r\n3. Closing the window should release the cursor.\r\n4. When grabbed, the window should not be resizable by dragging one of its sides.\r\n5. When switching to another app, the cursor should be released and re-grabbed when reactivating the SFML app.\r\n6. If the cursor is outside the view when it is grabbed the cursor should be projected into the window (and thus generate a mouse in event).\r\n7. The user should not be able to move fast the cursor and click outside the window to activate another application.\r\n8. The user should not be able to use the window bar to move, minimize, maximize or close the window.\r\n\r\n[This code](https://gist.github.com/mantognini/20226256cbac2b138db0) can be usefull for testing.\r\n\r\n**Regarding OS X:**\r\nThe current impl is not bad but still an approximation of the feature (test n° 7 is somewhat supported and n° 8 is not supported at all) . It seems really hard to do it on Mac. Other libs (e.g. SDL) have even more bugs or undesired behaviour than this implementation. However, a lot of tricks are used which is not nice at all for future modifications of `SFOpenGLView` (among other things).\r\n\r\nCommit d16d38e contains a more detailed explanation of the known issues (in commit message and comments in the code itself). I'm reluctant to include this commit in SFML codebase because it will considerably increase the complexity of the code and make it really hard to maintain. All that to \"only\" workaround a stupid corner case... Please let me know what you think.\r\n\r\nAn alternative for games that need grabbing would be to hide the cursor and use relative motion, preventing the cursor to actually move. This would involve much fewer corner cases in the implementations. Actually, SDL also provides this alternative."},"comment":{"url":"https://api.github.com/repos/SFML/SFML/issues/comments/171780081","html_url":"https://github.com/SFML/SFML/pull/614#issuecomment-171780081","issue_url":"https://api.github.com/repos/SFML/SFML/issues/614","id":171780081,"user":{"login":"Bromeon","id":708488,"avatar_url":"https://avatars.githubusercontent.com/u/708488?v=3","gravatar_id":"","url":"https://api.github.com/users/Bromeon","html_url":"https://github.com/Bromeon","followers_url":"https://api.github.com/users/Bromeon/followers","following_url":"https://api.github.com/users/Bromeon/following{/other_user}","gists_url":"https://api.github.com/users/Bromeon/gists{/gist_id}","starred_url":"https://api.github.com/users/Bromeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bromeon/subscriptions","organizations_url":"https://api.github.com/users/Bromeon/orgs","repos_url":"https://api.github.com/users/Bromeon/repos","events_url":"https://api.github.com/users/Bromeon/events{/privacy}","received_events_url":"https://api.github.com/users/Bromeon/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T21:07:53Z","updated_at":"2016-01-14T21:07:53Z","body":"So it seems like we need both for total flexibility? Since we almost have an implementation for mouse grabbing, let's continue with that now :wink:\r\n\r\nAre there changes planned for Windows? Otherwise I could test it. About the OS X implementation, as I said, maybe we could go with the simpler one and think about the imperfect workaround when the need actually arises."}}