Răsfoiți Sursa

termination of A2 by clicking the close button in the title barcan no longer hang the X11 event loop

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7893 8c9fc860-2736-0410-a75d-ab315db34111
eth.guenter 7 ani în urmă
părinte
comite
b3aa72b63b
3 a modificat fișierele cu 40 adăugiri și 3 ștergeri
  1. 1 1
      source/Release.Tool
  2. 11 2
      source/Unix.KbdMouse.Mod
  3. 28 0
      source/WMTerminator.Mod

+ 1 - 1
source/Release.Tool

@@ -1051,7 +1051,7 @@ PACKAGE GuiApplicationsMini ARCHIVE "GuiApplicationsMini.zip" SOURCE "GuiApplica
 	WMRestorable.Mod Release.Auto.dsk
 	WMApplications.Mod
 
-	WMDialogs.Mod
+	WMDialogs.Mod WMTerminator.Mod
 	WMDocumentEditor.Mod
 
 	WMErrors.Mod

+ 11 - 2
source/Unix.KbdMouse.Mod

@@ -6,7 +6,7 @@ MODULE KbdMouse;   (* g.f.	9.7.07 *)
 
 (* replacement for the keyboard and mouse drivers in the Unix ports *)
 
-IMPORT Machine, S := SYSTEM, Inputs, Plugins, X11, Displays, XDisplay, Api:=X11Api, Modules, Objects;
+IMPORT Machine, S := SYSTEM, Inputs, Plugins, X11, Displays, XDisplay, Commands, Api:=X11Api, Objects;
 
 CONST
 	ML = 0;  MM = 1;  MR = 2;
@@ -35,6 +35,14 @@ TYPE
 VAR
 	poll: Poll; keySymbol: ARRAY 256 OF LONGINT;
 	
+	PROCEDURE TerminateA2;
+	VAR
+		res: LONGINT;
+		s: ARRAY 256 OF CHAR;
+	BEGIN
+		Commands.Call( "WMTerminator.Shutdown", {}, res, s );
+	END TerminateA2;
+	
 
 	PROCEDURE CheckAlternateKeys( VAR mb: SET );
 	BEGIN
@@ -196,7 +204,8 @@ VAR
 					IF  S.VAL( X11.Atom,datal[0] ) = disp.wmDelete THEN									
 						(* shutdown *)
 						Machine.Release( Machine.X11 );
-						Modules.Shutdown( Modules.Reboot );
+						TerminateA2;
+					(*	Modules.Shutdown( Modules.Reboot ); *)
 					END; 
 			| Api.UnmapNotify:
 			| Api.MapNotify: 

+ 28 - 0
source/WMTerminator.Mod

@@ -0,0 +1,28 @@
+MODULE WMTerminator;  (** AUTHOR "GF"; PURPOSE "terminate A2"; *)
+
+IMPORT Modules, WMDialogs, Commands, Kernel;
+
+CONST
+	Ok = WMDialogs.ResOk;
+	Abort = WMDialogs.ResAbort;	
+
+PROCEDURE Shutdown*;
+VAR res: LONGINT;  msg: ARRAY 128 OF CHAR;
+	t: Kernel.Timer;
+BEGIN 
+	NEW( t );
+	IF  WMDialogs.Message( 1, "A2 terminator", "  Are you sure you want to stop A2 execution ?", {Ok, Abort} ) = Ok THEN
+		Commands.Call( "WMTerminator.Do", {}, res, msg );
+		
+		(* in case the termination handler (Modules.Shutdown) hangs, retry!*)
+		t.Sleep( 1000 );
+		Commands.Call( "WMTerminator.Do", {}, res, msg );
+	END;
+END Shutdown;
+
+PROCEDURE Do*;
+BEGIN
+	Modules.Shutdown( Modules.PowerDown );
+END Do;
+
+END WMTerminator.