Commit Graph

131 Commits

Author SHA1 Message Date
Sam Lantinga 059579e48f Fixed bug 2696 - Mac: fix display mode refresh rate calculation
Alex Szpakowski

SDL's Cocoa backend uses the CGDisplayMode API to get refresh rate information about a display mode, but CGDisplayModeGetRefreshRate will return 0 on most non-CRT monitors.

The only way I know of to get correct refresh rate information in OS X is via the CoreVideo DisplayLink API.
I have attached a patch which tries to use the CVDisplayLinkGetNominalOutputVideoRefreshPeriod function if CGDisplayModeGetRefreshRate fails, which fixes display mode refresh rate information on the monitors I tested.

The CVDisplayLink API requires linking with the CoreVideo framework, and the patch updates the various build files to do so.
2014-08-23 10:47:50 -07:00
Alex Baines f4ddacf425 Improvements to the IBus related code:
+ Handle HidePreeditText IBus signal.
+ Use SDL_GetKeyboardFocus instead of SDL_GetFocusWindow.
+ Move the X11 IBus SetFocus calls to the X11_DispatchFocus functions.
+ Simplify the IBus ifdefs when handling X11 KeyEvents.
+ Remove inotify watch when SDL_IBus_Quit is called.
2014-08-19 23:17:28 +01:00
Sam Lantinga bbab38552a SDL - fix fullscreen desktop windows not restoring to fullscreen state if focus changes happen due to programtic window changes (and not user alt-tabbing) 2014-08-18 18:16:45 -07:00
Sam Lantinga d1cc47b337 Fixed 2680 - OSX: Replace NSAutoreleasePool with @autoreleasepool
Tim McDaniel

This patch replaces all use of NSAutoreleasePool with the Apple recommended @autoreleasepool.  @autoreleasepool is supposedly more efficient, and since it is scope based it can't be accidentally not released.
2014-08-17 15:07:00 -07:00
Sam Lantinga 5e50180415 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.
2014-08-17 14:57:52 -07:00
Sam Lantinga 1ea8697894 Removed SDL_round() because the license wasn't compatible with zlib 2014-08-17 13:11:55 -07:00
Sam Lantinga 8272ed1819 Fixed bug 2687 - SDL_BlitScaled does not handle clipping correctly
Patch from Benoit Pierre:

video: fix clipping handling in SDL_UpperBlitScaled

- honor destination clipping rectangle
- update both destination and source rectangles when clipping source
  rectangle to source surface and destination rectangle to destination
  clip rectangle
- don't change scaling factors when clipping

N.B.:

- when no scaling is involved (source and destination width/height are
  the same), SDL_UpperBlit is used (so SDL_BlitScaled behaves like
  SDL_BlitSurface)
- the final destination rectangle after all clipping is performed is
  saved back to dstrect (like for SDL_UpperBlit)
2014-08-16 23:25:02 -07:00
Sam Lantinga 6fef39d6b8 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers 2014-08-06 11:34:54 -07:00
Sam Lantinga 6299daecba The OpenGL context returned by the UIKit backend is now an actual OpenGL context instead of the OpenGL view we created.
This allows you to use the returned context in functions like CVOpenGLESTextureCacheCreate()
2014-08-06 00:28:02 -07:00
Alfred Reynolds 87b8c8d108 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. 2014-07-31 12:46:23 -07:00
Alfred Reynolds 7552947654 SDL - fix re-entrancy into SDL_UpdateFullscreenMode under OSX. During HideWindow we get a RESTORED event which then turns fullscreen back on causing a hang in Cocoa_SetWindowFullscreenSpace waiting for the fullscreen transition to finish. 2014-07-30 17:45:52 -07:00
Ryan C. Gordon f7461cdc9a The Gimp puts out a different bogus color mask for 32-bit .bmp files. :) 2014-07-09 00:09:57 -04:00
Ryan C. Gordon a91f1a1adc Make SDL_LoadBMP() work with 32-bit bitmaps from ImageMagick. 2014-07-09 00:01:34 -04:00
Sam Lantinga 0c8e33764c Fixed bug 2628 - invalidate surface->map in SDL_SurfacePalette()
Wei Mingzhi

surface->map should be invalidated in SDL_SetSurfacePalette(), otherwise the palette would not be effective when blitting to another non-8bit surface which we previously blitted to.
2014-07-07 21:21:05 -07:00
Sam Lantinga fc4e798d79 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.
2014-07-07 12:48:25 -07:00
Sam Lantinga 7187b74cf4 Fixed compiler warnings on iOS 2014-07-07 11:00:25 -07:00
Sam Lantinga d44f392265 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.
2014-07-07 10:33:32 -07:00
Sam Lantinga 1ee96bb994 Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Gabriel Jacobo 5a3c553d0a Maybe fixes bug #2291 (red tinted screen on some Samsung Android devices)
Then again, maybe not!
2014-07-03 17:36:08 -03:00
Sam Lantinga 610225b451 Fixed null terminating the X11 error string 2014-06-28 19:51:26 -07:00
Gabriel Jacobo 765894e3cd Better fix to support EGL_KHR_create_context and not fail to build on Android
...or Raspberry Pi (EGL < 1.4 systems)
2014-06-28 13:05:16 -03:00
Gabriel Jacobo a9bb889864 Disable desktop OpenGL for EGL under Android 2014-06-28 12:48:29 -03:00
Gabriel Jacobo 1ed1f7f2e3 Fixes #2611 #2610, Touch events cause crash on Android, thanks Alvin & Sylvain
This bug was introduced on this rev: https://hg.libsdl.org/SDL/rev/42f6bd8c8575
2014-06-28 12:36:44 -03:00
Knut Andre Tidemann 02e9f81ebe SDL_egl: allow creation of versioned OpenGL contexts with EGL_KHR_create_context
If the EGL extension EGL_KHR_create_context is available, we can use it to
set the core/compatability profile and the minimum OpenGL version.

Use this if it is available to get the context requested by the GL attributes.
2014-06-28 12:17:29 -03:00
Ryan C. Gordon 95864f86d8 Patched to compile on Windows. 2014-06-25 17:24:06 -04:00
Ryan C. Gordon 84cb232067 Patched to compile with -Werror=declaration-after-statement 2014-06-25 17:13:43 -04:00
Ryan C. Gordon b29740b88f Merged Ryan's SDL-gui-backend branch.
Adds three APIs, and implements them on X11, Cocoa, and Windows:

- SDL_CaptureMouse()
- SDL_GetGlobalMouseState()
- SDL_SetWindowHitTest()
2014-06-25 17:06:12 -04:00
Ryan C. Gordon 8436956711 Changed SDL_GetAbsoluteMouseState() to SDL_GetGlobalMouseState().
This matches naming conventions in the main repository, between
 SDL_GetRelativeMouseState() and SDL_WarpMouseGlobal().
2014-06-25 16:16:55 -04:00
Sam Lantinga 704d9bd30d 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.
2014-06-25 02:08:37 -07:00
Sam Lantinga a8955f2640 Made the RLE code (semi) readable again 2014-06-25 01:35:17 -07:00
Sam Lantinga afe14829b8 Fixed bug 2556 - add compilation flag -Wshadow
Sylvain

here's the full patch for Blit + RLE.
2014-06-25 00:43:10 -07:00
Sam Lantinga 67e55655a3 Fixed grab interaction with Windows Classic theme
Testing:
* For each theme in Windows 7, Windows 7 Basic, and Windows 7 Classic:
- Ran testsprite2
- Pressed Ctrl-G to grab the mouse
- Alt-tabbed away, verified mouse is no longer grabbed
- Alt-tabbed back, verified that mouse was grabbed
- Alt-tabbed away
- Clicked in the window, verified mouse was grabbed
- Alt-tabbed away
- Grabbed the title bar and dragged the window around successfully, verified that mouse was grabbed when move modal loop completed
- Alt-tabbed away
- Clicked the minimize button on the title bar, the window was successfully minimized
- Clicked on the icon in the task bar, the window was restored and the mouse grabbed again
- Alt-tabbed away
- Clicked the close button on the title bar, the window was successfully closed
2014-06-23 10:09:15 -07:00
Sam Lantinga 9e2a2639f8 Added names for some theme related windows messages 2014-06-23 10:09:13 -07:00
Gabriel Jacobo 620510b337 Fix compiler warning 2014-06-23 09:18:31 -03:00
Sam Lantinga cff9eac637 Fixed bug 2579 - SDL fails to compile on Windows when only EGL+OpenGL ES defined
callow.mark

Compiling with SDL_VIDEO_RENDER_OGL=0, SDL_VIDEO_OPENGL=0, SDL_VIDEO_OPENGL_WGL=0, SDL_VIDEO_RENDER_OGL_ES2=1, SDL_VIDEO_OPENGL_ES2=1 and SDL_VIDEO_OPENGL_EGL=1 set in SDL_config_windows.h fails.

A patch is attached. See bug #2570 for reasons you might want to compile this way.
2014-06-22 09:48:46 -07:00
Sam Lantinga d65ac7785f Restore window OpenGL state if creating an OpenGL renderer fails 2014-06-22 02:48:43 -07:00
Sam Lantinga b7b6d8ab7a Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails 2014-06-22 02:30:36 -07:00
Sam Lantinga b56b37cde6 Fixed warning when building without ibus 2014-06-21 17:25:59 -07:00
Sam Lantinga d7924c73d6 Fixed bug 2563 - Remove obsolete code for supporting iOS < 5
Alex Szpakowski

Now that SDL for iOS requires at least iOS 5.1 at runtime, there are several old codepaths in the UIKit backend which can be removed. I've attached a patch which does so.
2014-06-21 12:43:57 -07:00
Alex Baines 41a39837ca Add IBus IME Support, move DBus code to its own file. (v3.3 squashed) 2014-06-18 20:11:39 +01:00
Sam Lantinga 8ef5651185 Fixed compiler warning 2014-06-21 11:36:00 -07:00
Sam Clegg 7e52722dfd Fix compiler warnings in Native Client and Linux builds. 2014-06-20 11:10:16 -03:00
Gabriel Jacobo ab238dc6e4 Assorted fixes for NaCl. Hat tip to Sylvain Becker 2014-06-16 09:54:33 -03:00
Gabriel Jacobo 9e55ace818 Fixes #2583, clean up EGL initialization 2014-06-16 09:47:23 -03:00
Sam Lantinga 260549d1ca Fixed bug 2567 - x11: Local dropped files are not URI-decoded
Melker Narikka

Local files that are dropped onto a window under X11
are not going through a URI decoding step, resulting in the following
in my test application:

Dropped file /home/meklu/Pictures/Screenshot%20from%202013-10-30%2014:04:50.png
Couldn't load /home/meklu/Pictures/Screenshot%20from%202013-10-30%2014:04:50.png

Expected result:

Dropped file /home/meklu/Pictures/Screenshot from 2013-10-30 14:04:50.png
Loaded /home/meklu/Pictures/Screenshot from 2013-10-30 14:04:50.png successfully

I've attached a patch that fixes the issue by doing URI decoding in-place on
the file string buffer.
2014-06-15 18:31:30 -07:00
Sam Lantinga 6146fe85cc Fixed 2584 - Memory leak in Cocoa_GetDisplayName
Diego

The Xcode Instruments Leak tool reports a leak from IODisplayCreateInfoDictionary in Cocoa_GetDisplayName.
This happened after upgrading to Xcode 5.
2014-06-15 17:18:05 -07:00
Ryan C. Gordon 39bad809c3 Mac: Fixed crash when returning from a fullscreen Space on shutdown. 2014-06-15 11:59:16 -04:00
Ryan C. Gordon 2cce7b2ed3 Implemented Cocoa GetAbsoluteMouseState(). 2014-06-11 00:40:19 -04:00
Ryan C. Gordon 4676705de0 Implement Windows GetAbsoluteMouseState(). 2014-06-11 00:12:19 -04:00
Ryan C. Gordon c8c55a01f4 This should probably query async button state. 2014-06-11 00:12:06 -04:00