From fb579fa9489428835a62e8e4ef4679bd1c740ea8 Mon Sep 17 00:00:00 2001
From: Rodrigo Braz Monteiro <zeratul@cellosoft.com>
Date: Tue, 21 Feb 2006 21:33:15 +0000
Subject: [PATCH] Audio display in SSA mode will no longer ignore clicks if it
 wasn't focused

Originally committed to SVN as r98.
---
 core/audio_display.cpp | 18 +++++++++++++++---
 core/audio_display.h   |  1 +
 core/changelog.txt     |  1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/core/audio_display.cpp b/core/audio_display.cpp
index caacb3e88..5b04e98ca 100644
--- a/core/audio_display.cpp
+++ b/core/audio_display.cpp
@@ -73,6 +73,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent,VideoDisplay *display)
 	loaded = false;
 	blockUpdate = false;
 	dontReadTimes = false;
+	holding = false;
 	Position = 0;
 	PositionSample = 0;
 	oldCurPos = 0;
@@ -1079,6 +1080,16 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
 		if (wxWindow::FindFocus() != this && Options.AsBool(_T("Audio Autofocus"))) SetFocus();
 	}
 
+	// Click type
+	if (event.ButtonDown(wxMOUSE_BTN_LEFT) && !holding) {
+		holding = true;
+		CaptureMouse();
+	}
+	if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT) && holding) {
+		holding = false;
+		ReleaseMouse();
+	}
+
 	// Mouse wheel
 	if (event.GetWheelRotation() != 0) {
 		// Zoom or scroll?
@@ -1152,14 +1163,15 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
 
 	// Left click
 	if (event.ButtonDown(wxMOUSE_BTN_LEFT)) {
-		if (wxWindow::FindFocus() != this) {
+		//if (wxWindow::FindFocus() != this) {
 			SetFocus();
-			return;
-		}
+			//return;
+		//}
 	}
 
 	// Right click
 	if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) {
+		SetFocus();
 		if (karaoke->enabled) {
 			int syl = GetSyllableAtX(x);
 			if (syl != -1) {
diff --git a/core/audio_display.h b/core/audio_display.h
index 2960ea342..03f4f85d0 100644
--- a/core/audio_display.h
+++ b/core/audio_display.h
@@ -76,6 +76,7 @@ private:
 	bool hasSel;
 	bool hasKaraoke;
 	bool diagUpdated;
+	bool holding;
 	__int64 selStart;
 	__int64 selEnd;
 	__int64 lineStart;
diff --git a/core/changelog.txt b/core/changelog.txt
index 762393f92..f9cbcd07a 100644
--- a/core/changelog.txt
+++ b/core/changelog.txt
@@ -41,6 +41,7 @@ Please visit http://aegisub.net to download latest version
 - Added a volume slider bar to audio mode. (AMZ)
 - Fixed some internal workings, which should make Aegisub use considerably less RAM (especially for large Karaoke files, 3x less RAM usage measured). (AMZ)
 - Aegisub will now dump the stack to stack.txt when it crashes with a fatal exception, which might or might not work. (AMZ)
+- Audio display in SSA mode will no longer ignore clicks if it wasn't focused (AMZ)
 
 
 = 1.09 beta - 2006.01.16 ===========================