Browse Source

Simplified window message handling related to activation/inactivation and minimizing the window.
Combined Activated & Inactivated events into the Activation event and moved it to GraphicsEvents.

Lasse Öörni 14 years ago
parent
commit
486d4902c8

+ 2 - 2
Engine/Core/Variant.h

@@ -181,14 +181,14 @@ public:
         *this = (int)value;
     }
     
-    /// Construct from a StringHash (convert to integer)
+    /// Construct from a string hash (convert to integer)
     Variant(const StringHash& value) :
         type_(VAR_NONE)
     {
         *this = (int)value.GetValue();
     }
     
-    /// Construct from a ShortStringHash (convert to integer)
+    /// Construct from a short string hash (convert to integer)
     Variant(const ShortStringHash& value) :
         type_(VAR_NONE)
     {

+ 7 - 0
Engine/Graphics/GraphicsEvents.h

@@ -35,6 +35,13 @@ EVENT(E_WINDOWMESSAGE, WindowMessage)
     PARAM(P_HANDLED, Handled);            // bool
 }
 
+/// Application activation state changed. Sent by the Input subsystem
+EVENT(E_ACTIVATION, Activation)
+{
+    PARAM(P_ACTIVE, Active);              // bool
+    PARAM(P_MINIMIZED, Minimized);        // bool
+}
+
 /// New screen mode set
 EVENT(E_SCREENMODE, ScreenMode)
 {

+ 13 - 20
Engine/Input/Input.cpp

@@ -241,7 +241,12 @@ void Input::MakeActive()
     SetClipCursor(clipCursor_);
     SetCursorVisible(false);
     
-    SendEvent(E_ACTIVATED);
+    using namespace Activation;
+    
+    VariantMap eventData;
+    eventData[P_ACTIVE] = active_;
+    eventData[P_MINIMIZED] = minimized_;
+    SendEvent(E_ACTIVATION, eventData);
 }
 
 void Input::MakeInactive()
@@ -259,7 +264,12 @@ void Input::MakeInactive()
     ClipCursor(0);
     SetCursorVisible(true);
     
-    SendEvent(E_INACTIVATED);
+    using namespace Activation;
+    
+    VariantMap eventData;
+    eventData[P_ACTIVE] = active_;
+    eventData[P_MINIMIZED] = minimized_;
+    SendEvent(E_ACTIVATION, eventData);
 }
 
 void Input::clearState()
@@ -468,12 +478,9 @@ void Input::HandleWindowMessage(StringHash eventType, VariantMap& eventData)
         break;
         
     case WM_ACTIVATE:
+        minimized_ = HIWORD(wParam) != 0;
         if (LOWORD(wParam) == WA_INACTIVE)
-        {
             MakeInactive();
-            if (graphics_->GetFullscreen())
-                minimized_ = true;
-        }
         else
         {
             if (!minimized_)
@@ -482,20 +489,6 @@ void Input::HandleWindowMessage(StringHash eventType, VariantMap& eventData)
         eventData[P_HANDLED] = true;
         break;
         
-    case WM_SIZE:
-        if (wParam == SIZE_MINIMIZED)
-        {
-            minimized_ = true;
-            MakeInactive();
-        }
-        if ((wParam == SIZE_RESTORED) || (wParam == SIZE_MAXIMIZED))
-        {
-            minimized_ = false;
-            activated_ = true;
-        }
-        eventData[P_HANDLED] = true;
-        break;
-        
     case WM_KEYDOWN:
         SetKey(wParam, true);
         eventData[P_HANDLED] = true;

+ 0 - 10
Engine/Input/InputEvents.h

@@ -25,16 +25,6 @@
 
 #include "Object.h"
 
-/// Application activated
-EVENT(E_ACTIVATED, Activated)
-{
-}
-
-/// Application inactivated
-EVENT(E_INACTIVATED, Inactivated)
-{
-}
-
 /// Mouse button pressed
 EVENT(E_MOUSEBUTTONDOWN, MouseButtonDown)
 {

+ 1 - 1
Engine/Math/BoundingBox.h

@@ -53,7 +53,7 @@ public:
     {
     }
     
-    /// Construct from a Rect, with the Z dimension left zero
+    /// Construct from a rect, with the Z dimension left zero
     BoundingBox(const Rect& rect) :
         min_(Vector3(rect.min_, 0.0f)),
         max_(Vector3(rect.max_, 0.0f)),

+ 1 - 1
Engine/Math/Vector4.h

@@ -43,7 +43,7 @@ public:
     {
     }
     
-    /// Construct from a Vector3 and the W coordinate
+    /// Construct from a 3-dimensional vector and the W coordinate
     Vector4(const Vector3& vector, float w) :
         x_(vector.x_),
         y_(vector.y_),