Граф коммитов

4455 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 1df12e3915 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.
2015-08-21 23:40:36 +01:00
Simon Tatham 67629cc0ba 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.
2015-08-16 18:26:23 +01:00
Simon Tatham 54a52b5eba 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.
2015-08-16 14:53:15 +01:00
Simon Tatham ccd7097330 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.
2015-08-16 14:50:48 +01:00
Simon Tatham 0ffc564351 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.
2015-08-16 14:50:48 +01:00
Simon Tatham aac9d5fcf7 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.
2015-08-16 14:50:48 +01:00
Simon Tatham 59a232c161 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.
2015-08-16 14:50:37 +01:00
Simon Tatham afae35eb90 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.
2015-08-16 14:50:28 +01:00
Simon Tatham 280b14f129 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.
2015-08-16 13:11:51 +01:00
Simon Tatham b5423b51d4 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.
2015-08-16 13:11:51 +01:00
Simon Tatham 0413cc856c 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.
2015-08-16 13:11:51 +01:00
Simon Tatham f853b695de 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.
2015-08-16 13:11:51 +01:00
Simon Tatham 1b3b993467 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()).
2015-08-16 13:11:51 +01:00
Simon Tatham 5319c659ad 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.
2015-08-16 13:11:06 +01:00
Simon Tatham 066bce3d19 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.
2015-08-16 13:10:42 +01:00
Simon Tatham 828ad5d6d4 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.
2015-08-16 09:08:19 +01:00
Simon Tatham 3c912e7994 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.
2015-08-15 21:07:35 +01:00
Simon Tatham f750a18587 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.)
2015-08-15 21:05:56 +01:00
Simon Tatham 0f60287f66 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.
2015-08-15 20:51:44 +01:00
Tim Kosse f3f215423b Close file descriptor in test main().
Some static analyzers are complaining about it.
2015-08-15 13:54:55 +01:00
Tim Kosse a6bd42ca24 Fix signature of platform_new_connection.
The hostname is a const char *.
2015-08-15 13:54:55 +01:00
Tim Kosse 636f9cf2ee Use DWORD as length argument for RegQueryValueEx. 2015-08-15 13:54:55 +01:00
Tim Kosse 44c107d56a 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.
2015-08-15 13:54:53 +01:00
Tim Kosse 3ca54e45e3 Use INT_PTR not int to store result of DialogBoxParam. 2015-08-15 13:54:53 +01:00
Tim Kosse 1ce39113f5 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.
2015-08-15 13:54:50 +01:00
Tim Kosse a39904388f 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.
2015-08-15 13:54:48 +01:00
Tim Kosse 71bc6a3459 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.
2015-08-15 13:54:46 +01:00
Tim Kosse f2e61275f2 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.
2015-08-15 13:54:46 +01:00
Tim Kosse 9965cd8a53 Fix warning about mismatched constness. 2015-08-15 13:54:46 +01:00
Tim Kosse 6539d39755 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.
2015-08-15 13:54:44 +01:00
Tim Kosse 1f6504c2de Do not re-define SECURITY_WIN32 if already defined.
Some toolchains have SECURITY_WIN32 defined by default.
2015-08-15 13:54:44 +01:00
Tim Kosse c058fc4ea2 Make manifest files work with 64bit builds of PuTTY.
Otherwise we would get 0xc000007b error when trying to start a 64bit
PuTTY Windows binary.
2015-08-15 13:54:44 +01:00
Tim Kosse fe210692fd 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.
2015-08-15 13:54:41 +01:00
Tim Kosse 3377ea57f5 Fix __uint128_t compile error on MinGW.
MinGW has __uint128_t, but not __uint64_t.
2015-08-15 13:54:41 +01:00
Tim Kosse 98f20bef77 Remove an unused variable. 2015-08-15 13:54:41 +01:00
Tim Kosse 481ebd232e Remove an unused variable. 2015-08-15 13:54:41 +01:00
Tim Kosse 05c7678fdb 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.
2015-08-15 13:54:39 +01:00
Tim Kosse 5f37d92450 Remove unused variable. 2015-08-15 13:24:27 +01:00
Tim Kosse ce9b13db53 Fix warning about missing return in ssh2_kexinit_addalg 2015-08-15 13:24:27 +01:00
Tim Kosse e443fd3a77 Fix a format string vulnerability if MALLOC_LOG is set. 2015-08-10 20:04:09 +01:00
Tim Kosse 6a70f944f6 Fix format string vulnerabilities.
Reported by Jong-Gwon Kim. Also fixes a few memory leaks in the
process.
2015-08-10 20:03:41 +01:00
Simon Tatham 8ff3b22243 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.
2015-08-09 21:18:27 +01:00
Simon Tatham 6eca89aebc Fix compile failure.
I'm sure I removed that 'return 0' at some point! But I must have made
a git error which excluded it from the commit I actually pushed, ahem.
2015-08-09 11:56:38 +01:00
Simon Tatham 7a80ab14e0 GTK 3 prep: write a replacement for gtk_quit_add().
GTK 2 has deprecated it and provided no replacement; a bug tracker
entry I found on the subject suggested that it was functionality that
didn't really belong in GTK, and glib ought to provide a replacement
instead, which would be a perfectly fine thing to suggest if they had
waited for glib to get round to doing so *before* throwing out a
function people were actually using. Sigh.

Anyway, it turns out that subsidiary invocations of gtk_main() don't
happen inside GTK as far as I can see, so all I need to do is to make
sure my own invocations of gtk_main() are followed by a cleanup
function which runs any quit functions that I've registered.

That was the last deprecated GTK function, so we now build cleanly
with -DGTK_DISABLE_DEPRECATED. (But, as mentioned a couple of commits
ago, we still don't build with -DGDK_DISABLE_DEPRECATED, because that
has migrating to Cairo drawing as a prerequisite.)
2015-08-09 11:39:40 +01:00
Simon Tatham 78592116a5 Use gtkcompat.h to slim down a few ifdefs.
Now that I've got a general place to centralise handling of at least
the simple differences between GTK 1 and 2, I should use it wherever
possible. So this commit removes just a small number of ifdefs which
are either obsoleted by definitions already in gtkcompat.h (like
set_size_request vs set_usize), or can easily be replaced by adding
another (e.g. gtk_color_selection_set_has_opacity_control).
2015-08-09 09:59:25 +01:00
Simon Tatham 5fa22495c7 GTK 3 prep: stop using *nearly* all GTK deprecated functions.
Building with -DGTK_DISABLE_DEPRECATED, we now suffer only one compile
failure, for the use of gtk_quit_add() in idle_toplevel_callback_func.
That function is apparently removed with no replacement in GTK 3, so
I'll need to find a completely different approach to getting toplevel
callbacks to run only in the outermost instance of gtk_main().

Also, this change doesn't do anything about the use of *GDK*
deprecated functions, because those include the entire family of
old-style drawing functions - i.e. the only way to build cleanly with
-DGDK_DISABLE_DEPRECATED will be to switch to Cairo drawing.
2015-08-08 18:30:55 +01:00
Simon Tatham 5e55b7a978 Switch to using gtk_window_parse_geometry in GTK 2.
On GTK versions where it's available, this is a much nicer way of
handling the -geometry command-line option, since not only do we get
all the faffing about with gravity for free, it also automatically
sets the user-position WM hints.
2015-08-08 18:23:38 +01:00
Simon Tatham fbb7c8c481 GTK 3 prep: replace GtkFileSelection with GtkFileChooserDialog.
I've put in a special #define to control this selection, in case I
decide that for reasons of taste I'd prefer to switch back to
GtkFileSelection in GTK2 which supports both!
2015-08-08 17:56:30 +01:00
Simon Tatham 961fd07d08 GTK 3 prep: use gtk_color_selection_get_current_color().
Replaces the deprecated gtk_color_selection_set_color() which took an
array of four doubles (RGBA), and instead takes a 'GdkColor' struct
containing four 16-bit integers.

For GTK1, we still have to retain the original version.
2015-08-08 17:56:28 +01:00
Simon Tatham 1e4273a929 GTK 3 prep: use the glib names for base object types.
All the things like GtkType, GtkObject, gtk_signal_connect and so on
should now consistently have the new-style glib names like GType,
GObject, g_signal_connect, etc.
2015-08-08 17:55:10 +01:00