sdlWindow.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "math/mMath.h"
  23. #include "gfx/gfxStructs.h"
  24. #include "windowManager/sdl/sdlWindow.h"
  25. #include "windowManager/sdl/sdlWindowMgr.h"
  26. #include "windowManager/sdl/sdlCursorController.h"
  27. #include "platformSDL/sdlInput.h"
  28. #include "platform/platformInput.h"
  29. #include "gfx/gfxDevice.h"
  30. #ifdef TORQUE_OS_LINUX
  31. #define SDL_VIDEO_DRIVER_X11 // TODO SDL
  32. #endif
  33. #include "SDL.h"
  34. #include "SDL_syswm.h"
  35. #define SCREENSAVER_QUERY_DENY 0 // Disable screensaver
  36. #ifndef IDI_ICON1
  37. #define IDI_ICON1 107
  38. #endif
  39. namespace
  40. {
  41. U32 getTorqueModFromSDL(U16 mod)
  42. {
  43. U32 ret = 0;
  44. if (mod & KMOD_LSHIFT)
  45. {
  46. ret |= SI_LSHIFT;
  47. ret |= SI_SHIFT;
  48. }
  49. if (mod & KMOD_RSHIFT)
  50. {
  51. ret |= SI_RSHIFT;
  52. ret |= SI_SHIFT;
  53. }
  54. if (mod & KMOD_LCTRL)
  55. {
  56. ret |= SI_LCTRL;
  57. ret |= SI_CTRL;
  58. }
  59. if (mod & KMOD_RCTRL)
  60. {
  61. ret |= SI_RCTRL;
  62. ret |= SI_CTRL;
  63. }
  64. if (mod & KMOD_LALT)
  65. {
  66. ret |= SI_LALT;
  67. ret |= SI_ALT;
  68. }
  69. if (mod & KMOD_RALT)
  70. {
  71. ret |= SI_RALT;
  72. ret |= SI_ALT;
  73. }
  74. // NOTE: For MacOS, this will treat command as Left or Right CTRL
  75. #ifdef TORQUE_OS_MAC
  76. if (mod & KMOD_LGUI)
  77. {
  78. ret |= SI_LCTRL;
  79. ret |= SI_CTRL;
  80. }
  81. if (mod & KMOD_RGUI)
  82. {
  83. ret |= SI_RCTRL;
  84. ret |= SI_CTRL;
  85. }
  86. #endif
  87. return ret;
  88. }
  89. }
  90. PlatformWindowSDL::PlatformWindowSDL():
  91. mOwningManager(NULL),
  92. mNextWindow(NULL),
  93. mWindowHandle(NULL),
  94. mOldParent(NULL),
  95. mDevice(NULL),
  96. mTarget(NULL),
  97. mPosition(0,0),
  98. mMouseLocked(false),
  99. mShouldLockMouse(false),
  100. mSuppressReset(false),
  101. mMenuHandle(NULL),
  102. mClosing(false)
  103. {
  104. mCursorController = new PlatformCursorControllerSDL( this );
  105. mVideoMode.bitDepth = 32;
  106. mVideoMode.fullScreen = false;
  107. mVideoMode.refreshRate = 60;
  108. mVideoMode.resolution.set(800,600);
  109. }
  110. PlatformWindowSDL::~PlatformWindowSDL()
  111. {
  112. // delete our sdl handle..
  113. SDL_DestroyWindow(mWindowHandle);
  114. // unlink ourselves from the window list...
  115. AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!");
  116. mOwningManager->unlinkWindow(this);
  117. }
  118. GFXDevice * PlatformWindowSDL::getGFXDevice()
  119. {
  120. return mDevice;
  121. }
  122. GFXWindowTarget * PlatformWindowSDL::getGFXTarget()
  123. {
  124. return mTarget;
  125. }
  126. const GFXVideoMode & PlatformWindowSDL::getVideoMode()
  127. {
  128. return mVideoMode;
  129. }
  130. void* PlatformWindowSDL::getSystemWindow(const WindowSystem system)
  131. {
  132. SDL_SysWMinfo info;
  133. SDL_VERSION(&info.version);
  134. SDL_GetWindowWMInfo(mWindowHandle,&info);
  135. #ifdef TORQUE_OS_WIN
  136. if( system == WindowSystem_Windows && info.subsystem == SDL_SYSWM_WINDOWS)
  137. return info.info.win.window;
  138. #endif
  139. #if defined(TORQUE_OS_LINUX)
  140. if( system == WindowSystem_X11 && info.subsystem == SDL_SYSWM_X11)
  141. return (void*)info.info.x11.window;
  142. #endif
  143. AssertFatal(0, "");
  144. return NULL;
  145. }
  146. void PlatformWindowSDL::_setVideoMode( const GFXVideoMode &mode )
  147. {
  148. mVideoMode = mode;
  149. mSuppressReset = true;
  150. S32 newDisplay = Con::getIntVariable("pref::Video::deviceId", 0);
  151. // Set our window to have the right style based on the mode
  152. if(mode.fullScreen && !Platform::getWebDeployment() && !mOffscreenRender)
  153. {
  154. SDL_Rect rect_sdl;
  155. // Move the window onto the correct monitor before setting fullscreen
  156. if (0 == SDL_GetDisplayBounds(newDisplay, &rect_sdl))
  157. {
  158. SDL_SetWindowPosition(mWindowHandle, rect_sdl.x, rect_sdl.y);
  159. }
  160. setSize(mode.resolution);
  161. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
  162. // When switching to Fullscreen, reset device after setting style
  163. if(mTarget.isValid())
  164. mTarget->resetMode();
  165. }
  166. else
  167. {
  168. // Reset device *first*, so that when we call setSize() and let it
  169. // access the monitor settings, it won't end up with our fullscreen
  170. // geometry that is just about to change.
  171. if(mTarget.isValid())
  172. mTarget->resetMode();
  173. if (!mOffscreenRender)
  174. {
  175. SDL_SetWindowFullscreen( mWindowHandle, 0);
  176. }
  177. // Restore the window to it's original size/position before applying changes
  178. SDL_RestoreWindow(mWindowHandle);
  179. // pref::Video::deviceMode values 0-windowed, 1-borderless, 2-fullscreen
  180. bool hasBorder = (0 == Con::getIntVariable("pref::Video::deviceMode", 0));
  181. SDL_SetWindowBordered(mWindowHandle, hasBorder ? SDL_TRUE : SDL_FALSE);
  182. setSize(mode.resolution);
  183. SDL_SetWindowPosition(mWindowHandle, SDL_WINDOWPOS_CENTERED_DISPLAY(newDisplay), SDL_WINDOWPOS_CENTERED_DISPLAY(newDisplay));
  184. if (hasBorder && Con::getBoolVariable("pref::Video::isMaximized", false))
  185. SDL_MaximizeWindow(mWindowHandle);
  186. }
  187. mSuppressReset = false;
  188. }
  189. bool PlatformWindowSDL::clearFullscreen()
  190. {
  191. return true;
  192. }
  193. bool PlatformWindowSDL::isFullscreen()
  194. {
  195. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  196. if( flags & SDL_WINDOW_FULLSCREEN || flags & SDL_WINDOW_FULLSCREEN_DESKTOP )
  197. return true;
  198. return false;
  199. }
  200. void PlatformWindowSDL::_setFullscreen(const bool fullscreen)
  201. {
  202. if( isFullscreen() )
  203. return;
  204. if(fullscreen && !mOffscreenRender)
  205. {
  206. Con::printf("PlatformWindowSDL::setFullscreen (full) enter");
  207. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN);
  208. }
  209. else
  210. {
  211. Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter");
  212. if (!mOffscreenRender)
  213. {
  214. SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP);
  215. }
  216. setSize(mVideoMode.resolution);
  217. }
  218. Con::printf("PlatformWindowSDL::setFullscreen exit");
  219. }
  220. bool PlatformWindowSDL::setCaption( const char *cap )
  221. {
  222. SDL_SetWindowTitle(mWindowHandle, cap);
  223. return true;
  224. }
  225. const char * PlatformWindowSDL::getCaption()
  226. {
  227. return StringTable->insert( SDL_GetWindowTitle(mWindowHandle) );
  228. }
  229. void PlatformWindowSDL::setFocus()
  230. {
  231. SDL_RaiseWindow(mWindowHandle);
  232. }
  233. void PlatformWindowSDL::setClientExtent( const Point2I newExtent )
  234. {
  235. Point2I oldExtent = getClientExtent();
  236. if (oldExtent == newExtent)
  237. return;
  238. SDL_SetWindowSize(mWindowHandle, newExtent.x, newExtent.y);
  239. }
  240. const Point2I PlatformWindowSDL::getClientExtent()
  241. {
  242. // Fetch Client Rect from Windows
  243. Point2I size;
  244. SDL_GetWindowSize(mWindowHandle, &size.x, &size.y);
  245. return size;
  246. }
  247. void PlatformWindowSDL::setBounds( const RectI &newBounds )
  248. {
  249. // TODO SDL
  250. }
  251. const RectI PlatformWindowSDL::getBounds() const
  252. {
  253. // TODO SDL
  254. return RectI(0, 0, 0, 0);
  255. }
  256. void PlatformWindowSDL::setPosition( const Point2I newPosition )
  257. {
  258. SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y );
  259. }
  260. const Point2I PlatformWindowSDL::getPosition()
  261. {
  262. Point2I position;
  263. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  264. // Return position
  265. return position;
  266. }
  267. Point2I PlatformWindowSDL::clientToScreen( const Point2I& pos )
  268. {
  269. Point2I position;
  270. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  271. return pos + position;
  272. }
  273. Point2I PlatformWindowSDL::screenToClient( const Point2I& pos )
  274. {
  275. Point2I position;
  276. SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y );
  277. return pos - position;
  278. }
  279. void PlatformWindowSDL::centerWindow()
  280. {
  281. int sizeX, sizeY;
  282. SDL_GetWindowSize(mWindowHandle, &sizeX, &sizeY);
  283. SDL_DisplayMode mode;
  284. SDL_GetDesktopDisplayMode(0, &mode);
  285. U32 posX = (mode.w/2) - (sizeX/2);
  286. U32 posY = (mode.h/2) - (sizeY/2);
  287. SDL_SetWindowPosition( mWindowHandle, posX, posY);
  288. }
  289. bool PlatformWindowSDL::setSize( const Point2I &newSize )
  290. {
  291. SDL_SetWindowSize(mWindowHandle, newSize.x, newSize.y);
  292. return true;
  293. }
  294. bool PlatformWindowSDL::isOpen()
  295. {
  296. return mWindowHandle;
  297. }
  298. bool PlatformWindowSDL::isVisible()
  299. {
  300. // Is the window open and visible, ie. not minimized?
  301. if(!mWindowHandle)
  302. return false;
  303. if (mOffscreenRender)
  304. return true;
  305. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  306. if( flags & SDL_WINDOW_SHOWN)
  307. return true;
  308. return false;
  309. }
  310. bool PlatformWindowSDL::isFocused()
  311. {
  312. if (mOffscreenRender)
  313. return true;
  314. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  315. if( flags & SDL_WINDOW_INPUT_FOCUS || flags & SDL_WINDOW_INPUT_GRABBED || flags & SDL_WINDOW_MOUSE_FOCUS )
  316. return true;
  317. return false;
  318. }
  319. bool PlatformWindowSDL::isMinimized()
  320. {
  321. if (mOffscreenRender)
  322. return false;
  323. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  324. if( flags & SDL_WINDOW_MINIMIZED)
  325. return true;
  326. return false;
  327. }
  328. bool PlatformWindowSDL::isMaximized()
  329. {
  330. if (mOffscreenRender)
  331. return true;
  332. U32 flags = SDL_GetWindowFlags( mWindowHandle );
  333. if( flags & SDL_WINDOW_MAXIMIZED)
  334. return true;
  335. return false;
  336. }
  337. WindowId PlatformWindowSDL::getWindowId()
  338. {
  339. return mWindowId;
  340. }
  341. void PlatformWindowSDL::minimize()
  342. {
  343. if (mOffscreenRender)
  344. return;
  345. SDL_MinimizeWindow( mWindowHandle );
  346. }
  347. void PlatformWindowSDL::maximize()
  348. {
  349. if (mOffscreenRender)
  350. return;
  351. SDL_MaximizeWindow( mWindowHandle );
  352. }
  353. void PlatformWindowSDL::restore()
  354. {
  355. if (mOffscreenRender)
  356. return;
  357. SDL_RestoreWindow( mWindowHandle );
  358. }
  359. void PlatformWindowSDL::hide()
  360. {
  361. if (mOffscreenRender)
  362. return;
  363. SDL_HideWindow( mWindowHandle );
  364. }
  365. void PlatformWindowSDL::show()
  366. {
  367. if (mOffscreenRender)
  368. return;
  369. SDL_ShowWindow( mWindowHandle );
  370. }
  371. void PlatformWindowSDL::close()
  372. {
  373. delete this;
  374. }
  375. void PlatformWindowSDL::defaultRender()
  376. {
  377. // TODO SDL
  378. }
  379. void PlatformWindowSDL::_triggerMouseLocationNotify(const SDL_Event& evt)
  380. {
  381. U32 mods = getTorqueModFromSDL(SDL_GetModState());
  382. if(!mMouseLocked)
  383. mouseEvent.trigger(getWindowId(), mods, evt.motion.x, evt.motion.y, false);
  384. else
  385. mouseEvent.trigger(getWindowId(), mods, evt.motion.xrel, evt.motion.yrel, true);
  386. }
  387. void PlatformWindowSDL::_triggerMouseWheelNotify(const SDL_Event& evt)
  388. {
  389. U32 mods = getTorqueModFromSDL(SDL_GetModState());
  390. S32 wheelDelta = Con::getIntVariable("$pref::Input::MouseWheelSpeed", 120);
  391. wheelEvent.trigger(getWindowId(), mods, evt.wheel.x * wheelDelta, evt.wheel.y * wheelDelta);
  392. }
  393. void PlatformWindowSDL::_triggerMouseButtonNotify(const SDL_Event& event)
  394. {
  395. S32 action = (event.type == SDL_MOUSEBUTTONDOWN) ? SI_MAKE : SI_BREAK;
  396. S32 button = -1;
  397. switch (event.button.button)
  398. {
  399. case SDL_BUTTON_LEFT:
  400. button = 0;
  401. break;
  402. case SDL_BUTTON_RIGHT:
  403. button = 1;
  404. break;
  405. case SDL_BUTTON_MIDDLE:
  406. button = 2;
  407. break;
  408. case SDL_BUTTON_X1:
  409. button = 3;
  410. break;
  411. case SDL_BUTTON_X2:
  412. button = 4;
  413. break;
  414. default:
  415. return;
  416. }
  417. U32 mod = getTorqueModFromSDL( SDL_GetModState() );
  418. buttonEvent.trigger(getWindowId(), mod, action, button );
  419. }
  420. void PlatformWindowSDL::_triggerKeyNotify(const SDL_Event& evt)
  421. {
  422. U32 inputAction = IA_MAKE;
  423. SDL_Keysym tKey = evt.key.keysym;
  424. if(evt.type == SDL_KEYUP)
  425. {
  426. inputAction = IA_BREAK;
  427. }
  428. if(evt.key.repeat)
  429. {
  430. inputAction = IA_REPEAT;
  431. }
  432. U32 torqueModifiers = getTorqueModFromSDL(evt.key.keysym.mod);
  433. U32 torqueKey = KeyMapSDL::getTorqueScanCodeFromSDL(tKey.scancode);
  434. if(tKey.scancode)
  435. {
  436. keyEvent.trigger(getWindowId(), torqueModifiers, inputAction, torqueKey);
  437. //Con::printf("Key %d : %d", tKey.sym, inputAction);
  438. if (inputAction == IA_MAKE && SDL_IsTextInputActive())
  439. {
  440. // We have to check if we already have a first responder active.
  441. // We don't want to type the character if it actually creates another responder!
  442. if (mWindowInputGenerator->lastKeyWasGlobalActionMap())
  443. {
  444. // Turn off Text input, and the next frame turn it back on. This tells SDL
  445. // to not generate a text event for this global action map key.
  446. SDL_StopTextInput();
  447. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::TEXT_INPUT);
  448. }
  449. }
  450. }
  451. }
  452. void PlatformWindowSDL::_triggerTextNotify(const SDL_Event& evt)
  453. {
  454. U32 mod = getTorqueModFromSDL( SDL_GetModState() );
  455. if( !evt.text.text[1] ) // get a char
  456. {
  457. U16 wchar = evt.text.text[0];
  458. charEvent.trigger(getWindowId(), mod, wchar );
  459. //Con::printf("Char: %c", wchar);
  460. return;
  461. }
  462. else // get a wchar string
  463. {
  464. const dsize_t len = strlen(evt.text.text);
  465. U16 wchar[16] = {};
  466. dMemcpy(wchar, evt.text.text, sizeof(char)*len);
  467. for(int i = 0; i < 16; ++i)
  468. {
  469. if( !wchar[i] )
  470. return;
  471. charEvent.trigger(getWindowId(), mod, wchar[i] );
  472. }
  473. }
  474. }
  475. void PlatformWindowSDL::_updateMonitorFromMove(const SDL_Event& evt)
  476. {
  477. SDL_Rect sdlRect;
  478. S32 monitorCount = SDL_GetNumVideoDisplays();
  479. for (S32 index = 0; index < monitorCount; ++index)
  480. {
  481. if (0 == SDL_GetDisplayBounds(index, &sdlRect))
  482. {
  483. if ((evt.window.data1 >= sdlRect.x) && (evt.window.data1 < (sdlRect.x + sdlRect.w)) &&
  484. (evt.window.data2 >= sdlRect.y) && (evt.window.data2 < (sdlRect.y + sdlRect.h)))
  485. {
  486. Con::setIntVariable("pref::Video::deviceId", index);
  487. return;
  488. }
  489. }
  490. }
  491. }
  492. void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
  493. {
  494. switch(evt.type)
  495. {
  496. case SDL_KEYDOWN:
  497. case SDL_KEYUP:
  498. {
  499. _triggerKeyNotify(evt);
  500. break;
  501. }
  502. case SDL_TEXTINPUT:
  503. {
  504. _triggerTextNotify(evt);
  505. break;
  506. }
  507. case SDL_MOUSEWHEEL:
  508. {
  509. _triggerMouseWheelNotify(evt);
  510. break;
  511. }
  512. case SDL_MOUSEMOTION:
  513. {
  514. _triggerMouseLocationNotify(evt);
  515. break;
  516. }
  517. case SDL_MOUSEBUTTONDOWN:
  518. case SDL_MOUSEBUTTONUP:
  519. {
  520. _triggerMouseButtonNotify(evt);
  521. break;
  522. }
  523. case SDL_WINDOWEVENT:
  524. {
  525. if (!mClosing)
  526. {
  527. switch (evt.window.event)
  528. {
  529. case SDL_WINDOWEVENT_FOCUS_GAINED:
  530. appEvent.trigger(getWindowId(), GainFocus);
  531. break;
  532. case SDL_WINDOWEVENT_FOCUS_LOST:
  533. appEvent.trigger(getWindowId(), LoseFocus);
  534. break;
  535. case SDL_WINDOWEVENT_MOVED:
  536. {
  537. S32 oldDisplay = Con::getIntVariable("pref::Video::deviceId", 0);
  538. _updateMonitorFromMove(evt);
  539. // If display device has changed, make sure window params are compatible with the new device.
  540. if (oldDisplay != Con::getIntVariable("pref::Video::deviceId", 0))
  541. Con::evaluate("configureCanvas();");
  542. break;
  543. }
  544. case SDL_WINDOWEVENT_RESIZED:
  545. {
  546. int width, height;
  547. SDL_GetWindowSize(mWindowHandle, &width, &height);
  548. mVideoMode.resolution.set(width, height);
  549. getGFXTarget()->resetMode();
  550. resizeEvent.trigger(getWindowId(), width, height);
  551. getScreenResChangeSignal().trigger(this, true);
  552. break;
  553. }
  554. case SDL_WINDOWEVENT_CLOSE:
  555. {
  556. appEvent.trigger(getWindowId(), WindowClose);
  557. mClosing = true;
  558. }
  559. case SDL_WINDOWEVENT_MINIMIZED:
  560. break;
  561. case SDL_WINDOWEVENT_MAXIMIZED:
  562. Con::setBoolVariable("pref::Video::isMaximized", true);
  563. break;
  564. case SDL_WINDOWEVENT_RESTORED:
  565. Con::setBoolVariable("pref::Video::isMaximized", false);
  566. break;
  567. default:
  568. break;
  569. }
  570. }
  571. }
  572. }
  573. }
  574. //-----------------------------------------------------------------------------
  575. // Mouse Locking
  576. //-----------------------------------------------------------------------------
  577. void PlatformWindowSDL::setMouseLocked( bool enable )
  578. {
  579. if (mOffscreenRender)
  580. return;
  581. mMouseLocked = enable;
  582. SDL_SetWindowGrab( mWindowHandle, SDL_bool(enable) );
  583. SDL_SetRelativeMouseMode( SDL_bool(enable) );
  584. }
  585. const UTF16 *PlatformWindowSDL::getWindowClassName()
  586. {
  587. // TODO SDL
  588. static String str("WindowClassName");
  589. return str.utf16();
  590. }
  591. const UTF16 *PlatformWindowSDL::getCurtainWindowClassName()
  592. {
  593. // TODO SDL
  594. static String str("CurtainWindowClassName");
  595. return str.utf16();
  596. }
  597. void PlatformWindowSDL::setKeyboardTranslation(const bool enabled)
  598. {
  599. mEnableKeyboardTranslation = enabled;
  600. // Flag for update. Let SDL know what kind of input state we are changing to.
  601. if (enabled)
  602. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::TEXT_INPUT);
  603. else
  604. mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::RAW_INPUT);
  605. }