diff options
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 1 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.cpp | 22 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.h | 35 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManager.cpp | 14 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 15 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 47 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowManager.cpp | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 1 |
9 files changed, 67 insertions, 73 deletions
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index ab974508145..b759b98f0bc 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -400,4 +400,3 @@ protected: }; #endif // _GHOST_ISYSTEM_H_ - diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index b566c1e38c8..7fd3a0971a5 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -39,14 +39,9 @@ #include "GHOST_Debug.h" // for testing lo-fi -#include "GHOST_EventPrinter.h" -#include <iostream> -using namespace std; - -GHOST_EventManager::GHOST_EventManager() -{ -} - +// #include "GHOST_EventPrinter.h" +// #include <iostream> +// using namespace std; GHOST_EventManager::~GHOST_EventManager() { @@ -110,14 +105,12 @@ GHOST_TSuccess GHOST_EventManager::pushEvent(GHOST_IEvent* event) bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) { // [mce] this variant switches the "handled" flag to work as described in the header - // it also stops after the first consumer has handled the event (no it doesn't) bool handled = false; if (event) { TConsumerVector::iterator iter; for (iter = m_consumers.begin(); iter != m_consumers.end(); iter++) { if ((*iter)->processEvent(event)) { handled = true; - // break; } } } @@ -125,7 +118,7 @@ bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) } #if 0 // disable to test a variant -bool GHOST_EventManager::dispatchEvent_original(GHOST_IEvent* event) +bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) /* original version */ { bool handled; if (event) { @@ -190,6 +183,7 @@ bool GHOST_EventManager::dispatchEvents_lo_fi() // cout << "\n--- lo-fi dispatch ---"; // cout << "\ndiscard:"; + while ((event = popEvent()) != NULL) { if (event->getType() == GHOST_kEventCursorMove) { // just a simple (x,y) pair, nothing much to adjust @@ -204,7 +198,7 @@ bool GHOST_EventManager::dispatchEvents_lo_fi() if (!dispatchEvent(event)) allHandled = false; } - + // finally dispatch the single cursor update if (cursorMove) { // cout << "\nsend:"; @@ -268,7 +262,7 @@ void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window) GHOST_IEvent* event = *iter; if (event->getWindow() == window) { - GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n"); + GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n"); /* * Found an event for this window, remove it. * The iterator will become invalid. @@ -293,7 +287,7 @@ void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* GHOST_IEvent* event = *iter; if ((event->getType() == type) && (!window || (event->getWindow() == window))) { - GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n"); + GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n"); /* * Found an event of this type for the window, remove it. * The iterator will become invalid. diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h index 5071adb1bd4..c73abed2f7e 100644 --- a/intern/ghost/intern/GHOST_EventManager.h +++ b/intern/ghost/intern/GHOST_EventManager.h @@ -53,32 +53,32 @@ public: /** * Constructor. */ - GHOST_EventManager(); + GHOST_EventManager() {}; /** * Destructor. */ - virtual ~GHOST_EventManager(); + ~GHOST_EventManager(); /** * Returns the number of events currently on the stack. * @return The number of events on the stack. */ - virtual GHOST_TUns32 getNumEvents(); + GHOST_TUns32 getNumEvents(); /** * Returns the number of events of a certain type currently on the stack. * @param type The type of events to be counted. * @return The number of events on the stack of this type. */ - virtual GHOST_TUns32 getNumEvents(GHOST_TEventType type); + GHOST_TUns32 getNumEvents(GHOST_TEventType type); /** * Return the event at the top of the stack without removal. * Do not delete the event! * @return The event at the top of the stack. */ - virtual GHOST_IEvent* peekEvent(); + GHOST_IEvent* peekEvent(); /** * Pushes an event on the stack. @@ -86,27 +86,27 @@ public: * Do not delete the event! * @param event The event to push on the stack. */ - virtual GHOST_TSuccess pushEvent(GHOST_IEvent* event); + GHOST_TSuccess pushEvent(GHOST_IEvent* event); /** * Dispatches the given event directly, bypassing the event stack. * @return Indication as to whether any of the consumers handled the event. */ - virtual bool dispatchEvent(GHOST_IEvent* event); + bool dispatchEvent(GHOST_IEvent* event); /** * Dispatches the event at the back of the stack. * The event will be removed from the stack. * @return Indication as to whether any of the consumers handled the event. */ - virtual bool dispatchEvent(); + bool dispatchEvent(); /** * Dispatches all the events on the stack. * The event stack will be empty afterwards. * @return Indication as to whether any of the consumers handled the events. */ - virtual bool dispatchEvents(); + bool dispatchEvents(); /** * Dispatches most events on the stack, consolidating cursor moves into a single move. @@ -115,29 +115,25 @@ public: */ bool dispatchEvents_lo_fi(); - /** * Adds a consumer to the list of event consumers. * @param consumer The consumer added to the list. * @return Indication as to whether addition has succeeded. */ - virtual GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer); + GHOST_TSuccess addConsumer(GHOST_IEventConsumer* consumer); /** * Removes a consumer from the list of event consumers. * @param consumer The consumer removed from the list. * @return Indication as to whether removal has succeeded. */ - virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer); + GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer); /** * Removes all events for a window from the stack. * @param window The window to remove events for. */ - virtual void - removeWindowEvents( - GHOST_IWindow* window - ); + void removeWindowEvents(GHOST_IWindow* window); /** * Removes all events of a certain type from the stack. @@ -146,11 +142,7 @@ public: * @param type The type of events to be removed. * @param window The window to remove the events for. */ - virtual void - removeTypeEvents( - GHOST_TEventType type, - GHOST_IWindow* window = 0 - ); + void removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window = 0); protected: /** @@ -179,4 +171,3 @@ protected: }; #endif // _GHOST_EVENT_MANAGER_H_ - diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index 1c00e991520..b14274278ad 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -55,8 +55,7 @@ void GHOST_NDOFManager::updateRotation(short r[3], GHOST_TUns64 time) void GHOST_NDOFManager::updateButtons(unsigned short buttons, GHOST_TUns64 time) { - GHOST_System* system = (GHOST_System*) GHOST_System::getSystem(); - GHOST_IWindow* window = system->getWindowManager()->getActiveWindow(); + GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); unsigned short diff = m_buttons ^ buttons; @@ -70,10 +69,9 @@ void GHOST_NDOFManager::updateButtons(unsigned short buttons, GHOST_TUns64 time) GHOST_TEventNDOFButtonData* data = (GHOST_TEventNDOFButtonData*) event->getData(); data->action = (buttons & mask) ? GHOST_kPress : GHOST_kRelease; -// data->pressed = buttons & mask; data->button = i + 1; -// printf("sending button %d %s\n", data->button, (data->action == GHOST_kPress) ? "pressed" : "released"); + // printf("sending button %d %s\n", data->button, (data->action == GHOST_kPress) ? "pressed" : "released"); m_system.pushEvent(event); } @@ -87,8 +85,7 @@ bool GHOST_NDOFManager::sendMotionEvent() if (m_atRest) return false; - GHOST_System* system = (GHOST_System*) GHOST_System::getSystem(); - GHOST_IWindow* window = system->getWindowManager()->getActiveWindow(); + GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); GHOST_EventNDOFMotion* event = new GHOST_EventNDOFMotion(m_motionTime, window); GHOST_TEventNDOFMotionData* data = (GHOST_TEventNDOFMotionData*) event->getData(); @@ -109,11 +106,10 @@ bool GHOST_NDOFManager::sendMotionEvent() data->dt = 0.001f * (m_motionTime - m_prevMotionTime); // in seconds - printf("dt = %d ms\n", (int)(m_motionTime - m_prevMotionTime)); - m_prevMotionTime = m_motionTime; -// printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f)\n", data->tx, data->ty, data->tz, data->rx, data->ry, data->rz); +// printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f\n", +// data->tx, data->ty, data->tz, data->rx, data->ry, data->rz, data->dt); m_system.pushEvent(event); diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 4e0888a87a7..a6b4e104c90 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -37,7 +37,6 @@ #include "GHOST_System.h" #include <time.h> -#include <stdio.h> /* just for printf */ #include "GHOST_DisplayManager.h" #include "GHOST_EventManager.h" @@ -196,18 +195,16 @@ bool GHOST_System::getFullScreen(void) bool GHOST_System::dispatchEvents() { + bool handled = false; + // NDOF Motion event is sent only once per dispatch, so do it now: - m_ndofManager->sendMotionEvent(); + handled |= m_ndofManager->sendMotionEvent(); - bool handled; if (m_eventManager) { if (m_input_fidelity_hint == LO_FI) - handled = m_eventManager->dispatchEvents_lo_fi(); + handled |= m_eventManager->dispatchEvents_lo_fi(); else - handled = m_eventManager->dispatchEvents(); - } - else { - handled = false; + handled |= m_eventManager->dispatchEvents(); } m_timerManager->fireTimers(getMilliSeconds()); @@ -276,8 +273,6 @@ GHOST_TSuccess GHOST_System::init() m_timerManager = new GHOST_TimerManager (); m_windowManager = new GHOST_WindowManager (); m_eventManager = new GHOST_EventManager (); -// m_ndofManager = new GHOST_NDOFManager(); -// Each platform now has their own NDOFManager subclass #ifdef GHOST_DEBUG if (m_eventManager) { diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index c1c6f874222..bb9b3ec450e 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -38,7 +38,7 @@ #include <stdio.h> // for debug [mce] -#define _WIN32_IE 0x501 /* shipped before XP, so doesn't impose additional req'm'ts */ +#define _WIN32_IE 0x501 /* shipped before XP, so doesn't impose additional requirements */ #include <shlobj.h> @@ -113,7 +113,7 @@ GHOST_SystemWin32::GHOST_SystemWin32() // Require COM for GHOST_DropTargetWin32 created in GHOST_WindowWin32. OleInitialize(0); - m_input_fidelity_hint = HI_FI; // just for testing... + m_input_fidelity_hint = LO_FI; // just for testing... // register for RawInput devices RAWINPUTDEVICE devices[1]; @@ -180,10 +180,8 @@ GHOST_IWindow* GHOST_SystemWin32::createWindow( window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples); if (window) { if (window->getValid()) { - // Store the pointer to the window -// if (state != GHOST_kWindowStateFullScreen) { - m_windowManager->addWindow(window); -// } + m_windowManager->addWindow(window); + m_windowManager->setActiveWindow(window); } else { // An invalid window could be one that was used to test for AA @@ -595,7 +593,15 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, bool k GHOST_Event* GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_IWindow* window) { - return new GHOST_Event(getSystem()->getMilliSeconds(), type, window); + GHOST_System* system = (GHOST_System*)getSystem(); + + if (type == GHOST_kEventWindowActivate) + { + puts("activating window"); + system->getWindowManager()->setActiveWindow(window); + } + + return new GHOST_Event(system->getMilliSeconds(), type, window); } GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType, @@ -645,13 +651,12 @@ vendor ID No other registered devices use the c62_ space, so a simple mask will work! */ - // The NDOF manager sends button changes immediately, and *pretends* to // send motion. Mark as 'sent' so motion will always get dispatched. eventSent = true; // multiple events per RAWHID? MSDN hints at this. - printf("%d events\n", (int)raw.data.hid.dwCount); + // printf("%d events\n", (int)raw.data.hid.dwCount); BYTE const* data = &raw.data.hid.bRawData; // MinGW's definition (below) doesn't agree with MSDN reference for bRawData: @@ -688,6 +693,7 @@ No other registered devices use the c62_ space, so a simple mask will work! { unsigned short buttons; memcpy(&buttons, data + 1, sizeof(buttons)); +#if 0 printf("buttons:"); if (buttons) { @@ -699,6 +705,7 @@ No other registered devices use the c62_ space, so a simple mask will work! } else printf(" none\n"); +#endif m_ndofManager->updateButtons(buttons, getMilliSeconds()); break; } @@ -999,8 +1006,20 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM case WM_INPUT: { - puts("WM_INPUT"); + // Raw mouse input benefitted from the buffered method, + // but SpaceNav gets along fine (better, even) grabbing single events. + RAWINPUT raw; + RAWINPUT* raw_ptr = &raw; + UINT rawSize = sizeof(RAWINPUT); + + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw_ptr, &rawSize, sizeof(RAWINPUTHEADER)); + eventSent |= processRawInput(raw, window); + + // necessary? + // DefRawInputProc(&raw_ptr, 1, sizeof(RAWINPUTHEADER)); + +#if 0 #define RAWCOUNT 10 // just a guess that we'll receive up to 10 event reports // the following code fetches all available, 10 at a time @@ -1028,20 +1047,20 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM RAWINPUT const& raw = rawBuffer[i]; eventSent |= processRawInput(raw, window); } - + // clear processed events from the queue DefRawInputProc((RAWINPUT**)&rawBuffer, n, sizeof(RAWINPUTHEADER)); } } +#endif break; } case WM_MOUSEWHEEL: - puts("WM_MOUSEWHEEL"); /* The WM_MOUSEWHEEL message is sent to the focus window * when the mouse wheel is rotated. The DefWindowProc * function propagates the message to the window's parent. * There should be no internal forwarding of the message, - * since DefWindowProc propagates it up the parent chain + * since DefWindowProc propagates it up the parent chain * until it finds a window that processes it. */ event = processWheelEvent(window, wParam, lParam); @@ -1102,7 +1121,7 @@ bool GHOST_SystemWin32::handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM case WM_PAINT: /* An application sends the WM_PAINT message when the system or another application * makes a request to paint a portion of an application's window. The message is sent - * when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage + * when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage * function when the application obtains a WM_PAINT message by using the GetMessage or * PeekMessage function. */ diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index 1ac357ac97f..aa932663e16 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -212,4 +212,4 @@ bool GHOST_WindowManager::getAnyModifiedState() } return isAnyModified; -}
\ No newline at end of file +} diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8dd901d9e54..874a2f778f5 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -27,7 +27,6 @@ */ #include <string.h> -#include <stdio.h> #include <math.h> #include <float.h> @@ -879,6 +878,7 @@ static int viewndof_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } +#if 0 static int viewndof_invoke_1st_try(bContext *C, wmOperator *op, wmEvent *event) { wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; @@ -961,6 +961,7 @@ static int viewndof_invoke_2nd_try(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } +#endif void VIEW3D_OT_ndof(struct wmOperatorType *ot) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e281e65539e..bce1cc22f7f 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <stdio.h> // [mce] debug, remove when finished #include "DNA_listBase.h" #include "DNA_screen_types.h" |