10.08.2013 Views

Bachelor Thesis - Computer Graphics Group

Bachelor Thesis - Computer Graphics Group

Bachelor Thesis - Computer Graphics Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Global uniqueness of the statically linked library instance inside the main<br />

application is guarded by a system-wide mutex. The mutex is destroyed automatically<br />

in case the application crashes. Hence, the library initializes correctly<br />

after the application has been restarted. No false reports of a previous<br />

instance are reported. In case a previous instance exists, the GesturesHook::instance()<br />

method throws an exception.<br />

The gesture detection algorithm is based on a finite state machine. Transitions<br />

between states occur in response to mouse input events, in context of the<br />

mouse-hook callback function. The states are listed and described in figure<br />

4.1. The actual finite state machine, showing all possible state transitions, can<br />

be seen in figure 4.2.<br />

Uninitialized<br />

Idle<br />

Ignored<br />

GesturePending<br />

GestureActive<br />

GestureBroken<br />

Cancelled<br />

Terminated<br />

•Initial state after the class instantiation. The mouse hook is<br />

inactive.<br />

•The mouse hook is active, no gesture is in progress. The<br />

library waits for the toggle button to be pressed.<br />

•The current gesture has been ignored. Either automatically,<br />

manually or by the main application's decision.<br />

•The gesture toggle button is pressed, but the mouse cursor<br />

has not been moved at least the activation distance.<br />

•A gesture is active, mouse movement events are being<br />

reported to the main application.<br />

•The toggle button has already been released, but no<br />

button up event has been received.<br />

•The gesture has been cancelled by the user or by the<br />

timeout timer.<br />

•Final state. The hook has been released.<br />

Figure 4.1: Finite state machine states<br />

According to the specification, the user must be able to click the toggle button<br />

without starting a gesture. When the toggle button is pressed, the event is<br />

filtered and the affected window does not receive the message. When the<br />

button is released, this event has to be filtered too. If not, the application<br />

would only receive a button up message without a preceding button down<br />

message. The button down message has to be sent manually. Care has to<br />

be taken not to activate the gesture processing again. The state switches to<br />

Ignored meanwhile. Otherwise, the event handling would hang in an endless<br />

loop. At first, a simple PostMessage call has been used. However, the results<br />

were not correct, as seen in the Spy++ application included with Visual Studio.<br />

25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!