Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
authorSam Lantinga <slouken@libsdl.org>
Fri, 20 Aug 2004 22:35:23 +0000
changeset 934af585d6efec8
parent 933 4272450dd8d0
child 935 f8d5ddc7aef1
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
From: Eric Wing <ewing2121@yahoo.com>
Subject: New OS X patch (was Re: [SDL] Bug with inverted mouse coordinates in

I have a new patch for OS X I would like to submit.
First, it appears no further action has been taken on
my fix from Apple on the OpenGL windowed mode mouse
inversion problem. The fix would reunify the code, and
no longer require case checking for which version of
the OS you are running. This is probably a good fix
because the behavior with the old code could change
again with future versions of the OS, so those fixes
are included in this new patch.

But in addition, when I was at Apple, I asked them
about the ability to distinguish between the modifier
keys on the left and right sides of the keyboard (e.g.
Left Shift, Right Shift, Left/Right Alt, L/R Cmd, L/R
Ctrl). They told me that starting with Panther, the OS
began supporting this feature. This has always been a
source of annoyance for me when bringing a program
that comes from Windows or Linux to OS X when the
keybindings happened to need distinguishable left-side
and right-side keys. So the rest of the patch I am
submitting contains new code to support this feature
on Panther (and presumably later versions of the OS).

So after removing the OS version checks for the mouse
inversion problem, I reused the OS version checks to
activate the Left/Right detection of modifier keys. If
you are running Panther (or above), the new code will
attempt to distinguish between sides. For the older
OS's, the code path reverts to the original code.

I've tested with Panther on a G4 Cube, G5 dual
processor, and Powerbook Rev C. The Cube and G5
keyboards demonstrated the ability to distinguish
between sides. The Powerbook seems to only have
left-side keys, but the patch was still able to handle
it by producing the same results as before the patch.

I also wanted to test a non-Apple keyboard.
Unfortunately, I don't have any PC USB keyboards.
However, I was able to borrow a Sun Microsystems USB
keyboard, so I tried that out on the G5, and I got the
correct behavior for left and right sides. I'm
expecting that if it worked with a Sun keyboard, most
other keyboards should work with no problems.
src/video/quartz/SDL_QuartzEvents.m
src/video/quartz/SDL_QuartzKeys.h
src/video/quartz/SDL_QuartzVideo.m
src/video/quartz/SDL_QuartzWM.m
     1.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Fri Aug 20 22:33:11 2004 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Fri Aug 20 22:35:23 2004 +0000
     1.3 @@ -27,6 +27,42 @@
     1.4  #include <IOKit/pwr_mgt/IOPMLib.h> // For wake from sleep detection
     1.5  #include "SDL_QuartzKeys.h"
     1.6  
     1.7 +/* 
     1.8 + * In Panther, this header defines device dependent masks for 
     1.9 + * right side keys. These definitions only exist in Panther, but
    1.10 + * the header seems to exist at least in Jaguar and probably earlier
    1.11 + * versions of the OS, so this should't break anything.
    1.12 + */
    1.13 +#include <IOKit/hidsystem/IOLLEvent.h>
    1.14 +/* 
    1.15 + * These are not defined before Panther. To keep the code compiling
    1.16 + * on systems without these, I will define if they don't exist.
    1.17 + */
    1.18 +#ifndef NX_DEVICERCTLKEYMASK
    1.19 +    #define NX_DEVICELCTLKEYMASK    0x00000001
    1.20 +#endif
    1.21 +#ifndef NX_DEVICELSHIFTKEYMASK
    1.22 +    #define NX_DEVICELSHIFTKEYMASK  0x00000002
    1.23 +#endif
    1.24 +#ifndef NX_DEVICERSHIFTKEYMASK
    1.25 +    #define NX_DEVICERSHIFTKEYMASK  0x00000004
    1.26 +#endif
    1.27 +#ifndef NX_DEVICELCMDKEYMASK
    1.28 +    #define NX_DEVICELCMDKEYMASK    0x00000008
    1.29 +#endif
    1.30 +#ifndef NX_DEVICERCMDKEYMASK
    1.31 +    #define NX_DEVICERCMDKEYMASK    0x00000010
    1.32 +#endif
    1.33 +#ifndef NX_DEVICELALTKEYMASK
    1.34 +    #define NX_DEVICELALTKEYMASK    0x00000020
    1.35 +#endif
    1.36 +#ifndef NX_DEVICERALTKEYMASK
    1.37 +    #define NX_DEVICERALTKEYMASK    0x00000040
    1.38 +#endif
    1.39 +#ifndef NX_DEVICERCTLKEYMASK
    1.40 +    #define NX_DEVICERCTLKEYMASK    0x00002000
    1.41 +#endif
    1.42 +
    1.43  void     QZ_InitOSKeymap (_THIS) {
    1.44      const void *KCHRPtr;
    1.45      UInt32 state;
    1.46 @@ -115,6 +151,7 @@
    1.47      keymap[QZ_KP6] = SDLK_KP6;
    1.48      keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
    1.49      keymap[QZ_LSHIFT] = SDLK_LSHIFT;
    1.50 +    keymap[QZ_RSHIFT] = SDLK_RSHIFT;
    1.51      keymap[QZ_z] = SDLK_z;
    1.52      keymap[QZ_x] = SDLK_x;
    1.53      keymap[QZ_c] = SDLK_c;
    1.54 @@ -133,6 +170,9 @@
    1.55      keymap[QZ_LCTRL] = SDLK_LCTRL;
    1.56      keymap[QZ_LALT] = SDLK_LALT;
    1.57      keymap[QZ_LMETA] = SDLK_LMETA;
    1.58 +    keymap[QZ_RCTRL] = SDLK_RCTRL;
    1.59 +    keymap[QZ_RALT] = SDLK_RALT;
    1.60 +    keymap[QZ_RMETA] = SDLK_RMETA;
    1.61      keymap[QZ_SPACE] = SDLK_SPACE;
    1.62      keymap[QZ_LEFT] = SDLK_LEFT;
    1.63      keymap[QZ_DOWN] = SDLK_DOWN;
    1.64 @@ -259,7 +299,10 @@
    1.65          [ NSApp sendEvent:event ];
    1.66  }
    1.67  
    1.68 -static void QZ_DoModifiers (_THIS, unsigned int newMods) {
    1.69 +/* This is the original behavior, before support was added for 
    1.70 + * differentiating between left and right versions of the keys.
    1.71 + */
    1.72 +static void QZ_DoUnsidedModifiers (_THIS, unsigned int newMods) {
    1.73  
    1.74      const int mapping[] = { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
    1.75  
    1.76 @@ -267,9 +310,6 @@
    1.77      int bit;
    1.78      SDL_keysym key;
    1.79      
    1.80 -    if (current_mods == newMods)
    1.81 -    	return;
    1.82 -
    1.83      key.scancode    = 0;
    1.84      key.sym         = SDLK_UNKNOWN;
    1.85      key.unicode     = 0;
    1.86 @@ -302,7 +342,268 @@
    1.87                    SDL_PrivateKeyboard (SDL_RELEASED, &key);
    1.88          }
    1.89      }
    1.90 +}
    1.91  
    1.92 +/* This is a helper function for QZ_HandleModifierSide. This 
    1.93 + * function reverts back to behavior before the distinction between
    1.94 + * sides was made.
    1.95 + */
    1.96 +static void QZ_HandleNonDeviceModifier ( _THIS, unsigned int device_independent_mask, unsigned int newMods, unsigned int key_sym) {
    1.97 +    unsigned int currentMask, newMask;
    1.98 +    SDL_keysym key;
    1.99 +    
   1.100 +    key.scancode    = 0;
   1.101 +    key.sym         = key_sym;
   1.102 +    key.unicode     = 0;
   1.103 +    key.mod         = KMOD_NONE;
   1.104 +    
   1.105 +    /* Isolate just the bits we care about in the depedent bits so we can 
   1.106 +     * figure out what changed
   1.107 +     */ 
   1.108 +    currentMask = current_mods & device_independent_mask;
   1.109 +    newMask     = newMods & device_independent_mask;
   1.110 +    
   1.111 +    if ( currentMask &&
   1.112 +         currentMask != newMask ) {     /* modifier up event */
   1.113 +         SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.114 +    }
   1.115 +    else if ( newMask &&
   1.116 +          currentMask != newMask ) {     /* modifier down event */
   1.117 +          SDL_PrivateKeyboard (SDL_PRESSED, &key);
   1.118 +    }
   1.119 +}
   1.120 +
   1.121 +/* This is a helper function for QZ_HandleModifierSide. 
   1.122 + * This function sets the actual SDL_PrivateKeyboard event.
   1.123 + */
   1.124 +static void QZ_HandleModifierOneSide ( _THIS, unsigned int newMods,
   1.125 +                                       unsigned int key_sym, 
   1.126 +                                       unsigned int sided_device_dependent_mask ) {
   1.127 +    
   1.128 +    SDL_keysym key;
   1.129 +    unsigned int current_dep_mask, new_dep_mask;
   1.130 +    
   1.131 +    key.scancode    = 0;
   1.132 +    key.sym         = key_sym;
   1.133 +    key.unicode     = 0;
   1.134 +    key.mod         = KMOD_NONE;
   1.135 +    
   1.136 +    /* Isolate just the bits we care about in the depedent bits so we can 
   1.137 +     * figure out what changed
   1.138 +     */ 
   1.139 +    current_dep_mask = current_mods & sided_device_dependent_mask;
   1.140 +    new_dep_mask     = newMods & sided_device_dependent_mask;
   1.141 +    
   1.142 +    /* We now know that this side bit flipped. But we don't know if
   1.143 +     * it went pressed to released or released to pressed, so we must 
   1.144 +     * find out which it is.
   1.145 +     */
   1.146 +    if( new_dep_mask &&
   1.147 +        current_dep_mask != new_dep_mask ) { 
   1.148 +        /* Modifier down event */
   1.149 +        SDL_PrivateKeyboard (SDL_PRESSED, &key);
   1.150 +    }
   1.151 +    else /* Modifier up event */ {
   1.152 +        SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.153 +    }
   1.154 +}
   1.155 +
   1.156 +/* This is a helper function for QZ_DoSidedModifiers.
   1.157 + * This function will figure out if the modifier key is the left or right side, 
   1.158 + * e.g. left-shift vs right-shift. 
   1.159 + */
   1.160 +static void QZ_HandleModifierSide ( _THIS, int device_independent_mask, 
   1.161 +                                    unsigned int newMods, 
   1.162 +                                    unsigned int left_key_sym, 
   1.163 +                                    unsigned int right_key_sym,
   1.164 +                                    unsigned int left_device_dependent_mask, 
   1.165 +                                    unsigned int right_device_dependent_mask ) {
   1.166 +    unsigned int device_dependent_mask = 0;
   1.167 +    unsigned int diff_mod = 0;
   1.168 +    
   1.169 +    device_dependent_mask = left_device_dependent_mask | right_device_dependent_mask;
   1.170 +    /* On the basis that the device independent mask is set, but there are 
   1.171 +     * no device dependent flags set, we'll assume that we can't detect this 
   1.172 +     * keyboard and revert to the unsided behavior.
   1.173 +     */
   1.174 +    if ( (device_dependent_mask & newMods) == 0 ) {
   1.175 +        /* Revert to the old behavior */
   1.176 +        QZ_HandleNonDeviceModifier ( this, device_independent_mask, newMods, left_key_sym );
   1.177 +        return;
   1.178 +    }
   1.179 +        
   1.180 +    /* XOR the previous state against the new state to see if there's a change */
   1.181 +    diff_mod = (device_dependent_mask & current_mods)
   1.182 +        ^ (device_dependent_mask & newMods);
   1.183 +
   1.184 +    if ( diff_mod ) {
   1.185 +        /* A change in state was found. Isolate the left and right bits 
   1.186 +         * to handle them separately just in case the values can simulataneously
   1.187 +         * change or if the bits don't both exist.
   1.188 +         */
   1.189 +        if ( left_device_dependent_mask & diff_mod ) {
   1.190 +            QZ_HandleModifierOneSide ( this, newMods, left_key_sym, left_device_dependent_mask );
   1.191 +        }
   1.192 +        if ( right_device_dependent_mask & diff_mod ) {
   1.193 +            QZ_HandleModifierOneSide ( this, newMods, right_key_sym, right_device_dependent_mask );
   1.194 +        }
   1.195 +    }
   1.196 +}
   1.197 +   
   1.198 +/* This is a helper function for QZ_DoSidedModifiers.
   1.199 + * This function will release a key press in the case that 
   1.200 + * it is clear that the modifier has been released (i.e. one side 
   1.201 + * can't still be down).
   1.202 + */
   1.203 +static void QZ_ReleaseModifierSide ( _THIS, 
   1.204 +                                     unsigned int device_independent_mask, 
   1.205 +                                     unsigned int newMods,
   1.206 +                                     unsigned int left_key_sym, 
   1.207 +                                     unsigned int right_key_sym,
   1.208 +                                     unsigned int left_device_dependent_mask, 
   1.209 +                                     unsigned int right_device_dependent_mask ) {
   1.210 +    unsigned int device_dependent_mask = 0;
   1.211 +    SDL_keysym key;
   1.212 +    
   1.213 +    key.scancode    = 0;
   1.214 +    key.sym         = SDLK_UNKNOWN;
   1.215 +    key.unicode     = 0;
   1.216 +    key.mod         = KMOD_NONE;
   1.217 +    
   1.218 +    device_dependent_mask = left_device_dependent_mask | right_device_dependent_mask;
   1.219 +    /* On the basis that the device independent mask is set, but there are 
   1.220 +     * no device dependent flags set, we'll assume that we can't detect this 
   1.221 +     * keyboard and revert to the unsided behavior.
   1.222 +     */
   1.223 +    if ( (device_dependent_mask & current_mods) == 0 ) {
   1.224 +        /* In this case, we can't detect the keyboard, so use the left side 
   1.225 +         * to represent both, and release it. 
   1.226 +         */
   1.227 +        key.sym = left_key_sym;
   1.228 +        SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.229 +
   1.230 +        return;
   1.231 +    }
   1.232 +        
   1.233 +        
   1.234 +    /* 
   1.235 +     * This could have been done in an if-else case because at this point,
   1.236 +     * we know that all keys have been released when calling this function. 
   1.237 +     * But I'm being paranoid so I want to handle each separately,
   1.238 +     * so I hope this doesn't cause other problems.
   1.239 +     */
   1.240 +    if ( left_device_dependent_mask & current_mods ) {
   1.241 +        key.sym = left_key_sym;
   1.242 +        SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.243 +    }
   1.244 +    if ( right_device_dependent_mask & current_mods ) {
   1.245 +        key.sym = right_key_sym;
   1.246 +        SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.247 +    }
   1.248 +}
   1.249 +
   1.250 +/* This is a helper function for QZ_DoSidedModifiers.
   1.251 + * This function handles the CapsLock case.
   1.252 + */
   1.253 +static void QZ_HandleCapsLock (_THIS, unsigned int newMods) {
   1.254 +    unsigned int currentMask, newMask;
   1.255 +    SDL_keysym key;
   1.256 +    
   1.257 +    key.scancode    = 0;
   1.258 +    key.sym         = SDLK_CAPSLOCK;
   1.259 +    key.unicode     = 0;
   1.260 +    key.mod         = KMOD_NONE;
   1.261 +    
   1.262 +    currentMask = current_mods & NSAlphaShiftKeyMask;
   1.263 +    newMask     = newMods & NSAlphaShiftKeyMask;
   1.264 +
   1.265 +    if ( currentMask &&
   1.266 +         currentMask != newMask ) {     /* modifier up event */
   1.267 +         /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
   1.268 +         SDL_PrivateKeyboard (SDL_PRESSED, &key);
   1.269 +         SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.270 +    }
   1.271 +    else if ( newMask &&
   1.272 +              currentMask != newMask ) {     /* modifier down event */
   1.273 +        /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
   1.274 +        SDL_PrivateKeyboard (SDL_PRESSED, &key);
   1.275 +        SDL_PrivateKeyboard (SDL_RELEASED, &key);
   1.276 +    }
   1.277 +}
   1.278 +
   1.279 +/* This function will handle the modifier keys and also determine the 
   1.280 + * correct side of the key.
   1.281 + */
   1.282 +static void QZ_DoSidedModifiers (_THIS, unsigned int newMods) {
   1.283 +	/* Set up arrays for the key syms for the left and right side. */
   1.284 +    const unsigned int left_mapping[]  = { SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
   1.285 +    const unsigned int right_mapping[] = { SDLK_RSHIFT, SDLK_RCTRL, SDLK_RALT, SDLK_RMETA };
   1.286 +	/* Set up arrays for the device dependent masks with indices that 
   1.287 +     * correspond to the _mapping arrays 
   1.288 +     */
   1.289 +    const unsigned int left_device_mapping[]  = { NX_DEVICELSHIFTKEYMASK, NX_DEVICELCTLKEYMASK, NX_DEVICELALTKEYMASK, NX_DEVICELCMDKEYMASK };
   1.290 +    const unsigned int right_device_mapping[] = { NX_DEVICERSHIFTKEYMASK, NX_DEVICERCTLKEYMASK, NX_DEVICERALTKEYMASK, NX_DEVICERCMDKEYMASK };
   1.291 +
   1.292 +    unsigned int i;
   1.293 +    unsigned int bit;
   1.294 +    
   1.295 +    /* Handle CAPSLOCK separately because it doesn't have a left/right side */
   1.296 +    QZ_HandleCapsLock ( this, newMods );
   1.297 +        
   1.298 +    /* Iterate through the bits, testing each against the current modifiers */
   1.299 +    for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
   1.300 +		
   1.301 +        unsigned int currentMask, newMask;
   1.302 +		
   1.303 +        currentMask = current_mods & bit;
   1.304 +        newMask     = newMods & bit;
   1.305 +		
   1.306 +        /* If the bit is set, we must always examine it because the left
   1.307 +         * and right side keys may alternate or both may be pressed.
   1.308 +         */
   1.309 +        if ( newMask ) {
   1.310 +            QZ_HandleModifierSide ( this, bit, newMods, 
   1.311 +                                       left_mapping[i],
   1.312 +                                       right_mapping[i],
   1.313 +                                       left_device_mapping[i],
   1.314 +                                       right_device_mapping[i] );
   1.315 +        }
   1.316 +        /* If the state changed from pressed to unpressed, we must examine
   1.317 +            * the device dependent bits to release the correct keys.
   1.318 +            */
   1.319 +        else if ( currentMask &&
   1.320 +                  currentMask != newMask ) { /* modifier up event */
   1.321 +                  QZ_ReleaseModifierSide ( this, bit, newMods,
   1.322 +                                           left_mapping[i],
   1.323 +                                           right_mapping[i],
   1.324 +                                           left_device_mapping[i],
   1.325 +                                           right_device_mapping[i] );
   1.326 +        }
   1.327 +    }
   1.328 +}
   1.329 +
   1.330 +/* This function is called to handle the modifiers.
   1.331 + * It will try to distinguish between the left side and right side 
   1.332 + * of the keyboard for those modifiers that qualify if the 
   1.333 + * operating system version supports it. Otherwise, the code 
   1.334 + * will not try to make the distinction.
   1.335 + */
   1.336 +static void QZ_DoModifiers (_THIS, unsigned int newMods) {
   1.337 +	
   1.338 +    if (current_mods == newMods)
   1.339 +    	return;
   1.340 +    
   1.341 +    /* 
   1.342 +     * Starting with Panther (10.3.0), the ability to distinguish between 
   1.343 +     * left side and right side modifiers is available.
   1.344 +     */
   1.345 +    if( system_version >= 0x1030 ) {
   1.346 +        QZ_DoSidedModifiers (this, newMods);
   1.347 +    }
   1.348 +    else {
   1.349 +        QZ_DoUnsidedModifiers (this, newMods);
   1.350 +    }
   1.351 +    
   1.352      current_mods = newMods;
   1.353  }
   1.354  
     2.1 --- a/src/video/quartz/SDL_QuartzKeys.h	Fri Aug 20 22:33:11 2004 +0000
     2.2 +++ b/src/video/quartz/SDL_QuartzKeys.h	Fri Aug 20 22:35:23 2004 +0000
     2.3 @@ -109,8 +109,8 @@
     2.4  #define QZ_COMMA		0x2B
     2.5  #define QZ_PERIOD		0x2F
     2.6  #define QZ_SLASH		0x2C
     2.7 -#if 0	/* These are the same as the left versions - use left by default */
     2.8 -#define QZ_RSHIFT		0x38
     2.9 +#if 1	/* Panther now defines right side keys */
    2.10 +#define QZ_RSHIFT		0x3C
    2.11  #endif
    2.12  #define QZ_UP			0x7E
    2.13  #define QZ_KP1			0x53
    2.14 @@ -121,10 +121,10 @@
    2.15  #define QZ_LALT			0x3A
    2.16  #define QZ_LMETA		0x37
    2.17  #define QZ_SPACE		0x31
    2.18 -#if 0	/* These are the same as the left versions - use left by default */
    2.19 -#define QZ_RMETA		0x37
    2.20 -#define QZ_RALT			0x3A
    2.21 -#define QZ_RCTRL		0x3B
    2.22 +#if 1	/* Panther now defines right side keys */
    2.23 +#define QZ_RMETA		0x36
    2.24 +#define QZ_RALT			0x3D
    2.25 +#define QZ_RCTRL		0x3E
    2.26  #endif
    2.27  #define QZ_LEFT			0x7B
    2.28  #define QZ_DOWN			0x7D
     3.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Fri Aug 20 22:33:11 2004 +0000
     3.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Fri Aug 20 22:35:23 2004 +0000
     3.3 @@ -207,7 +207,7 @@
     3.4      
     3.5      if ( Gestalt(gestaltSystemVersion, &system_version) != noErr )
     3.6          system_version = 0;
     3.7 -
     3.8 +    
     3.9      /* register for sleep notifications so wake from sleep generates SDL_VIDEOEXPOSE */
    3.10      QZ_RegisterForSleepNotifications (this);
    3.11      
     4.1 --- a/src/video/quartz/SDL_QuartzWM.m	Fri Aug 20 22:33:11 2004 +0000
     4.2 +++ b/src/video/quartz/SDL_QuartzWM.m	Fri Aug 20 22:35:23 2004 +0000
     4.3 @@ -138,12 +138,8 @@
     4.4          p->y = CGDisplayPixelsHigh (display_id) - p->y;
     4.5      }
     4.6      else {
     4.7 -        
     4.8 -        NSPoint newPoint;
     4.9 -        
    4.10 -        newPoint = [ window_view convertPoint:*p toView:[ qz_window contentView ] ];
    4.11 -        
    4.12 -        *p = newPoint;
    4.13 +       
    4.14 +        *p = [ window_view convertPoint:*p toView: nil ];
    4.15      }
    4.16  }
    4.17  
    4.18 @@ -155,17 +151,11 @@
    4.19          p->y = CGDisplayPixelsHigh (display_id) - p->y;
    4.20      }
    4.21      else {
    4.22 +
    4.23 +        *p = [ window_view convertPoint:*p fromView: nil ];
    4.24          
    4.25 -        NSPoint newPoint;
    4.26 -        
    4.27 -        newPoint = [ window_view convertPoint:*p fromView:[ qz_window contentView ] ];
    4.28 -        
    4.29 -        *p = newPoint;
    4.30 -
    4.31 -        /* If OSX version is 10.3.0 or later, we need a workaround in OpenGL mode */
    4.32 -        if( system_version >= 0x1030 && (SDL_VideoSurface->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) ) {
    4.33 -            p->y = [window_view frame].size.height - p->y - 1;
    4.34 -        }
    4.35 +        /* The coordinates need to be inverted */
    4.36 +        p->y = [window_view frame].size.height - p->y - 1;
    4.37      }
    4.38  }
    4.39