win32WindowMgr.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #ifndef _WINDOWMANAGER_WIN32_WIN32WINDOWMANAGER_
  23. #define _WINDOWMANAGER_WIN32_WIN32WINDOWMANAGER_
  24. #include <windows.h>
  25. #include "math/mMath.h"
  26. #include "gfx/gfxStructs.h"
  27. #include "windowManager/win32/win32Window.h"
  28. #include "core/util/tVector.h"
  29. /// Win32 implementation of the window manager interface.
  30. class Win32WindowManager : public PlatformWindowManager
  31. {
  32. friend class Win32Window;
  33. virtual void _processCmdLineArgs(const S32 argc, const char **argv);
  34. /// Link the specified window into the window list.
  35. void linkWindow(Win32Window *w);
  36. /// Remove specified window from the window list.
  37. void unlinkWindow(Win32Window *w);
  38. /// Callback for the process list.
  39. void _process();
  40. /// List of allocated windows.
  41. Win32Window *mWindowListHead;
  42. /// Parent window, used in window setup in web plugin scenarios.
  43. HWND mParentWindow;
  44. /// set via command line -offscreen option, controls whether rendering/input
  45. // is intended for offscreen rendering
  46. bool mOffscreenRender;
  47. /// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on.
  48. // Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal.
  49. bool mDisplayWindow;
  50. /// Internal structure used when enumerating monitors
  51. struct MonitorInfo {
  52. HMONITOR monitorHandle;
  53. RectI region;
  54. String name;
  55. };
  56. /// Array of enumerated monitors
  57. Vector<MonitorInfo> mMonitors;
  58. /// Callback to receive information about available monitors.
  59. static BOOL CALLBACK MonitorEnumProc(
  60. HMONITOR hMonitor, // handle to display monitor
  61. HDC hdcMonitor, // handle to monitor DC
  62. LPRECT lprcMonitor, // monitor intersection rectangle
  63. LPARAM dwData // data
  64. );
  65. /// Callback to receive information about available monitor regions
  66. static BOOL CALLBACK MonitorRegionEnumProc(
  67. HMONITOR hMonitor, // handle to display monitor
  68. HDC hdcMonitor, // handle to monitor DC
  69. LPRECT lprcMonitor, // monitor intersection rectangle
  70. LPARAM dwData // data
  71. );
  72. /// If a curtain window is present, then its HWND will be stored here.
  73. HWND mCurtainWindow;
  74. SignalSlot<void()> mOnProcessSignalSlot;
  75. public:
  76. Win32WindowManager();
  77. ~Win32WindowManager();
  78. virtual RectI getPrimaryDesktopArea();
  79. virtual S32 getDesktopBitDepth();
  80. virtual Point2I getDesktopResolution();
  81. /// Build out the monitors list. Also used to rebuild the list after
  82. /// a WM_DISPLAYCHANGE message.
  83. virtual void buildMonitorsList();
  84. virtual S32 findFirstMatchingMonitor(const char* name);
  85. virtual U32 getMonitorCount();
  86. virtual const char* getMonitorName(U32 index);
  87. virtual RectI getMonitorRect(U32 index);
  88. virtual void getMonitorRegions(Vector<RectI> &regions);
  89. virtual PlatformWindow *createWindow(GFXDevice *device, const GFXVideoMode &mode);
  90. virtual void getWindows(VectorPtr<PlatformWindow*> &windows);
  91. virtual void setParentWindow(void* newParent);
  92. virtual void* getParentWindow();
  93. virtual PlatformWindow *getWindowById(WindowId id);
  94. virtual PlatformWindow *getFirstWindow();
  95. virtual PlatformWindow* getFocusedWindow();
  96. virtual void lowerCurtain();
  97. virtual void raiseCurtain();
  98. virtual void setDisplayWindow(bool set) { mDisplayWindow = set; }
  99. };
  100. #endif