src/video/cocoa/SDL_cocoawindow.m


Log

Author Commit Date CI Message
Sam Lantinga 5e501804 2014-08-17T14:57:52 Fixed bug 2655 - OSX: Window position and global mouse coord spaces are different Tim McDaniel On OSX, with revision 8729, the coordinate space for window position and the coordinate space for global mouse position don't match. For a non-fullscreen window, the window position is global relative to the bottom of the menubar. The global mouse position is relative to the top of the screen. This affects Cocoa_WarpMouse and potentially other things as well. Further, the coordinate system for window position is now affected by what screen it is on. For example, if I have two equal size screens oriented side by side such that the tops of the screens are equal in global space, with the menubar on one screen, and a window straddles the two screens, the window's y position makes no sense. The window's y position depends on what screen "most" of the window is on. So if I move the window horizontally just a bit, the y position of my window is now different by the size of the menubar, even though the window was not moved vertically. I'd like to reiterate that this was a fairly fundamental change (and a breaking change for us). If SDL OSX is to really support multi-display configurations, this is especially problematic. If the real concern is preventing windows from going under the menubar, then perhaps a solution involving something like overriding [NSWindow constrainFrameRect] would be less problematic than redefining the global window coord space for the main display.
Alfred Reynolds 87b8c8d1 2014-07-31T12:46:23 SDL - when raising the window under OSX also force the app to activate. This fixes a fullscreen window on a separate space not coming front when raisewindow is called.
Sam Lantinga fc4e798d 2014-07-07T12:48:25 Fixed bug 2631 - Mac: minor code cleanup Alex Szpakowski Some minor changes to the Mac-specific backend code: - Fixed up some code style issues (mostly brace style inconsistencies). - Fixed a compiler warning in SDL_cocoaevents.m. - Removed some useless code now that the 10.7 SDK is required to build SDL. - Removed Gestalt(gestaltSystemVersion, ...) call and switched to NSAppKitVersionNumber for version checking code. Using Gestalt with gestaltSystemVersion will give 0x1090 in Mac OS 10.10+, and the whole Gestalt function was deprecated in Mac OS 10.8.
Sam Lantinga d44f3922 2014-07-07T10:33:32 Fixed bug 2629 - Mac: crash when calling SDL_DestroyWindow with an active OpenGL context Alex Szpakowski Since this commit https://hg.libsdl.org/SDL/rev/59b543340d63 , calling SDL_DestroyWindow will crash the program if the window has an active OpenGL context. This is because the Cocoa_DestroyWindow code sets the window's driverdata to NULL and then calls [context setWindow:NULL], which tries to access the window's driverdata, resulting in a null pointer dereference. I have attached a patch which fixes the issue by moving the line which sets the driverdata to NULL to after the lines which call functions that use the driverdata pointer.
Ryan C. Gordon b29740b8 2014-06-25T17:06:12 Merged Ryan's SDL-gui-backend branch. Adds three APIs, and implements them on X11, Cocoa, and Windows: - SDL_CaptureMouse() - SDL_GetGlobalMouseState() - SDL_SetWindowHitTest()
Sam Lantinga 704d9bd3 2014-06-25T02:08:37 Fixed bug 2525 - Keyboard focus crash Todd Seiler Call Stack: #0 0x0000000101c29291 in Cocoa_StartTextInput at /Users/Todd/Desktop/codes/sources/SDL/src/video/cocoa/SDL_cocoakeyboard.m:512 #1 0x0000000101c110c5 in SDL_SetKeyboardFocus at /Users/Todd/Desktop/codes/sources/SDL/src/events/SDL_keyboard.c:643 #2 0x0000000101c32be4 in SetupWindowData at /Users/Todd/Desktop/codes/sources/SDL/src/video/cocoa/SDL_cocoawindow.m:981 #3 0x0000000101c32d2a in Cocoa_CreateWindowFrom at /Users/Todd/Desktop/codes/sources/SDL/src/video/cocoa/SDL_cocoawindow.m:1092 #4 0x0000000101c99999 in SDL_CreateWindowFrom_REAL at /Users/Todd/Desktop/codes/sources/SDL/src/video/SDL_video.c:1338 #5 0x0000000101ce1484 in SDL_CreateWindowFrom at /Users/Todd/Desktop/codes/sources/SDL/src/dynapi/SDL_dynapi_procs.h:547 #6 0x0000000100018a5e in SceneRenderer at /Users/Todd/Desktop/codes/sources/tseiler_Todds-MacBook-Pro_3405/AppName/src/SceneRenderer.cpp:138 #7 0x0000000100017ca5 in SceneRenderer at /Users/Todd/Desktop/codes/sources/tseiler_Todds-MacBook-Pro_3405/AppName/src/SceneRenderer.cpp:145 #8 0x000000010000cd96 in App::execute(int, char**) at /Users/Todd/Desktop/codes/sources/tseiler_Todds-MacBook-Pro_3405/AppName/src/App.cpp:28 #9 0x0000000100004402 in main at /Users/Todd/Desktop/codes/sources/tseiler_Todds-MacBook-Pro_3405/AppName/src/main.cpp:8 This issue occurred when using Ogre3D Graphics engine on Mac (cocoa) to create the window. Then handing the window handle off to SDL_CreateWindowFrom(). In Ogre3D application you do the following: window_ = root_->initialise(true, "Ogre Window 2"); loadOgreResources(); Ogre::WindowEventUtilities::addWindowEventListener(window_, this); #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE NSWindow* Data = 0; window_->getCustomAttribute("WINDOW", &Data); sdl_window_ = SDL_CreateWindowFrom((void*)Data); #endif It results in a crash in this function: SDL_cocoakeyboard.m void Cocoa_StartTextInput(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SDL_Window *window = SDL_GetKeyboardFocus(); NSWindow *nswindow = nil; if (window) nswindow = ((SDL_WindowData*)window->driverdata)->nswindow; // ... } The crash occurred because "driverdata" was nil. Before this function call, a call to SetupWindowData is called: SDL_cocoawindow.m static int SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created) { // ... if ([nswindow isKeyWindow]) { window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_SetKeyboardFocus(data->window); } /* Prevents the window's "window device" from being destroyed when it is * hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html */ [nswindow setOneShot:NO]; /* All done! */ [pool release]; window->driverdata = data; return 0; } As you can see: "window->driverdata = data" is performed after the "SDL_SetKeyboardFocus()" call, which eventually leads to "Cocoa_StartTextInput()" where the crash occurs.
Sam Lantinga b7b6d8ab 2014-06-22T02:30:36 Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
Sam Lantinga 65133ebc 2014-06-04T09:39:08 Wait for the fullscreen transition to complete before allowing the application to continue. This fixes Alt-Enter in the Steam streaming client, which sets the window size and position immediately after switching out of fullscreen mode.
Sam Lantinga 16360b19 2014-06-04T01:56:14 Fixed escape cancelling fullscreen mode now that the SDL window is the first res ponder.
Sam Lantinga a8fcbc46 2014-06-02T09:09:40 Fixed bug 2534 - Mac: black bar at top of screen in SDL_WINDOW_FULLSCREEN mode Alex Szpakowski Patch to fix the y component of the position of fullscreen windows in OS X. In Mac OS X with the latest Mercurial code, when a window is in exclusive-fullscreen the y component of its position is offset by the same amount that is normally taken up by the menubar, resulting in a black bar at the top of the screen. The recent changes to the internal ConvertNSRect function make it treat the bottom of the menubar as 0 for the y component of window positions, even when the window is fullscreen and 'above' the menubar. I have attached a patch which fixes the issue by only making the window position relative to the menubar in windowed modes.
Sam Lantinga 3905b910 2014-06-02T09:01:10 Fixed bug 2479 - [OS X] SDL_SetWindowFullscreen fails to switch to windowed Eric Wasylishen The problem seems to be the spaces handling code in -setFullscreenSpace: (SDL_cocoawindow.m) is incorrectly reporting that the SDL_WINDOW_FULLSCREEN -> windowed transition has already happened. i.e. I saw this case was getting hit when trying to leave SDL_WINDOW_FULLSCREEN: "else if (state == isFullscreenSpace) { return YES; /* already there. */ }" With the attached patch, both Control+Enter (SDL_WINDOW_FULLSCREEN toggle) and Option+Enter (SDL_WINDOW_FULLSCREEN_DESKTOP toggle) work in an sdl test app (I tried testwm2). Tested on OS X 10.9.2.
Ryan C. Gordon 98c03f39 2014-05-28T01:22:47 Changed drag area API to a hit-testing API. There were several good arguments for this: it's how Windows works with WM_NCHITTEST, SDL doesn't need to manage a list of rects, it allows more control over the regions (how do you use rects to cleanly surround a circular button?), the callback can be more optimized than a iterating a list of rects, and you don't have to send an updated list of rects whenever the window resizes or layout changes.
Ryan C. Gordon 3cbc83ef 2014-05-27T01:27:42 First shot at SDL_SetWindowDragAreas(). Only Cocoa implemented right now.
Ryan C. Gordon ded970f7 2014-05-24T18:23:56 Flip this around to do the simpler condition first.
J?rgen P. Tjern? 8b280091 2014-04-24T21:05:51 Mac: Correct the y-axis position after 870c7d21004b This fixes a bug where we'd offset positions by the height of the dock, if it was along the bottom of the screen. Fixes https://bugzilla.libsdl.org/show_bug.cgi?id=2509 Thanks to Alex Szpakowski for bug & patch.
J?rgen P. Tjern? beff5cec 2014-04-19T13:15:53 Mac: SDL_SetWindowPosition is now relative to the menubar. It used to be that SDL_SetWindowPosition was relative to the top of the screen, which didn't make sense. In addition, borderless windows can be positioned *below* the menubar, so SDL_SetWindowPosition(win, 0, 0) on a borderless window would hide ~30ish pixels of the window below the menubar.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Ryan C. Gordon 84b919a2 2014-03-20T11:22:57 Static analysis fix: dereference of a NULL pointer.
Sam Lantinga 9245c930 2014-03-15T16:27:06 Only show the window if it's supposed to be shown.
Ryan C. Gordon c663d731 2014-03-15T15:35:15 Mac: Make sure window is still showing when we exit a fullscreen space.
Sam Lantinga 26e8e387 2014-03-14T18:06:09 Fixed Mac OS X window level when leaving fullscreen mode
Ryan C. Gordon 9e67444a 2014-03-03T21:25:16 Mac: Added a hint to opt-out of new Spaces code.
Ryan C. Gordon 3889d478 2014-03-02T22:55:12 Removed unused variable.
Ryan C. Gordon 0e5cc8df 2014-03-02T22:51:31 Mac: Don't lose the menu/dock when switching back to a resizable window Space.
Ryan C. Gordon 86be8321 2014-03-02T22:16:49 Mac: only programmatically create Spaces if we're FULLSCREEN_DESKTOP. (coming back from fullscreen in any state is okay).
Ryan C. Gordon 460f97ff 2014-03-02T16:36:40 A bunch of fixes for the new Spaces code.
Ryan C. Gordon 5eccbac4 2014-03-02T15:35:24 Mac: Manage menubar and dock as FULLSCREEN_DESKTOP windows become/resign key.
Ryan C. Gordon 51faf449 2014-03-02T12:45:51 Reworked fullscreen policy on Mac OS X. - SDL_WINDOW_FULLSCREEN works as always (change resolution, lock to window). - SDL_WINDOW_FULLSCREEN_DESKTOP now puts the window in its own Space, and hides the menu bar, but you can slide between Spaces and Command-Tab between apps without the window minimizing, etc. - SDL_WINDOW_RESIZABLE windows will get the new 10.7+ "toggle fullscreen" window decoration and menubar item. As far as the app is concerned, this is no different than resizing a window, but it gives the end-user more power. - The hint for putting fullscreen windows into the Spaces system is gone, since Spaces can't enforce the requested resolution. It's a perfect match for FULLSCREEN_DESKTOP, though, so this is all automated now.
J?rgen P. Tjern? 4850d259 2014-02-26T11:35:02 Mac: Redo cursor warp handling. This fixes bugs related to getting unnaturally large xrel/yrel for SDL_MOUSEMOTION after warps and enabling / disabling relative mode. Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=1836
J?rgen P. Tjern? 52a63e82 2014-02-25T17:27:41 Mac: Improve moving relative mode windows. This makes it possible to move windows by their title bar, even if they're in relative mode, if you click the title bar when the window does not have focus. Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2396
J?rgen P. Tjern? 95f7e242 2014-02-25T15:28:12 Mac: Immediately update current OpenGL context's shape. Previously we were postponing our -[NSOpenGLContext update] call to the next SDL_GL_SwapWindow, even if the context was current on the current thread. This changes it so that we will do the update immediately if it's the current context. If you're rendering on another thread, you need to call SDL_GL_SwapWindow once after a resize event to ensure your drawable will produce non-garbage data. Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2339
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
J?rgen P. Tjern? bc92383e 2014-01-15T11:31:56 Mac: Don't give windows focus back when we're closing them. Fixes bug #1840 (https://bugzilla.libsdl.org/show_bug.cgi?id=1840)
J?rgen P. Tjern? 8f660a46 2014-01-14T17:33:24 Mac: Trigger SDL_FINGERUP for all touches. Fixes bug #2348. Thanks to Alex Szpakowski for the patch!
Sam Lantinga 27779311 2013-12-27T10:18:11 Bump SDL to build with 10.7 SDK. This also bumps the minimum requirement for building SDL to 10.7, and removes some checking we no longer need. CR: saml
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Sam Lantinga 4295a92f 2013-11-14T22:26:49 Fixed bug 2240 - On OS/X after calling SDL_SetWindowBordered right mouse clicks no longer register philhassey On OS/X after calling SDL_SetWindowBordered right mouse clicks no longer register. Steps to Reproduce: 1. Open a windowed window on OS/X. (With the border on.) 2. e.button.button will give values 1,2,3 depending on which mouse button I click. 3. Call SDL_SetWindowBordered to disable the border. 4. e.button.button will only give values 1,2. 3 (right mouse button) stops coming through. Expected result: I expect all mouse buttons to register.
Sam Lantinga 12961352 2013-11-12T02:04:12 Fixed build error with SDK < 10.7
Sam Lantinga 253b9ba8 2013-11-12T02:02:12 We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.
Sam Lantinga 75145ea0 2013-11-12T01:52:54 Added a hint SDL_HINT_VIDEO_FULLSCREEN_SPACES to specify that windows go fullscreen into their own spaces on Mac OS X.
Sam Lantinga 5f8a0b18 2013-11-12T00:32:29 Fullscreen space naming cleanup to avoid confusion with normal fullscreen mode
Sam Lantinga 7459b159 2013-11-11T23:42:43 Made sure the window had the correct border when manually being brought back from fullscreen mode.
Sam Lantinga cb190b82 2013-11-11T22:43:05 Fixed assertion when quickly toggling from fullscreen back to fullscreen: "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'backgroundWindows not nil in enterFullScreenTransitionWithOptions:animated:activatingIt:'" To reproduce this, run testsprite2, press Alt-Enter once, again while it's animating to fullscreen, and then again while it's animating out of fullscreen.
Sam Lantinga 8f8070db 2013-11-11T21:38:11 Fixed window resizing when entering and leaving fullscreen mode
Sam Lantinga 7cf76ffb 2013-11-11T21:21:18 Fixed assertion failure when minimizing a fullscreen window.
Sam Lantinga cb31a80d 2013-11-11T20:42:59 Properly handle toggling fullscreen state when another fullscreen state change is in progress.
Sam Lantinga f0692d65 2013-11-11T03:29:11 Fixed compiling with older Mac OS X SDK
Sam Lantinga 4c1322f6 2013-11-11T02:53:00 Added support for new style fullscreen transitions on Mac OS X
Sam Lantinga 893afbaf 2013-11-10T19:19:44 Fixed pool memory leak
Sam Lantinga 5821466c 2013-11-10T17:40:35 Fixed bug 2176 - SDL_CreateWindow(w=INT_MAX, h=INT_MAX) causes program to hang Catch exceptions generated when trying to create a Cocoa window.
Sam Lantinga 621c7f8f 2013-11-08T14:04:51 Added SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK hint which controls whether ctrl+click should emulate a right click on OSX.
Sam Lantinga bcf5472d 2013-10-21T02:37:03 Fixed bug 2073 - Mac: window moves unexpectedly when exiting SDL_WINDOW_FULLSCREEN_DESKTOP mode Alex Szpakowski In Mac OS X, when SDL_SetWindowFullscreen(window, 0) is called on a window which was in SDL_WINDOW_FULLSCREEN_DESKTOP mode, its original size is restored but its position is moved to the bottom of the screen. I tracked down the issue to these two lines: http://hg.libsdl.org/SDL/file/fdd5cc9e9f90/src/video/cocoa/SDL_cocoawindow.m#l1034 I believe [nswindow setFrameOrigin:rect.origin] implicitly calls [nswindow constrainFrameRect:rect toScreen:screen], which will attempt to constrain the window to the screen, but at that point the window size is still full-screen rather than the restored window size, so the constrainFrameRect function operates on the wrong window size. https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/constrainFrameRect:toScreen: I resolved the issue by swapping the order of the function calls, like so: [nswindow setContentSize:rect.size]; [nswindow setFrameOrigin:rect.origin];
Sam Lantinga 69a4351e 2013-09-30T22:35:32 Fixed bug 2121 - GCC throws error on SDL_FORCE_INLINE when compiling with -ansi
Edward Rudd 869a7076 2013-09-20T13:43:00 add in High DPI support (aka Retina) - based on J?rgen's patch with a few bug fixes
Sam Lantinga 67c02a28 2013-09-13T17:42:31 Mac: Translate Ctrl-Left click to right click.
J?rgen P. Tjern? 14bf230d 2013-08-12T11:09:13 Mac: Fix restoring of Cmd-H-hidden fullscreen desktop windows. This should fix http://bugzilla.libsdl.org/show_bug.cgi?id=1996
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.