#include "keymap.h"
#include "w32heap.h"
-#include "w32bdf.h"
#include <shellapi.h>
#include "font.h"
extern int w32_codepage_for_font (char *fontname);
extern Cursor w32_load_cursor (LPCTSTR name);
-extern glyph_metric *w32_BDF_TextMetric(bdffont *fontp,
- unsigned char *text, int dim);
extern Lisp_Object Vwindow_system;
#define x_any_window_to_frame x_window_to_frame
#endif
-/* Dynamic linking to GetFontUnicodeRanges (not available on 95, 98, ME). */
-DWORD (PASCAL *pfnGetFontUnicodeRanges) (HDC device, GLYPHSET *ranges);
+/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
+BOOL (PASCAL *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
+
+#ifndef LWA_ALPHA
+#define LWA_ALPHA 0x02
+#endif
+/* WS_EX_LAYERED is defined unconditionally by MingW, but only for W2K and
+ later targets by MSVC headers. */
+#ifndef WS_EX_LAYERED
+#define WS_EX_LAYERED 0x80000
+#endif
/* Frame being updated by update_frame. This is declared in term.c.
This is set by update_begin and looked at by all the
void x_wm_set_window_state P_ ((struct frame *, int));
void x_wm_set_icon_pixmap P_ ((struct frame *, int));
static void w32_initialize P_ ((void));
-static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
-int x_compute_min_glyph_bounds P_ ((struct frame *));
static void x_update_end P_ ((struct frame *));
static void w32_frame_up_to_date P_ ((struct frame *));
static void w32_set_terminal_modes P_ ((struct terminal *));
release_frame_dc (f, hdc);
}
+#define OPAQUE_FRAME 255
+
+void
+x_set_frame_alpha (f)
+ struct frame *f;
+{
+ struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
+ double alpha = 1.0;
+ double alpha_min = 1.0;
+ BYTE opac;
+ LONG ex_style;
+ HWND window = FRAME_W32_WINDOW (f);
+
+ /* Older versions of Windows do not support transparency. */
+ if (!pfnSetLayeredWindowAttributes)
+ return;
+
+ if (dpyinfo->x_highlight_frame == f)
+ alpha = f->alpha[0];
+ else
+ alpha = f->alpha[1];
+
+ if (FLOATP (Vframe_alpha_lower_limit))
+ alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
+ else if (INTEGERP (Vframe_alpha_lower_limit))
+ alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
+
+ if (alpha < 0.0 || 1.0 < alpha)
+ alpha = 1.0;
+ else if (alpha < alpha_min && alpha_min <= 1.0)
+ alpha = alpha_min;
+
+ opac = alpha * OPAQUE_FRAME;
+
+ ex_style = GetWindowLong (window, GWL_EXSTYLE);
+
+ if (opac == OPAQUE_FRAME)
+ ex_style &= ~WS_EX_LAYERED;
+ else
+ ex_style |= WS_EX_LAYERED;
+
+ SetWindowLong (window, GWL_EXSTYLE, ex_style);
+
+ if (opac != OPAQUE_FRAME)
+ pfnSetLayeredWindowAttributes (window, 0, opac, LWA_ALPHA);
+}
+
\f
/***********************************************************************
Starting and ending an update
if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
|| s->font_not_found_p
|| s->extends_to_end_of_line_p
- || FONT_COMPAT (s->font)->bdf
|| cleartype_active
|| force_p)
{
struct glyph_string *s;
{
int i, x;
- HFONT old_font;
/* If first glyph of S has a left box line, start drawing the text
of S to the right of that box line. */
else
x = s->x;
- if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR)
- || cleartype_active)
- SetBkMode (s->hdc, TRANSPARENT);
- else
- SetBkMode (s->hdc, OPAQUE);
-
SetTextColor (s->hdc, s->gc->foreground);
SetBkColor (s->hdc, s->gc->background);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- if (s->font && FONT_COMPAT (s->font)->hfont)
- old_font = SelectObject (s->hdc, FONT_COMPAT (s->font)->hfont);
-
/* Draw characters of S as rectangles if S's font could not be
loaded. */
if (s->font_not_found_p)
}
else
{
- int boff = s->font->baseline_offset;
struct font *font = s->font;
+ int boff = font->baseline_offset;
int y;
+ HFONT old_font;
- if (s->font->vertical_centering)
- boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff;
+ old_font = SelectObject (s->hdc, FONT_HANDLE (font));
+
+ if (font->vertical_centering)
+ boff = VCENTER_BASELINE_OFFSET (font, s->f) - boff;
y = s->ybase - boff;
if (s->for_overlaps
font->driver->draw (s, 0, s->nchars, x, y, 1);
if (s->face->overstrike)
font->driver->draw (s, 0, s->nchars, x + 1, y, 0);
- }
- if (s->font && FONT_COMPAT (s->font)->hfont)
- SelectObject (s->hdc, old_font);
+ SelectObject (s->hdc, old_font);
+ }
}
/* Draw the foreground of composite glyph string S. */
struct glyph_string *s;
{
int i, j, x;
- HFONT old_font;
/* If first glyph of S has a left box line, start drawing the text
of S to the right of that box line. */
SetTextColor (s->hdc, s->gc->foreground);
SetBkColor (s->hdc, s->gc->background);
- SetBkMode (s->hdc, TRANSPARENT);
SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
- if (s->font && FONT_COMPAT (s->font)->hfont)
- old_font = SelectObject (s->hdc, FONT_COMPAT (s->font)->hfont);
-
/* Draw a rectangle for the composition if the font for the very
first character of the composition could not be loaded. */
if (s->font_not_found_p)
w32_draw_rectangle (s->hdc, s->gc, x, s->y, s->width - 1,
s->height - 1);
}
-
+ else
{
struct font *font = s->font;
int y = s->ybase;
int width = 0;
+ HFONT old_font;
+
+ old_font = SelectObject (s->hdc, FONT_HANDLE (font));
if (s->cmp->method == COMPOSITION_WITH_GLYPH_STRING)
{
font->driver->draw (s, j, j + 1, xx + 1, yy, 0);
}
}
+ SelectObject (s->hdc, old_font);
}
-
- if (s->font && FONT_COMPAT (s->font)->hfont)
- SelectObject (s->hdc, old_font);
}
/* Draw strike-through. */
if (s->face->strike_through_p
- && (FONT_COMPAT (s->font)->bdf
- || !FONT_COMPAT (s->font)->tm.tmStruckOut))
+ && !FONT_TEXTMETRIC(s->font).tmStruckOut)
{
unsigned long h = 1;
unsigned long dy = (s->height - h) / 2;
struct frame *f;
{
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
static void
struct frame *f;
{
x_update_cursor (f, 1);
+ x_set_frame_alpha (f);
}
/* The focus has changed. Update the frames as necessary to reflect
resize will happen asynchronously. But on Windows, the menu bar
automatically wraps when the frame is too narrow to contain it,
and that causes any calculations made here to come out wrong. The
- end is some nasty buggy behaviour, including the potential loss
+ end is some nasty buggy behavior, including the potential loss
of the minibuffer.
Disabling this code is either not sufficient to fix the problems
BLOCK_INPUT;
/* Strictly speaking, raise-frame should only change the frame's Z
- order, leaving input focus unchanged. This is reasonable behaviour
+ order, leaving input focus unchanged. This is reasonable behavior
on X where the usual policy is point-to-focus. However, this
- behaviour would be very odd on Windows where the usual policy is
+ behavior would be very odd on Windows where the usual policy is
click-to-focus.
On X, if the mouse happens to be over the raised frame, it gets
UINT smoothing_type;
BOOL smoothing_enabled;
- HANDLE gdi_lib = LoadLibrary ("gdi32.dll");
+ HANDLE user_lib = LoadLibrary ("user32.dll");
#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn)
- LOAD_PROC (gdi_lib, GetFontUnicodeRanges);
+ LOAD_PROC (user_lib, SetLayeredWindowAttributes);
#undef LOAD_PROC
- FreeLibrary (gdi_lib);
+ FreeLibrary (user_lib);
/* Ensure scrollbar handle is at least 5 pixels. */
vertical_scroll_bar_min_handle = 5;