svgalib vncviewer update

Barnali Banerjee ganesh "at" cse.iitb.ernet.in
Sat, 07 Mar 1998 23:58:53 +0000


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime "at" docserver.cac.washington.edu for more info.

---559023410-851401618-889315206=:28874
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi,
	here's a modified svga.c which should (hopefully !) work for most
people. Just replace the old svncviewer/svga.c with this one.
The -owncmap, -truecolour, -bgr233 and -depth options should work now.
Note that only 16 and 32 bpp are possible in truecolour since the server
only supports these.
Keyboard handling still sucks, anyone give me a clue as to how to handle
scancode->KeySym conversion properly ?

If you have any problems, please mail me with the following details:
Linux version, distribution
Graphics card, and whether svgalib apps (like zgv) normally work on it.
What graphics mode was being used. svncviewer will print a message like
SVGA: Using mode 10
at startup.
If it quits with a broken pipe, it means that the server gave up on us
because of unacceptable parameters. Please look at ~/.vnc/X.log and check
the details of the last client connection.

								-- ganesh

---559023410-851401618-889315206=:28874
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="svga.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SV4.3.90.980308053006.28874B "at" kailash>
Content-Description: 

LyoNCiAqICBDb3B5cmlnaHQgKEMpIDE5OTcsIDE5OTggT2xpdmV0dGkgJiBP
cmFjbGUgUmVzZWFyY2ggTGFib3JhdG9yeQ0KICoNCiAqICBUaGlzIGlzIGZy
ZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBt
b2RpZnkNCiAqICBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5l
cmFsIFB1YmxpYyBMaWNlbnNlIGFzIHB1Ymxpc2hlZCBieQ0KICogIHRoZSBG
cmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uIDIgb2Yg
dGhlIExpY2Vuc2UsIG9yDQogKiAgKGF0IHlvdXIgb3B0aW9uKSBhbnkgb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