Changed Start/StopTextInput back to not take any parameters.
authordewyatt
Mon, 12 Jul 2010 14:17:43 -0400
changeset 4753 11b0a6a3eb4d
parent 4752 dc7bdcf06367
child 4754 2072fed2f583
Changed Start/StopTextInput back to not take any parameters. We call SDL_GetKeyboardFocus internally now.
include/SDL_keyboard.h
src/SDL_compat.c
src/events/SDL_keyboard.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/win32/SDL_win32keyboard.c
src/video/win32/SDL_win32keyboard.h
--- a/include/SDL_keyboard.h	Mon Jul 12 11:33:27 2010 -0400
+++ b/include/SDL_keyboard.h	Mon Jul 12 14:17:43 2010 -0400
@@ -140,14 +140,14 @@
  *  \sa SDL_StopTextInput()
  *  \sa SDL_SetTextInputRect()
  */
-extern DECLSPEC void SDLCALL SDL_StartTextInput(SDL_Window *window);
+extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
 
 /**
  *  \brief Stop receiving any text input events.
  *  
  *  \sa SDL_StartTextInput()
  */
-extern DECLSPEC void SDLCALL SDL_StopTextInput(SDL_Window *window);
+extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
 
 /**
  *  \brief Set the rectangle used to type Unicode text inputs.
--- a/src/SDL_compat.c	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/SDL_compat.c	Mon Jul 12 14:17:43 2010 -0400
@@ -1740,11 +1740,11 @@
     switch (enable) {
     case 1:
         SDL_enabled_UNICODE = 1;
-        SDL_StartTextInput(SDL_VideoWindow);
+        SDL_StartTextInput();
         break;
     case 0:
         SDL_enabled_UNICODE = 0;
-        SDL_StopTextInput(SDL_VideoWindow);
+        SDL_StopTextInput();
         break;
     }
     return previous;
--- a/src/events/SDL_keyboard.c	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/events/SDL_keyboard.c	Mon Jul 12 14:17:43 2010 -0400
@@ -617,7 +617,7 @@
                             0, 0);
 
         if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
-            SDL_StartTextInput(window);
+            SDL_StartTextInput();
         }
     }
 }
--- a/src/video/SDL_sysvideo.h	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/video/SDL_sysvideo.h	Mon Jul 12 14:17:43 2010 -0400
@@ -299,8 +299,8 @@
     void (*SuspendScreenSaver) (_THIS);
 
     /* Text input */
-    void (*StartTextInput) (_THIS, SDL_Window *window);
-    void (*StopTextInput) (_THIS, SDL_Window *window);
+    void (*StartTextInput) (_THIS);
+    void (*StopTextInput) (_THIS);
     void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
 
     /* * * */
--- a/src/video/SDL_video.c	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/video/SDL_video.c	Mon Jul 12 14:17:43 2010 -0400
@@ -3385,20 +3385,20 @@
 }
 
 void
-SDL_StartTextInput(SDL_Window *window)
+SDL_StartTextInput(void)
 {
     if (_this && _this->StartTextInput) {
-        _this->StartTextInput(_this, window);
+        _this->StartTextInput(_this);
     }
     SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
     SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
 }
 
 void
-SDL_StopTextInput(SDL_Window *window)
+SDL_StopTextInput(void)
 {
     if (_this && _this->StopTextInput) {
-        _this->StopTextInput(_this, window);
+        _this->StopTextInput(_this);
     }
     SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
     SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
--- a/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/video/win32/SDL_win32keyboard.c	Mon Jul 12 14:17:43 2010 -0400
@@ -141,21 +141,29 @@
 }
 
 void
-WIN_StartTextInput(_THIS, SDL_Window *window)
+WIN_StartTextInput(_THIS)
 {
-    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
-    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
-    IME_Init(videodata, hwnd);
-    IME_Enable(videodata, hwnd);
+    SDL_Window *window = SDL_GetKeyboardFocus();
+    if (window)
+    {
+        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
+        IME_Init(videodata, hwnd);
+        IME_Enable(videodata, hwnd);
+    }
 }
 
 void
-WIN_StopTextInput(_THIS, SDL_Window *window)
+WIN_StopTextInput(_THIS)
 {
-    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
-    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
-    IME_Init(videodata, hwnd);
-    IME_Disable(videodata, hwnd);
+    SDL_Window *window = SDL_GetKeyboardFocus();
+    if (window)
+    {
+        HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+        SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
+        IME_Init(videodata, hwnd);
+        IME_Disable(videodata, hwnd);
+    }
 }
 
 void
--- a/src/video/win32/SDL_win32keyboard.h	Mon Jul 12 11:33:27 2010 -0400
+++ b/src/video/win32/SDL_win32keyboard.h	Mon Jul 12 14:17:43 2010 -0400
@@ -31,8 +31,8 @@
 extern void WIN_UpdateKeymap(void);
 extern void WIN_QuitKeyboard(_THIS);
 
-extern void WIN_StartTextInput(_THIS, SDL_Window *window);
-extern void WIN_StopTextInput(_THIS, SDL_Window *window);
+extern void WIN_StartTextInput(_THIS);
+extern void WIN_StopTextInput(_THIS);
 extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);
 
 extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata);