From 7c4990bd81fb864ec48faabdad6b15bac5bed9a3 Mon Sep 17 00:00:00 2001
From: "Kirill Lipatov (Leency)" <lipatov.kiril@gmail.com>
Date: Tue, 19 May 2020 21:39:09 +0000
Subject: [PATCH] sysmon: kill process by delete key @icon: fix old issue with
 accedental icon click when user moved clicked mouse from active window

git-svn-id: svn://kolibrios.org@7956 a494cfbc-eb01-0410-851d-a64ba20cac60
---
 programs/cmm/sysmon/process.h     | 12 +++++++++---
 programs/system/icon_new/icon.asm | 15 +++++++++++----
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/programs/cmm/sysmon/process.h b/programs/cmm/sysmon/process.h
index c55f0caad7..99a55e9546 100644
--- a/programs/cmm/sysmon/process.h
+++ b/programs/cmm/sysmon/process.h
@@ -45,6 +45,7 @@ void Processes__Main()
 			break;
 		case evKey:
 			Sysmon__KeyEvent();
+			if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess();
 			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
 			break;
 		case evButton:
@@ -54,9 +55,7 @@ void Processes__Main()
 				SelectList_LineChanged();
 			}
 			if (BTN_ID_KILL_PROCESS == btn) {
-				KillProcess(current_process_id);
-				pause(10);
-				SelectList_LineChanged(); 
+				EventKillCurrentProcess();
 			}
 			if (BTN_ID_SHOW_PROCESS_INFO == btn) {
 				io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); 
@@ -88,6 +87,13 @@ void Processes__Main()
 	}
 }
 
+void EventKillCurrentProcess()
+{
+	KillProcess(current_process_id);
+	pause(10);
+	SelectList_LineChanged(); 
+}
+
 void Processes__GetProcessList()
 {
 	int i, j;
diff --git a/programs/system/icon_new/icon.asm b/programs/system/icon_new/icon.asm
index 33f94063f7..0da9a1684d 100644
--- a/programs/system/icon_new/icon.asm
+++ b/programs/system/icon_new/icon.asm
@@ -196,10 +196,17 @@ MSGMouse:
 	mov	[MouseX],ebx
 
 
-	mcall	37,2
-	test	al,001b
-	jnz	LButtonPress
-	test	al,010b
+	mcall 37,3
+	test  eax,1b ; bit 0 is set = left button is held
+	jnz   @f
+	jmp   CheckRB
+@@:
+	test  eax,100000000b ; bit 8 is set = left button is pressed
+	jnz   @f
+	jmp   CheckRB
+@@:
+	jnz   LButtonPress
+CheckRB:
 	jnz	RButtonPress
 	jmp	messages