]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
8 years agoInclude stdint.h (where available) for uintptr_t.
Simon Tatham [Mon, 28 Sep 2015 18:52:38 +0000 (19:52 +0100)]
Include stdint.h (where available) for uintptr_t.

Commit f2e61275f introduced the use of uintptr_t, without adding an
include of <stdint.h> which is where the C standard says that type
should be defined. This didn't cause a build failure, because Visual
Studio also defines it in <stddef.h> which we do include. But a user
points out that other Windows toolchains - e.g. MinGW - don't
necessarily do the same.

I can't add an unconditional include of <stdint.h>, because the VS I
use for the current official builds doesn't have that header at all.
So I conditionalise it out for old VS; if it needs throwing out for
any other toolchain, I'll add further conditions as reports come in.

8 years agoSet GTK3 as the default, and stop marking it unfinished.
Simon Tatham [Sat, 26 Sep 2015 13:17:51 +0000 (14:17 +0100)]
Set GTK3 as the default, and stop marking it unfinished.

Today I've gone through the whole GTK front end, doing a manual test
of every piece of code that I either remembered having had to fiddle
with for GTK3, or suddenly realised I _should_ have fiddled with. I've
fixed all the bugs arising from that exercise; and what with that, the
fact that the new Cairo image surface strategy makes server-side font
handling _faster_ in GTK3 than in GTK2, and the fact that GTK3 also
supports the shiny new smooth scrolling system for touchpads, I
suddenly think that the GTK3 build is now at least as good as GTK2.

So I've switched the configure script over to picking it by default if
it can, and I've also removed the 'unfinished and experimental'
warning if you select it. I for one will now start using GTK3 PuTTY
and pterm for my day-to-day work.

8 years agoWiden the GTK askalg() message box.
Simon Tatham [Sat, 26 Sep 2015 13:13:56 +0000 (14:13 +0100)]
Widen the GTK askalg() message box.

In GTK3, the line 'Continue with connection?' got wrapped (in spite of
my attempt to enforce via string_width() that it didn't - probably a
few pixels were needed on top of that for various padding and
furniture) so it looked even sillier. But it looked a bit narrow to be
sensible even in GTK2, so the simplest answer is just to widen it
considerably.

8 years agoMake sure Escape terminates the About box.
Simon Tatham [Sat, 26 Sep 2015 13:09:27 +0000 (14:09 +0100)]
Make sure Escape terminates the About box.

I think it only did so in GTK2 by virtue of the About box being a
GtkDialog. But in GTK3 I've abandoned GtkDialog for not being flexible
enough, so I have to process the Escape key myself.

8 years agoMake sure Escape in a message box always does something.
Simon Tatham [Sat, 26 Sep 2015 12:57:12 +0000 (13:57 +0100)]
Make sure Escape in a message box always does something.

The askalg() dialog, and several one-button things like the licence
box, have no button labelled 'cancel'. But in all cases we do want
Escape to terminate the box, with as negative an answer as is
available. So now we assign the 'iscancel' flag to any button whose
numeric value is the smallest of the ones given as input to
messagebox().

(In a one-button box, this leads to isdefault and iscancel _both_
being set for that button. That's fine; it works.)

8 years agoFix GTK keyboard-shortcut focusing of CTRL_LISTBOX.
Simon Tatham [Sat, 26 Sep 2015 12:22:49 +0000 (13:22 +0100)]
Fix GTK keyboard-shortcut focusing of CTRL_LISTBOX.

I had put an entire piece of code into win_key_press's SHORTCUT_UCTRL
handler to carefully handle all the different kinds of list box
control and do something sensible with each one, and then I just went
and used a generic SHORTCUT_FOCUS type shortcut instead of actually
_calling_ all that carefully prepared code.

Now selecting (say) the character-classes list box in the Selection
panel using its Alt-e shortcut works; also, shortcut-selecting a popup
menu such as the ones in the Bugs panel causes the menu to pop up,
which I think is nicer than what previously happened.

8 years agoPermit the config box treeview to be keyboard-selected.
Simon Tatham [Sat, 26 Sep 2015 12:12:25 +0000 (13:12 +0100)]
Permit the config box treeview to be keyboard-selected.

I'd failed to set the widget field in its shortcut structure, leading
to an annoying GTK warning log message and no useful UI action when
Alt-G was pressed in the config box.

8 years agoRemove a couple of outdated FIXME comments.
Simon Tatham [Sat, 26 Sep 2015 11:59:26 +0000 (12:59 +0100)]
Remove a couple of outdated FIXME comments.

I had originally planned to implement a Compose-type key locally in
GTK PuTTY, as I did in Windows PuTTY. But in fact we've done this for
some time by delegating to the GTK IM system, which is a far better
idea anyway. So there's no point any more having the FIXME comment
that mentions Compose keys.

Also, there was a comment worrying about what I was going to do about
double-width characters in Pango, which is long since sorted out.

8 years agoAdd some missing GTK focus-in event handlers.
Simon Tatham [Sat, 26 Sep 2015 10:48:21 +0000 (11:48 +0100)]
Add some missing GTK focus-in event handlers.

Fixes a behaviour which I intended all along but apparently didn't
work before on GTK: if you start PuTTY, _select_ a saved session in
the list box but don't hit Load, and then just hit Open, then it will
be implicitly loaded and run for you, as a special case to save you an
extra button-press.

This depends on noticing that the saved-sessions list box last had the
focus, for which I need my widget_focus() handler to be called for
basically all config widgets so that I can track what _did_ last have
focus. Unfortunately, I missed a couple out.

8 years agoDon't defer displaying the prompt label in gtkask.
Simon Tatham [Sat, 26 Sep 2015 10:09:20 +0000 (11:09 +0100)]
Don't defer displaying the prompt label in gtkask.

The previous sequence of events was that I would display the window
synchronously (via gtk_widget_show_now), so that I knew it was
actually on the screen and realised as an X window, and then I'd grab
the keyboard, and once the keyboard was grabbed, connect up the
keyboard event handlers and display the prompt.

I have to assume that deferring the display of the 'enter the
passphrase' prompt until the keyboard handlers were set up was
intended as some sort of 'not misleading the user' measure - don't
tell them to start typing until we're actually ready to start typing.
But unfortunately it has the side effect that the window is displayed
at a much smaller size before the prompt label appears, and centred on
the screen according to _that_ size - and then we display the prompt
label and the window resizes and is now off-centre. So I think it's
better not to try to be clever, and just make the window come up at
the right size initially.

(Actually, it looks as if nothing in the window is actually drawn
until that whole init function is finished anyway, so the prompt label
_already_ doesn't get physically displayed too early. So the whole
idea was pointless in the first place!)

8 years agoBring the gtkask.c test main() up to date.
Simon Tatham [Sat, 26 Sep 2015 09:53:32 +0000 (10:53 +0100)]
Bring the gtkask.c test main() up to date.

I changed the prototype of gtk_askpass_main() since I last tried to
compile that standalone test program.

8 years agoVisually distinguish charset headings in GTK3 unifontsel.
Simon Tatham [Sat, 26 Sep 2015 09:42:02 +0000 (10:42 +0100)]
Visually distinguish charset headings in GTK3 unifontsel.

When displaying a server-side font, the unified font selector's
font-style list box contains some lines which are character-set
headings, and others which are actually selectable font styles. We tag
the former with the "sensitive"=FALSE attribute, to prevent them from
responding to clicks. In GTK2, this also made them visually distinct
from the normal lines, by greying them out; in GTK3 it makes no visual
difference.

The simplest solution is to bold those lines, hinting that they're
sort of section headings. That looks OK in GTK2 as well, so I've done
it unconditionally.

8 years agoFix combining character handling in Pango.
Simon Tatham [Sat, 26 Sep 2015 09:18:53 +0000 (10:18 +0100)]
Fix combining character handling in Pango.

The top-level loop in gtkwin.c which draws text was expecting that the
right way to draw a printing character plus combining characters was
to overprint them one by one on top of each other. This is an OK
assumption for X bitmap fonts, but in Pango, it works very badly -
most obviously because asking Pango to display a combining char on its
own causes it to print a dotted circle representing the base char, but
also because surely there will be character combinations where Pango
wants to do something more sophisticated than just printing them each
at a standard offset, and it would be a shame not to let it.

So I've moved the previous overprinting loop down into the x11font
subclass of the unifont mechanism. The top-level gtkwin.c drawing code
now calls a new method unifont_draw_combining, which in the X11 case
does the same loop as before, but in the Pango case, just passes a
whole base+combinings string to Pango in one go and lets it do the
best job it can.

8 years agoFix winhandl.c's failure to ever free a foreign handle.
Simon Tatham [Fri, 25 Sep 2015 15:03:47 +0000 (16:03 +0100)]
Fix winhandl.c's failure to ever free a foreign handle.

Handles managed by winhandl.c have a 'busy' flag, which is used to
mean two things: (a) is a subthread currently blocked on this handle
so various operations in the main thread have to be deferred until it
finishes? And (b) is this handle currently one that should be returned
to the main loop to be waited for?

For HT_INPUT and HT_OUTPUT, those things are either both true or both
false, so a single flag covering both of them is fine. But HT_FOREIGN
handles have the property that they should always be waited for in the
main loop, but no subthread is blocked on them. The latter means that
operations done on them in the main thread should not be deferred; the
only such operation is cleaning them up in handle_free().

handle_free() was failing to spot this, and was deferring freeing
HT_FOREIGN handles until their subthread terminated - which of course
never happened. As a result, when a named pipe server was closed, its
actual Windows event object got destroyed, but winhandl.c still kept
passing it back to the main thread, leading to a tight loop because
MsgWaitForMultipleObjects would return ERROR_INVALID_HANDLE and never
block.

8 years agoSupport smooth scrolling in GTK3.
Simon Tatham [Fri, 25 Sep 2015 14:11:44 +0000 (15:11 +0100)]
Support smooth scrolling in GTK3.

Touchpad gestures can generate much smoother scrolling events than the
discrete increments of mouse wheels. GDK3 supports this by means of a
new kind of scroll event, with direction GDK_SCROLL_SMOOTH and a
floating-point delta value. Added support for this; so in GTK3 mode,
you can now touchpad-scroll at a granularity of one line rather than
five, but in mouse tracking mode, scroll events are still grouped into
5-line chunks for purposes of turning them into escape sequences to
send to the server.

8 years agoMake scroll events work again in GTK3.
Simon Tatham [Fri, 25 Sep 2015 13:09:57 +0000 (14:09 +0100)]
Make scroll events work again in GTK3.

Apparently, if you don't specify GDK_SMOOTH_SCROLL_MASK in a widget's
event mask, then you don't receive "scroll_event" signals at all, even
of the non-smooth variety that was all GTK2 had. Hence, neither mouse
scroll wheels nor touchpad scroll gestures seem to generate any
response.

Adding GDK_SMOOTH_SCROLL_MASK brings the old scroll events back again,
so this is at least no worse than GTK2 was. But in GTK3 we _ought_ to
be able to do better still, by supporting smooth scrolling from
touchpads; this commit doesn't do that.

8 years agoRemove an accidentally committed diagnostic.
Simon Tatham [Fri, 25 Sep 2015 11:45:08 +0000 (12:45 +0100)]
Remove an accidentally committed diagnostic.

Forgot to remove this after debugging a development-time problem with
the new EPIPE special case. One of these days I'm going to have to set
up an automated way to protect against this kind of mistake...

8 years agoAvoid logging pre-verstring EPIPE from sharing downstreams.
Simon Tatham [Fri, 25 Sep 2015 11:05:55 +0000 (12:05 +0100)]
Avoid logging pre-verstring EPIPE from sharing downstreams.

If you use the new 'plink -shareexists' feature, then on Unix at least
it's possible for the upstream to receive EPIPE, because the
downstream makes a test connection and immediately closes it, so that
upstream fails to write its version string.

This looks a bit ugly in the upstream's Event Log, so I'm making a
special case: an error of 'broken pipe' type, which occurs on a socket
from a connection sharing downstream, before we've received a version
string from that downstream, is treated as an unusual kind of normal
connection termination and not logged as an error.

8 years agoNew Plink operating mode: 'plink -shareexists'.
Simon Tatham [Fri, 25 Sep 2015 10:46:28 +0000 (11:46 +0100)]
New Plink operating mode: 'plink -shareexists'.

A Plink invocation of the form 'plink -shareexists <session>' tests
for a currently live connection-sharing upstream for the session in
question. <session> can be any syntax you'd use with Plink to make the
actual connection (a host/port number, a bare saved session name,
-load, whatever).

I envisage this being useful for things like adaptive proxying - e.g.
if you want to connect to host A which you can't route to directly,
and you might already have a connection to either of hosts B or C
which are viable proxies, then you could write a proxy shell script
which checks whether you already have an upstream for B or C and goes
via whichever one is currently active.

Testing for the upstream's existence has to be done by actually
connecting to its socket, because on Unix the mere existence of a
Unix-domain socket file doesn't guarantee that there's a process
listening to it. So we make a test connection, and then immediately
disconnect; hence, that shows up in the upstream's event log.

8 years agoActually set the 'got_verstring' flag in sshshare.c!
Simon Tatham [Fri, 25 Sep 2015 11:06:06 +0000 (12:06 +0100)]
Actually set the 'got_verstring' flag in sshshare.c!

For each connection to a downstream I had a flag indicating that we'd
sent a version string to that downstream, and one indicating that we'd
received one in return. But I never actually set the latter to TRUE -
which was OK, as it turned out, because I never used it for anything
either.

Now I do want to use it, so I'd better actually set it :-)

8 years agoFactor out ssh_hostport_setup().
Simon Tatham [Fri, 25 Sep 2015 09:58:29 +0000 (10:58 +0100)]
Factor out ssh_hostport_setup().

This is the part of ssh.c's connect_to_host() which figures out the
host name and port number that logically identify the connection -
i.e. not necessarily where we physically connected to, but what we'll
use to look up the saved session cache, put in the window title bar,
and give to the connection sharing code to identify other connections
to share with.

I'm about to want to use it for another purpose, so it needs to be
moved out into a separate function.

8 years agoFactor out ssh_share_sockname().
Simon Tatham [Fri, 25 Sep 2015 09:58:05 +0000 (10:58 +0100)]
Factor out ssh_share_sockname().

This is the part of ssh_connection_sharing_init() which decides on the
identifying string to pass to the platform sharing setup. I'm about to
want to use it for another purpose, so it needs to be moved into a
separate function.

8 years agoFix misplaced separator in GTK3 dialog boxes.
Simon Tatham [Fri, 25 Sep 2015 09:05:57 +0000 (10:05 +0100)]
Fix misplaced separator in GTK3 dialog boxes.

When I abandoned GtkDialog for GtkWindow (in dc11417ae), I manually
added a horizontal GtkSeparator between the content and action areas.
Or rather, I tried to - but I forgot that gtk_box_pack_end works in
the opposite order, so that you have to add the bottom-most element
first and then the one you want to appear above it. So my separator
was below the action area, rather than between it and the content
area.

8 years agoFix window resizing in GTK 3 PuTTY.
Simon Tatham [Fri, 25 Sep 2015 08:52:19 +0000 (09:52 +0100)]
Fix window resizing in GTK 3 PuTTY.

In GTK 3, it was impossible to resize the window smaller than it
started off, because the size request on the drawing area was taken as
a minimum. (I can't actually remember how the GTK 2 version doesn't
have this problem too.)

Fixed by instead setting the initial window size using
gtk_window_set_default_geometry() (having first set up the geometry
hints to reflect the character cell size).

8 years agoSanitise bad characters in log file names.
Simon Tatham [Fri, 25 Sep 2015 08:23:26 +0000 (09:23 +0100)]
Sanitise bad characters in log file names.

On Windows, colons are illegal in filenames, because they're part of
the path syntax. But colons can appear in automatically constructed
log file names, if an IPv6 address is expanded from the &H placeholder.

Now we coerce any such illegal characters to '.', which is a bit of a
bodge but should at least cause a log file to be generated.

8 years agoShout more loudly if we can't open a log file.
Simon Tatham [Fri, 25 Sep 2015 08:15:21 +0000 (09:15 +0100)]
Shout more loudly if we can't open a log file.

A user points out that logging fopen failures to the Event Log is a
bit obscure, and it's possible to proceed for months in the assumption
that your sessions are being correctly logged when in fact the
partition was full or you were aiming them at the wrong directory. Now
we produce output visibly in the PuTTY window.

8 years agoCentralise stripslashes() and make it OS-sensitive.
Simon Tatham [Thu, 24 Sep 2015 16:47:10 +0000 (17:47 +0100)]
Centralise stripslashes() and make it OS-sensitive.

I noticed that Unix PSCP was unwantedly renaming downloaded files
which had a backslash in their names, because pscp.c's stripslashes()
treated \ as a path component separator, since it hadn't been modified
since PSCP ran on Windows only.

It also turns out that pscp.c, psftp.c and winsftp.c all had a
stripslashes(), and they didn't all have quite the same prototype. So
now there's one in winsftp.c and one in uxsftp.c, with appropriate
OS-dependent behaviour, and the ones in pscp.c and psftp.c are gone.

8 years agoCommand-line options to log sessions.
Simon Tatham [Thu, 24 Sep 2015 16:30:04 +0000 (17:30 +0100)]
Command-line options to log sessions.

Log files, especially SSH packet logs, are often things you want to
generate in unusual circumstances, so it's good to have lots of ways
to ask for them. Particularly, it's especially painful to have to set
up a custom saved session to get diagnostics out of the command-line
tools.

I've added options '-sessionlog', '-sshlog' and '-sshrawlog', each of
which takes a filename argument. I think the fourth option (session
output but filtered down to the printable subset) is not really a
_debugging_ log in the same sense, so it's not as critical to have an
option for it.

8 years agoUse a Cairo image surface as a client-side cache.
Simon Tatham [Thu, 24 Sep 2015 13:08:25 +0000 (14:08 +0100)]
Use a Cairo image surface as a client-side cache.

In any DRAWTYPE_CAIRO mode, we now do all our Cairo drawing to a Cairo
image surface which lives on the client; then we either blit directly
from that to the window (if we're in GTK3 mode, or GTK2 without
deprecated pieces of API), or else we blit from the Cairo surface to
the server-side pixmap and then from there to the actual window.

In DRAWTYPE_GDK mode, nothing much has changed: we still draw directly
to the server-side pixmap using the GDK drawing API, then blit from
there to the window. But there is one change, namely that the blit is
no longer done proactively - instead, we queue a redraw of the
affected rectangle, and wait until we're called back by the expose
handler.

The main aim of all this is to arrange that the only time we ever draw
to the real window is in response to expose/draw events. The
experimental GTK3 OS X port stopped working a week or two ago (I
presume in response to an OS update) with the symptoms that attempts
to draw on the window outside the context of a "draw" event handler
just didn't seem to work any more; this change fixes it.

In addition to that benefit, this change also has obvious performance
advantages in principle. No more expensive text rendering in response
to an expose event - just re-copy to the window from the bitmap we
already have, from wherever it's stored that's nearest.

Moreover, this seems to have fixed the significant performance problem
with X server-side fonts under GTK. I didn't expect _that_! I'd
guessed that the approach of downloading character bitmaps and
rendering them manually via Cairo was just inherently slow for some
reason. I've no real idea _why_ this change improves matters so much;
my best guess is that perhaps there's an overhead in each drawing
operation to a GDK Cairo surface, so we win by doing lots of
operations to a much faster image surface and then batching them up
into one GDK Cairo operation. But whyever it is, I'm certainly not
complaining!

(In fact, it now seems to be noticeably _faster_, at least on my usual
local X displays, to draw server-side fonts using that technique than
using the old GDK approach. I may yet decide to switch over...)

8 years agoFix spurious EAGAIN in Plink host key (and other) prompts.
Simon Tatham [Thu, 24 Sep 2015 10:58:44 +0000 (11:58 +0100)]
Fix spurious EAGAIN in Plink host key (and other) prompts.

Plink sets standard input into nonblocking mode, meaning that read()
from fd 0 in an interactive context will typically return -1 EAGAIN.
But the prompt functions in uxcons.c, used for verifying SSH host keys
and suchlike, were doing an unguarded read() from fd 0, and then
panicking and aborting the session when they got EAGAIN.

Fixed by inventing a wrapper around read(2) which handles EAGAIN but
passes all other errors back to the caller. (Seemed slightly less
dangerous than the stateful alternative of temporarily re-blockifying
the file descriptor.)

8 years agoDon't try to agree a MAC we'll never use.
Simon Tatham [Thu, 24 Sep 2015 10:41:43 +0000 (11:41 +0100)]
Don't try to agree a MAC we'll never use.

If we've chosen the ChaCha20-Poly1305 option for a cipher, then that
forces the use of its associated MAC. In that situation, we should
avoid even _trying_ to figure out a MAC by examining the MAC string
from the server's KEXINIT, because we won't use the MAC selected by
that method anyway, so there's no point imposing the requirement on
servers to present a MAC we believe in just so we know it's there.

This was breaking interoperation with tinysshd, and is in violation of
OpenSSH's spec for the "chacha20-poly1305@openssh.com" cipher.

8 years agoSplit ssh2_cipher's keylen field into two.
Simon Tatham [Thu, 10 Sep 2015 07:10:52 +0000 (08:10 +0100)]
Split ssh2_cipher's keylen field into two.

The revamp of key generation in commit e460f3083 made the assumption
that you could decide how many bytes of key material to generate by
converting cipher->keylen from bits to bytes. This is a good
assumption for all ciphers except DES/3DES: since the SSH DES key
setup ignores one bit in every byte of key material it's given, you
need more bytes than its keylen field would have you believe. So
currently the DES ciphers aren't being keyed correctly.

The original keylen field is used for deciding how big a DH group to
request, and on that basis I think it still makes sense to keep it
reflecting the true entropy of a cipher key. So it turns out we need
two _separate_ key length fields per cipher - one for the real
entropy, and one for the much more obvious purpose of knowing how much
data to ask for from ssh2_mkkey.

A compensatory advantage, though, is that we can now measure the
latter directly in bytes rather than bits, so we no longer have to
faff about with dividing by 8 and rounding up.

8 years agoNew script to generate OS X icon files.
Simon Tatham [Sun, 6 Sep 2015 08:50:09 +0000 (09:50 +0100)]
New script to generate OS X icon files.

The Xcode icon composer doesn't seem to exist any more in modern
versions of Xcode, or at least if it does then it's well hidden and
certainly doesn't live at the top-level path at /Developer where web
pages still claim it can be found.

There is a free software 'libicns' and associated command-line tools,
but they're large, complicated, picky about the exact format of PNGs
they get as input, and in any case a needless extra build dependency
when it turns out the important parts of the file format can be done
in a few dozen lines of Python. So here's a new macicon.py, and
icons/Makefile additions to build a demo icon for OS X PuTTY, as and
when I finally get it working.

Also I've deleted the static icon file in the neglected 'macosx'
source directory, because this one is better anyway - the old one was
appalling quality, and must have been autogenerated from a single
image in some way.

8 years agoClean up GTK keyboard event diagnostics.
Simon Tatham [Sun, 6 Sep 2015 08:13:48 +0000 (09:13 +0100)]
Clean up GTK keyboard event diagnostics.

When I introduced the KEY_EVENT_DIAGNOSTICS system last month in
commit 769600b22, I somehow didn't notice that it sat next to an
existing system of ifdefs labelled KEY_DEBUGGING, which did some
things worse but some things better.

Now I've expanded both of those into a fairly complete system of
diagnostics (keeping the newer name of KEY_EVENT_DIAGNOSTICS), and
made them use debug() rather than printf() so that in situations where
no standard output is available I can still retrieve the diagnostics
from debug.log.

8 years agoRevert accidentally committed breakage of Shift-Ins paste.
Simon Tatham [Sun, 6 Sep 2015 08:17:53 +0000 (09:17 +0100)]
Revert accidentally committed breakage of Shift-Ins paste.

I turned it into Shift-Return, because I was trying to find out why
the former didn't work on OS X and replaced it with something else
random to see if the code was even being reached. And then, like an
utter doofus, I committed that change as part of a50da0e30.

8 years agoIgnore mouse events that didn't start with a click.
Simon Tatham [Thu, 3 Sep 2015 18:20:28 +0000 (19:20 +0100)]
Ignore mouse events that didn't start with a click.

On OS X GTK, when you click in a pterm that wasn't the active window,
the first click activates it but is swallowed by the windowing system
- but a subsequent tiny drag can still be taken as part of a selection
action, making it difficult to activate the window in order to paste
into it.

Fixed by ignoring mouse drags when the terminal.c mouse state was
NO_SELECTION; if we've seen one prior click then it should be
ABOUT_TO, or DRAGGING if we saw a double or triple click.

8 years agoKey rollover: fix the .htaccess files built by Buildscr.
Simon Tatham [Thu, 3 Sep 2015 18:04:54 +0000 (19:04 +0100)]
Key rollover: fix the .htaccess files built by Buildscr.

The build script generates the .htaccess files that go in each
individual build and redirect generic names like 'putty.tar.gz' to the
real filenames including that build's version number. Those .htaccess
files redirect the corresponding signatures as well, so they need
updating now that we're generating signature files with a different
extension.

8 years agoKey rollover: cut and paste errors in pgpkeys.but.
Simon Tatham [Thu, 3 Sep 2015 18:04:26 +0000 (19:04 +0100)]
Key rollover: cut and paste errors in pgpkeys.but.

What should have been links to the old DSA keys were actually a second
copy of the links to the old RSA ones. Ahem.

8 years agoInitial support for clipboard on OS X.
Simon Tatham [Wed, 2 Sep 2015 20:37:33 +0000 (21:37 +0100)]
Initial support for clipboard on OS X.

Rather than trying to get my existing hugely complicated X-style
clipboard code to somehow work with the Quartz GTK back end, I've
written an entirely new and much simpler alternative clipboard handler
usnig the higher-leve GtkClipboard interface. It assumes all clipboard
text can be converted to and from UTF-8 sensibly (which isn't a good
assumption on all front ends, but on OS X I think it's reasonable),
and it talks to GDK_SELECTION_CLIPBOARD rather than PRIMARY, which is
the only clipboard OS X has.

I had to do a fiddly thing to cope with the fact that each call to
gtk_clipboard_set_with_data caused a call to the clipboard clear
function left over from the previous set of data, so I had to avoid
mistaking that for a clipboard-clear for the _new_ data and
immediately deselecting it. I did that by allocating a distinct
placeholder object in memory for each instance of the copy operation,
so that I can tell whether a clipboard-clear is for the current copy
or a previous one.

This is only very basic support which demonstrates successful copying
and pasting is at least possible. For a sensible OS X implementation
we'll need a more believable means of generating a paste UI action
(it's quite easy to find a Mac on which neither Shift-Ins nor the
third mouse button even exists!). Also, after the trouble I had with
the clipboard-clear event, it's a bit annoying to find that it
_doesn't_ seem to get called when another application becomes the
clipboard owner. That may just be something we have to put up with, if
I can't find any reason why it's failing.

8 years agoFix assertion failure in xterm mouse tracking.
Simon Tatham [Wed, 2 Sep 2015 17:56:20 +0000 (18:56 +0100)]
Fix assertion failure in xterm mouse tracking.

The original version of the xterm mouse tracking protocol did not
support character-cell coordinates greater than 223. If term_mouse()
got one, it would fail to construct an escape sequence for the mouse
event, and would then call ldisc_send() with a zero-length string -
which fails an assertion that I added in November (c269dd0135) on the
occasion of moving ldisc_echoedit_update() into its own function. So
the corresponding operation before that change would have done a
gratuitous ldisc_echoedit_update(), which is exactly the sort of thing
the assertion was there to catch :-)

Later extensions to the mouse tracking protocol support larger
coordinates anyway (try ESC[?1006h or ESC[?1015h in addition to the
ESC[?1000h that turns the whole system on in the first place). It's
only clients that don't use one of those extensions which would have
had the problem.

Thanks to Mirko Wolle for the report.

8 years agoKey rollover: add a checklist item for the Download page.
Simon Tatham [Wed, 2 Sep 2015 17:39:32 +0000 (18:39 +0100)]
Key rollover: add a checklist item for the Download page.

Next time I do a release, I'll have to remember to adjust the download
page links to the GPG signature files.

8 years agoKey rollover: put the new Master Key fingerprint in the tools.
Simon Tatham [Wed, 2 Sep 2015 17:31:24 +0000 (18:31 +0100)]
Key rollover: put the new Master Key fingerprint in the tools.

For the moment we're also retaining the old ones. Not sure when will
be the best time to get rid of those; after the next release, perhaps?

8 years agoKey rollover: switch to signing using the new keys.
Simon Tatham [Wed, 2 Sep 2015 17:30:10 +0000 (18:30 +0100)]
Key rollover: switch to signing using the new keys.

sign.sh's command-line syntax has changed, so I've updated the sample
command line in CHECKLST as well. Also the file extensions of the
signatures have changed, so I've updated the pre-release verification
command line in CHECKLST too.

8 years agoKey rollover: rewrite the PGP keys manual appendix.
Simon Tatham [Wed, 2 Sep 2015 17:24:39 +0000 (18:24 +0100)]
Key rollover: rewrite the PGP keys manual appendix.

This gives pride of place to the new set of keys we've recently
generated, and relegates the old ones to an afterthought.

8 years agoOS X: fix handling of Ctrl-Space.
Simon Tatham [Tue, 1 Sep 2015 18:18:26 +0000 (19:18 +0100)]
OS X: fix handling of Ctrl-Space.

I'd left it out of my simulated Ctrl processing. It should have been
treated as \0, the same as ^2 and ^@.

8 years agoWork around OS X GTK treating Option as an AltGr key.
Simon Tatham [Tue, 1 Sep 2015 18:10:29 +0000 (19:10 +0100)]
Work around OS X GTK treating Option as an AltGr key.

If I'm using Option as the Meta key, I want to suppress OS X GTK's
default behaviour of treating it as an AltGr-oid which changes the
keyval and Unicode translation of alphabetic keys. So on OS X I enable
a somewhat bodgy workaround which retranslates from the hardware
keycode as if the Option modifier had not been active at the time, and
use that as the character to prefix Esc to.

This is a bit nasty because I have to hardwire group = 0 in the call
to gdk_keymap_translate_keyboard_state(), whereas in principle what I
wanted was group = (whatever would have resulted from everything else
in the key event other than MOD1). However, in practice, they seem to
be the same, so this will do for the moment.

8 years agoOn OS X, be able to configure either Option or Command as Meta.
Simon Tatham [Tue, 1 Sep 2015 18:00:25 +0000 (19:00 +0100)]
On OS X, be able to configure either Option or Command as Meta.

Personally I like using Command as the Esc-prefixing Meta key in
terminal sessions, because it occupies the same physical keyboard
position as the Alt key that I'm used to using on non-Macs. OS X
Terminal uses Option for that purpose (freeing up Command for the
conventional Mac keyboard shortcuts, of course), so I anticipate
differences of opinion.

Hence, here's a pair of OSX-specific config options which permit a
user to set either, or neither, or both of those modifier keys to
function as the terminal Meta key.

8 years agopterm: move termios setup to after the fork.
Simon Tatham [Tue, 1 Sep 2015 17:45:51 +0000 (18:45 +0100)]
pterm: move termios setup to after the fork.

On OS X, apparently, we can't do termios setup on the pty master, so
instead we have to leave it until we've opened the slave fd in the
child process. That works on Linux too, so let's leave it here rather
than having another cumbersome ifdef.

8 years agopterm: set IUTF8 on pty devices depending on charset.
Simon Tatham [Tue, 1 Sep 2015 17:35:38 +0000 (18:35 +0100)]
pterm: set IUTF8 on pty devices depending on charset.

In a UTF-8 pterm, it makes sense to set the IUTF8 flag (on systems
that have one) on the pty device, so that line editing will take
account of UTF-8 multibyte characters.

8 years agoWork around Pango fonts with fractional width.
Simon Tatham [Mon, 31 Aug 2015 15:37:05 +0000 (16:37 +0100)]
Work around Pango fonts with fractional width.

By retrieving characters' widths using get_extents and not
get_pixel_extents, we can spot when they're not actually an exact
multiple of a pixel, and avoid getting confused by the overall width
of a long string being off by up to a pixel per character.

8 years agoFix an uninitialised bufchain in NO_PTY_PRE_INIT mode.
Simon Tatham [Mon, 31 Aug 2015 15:11:37 +0000 (16:11 +0100)]
Fix an uninitialised bufchain in NO_PTY_PRE_INIT mode.

The Pty that we created in pty_pre_init had its bufchain properly
initialised, but if that one didn't get created, then the one we
create in pty_init did not. Now both should go through the same init
routine.

8 years agoSlightly improve layout in GTK3 Pageant passphrase prompts.
Simon Tatham [Mon, 31 Aug 2015 14:45:27 +0000 (15:45 +0100)]
Slightly improve layout in GTK3 Pageant passphrase prompts.

Now I've moved align_label_left() into gtkmisc.c where gtkask.c can
get at it, we can use it to fix the alignment of the prompt label.
Also, use gtk_label_set_width_chars() to give the label a more or less
sensible width.

8 years agoMove more functions into the new gtkmisc.c.
Simon Tatham [Mon, 31 Aug 2015 14:44:24 +0000 (15:44 +0100)]
Move more functions into the new gtkmisc.c.

Several utility functions I've written over the last few weeks were in
rather random places because I didn't have a central gtkmisc.c to put
them in. Now I've got one, put them there!

8 years agoStop using GtkDialog (for most purposes) in GTK 3!
Simon Tatham [Mon, 31 Aug 2015 14:45:18 +0000 (15:45 +0100)]
Stop using GtkDialog (for most purposes) in GTK 3!

They've now deprecated gtk_dialog_get_action_area, because they really
want a dialog box's action area to be filled with nothing but buttons
controlled by GTK which end the dialog with a response code. But we're
accustomed to putting all sorts of other things in our action area -
non-buttons, buttons that don't end the dialog, and sub-widgets that
do layout - and so I think it's no longer sensible to be trying to
coerce our use cases into GtkDialog.

Hence, I'm introducing a set of wrapper functions which equivocate
between a GtkDialog for GTK1 and GTK2, and a GtkWindow with a vbox in
it for GTK3, and I'll lay out the action area by hand.

(Not everything has sensible layout and margins in the new GTK3 system
yet, but I can sort that out later.)

Because the new functions are needed by gtkask.c, which doesn't link
against gtkdlg.c or include putty.h, I've put them in a new source
file and header file pair gtkmisc.[ch] which is common to gtkask and
the main GTK edifice.

8 years agoAdd a missing cast in g_object_set.
Simon Tatham [Mon, 31 Aug 2015 13:36:12 +0000 (14:36 +0100)]
Add a missing cast in g_object_set.

When NULL appears in variadic argument lists, it should be cast to the
pointer type that the function will be expecting, because otherwise it
might end up as a type not even the same size as a pointer.

8 years agoUse GtkMessageDialog for dlg_error().
Simon Tatham [Mon, 31 Aug 2015 13:29:56 +0000 (14:29 +0100)]
Use GtkMessageDialog for dlg_error().

This is a much simpler way to display simple message-box type dialogs,
whose absence I've previously been working around by laboriously
constructing something in my usual style.

8 years agoStop using GtkAlignment in GTK 3.
Simon Tatham [Mon, 31 Aug 2015 13:05:51 +0000 (14:05 +0100)]
Stop using GtkAlignment in GTK 3.

We were using it in the main config box to ensure everything expanded
on window resize, but in GTK3 that's the default anyway. And we were
using it to put padding around the edges of the font selector, which
is now done using the "margin" property.

8 years agoAvoid deprecated gtk_misc_set_alignment().
Simon Tatham [Mon, 31 Aug 2015 12:57:34 +0000 (13:57 +0100)]
Avoid deprecated gtk_misc_set_alignment().

As of GTK 3.16 (but not in previous GTK 3 versions), there's a new
gtk_label_set_xalign which does this job.

8 years agoAvoid using gdk_cursor_new() in GTK 3.
Simon Tatham [Mon, 31 Aug 2015 12:41:16 +0000 (13:41 +0100)]
Avoid using gdk_cursor_new() in GTK 3.

It's deprecated in up-to-date versions, but fortunately, the
workaround is just to explicitly include the appropriate GdkDisplay.

8 years agoSwitch to gdk_rgba_parse() for GDK 3.
Simon Tatham [Mon, 31 Aug 2015 12:37:30 +0000 (13:37 +0100)]
Switch to gdk_rgba_parse() for GDK 3.

I'm using a slightly more up-to-date GTK version for testing on MacOS,
and it's marked a few more functions as deprecated, among which is
gdk_color_parse(). So now parsing -fg and -bg options has to be done
by two different calls and an ugly #ifdef, depending on GTK version.

8 years agoDon't use "server:fixed" as the default font without X.
Simon Tatham [Mon, 31 Aug 2015 12:24:09 +0000 (13:24 +0100)]
Don't use "server:fixed" as the default font without X.

If we're not supporting server-side fonts, it's utterly silly to set
one as the default! Instead, we use Pango's guarantee that some
reasonably sensible monospaced font will be made available under the
name "Monospace", and use that at a reasonable default size of 12pt.

8 years agoIntroduce a config option for building on OS X GTK.
Simon Tatham [Mon, 31 Aug 2015 12:05:51 +0000 (13:05 +0100)]
Introduce a config option for building on OS X GTK.

Using GTK to run on OS X is going to require several workarounds and
behaviour tweaks to be enabled at various points in the code, and it's
already getting cumbersome to remember what they all are to put on the
command line. Here's a central #define (OSX_GTK) that enables them all
in one go, and a configure option (--with-quartz) that sets it.

As part of this commit, I've also rearranged the #include order in the
GTK source files, so that they include unix.h (which now might be
where NOT_X_WINDOWS gets defined) before they test NOT_X_WINDOWS to
decide whether to include X11 headers.

8 years agoHandle the Ctrl modifier key ourselves if necessary.
Simon Tatham [Mon, 31 Aug 2015 12:00:42 +0000 (13:00 +0100)]
Handle the Ctrl modifier key ourselves if necessary.

The Quartz GDK back end, if you press (say) Ctrl-A, will generate a
GdkKeyEvent with keyval='a' and state=CONTROL, but it'll have a
translated string of "a" where the X back end would have returned
"\001". So we have to do our own translation, which fortunately isn't
hard.

8 years agoAdd a bodge to make pty masters nonblocking on OS X.
Simon Tatham [Mon, 31 Aug 2015 12:00:19 +0000 (13:00 +0100)]
Add a bodge to make pty masters nonblocking on OS X.

OS X for some reason doesn't let my usual fcntl approach (wrapped in
nonblock()) work on pty masters - the fcntl(F_SETFL) fails, with the
(in this context) hilariously inappropriate error code ENOTTY. Work
around it by instead passing O_NONBLOCK to posix_openpt.

8 years agoAdd a new #define to disable pty_pre_init.
Simon Tatham [Mon, 31 Aug 2015 11:51:25 +0000 (12:51 +0100)]
Add a new #define to disable pty_pre_init.

OS X dislikes us calling the setuid or setgid syscalls when not
privileged, even if we try to set ourselves to the _same_ uid/gid.
Since I don't anticipate this code needing to run setuid on OS X, and
since I do anticipate wanting to handle multiple ptys in a single
process so that pty_pre_init would be useless anyway, the simplest fix
seems to me to be just conditioning out the whole of pty_pre_init
completely.

8 years agoRemove LIBS from Unix pageant Recipe line
Owen S. Dunn [Fri, 28 Aug 2015 15:36:36 +0000 (16:36 +0100)]
Remove LIBS from Unix pageant Recipe line

The Recipe line for Unix pageant mistakenly included LIBS which is
the set of Windows standard libraries.  Remove it.

8 years agoMake Columns disregard the preferred width of GtkEntry.
Simon Tatham [Thu, 27 Aug 2015 17:59:24 +0000 (18:59 +0100)]
Make Columns disregard the preferred width of GtkEntry.

On OS X GTK, it requests a preferred width that's way too large. I
think that's because that's based on its max_width_chars rather than
its width_chars (and I only set the latter). But I don't want to
actually reduce its max_width_chars, in case (either now or in a
future version) that causes it to actually refuse to take up all the
space it's allocated.

8 years agoStop using abs(unsigned) in X11 time comparison.
Simon Tatham [Thu, 27 Aug 2015 17:39:36 +0000 (18:39 +0100)]
Stop using abs(unsigned) in X11 time comparison.

The validation end of XDM-AUTHORIZATION-1 needs to check that two
time_t values differ by at most XDM_MAXSKEW, which it was doing by
subtracting them and passing the result to abs(). This provoked a
warning from OS X's clang, on the reasonable enough basis that the
value passed to abs was unsigned.

Fixed by using the (well defined) unsigned arithmetic wraparound: to
check that the mathematical difference of two unsigned numbers is in
the interval [-k,+k], compute their difference _plus k_ as an
unsigned, and check the result is in the interval [0,2k] by doing an
unsigned comparison against 2k.

8 years agoAdd conditioned-out diagnostics in GTK key_event().
Simon Tatham [Thu, 27 Aug 2015 17:35:17 +0000 (18:35 +0100)]
Add conditioned-out diagnostics in GTK key_event().

These should dump out all the important parts of the incoming
GdkEventKey, so that if keys aren't being translated right, it should
be possible to work out something about why not.

To enable: make CPPFLAGS="-DKEY_EVENT_DIAGNOSTICS"

8 years agoAdd conditioned-out diagnostics in columns_compute_width.
Simon Tatham [Thu, 27 Aug 2015 17:32:41 +0000 (18:32 +0100)]
Add conditioned-out diagnostics in columns_compute_width.

These are a slightly cleaned-up version of the diagnostics I was using
to debug the layout problems in the GTK3 config box the other day. In
particular, if the box comes out far too wide - as I've just found out
that it also does when I compile the current state of the code against
OS X GTK3 - these diagnostics should provide enough information to
figure out which control is the limiting factor.

To enable: make CPPFLAGS="-DCOLUMNS_WIDTH_DIAGNOSTICS"

8 years agoTurn GTK3 deprecation warnings back on.
Simon Tatham [Tue, 25 Aug 2015 18:59:45 +0000 (19:59 +0100)]
Turn GTK3 deprecation warnings back on.

After the last few commits, we now compile cleanly against GTK3 even
without -Wno-deprecated-declarations, so let's turn the default
warnings back on to ensure we don't regress that.

8 years agoRemove a mysterious GTK size-request tweak.
Simon Tatham [Tue, 25 Aug 2015 18:55:38 +0000 (19:55 +0100)]
Remove a mysterious GTK size-request tweak.

In shortcut_add(), when we add an underlined letter to a GtkLabel, we
were fetching the label's height before changing its text, and
restoring it afterwards. I've no idea why - I can see no difference
with and without the code.

That code's been there since 2003 without explanation. My best guess
is that it was working around a GTK bug of the day, but since no
difference is visible even in current GTK1, I think I'm just going to
remove it. If any problems show up later, I can put it back, with an
actual comment!

8 years agoCompile fixes for GTK1 after recent work.
Simon Tatham [Tue, 25 Aug 2015 18:50:23 +0000 (19:50 +0100)]
Compile fixes for GTK1 after recent work.

The whole of get_label_text_dimensions() should have been outside the
GTK 2 ifdef; I'd left a gtk_label_set_width_chars() unconditional; and
GDK1's gdk_window_set_background() lacks a const in its prototype.
Serves me right for not test-compiling in all three versions!

8 years agoFix the config box treeview width in GTK3.
Simon Tatham [Tue, 25 Aug 2015 18:44:44 +0000 (19:44 +0100)]
Fix the config box treeview width in GTK3.

My trickery in GTK2 to start with some branches of the tree collapsed
but give the widget all the width it will need when they open later
was not working in GTK3, for the same reason I've needed several other
fixes recently: just after creation, GTK3 widgets report their
preferred size as zero.

Fixed by doing basically the same trick I was doing in GTK2, but
deferring it until the "map" event happens later on.

8 years agoMake string_width() work in GTK3.
Simon Tatham [Mon, 24 Aug 2015 18:31:44 +0000 (19:31 +0100)]
Make string_width() work in GTK3.

This was another piece of code that determined text size by
instantiating a GtkLabel and asking for its size, which I had to fix
in gtkfont.c recently because that strategy doesn't work in GTK3.

Replaced the implementation of string_width() with a call to the
function I added in gtkfont.c, and now dialog boxes which depend on
that for their width measurement (e.g. the one in reallyclose()) don't
come out in silly sizes on GTK3 any more.

8 years agoUse columns_force_same_height() for vertical centring.
Simon Tatham [Mon, 24 Aug 2015 18:23:38 +0000 (19:23 +0100)]
Use columns_force_same_height() for vertical centring.

In cases where two controls sit alongside one another such as a label
alongside an edit box, I've previously been arranging for them to be
vertically centred by fiddling with the size request and alignment of
what I assume will be the shorter control. But now I've written
columns_force_same_height(), that's a much easier approach, and it's
also compatible with GTK3 without using a deprecated method; so this
change switches over all vertical centring to doing it that way.

Also, while I'm here, I noticed that the edit box and button of
CTRL_FILESELECT / CTRL_FONTSELECT were not vertically centred, and
since it's now really easy to make sure they are, I've added another
use of columns_force_same_height() there.

8 years agoNew Columns method, columns_force_same_height().
Simon Tatham [Mon, 24 Aug 2015 18:23:32 +0000 (19:23 +0100)]
New Columns method, columns_force_same_height().

This forces two child widgets of a Columns to occupy the same amount
of vertical space, and if one is really shorter than the other,
vertically centres it in the extra space.

8 years agoFactor out columns_find_child() in the Columns class.
Simon Tatham [Mon, 24 Aug 2015 18:12:29 +0000 (19:12 +0100)]
Factor out columns_find_child() in the Columns class.

This is an obviously reusable loop over cols->children looking for a
widget, which I'm about to use a couple more times so it seems worth
pulling it out into its own helper function.

8 years agoAnother GTK3 fix for GtkEntry width.
Simon Tatham [Mon, 24 Aug 2015 18:04:37 +0000 (19:04 +0100)]
Another GTK3 fix for GtkEntry width.

When I committed 5e738877b the other day, I missed another case of the
same thing in the file/font selector handling.

8 years agoUse new GTK3 API call for server-controlled window resize.
Simon Tatham [Mon, 24 Aug 2015 17:59:13 +0000 (18:59 +0100)]
Use new GTK3 API call for server-controlled window resize.

gtk_window_resize_to_geometry() allows us to make use of the already-
set-up WM resize hints to immediately figure out how to resize the
window to a particular character cell size, and hence makes a much
simpler implementation of request_resize() than the previous hackery.

8 years agoIn GTK3, omit our GTK 1/2 workaround for wrapping labels.
Simon Tatham [Sun, 23 Aug 2015 14:01:07 +0000 (15:01 +0100)]
In GTK3, omit our GTK 1/2 workaround for wrapping labels.

Now we're properly implementing the GTK3 height-for-width layout
model, this bodge is no longer necessary.

8 years agoImplement GTK3 height-for-width layout in Columns.
Simon Tatham [Sun, 23 Aug 2015 13:50:47 +0000 (14:50 +0100)]
Implement GTK3 height-for-width layout in Columns.

Now that I've got the main calculation code separated from the GTK2
size_request and size_allocate top-level methods, I can introduce a
completely different set of GTK3 top-level methods, which run the same
underlying calculations but based on different width and height
information.

So now we do proper height-for-width layout, as you can see if you
flip the PuTTY config box to a pane with a wrapping label on it (e.g.
Fonts or Logging) and resize the window horizontally. Where the GTK2
config box just left the wrapped text label at its original size, and
the GTK3 one before this change would reflow the text but without
changing the label's height, now the text reflows and the controls
below it move up and down when the number of lines of wrapped text
changes.

(As far as I'm concerned, that's a nice demo of GTK3's new abilities
but not a critically important UI feature for this app. The more
important point is that switching to the modern layout model removes
one of the remaining uses of the deprecated gtk_widget_size_request.)

8 years agoGTK3 prep: refactor the layout calculation in Columns.
Simon Tatham [Sun, 23 Aug 2015 13:49:01 +0000 (14:49 +0100)]
GTK3 prep: refactor the layout calculation in Columns.

Previously, columns_size_request and columns_size_allocate would each
loop over all the widgets doing computations for both width and
height. Now I've separated out the width parts from the height parts,
and moved both out into four new functions, so that the top-level
columns_size_request and columns_size_allocate are just wrappers that
call the new functions and plumb size and position information between
them and GTK.

Actual functionality should be unchanged by this patch.

8 years agoPerformance: cache character widths returned from Pango.
Simon Tatham [Sun, 23 Aug 2015 13:13:30 +0000 (14:13 +0100)]
Performance: cache character widths returned from Pango.

Profiling reveals that pterm in Pango rendering mode uses an absurd
amount of CPU when it's not even actually _drawing_ the text, because
of all the calls to pango_layout_get_pixel_extents() while
pangofont_draw_text tries to work out which characters it can safely
draw as part of a long string. Caching the results speeds things up
greatly.

8 years agoFix an arithmetic error in the X font downloader cache.
Simon Tatham [Sun, 23 Aug 2015 13:10:59 +0000 (14:10 +0100)]
Fix an arithmetic error in the X font downloader cache.

If you're trying to arrange that an array size is large enough for
element n to exist, and you also want to round it up to the next
multiple of 0x100, you must set the size to (n + 0x100) & ~0xFF, and
not (n + 0xFF) & ~0xFF. Put another way, the number you have to round
up is not n, but the minimum size n+1 that causes array[n] to exist.

8 years ago'pterm --display' should set $DISPLAY inside the terminal.
Simon Tatham [Sat, 22 Aug 2015 14:05:12 +0000 (15:05 +0100)]
'pterm --display' should set $DISPLAY inside the terminal.

If you open a pterm on a different display via the --display
command-line option rather than by setting $DISPLAY, I think (and
other terminals seem to agree) that it's sensible to set $DISPLAY
anyway for processes running inside the terminal.

8 years agoIn GTK3, use the new GtkColorChooserDialog.
Simon Tatham [Sat, 22 Aug 2015 13:49:02 +0000 (14:49 +0100)]
In GTK3, use the new GtkColorChooserDialog.

This replaces the old GtkColorSelectionDialog, and has the convenience
advantage that the actual chooser (with all the 'set colour', 'get
colour' methods) and the containing dialog box are now the same object
implementing multiple interfaces, so I don't keep having to call 'get
me the underlying chooser for this dialog' accessors. Also you now
hook into both the OK and Cancel buttons (and all other response
codes) at the same time with a single event.

8 years agoIn GTK3, unifontsel should use GtkGrid, not GtkTable.
Simon Tatham [Sat, 22 Aug 2015 13:28:04 +0000 (14:28 +0100)]
In GTK3, unifontsel should use GtkGrid, not GtkTable.

GtkTable is deprecated; the way of the future is GtkGrid, in which you
don't have to specify the number of rows/columns in advance (it's
worked out dynamically by observing what row/column numbers you
actually attached anything to), and also you handle expansion
behaviour by setting the "hexpand", "vexpand" or "expand" properties
on the child widgets rather than setting flags in the container.

8 years agoStop using GTK3-deprecated gdk_window_set_background().
Simon Tatham [Sat, 22 Aug 2015 13:11:45 +0000 (14:11 +0100)]
Stop using GTK3-deprecated gdk_window_set_background().

We now have to use gdk_window_set_background_rgba(), having first set
up an appropriate GdkRGBA structure.

8 years agoStop using GTK3-deprecated gdk_get_display().
Simon Tatham [Sat, 22 Aug 2015 13:07:02 +0000 (14:07 +0100)]
Stop using GTK3-deprecated gdk_get_display().

The new way is gdk_display_get_name(gdk_display_get_default()), which
returns a const char * rather than a char *, so I've also had to
fiddle with the prototype and call sites of get_x_display().

(Also included gtkcompat.h into uxputty.c, since that wanted to call
gdk_get_display() but didn't previously include it.)

8 years agoProvide #defines for GTK3-deprecated gtk_{h,v}foo_new().
Simon Tatham [Sat, 22 Aug 2015 12:59:20 +0000 (13:59 +0100)]
Provide #defines for GTK3-deprecated gtk_{h,v}foo_new().

In GTK3, GtkBox, GtkScrollbar and GtkSeparator are all single classes
with a GtkOrientation parameter, whereas in GTK2 the horizontal and
vertical versions were trivial subclasses of them. Hence, the old
constructors are now deprecated, but _only_ the constructors are
affected, since after constructing one you always used methods of the
superclass on it anyway.

Rather than faff about with an ifdef at every call site, I've just put
some wrapper macros in gtkcompat.h to make it easy to keep this code
similar between all supported GTK versions.

8 years agoAvoid deprecated gtk_cell_renderer_get_size in GTK3.
Simon Tatham [Sat, 22 Aug 2015 12:53:29 +0000 (13:53 +0100)]
Avoid deprecated gtk_cell_renderer_get_size in GTK3.

gtk_cell_renderer_get_preferred_size() is the new way to do it.

8 years agoStop using deprecated GTK_STOCK_* in GTK3.
Simon Tatham [Sat, 22 Aug 2015 12:50:56 +0000 (13:50 +0100)]
Stop using deprecated GTK_STOCK_* in GTK3.

According to the GTK3 docs, we're now supposed to use fixed label
strings instead.

8 years agoMake unifontsel_deselect() clear the preview pane.
Simon Tatham [Sat, 22 Aug 2015 12:41:15 +0000 (13:41 +0100)]
Make unifontsel_deselect() clear the preview pane.

In the case where we deselect the previously selected font (e.g.
because we've just changed the filter settings to remove it from the
list), we were leaving the preview pane in its previous state, which
is fine in GTK2 when it just carries on displaying the last thing
drawn to the backing pixmap but goes wrong in GTK3 where we still have
to actually respond to draw events.

But it makes more conceptual sense anyway to actually empty the
preview pane when no font is selected, so now we do that. So now
unifontsel_draw_preview_text() is called from unifontsel_deselect(),
and also the preview-drawing code will still draw the background
rectangle regardless of whether font != NULL.

8 years agoFix crash in GTK3 when unifontsel filter settings change.
Simon Tatham [Sat, 22 Aug 2015 12:41:11 +0000 (13:41 +0100)]
Fix crash in GTK3 when unifontsel filter settings change.

The call to gtk_list_store_clear() in unifontsel_setup_familylist()
was causing a call to family_changed() via the GTK signal system,
which didn't happen in GTK2. family_changed() in turn was calling
unifontsel_select_font(), which got confused when the tree model
didn't match reality, and tried to access a bogus tree iterator.

This is easily fixed by using the existing fs->inhibit_response flag,
which prevents us responding to GTK events when we know they were
generated by our own fiddling about with the data; it's just that we
never needed to set it in unifontsel_setup_familylist() before.

Also, added a check of the return value from the key get_iter call in
unifontsel_select_font(), so that it'll at least fail an assertion
rather than actually trying to access bogus memory. But that operation
_should_ still always succeed, and if it doesn't, it's probably a sign
that we need another use of fs->inhibit_response.

8 years agoFix GTK3 size calculations in unifontsel_new.
Simon Tatham [Sat, 22 Aug 2015 10:46:05 +0000 (11:46 +0100)]
Fix GTK3 size calculations in unifontsel_new.

It turns out that in GTK3, if you instantiate a GtkLabel and
immediately try to find out its preferred size, you get back zero for
both dimensions. Presumably none of that gets figured out properly
until the widget is displayed, or some such.

However, you can retrieve the PangoLayout from the label immediately
and ask Pango for the dimensions of that. That seems like a bit of a
bodge, but it works! The GTK3 unifont selector now comes out with all
the interface elements in sensible sizes - in particular, the preview
drawing area now has non-zero height.

8 years agoIn GTK3, don't use the "has-separator" GtkDialog property.
Simon Tatham [Sat, 22 Aug 2015 10:09:06 +0000 (11:09 +0100)]
In GTK3, don't use the "has-separator" GtkDialog property.

It doesn't exist any more, so the attempt to set it was generating an
annoying runtime warning message.

8 years agoUse GTK3's method of setting GtkEntry min width.
Simon Tatham [Sat, 22 Aug 2015 09:37:48 +0000 (10:37 +0100)]
Use GTK3's method of setting GtkEntry min width.

The config box setup code wants a lot of very narrow edit boxes, so it
decreases their minimum width from the GTK default of 150 pixels. In
GTK 3, we have to do this using gtk_entry_set_width_chars() rather
than gtk_widget_set_size_request() as we were previously using, or it
won't work.

This change by itself seems to restore the GTK3 config box to a
sensible layout, in spite of the fact that my Columns layout class is
still doing all its size allocation the GTK2 way, with no attention
paid to the shiny new GTK3 height-for-width system.

8 years agoRemove arbitrary limit SSH2_MKKEY_ITERS.
Simon Tatham [Fri, 21 Aug 2015 22:40:16 +0000 (23:40 +0100)]
Remove arbitrary limit SSH2_MKKEY_ITERS.

Tim Kosse points out that we now support some combinations of crypto
primitives which break the hardwired assumption that two blocks of
hash output from the session-key derivation algorithm are sufficient
to key every cipher and MAC in the system.

So now ssh2_mkkey is given the desired key length, and performs as
many iterations as necessary.

8 years agoAdd a key-length field to 'struct ssh_mac'.
Simon Tatham [Fri, 21 Aug 2015 22:20:12 +0000 (23:20 +0100)]
Add a key-length field to 'struct ssh_mac'.

The key derivation code has been assuming (though non-critically, as
it happens) that the size of the MAC output is the same as the size of
the MAC key. That isn't even a good assumption for the HMAC family,
due to HMAC-SHA1-96 and also the bug-compatible versions of HMAC-SHA1
that only use 16 bytes of key material; so now we have an explicit
key-length field separate from the MAC-length field.