--- putty-r8859/putty.h	2010-02-04 12:01:08.287795500 +0000
+++ putty-trans/putty.h	2010-02-04 11:48:23.482051100 +0000
@@ -545,6 +545,8 @@
     int hide_mouseptr;
     int sunken_edge;
     int window_border;
+    int transparency;		       /* window transparency level */
+    int opaque_when_focused;
     char answerback[256];
     char printer[128];
     int arabicshaping;
--- putty-r8859/config.c	2010-02-04 12:01:07.620757300 +0000
+++ putty-trans/config.c	2010-02-04 12:31:34.903271900 +0000
@@ -1212,7 +1212,7 @@
 				HELPCTX(session_saved),
 				sessionsaver_handler, P(ssd));
     ssd->listbox->generic.column = 0;
-    ssd->listbox->listbox.height = 7;
+    ssd->listbox->listbox.height = 11;
     if (!midsession) {
 	ssd->loadbutton = ctrl_pushbutton(s, "Load", 'l',
 					  HELPCTX(session_saved),
--- putty-r8859/dialog.c	2010-02-04 12:01:07.568754300 +0000
+++ putty-trans/dialog.c	2010-02-07 01:37:30.453229100 +0000
@@ -473,7 +473,13 @@
 		ctrl->radio.buttondata[button].i)
 		break;
 	/* We expected that `break' to happen, in all circumstances. */
-	assert(button < ctrl->radio.nbuttons);
+	/* assert(button < ctrl->radio.nbuttons); */
+	/* It can now unfortunately happen that that it won't - 
+	 * when a radio button that previously existed now doesn't.
+	 * In that case, we default to the first button
+	 */
+	if (button >= ctrl->radio.nbuttons)
+	    button = 0;
 	dlg_radiobutton_set(ctrl, dlg, button);
     } else if (event == EVENT_VALCHANGE) {
 	button = dlg_radiobutton_get(ctrl, dlg);
--- putty-r8859/settings.c	2010-02-04 12:01:07.802767700 +0000
+++ putty-trans/settings.c	2010-02-04 11:49:53.942225100 +0000
@@ -392,6 +392,8 @@
     write_setting_i(sesskey, "WindowBorder", cfg->window_border);
     write_setting_i(sesskey, "CurType", cfg->cursor_type);
     write_setting_i(sesskey, "BlinkCur", cfg->blink_cur);
+    write_setting_i(sesskey, "Transparency", cfg->transparency);
+    write_setting_i(sesskey, "OpaqueWhenFocused", cfg->opaque_when_focused);
     write_setting_i(sesskey, "Beep", cfg->beep);
     write_setting_i(sesskey, "BeepInd", cfg->beep_ind);
     write_setting_filename(sesskey, "BellWaveFile", cfg->bell_wavefile);
@@ -689,6 +691,8 @@
     gppi(sesskey, "WindowBorder", 1, &cfg->window_border);
     gppi(sesskey, "CurType", 0, &cfg->cursor_type);
     gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur);
+    gppi(sesskey, "Transparency", 0, &cfg->transparency);
+    gppi(sesskey, "OpaqueWhenFocused", 0, &cfg->opaque_when_focused);
     /* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */
     gppi(sesskey, "Beep", 1, &cfg->beep);
     gppi(sesskey, "BeepInd", 0, &cfg->beep_ind);
--- putty-r8859/windows/win_res.rc2	2010-02-04 12:01:02.910487900 +0000
+++ putty-trans/windows/win_res.rc2	2010-02-04 10:45:25.520964000 +0000
@@ -31,7 +31,7 @@
 END
 
 /* Accelerators used: aco */
-IDD_MAINBOX DIALOG DISCARDABLE 0, 0, 300, 252
+IDD_MAINBOX DIALOG DISCARDABLE 0, 0, 300, 277
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "PuTTY Configuration"
 FONT 8, "MS Shell Dlg"
--- putty-r8859/windows/winstuff.h	2010-02-04 12:01:02.943489800 +0000
+++ putty-trans/windows/winstuff.h	2010-02-04 11:40:05.172549400 +0000
@@ -15,6 +15,19 @@
 
 #include "winhelp.h"
 
+#include <winbase.h>
+#include <wingdi.h>
+#include <uxtheme.h>		       /* for struct MARGINS */
+
+#if WINVER < 0x500 || _WIN32_WINNT < 0x0501
+typedef struct _MARGINS {
+  int cxLeftWidth;
+  int cxRightWidth;
+  int cyTopHeight;
+  int cyBottomHeight;
+} MARGINS, *PMARGINS;
+#endif
+
 struct Filename {
     char path[FILENAME_MAX];
 };
@@ -426,6 +439,7 @@
  */
 extern OSVERSIONINFO osVersion;
 BOOL init_winver(void);
+BOOL is_glass_available(void);
 
 /*
  * Exports from sizetip.c.
--- putty-r8859/windows/winhelp.h	2010-02-04 12:01:02.967491100 +0000
+++ putty-trans/windows/winhelp.h	2010-02-04 11:52:22.653730900 +0000
@@ -71,6 +71,8 @@
 #define WINHELP_CTX_appearance_title "appearance.title:config-title"
 #define WINHELP_CTX_appearance_hidemouse "appearance.hidemouse:config-mouseptr"
 #define WINHELP_CTX_appearance_border "appearance.border:config-winborder"
+#define WINHELP_CTX_appearance_transparency "appearance.transparency:config-transparency"
+#define WINHELP_CTX_appearance_opaquefocus "appearance.opaquefocus:config-opaquefocus"
 #define WINHELP_CTX_connection_termtype "connection.termtype:config-termtype"
 #define WINHELP_CTX_connection_termspeed "connection.termspeed:config-termspeed"
 #define WINHELP_CTX_connection_username "connection.username:config-username"
--- putty-r8859/windows/wincfg.c	2010-02-04 12:01:02.981491900 +0000
+++ putty-trans/windows/wincfg.c	2010-02-08 00:18:53.600237900 +0000
@@ -9,6 +9,7 @@
 #include "putty.h"
 #include "dialog.h"
 #include "storage.h"
+#include "winstuff.h"		       /* for is_glass_available() */
 
 static void about_handler(union control *ctrl, void *dlg,
 			  void *data, int event)
@@ -36,6 +37,7 @@
     struct controlset *s;
     union control *c;
     char *str;
+    BOOL with_glass;
 
     if (!midsession) {
 	/*
@@ -87,6 +89,22 @@
         }
     }
 
+    s = ctrl_getset(b, "Window/Appearance", "trans", "Transparency");
+    with_glass = is_glass_available();
+    ctrl_radiobuttons(s, NULL, NO_SHORTCUT, with_glass ? 5 : 4, 
+		      HELPCTX(appearance_transparency), 
+		      dlg_stdradiobutton_handler, 
+		      I(offsetof(Config,transparency)),
+		      "Off", NO_SHORTCUT, I(0),
+		      "Low", NO_SHORTCUT, I(1),
+		      with_glass ? "Med." : "Medium", NO_SHORTCUT, I(2),
+		      "High", NO_SHORTCUT, I(3),
+		      with_glass ? "Glass" : NULL, NO_SHORTCUT, I(-1), NULL);
+    ctrl_checkbox(s, "Opaque when focused", NO_SHORTCUT, 
+		  HELPCTX(appearance_opaquefocus),
+		  dlg_stdcheckbox_handler, 
+		  I(offsetof(Config,opaque_when_focused)));
+
     /*
      * Windows has the AltGr key, which has various Windows-
      * specific options.
--- putty-r8859/windows/windlg.c	2010-02-04 12:01:03.032494900 +0000
+++ putty-trans/windows/windlg.c	2010-02-04 10:38:55.404650700 +0000
@@ -343,7 +343,7 @@
 	/*
 	 * Here we must create the basic standard controls.
 	 */
-	ctlposinit(&cp, hwnd, 3, 3, 235);
+	ctlposinit(&cp, hwnd, 3, 3, 260);
 	wc = &ctrls_base;
 	base_id = IDCX_STDBASE;
     } else {
@@ -430,7 +430,7 @@
 	    r.left = 3;
 	    r.right = r.left + 95;
 	    r.top = 13;
-	    r.bottom = r.top + 219;
+	    r.bottom = r.top + 244;
 	    MapDialogRect(hwnd, &r);
 	    treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
 				      WS_CHILD | WS_VISIBLE |
--- putty-r8859/windows/window.c	2010-02-04 12:01:02.860485000 +0000
+++ putty-trans/windows/window.c	2010-02-08 00:16:42.181721200 +0000
@@ -202,6 +202,54 @@
 
 static UINT wm_mousewheel = WM_MOUSEWHEEL;
 
+static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
+static HRESULT (WINAPI *pDwmExtendFrameIntoClientArea)(HWND, const MARGINS *);
+
+static void load_funcs(void)
+{
+    HMODULE user;
+    HMODULE dwm;
+    user = LoadLibrary("user32");
+    pSetLayeredWindowAttributes =
+        (void *)GetProcAddress(user, "SetLayeredWindowAttributes");
+
+    dwm = LoadLibrary("dwmapi");
+    pDwmIsCompositionEnabled =
+        (void *)GetProcAddress(dwm, "DwmIsCompositionEnabled");
+    pDwmExtendFrameIntoClientArea =
+        (void *)GetProcAddress(dwm, "DwmExtendFrameIntoClientArea");
+}
+
+BOOL is_glass_available(void)
+{
+    BOOL result = FALSE;
+    if (pDwmIsCompositionEnabled)
+        pDwmIsCompositionEnabled(&result);
+    return result;
+}
+
+static void enable_glass(BOOL enabled)
+{
+	MARGINS m = {enabled ? -1 : 0, 0, 0, 0};
+    if (pDwmExtendFrameIntoClientArea)
+        pDwmExtendFrameIntoClientArea(hwnd, &m);
+}
+
+static void update_transparency(void)
+{
+    BOOL opaque = cfg.opaque_when_focused && term->has_focus;
+    if (pSetLayeredWindowAttributes) {
+        int trans = max(cfg.transparency, 0);
+        SetWindowLong(hwnd, GWL_EXSTYLE, trans ? WS_EX_LAYERED : 0);
+        if (trans) {
+            unsigned char alpha = opaque ? 255 : 255 - 16 * trans;
+            pSetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
+        }
+    }
+    enable_glass(cfg.transparency < 0 && !is_full_screen() && !opaque);
+}
+
 /* Dummy routine, only required in plink. */
 void ldisc_update(void *frontend, int echo, int edit)
 {
@@ -324,6 +372,7 @@
     flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
 
     sk_init();
+    load_funcs();
 
     InitCommonControls();
 
@@ -1660,6 +1709,8 @@
 	init_fonts(0,0);
     }
 
+    update_transparency();
+
     /* Oh, looks like we're minimised */
     if (win_width == 0 || win_height == 0)
 	return;
@@ -2594,6 +2645,7 @@
 	flash_window(0);	       /* stop */
 	compose_state = 0;
 	term_update(term);
+	update_transparency();
 	break;
       case WM_KILLFOCUS:
 	show_mouseptr(1);
@@ -2601,6 +2653,7 @@
 	DestroyCaret();
 	caret_x = caret_y = -1;	       /* ensure caret is replaced next time */
 	term_update(term);
+	update_transparency();
 	break;
       case WM_ENTERSIZEMOVE:
 #ifdef RDB_DEBUG_PATCH
