comparison src/w32term.c @ 96403:4b6d1b55f59c

* 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.
author Jason Rumney <jasonr@gnu.org>
date Sat, 28 Jun 2008 23:54:27 +0000
parents c3309dba6542
children 0b2f64a1ff6e
comparison
equal deleted inserted replaced
96402:7f88a1df4a80 96403:4b6d1b55f59c
137 WCRANGE ranges[1]; 137 WCRANGE ranges[1];
138 } GLYPHSET; 138 } GLYPHSET;
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). */
143 DWORD (PASCAL *pfnGetFontUnicodeRanges) (HDC device, GLYPHSET *ranges); 143 BOOL (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
147 w32 functions. It is zero while not inside an update. 151 w32 functions. It is zero while not inside an update.
148 In that case, the w32 functions assume that `SELECTED_FRAME ()' 152 In that case, the w32 functions assume that `SELECTED_FRAME ()'
410 } 414 }
411 415
412 release_frame_dc (f, hdc); 416 release_frame_dc (f, hdc);
413 } 417 }
414 418
419 #define OPAQUE_FRAME 255
420
421 void
422 x_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
418 ***********************************************************************/ 469 ***********************************************************************/
419 470
2614 static void 2665 static void
2615 frame_highlight (f) 2666 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
2621 static void 2673 static void
2622 frame_unhighlight (f) 2674 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
2629 the new situation. Note that we can't change the selected frame 2682 the new situation. Note that we can't change the selected frame
2630 here, because the Lisp code we are interrupting might become confused. 2683 here, because the Lisp code we are interrupting might become confused.
6289 /* Dynamically link to optional system components. */ 6342 /* Dynamically link to optional system components. */
6290 { 6343 {
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;
6306 6359
6307 /* For either kind of scroll bar, take account of the arrows; these 6360 /* For either kind of scroll bar, take account of the arrows; these