projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A user points out that we should free the 'hProcess' and 'hThread'
[u/mdw/putty]
/
windows
/
window.c
diff --git
a/windows/window.c
b/windows/window.c
index
df69db1
..
5eb1d04
100644
(file)
--- a/
windows/window.c
+++ b/
windows/window.c
@@
-174,8
+174,9
@@
static HFONT fonts[FONT_MAXNO];
static LOGFONT lfont;
static int fontflag[FONT_MAXNO];
static enum {
static LOGFONT lfont;
static int fontflag[FONT_MAXNO];
static enum {
- BOLD_COLOURS, BOLD_SHADOW, BOLD_FONT
-} bold_mode;
+ BOLD_NONE, BOLD_SHADOW, BOLD_FONT
+} bold_font_mode;
+static int bold_colours;
static enum {
UND_LINE, UND_FONT
} und_mode;
static enum {
UND_LINE, UND_FONT
} und_mode;
@@
-699,6
+700,12
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
}
/*
}
/*
+ * Initialise the fonts, simultaneously correcting the guesses
+ * for font_{width,height}.
+ */
+ init_fonts(0,0);
+
+ /*
* Initialise the terminal. (We have to do this _after_
* creating the window, since the terminal is the first thing
* which will call schedule_timer(), which will in turn call
* Initialise the terminal. (We have to do this _after_
* creating the window, since the terminal is the first thing
* which will call schedule_timer(), which will in turn call
@@
-712,12
+719,6
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
conf_get_int(conf, CONF_savelines));
/*
conf_get_int(conf, CONF_savelines));
/*
- * Initialise the fonts, simultaneously correcting the guesses
- * for font_{width,height}.
- */
- init_fonts(0,0);
-
- /*
* Correct the guesses for extra_{width,height}.
*/
{
* Correct the guesses for extra_{width,height}.
*/
{
@@
-1409,8
+1410,9
@@
static void init_fonts(int pick_width, int pick_height)
for (i = 0; i < FONT_MAXNO; i++)
fonts[i] = NULL;
for (i = 0; i < FONT_MAXNO; i++)
fonts[i] = NULL;
- bold_mode = conf_get_int(conf, CONF_bold_colour) ?
- BOLD_COLOURS : BOLD_FONT;
+ bold_font_mode = conf_get_int(conf, CONF_bold_style) & 1 ?
+ BOLD_FONT : BOLD_NONE;
+ bold_colours = conf_get_int(conf, CONF_bold_style) & 2 ? TRUE : FALSE;
und_mode = UND_FONT;
font = conf_get_fontspec(conf, CONF_font);
und_mode = UND_FONT;
font = conf_get_fontspec(conf, CONF_font);
@@
-1535,7
+1537,7
@@
static void init_fonts(int pick_width, int pick_height)
}
}
}
}
- if (bold_mode == BOLD_FONT) {
+ if (bold_
font_
mode == BOLD_FONT) {
f(FONT_BOLD, font->charset, fw_bold, FALSE);
}
#undef f
f(FONT_BOLD, font->charset, fw_bold, FALSE);
}
#undef f
@@
-1562,9
+1564,9
@@
static void init_fonts(int pick_width, int pick_height)
fonts[FONT_UNDERLINE] = 0;
}
fonts[FONT_UNDERLINE] = 0;
}
- if (bold_mode == BOLD_FONT &&
+ if (bold_
font_
mode == BOLD_FONT &&
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
- bold_mode = BOLD_SHADOW;
+ bold_
font_
mode = BOLD_SHADOW;
DeleteObject(fonts[FONT_BOLD]);
fonts[FONT_BOLD] = 0;
}
DeleteObject(fonts[FONT_BOLD]);
fonts[FONT_BOLD] = 0;
}
@@
-2010,10
+2012,14
@@
void notify_remote_exit(void *fe)
}
}
}
}
-void timer_change_notify(long next)
+void timer_change_notify(
unsigned
long next)
{
{
- long ticks = next - GETTICKCOUNT();
- if (ticks <= 0) ticks = 1; /* just in case */
+ unsigned long now = GETTICKCOUNT();
+ long ticks;
+ if (now - next < INT_MAX)
+ ticks = 0;
+ else
+ ticks = next - now;
KillTimer(hwnd, TIMING_TIMER_ID);
SetTimer(hwnd, TIMING_TIMER_ID, ticks, NULL);
timing_next_time = next;
KillTimer(hwnd, TIMING_TIMER_ID);
SetTimer(hwnd, TIMING_TIMER_ID, ticks, NULL);
timing_next_time = next;
@@
-2040,7
+2046,7
@@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
switch (message) {
case WM_TIMER:
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
switch (message) {
case WM_TIMER:
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
- long next;
+
unsigned
long next;
KillTimer(hwnd, TIMING_TIMER_ID);
if (run_timers(timing_next_time, &next)) {
KillTimer(hwnd, TIMING_TIMER_ID);
if (run_timers(timing_next_time, &next)) {
@@
-2150,6
+2156,8
@@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
si.lpReserved2 = NULL;
CreateProcess(b, cl, NULL, NULL, inherit_handles,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
si.lpReserved2 = NULL;
CreateProcess(b, cl, NULL, NULL, inherit_handles,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
if (filemap)
CloseHandle(filemap);
if (filemap)
CloseHandle(filemap);
@@
-2333,8
+2341,8
@@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
conf_get_int(prev_conf, CONF_font_quality) ||
conf_get_int(conf, CONF_vtmode) !=
conf_get_int(prev_conf, CONF_vtmode) ||
conf_get_int(prev_conf, CONF_font_quality) ||
conf_get_int(conf, CONF_vtmode) !=
conf_get_int(prev_conf, CONF_vtmode) ||
- conf_get_int(conf, CONF_bold_
colour
) !=
- conf_get_int(prev_conf, CONF_bold_
colour
) ||
+ conf_get_int(conf, CONF_bold_
style
) !=
+ conf_get_int(prev_conf, CONF_bold_
style
) ||
resize_action == RESIZE_DISABLED ||
resize_action == RESIZE_EITHER ||
resize_action != conf_get_int(prev_conf,
resize_action == RESIZE_DISABLED ||
resize_action == RESIZE_EITHER ||
resize_action != conf_get_int(prev_conf,
@@
-3215,8
+3223,9
@@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
} else
break;
} else
break;
- if (send_raw_mouse && shift_pressed &&
- !(conf_get_int(conf, CONF_mouse_override))) {
+ if (send_raw_mouse &&
+ !(conf_get_int(conf, CONF_mouse_override) &&
+ shift_pressed)) {
/* Mouse wheel position is in screen coordinates for
* some reason */
POINT p;
/* Mouse wheel position is in screen coordinates for
* some reason */
POINT p;
@@
-3323,6
+3332,7
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
int text_adjust = 0;
int xoffset = 0;
int maxlen, remaining, opaque;
int text_adjust = 0;
int xoffset = 0;
int maxlen, remaining, opaque;
+ int is_cursor = FALSE;
static int *lpDx = NULL;
static int lpDx_len = 0;
int *lpDx_maybe;
static int *lpDx = NULL;
static int lpDx_len = 0;
int *lpDx_maybe;
@@
-3346,11
+3356,9
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
if ((attr & TATTR_ACTCURS) && (cursor_type == 0 || term->big_cursor)) {
attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS);
if ((attr & TATTR_ACTCURS) && (cursor_type == 0 || term->big_cursor)) {
attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS);
- if (bold_mode == BOLD_COLOURS)
- attr &= ~ATTR_BOLD;
-
/* cursor fg and bg */
attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT);
/* cursor fg and bg */
attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT);
+ is_cursor = TRUE;
}
nfont = 0;
}
nfont = 0;
@@
-3412,7
+3420,7
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
- if (bold_mode == BOLD_FONT && (attr & ATTR_BOLD))
+ if (bold_
font_
mode == BOLD_FONT && (attr & ATTR_BOLD))
nfont |= FONT_BOLD;
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
nfont |= FONT_UNDERLINE;
nfont |= FONT_BOLD;
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
nfont |= FONT_UNDERLINE;
@@
-3432,11
+3440,11
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
nfg = nbg;
nbg = t;
}
nfg = nbg;
nbg = t;
}
- if (bold_
mode == BOLD_COLOURS && (attr & ATTR_BOLD)
) {
+ if (bold_
colours && (attr & ATTR_BOLD) && !is_cursor
) {
if (nfg < 16) nfg |= 8;
else if (nfg >= 256) nfg |= 1;
}
if (nfg < 16) nfg |= 8;
else if (nfg >= 256) nfg |= 1;
}
- if (bold_
mode == BOLD_COLOURS
&& (attr & ATTR_BLINK)) {
+ if (bold_
colours
&& (attr & ATTR_BLINK)) {
if (nbg < 16) nbg |= 8;
else if (nbg >= 256) nbg |= 1;
}
if (nbg < 16) nbg |= 8;
else if (nbg >= 256) nbg |= 1;
}
@@
-3586,7
+3594,7
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, uni_buf, nlen,
lpDx_maybe);
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, uni_buf, nlen,
lpDx_maybe);
- if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ if (bold_
font_
mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
@@
-3611,7
+3619,7
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, directbuf, len, lpDx_maybe);
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, directbuf, len, lpDx_maybe);
- if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ if (bold_
font_
mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
/* GRR: This draws the character outside its box and
SetBkMode(hdc, TRANSPARENT);
/* GRR: This draws the character outside its box and
@@
-3650,7
+3658,7
@@
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
opaque && !(attr & TATTR_COMBINING));
/* And the shadow bold hack. */
opaque && !(attr & TATTR_COMBINING));
/* And the shadow bold hack. */
- if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ if (bold_
font_
mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
@@
-4930,7
+4938,7
@@
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
bgcolour = tmpcolour;
}
bgcolour = tmpcolour;
}
- if (bold_
mode == BOLD_COLOURS
&& (attr[i] & ATTR_BOLD)) {
+ if (bold_
colours
&& (attr[i] & ATTR_BOLD)) {
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
@@
-5021,7
+5029,7
@@
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
bgcolour = tmpcolour;
}
bgcolour = tmpcolour;
}
- if (bold_
mode == BOLD_COLOURS
&& (attr[tindex] & ATTR_BOLD)) {
+ if (bold_
colours
&& (attr[tindex] & ATTR_BOLD)) {
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
if (fgcolour < 8) /* ANSI colours */
fgcolour += 8;
else if (fgcolour >= 256) /* Default colours */
@@
-5038,7
+5046,7
@@
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
/*
* Collect other attributes
*/
/*
* Collect other attributes
*/
- if (bold_
mode != BOLD_COLOURS
)
+ if (bold_
font_mode != BOLD_NONE
)
attrBold = attr[tindex] & ATTR_BOLD;
else
attrBold = 0;
attrBold = attr[tindex] & ATTR_BOLD;
else
attrBold = 0;
@@
-5057,7
+5065,7
@@
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
bgcolour = -1; /* No coloring */
if (fgcolour >= 256) { /* Default colour */
bgcolour = -1; /* No coloring */
if (fgcolour >= 256) { /* Default colour */
- if (bold_
mode == BOLD_COLOURS
&& (fgcolour & 1) && bgcolour == -1)
+ if (bold_
colours
&& (fgcolour & 1) && bgcolour == -1)
attrBold = ATTR_BOLD; /* Emphasize text with bold attribute */
fgcolour = -1; /* No coloring */
attrBold = ATTR_BOLD; /* Emphasize text with bold attribute */
fgcolour = -1; /* No coloring */
@@
-5353,9
+5361,9
@@
static int flashing = 0;
* Timer for platforms where we must maintain window flashing manually
* (e.g., Win95).
*/
* Timer for platforms where we must maintain window flashing manually
* (e.g., Win95).
*/
-static void flash_window_timer(void *ctx, long now)
+static void flash_window_timer(void *ctx,
unsigned
long now)
{
{
- if (flashing && now
- next_flash >= 0
) {
+ if (flashing && now
== next_flash
) {
flash_window(1);
}
}
flash_window(1);
}
}