diff options
| author | Jason Rumney | 2008-06-28 23:54:27 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-06-28 23:54:27 +0000 |
| commit | 8b61a891130e081faa91a897e17c4cc26efdfb41 (patch) | |
| tree | 1b4e5d6394798a8ee63412eb9be75f724d8acd20 | |
| parent | a7d545207891622ea4a90de96b994bf10d25ab3c (diff) | |
| download | emacs-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.
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/frame.c | 2 | ||||
| -rw-r--r-- | src/w32fns.c | 4 | ||||
| -rw-r--r-- | src/w32term.c | 63 |
4 files changed, 74 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 85931f7abd1..df8c4b524be 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2008-06-28 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32term.c (pfnGetFontUnicodeRanges): Remove unused function pointer. | ||
| 4 | (pfnSetLayeredWindowAttributes): New function pointer. | ||
| 5 | (w32_initialize): Initialize it when supported. | ||
| 6 | (x_set_frame_alpha): New function. | ||
| 7 | |||
| 8 | * w32fns.c (Fx_create_frame): Initialize frame parameter `alpha'. | ||
| 9 | (w32_frame_parm_handlers): Set alpha handler. | ||
| 10 | |||
| 11 | * frame.c (x_set_alpha) [HAVE_NTGUI]: Call x_set_frame_alpha. | ||
| 12 | |||
| 1 | 2008-06-27 Jason Rumney <jasonr@gnu.org> | 13 | 2008-06-27 Jason Rumney <jasonr@gnu.org> |
| 2 | 14 | ||
| 3 | * w32fns.c (x_to_w32_font, w32_to_x_font, x_to_w32_weight) | 15 | * w32fns.c (x_to_w32_font, w32_to_x_font, x_to_w32_weight) |
diff --git a/src/frame.c b/src/frame.c index 6320d0ca1ff..a7f22fad6a9 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -3692,7 +3692,7 @@ x_set_alpha (f, arg, oldval) | |||
| 3692 | for (i = 0; i < 2; i++) | 3692 | for (i = 0; i < 2; i++) |
| 3693 | f->alpha[i] = newval[i]; | 3693 | f->alpha[i] = newval[i]; |
| 3694 | 3694 | ||
| 3695 | #ifdef HAVE_X_WINDOWS | 3695 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| 3696 | BLOCK_INPUT; | 3696 | BLOCK_INPUT; |
| 3697 | x_set_frame_alpha (f); | 3697 | x_set_frame_alpha (f); |
| 3698 | UNBLOCK_INPUT; | 3698 | UNBLOCK_INPUT; |
diff --git a/src/w32fns.c b/src/w32fns.c index 2a042717ac1..c9a9a5ab359 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -4521,6 +4521,8 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 4521 | "cursorType", "CursorType", RES_TYPE_SYMBOL); | 4521 | "cursorType", "CursorType", RES_TYPE_SYMBOL); |
| 4522 | x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, | 4522 | x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, |
| 4523 | "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); | 4523 | "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); |
| 4524 | x_default_parameter (f, parameters, Qalpha, Qnil, | ||
| 4525 | "alpha", "Alpha", RES_TYPE_NUMBER); | ||
| 4524 | 4526 | ||
| 4525 | /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. | 4527 | /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. |
| 4526 | Change will not be effected unless different from the current | 4528 | Change will not be effected unless different from the current |
| @@ -6883,7 +6885,7 @@ frame_parm_handler w32_frame_parm_handlers[] = | |||
| 6883 | 0, /* x_set_wait_for_wm, */ | 6885 | 0, /* x_set_wait_for_wm, */ |
| 6884 | x_set_fullscreen, | 6886 | x_set_fullscreen, |
| 6885 | x_set_font_backend, | 6887 | x_set_font_backend, |
| 6886 | 0 /* x_set_alpha, */ | 6888 | x_set_alpha |
| 6887 | }; | 6889 | }; |
| 6888 | 6890 | ||
| 6889 | void | 6891 | void |
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). */ |
| 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 |
| @@ -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 | |||
| 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 |
| @@ -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 | ||
| 2621 | static void | 2673 | static 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; |