1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef WindowDefs_h__ 7 #define WindowDefs_h__ 8 9 /* 10 * nsWindowDefs - nsWindow related definitions, consts, and macros. 11 */ 12 13 #include "mozilla/widget/WinMessages.h" 14 #include "nsBaseWidget.h" 15 #include "nsdefs.h" 16 #include "resource.h" 17 18 /************************************************************** 19 * 20 * SECTION: defines 21 * 22 **************************************************************/ 23 24 // ConstrainPosition window positioning slop value 25 #define kWindowPositionSlop 20 26 27 // Origin of the system context menu when displayed in full screen mode 28 #define MOZ_SYSCONTEXT_X_POS 20 29 #define MOZ_SYSCONTEXT_Y_POS 20 30 31 // Don't put more than this many rects in the dirty region, just fluff 32 // out to the bounding-box if there are more 33 #define MAX_RECTS_IN_REGION 100 34 35 // Tablet PC Mouse Input Source 36 #define TABLET_INK_SIGNATURE 0xFFFFFF00 37 #define TABLET_INK_CHECK 0xFF515700 38 #define TABLET_INK_TOUCH 0x00000080 39 #define TABLET_INK_ID_MASK 0x0000007F 40 #define MOUSE_INPUT_SOURCE() WinUtils::GetMouseInputSource() 41 #define MOUSE_POINTERID() WinUtils::GetMousePointerID() 42 43 /************************************************************** 44 * 45 * SECTION: enums 46 * 47 **************************************************************/ 48 49 // nsWindow::sCanQuit 50 typedef enum { TRI_UNKNOWN = -1, TRI_FALSE = 0, TRI_TRUE = 1 } TriStateBool; 51 52 /************************************************************** 53 * 54 * SECTION: constants 55 * 56 **************************************************************/ 57 58 /* 59 * Native windows class names 60 * 61 * ::: IMPORTANT ::: 62 * 63 * External apps and drivers depend on window class names. 64 * For example, changing the window classes could break 65 * touchpad scrolling or screen readers. 66 */ 67 const uint32_t kMaxClassNameLength = 40; 68 const wchar_t kClassNameHidden[] = L"MozillaHiddenWindowClass"; 69 const wchar_t kClassNameGeneral[] = L"MozillaWindowClass"; 70 const wchar_t kClassNameDialog[] = L"MozillaDialogClass"; 71 const wchar_t kClassNameDropShadow[] = L"MozillaDropShadowWindowClass"; 72 const wchar_t kClassNameTemp[] = L"MozillaTempWindowClass"; 73 const wchar_t kClassNameTransition[] = L"MozillaTransitionWindowClass"; 74 75 /************************************************************** 76 * 77 * SECTION: structs 78 * 79 **************************************************************/ 80 81 // Used for synthesizing events 82 struct KeyPair { 83 uint8_t mGeneral; 84 uint8_t mSpecific; 85 uint16_t mScanCode; KeyPairKeyPair86 KeyPair(uint32_t aGeneral, uint32_t aSpecific) 87 : mGeneral(aGeneral & 0xFF), 88 mSpecific(aSpecific & 0xFF), 89 mScanCode((aGeneral & 0xFFFF0000) >> 16) {} KeyPairKeyPair90 KeyPair(uint8_t aGeneral, uint8_t aSpecific, uint16_t aScanCode) 91 : mGeneral(aGeneral), mSpecific(aSpecific), mScanCode(aScanCode) {} 92 }; 93 94 #if (WINVER < 0x0600) 95 struct TITLEBARINFOEX { 96 DWORD cbSize; 97 RECT rcTitleBar; 98 DWORD rgstate[CCHILDREN_TITLEBAR + 1]; 99 RECT rgrect[CCHILDREN_TITLEBAR + 1]; 100 }; 101 #endif 102 103 namespace mozilla { 104 namespace widget { 105 106 struct MSGResult { 107 // Result for the message. 108 LRESULT& mResult; 109 // If mConsumed is true, the caller shouldn't call next wndproc. 110 bool mConsumed; 111 112 explicit MSGResult(LRESULT* aResult = nullptr) 113 : mResult(aResult ? *aResult : mDefaultResult), mConsumed(false) {} 114 115 private: 116 LRESULT mDefaultResult; 117 }; 118 119 } // namespace widget 120 } // namespace mozilla 121 122 /************************************************************** 123 * 124 * SECTION: macros 125 * 126 **************************************************************/ 127 128 #define NSRGB_2_COLOREF(color) \ 129 RGB(NS_GET_R(color), NS_GET_G(color), NS_GET_B(color)) 130 #define COLOREF_2_NSRGB(color) \ 131 NS_RGB(GetRValue(color), GetGValue(color), GetBValue(color)) 132 133 #define VERIFY_WINDOW_STYLE(s) \ 134 NS_ASSERTION(((s) & (WS_CHILD | WS_POPUP)) != (WS_CHILD | WS_POPUP), \ 135 "WS_POPUP and WS_CHILD are mutually exclusive") 136 137 #endif /* WindowDefs_h__ */ 138