aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorJason Rumney2008-06-28 23:54:27 +0000
committerJason Rumney2008-06-28 23:54:27 +0000
commit8b61a891130e081faa91a897e17c4cc26efdfb41 (patch)
tree1b4e5d6394798a8ee63412eb9be75f724d8acd20 /src/w32term.c
parenta7d545207891622ea4a90de96b994bf10d25ab3c (diff)
downloademacs-8b61a891130e081faa91a897e17c4cc26efdfb41.tar.gz
emacs-8b61a891130e081faa91a897e17c4cc26efdfb41.zip
* w32term.c (pfnGetFontUnicodeRanges): Remove unused function pointer.
(pfnSetLayeredWindowAttributes): New function pointer. (w32_initialize): Initialize it when supported. (x_set_frame_alpha): New function. * w32fns.c (Fx_create_frame): Initialize frame parameter `alpha'. (w32_frame_parm_handlers): Set alpha handler. * frame.c (x_set_alpha) [HAVE_NTGUI]: Call x_set_frame_alpha.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 52c78b0558a..65028f75013 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -139,8 +139,12 @@ typedef struct tagGLYPHSET
139 139
140#endif 140#endif
141 141
142/* Dynamic linking to GetFontUnicodeRanges (not available on 95, 98, ME). */ 142/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
143DWORD (PASCAL *pfnGetFontUnicodeRanges) (HDC device, GLYPHSET *ranges); 143BOOL (PASCAL *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
144
145#ifndef LWA_ALPHA
146#define LWA_ALPHA 0x02
147#endif
144 148
145/* Frame being updated by update_frame. This is declared in term.c. 149/* Frame being updated by update_frame. This is declared in term.c.
146 This is set by update_begin and looked at by all the 150 This is set by update_begin and looked at by all the
@@ -412,6 +416,53 @@ w32_clear_window (f)
412 release_frame_dc (f, hdc); 416 release_frame_dc (f, hdc);
413} 417}
414 418
419#define OPAQUE_FRAME 255
420
421void
422x_set_frame_alpha (f)
423 struct frame *f;
424{
425 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
426 double alpha = 1.0;
427 double alpha_min = 1.0;
428 BYTE opac;
429 LONG ex_style;
430 HWND window = FRAME_W32_WINDOW (f);
431
432 /* Older versions of Windows do not support transparency. */
433 if (!pfnSetLayeredWindowAttributes)
434 return;
435
436 if (dpyinfo->x_highlight_frame == f)
437 alpha = f->alpha[0];
438 else
439 alpha = f->alpha[1];
440
441 if (FLOATP (Vframe_alpha_lower_limit))
442 alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
443 else if (INTEGERP (Vframe_alpha_lower_limit))
444 alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0;
445
446 if (alpha < 0.0 || 1.0 < alpha)
447 alpha = 1.0;
448 else if (alpha < alpha_min && alpha_min <= 1.0)
449 alpha = alpha_min;
450
451 opac = alpha * OPAQUE_FRAME;
452
453 ex_style = GetWindowLong (window, GWL_EXSTYLE);
454
455 if (opac == OPAQUE_FRAME)
456 ex_style ^= WS_EX_LAYERED;
457 else
458 ex_style |= WS_EX_LAYERED;
459
460 SetWindowLong (window, GWL_EXSTYLE, ex_style);
461
462 if (opac != OPAQUE_FRAME)
463 pfnSetLayeredWindowAttributes (window, 0, opac, LWA_ALPHA);
464}
465
415 466
416/*********************************************************************** 467/***********************************************************************
417 Starting and ending an update 468 Starting and ending an update
@@ -2616,6 +2667,7 @@ frame_highlight (f)
2616 struct frame *f; 2667 struct frame *f;
2617{ 2668{
2618 x_update_cursor (f, 1); 2669 x_update_cursor (f, 1);
2670 x_set_frame_alpha (f);
2619} 2671}
2620 2672
2621static void 2673static void
@@ -2623,6 +2675,7 @@ frame_unhighlight (f)
2623 struct frame *f; 2675 struct frame *f;
2624{ 2676{
2625 x_update_cursor (f, 1); 2677 x_update_cursor (f, 1);
2678 x_set_frame_alpha (f);
2626} 2679}
2627 2680
2628/* The focus has changed. Update the frames as necessary to reflect 2681/* The focus has changed. Update the frames as necessary to reflect
@@ -6291,15 +6344,15 @@ w32_initialize ()
6291 UINT smoothing_type; 6344 UINT smoothing_type;
6292 BOOL smoothing_enabled; 6345 BOOL smoothing_enabled;
6293 6346
6294 HANDLE gdi_lib = LoadLibrary ("gdi32.dll"); 6347 HANDLE user_lib = LoadLibrary ("user32.dll");
6295 6348
6296#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn) 6349#define LOAD_PROC(lib, fn) pfn##fn = (void *) GetProcAddress (lib, #fn)
6297 6350
6298 LOAD_PROC (gdi_lib, GetFontUnicodeRanges); 6351 LOAD_PROC (user_lib, SetLayeredWindowAttributes);
6299 6352
6300#undef LOAD_PROC 6353#undef LOAD_PROC
6301 6354
6302 FreeLibrary (gdi_lib); 6355 FreeLibrary (user_lib);
6303 6356
6304 /* Ensure scrollbar handle is at least 5 pixels. */ 6357 /* Ensure scrollbar handle is at least 5 pixels. */
6305 vertical_scroll_bar_min_handle = 5; 6358 vertical_scroll_bar_min_handle = 5;