[Bf-blender-cvs] [6cb692f] master: cleanup: ghost Win32 event processing functions

Mike Erwin noreply at git.blender.org
Fri Feb 27 01:54:23 CET 2015


Commit: 6cb692f48ebe0f68c86a7de710b0b682cf868b4f
Author: Mike Erwin
Date:   Thu Feb 26 19:53:55 2015 -0500
Branches: master
https://developer.blender.org/rB6cb692f48ebe0f68c86a7de710b0b682cf868b4f

cleanup: ghost Win32 event processing functions

Removed window arg from key conversion functions.

Removed processModifierKeys declaration since that function was
apparently never implemented.

Using Win32-specific classes instead of their generic superclass -- this
helps in a few cases like WinTab.

===================================================================

M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemWin32.h

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 650107e..e6cdda1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -235,7 +235,7 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(
         const bool exclusive,
         const GHOST_TEmbedderWindowID parentWindow)
 {
-	GHOST_Window *window =
+	GHOST_WindowWin32 *window =
 		new GHOST_WindowWin32(
 		        this,
 		        title,
@@ -432,7 +432,7 @@ GHOST_TSuccess GHOST_SystemWin32::exit()
 	return GHOST_System::exit();
 }
 
-GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const &raw, int *keyDown, char *vk)
+GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw, int *keyDown, char *vk)
 {
 	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 	GHOST_TKey key = GHOST_kKeyUnknown;
@@ -444,7 +444,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const &raw
 	unsigned int msg = raw.data.keyboard.Message;
 	*keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK) && msg != WM_KEYUP && msg != WM_SYSKEYUP;
 
-	key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0)));
+	key = this->convertKey(raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags & (RI_KEY_E1 | RI_KEY_E0)));
 	
 	// extra handling of modifier keys: don't send repeats out from GHOST
 	if (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt) {
@@ -509,7 +509,7 @@ GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const &raw
 //! note: this function can be extended to include other exotic cases as they arise.
 // This function was added in response to bug [#25715]
 // This is going to be a long list [T42426]
-GHOST_TKey GHOST_SystemWin32::processSpecialKey(GHOST_IWindow *window, short vKey, short scanCode) const
+GHOST_TKey GHOST_SystemWin32::processSpecialKey(short vKey, short scanCode) const
 {
 	GHOST_TKey key = GHOST_kKeyUnknown;
 	switch (PRIMARYLANGID(m_langId)) {
@@ -525,7 +525,7 @@ GHOST_TKey GHOST_SystemWin32::processSpecialKey(GHOST_IWindow *window, short vKe
 	return key;
 }
 
-GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, short scanCode, short extend) const
+GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short extend) const
 {
 	GHOST_TKey key;
 
@@ -633,7 +633,7 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor
 			case VK_SCROLL: key = GHOST_kKeyScrollLock; break;
 			case VK_CAPITAL: key = GHOST_kKeyCapsLock; break;
 			case VK_OEM_8:
-				key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(window, vKey, scanCode);
+				key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode);
 				break;
 			case VK_MEDIA_PLAY_PAUSE: key = GHOST_kKeyMediaPlay; break;
 			case VK_MEDIA_STOP: key = GHOST_kKeyMediaStop; break;
@@ -650,18 +650,17 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, short vKey, shor
 
 GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(
         GHOST_TEventType type,
-        GHOST_IWindow *window,
+        GHOST_WindowWin32 *window,
         GHOST_TButtonMask mask)
 {
 	return new GHOST_EventButton(getSystem()->getMilliSeconds(), type, window, mask);
 }
 
 
-GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow)
+GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
 {
 	GHOST_TInt32 x_screen, y_screen;
 	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *) getSystem();
-	GHOST_WindowWin32 *window = (GHOST_WindowWin32 *) Iwindow;
 	
 	system->getCursorPosition(x_screen, y_screen);
 
@@ -713,7 +712,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type,
 }
 
 
-GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam)
+GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
 {
 	// short fwKeys = LOWORD(wParam);			// key flags
 	int zDelta = (short) HIWORD(wParam);    // wheel rotation
@@ -728,12 +727,12 @@ GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WP
 }
 
 
-GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const &raw)
+GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
 {
 	int keyDown = 0;
 	char vk;
 	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
-	GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
+	GHOST_TKey key = system->hardKey(raw, &keyDown, &vk);
 	GHOST_EventKey *event;
 
 	if (key != GHOST_kKeyUnknown) {
@@ -780,22 +779,22 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
 }
 
 
-GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_IWindow *window)
+GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
 {
-	GHOST_System *system = (GHOST_System *)getSystem();
+	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 
 	if (type == GHOST_kEventWindowActivate) {
 		system->getWindowManager()->setActiveWindow(window);
-		((GHOST_WindowWin32 *)window)->bringTabletContextToFront();
+		window->bringTabletContextToFront();
 	}
 
 	return new GHOST_Event(system->getMilliSeconds(), type, window);
 }
 
 #ifdef WITH_INPUT_IME
-GHOST_Event *GHOST_SystemWin32::processImeEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TEventImeData *data)
+GHOST_Event *GHOST_SystemWin32::processImeEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TEventImeData *data)
 {
-	GHOST_System *system = (GHOST_System *)getSystem();
+	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 	return new GHOST_EventIME(system->getMilliSeconds(), type, window, data);
 }
 #endif
@@ -804,11 +803,11 @@ GHOST_Event *GHOST_SystemWin32::processImeEvent(GHOST_TEventType type, GHOST_IWi
 GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(
         GHOST_TEventType eventType,
         GHOST_TDragnDropTypes draggedObjectType,
-        GHOST_IWindow *window,
+        GHOST_WindowWin32 *window,
         int mouseX, int mouseY,
         void *data)
 {
-	GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem());
+	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 	return system->pushEvent(new GHOST_EventDragnDrop(system->getMilliSeconds(),
 	                                                  eventType,
 	                                                  draggedObjectType,
@@ -912,7 +911,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
 	bool eventHandled = false;
 
 	LRESULT lResult = 0;
-	GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem());
+	GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 	GHOST_EventManager *eventManager = system->getEventManager();
 	GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized");
 
@@ -1068,11 +1067,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
 				// Tablet events, processed
 				////////////////////////////////////////////////////////////////////////
 				case WT_PACKET:
-					((GHOST_WindowWin32 *)window)->processWin32TabletEvent(wParam, lParam);
+					window->processWin32TabletEvent(wParam, lParam);
 					break;
 				case WT_CSRCHANGE:
 				case WT_PROXIMITY:
-					((GHOST_WindowWin32 *)window)->processWin32TabletInitEvent();
+					window->processWin32TabletInitEvent();
 					break;
 				////////////////////////////////////////////////////////////////////////
 				// Mouse events, processed
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 3374b39..e615ef1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -53,6 +53,8 @@ class GHOST_EventWheel;
 class GHOST_EventWindow;
 class GHOST_EventDragnDrop;
 
+class GHOST_WindowWin32;
+
 /**
  * WIN32 Implementation of GHOST_System class.
  * \see GHOST_System.
@@ -203,7 +205,7 @@ public:
 	 * \param window The window on which the event occurred
 	 * \return Indication whether the event was handled.
 	 */
-	static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_IWindow *window, int mouseX, int mouseY, void *data);
+	static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowWin32 *window, int mouseX, int mouseY, void *data);
 	
 /**
  * Confirms quitting he program when there is just one window left open
@@ -227,32 +229,21 @@ protected:
 	
 	/**
 	 * Converts raw WIN32 key codes from the wndproc to GHOST keys.
-	 * \param window->	The window for this handling
 	 * \param vKey		The virtual key from hardKey
-	 * \param ScanCode	The ScanCode of pressed key (simular to PS/2 Set 1)
+	 * \param ScanCode	The ScanCode of pressed key (similar to PS/2 Set 1)
 	 * \param extend	Flag if key is not primly (left or right)
 	 * \return The GHOST key (GHOST_kKeyUnknown if no match).
 	 */
-	GHOST_TKey convertKey(GHOST_IWindow *window, short vKey, short ScanCode, short extend) const;
+	GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
 
 	/**
 	 * Catches raw WIN32 key codes from WM_INPUT in the wndproc.
-	 * \param window	The window for this handling
 	 * \param raw		RawInput structure with detailed info about the key event
 	 * \param keyDown	Pointer flag that specify if a key is down
 	 * \param vk		Pointer to virtual key
 	 * \return The GHOST key (GHOST_kKeyUnknown if no match).
 	 */
-	GHOST_TKey hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int *keyDown, char *vk);
-
-	/**
-	 * Creates modifier key event(s) and updates the key data stored locally (m_modifierKeys).
-	 * With the modifier keys, we want to distinguish left and right keys.
-	 * Sometimes this is not possible (Windows ME for instance). Then, we want
-	 * events generated for both keys.
-	 * \param window	The w

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list