From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-2?q?Rafa=B3_Cygnarowski?= Subject: Re: Trapping dosemu exit Date: Wed, 30 Jan 2008 12:19:48 +0100 Message-ID: <200801301219.53908.zswi@pers.pl> References: <1196829301.19107.9.camel@bambang-desktop> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1755354.NpZp7HQFLr"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1196829301.19107.9.camel@bambang-desktop> Sender: linux-msdos-owner@vger.kernel.org List-ID: To: linux-msdos@vger.kernel.org, bambang --nextPart1755354.NpZp7HQFLr Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dnia =B6roda, 5 grudnia 2007, bambang napisa=B3: > Hi all, > > We use dosemu 1.4.0 to access Novell Netware in Graphics terminal. > > Everything goes well except one little problem: It's often the users > exit the dosemu by directly closing the dosemu window thus not logging > out from the novell connection. Obviously, the novell connection still > left opened and causing problems. > > Is there a way to trap dosemu terminating event, so we can force a > logout or warn the user and reject the termination. Because I suffer from the same reason and I found a little bit time to solve this problem, here is a patch for X plugin (and only X and not SDL).=20 Please use it with caution - it's not well tested yet. =2D------------------------------------------------------------------------= =2D------- diff -Nur dosemu-1.4.0.orig/src/plugin/X/X.c dosemu-1.4.0.chng/src/plugin/X= /X.c =2D-- dosemu-1.4.0.orig/src/plugin/X/X.c 2007-05-04 07:59:48.000000000 +0200 +++ dosemu-1.4.0.chng/src/plugin/X/X.c 2008-01-30 12:09:47.000000000 +0100 @@ -383,6 +383,9 @@ static Atom comm_atom =3D None; static Boolean kdos_client =3D FALSE; /* started by kdos */ =20 +static Boolean about_to_quit =3D FALSE; +extern struct text_system Text_X; +void (*Draw_cursor_backup)(int x, int y, Bit8u attr, int first, int last, = Boolean focus); =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= */ =20 @@ -1434,6 +1437,7 @@ =20 case FocusIn: X_printf("X: focus in\n"); + if (about_to_quit) break; if (vga.mode_class =3D=3D TEXT) text_gain_focus(); if (config.X_background_pause && !dosemu_user_froze) unfreeze_dosemu (); have_focus =3D TRUE; @@ -1441,6 +1445,7 @@ =20 case FocusOut: X_printf("X: focus out\n"); + if (about_to_quit) break; if (mainwindow =3D=3D fullscreenwindow) break; if (vga.mode_class =3D=3D TEXT) text_lose_focus(); output_byte_8042(port60_buffer | 0x80); @@ -1458,9 +1463,36 @@ * atom, it means the window manager wants us to die. */ if(e.xclient.message_type =3D=3D proto_atom && *e.xclient.data.l =3D=3D= delete_atom) { + int i; + X_printf("X: got window delete message\n"); =2D /* XXX - Is it ok to call this from a SIGALRM handler? */ =2D leavedos(0); + + if (about_to_quit) + break; + + about_to_quit =3D TRUE; + Draw_cursor_backup =3D Text_X.Draw_cursor; + Text_X.Draw_cursor =3D NULL; + freeze_dosemu(); + + for (i =3D 0; i < 12; i++) + Text_X.Draw_string(14, i+6, " = " , 52, 0xf0); + + Text_X.Draw_string(15, 7, " = " , 50, 0x4f); + Text_X.Draw_string(15, 8, " You are about to abort DosEmu session. = " , 50, 0x4f); + Text_X.Draw_string(15, 9, " This is not recomended way for closing D= osEmu. " , 50, 0x4f); + Text_X.Draw_string(15, 10, " Close all your programs and use exitemu = command. " , 50, 0x4f); + Text_X.Draw_string(15, 11, " = " , 50, 0x4f); + Text_X.Draw_string(15, 12, " Do you still want to continue? = " , 50, 0x4f); + Text_X.Draw_string(15, 13, " = " , 50, 0x4f); + Text_X.Draw_string(15, 14, " Y - abort DosEmu session = " , 50, 0x4f); + Text_X.Draw_string(15, 15, " N - continue DosEmu session = " , 50, 0x4f); + Text_X.Draw_string(15, 16, " = " , 50, 0x4f); + =20 + Text_X.Draw_string(48, 10, "exitemu" , 7, 0x4a); + Text_X.Draw_string(18, 14, "Y" , 1, 0x4e); + Text_X.Draw_string(18, 15, "N" , 1, 0x4e); + =20 break; } =20 @@ -1490,6 +1522,24 @@ keyrel_pending =3D 0; } =20 + if (about_to_quit) { + KeySym keysym =3D XKeycodeToKeysym(display, e.xkey.keycode, 0); + if (keysym =3D=3D XK_Y || keysym =3D=3D XK_y) { + leavedos(0); + } else if (keysym =3D=3D XK_N || keysym =3D=3D XK_n) { + about_to_quit =3D FALSE; + Text_X.Draw_cursor =3D Draw_cursor_backup; + if(vga.mode_class =3D=3D TEXT) { + X_redraw_text_screen(); + } else { + dirty_all_video_pages(); + X_update_screen(); + } + unfreeze_dosemu(); + } + break; + } + if((e.xkey.state & ControlMask) && (e.xkey.state & Mod1Mask)) { KeySym keysym =3D XKeycodeToKeysym(display, e.xkey.keycode, 0); if (keysym =3D=3D grab_keysym) { @@ -1504,6 +1554,7 @@ break; } } + =20 /*=20 Clears the visible selection if the cursor is inside the selection */ diff -Nur dosemu-1.4.0.orig/src/plugin/X/X_font.c dosemu-1.4.0.chng/src/plu= gin/X/X_font.c =2D-- dosemu-1.4.0.orig/src/plugin/X/X_font.c 2007-05-04 07:59:48.000000000= +0200 +++ dosemu-1.4.0.chng/src/plugin/X/X_font.c 2008-01-30 10:04:00.000000000 += 0100 @@ -195,8 +195,7 @@ text_colors[i] =3D xc.pixel; } =20 =2D =2Dstatic struct text_system Text_X =3D +struct text_system Text_X =3D { X_draw_string,=20 X_draw_line, =2D------------------------------------------------------------------------= =2D------- Regards, =2D-=20 Rafa=B3 Cygnarowski rafi@pers.pl --nextPart1755354.NpZp7HQFLr Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.6 (GNU/Linux) iD8DBQBHoF1ZiTbqoF5x7W4RAmjgAJ9UbJiafrRoeVLpHzhLwLTHgTsbOwCeIvQG ByFK7/7n7xNZ0gCCfdz30RM= =LFYH -----END PGP SIGNATURE----- --nextPart1755354.NpZp7HQFLr--