diff options
| author | Glenn Morris | 2008-05-21 03:59:44 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-05-21 03:59:44 +0000 |
| commit | 4a59a6c0154e17f5df4b6f32f012d61acaaf31eb (patch) | |
| tree | e792e1c2ad360477d859b0f8c27228b6eea8d212 /src | |
| parent | 271a71c732275dc7b7eb58910c72a9a037f5827b (diff) | |
| download | emacs-4a59a6c0154e17f5df4b6f32f012d61acaaf31eb.tar.gz emacs-4a59a6c0154e17f5df4b6f32f012d61acaaf31eb.zip | |
Seiji Zenitani <zenitani at mac.com>
Ryo Yoshitake <ryo at shiftmode.net>
(x_set_frame_alpha): Add function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c index 7590d2ee7ce..a02c7b955c8 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -457,6 +457,67 @@ x_display_info_for_display (dpy) | |||
| 457 | return 0; | 457 | return 0; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | #define OPAQUE 0xffffffff | ||
| 461 | #define OPACITY "_NET_WM_WINDOW_OPACITY" | ||
| 462 | |||
| 463 | void | ||
| 464 | x_set_frame_alpha (f) | ||
| 465 | struct frame *f; | ||
| 466 | { | ||
| 467 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 468 | Display *dpy = FRAME_X_DISPLAY (f); | ||
| 469 | Window win = FRAME_OUTER_WINDOW (f); | ||
| 470 | if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc) | ||
| 471 | /* Since the WM decoration lies under the FRAME_OUTER_WINDOW, | ||
| 472 | we must treat the former instead of the latter. */ | ||
| 473 | win = FRAME_X_OUTPUT(f)->parent_desc; | ||
| 474 | |||
| 475 | double alpha = 1.0, alpha_min = 1.0; | ||
| 476 | |||
| 477 | if (dpyinfo->x_highlight_frame == f) | ||
| 478 | alpha = f->alpha[0]; | ||
| 479 | else | ||
| 480 | alpha = f->alpha[1]; | ||
| 481 | |||
| 482 | if (FLOATP (Vframe_alpha_lower_limit)) | ||
| 483 | alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit); | ||
| 484 | else if (INTEGERP (Vframe_alpha_lower_limit)) | ||
| 485 | alpha_min = (XINT (Vframe_alpha_lower_limit)) / 100.0; | ||
| 486 | |||
| 487 | if (alpha < 0.0 || 1.0 < alpha) | ||
| 488 | alpha = 1.0; | ||
| 489 | else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0) | ||
| 490 | alpha = alpha_min; | ||
| 491 | |||
| 492 | unsigned int opac = (unsigned int)(alpha * OPAQUE); | ||
| 493 | |||
| 494 | /* return unless necessary */ | ||
| 495 | { | ||
| 496 | unsigned char *data; | ||
| 497 | Atom actual; | ||
| 498 | int format; | ||
| 499 | unsigned long n, left; | ||
| 500 | |||
| 501 | XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False), | ||
| 502 | 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, | ||
| 503 | (unsigned char **) &data); | ||
| 504 | if (data != None) | ||
| 505 | if (*(unsigned int *)data == opac) | ||
| 506 | { | ||
| 507 | XFree ((void *) data); | ||
| 508 | return; | ||
| 509 | } | ||
| 510 | else | ||
| 511 | { | ||
| 512 | XFree ((void *) data); | ||
| 513 | } | ||
| 514 | } | ||
| 515 | |||
| 516 | XChangeProperty (dpy, win, XInternAtom (dpy, OPACITY, False), | ||
| 517 | XA_CARDINAL, 32, PropModeReplace, | ||
| 518 | (unsigned char *) &opac, 1L); | ||
| 519 | XSync (dpy, False); | ||
| 520 | } | ||
| 460 | 521 | ||
| 461 | 522 | ||
| 462 | /*********************************************************************** | 523 | /*********************************************************************** |
| @@ -3171,6 +3232,7 @@ frame_highlight (f) | |||
| 3171 | f->output_data.x->border_pixel); | 3232 | f->output_data.x->border_pixel); |
| 3172 | UNBLOCK_INPUT; | 3233 | UNBLOCK_INPUT; |
| 3173 | x_update_cursor (f, 1); | 3234 | x_update_cursor (f, 1); |
| 3235 | x_set_frame_alpha (f); | ||
| 3174 | } | 3236 | } |
| 3175 | 3237 | ||
| 3176 | static void | 3238 | static void |
| @@ -3186,6 +3248,7 @@ frame_unhighlight (f) | |||
| 3186 | f->output_data.x->border_tile); | 3248 | f->output_data.x->border_tile); |
| 3187 | UNBLOCK_INPUT; | 3249 | UNBLOCK_INPUT; |
| 3188 | x_update_cursor (f, 1); | 3250 | x_update_cursor (f, 1); |
| 3251 | x_set_frame_alpha (f); | ||
| 3189 | } | 3252 | } |
| 3190 | 3253 | ||
| 3191 | /* The focus has changed. Update the frames as necessary to reflect | 3254 | /* The focus has changed. Update the frames as necessary to reflect |