]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
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.

8 years agoAdd copy and free methods to 'struct ssh_hash'.
Simon Tatham [Fri, 21 Aug 2015 22:13:59 +0000 (23:13 +0100)]
Add copy and free methods to 'struct ssh_hash'.

This permits a hash state to be cloned in the middle of being used, so
that multiple strings with the same prefix can be hashed without
having to repeat all the computation over the prefix.

Having done that, we'll also sometimes need to free a hash state that
we aren't generating actual hash output from, so we need a free method
as well.

8 years agoNew test output file, checking all display-relevant stuff.
Simon Tatham [Sun, 16 Aug 2015 17:26:23 +0000 (18:26 +0100)]
New test output file, checking all display-relevant stuff.

This is the test file I wish I'd had while I was rewriting the
text-drawing function this week :-) Better late than never.

8 years agoGTK3 port: add '--with-gtk=3' to the configure script.
Simon Tatham [Sun, 16 Aug 2015 13:53:15 +0000 (14:53 +0100)]
GTK3 port: add '--with-gtk=3' to the configure script.

After the last few changes, the whole codebase now compiles and links
successfully against GTK3, and I can run an experimental pterm. The
config box and font selector look ugly, but the basics all seem to
work.

In order to compile at all, I had to manually bodge in the extra
compile flag -Wno-deprecated-declarations. My plan is to fix all the
uses of deprecated things, and then remove that flag.

I've made GTK3 the second choice, after GTK2 but before GTK1. GTK2 is
the only GTK version that produces a completely sensible build (partly
because the GTK3 port is visibly unfinished, and mostly because its
server-side font handling is just too slow), so it remains the first
choice.

8 years agoGTK3 port: condition out all uses of GdkColormap.
Simon Tatham [Sun, 16 Aug 2015 13:22:14 +0000 (14:22 +0100)]
GTK3 port: condition out all uses of GdkColormap.

The entire concept has gone away in GTK3, which assumes that everyone
is now using modern true-colour video modes and so there's no longer
any reason you shouldn't just casually make up any RGB triple you like
without bothering to ask the display system's permission.

8 years agoGTK3 port: respell GDK_WINDOW_XWINDOW / GDK_DRAWABLE_XID.
Simon Tatham [Sun, 16 Aug 2015 13:16:23 +0000 (14:16 +0100)]
GTK3 port: respell GDK_WINDOW_XWINDOW / GDK_DRAWABLE_XID.

GDK3 now spells both of those as GDK_WINDOW_XID. (Of course 'drawable'
is no longer a relevant concept in GDK3, since pixmaps are no longer
supported and so all drawables are just windows.) We keep backwards
compatibility, of course.

8 years agoGTK3 port: replace size_request in the Columns layout class.
Simon Tatham [Sun, 16 Aug 2015 13:16:08 +0000 (14:16 +0100)]
GTK3 port: replace size_request in the Columns layout class.

It's been replaced by a new pair of methods get_preferred_width and
get_preferred_height. For the moment, I've followed the porting
guide's suggestion of keeping the old size_request function as an
underlying implementation and having each of those methods just return
one of its outputs. The results are ugly, but it'll compile and run,
which is a start.

8 years agoGTK3 port: use gdk_device_grab() in gtkask.c.
Simon Tatham [Sun, 16 Aug 2015 13:36:32 +0000 (14:36 +0100)]
GTK3 port: use gdk_device_grab() in gtkask.c.

This replaces the old gdk_keyboard_grab(), and is what a GTK3 app has
to use for grabbing the keyboard away from all other X clients.

8 years agoGTK3 port: support the new "draw" signal.
Simon Tatham [Sun, 16 Aug 2015 13:34:19 +0000 (14:34 +0100)]
GTK3 port: support the new "draw" signal.

This replaces GTK 1/2's "expose_event", and provides a ready-made
cairo_t to do the drawing with. My previous work has already separated
all constructions of a cairo_t from the subsequent drawing with it, so
the new draw event handlers just have to call the latter without the
former.

8 years agoReimplement GTK uxsel_input_add using GIOChannel.
Simon Tatham [Sun, 16 Aug 2015 12:07:26 +0000 (13:07 +0100)]
Reimplement GTK uxsel_input_add using GIOChannel.

This is the new recommended approach since gdk_input_{add,remove} were
deprecated (and, honestly, seems a lot more sensible - why on earth
would those functions have lived in *GDK* of all places?). The old
implementation is preserved under ifdef for GTK1.

This was the last of the GDK deprecated functions to go! So GTK PuTTY
now compiles cleanly with -DGDK_DISABLE_DEPRECATED in addition to all
the other precautionary flags (though if you do that, you disable GDK
rendering, which greatly slows down server-side font handling). This
completes the GTK2-compatible preparation phase of the GTK 3 migration
guide.

8 years agoChange uxsel_input_add's return type from int to pointer.
Simon Tatham [Sun, 16 Aug 2015 11:50:46 +0000 (12:50 +0100)]
Change uxsel_input_add's return type from int to pointer.

In case a front end needs to store more than an integer id to be
returned to uxsel_input_remove, we now return a pointer to a
frontend-defined structure.

8 years agoUse gtk_window_set_icon() where available.
Simon Tatham [Sun, 16 Aug 2015 08:41:10 +0000 (09:41 +0100)]
Use gtk_window_set_icon() where available.

GTK is deprecating the use of gdk_window_set_icon(), in favour of a
method that doesn't have to drop down to the GDK level at all (and
also doesn't use a pixmap). No reason not to use that instead.

8 years agoRemove an outdated comment.
Simon Tatham [Sun, 16 Aug 2015 08:29:47 +0000 (09:29 +0100)]
Remove an outdated comment.

I've just noticed the comment in gtkfont.c that said wouldn't it be
nice to find a way to avoid the GDK pixmap-stretching code when using
Pango fonts. We now do support this, but we support it in gtkwin.c
rather than gtkfont.c - because we do it using a Cairo transformation
matrix, so it still takes place at the level above Pango rather than
in Pango proper. (I never did find out whether Pango itself included
facilities to arbitrarily stretch a font.)

Hence, this comment is useless now. Discard.

8 years agoReplace deprecated GDK_DISPLAY() with modern facilities.
Simon Tatham [Sun, 16 Aug 2015 08:23:32 +0000 (09:23 +0100)]
Replace deprecated GDK_DISPLAY() with modern facilities.

We still don't actually support more than one X display active at
once, so it's sufficient to replace every call to that macro with
GDK_DISPLAY_XDISPLAY(gdk_display_get_default()).

8 years agoMake the use of server-side backing pixmaps in GTK optional.
Simon Tatham [Sun, 16 Aug 2015 08:02:31 +0000 (09:02 +0100)]
Make the use of server-side backing pixmaps in GTK optional.

We won't be able to use them in GTK3, or when compiling with GTK2 and
-DGDK_DISABLE_DEPRECATED.

This applies to the one we use for the main terminal window, and also
the small one we use for the preview pane in the unified font selector.

8 years agoSaw unifontsel_draw_preview_text() in half.
Simon Tatham [Sun, 16 Aug 2015 09:32:24 +0000 (10:32 +0100)]
Saw unifontsel_draw_preview_text() in half.

Now it's got an inner half that does actual drawing given a draw
context, and an outer half that sets up and tears down the draw
context. Sooner or later the inner half will need calling
independently of the outer, because GTK3's draw event will provide a
ready-made cairo_t.

8 years agoCall draw_stretch_before *after* setting up the clip region.
Simon Tatham [Sun, 16 Aug 2015 07:55:04 +0000 (08:55 +0100)]
Call draw_stretch_before *after* setting up the clip region.

A small bug in yesterday's work: since in Cairo mode
draw_stretch_before changes the transformation matrix, if we do it
before calling draw_clip then the clip region will be interpreted in
the transformed coordinates.

This caused a subtle display bug in yesterday's commit: drawing one
half of double-height text would have drawn _both_ halves of it on to
the window's backing pixmap, but only copied the correct half on to
the window proper - but the overdrawing on the pixmap would have shown
up if the window was hidden and re-exposed.

8 years agoWithdraw the horrible bodge in make_mouse_ptr().
Simon Tatham [Sat, 15 Aug 2015 20:07:35 +0000 (21:07 +0100)]
Withdraw the horrible bodge in make_mouse_ptr().

We were previously building our own mouse pointers out of pixmaps,
having first drawn characters from the X server standard font 'cursor'
on to those pixmaps, giving an effect almost exactly the same as just
calling gdk_cursor_new(some constant) except that we got to choose the
foreground and background colours of the resulting pointers.

But it's not clear why we needed to do that! In both GTK1 and GTK2 as
of my current testing, the standard colours appear to be just what I
wanted anyway (white pointer with black outline). The previous
implementation (and commit comment) was written in 2002, so perhaps it
was working around a GTK1 bug of the time.

So I've removed it completely, and replaced it with simple calls to
gdk_cursor_new  (plus a workaround for GTK1's lack of GDK_BLANK_CURSOR,
but that's still much simpler than the previous code). If anyone does
report a colour problem, I may have to go back to doing something
clever, but if I can possibly arrange it, I'll want to do it by some
other technique, probably (as suggested in a comment in the previous
implementation) getting the underlying X cursor id and calling
XRecolorCursor.

8 years agoRefactor the GTK drawing system to do both GDK and Cairo.
Simon Tatham [Sat, 15 Aug 2015 20:05:56 +0000 (21:05 +0100)]
Refactor the GTK drawing system to do both GDK and Cairo.

We're going to have to use Cairo in the GTK3 port, because that's all
GTK3 supports; but we still need old-style GDK for GTK1 support, and
also for performance reasons in GTK2 (see below). Hence, this change
completely restructures GTK PuTTY's drawing code so that there's a
central 'drawing context' structure which contains a type code
indicating GDK or Cairo, and then either some GDK gubbins or some
Cairo gubbins as appropriate; all actual drawing is abstracted through
a set of routines which test the type code in that structure and do
one thing or another. And because the type code is tested at run time,
both sets of drawing primitives can be compiled in at once, and where
possible, they will be.

X server-side bitmap fonts are still supported in the Cairo world, but
because Cairo drawing is entirely client-side, they have to work by
cheekily downloading each glyph bitmap from the server when it's first
needed, and building up a client-side cache of 'cairo_surface_t's
containing the bitmaps with which we then draw on the window. This
technique works, but it's rather slow; hence, even in GTK2, we keep
the GDK drawing back end compiled in, and switch over to it when the
main selected font is a bitmap one.

One visible effect of the new Cairo routines is in the double-width
and double-height text you can get by sending ESC # 3, ESC # 4 and
ESC # 6 escape sequences. In GDK, that's always been done by a really
horrible process of manually scaling the bitmap, server-side, column
by column and row by row, causing each pixel to be exactly doubled or
quadrupled. But in Cairo, we can just set a transformation matrix, and
then that takes effect _before_ the scalable fonts are rendered - so
the results are visibly nicer, and use all the available resolution.

(Sadly, if you're using a server-side bitmap font as your primary one,
then the GDK backend will be selected for all drawing in the terminal
as a whole - so in that situation, even fallback characters absent
from the primary font and rendered by Pango will get the old GDK
scaling treatment. It's only if your main font is scalable, so that
the Cairo backend is selected, that DW/DH characters will come out
looking nice.)

8 years agoStop multifont fallback from crashing in GTK1.
Simon Tatham [Sat, 15 Aug 2015 19:26:07 +0000 (20:26 +0100)]
Stop multifont fallback from crashing in GTK1.

I was tacitly assuming that mfont->fallback would always be non-NULL,
which is true in a world containing Pango, but untrue in GTK1 when
Pango isn't there. In that situation we fall back to just omitting the
characters that would be displayed in the fallback font, on the
grounds that that's better than dereferencing through a NULL vtable.

8 years agoClose file descriptor in test main().
Tim Kosse [Tue, 11 Aug 2015 09:30:13 +0000 (11:30 +0200)]
Close file descriptor in test main().

Some static analyzers are complaining about it.

8 years agoFix signature of platform_new_connection.
Tim Kosse [Tue, 11 Aug 2015 09:27:20 +0000 (11:27 +0200)]
Fix signature of platform_new_connection.

The hostname is a const char *.

8 years agoUse DWORD as length argument for RegQueryValueEx.
Tim Kosse [Tue, 11 Aug 2015 12:34:11 +0000 (14:34 +0200)]
Use DWORD as length argument for RegQueryValueEx.

8 years agoCast return value of ShellExecute to INT_PTR.
Tim Kosse [Tue, 11 Aug 2015 12:30:14 +0000 (14:30 +0200)]
Cast return value of ShellExecute to INT_PTR.

ShellExecute returns HINSTANCE which is a typedef for void*. Cast the
return value to INT_PTR instead of int to avoid truncation on 64bit
builds.

8 years agoUse INT_PTR not int to store result of DialogBoxParam.
Tim Kosse [Tue, 11 Aug 2015 12:27:48 +0000 (14:27 +0200)]
Use INT_PTR not int to store result of DialogBoxParam.

8 years agoDLGPROC callbacks should return INT_PTR.
Tim Kosse [Tue, 11 Aug 2015 12:22:09 +0000 (14:22 +0200)]
DLGPROC callbacks should return INT_PTR.

The Windows headers define the return type of DLGPROC as INT_PTR which
on 64bit Windows has a different size than int.

8 years agoFix type of third argument to AppendMenu
Tim Kosse [Tue, 11 Aug 2015 12:25:42 +0000 (14:25 +0200)]
Fix type of third argument to AppendMenu

We are passing pointers as third argument to AppendMenu. Do not
truncate them to UINT, use UINT_PTR instead which has the required
size on 64bit Windows.

8 years agoFix type of 4th argument to WinHelp
Tim Kosse [Tue, 11 Aug 2015 12:07:36 +0000 (14:07 +0200)]
Fix type of 4th argument to WinHelp

We're passing a pointer as 4th argument to WinHelp. Do not cast it to
DWORD which would truncate the pointer. Instead use UINT_PTR as that
is what WinHelp expects.

8 years agoCast pointers to uintptr_t instead of unsigned {long,int}.
Tim Kosse [Tue, 11 Aug 2015 12:01:02 +0000 (14:01 +0200)]
Cast pointers to uintptr_t instead of unsigned {long,int}.

On 64bit Windows, pointers are 64bit whereas both unsigned long and
unsigned int are 32bit. Using uintptr_t avoids truncation.

8 years agoFix warning about mismatched constness.
Tim Kosse [Tue, 11 Aug 2015 12:18:13 +0000 (14:18 +0200)]
Fix warning about mismatched constness.

8 years agoUse correct type to print Windows error codes.
Tim Kosse [Tue, 11 Aug 2015 12:13:20 +0000 (14:13 +0200)]
Use correct type to print Windows error codes.

GetLastError returns DWORD. To print it, convert it to unsigned int
and use the %u format specifier.

8 years agoDo not re-define SECURITY_WIN32 if already defined.
Tim Kosse [Tue, 11 Aug 2015 09:25:40 +0000 (11:25 +0200)]
Do not re-define SECURITY_WIN32 if already defined.

Some toolchains have SECURITY_WIN32 defined by default.

8 years agoMake manifest files work with 64bit builds of PuTTY.
Tim Kosse [Tue, 11 Aug 2015 09:10:33 +0000 (11:10 +0200)]
Make manifest files work with 64bit builds of PuTTY.

Otherwise we would get 0xc000007b error when trying to start a 64bit
PuTTY Windows binary.

8 years agoDetect end of string in fingerprint alignment.
Tim Kosse [Tue, 11 Aug 2015 11:45:26 +0000 (13:45 +0200)]
Detect end of string in fingerprint alignment.

This prevents writing past the end of the buffer should
ssh2_fingerprint ever return a fingerprint not containing a colon.

8 years agoFix __uint128_t compile error on MinGW.
Tim Kosse [Tue, 11 Aug 2015 07:43:34 +0000 (09:43 +0200)]
Fix  __uint128_t compile error on MinGW.

MinGW has __uint128_t, but not __uint64_t.

8 years agoRemove an unused variable.
Tim Kosse [Tue, 11 Aug 2015 12:29:44 +0000 (14:29 +0200)]
Remove an unused variable.

8 years agoRemove an unused variable.
Tim Kosse [Tue, 11 Aug 2015 12:05:59 +0000 (14:05 +0200)]
Remove an unused variable.

8 years agoFix warning about uninitialized variable.
Tim Kosse [Tue, 11 Aug 2015 08:44:00 +0000 (10:44 +0200)]
Fix warning about uninitialized variable.

Some MinGW versions do not know that assert(0) never returns. This
change also handles the case of building with NDEBUG.

8 years agoRemove unused variable.
Tim Kosse [Tue, 11 Aug 2015 11:44:28 +0000 (13:44 +0200)]
Remove unused variable.

8 years agoFix warning about missing return in ssh2_kexinit_addalg
Tim Kosse [Tue, 11 Aug 2015 07:39:05 +0000 (09:39 +0200)]
Fix warning about missing return in ssh2_kexinit_addalg

8 years agoFix a format string vulnerability if MALLOC_LOG is set.
Tim Kosse [Fri, 1 May 2015 13:55:37 +0000 (15:55 +0200)]
Fix a format string vulnerability if MALLOC_LOG is set.

8 years agoFix format string vulnerabilities.
Tim Kosse [Fri, 1 May 2015 13:54:51 +0000 (15:54 +0200)]
Fix format string vulnerabilities.

Reported by Jong-Gwon Kim. Also fixes a few memory leaks in the
process.

8 years agoAdd a FAQ for 'checksum mismatch' reports.
Simon Tatham [Sun, 9 Aug 2015 20:18:27 +0000 (21:18 +0100)]
Add a FAQ for 'checksum mismatch' reports.

The aim is to try to reduce the incidence of the two least helpful
classes of those reports: the ones which have just got mismatched
checksum files, and the ones which don't tell us the information that
would help.